Skip to contentSkip to conversation

igt subtests support and piglit integration

PATCH In review Daniel Vetter 2 participants 7 messages Nov 27, 2012 – Nov 29, 2012 Library code

lore
Share & tools
lore
#0 lore raw

cover igt subtests support and piglit integration

Hi all,

This little patchseries adds some support to the Makefiles so that the piglit igt integration can automagically enumerate tests, without the need to specify things at a hundred different places.

The second part adds some small infrastructure to support subtests in a simple way. The piglit support adds each subtests as a sparate testcase, and starts each binary with --run-subtest <testname> for each one. As a proof of concept I've converted flip_test, but I plan to slouch through all the others in the next few days.

I've pushed the piglit stuff to

http://cgit.freedesktop.org/~danvet/piglit/log/

Comments and flames highly welcome.

Cheers, Daniel

Daniel Vetter (5):
tests: infrastructure for piglit runner
tests: remove ZZ_check_dmesg from runner
tests: dont polute stderr if the test succeeds/skips lib/drmtest: subtest infrastructure tests/flip_test: use subtest infrastructure

 lib/drmtest.c           | 63 +++++++++++++++++++++++++++++++++++++++++++++++++
 lib/drmtest.h           |  3 +++
 tests/Makefile.am       | 44 +++++++++++++++++++++++++++-------
 tests/flip_test.c       | 51 +++++++++++++++++++++------------------
 tests/gem_cpu_reloc.c   |  2 +-
 tests/gem_cs_prefetch.c |  2 +-
 tests/gem_ctx_create.c  |  2 +-
 tests/sysfs_rps.c       |  2 +-
 8 files changed, 133 insertions(+), 36 deletions(-)
Signature · 1 line
1.7.11.7
#1 lore raw

PATCH 1/5 tests: infrastructure for piglit runner

Piglit needs a way to grab the latest list of tests to run, so add new make targets to dump those. Note that for future extendability we'll dump 2 different lists, one for single-testcase tests and one for testcases with enumerable subcases. Some support code for the later will follow in subsequent patches.

---
 tests/Makefile.am | 41 ++++++++++++++++++++++++++++++++++-------
 1 file changed, 34 insertions(+), 7 deletions(-)
tests/Makefile.am +34 -7
index 735eb09..f7b530f 100644
@@ -1,6 +1,7 @@
 noinst_PROGRAMS = \
 	gem_stress \
 	$(TESTS_progs) \
+	$(TESTS_progs_M) \
 	$(HANG) \
 	$(NULL)
 
@@ -11,6 +12,9 @@ NOUVEAU_TESTS = \
 	prime_nv_test
 endif
 
+TESTS_progs_M = \
+	$(NULL)
+
 TESTS_progs = \
 	getversion \
 	getclient \
@@ -30,7 +34,7 @@ TESTS_progs = \
 	gem_ringfill \
 	gem_mmap \
 	gem_mmap_gtt \
-	gem_mmap_offset_exhaustion \
+	#gem_mmap_offset_exhaustion \
 	gem_non_secure_batch \
 	gem_pwrite \
 	gem_pread_after_blit \
@@ -91,6 +95,9 @@ TESTS_progs = \
 
 # IMPORTANT: The ZZ_ tests need to be run last!
 # ... and make can't deal with inlined comments ...
+TESTS_scripts_M = \
+	$(NULL)
+
 TESTS_scripts = \
 	debugfs_reader \
 	debugfs_emon_crash \
@@ -101,18 +108,38 @@ TESTS_scripts = \
 	ZZ_hangman \
 	$(NULL)
 
-kernel_tests = \
+multi_kernel_tests = \
+	$(TESTS_progs_M) \
+	$(TESTS_scripts_M) \
+	$(NULL)
+
+single_kernel_tests = \
 	$(TESTS_progs) \
 	$(TESTS_scripts) \
 	$(NULL)
 
+kernel_tests = \
+	$(single_kernel_tests) \
+	$(multi_kernel_tests) \
+	$(NULL)
+
 TESTS = \
 	$(NULL)
 
 test:
-	whoami | grep root || ( echo ERROR: not running as root; exit 1 )
-	./check_drm_clients
-	make TESTS="${kernel_tests}" check
+	@whoami | grep root || ( echo ERROR: not running as root; exit 1 )
+	@./check_drm_clients
+	@make TESTS="${kernel_tests}" check
+
+list-single-tests:
+	@echo TESTLIST
+	@echo ${single_kernel_tests}
+	@echo END TESTLIST
+
+list-multi-tests:
+	@echo TESTLIST
+	@echo ${multi_kernel_tests}
+	@echo END TESTLIST
 
 HANG = \
 	gem_bad_batch \
@@ -121,8 +148,8 @@ HANG = \
 	gem_bad_address \
 	$(NULL)
 
-EXTRA_PROGRAMS = $(TESTS_progs) $(HANG)
-EXTRA_DIST = $(TESTS_scripts) drm_lib.sh check_drm_clients debugfs_wedged
+EXTRA_PROGRAMS = $(TESTS_progs) $(TESTS_progs_M) $(HANG)
+EXTRA_DIST = $(TESTS_scripts) $(TESTS_scripts_M) drm_lib.sh check_drm_clients debugfs_wedged
 CLEANFILES = $(EXTRA_PROGRAMS)
 
 AM_CFLAGS = $(DRM_CFLAGS) $(CWARNFLAGS) \
Signature · 1 line
1.7.11.7
#2 lore raw

PATCH 2/5 tests: remove ZZ_check_dmesg from runner

In reply to Daniel Vetter

This is getting in the way of piglit integration. If we want this functionality again, we should integrate it into the IGT piglit runner as an option.

---
 tests/Makefile.am | 1 -
 1 file changed, 1 deletion(-)
tests/Makefile.am +0 -1
index f7b530f..ff6e829 100644
@@ -104,7 +104,6 @@ TESTS_scripts = \
 	sysfs_l3_parity \
 	sysfs_edid_timing \
 	module_reload \
-	ZZ_check_dmesg \
 	ZZ_hangman \
 	$(NULL)
 
Signature · 1 line
1.7.11.7
#3 lore raw

PATCH 3/5 tests: dont polute stderr if the test succeeds/skips

In reply to Daniel Vetter

Results in spurious 'warn' results in piglit. Also don't print progress indicators when not outputting to a terminal.

---
 lib/drmtest.c           | 3 +++
 tests/gem_cpu_reloc.c   | 2 +-
 tests/gem_cs_prefetch.c | 2 +-
 tests/gem_ctx_create.c  | 2 +-
 tests/sysfs_rps.c       | 2 +-
 5 files changed, 7 insertions(+), 4 deletions(-)
lib/drmtest.c +3 -0
index c309851..a18b3a0 100644
@@ -543,6 +543,9 @@ void drmtest_progress(const char *header, uint64_t i, uint64_t total)
 {
 	int divider = 200;
 
+	if (!isatty(fileno(stderr)))
+		return;
+
 	if (i+1 >= total) {
 		fprintf(stderr, "\r%s100%%\n", header);
 		return;
tests/gem_cpu_reloc.c +1 -1
index 787e507..baf8301 100644
@@ -209,7 +209,7 @@ int main(int argc, char **argv)
 		drmtest_progress("gem_cpu_reloc: ", 2*count+i, 3*count);
 	}
 
-	fprintf(stderr, "Test suceeded, cleanup up - this might take a while.\n");
+	printf("Test suceeded, cleanup up - this might take a while.\n");
 	close(fd);
 
 	return 0;
tests/gem_cs_prefetch.c +1 -1
index 9ba8028..9ef35eb 100644
@@ -163,7 +163,7 @@ int main(int argc, char **argv)
 		drmtest_progress("gem_cs_prefetch: ", i, count);
 	}
 
-	fprintf(stderr, "Test suceeded, cleanup up - this might take a while.\n");
+	printf("Test suceeded, cleanup up - this might take a while.\n");
 	drm_intel_bufmgr_destroy(bufmgr);
 
 	close(fd);
