Skip to contentSkip to conversation

lib: igt_fork_hang_helper must be run in fixtures

PATCH In review Daniel Vetter 4 participants 10 messages Dec 3, 2015 – Dec 4, 2015 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 lib: igt_fork_hang_helper must be run in fixtures

Because it opens an intel-specific drm fd. Fixes crashes when running igt on no-intel.

---
 lib/igt_gt.c                 | 23 ++++++-----------------
 lib/igt_gt.h                 |  2 +-
 tests/gem_evict_alignment.c  | 26 +++++++++++++-------------
 tests/gem_evict_everything.c | 36 ++++++++++++++++++------------------
 4 files changed, 38 insertions(+), 49 deletions(-)
lib/igt_gt.c +6 -17
index 69cf3654f207..688ea5e6de38 100644
@@ -190,31 +190,22 @@ hang_helper_process(pid_t pid, int fd)
  * This is useful to exercise slow running code (such as aperture placement)
  * which needs to be robust against a GPU reset.
  *
- * In tests with subtests this function can be called outside of failure
- * catching code blocks like #igt_fixture or #igt_subtest.
+ * This function automatically skips when test requirements aren't met using
+ * igt_skip().
  */
-int igt_fork_hang_helper(void)
+void igt_fork_hang_helper(void)
 {
 	int fd, gen;
 
-	if (igt_only_list_subtests())
-		return 1;
-
 	fd = drm_open_driver(DRIVER_INTEL);
-	if (fd == -1)
-		return 0;
 
 	gen = intel_gen(intel_get_drm_devid(fd));
-	if (gen < 5) {
-		close(fd);
-		return 0;
-	}
+	igt_skip_on(gen < 5);
 
 	igt_fork_helper(&hang_helper)
 		hang_helper_process(getppid(), fd);
 
 	close(fd);
-	return 1;
 }
 
 /**
@@ -227,10 +218,8 @@ int igt_fork_hang_helper(void)
  */
 void igt_stop_hang_helper(void)
 {
-	if (igt_only_list_subtests())
-		return;
-
-	igt_stop_helper(&hang_helper);
+	if (hang_helper.running)
+		igt_stop_helper(&hang_helper);
 }
 
 /**
lib/igt_gt.h +1 -1
index 510542339c44..b70bbd155a35 100644
@@ -36,7 +36,7 @@ typedef struct igt_hang_ring {
 struct igt_hang_ring igt_hang_ring(int fd, int ring);
 void igt_post_hang_ring(int fd, struct igt_hang_ring arg);
 
-int igt_fork_hang_helper(void);
+void igt_fork_hang_helper(void);
 void igt_stop_hang_helper(void);
 
 int igt_open_forcewake_handle(void);
tests/gem_evict_alignment.c +13 -13
index 2c0d261df0d0..14b861628516 100644
@@ -220,22 +220,22 @@ igt_main
 		major_evictions(fd, size, count);
 	}
 
-	if (igt_fork_hang_helper()) {
-		igt_subtest("minor-hang") {
-			size = 1024 * 1024;
-			count = 3*gem_aperture_size(fd) / size / 4;
-			minor_evictions(fd, size, count);
-		}
+	igt_subtest("minor-hang") {
+		igt_fork_hang_helper();
+		size = 1024 * 1024;
+		count = 3*gem_aperture_size(fd) / size / 4;
+		minor_evictions(fd, size, count);
+	}
 
-		igt_subtest("major-hang") {
-			size = 3*gem_aperture_size(fd) / 4;
-			count = 4;
-			major_evictions(fd, size, count);
-		}
-		igt_stop_hang_helper();
+	igt_subtest("major-hang") {
+		size = 3*gem_aperture_size(fd) / 4;
+		count = 4;
+		major_evictions(fd, size, count);
 	}
 	igt_stop_signal_helper();
 
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_helper();
 		close(fd);
+	}
 }
tests/gem_evict_everything.c +18 -18
index ebf59f9090e4..db6c333b1915 100644
@@ -243,32 +243,32 @@ igt_main
 		test_major_evictions(fd, size, count);
 	}
 
-	if (igt_fork_hang_helper()) {
-		igt_fixture {
-			size = 1024 * 1024;
-			count = 3*gem_aperture_size(fd) / size / 4;
-		}
+	igt_fixture {
+		igt_fork_hang_helper();
 
-		igt_subtest("mlocked-hang")
-			test_mlocked_evictions(fd, size, count);
+		size = 1024 * 1024;
+		count = 3*gem_aperture_size(fd) / size / 4;
+	}
 
-		igt_subtest("swapping-hang")
-			test_swapping_evictions(fd, size, count);
+	igt_subtest("mlocked-hang")
+		test_mlocked_evictions(fd, size, count);
 
-		igt_subtest("minor-hang")
-			test_minor_evictions(fd, size, count);
+	igt_subtest("swapping-hang")
+		test_swapping_evictions(fd, size, count);
 
-		igt_subtest("major-hang") {
-			size = 3*gem_aperture_size(fd) / 4;
-			count = 4;
-			test_major_evictions(fd, size, count);
-		}
+	igt_subtest("minor-hang")
+		test_minor_evictions(fd, size, count);
 
-		igt_stop_hang_helper();
+	igt_subtest("major-hang") {
+		size = 3*gem_aperture_size(fd) / 4;
+		count = 4;
+		test_major_evictions(fd, size, count);
 	}
-	igt_stop_signal_helper();
+
+	igt_stop_hang_helper();
 
 	igt_fixture {
+		igt_stop_signal_helper();
 		close(fd);
 	}
 }
Signature · 6 lines
2.5.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 2/3 tests/drm_lib.sh: Skip when i915 debugfs wasn't found

Instead of failing. We might want to move this into i915 tests eventually, but this is good for now.

---
 tests/drm_lib.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/drm_lib.sh +6 -1
index c50664c7730d..e7ec4a1cfcb5 100755
@@ -28,6 +28,11 @@ for arg in $@ ; do
 	esac
 done
 
+skip() {
+	echo "$@"
+	exit 1
+}
+
 die() {
 	echo "$@"
 	exit 1
@@ -54,7 +59,7 @@ for minor in `seq 0 16`; do
 done
 
 if [ $i915_dfs_path = "x" ] ; then
-	die " i915 debugfs path not found."
+	skip " i915 debugfs path not found."
 fi
 
 # read everything we can
Signature · 6 lines
2.5.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH i-g-t 2/3] tests/drm_lib.sh: Skip when i915 debugfs wasn't found

Quoted 13 lines · Daniel Vetter

Instead of failing. We might want to move this into i915 tests eventually, but this is good for now.

---
 tests/drm_lib.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/drm_lib.sh +0 -0
index c50664c7730d..e7ec4a1cfcb5 100755

tests/drm_lib.sh for arg in $@ ; do · line 33

Quoted 6 lines
tests/drm_lib.sh +3 -0
@@ -28,6 +28,11 @@ for arg in $@ ; do
        esac
 done
 
+skip() {
+       echo "$@"
+       exit 1

Shouldn't this be 77 to indicate skip?

Quoted 17 lines
tests/drm_lib.sh +3 -2
+}
+
 die() {
        echo "$@"
        exit 1
@@ -54,7 +59,7 @@ for minor in `seq 0 16`; do
 done
 
 if [ $i915_dfs_path = "x" ] ; then
-       die " i915 debugfs path not found."
+       skip " i915 debugfs path not found."
 fi
 
 # read everything we can
--

2.5.1

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

Re: [PATCH i-g-t 2/3] tests/drm_lib.sh: Skip when i915 debugfs wasn't found

Quoted 26 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Thomas Wood
Sent: Thursday, December 3, 2015 10:08 AM
To: Daniel Vetter
Cc: Intel Graphics Development
Subject: Re: [Intel-gfx] [PATCH i-g-t 2/3] tests/drm_lib.sh: Skip when i915 debugfs wasn't found

Quoted 16 lines · Daniel Vetter

Instead of failing. We might want to move this into i915 tests eventually, but this is good for now.

---
 tests/drm_lib.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/drm_lib.sh index renamed from tests/drm_lib.sh +0 -0

c50664c7730d..e7ec4a1cfcb5 100755

tests/drm_lib.sh +0 -0
@@ -28,6 +28,11 @@ for arg in $@ ; do
        esac
 done
 
Quoted 5 lines

tests/drm_lib.sh for arg in $@ ; do · line 33

Quoted 3 lines
tests/drm_lib.sh +3 -0
+skip() {
+       echo "$@"
+       exit 1

Shouldn't this be 77 to indicate skip?

Why have hard coded values at all? IGT_EXIT_SKIP is already defined as the value returned when a test skips. The code is more maintainable if fixed values are only defined in 1 place.

//Derek

Quoted 18 lines
Quoted 18 lines
tests/drm_lib.sh +3 -2
+}
+
 die() {
        echo "$@"
        exit 1
@@ -54,7 +59,7 @@ for minor in `seq 0 16`; do  done
 
 if [ $i915_dfs_path = "x" ] ; then
-       die " i915 debugfs path not found."
+       skip " i915 debugfs path not found."
 fi
 
 # read everything we can
--

2.5.1

Quoted 9 lines
Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

Re: [PATCH i-g-t 2/3] tests/drm_lib.sh: Skip when i915 debugfs wasn't found

Quoted 26 lines · Derek J
Quoted 26 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Thomas Wood
Sent: Thursday, December 3, 2015 10:08 AM
To: Daniel Vetter
Cc: Intel Graphics Development
Subject: Re: [Intel-gfx] [PATCH i-g-t 2/3] tests/drm_lib.sh: Skip when i915 debugfs wasn't found

Quoted 16 lines · Daniel Vetter

Instead of failing. We might want to move this into i915 tests eventually, but this is good for now.

---
 tests/drm_lib.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
tests/drm_lib.sh index renamed from tests/drm_lib.sh +0 -0

c50664c7730d..e7ec4a1cfcb5 100755

tests/drm_lib.sh +0 -0
@@ -28,6 +28,11 @@ for arg in $@ ; do
        esac
 done
 
Quoted 7 lines
Quoted 5 lines

tests/drm_lib.sh for arg in $@ ; do · line 33

Quoted 3 lines
tests/drm_lib.sh +3 -0
+skip() {
+       echo "$@"
+       exit 1

Shouldn't this be 77 to indicate skip?

Why have hard coded values at all? IGT_EXIT_SKIP is already defined as the value returned when a test skips. The code is more maintainable if fixed values are only defined in 1 place.

These aren't actually defined for the shell scripts, but it would probably be a good idea to do so for the reason you mention.

Quoted 30 lines

//Derek

Quoted 27 lines
Quoted 18 lines
tests/drm_lib.sh +3 -2
+}
+
 die() {
        echo "$@"
        exit 1
@@ -54,7 +59,7 @@ for minor in `seq 0 16`; do  done
 
 if [ $i915_dfs_path = "x" ] ; then
-       die " i915 debugfs path not found."
+       skip " i915 debugfs path not found."
 fi
 
 # read everything we can
--

2.5.1

Quoted 4 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

PATCH 1/1 tests: add exit value constants for shell script tests

---
 tests/check_drm_clients       |  2 +-
 tests/debugfs_emon_crash      |  2 +-
 tests/drm_lib.sh              | 22 ++++++++++++++--------
 tests/drv_debugfs_reader      |  2 +-
 tests/drv_missed_irq_hang     | 14 +++++++-------
 tests/drv_module_reload_basic |  8 ++++----
 tests/kms_sysfs_edid_timing   |  4 ++--
 tests/sysfs_l3_parity         |  6 +++---
 tests/test_rte_check          |  2 +-
 tests/tools_test              |  2 +-
 10 files changed, 35 insertions(+), 29 deletions(-)
tests/check_drm_clients +1 -1
index eb12416..2a891b8 100755
@@ -3,4 +3,4 @@
 SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 . $SOURCE_DIR/drm_lib.sh
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/debugfs_emon_crash +1 -1
index 809bfab..1dbfcb2 100755
@@ -13,4 +13,4 @@ done
 
 # If we got here, we haven't crashed
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drm_lib.sh +14 -8
index c50664c..d2c6420 100755
@@ -1,20 +1,26 @@
 #!/bin/sh
 
+IGT_EXIT_TIMEOUT=78
+IGT_EXIT_SKIP=77
+IGT_EXIT_SUCCESS=0
+IGT_EXIT_INVALID=79
+IGT_EXIT_FAILURE=99
+
 # hacked-up long option parsing
 for arg in $@ ; do
 	case $arg in
 		--list-subtests)
-			exit 79
+			exit $IGT_EXIT_INVALID
 			;;
 		--run-subtest)
-			exit 79
+			exit $IGT_EXIT_INVALID
 			;;
 		--debug)
 			IGT_LOG_LEVEL=debug
 			;;
 		--help-description)
 			echo $IGT_TEST_DESCRIPTION
-			exit 0
+			exit $IGT_EXIT_SUCCESS
 			;;
 		--help)
 			echo "Usage: `basename $0` [OPTIONS]"
@@ -23,18 +29,18 @@ for arg in $@ ; do
 			echo "  --debug"
 			echo "  --help-description"
 			echo "  --help"
-			exit 0
+			exit $IGT_EXIT_SUCCESS
 			;;
 	esac
 done
 
 die() {
 	echo "$@"
-	exit 1
+	exit $IGT_EXIT_FAILURE
 }
 
 do_or_die() {
-	$@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit -1)
+	$@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit $IGT_EXIT_FAILURE)
 }
 
 if [ -d /debug/dri ] ; then
@@ -63,7 +69,7 @@ if [ `cat $i915_dfs_path/clients | wc -l` -gt "2" ] ; then
 		die "ERROR: other drm clients running"
 fi
 
-whoami | grep -q root || ( echo ERROR: not running as root; exit 1 )
+whoami | grep -q root || ( echo ERROR: not running as root; exit $IGT_EXIT_FAILURE )
 
 i915_sfs_path=
 if [ -d /sys/class/drm ] ; then
@@ -76,7 +82,7 @@ fi
 
 function drmtest_skip_on_simulation()
 {
-	[ -n "$INTEL_SIMULATION" ] && exit 77
+	[ -n "$INTEL_SIMULATION" ] && exit $IGT_EXIT_SKIP
 }
 
 drmtest_skip_on_simulation
tests/drv_debugfs_reader +1 -1
index 9e2845e..6ea4e64 100755
@@ -6,4 +6,4 @@ SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 # read everything we can
 cat $i915_dfs_path/* > /dev/null 2>&1
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drv_missed_irq_hang +7 -7
index 6e8cfc2..8083fe5 100755
@@ -19,20 +19,20 @@ function blt_wait {
 function check_for_missed_irq {
 	if test `cat i915_ring_missed_irq` = 0x00000000; then
 		echo "missed interrupts undetected"
-		exit 1
+		exit $IGT_EXIT_FAILURE
 	fi
 }
 
 function check_for_hang {
 	if cat i915_error_state | grep -v "no error state collected" > /dev/null ; then
 		echo "gpu hang reported"
-		exit 2
+		exit $IGT_EXIT_FAILURE
 	fi
 }
 
 if [ ! -f i915_ring_missed_irq ] ; then
 	echo "kernel doesn't support interrupt masking"
-	exit 77
+	exit $IGT_EXIT_SKIP
 fi
 
 # clear error state first
@@ -43,7 +43,7 @@ echo 0xf > i915_ring_test_irq
 echo "Interrupts masked"
 if test `cat i915_ring_test_irq` != 0x0000000f; then
 	echo "Failed to set interrupt mask"
-	exit 3
+	exit $IGT_EXIT_FAILURE
 fi
 
 blt_wait
@@ -57,7 +57,7 @@ echo 0 > i915_ring_test_irq
 echo "Interrupts unmasked"
 if test `cat i915_ring_test_irq` != 0x00000000; then
 	echo "Failed to clear interrupt mask"
-	exit 3
+	exit $IGT_EXIT_FAILURE
 fi
 
 blt_wait
@@ -67,7 +67,7 @@ echo 0 > i915_ring_missed_irq
 echo "Cleared missed interrupts"
 if test `cat i915_ring_missed_irq` != 0x00000000; then
 	echo "Failed to clear missed interrupts"
-	exit 3
+	exit $IGT_EXIT_FAILURE
 fi
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drv_module_reload_basic +4 -4
index ec1bae8..43c511b 100755
@@ -33,7 +33,7 @@ rmmod drm &> /dev/null
 
 if lsmod | grep i915 &> /dev/null ; then
 	echo WARNING: i915.ko still loaded!
-	exit 1
+	exit $IGT_EXIT_FAILURE
 else
 	echo module successfully unloaded
 fi
@@ -48,13 +48,13 @@ if $SOURCE_DIR/gem_alive > /dev/null ; then
 	echo "module successfully loaded again"
 else
 	echo "failed to reload module successfully"
-	exit 2
+	exit $IGT_EXIT_FAILURE
 fi
 
 # then try to run something
 if ! $SOURCE_DIR/gem_linear_blits --run-subtest basic > /dev/null ; then
 	echo "failed to execute a simple batch after reload"
-	exit 3
+	exit $IGT_EXIT_FAILURE
 fi
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/kms_sysfs_edid_timing +2 -2
index ec704f6..46ea540 100755
@@ -19,7 +19,7 @@ RES=$(((TIME2 - TIME1) / 1000000))
 
 if [ $RES -gt 600 ]; then
 	echo "Talking to outputs took ${RES}ms, something is wrong"
-	exit 1
+	exit $IGT_EXIT_FAILURE
 fi
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/sysfs_l3_parity +3 -3
index 9bd1724..6f14b84 100755
@@ -5,7 +5,7 @@ SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 
 if ! find /sys/class/drm/card*/ | grep l3_parity > /dev/null ; then
 	echo "no l3_parity interface, skipping test"
