[igt-dev] [PATCH i-g-t] tests/gem_exec_faulting_reloc: Add hang detector

Antonio Argenziano antonio.argenziano at intel.com
Wed Jul 18 17:54:01 UTC 2018


Add hang detector to the test so that we fail in case of an hang caused by
the batches it submits.

Signed-off-by: Antonio Argenziano <antonio.argenziano at intel.com>
---
 tests/gem_exec_faulting_reloc.c | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c
index 6b05e43f..9def01ba 100644
--- a/tests/gem_exec_faulting_reloc.c
+++ b/tests/gem_exec_faulting_reloc.c
@@ -39,7 +39,7 @@
 #include <sys/time.h>
 #include "drm.h"
 
-/* Testcase: Submit patches with relocations in memory that will fault
+/* Testcase: Submit batches with relocations in memory that will fault
  *
  * To be really evil, use a gtt mmap for them.
  */
@@ -111,7 +111,7 @@ static int gem_linear_blt(uint32_t *batch,
 			b += 8;
 		length -= height * 16*1024;
 	}
-	
+
 	if (length) {
 		int i = 0;
 		b[i++] = COPY_BLT_CMD_NOLEN | BLT_WRITE_ALPHA | BLT_WRITE_RGB;
@@ -160,7 +160,7 @@ static int gem_linear_blt(uint32_t *batch,
 	return (b+2 - batch) * sizeof(uint32_t);
 }
 
-static void run(int object_size)
+static void run(int fd, int object_size)
 {
 	struct drm_i915_gem_execbuffer2 execbuf;
 	struct drm_i915_gem_exec_object2 exec[3];
@@ -168,11 +168,9 @@ static void run(int object_size)
 	uint32_t buf[40];
 	uint32_t handle, handle_relocs, src, dst;
 	void *gtt_relocs;
-	int fd, len;
+	int len;
 	int ring;
 
-	fd = drm_open_driver(DRIVER_INTEL);
-	igt_require_gem(fd);
 	devid = intel_get_drm_devid(fd);
 	handle = gem_create(fd, 4096);
 	src = gem_create(fd, object_size);
@@ -237,17 +235,29 @@ static void run(int object_size)
 	gem_sync(fd, handle);
 
 	gem_close(fd, handle);
-
-	close(fd);
 }
 
 igt_main
 {
+	int fd;
+
+	igt_fixture {
+		fd = drm_open_driver(DRIVER_INTEL);
+		igt_require_gem(fd);
+
+		igt_fork_hang_detector(fd);
+	}
+
 	igt_subtest("normal")
-		run(OBJECT_SIZE);
+		run(fd, OBJECT_SIZE);
 	igt_subtest("no-prefault") {
 		igt_disable_prefault();
-		run(OBJECT_SIZE);
+		run(fd, OBJECT_SIZE);
 		igt_enable_prefault();
 	}
+
+	igt_fixture {
+		igt_stop_hang_detector();
+		close(fd);
+	}
 }
-- 
2.16.2



More information about the igt-dev mailing list