[Intel-gfx] [PATCH i-g-t 2/2] tests: Push igt_fork/stop_hang_detector into fixtures

Daniel Vetter daniel.vetter at ffwll.ch
Fri Jun 17 14:05:39 UTC 2016


It access hardware, hence why the simple igt_only_list_subtests()
check from igt_fork/stop_signal_helper() isn't enough.

Signed-off-by: Daniel Vetter <daniel.vetter at intel.com>
---
 lib/igt_aux.c                |  6 ------
 tests/gem_concurrent_all.c   |  6 ++++--
 tests/gem_ctx_create.c       | 10 +++++-----
 tests/gem_ctx_switch.c       |  7 +++----
 tests/gem_evict_everything.c |  4 ++--
 tests/gem_exec_basic.c       | 11 ++++++-----
 tests/gem_exec_create.c      | 10 ++++++----
 tests/gem_exec_flush.c       | 10 +++++-----
 tests/gem_exec_gttfill.c     |  6 ++----
 tests/gem_exec_nop.c         |  7 +++----
 tests/gem_exec_parallel.c    | 11 ++++++-----
 tests/gem_exec_store.c       | 11 ++++++-----
 tests/gem_exec_suspend.c     | 11 ++++++-----
 tests/gem_exec_whisper.c     | 11 ++++++-----
 tests/gem_sync.c             | 11 ++++++-----
 15 files changed, 66 insertions(+), 66 deletions(-)

diff --git a/lib/igt_aux.c b/lib/igt_aux.c
index 27b74aec8461..e64b29cc090e 100644
--- a/lib/igt_aux.c
+++ b/lib/igt_aux.c
@@ -403,9 +403,6 @@ void igt_fork_hang_detector(int fd)
 {
 	struct stat st;
 
-	if (igt_only_list_subtests())
-		return;
-
 	igt_assert(fstat(fd, &st) == 0);
 
 	signal(SIGRTMAX, sig_abort);
@@ -415,9 +412,6 @@ void igt_fork_hang_detector(int fd)
 
 void igt_stop_hang_detector(void)
 {
-	if (igt_only_list_subtests())
-		return;
-
 	igt_stop_helper(&hang_detector);
 }
 #else
diff --git a/tests/gem_concurrent_all.c b/tests/gem_concurrent_all.c
index 019628eda1f8..9b19455bcfd8 100644
--- a/tests/gem_concurrent_all.c
+++ b/tests/gem_concurrent_all.c
@@ -1432,7 +1432,8 @@ run_mode(const char *prefix,
 			continue;
 
 		if (!*h->suffix)
-			igt_fork_hang_detector(fd);
+			igt_fixture
+				igt_fork_hang_detector(fd);
 
 		for (p = all ? pipelines : pskip; p->prefix; p++) {
 			igt_fixture p->require();
@@ -1563,7 +1564,8 @@ run_mode(const char *prefix,
 		}
 
 		if (!*h->suffix)
-			igt_stop_hang_detector();
+			igt_fixture
+				igt_stop_hang_detector();
 	}
 
 	igt_fixture
diff --git a/tests/gem_ctx_create.c b/tests/gem_ctx_create.c
index 0bdd4082d37e..021cfa24ff81 100644
--- a/tests/gem_ctx_create.c
+++ b/tests/gem_ctx_create.c
@@ -160,9 +160,9 @@ igt_main
 			}
 		} else
 			ppgtt_engines[ppgtt_nengine++] = 0;
-	}
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	igt_subtest("basic") {
 		memset(&create, 0, sizeof(create));
@@ -193,8 +193,8 @@ igt_main
 			active(fd, e->exec_id | e->flags, 20, ncpus);
 	}
 
-	igt_stop_hang_detector();
-
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(fd);
+	}
 }
diff --git a/tests/gem_ctx_switch.c b/tests/gem_ctx_switch.c
index 7b273368faa8..aa48a1683457 100644
--- a/tests/gem_ctx_switch.c
+++ b/tests/gem_ctx_switch.c
@@ -152,9 +152,9 @@ igt_main
 		fd = drm_open_driver(DRIVER_INTEL);
 		handle = gem_create(fd, 4096);
 		gem_write(fd, handle, 0, &bbe, sizeof(bbe));