-	exit 77
+	exit $IGT_EXIT_SKIP
 fi
 
 $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e
@@ -15,7 +15,7 @@ $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -d
 disabled=`$SOURCE_DIR/../tools/intel_l3_parity -l | grep -c 'Row 0, Bank 0, Subbank 0 is disabled'`
 if [ "$disabled" != "1" ] ; then
 	echo "Fail"
-	exit 1
+	exit $IGT_EXIT_FAILURE
 fi
 
 $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e
@@ -23,5 +23,5 @@ $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e
 #Check that we can clear remaps
 if [ `$SOURCE_DIR/../tools/intel_l3_parity -l | wc -l` != 1 ] ; then
 	echo "Fail 2"
-	exit 1
+	exit $IGT_EXIT_FAILURE
 fi
tests/test_rte_check +1 -1
index eb12416..2a891b8 100755
@@ -3,4 +3,4 @@
 SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 . $SOURCE_DIR/drm_lib.sh
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/tools_test +1 -1
index a6178e1..0487827 100755
@@ -12,5 +12,5 @@ do_or_die "intel_reg_dumper"
 
 # TODO: Add more tests
 
-exit 0
+exit $IGT_EXIT_SUCCESS
 
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw

Re: [PATCH i-g-t] tests: add exit value constants for shell script tests

