Mixing script and standlone tests didn't mix well with the
strict i915_ring_stop flags handling. Also squash drv_missed_irq_hang
to the new test.
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=78322
Suggested-by: Daniel Vetter daniel.vet...@ffwll.ch
Signed-off-by: Mika Kuoppala mika.kuopp...@intel.com
---
tests/Makefile.sources|3 +-
tests/drv_hangman | 70 -
tests/drv_hangman.c | 357 +
tests/drv_missed_irq_hang | 70 -
4 files changed, 358 insertions(+), 142 deletions(-)
delete mode 100755 tests/drv_hangman
create mode 100644 tests/drv_hangman.c
delete mode 100755 tests/drv_missed_irq_hang
diff --git a/tests/Makefile.sources b/tests/Makefile.sources
index fbf63e9..9f5cd76 100644
--- a/tests/Makefile.sources
+++ b/tests/Makefile.sources
@@ -17,6 +17,7 @@ NOUVEAU_TESTS_M = \
TESTS_progs_M = \
core_get_client_auth \
drv_suspend \
+ drv_hangman \
gem_bad_reloc \
gem_basic \
gem_caching \
@@ -148,8 +149,6 @@ TESTS_scripts_M = \
TESTS_scripts = \
debugfs_emon_crash \
drv_debugfs_reader \
- drv_hangman \
- drv_missed_irq_hang \
drv_module_reload \
kms_sysfs_edid_timing \
sysfs_l3_parity \
diff --git a/tests/drv_hangman b/tests/drv_hangman
deleted file mode 100755
index 6b310bc..000
--- a/tests/drv_hangman
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/bin/bash
-#
-# Testcase: Simulate gpu hang
-#
-# This check uses the stop_rings facility to exercise the gpu hang code.
-# by reading /sys/kernel/debug/dri/0/i915_emon_status too quickly
-#
-
-SOURCE_DIR=$( dirname ${BASH_SOURCE[0]} )
-. $SOURCE_DIR/drm_lib.sh
-
-oldpath=`pwd`
-
-cd $i915_dfs_path
-
-if [ ! -f i915_ring_stop ] ; then
- echo kernel doesn't support ring stopping
- exit 77
-fi
-
-function check_iface {
-dir=$1
-file=$2
-mandatory=$3
-
-[ -z $dir ] return
-
-path=$dir/$file
-echo checking ${path}
-
-if [ ! -f $path ] ; then
- if [ $mandatory != 0 ] ; then
- echo '${path}' not found;
- exit 1;
- else
- echo ${path} not mandatory;
- return;
- fi
-fi
-
-if cat $path | grep -v no error state collected /dev/null ; then
- echo gpu hang detected
- exit 2
-fi
-
-echo 0xf i915_ring_stop
-echo rings stopped
-
-(cd $oldpath; $SOURCE_DIR/gem_exec_big) /dev/null
-
-if cat $path | grep -v no error state collected /dev/null ; then
- echo gpu hang correctly detected
-else
- echo gpu hang not detected
- exit 3
-fi
-
-# clear error state
-echo $path
-
-if cat $path | grep -v no error state collected /dev/null ; then
- echo gpu hang still present
- exit 4
-fi
-}
-
-check_iface $i915_dfs_path i915_error_state 1
-check_iface $i915_sfs_path error 0
-
-exit 0
diff --git a/tests/drv_hangman.c b/tests/drv_hangman.c
new file mode 100644
index 000..cf141c6
--- /dev/null
+++ b/tests/drv_hangman.c
@@ -0,0 +1,357 @@
+/*
+ * Copyright © 2014 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the Software),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ * Authors:
+ *Mika Kuoppala mika.kuopp...@intel.com
+ *
+ */
+
+#include limits.h
+#include sys/types.h
+#include sys/stat.h
+#include fcntl.h
+
+#include drmtest.h
+#include igt_debugfs.h
+#include ioctl_wrappers.h
+
+static int _read_sysfs(void *dst, int maxlen,
+ const char* path,
+ const char *fname)
+{
+ int fd;
+ char full[PATH_MAX];
+ int r, e;
+
+ igt_assert(snprintf(full, PATH_MAX, %s/%s, path, fname) PATH_MAX);
+
+ fd = open(full, O_RDONLY);
+ if (fd == -1)
+ return -errno;
+
+ r = read(fd, dst, maxlen);
+ e = errno;
+ close(fd);
+
+ if (r 0)
+ return -e;
+
+ return r;
+}
+
+static