tests/gem_ctx_create.c +1 -1
index def76d3..84ef214 100644
@@ -49,7 +49,7 @@ int main(int argc, char *argv[])
 
 	ret = drmIoctl(fd, CONTEXT_CREATE_IOCTL, &create);
 	if (ret != 0 && (errno == ENODEV || errno == EINVAL)) {
-		fprintf(stderr, "Kernel is too old, or contexts not supported: %s\n",
+		printf("Kernel is too old, or contexts not supported: %s\n",
 			strerror(errno));
 		exit(77);
 	} else if (ret != 0) {
tests/sysfs_rps.c +1 -1
index 94c4382..8ba541c 100644
@@ -147,7 +147,7 @@ int main(int argc, char *argv[])
 		assert(ret != -1);
 		junk->filp = fopen(path, junk->mode);
 		if (junk->filp == NULL) {
-			fprintf(stderr, "Kernel is too old. GTFO\n");
+			printf("Kernel is too old. GTFO\n");
 			exit(77);
 		}
 		val = readval(junk->filp);
Signature · 1 line
1.7.11.7
#4 lore raw

PATCH 4/5 lib/drmtest: subtest infrastructure

In reply to Daniel Vetter

To make these helpers as least invasive as possible simply initialize the options with a getopt parser and let the control flow be steered with a simple helper which gets the subtest name as an argument.

The only tricky part for using it is that the subtest check helper doubles up as the conduit to enumerate tests (and in that mode prevents any test from being run). It is therefore important that nothing gets printed to stdout outside of these checks.

---
 lib/drmtest.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/drmtest.h |  3 +++
 2 files changed, 63 insertions(+)
lib/drmtest.c +60 -0
index a18b3a0..8ff4b2e 100644
@@ -36,6 +36,7 @@
 #include <signal.h>
 #include <pciaccess.h>
 #include <math.h>
+#include <getopt.h>
 
 #include "drmtest.h"
 #include "i915_drm.h"
@@ -513,6 +514,65 @@ void drmtest_stop_signal_helper(void)
 	signal_helper = -1;
 }
 
+/* subtests helpers */
+static bool list_subtests = false;
+static char *run_single_subtest = NULL;
+
+void drmtest_subtest_init(int argc, char **argv)
+{
+	int c, option_index = 0;
+	static struct option long_options[] = {
+		{"list-subtests", 0, 0, 'l'},
+		{"run-subtest", 1, 0, 'r'},
+		{NULL, 0, 0, 0,}
+	};
+
+	/* supress getopt errors about unknown options */
+	opterr = 0;
+	while((c = getopt_long(argc, argv, "",
+			       long_options, &option_index)) != -1) {
+		switch(c) {
+		case 'l':
+			list_subtests = true;
+			goto out;
+		case 'S':
+			run_single_subtest = strdup(optarg);
+			goto out;
+		}
+	}
+
+out:
+	/* reset opt parsing */
+	optind = 1;
+}
+
+/*
+ * Note: Testcases which use these helpers MUST NOT output anything to stdout
+ * outside of places protected by drmtest_run_subtest checks - the piglit
+ * runner adds every line to the subtest list.
+ */
+bool drmtest_run_subtest(const char *subtest_name)
+{
+	if (list_subtests) {
+		printf("%s\n", subtest_name);
+		return false;
+	}
+
+	if (!run_single_subtest) {
+		return true;
+	} else {
+		if (strcmp(subtest_name, run_single_subtest) == 0)
+			return true;
+
+		return false;
+	}
+}
+
+bool drmtest_only_list_subtests(void)
+{
+	return list_subtests;
+}
+
 /* other helpers */
 void drmtest_exchange_int(void *array, unsigned i, unsigned j)
 {
lib/drmtest.h +3 -0
index fcb10bb..796fa83 100644
@@ -84,6 +84,9 @@ void drmtest_permute_array(void *array, unsigned size,
 						 unsigned i,
 						 unsigned j));
 void drmtest_progress(const char *header, uint64_t i, uint64_t total);
+void drmtest_subtest_init(int argc, char **argv);
+bool drmtest_run_subtest(const char *subtest_name);
+bool drmtest_only_list_subtests(void);
 
 /* helpers based upon the libdrm buffer manager */
 void drmtest_init_aperture_trashers(drm_intel_bufmgr *bufmgr);
Signature · 1 line
1.7.11.7
#5 lore raw

PATCH 5/5 tests/flip_test: use subtest infrastructure

In reply to Daniel Vetter

To make the testnames easier to handle in scripts, replace all spaces with dashes.

The important part is to not print anything to stdout when enumerating subtests, so protect the timestamp test with the right check.

---
 tests/Makefile.am |  2 +-
 tests/flip_test.c | 51 ++++++++++++++++++++++++++++-----------------------
 2 files changed, 29 insertions(+), 24 deletions(-)
tests/Makefile.am +1 -1
index ff6e829..f4a3abb 100644
@@ -13,6 +13,7 @@ NOUVEAU_TESTS = \
 endif
 
 TESTS_progs_M = \
+	flip_test \
 	$(NULL)
 
 TESTS_progs = \
@@ -81,7 +82,6 @@ TESTS_progs = \
 	drm_vma_limiter_cached \
 	sysfs_rc6_residency \
 	sysfs_rps \
-	flip_test \
 	gem_wait_render_timeout \
 	gem_ctx_create \
 	gem_ctx_bad_destroy \
tests/flip_test.c +28 -23

78 lines not on this page · raw message

Signature · 1 line
1.7.11.7
#6 lore raw

Re: [PATCH 5/5] tests/flip_test: use subtest infrastructure

Quoted 37 lines · Daniel Vetter

To make the testnames easier to handle in scripts, replace all spaces with dashes.

The important part is to not print anything to stdout when enumerating subtests, so protect the timestamp test with the right check.

---
 tests/Makefile.am |  2 +-
 tests/flip_test.c | 51 ++++++++++++++++++++++++++++-----------------------
 2 files changed, 29 insertions(+), 24 deletions(-)
tests/Makefile.am +1 -1
index ff6e829..f4a3abb 100644
@@ -13,6 +13,7 @@ NOUVEAU_TESTS = \
 endif
 
 TESTS_progs_M = \
+	flip_test \
 	$(NULL)
 
 TESTS_progs = \
@@ -81,7 +82,6 @@ TESTS_progs = \
 	drm_vma_limiter_cached \
 	sysfs_rc6_residency \
 	sysfs_rps \
-	flip_test \
 	gem_wait_render_timeout \
 	gem_ctx_create \
 	gem_ctx_bad_destroy \
tests/flip_test.c +0 -0
index 5214da9..5ad62d1 100644

tests/flip_test.c int main(int argc, char **argv) · line 974

Quoted 8 lines
tests/flip_test.c +2 -2
@@ -969,50 +969,55 @@ int main(int argc, char **argv)
 		int flags;
 		const char *name;
 	} tests[] = {
-		{ 15, TEST_VBLANK | TEST_CHECK_TS, "wf-vblank" },
+		{ 15, TEST_VBLANK | TEST_CHECK_TS, "wf_vblank" },
 		{ 15, TEST_VBLANK | TEST_VBLANK_BLOCK | TEST_CHECK_TS,
-					"blocking wf-vblank" },
+					"blocking-wf_vblank" },