1 comment / question inline, otherwise looks ok to me.

//Derek

Quoted 90 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Thomas Wood
Sent: Thursday, December 3, 2015 11:31 AM
To: [email protected]
Subject: [Intel-gfx] [PATCH i-g-t] tests: add exit value constants for shell script tests

---

tests/check_drm_clients       |  2 +-
tests/debugfs_emon_crash      |  2 +-
tests/drm_lib.sh              | 22 ++++++++++++++--------
tests/drv_debugfs_reader      |  2 +-
tests/drv_missed_irq_hang     | 14 +++++++-------
tests/drv_module_reload_basic |  8 ++++----
tests/kms_sysfs_edid_timing   |  4 ++--
tests/sysfs_l3_parity         |  6 +++---
tests/test_rte_check          |  2 +-
tests/tools_test              |  2 +-
10 files changed, 35 insertions(+), 29 deletions(-)
tests/check_drm_clients +0 -0
@@ -3,4 +3,4 @@

SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
. $SOURCE_DIR/drm_lib.sh

tests/check_drm_clients +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/debugfs_emon_crash +1 -1
@@ -13,4 +13,4 @@ done
 
 # If we got here, we haven't crashed
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drm_lib.sh +6 -0
@@ -1,20 +1,26 @@
 #!/bin/sh
 