-	}
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	for (e = intel_execution_engines; e->name; e++) {
 		igt_subtest_f("%s%s", e->exec_id == 0 ? "basic-" : "", e->name)
@@ -167,9 +167,8 @@ igt_main
 			single(fd, handle, e, INTERRUPTIBLE, ncpus);
 	}
 
-	igt_stop_hang_detector();
-
 	igt_fixture {
+		igt_stop_hang_detector();
 		gem_close(fd, handle);
 		close(fd);
 	}
diff --git a/tests/gem_evict_everything.c b/tests/gem_evict_everything.c
index 61ee5479e246..51ed2931dfc5 100644
--- a/tests/gem_evict_everything.c
+++ b/tests/gem_evict_everything.c
@@ -266,10 +266,10 @@ igt_main
 		test_major_evictions(fd, size, count);
 	}
 
-	igt_stop_hang_helper();
+	igt_stop_signal_helper();
 
 	igt_fixture {
-		igt_stop_signal_helper();
+		igt_stop_hang_helper();
 		close(fd);
 	}
 }
diff --git a/tests/gem_exec_basic.c b/tests/gem_exec_basic.c
index b0a4cda24e85..5f0f33b871a7 100644
--- a/tests/gem_exec_basic.c
+++ b/tests/gem_exec_basic.c
@@ -104,10 +104,11 @@ igt_main
 	const struct intel_execution_engine *e;
 	int fd = -1;
 
-	igt_fixture
+	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	for (e = intel_execution_engines; e->name; e++) {
 		igt_subtest_f("basic-%s", e->name)
@@ -118,8 +119,8 @@ igt_main
 			gtt(fd, e->exec_id | e->flags);
 	}
 
-	igt_stop_hang_detector();
-
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(fd);
+	}
 }
diff --git a/tests/gem_exec_create.c b/tests/gem_exec_create.c
index f5a61bacf91d..6e01947c57e9 100644
--- a/tests/gem_exec_create.c
+++ b/tests/gem_exec_create.c
@@ -150,10 +150,11 @@ igt_main
 	const int ncpus = sysconf(_SC_NPROCESSORS_ONLN);
 	int device = -1;
 
-	igt_fixture
+	igt_fixture {
 		device = drm_open_driver(DRIVER_INTEL);
 
-	igt_fork_hang_detector(device);
+		igt_fork_hang_detector(device);
+	}
 
 	igt_subtest("basic")
 		all(device, 0, 20, 1);
@@ -163,8 +164,9 @@ igt_main
 	igt_subtest("madvise")
 		all(device, LEAK, 20, 1);
 
-	igt_stop_hang_detector();
 
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(device);
+	}
 }
diff --git a/tests/gem_exec_flush.c b/tests/gem_exec_flush.c
index e42078955324..c16638b817d9 100644
--- a/tests/gem_exec_flush.c
+++ b/tests/gem_exec_flush.c
@@ -519,9 +519,9 @@ igt_main
 		gem_require_mmap_wc(fd);
 		gen = intel_gen(intel_get_drm_devid(fd));
 		igt_info("Has LLC? %s\n", yesno(gem_has_llc(fd)));
-	}
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	for (e = intel_execution_engines; e->name; e++) igt_subtest_group {
 		unsigned ring = e->exec_id | e->flags;
@@ -593,8 +593,8 @@ igt_main
 		}
 	}
 
-	igt_stop_hang_detector();
-
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(fd);
+	}
 }
diff --git a/tests/gem_exec_gttfill.c b/tests/gem_exec_gttfill.c
index 5966125c7e81..3ec43dcf11f2 100644
--- a/tests/gem_exec_gttfill.c
+++ b/tests/gem_exec_gttfill.c
@@ -196,10 +196,9 @@ igt_main
 
 	igt_fixture {
 		device = drm_open_driver(DRIVER_INTEL);
+		igt_fork_hang_detector(device);
 	}
 
-	igt_fork_hang_detector(device);
-
 	igt_subtest("basic")
 		fillgtt(device, 0, 1); /* just enough to run a single pass */
 
@@ -210,9 +209,8 @@ igt_main
 	igt_subtest("all")
 		fillgtt(device, 0, 150);
 
-	igt_stop_hang_detector();
-
 	igt_fixture {
+		igt_stop_hang_detector();
 		close(device);
 	}
 }
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index e90d5ebad023..9e5aab50f022 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -208,9 +208,9 @@ igt_main
 		device = drm_open_driver(DRIVER_INTEL);
 		handle = gem_create(device, 4096);
 		gem_write(device, handle, 0, &bbe, sizeof(bbe));
