Skip to contentSkip to conversation

tests/gem_reset_stats: Correctly wrap global test code

PATCH New Daniel Vetter 1 participant 2 messages Feb 11, 2014 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 tests/gem_reset_stats: Correctly wrap global test code

Tests _must_ be able to run as non-root and on non-intel platforms, otherwise the enumeration is busted (since QA enumerates testcases on a gpu-less xeon box).

---
 tests/gem_reset_stats.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
tests/gem_reset_stats.c +7 -6
index 331d954752d5..a7d6550df07a 100644
@@ -1020,6 +1020,8 @@ static void test_params(void)
 #define RING_HAS_CONTEXTS current_ring->contexts(current_ring)
 #define RUN_CTX_TEST(...) do { igt_skip_on(RING_HAS_CONTEXTS == false); __VA_ARGS__; } while (0)
 
+int fd;
+
 igt_main
 {
 	struct local_drm_i915_gem_context_create create;
@@ -1029,7 +1031,6 @@ igt_main
 	igt_skip_on_simulation();
 
 	igt_fixture {
-		int fd;
 		fd = drm_open_any();
 		devid = intel_get_drm_devid(fd);
 		igt_require_f(intel_gen(devid) >= 4,
@@ -1041,8 +1042,6 @@ igt_main
 			      strerror(errno));
 
 		assert(igt_debugfs_init(&dfs) == 0);
-
-		close(fd);
 	}
 
 	igt_subtest("params")
@@ -1050,13 +1049,12 @@ igt_main
 
 	for (int i = 0; i < NUM_RINGS; i++) {
 		const char *name;
-		int fd;
 
 		current_ring = &rings[i];
 		name = current_ring->name;
 
-		fd = drm_open_any();
-		gem_require_ring(fd, current_ring->exec);
+		igt_fixture
+			gem_require_ring(fd, current_ring->exec);
 
 		igt_subtest_f("reset-stats-%s", name)
 			test_rs(4, 1, 0);
@@ -1094,4 +1092,7 @@ igt_main
 			test_close_pending_fork(false);
 		}
 	}
+
+	igt_fixture
+		close(fd);
 }
Signature · 1 line
1.8.1.4
#1 lore raw

PATCH 2/2 lib/drmtest: Fix up skip_henceforth checks

We need to first check whether we'll even run the testcase before deciding to print a premature SKIP/FAIL. Without this and global skipped resulted in superflous output when running only one testcase.

References: https://bugs.freedesktop.org/show_bug.cgi?id=74100

---
 lib/drmtest.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)
lib/drmtest.c +5 -8
index f4a860058551..2718de4d0a4b 100644
@@ -972,6 +972,10 @@ bool __igt_run_subtest(const char *subtest_name)
 		return false;
 	}
 
+	if (run_single_subtest &&
+	    strcmp(subtest_name, run_single_subtest) != 0)
+		return false;
+
 	if (skip_subtests_henceforth) {
 		printf("Subtest %s: %s\n", subtest_name,
 		       skip_subtests_henceforth == SKIP ?
@@ -979,14 +983,7 @@ bool __igt_run_subtest(const char *subtest_name)
 		return false;
 	}
 
-	if (!run_single_subtest) {
-		return (in_subtest = subtest_name);
-	} else {
-		if (strcmp(subtest_name, run_single_subtest) == 0)
-			return (in_subtest = subtest_name);
-
-		return false;
-	}
+	return (in_subtest = subtest_name);
 }
 
 const char *igt_subtest_name(void)
Signature · 1 line
1.8.1.4