+IGT_EXIT_TIMEOUT=78
+IGT_EXIT_SKIP=77
+IGT_EXIT_SUCCESS=0
+IGT_EXIT_INVALID=79
+IGT_EXIT_FAILURE=99
+
 # hacked-up long option parsing

for arg in $@ ; do
case $arg in
--list-subtests)

tests/drm_lib.sh +1 -1
-			exit 79
+			exit $IGT_EXIT_INVALID
			;;
		--run-subtest)
tests/drm_lib.sh +1 -1
-			exit 79
+			exit $IGT_EXIT_INVALID
			;;
		--debug)
			IGT_LOG_LEVEL=debug
			;;
		--help-description)
			echo $IGT_TEST_DESCRIPTION
tests/drm_lib.sh +1 -1
-			exit 0
+			exit $IGT_EXIT_SUCCESS
			;;
		--help)
			echo "Usage: `basename $0` [OPTIONS]"
tests/drm_lib.sh +1 -1
@@ -23,18 +29,18 @@ for arg in $@ ; do
 			echo "  --debug"
 			echo "  --help-description"
 			echo "  --help"
-			exit 0
+			exit $IGT_EXIT_SUCCESS
 			;;
 	esac

done

die() {
	echo "$@"
tests/drm_lib.sh +1 -1
-	exit 1
+	exit $IGT_EXIT_FAILURE

}

do_or_die() {

tests/drm_lib.sh

Quoted 2 lines
tests/drm_lib.sh +1 -1
-	$@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit -1)
+	$@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit 

Would exit $? Be helpful here to pass the error value on?

Quoted 170 lines

+$IGT_EXIT_FAILURE)
}

if [ -d /debug/dri ] ; then

tests/drm_lib.sh +0 -0
@@ -63,7 +69,7 @@ if [ `cat $i915_dfs_path/clients | wc -l` -gt "2" ] ; then
 		die "ERROR: other drm clients running"

fi

tests/drm_lib.sh +2 -1
-whoami | grep -q root || ( echo ERROR: not running as root; exit 1 )
+whoami | grep -q root || ( echo ERROR: not running as root; exit 
+$IGT_EXIT_FAILURE )

i915_sfs_path=
if [ -d /sys/class/drm ] ; then

tests/drm_lib.sh +1 -1
@@ -76,7 +82,7 @@ fi
 
 function drmtest_skip_on_simulation()
 {
-	[ -n "$INTEL_SIMULATION" ] && exit 77
+	[ -n "$INTEL_SIMULATION" ] && exit $IGT_EXIT_SKIP
 }
 

drmtest_skip_on_simulation

tests/drv_debugfs_reader +0 -0
@@ -6,4 +6,4 @@ SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 # read everything we can