The commit message says nothing about replacing dashes with underscores. Seems to me it would be better to leave dashes as they are, and replace spaces with underscores. Or replace all [^a-zA-Z0-9] with -.

BR,
Jani.

Quoted 77 lines
tests/flip_test.c +26 -21
 		{ 5,  TEST_VBLANK | TEST_VBLANK_ABSOLUTE,
-					"absolute wf-vblank" },
+					"absolute-wf_vblank" },
 		{ 5,  TEST_VBLANK | TEST_VBLANK_BLOCK | TEST_VBLANK_ABSOLUTE,
-					"blocking absolute wf-vblank" },
-		{ 30,  TEST_VBLANK | TEST_DPMS | TEST_EINVAL, "wf-vblank vs dpms" },
+					"blocking-absolute-wf_vblank" },
+		{ 30,  TEST_VBLANK | TEST_DPMS | TEST_EINVAL, "wf_vblank-vs-dpms" },
 		{ 30,  TEST_VBLANK | TEST_DPMS | TEST_WITH_DUMMY_LOAD,
-					"delayed wf-vblank vs dpms" },
-		{ 30,  TEST_VBLANK | TEST_MODESET | TEST_EINVAL, "wf-vblank vs modeset" },
+					"delayed-wf_vblank-vs-dpms" },
+		{ 30,  TEST_VBLANK | TEST_MODESET | TEST_EINVAL, "wf_vblank-vs-modeset" },
 		{ 30,  TEST_VBLANK | TEST_MODESET | TEST_WITH_DUMMY_LOAD,
-					"delayed wf-vblank vs modeset" },
-
-		{ 15, TEST_FLIP | TEST_CHECK_TS | TEST_EBUSY , "plain flip" },
-		{ 30, TEST_FLIP | TEST_DPMS | TEST_EINVAL, "flip vs dpms" },
-		{ 30, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_LOAD, "delayed flip vs dpms" },
-		{ 5,  TEST_FLIP | TEST_PAN, "flip vs panning" },
-		{ 30, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_LOAD, "delayed flip vs panning" },
-		{ 30, TEST_FLIP | TEST_MODESET | TEST_EINVAL, "flip vs modeset" },
-		{ 30, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_LOAD, "delayed flip vs modeset" },
+					"delayed-wf_vblank-vs-modeset" },
+
+		{ 15, TEST_FLIP | TEST_CHECK_TS | TEST_EBUSY , "plain-flip" },
+		{ 30, TEST_FLIP | TEST_DPMS | TEST_EINVAL, "flip-vs-dpms" },
+		{ 30, TEST_FLIP | TEST_DPMS | TEST_WITH_DUMMY_LOAD, "delayed-flip-vs-dpms" },
+		{ 5,  TEST_FLIP | TEST_PAN, "flip-vs-panning" },
+		{ 30, TEST_FLIP | TEST_PAN | TEST_WITH_DUMMY_LOAD, "delayed-flip-vs-panning" },
+		{ 30, TEST_FLIP | TEST_MODESET | TEST_EINVAL, "flip-vs-modeset" },
+		{ 30, TEST_FLIP | TEST_MODESET | TEST_WITH_DUMMY_LOAD, "delayed-flip-vs-modeset" },
 		{ 5,  TEST_FLIP | TEST_VBLANK_EXPIRED_SEQ,
-					"flip vs. expired vblank" },
+					"flip-vs-expired-vblank" },
 
 		{ 15, TEST_FLIP | TEST_VBLANK | TEST_VBLANK_ABSOLUTE |
-		      TEST_CHECK_TS, "flip vs absolute wf-vblank" },
+		      TEST_CHECK_TS, "flip-vs-absolute-wf_vblank" },
 		{ 15, TEST_FLIP | TEST_VBLANK | TEST_CHECK_TS,
-					"flip vs wf-vblank" },
+					"flip-vs-wf_vblank" },
 		{ 15, TEST_FLIP | TEST_VBLANK | TEST_VBLANK_BLOCK |
-			TEST_CHECK_TS, "flip vs blocking wf-vblank" },
+			TEST_CHECK_TS, "flip-vs-blocking-wf-vblank" },
 	};
 	int i;
 
+	drmtest_subtest_init(argc, argv);
+
 	drm_fd = drm_open_any();
 
-	get_timestamp_format();
+	if (!drmtest_only_list_subtests())
+		get_timestamp_format();
 
 	bufmgr = drm_intel_bufmgr_gem_init(drm_fd, 4096);
 	devid = intel_get_drm_devid(drm_fd);
 	batch = intel_batchbuffer_alloc(bufmgr, devid);
 
 	for (i = 0; i < sizeof(tests) / sizeof (tests[0]); i++) {
-		printf("running testcase: %s\n", tests[i].name);
-		run_test(tests[i].duration, tests[i].flags, tests[i].name);
+		if (drmtest_run_subtest(tests[i].name)) {
+			printf("running testcase: %s\n", tests[i].name);
+			run_test(tests[i].duration, tests[i].flags, tests[i].name);
+		}
 	}
 
 	close(drm_fd);
Signature · 6 lines
1.7.11.7

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