-	}
 
-	igt_fork_hang_detector(device);
+		igt_fork_hang_detector(device);
+	}
 
 	igt_subtest("basic")
 		all(device, handle, 10);
@@ -222,9 +222,8 @@ igt_main
 	igt_subtest("all")
 		all(device, handle, 150);
 
-	igt_stop_hang_detector();
-
 	igt_fixture {
+		igt_stop_hang_detector();
 		gem_close(device, handle);
 		close(device);
 	}
diff --git a/tests/gem_exec_parallel.c b/tests/gem_exec_parallel.c
index 2c04ca16263a..6532797ad3f6 100644
--- a/tests/gem_exec_parallel.c
+++ b/tests/gem_exec_parallel.c
@@ -267,10 +267,11 @@ igt_main
 	};
 	int fd;
 
-	igt_fixture
+	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_INTEL);
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	for (const struct mode *m = modes; m->name; m++)
 		igt_subtest_f("%s", *m->name ? m->name : "basic")
@@ -286,8 +287,8 @@ igt_main
 				all(fd, e->exec_id | e->flags, m->flags);
 	}
 
-	igt_stop_hang_detector();
-
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(fd);
+	}
 }
diff --git a/tests/gem_exec_store.c b/tests/gem_exec_store.c
index ae7524258974..cd852e603329 100644
--- a/tests/gem_exec_store.c
+++ b/tests/gem_exec_store.c
@@ -213,10 +213,11 @@ igt_main
 	const struct intel_execution_engine *e;
 	int fd;
 
-	igt_fixture
+	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_INTEL);
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	for (e = intel_execution_engines; e->name; e++)
 		igt_subtest_f("basic-%s", e->name)
@@ -225,8 +226,8 @@ igt_main
 	igt_subtest("basic-all")
 		store_all(fd);
 
-	igt_stop_hang_detector();
-
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(fd);
+	}
 }
diff --git a/tests/gem_exec_suspend.c b/tests/gem_exec_suspend.c
index cd133cc5e835..a45082ea2b6b 100644
--- a/tests/gem_exec_suspend.c
+++ b/tests/gem_exec_suspend.c
@@ -238,10 +238,11 @@ igt_main
 	const struct intel_execution_engine *e;
 	int fd;
 
-	igt_fixture
+	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_INTEL);
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	igt_subtest("basic")
 		run_test(fd, -1, NOSLEEP);
@@ -261,8 +262,8 @@ igt_main
 		}
 	}
 
-	igt_stop_hang_detector();
-
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(fd);
+	}
 }
diff --git a/tests/gem_exec_whisper.c b/tests/gem_exec_whisper.c
index 0b309234c2b8..24c258f6181e 100644
--- a/tests/gem_exec_whisper.c
+++ b/tests/gem_exec_whisper.c
@@ -390,10 +390,11 @@ igt_main
 	};
 	int fd;
 
-	igt_fixture
+	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_INTEL);
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	for (const struct mode *m = modes; m->name; m++)
 		igt_subtest_f("%s", m->name)
@@ -410,8 +411,8 @@ igt_main
 		}
 	}
 
-	igt_stop_hang_detector();
-
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(fd);
+	}
 }
diff --git a/tests/gem_sync.c b/tests/gem_sync.c
index 320bce3378e4..937c6eb2c7d6 100644
--- a/tests/gem_sync.c
+++ b/tests/gem_sync.c
@@ -209,10 +209,11 @@ igt_main
 
 	igt_skip_on_simulation();
 
-	igt_fixture
+	igt_fixture {
 		fd = drm_open_driver(DRIVER_INTEL);
 
-	igt_fork_hang_detector(fd);
+		igt_fork_hang_detector(fd);
+	}
 
 	for (e = intel_execution_engines; e->name; e++) {
 		igt_subtest_f("%s", e->name)
@@ -231,8 +232,8 @@ igt_main
 	igt_subtest("forked-all")
 		sync_all(fd, ncpus);
 
-	igt_stop_hang_detector();
-
-	igt_fixture
+	igt_fixture {
+		igt_stop_hang_detector();
 		close(fd);
+	}
 }
-- 
2.8.1



More information about the Intel-gfx mailing list