cat $i915_dfs_path/* > /dev/null 2>&1

tests/drv_debugfs_reader +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drv_missed_irq_hang +2 -2
@@ -19,20 +19,20 @@ function blt_wait {
 function check_for_missed_irq {
 	if test `cat i915_ring_missed_irq` = 0x00000000; then
 		echo "missed interrupts undetected"
-		exit 1
+		exit $IGT_EXIT_FAILURE
 	fi
 }
 
 function check_for_hang {
 	if cat i915_error_state | grep -v "no error state collected" > /dev/null ; then
 		echo "gpu hang reported"
-		exit 2
+		exit $IGT_EXIT_FAILURE
 	fi
 }
 

if [ ! -f i915_ring_missed_irq ] ; then
echo "kernel doesn't support interrupt masking"

tests/drv_missed_irq_hang +1 -1
-	exit 77
+	exit $IGT_EXIT_SKIP

fi

# clear error state first
tests/drv_missed_irq_hang +0 -0
@@ -43,7 +43,7 @@ echo 0xf > i915_ring_test_irq  echo "Interrupts masked"

if test cat i915_ring_test_irq != 0x0000000f; then
echo "Failed to set interrupt mask"

tests/drv_missed_irq_hang +1 -1
-	exit 3
+	exit $IGT_EXIT_FAILURE

fi

blt_wait

tests/drv_missed_irq_hang +0 -0
@@ -57,7 +57,7 @@ echo 0 > i915_ring_test_irq  echo "Interrupts unmasked"

if test cat i915_ring_test_irq != 0x00000000; then
echo "Failed to clear interrupt mask"

tests/drv_missed_irq_hang +1 -1
-	exit 3
+	exit $IGT_EXIT_FAILURE

fi

blt_wait

tests/drv_missed_irq_hang +0 -0
@@ -67,7 +67,7 @@ echo 0 > i915_ring_missed_irq  echo "Cleared missed interrupts"

if test cat i915_ring_missed_irq != 0x00000000; then
echo "Failed to clear missed interrupts"

tests/drv_missed_irq_hang +1 -1
-	exit 3
+	exit $IGT_EXIT_FAILURE

fi

tests/drv_missed_irq_hang +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drv_module_reload_basic +0 -0
@@ -33,7 +33,7 @@ rmmod drm &> /dev/null
 

if lsmod | grep i915 &> /dev/null ; then
echo WARNING: i915.ko still loaded!

tests/drv_module_reload_basic +1 -1
-	exit 1
+	exit $IGT_EXIT_FAILURE

else
echo module successfully unloaded
fi

tests/drv_module_reload_basic +0 -0
@@ -48,13 +48,13 @@ if $SOURCE_DIR/gem_alive > /dev/null ; then
 	echo "module successfully loaded again"

else
echo "failed to reload module successfully"

tests/drv_module_reload_basic +1 -1
-	exit 2
+	exit $IGT_EXIT_FAILURE

fi

# then try to run something
if ! $SOURCE_DIR/gem_linear_blits --run-subtest basic > /dev/null ; then
	echo "failed to execute a simple batch after reload"
tests/drv_module_reload_basic +1 -1
-	exit 3
+	exit $IGT_EXIT_FAILURE

fi

tests/drv_module_reload_basic +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/kms_sysfs_edid_timing +0 -0
@@ -19,7 +19,7 @@ RES=$(((TIME2 - TIME1) / 1000000))
 

if [ $RES -gt 600 ]; then

	echo "Talking to outputs took ${RES}ms, something is wrong"
tests/kms_sysfs_edid_timing +1 -1
-	exit 1
+	exit $IGT_EXIT_FAILURE

fi

tests/kms_sysfs_edid_timing +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/sysfs_l3_parity +0 -0
@@ -5,7 +5,7 @@ SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 

if ! find /sys/class/drm/card*/ | grep l3_parity > /dev/null ; then
echo "no l3_parity interface, skipping test"

tests/sysfs_l3_parity +1 -1
-	exit 77
+	exit $IGT_EXIT_SKIP

fi

$SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e @@ -15,7 +15,7 @@ $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -d disabled=$SOURCE_DIR/../tools/intel_l3_parity -l | grep -c 'Row 0, Bank 0, Subbank 0 is disabled' if [ "$disabled" != "1" ] ; then
echo "Fail"

tests/sysfs_l3_parity +1 -1
-	exit 1
+	exit $IGT_EXIT_FAILURE

fi

$SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e @@ -23,5 +23,5 @@ $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e #Check that we can clear remaps if [ $SOURCE_DIR/../tools/intel_l3_parity -l | wc -l != 1 ] ; then
echo "Fail 2"

tests/sysfs_l3_parity +1 -1
-	exit 1
+	exit $IGT_EXIT_FAILURE

fi

tests/test_rte_check +0 -0
@@ -3,4 +3,4 @@

SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
. $SOURCE_DIR/drm_lib.sh

tests/test_rte_check +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/tools_test +1 -2
@@ -12,5 +12,5 @@ do_or_die "intel_reg_dumper"
 
 # TODO: Add more tests
 
-exit 0
+exit $IGT_EXIT_SUCCESS
 
--

1.9.1

Quoted 5 lines

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw

Re: [PATCH i-g-t] tests: add exit value constants for shell script tests

Quoted 93 lines · Derek J

1 comment / question inline, otherwise looks ok to me.

//Derek

Quoted 89 lines

-----Original Message-----
From: Intel-gfx [mailto:[email protected]] On Behalf Of Thomas Wood
Sent: Thursday, December 3, 2015 11:31 AM
To: [email protected]
Subject: [Intel-gfx] [PATCH i-g-t] tests: add exit value constants for shell script tests

---

tests/check_drm_clients       |  2 +-
tests/debugfs_emon_crash      |  2 +-
tests/drm_lib.sh              | 22 ++++++++++++++--------
tests/drv_debugfs_reader      |  2 +-
tests/drv_missed_irq_hang     | 14 +++++++-------
tests/drv_module_reload_basic |  8 ++++----
tests/kms_sysfs_edid_timing   |  4 ++--
tests/sysfs_l3_parity         |  6 +++---
tests/test_rte_check          |  2 +-
tests/tools_test              |  2 +-
10 files changed, 35 insertions(+), 29 deletions(-)
tests/check_drm_clients +0 -0
@@ -3,4 +3,4 @@

SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
. $SOURCE_DIR/drm_lib.sh

tests/check_drm_clients +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/debugfs_emon_crash +1 -1
@@ -13,4 +13,4 @@ done
 
 # If we got here, we haven't crashed
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drm_lib.sh +6 -0
@@ -1,20 +1,26 @@
 #!/bin/sh
 
+IGT_EXIT_TIMEOUT=78
+IGT_EXIT_SKIP=77
+IGT_EXIT_SUCCESS=0
+IGT_EXIT_INVALID=79
+IGT_EXIT_FAILURE=99
+
 # hacked-up long option parsing

for arg in $@ ; do
case $arg in
--list-subtests)

tests/drm_lib.sh +4 -4
-                      exit 79
+                      exit $IGT_EXIT_INVALID
                      ;;
              --run-subtest)
-                      exit 79
+                      exit $IGT_EXIT_INVALID
                      ;;
              --debug)
                      IGT_LOG_LEVEL=debug
                      ;;
              --help-description)
                      echo $IGT_TEST_DESCRIPTION
-                      exit 0
+                      exit $IGT_EXIT_SUCCESS
                      ;;
              --help)
                      echo "Usage: `basename $0` [OPTIONS]"
@@ -23,18 +29,18 @@ for arg in $@ ; do
                      echo "  --debug"
                      echo "  --help-description"
                      echo "  --help"
-                      exit 0
+                      exit $IGT_EXIT_SUCCESS
                      ;;
      esac

done

die() {
      echo "$@"
tests/drm_lib.sh +1 -1
-      exit 1
+      exit $IGT_EXIT_FAILURE

}

Quoted 5 lines

tests/drm_lib.sh

Quoted 3 lines

do_or_die() {

tests/drm_lib.sh +1 -1
-      $@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit -1)
+      $@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit

Would exit $? Be helpful here to pass the error value on?

The value would have a different meaning depending on $@, so I don't think it would be immediately useful to a test runner (it may even conflict with the exit codes defined above). The value of $? is printed out so at least it can be inspected in the logs.

Quoted 168 lines
Quoted 168 lines

+$IGT_EXIT_FAILURE)
}

if [ -d /debug/dri ] ; then

tests/drm_lib.sh +0 -0
@@ -63,7 +69,7 @@ if [ `cat $i915_dfs_path/clients | wc -l` -gt "2" ] ; then
              die "ERROR: other drm clients running"

fi

tests/drm_lib.sh +2 -1
-whoami | grep -q root || ( echo ERROR: not running as root; exit 1 )
+whoami | grep -q root || ( echo ERROR: not running as root; exit
+$IGT_EXIT_FAILURE )

i915_sfs_path=
if [ -d /sys/class/drm ] ; then

tests/drm_lib.sh +1 -1
@@ -76,7 +82,7 @@ fi
 
 function drmtest_skip_on_simulation()
 {
-      [ -n "$INTEL_SIMULATION" ] && exit 77
+      [ -n "$INTEL_SIMULATION" ] && exit $IGT_EXIT_SKIP
 }
 

drmtest_skip_on_simulation

tests/drv_debugfs_reader +0 -0
@@ -6,4 +6,4 @@ SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 # read everything we can

cat $i915_dfs_path/* > /dev/null 2>&1

tests/drv_debugfs_reader +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drv_missed_irq_hang +2 -2
@@ -19,20 +19,20 @@ function blt_wait {
 function check_for_missed_irq {
      if test `cat i915_ring_missed_irq` = 0x00000000; then
              echo "missed interrupts undetected"
-              exit 1
+              exit $IGT_EXIT_FAILURE
      fi
 }
 
 function check_for_hang {
      if cat i915_error_state | grep -v "no error state collected" > /dev/null ; then
              echo "gpu hang reported"
-              exit 2
+              exit $IGT_EXIT_FAILURE
      fi
 }
 

if [ ! -f i915_ring_missed_irq ] ; then
echo "kernel doesn't support interrupt masking"

tests/drv_missed_irq_hang +1 -1
-      exit 77
+      exit $IGT_EXIT_SKIP

fi

# clear error state first
tests/drv_missed_irq_hang +0 -0
@@ -43,7 +43,7 @@ echo 0xf > i915_ring_test_irq  echo "Interrupts masked"

if test cat i915_ring_test_irq != 0x0000000f; then
echo "Failed to set interrupt mask"

tests/drv_missed_irq_hang +1 -1
-      exit 3
+      exit $IGT_EXIT_FAILURE

fi

blt_wait

tests/drv_missed_irq_hang +0 -0
@@ -57,7 +57,7 @@ echo 0 > i915_ring_test_irq  echo "Interrupts unmasked"

if test cat i915_ring_test_irq != 0x00000000; then
echo "Failed to clear interrupt mask"

tests/drv_missed_irq_hang +1 -1
-      exit 3
+      exit $IGT_EXIT_FAILURE

fi

blt_wait

tests/drv_missed_irq_hang +0 -0
@@ -67,7 +67,7 @@ echo 0 > i915_ring_missed_irq  echo "Cleared missed interrupts"

if test cat i915_ring_missed_irq != 0x00000000; then
echo "Failed to clear missed interrupts"

tests/drv_missed_irq_hang +1 -1
-      exit 3
+      exit $IGT_EXIT_FAILURE

fi

tests/drv_missed_irq_hang +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drv_module_reload_basic +0 -0
@@ -33,7 +33,7 @@ rmmod drm &> /dev/null
 

if lsmod | grep i915 &> /dev/null ; then
echo WARNING: i915.ko still loaded!

tests/drv_module_reload_basic +1 -1
-      exit 1
+      exit $IGT_EXIT_FAILURE

else
echo module successfully unloaded
fi

tests/drv_module_reload_basic +0 -0
@@ -48,13 +48,13 @@ if $SOURCE_DIR/gem_alive > /dev/null ; then
      echo "module successfully loaded again"

else
echo "failed to reload module successfully"

tests/drv_module_reload_basic +1 -1
-      exit 2
+      exit $IGT_EXIT_FAILURE

fi

# then try to run something
if ! $SOURCE_DIR/gem_linear_blits --run-subtest basic > /dev/null ; then
      echo "failed to execute a simple batch after reload"
tests/drv_module_reload_basic +1 -1
-      exit 3
+      exit $IGT_EXIT_FAILURE

fi

tests/drv_module_reload_basic +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/kms_sysfs_edid_timing +0 -0
@@ -19,7 +19,7 @@ RES=$(((TIME2 - TIME1) / 1000000))
 

if [ $RES -gt 600 ]; then

      echo "Talking to outputs took ${RES}ms, something is wrong"
tests/kms_sysfs_edid_timing +1 -1
-      exit 1
+      exit $IGT_EXIT_FAILURE

fi

tests/kms_sysfs_edid_timing +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/sysfs_l3_parity +0 -0
@@ -5,7 +5,7 @@ SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 

if ! find /sys/class/drm/card*/ | grep l3_parity > /dev/null ; then
echo "no l3_parity interface, skipping test"

tests/sysfs_l3_parity +1 -1
-      exit 77
+      exit $IGT_EXIT_SKIP

fi

$SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e @@ -15,7 +15,7 @@ $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -d disabled=$SOURCE_DIR/../tools/intel_l3_parity -l | grep -c 'Row 0, Bank 0, Subbank 0 is disabled' if [ "$disabled" != "1" ] ; then
echo "Fail"

tests/sysfs_l3_parity +1 -1
-      exit 1
+      exit $IGT_EXIT_FAILURE

fi

$SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e @@ -23,5 +23,5 @@ $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e #Check that we can clear remaps if [ $SOURCE_DIR/../tools/intel_l3_parity -l | wc -l != 1 ] ; then
echo "Fail 2"

tests/sysfs_l3_parity +1 -1
-      exit 1
+      exit $IGT_EXIT_FAILURE

fi

tests/test_rte_check +0 -0
@@ -3,4 +3,4 @@

SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
. $SOURCE_DIR/drm_lib.sh

tests/test_rte_check +1 -1
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/tools_test +1 -1
@@ -12,5 +12,5 @@ do_or_die "intel_reg_dumper"
 
 # TODO: Add more tests
 
-exit 0
+exit $IGT_EXIT_SUCCESS
 
Quoted 8 lines
Quoted 8 lines

--
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

Re: [PATCH i-g-t] tests: add exit value constants for shell script tests

In reply to Thomas Wood
Quoted 1 line · Thomas Wood

Yeah that's nicer. I fixed up patch 2 to use the correct exit code and push the entire series. Thanks for the feedback!

Cheers, Daniel

Quoted 274 lines
---
 tests/check_drm_clients       |  2 +-
 tests/debugfs_emon_crash      |  2 +-
 tests/drm_lib.sh              | 22 ++++++++++++++--------
 tests/drv_debugfs_reader      |  2 +-
 tests/drv_missed_irq_hang     | 14 +++++++-------
 tests/drv_module_reload_basic |  8 ++++----
 tests/kms_sysfs_edid_timing   |  4 ++--
 tests/sysfs_l3_parity         |  6 +++---
 tests/test_rte_check          |  2 +-
 tests/tools_test              |  2 +-
 10 files changed, 35 insertions(+), 29 deletions(-)
tests/check_drm_clients +1 -1
index eb12416..2a891b8 100755
@@ -3,4 +3,4 @@
 SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 . $SOURCE_DIR/drm_lib.sh
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/debugfs_emon_crash +1 -1
index 809bfab..1dbfcb2 100755
@@ -13,4 +13,4 @@ done
 
 # If we got here, we haven't crashed
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drm_lib.sh +14 -8
index c50664c..d2c6420 100755
@@ -1,20 +1,26 @@
 #!/bin/sh
 
+IGT_EXIT_TIMEOUT=78
+IGT_EXIT_SKIP=77
+IGT_EXIT_SUCCESS=0
+IGT_EXIT_INVALID=79
+IGT_EXIT_FAILURE=99
+
 # hacked-up long option parsing
 for arg in $@ ; do
 	case $arg in
 		--list-subtests)
-			exit 79
+			exit $IGT_EXIT_INVALID
 			;;
 		--run-subtest)
-			exit 79
+			exit $IGT_EXIT_INVALID
 			;;
 		--debug)
 			IGT_LOG_LEVEL=debug
 			;;
 		--help-description)
 			echo $IGT_TEST_DESCRIPTION
-			exit 0
+			exit $IGT_EXIT_SUCCESS
 			;;
 		--help)
 			echo "Usage: `basename $0` [OPTIONS]"
@@ -23,18 +29,18 @@ for arg in $@ ; do
 			echo "  --debug"
 			echo "  --help-description"
 			echo "  --help"
-			exit 0
+			exit $IGT_EXIT_SUCCESS
 			;;
 	esac
 done
 
 die() {
 	echo "$@"
-	exit 1
+	exit $IGT_EXIT_FAILURE
 }
 
 do_or_die() {
-	$@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit -1)
+	$@ > /dev/null 2>&1 || (echo "FAIL: $@ ($?)" && exit $IGT_EXIT_FAILURE)
 }
 
 if [ -d /debug/dri ] ; then
@@ -63,7 +69,7 @@ if [ `cat $i915_dfs_path/clients | wc -l` -gt "2" ] ; then
 		die "ERROR: other drm clients running"
 fi
 
-whoami | grep -q root || ( echo ERROR: not running as root; exit 1 )
+whoami | grep -q root || ( echo ERROR: not running as root; exit $IGT_EXIT_FAILURE )
 
 i915_sfs_path=
 if [ -d /sys/class/drm ] ; then
@@ -76,7 +82,7 @@ fi
 
 function drmtest_skip_on_simulation()
 {
-	[ -n "$INTEL_SIMULATION" ] && exit 77
+	[ -n "$INTEL_SIMULATION" ] && exit $IGT_EXIT_SKIP
 }
 
 drmtest_skip_on_simulation
tests/drv_debugfs_reader +1 -1
index 9e2845e..6ea4e64 100755
@@ -6,4 +6,4 @@ SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 # read everything we can
 cat $i915_dfs_path/* > /dev/null 2>&1
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drv_missed_irq_hang +7 -7
index 6e8cfc2..8083fe5 100755
@@ -19,20 +19,20 @@ function blt_wait {
 function check_for_missed_irq {
 	if test `cat i915_ring_missed_irq` = 0x00000000; then
 		echo "missed interrupts undetected"
-		exit 1
+		exit $IGT_EXIT_FAILURE
 	fi
 }
 
 function check_for_hang {
 	if cat i915_error_state | grep -v "no error state collected" > /dev/null ; then
 		echo "gpu hang reported"
-		exit 2
+		exit $IGT_EXIT_FAILURE
 	fi
 }
 
 if [ ! -f i915_ring_missed_irq ] ; then
 	echo "kernel doesn't support interrupt masking"
-	exit 77
+	exit $IGT_EXIT_SKIP
 fi
 
 # clear error state first
@@ -43,7 +43,7 @@ echo 0xf > i915_ring_test_irq
 echo "Interrupts masked"
 if test `cat i915_ring_test_irq` != 0x0000000f; then
 	echo "Failed to set interrupt mask"
-	exit 3
+	exit $IGT_EXIT_FAILURE
 fi
 
 blt_wait
@@ -57,7 +57,7 @@ echo 0 > i915_ring_test_irq
 echo "Interrupts unmasked"
 if test `cat i915_ring_test_irq` != 0x00000000; then
 	echo "Failed to clear interrupt mask"
-	exit 3
+	exit $IGT_EXIT_FAILURE
 fi
 
 blt_wait
@@ -67,7 +67,7 @@ echo 0 > i915_ring_missed_irq
 echo "Cleared missed interrupts"
 if test `cat i915_ring_missed_irq` != 0x00000000; then
 	echo "Failed to clear missed interrupts"
-	exit 3
+	exit $IGT_EXIT_FAILURE
 fi
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/drv_module_reload_basic +4 -4
index ec1bae8..43c511b 100755
@@ -33,7 +33,7 @@ rmmod drm &> /dev/null
 
 if lsmod | grep i915 &> /dev/null ; then
 	echo WARNING: i915.ko still loaded!
-	exit 1
+	exit $IGT_EXIT_FAILURE
 else
 	echo module successfully unloaded
 fi
@@ -48,13 +48,13 @@ if $SOURCE_DIR/gem_alive > /dev/null ; then
 	echo "module successfully loaded again"
 else
 	echo "failed to reload module successfully"
-	exit 2
+	exit $IGT_EXIT_FAILURE
 fi
 
 # then try to run something
 if ! $SOURCE_DIR/gem_linear_blits --run-subtest basic > /dev/null ; then
 	echo "failed to execute a simple batch after reload"
-	exit 3
+	exit $IGT_EXIT_FAILURE
 fi
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/kms_sysfs_edid_timing +2 -2
index ec704f6..46ea540 100755
@@ -19,7 +19,7 @@ RES=$(((TIME2 - TIME1) / 1000000))
 
 if [ $RES -gt 600 ]; then
 	echo "Talking to outputs took ${RES}ms, something is wrong"
-	exit 1
+	exit $IGT_EXIT_FAILURE
 fi
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/sysfs_l3_parity +3 -3
index 9bd1724..6f14b84 100755
@@ -5,7 +5,7 @@ SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 
 if ! find /sys/class/drm/card*/ | grep l3_parity > /dev/null ; then
 	echo "no l3_parity interface, skipping test"
-	exit 77
+	exit $IGT_EXIT_SKIP
 fi
 
 $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e
@@ -15,7 +15,7 @@ $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -d
 disabled=`$SOURCE_DIR/../tools/intel_l3_parity -l | grep -c 'Row 0, Bank 0, Subbank 0 is disabled'`
 if [ "$disabled" != "1" ] ; then
 	echo "Fail"
-	exit 1
+	exit $IGT_EXIT_FAILURE
 fi
 
 $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e
@@ -23,5 +23,5 @@ $SOURCE_DIR/../tools/intel_l3_parity -r 0 -b 0 -s 0 -e
 #Check that we can clear remaps
 if [ `$SOURCE_DIR/../tools/intel_l3_parity -l | wc -l` != 1 ] ; then
 	echo "Fail 2"
-	exit 1
+	exit $IGT_EXIT_FAILURE
 fi
tests/test_rte_check +1 -1
index eb12416..2a891b8 100755
@@ -3,4 +3,4 @@
 SOURCE_DIR="$( dirname "${BASH_SOURCE[0]}" )"
 . $SOURCE_DIR/drm_lib.sh
 
-exit 0
+exit $IGT_EXIT_SUCCESS
tests/tools_test +1 -1
index a6178e1..0487827 100755
@@ -12,5 +12,5 @@ do_or_die "intel_reg_dumper"
 
 # TODO: Add more tests
 
-exit 0
+exit $IGT_EXIT_SUCCESS
 
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw

PATCH 3/3 tests/drv_hangman: Open drm fd before doing anything

In reply to Daniel Vetter

This way we correctly auto-skip instead of falling over the lack of i915 debugfs files first and fail the testcase due to that.

---
 tests/drv_hangman.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
tests/drv_hangman.c +4 -2
index 6caf910b0b12..cd63b97db370 100644
@@ -217,10 +217,11 @@ static void test_error_state_basic(void)
 {
 	int fd;
 
+	fd = drm_open_driver(DRIVER_INTEL);
+
 	clear_error_state();
 	assert_error_state_clear();
 
-	fd = drm_open_driver(DRIVER_INTEL);
 	submit_batch(fd, I915_EXEC_RENDER, true);
 	close(fd);
 
@@ -373,9 +374,10 @@ static void test_error_state_capture(unsigned ring_id,
 	uint64_t offset;
 	bool cmd_parser;
 
+	fd = drm_open_driver(DRIVER_INTEL);
+
 	clear_error_state();
 
-	fd = drm_open_driver(DRIVER_INTEL);
 	gen = intel_gen(intel_get_drm_devid(fd));
 	cmd_parser = uses_cmd_parser(fd, gen);
 
Signature · 6 lines
2.5.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx