[Intel-gfx] [PATCH 2/7] lib/drmtest: Add drmtest_subtest_block macro

Daniel Vetter daniel.vetter at ffwll.ch
Mon Aug 12 11:09:56 CEST 2013


Doesn't do more than an if (drmtest_run_test(name)) right now, but
as soon as we get a bit of infrastructure to handle test failures and
skipping, this will get more interesting.

Signed-off-by: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 lib/drmtest.h                          |  1 +
 tests/gem_basic.c                      |  6 +++---
 tests/gem_cpu_concurrent_blit.c        | 12 ++++++------
 tests/gem_cs_tlb.c                     |  8 ++++----
 tests/gem_dummy_reloc_loop.c           | 10 +++++-----
 tests/gem_exec_bad_domains.c           | 10 +++++-----
 tests/gem_exec_faulting_reloc.c        |  4 ++--
 tests/gem_exec_nop.c                   |  8 ++++----
 tests/gem_fence_thrash.c               | 14 +++++++-------
 tests/gem_flink.c                      | 10 +++++-----
 tests/gem_flink_race.c                 |  4 ++--
 tests/gem_gtt_concurrent_blit.c        | 12 ++++++------
 tests/gem_linear_blits.c               |  4 ++--
 tests/gem_mmap_gtt.c                   | 14 +++++++-------
 tests/gem_partial_pwrite_pread.c       |  6 +++---
 tests/gem_pread_after_blit.c           | 16 ++++++++--------
 tests/gem_prw_concurrent_blit.c        | 12 ++++++------
 tests/gem_pwrite_pread.c               | 24 ++++++++++++------------
 tests/gem_ringfill.c                   |  8 +++++---
 tests/gem_set_tiling_vs_blt.c          |  6 +++---
 tests/gem_suspend.c                    |  4 ++--
 tests/gem_tiled_blits.c                |  4 ++--
 tests/gem_tiled_partial_pwrite_pread.c |  6 +++---
 tests/gem_write_read_ring_switch.c     |  9 +++++----
 tests/kms_flip.c                       |  4 ++--
 tests/kms_render.c                     |  2 +-
 tests/prime_nv_api.c                   |  2 +-
 tests/prime_nv_pcopy.c                 | 17 +++++++++--------
 tests/prime_nv_test.c                  |  2 +-
 tests/prime_self_import.c              |  2 +-
 30 files changed, 123 insertions(+), 118 deletions(-)

diff --git a/lib/drmtest.h b/lib/drmtest.h
index 773beaa..ada8e81 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -95,6 +95,7 @@ void drmtest_progress(const char *header, uint64_t i, uint64_t total);
 /* subtest infrastructure */
 void drmtest_subtest_init(int argc, char **argv);
 bool drmtest_run_subtest(const char *subtest_name);
+#define drmtest_subtest_block(name) if (drmtest_run_subtest((name)))
 bool drmtest_only_list_subtests(void);
 
 /* helpers to automatically reduce test runtime in simulation */
diff --git a/tests/gem_basic.c b/tests/gem_basic.c
index 5cc8684..900194d 100644
--- a/tests/gem_basic.c
+++ b/tests/gem_basic.c
@@ -84,11 +84,11 @@ int main(int argc, char **argv)
 
 	fd = drm_open_any();
 
-	if (drmtest_run_subtest("bad-close"))
+	drmtest_subtest_block("bad-close")
 		test_bad_close(fd);
-	if (drmtest_run_subtest("create-close"))
+	drmtest_subtest_block("create-close")
 		test_create_close(fd);
-	if (drmtest_run_subtest("create-fd-close"))
+	drmtest_subtest_block("create-fd-close")
 		test_create_fd_close(fd);
 
 	return 0;
diff --git a/tests/gem_cpu_concurrent_blit.c b/tests/gem_cpu_concurrent_blit.c
index e6cc50b..7bcfcd8 100644
--- a/tests/gem_cpu_concurrent_blit.c
+++ b/tests/gem_cpu_concurrent_blit.c
@@ -117,7 +117,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to overwrite the source values */
-	if (drmtest_run_subtest("overwrite-source")) {
+	drmtest_subtest_block("overwrite-source") {
 		for (i = 0; i < num_buffers; i++) {
 			set_bo(src[i], i, width, height);
 			set_bo(dst[i], i, width, height);
@@ -131,7 +131,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to read the results before the copy completes */
-	if (drmtest_run_subtest("early-read")) {
+	drmtest_subtest_block("early-read") {
 		for (i = num_buffers; i--; )
 			set_bo(src[i], 0xdeadbeef, width, height);
 		for (i = 0; i < num_buffers; i++)
@@ -141,7 +141,7 @@ main(int argc, char **argv)
 	}
 
 	/* and finally try to trick the kernel into loosing the pending write */
-	if (drmtest_run_subtest("gpu-read-after-write")) {
+	drmtest_subtest_block("gpu-read-after-write") {
 		for (i = num_buffers; i--; )
 			set_bo(src[i], 0xabcdabcd, width, height);
 		for (i = 0; i < num_buffers; i++)
@@ -155,7 +155,7 @@ main(int argc, char **argv)
 	drmtest_fork_signal_helper();
 
 	/* try to overwrite the source values */
-	if (drmtest_run_subtest("overwrite-source-interruptible")) {
+	drmtest_subtest_block("overwrite-source-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = 0; i < num_buffers; i++) {
@@ -172,7 +172,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to read the results before the copy completes */
-	if (drmtest_run_subtest("early-read-interruptible")) {
+	drmtest_subtest_block("early-read-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = num_buffers; i--; )
@@ -185,7 +185,7 @@ main(int argc, char **argv)
 	}
 
 	/* and finally try to trick the kernel into loosing the pending write */
-	if (drmtest_run_subtest("gpu-read-after-write-interruptible")) {
+	drmtest_subtest_block("gpu-read-after-write-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = num_buffers; i--; )
diff --git a/tests/gem_cs_tlb.c b/tests/gem_cs_tlb.c
index 05e78c2..081b6f2 100644
--- a/tests/gem_cs_tlb.c
+++ b/tests/gem_cs_tlb.c
@@ -164,18 +164,18 @@ int main(int argc, char **argv)
 		sleep(5); /* needs more serious ducttape */
 	}
 
-	if (drmtest_run_subtest("render"))
+	drmtest_subtest_block("render")
 		run_on_ring(fd, I915_EXEC_RENDER, "render");
 
-	if (drmtest_run_subtest("bsd"))
+	drmtest_subtest_block("bsd")
 		if (HAS_BSD_RING(devid))
 			run_on_ring(fd, I915_EXEC_BSD, "bsd");
 
-	if (drmtest_run_subtest("blt"))
+	drmtest_subtest_block("blt")
 		if (HAS_BLT_RING(devid))
 			run_on_ring(fd, I915_EXEC_BLT, "blt");
 
-	if (drmtest_run_subtest("vebox"))
+	drmtest_subtest_block("vebox")
 		if (gem_has_vebox(fd))
 			run_on_ring(fd, LOCAL_I915_EXEC_VEBOX, "vebox");
 
diff --git a/tests/gem_dummy_reloc_loop.c b/tests/gem_dummy_reloc_loop.c
index b889f83..7cffbbe 100644
--- a/tests/gem_dummy_reloc_loop.c
+++ b/tests/gem_dummy_reloc_loop.c
@@ -160,13 +160,13 @@ int main(int argc, char **argv)
 		exit(-1);
 	}
 
-	if (drmtest_run_subtest("render")) {
+	drmtest_subtest_block("render") {
 		printf("running dummy loop on render\n");
 		dummy_reloc_loop(I915_EXEC_RENDER);
 		printf("dummy loop run on render completed\n");
 	}
 
-	if (drmtest_run_subtest("bsd")) {
+	drmtest_subtest_block("bsd") {
 		if (HAS_BSD_RING(devid)) {
 			sleep(2);
 			printf("running dummy loop on bsd\n");
@@ -175,7 +175,7 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if (drmtest_run_subtest("blt")) {
+	drmtest_subtest_block("blt") {
 		if (HAS_BLT_RING(devid)) {
 			sleep(2);
 			printf("running dummy loop on blt\n");
@@ -184,7 +184,7 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if (drmtest_run_subtest("vebox")) {
+	drmtest_subtest_block("vebox") {
 		if (gem_has_vebox(fd)) {
 			sleep(2);
 			printf("running dummy loop on vebox\n");
@@ -193,7 +193,7 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if (drmtest_run_subtest("mixed")) {
+	drmtest_subtest_block("mixed") {
 		if (num_rings > 1) {
 			sleep(2);
 			printf("running dummy loop on random rings\n");
diff --git a/tests/gem_exec_bad_domains.c b/tests/gem_exec_bad_domains.c
index d174349..53c33fd 100644
--- a/tests/gem_exec_bad_domains.c
+++ b/tests/gem_exec_bad_domains.c
@@ -166,7 +166,7 @@ int main(int argc, char **argv)
 
 	tmp = drm_intel_bo_alloc(bufmgr, "tmp", 128 * 128, 4096);
 
-	if (drmtest_run_subtest("cpu-domain")) {
+	drmtest_subtest_block("cpu-domain") {
 		BEGIN_BATCH(2);
 		OUT_BATCH(0);
 		OUT_RELOC(tmp, I915_GEM_DOMAIN_CPU, 0, 0);
@@ -188,7 +188,7 @@ int main(int argc, char **argv)
 		}
 	}
 
-	if (drmtest_run_subtest("gtt-domain")) {
+	drmtest_subtest_block("gtt-domain") {
 		BEGIN_BATCH(2);
 		OUT_BATCH(0);
 		OUT_RELOC(tmp, I915_GEM_DOMAIN_GTT, 0, 0);
@@ -212,7 +212,7 @@ int main(int argc, char **argv)
 
 #if 0 /* kernel checks have been eased, doesn't reject conflicting write domains
 	 any more */
-	if (drmtest_run_subtest("conflicting-write-domain")) {
+	drmtest_subtest_block("conflicting-write-domain") {
 		BEGIN_BATCH(4);
 		OUT_BATCH(0);
 		OUT_RELOC(tmp, I915_GEM_DOMAIN_RENDER,
@@ -229,10 +229,10 @@ int main(int argc, char **argv)
 	}
 #endif
 
-	if (drmtest_run_subtest("double-write-domain"))
+	drmtest_subtest_block("double-write-domain")
 		multi_write_domain(fd);
 
-	if (drmtest_run_subtest("invalid-gpu-domain")) {
+	drmtest_subtest_block("invalid-gpu-domain") {
 		BEGIN_BATCH(2);
 		OUT_BATCH(0);
 		OUT_RELOC(tmp, ~(I915_GEM_GPU_DOMAINS | I915_GEM_DOMAIN_GTT | I915_GEM_DOMAIN_CPU),
diff --git a/tests/gem_exec_faulting_reloc.c b/tests/gem_exec_faulting_reloc.c
index c7f7b6b..d9c9db3 100644
--- a/tests/gem_exec_faulting_reloc.c
+++ b/tests/gem_exec_faulting_reloc.c
@@ -222,9 +222,9 @@ int main(int argc, char **argv)
 {
 	drmtest_subtest_init(argc, argv);
 
-	if (drmtest_run_subtest("normal"))
+	drmtest_subtest_block("normal")
 		run(OBJECT_SIZE);
-	if (drmtest_run_subtest("no-prefault")) {
+	drmtest_subtest_block("no-prefault") {
 		drmtest_disable_prefault();
 		run(OBJECT_SIZE);
 		drmtest_enable_prefault();
diff --git a/tests/gem_exec_nop.c b/tests/gem_exec_nop.c
index 35cb23d..ca1f580 100644
--- a/tests/gem_exec_nop.c
+++ b/tests/gem_exec_nop.c
@@ -124,18 +124,18 @@ int main(int argc, char **argv)
 	handle = gem_create(fd, 4096);
 	gem_write(fd, handle, 0, batch, sizeof(batch));
 
-	if (drmtest_run_subtest("render"))
+	drmtest_subtest_block("render")
 		loop(fd, handle, I915_EXEC_RENDER, "render");
 
-	if (drmtest_run_subtest("bsd"))
+	drmtest_subtest_block("bsd")
 		if (HAS_BSD_RING(devid))
 			loop(fd, handle, I915_EXEC_BSD, "bsd");
 
-	if (drmtest_run_subtest("blt"))
+	drmtest_subtest_block("blt")
 		if (HAS_BLT_RING(devid))
 			loop(fd, handle, I915_EXEC_BLT, "blt");
 
-	if (drmtest_run_subtest("vebox"))
+	drmtest_subtest_block("vebox")
 		if (gem_has_vebox(fd))
 			loop(fd, handle, LOCAL_I915_EXEC_VEBOX, "vebox");
 
diff --git a/tests/gem_fence_thrash.c b/tests/gem_fence_thrash.c
index a28c127..a6cd6ee 100644
--- a/tests/gem_fence_thrash.c
+++ b/tests/gem_fence_thrash.c
@@ -210,33 +210,33 @@ main(int argc, char **argv)
 	drmtest_subtest_init(argc, argv);
 	drmtest_skip_on_simulation();
 
-	if (drmtest_run_subtest("bo-write-verify-none"))
+	drmtest_subtest_block("bo-write-verify-none")
 		assert (run_test(0, bo_write_verify, I915_TILING_NONE, 80) == 0);
 
-	if (drmtest_run_subtest("bo-write-verify-x"))
+	drmtest_subtest_block("bo-write-verify-x")
 		assert (run_test(0, bo_write_verify, I915_TILING_X, 80) == 0);
 
-	if (drmtest_run_subtest("bo-write-verify-y"))
+	drmtest_subtest_block("bo-write-verify-y")
 		assert (run_test(0, bo_write_verify, I915_TILING_Y, 80) == 0);
 
-	if (drmtest_run_subtest("bo-write-verify-threaded-none"))
+	drmtest_subtest_block("bo-write-verify-threaded-none")
 		assert (run_test(5, bo_write_verify, I915_TILING_NONE, 2) == 0);
 
-	if (drmtest_run_subtest("bo-write-verify-threaded-x")) {
+	drmtest_subtest_block("bo-write-verify-threaded-x") {
 		assert (run_test(2, bo_write_verify, I915_TILING_X, 2) == 0);
 		assert (run_test(5, bo_write_verify, I915_TILING_X, 2) == 0);
 		assert (run_test(10, bo_write_verify, I915_TILING_X, 2) == 0);
 		assert (run_test(20, bo_write_verify, I915_TILING_X, 2) == 0);
 	}
 
-	if (drmtest_run_subtest("bo-write-verify-threaded-y")) {
+	drmtest_subtest_block("bo-write-verify-threaded-y") {
 		assert (run_test(2, bo_write_verify, I915_TILING_Y, 2) == 0);
 		assert (run_test(5, bo_write_verify, I915_TILING_Y, 2) == 0);
 		assert (run_test(10, bo_write_verify, I915_TILING_Y, 2) == 0);
 		assert (run_test(20, bo_write_verify, I915_TILING_Y, 2) == 0);
 	}
 
-	if (drmtest_run_subtest("bo-copy"))
+	drmtest_subtest_block("bo-copy")
 		assert(run_test(1, bo_copy, I915_TILING_X, 1) == 0);
 
 	return 0;
diff --git a/tests/gem_flink.c b/tests/gem_flink.c
index cc4f0e5..abdbfca 100644
--- a/tests/gem_flink.c
+++ b/tests/gem_flink.c
@@ -158,15 +158,15 @@ int main(int argc, char **argv)
 
 	fd = drm_open_any();
 
-	if (drmtest_run_subtest("basic"))
+	drmtest_subtest_block("basic")
 		test_flink(fd);
-	if (drmtest_run_subtest("double-flink"))
+	drmtest_subtest_block("double-flink")
 		test_double_flink(fd);
-	if (drmtest_run_subtest("bad-flink"))
+	drmtest_subtest_block("bad-flink")
 		test_bad_flink(fd);
-	if (drmtest_run_subtest("bad-open"))
+	drmtest_subtest_block("bad-open")
 		test_bad_open(fd);
-	if (drmtest_run_subtest("flink-lifetime"))
+	drmtest_subtest_block("flink-lifetime")
 		test_flink_lifetime(fd);
 
 	return 0;
diff --git a/tests/gem_flink_race.c b/tests/gem_flink_race.c
index ce6f302..4c846e0 100644
--- a/tests/gem_flink_race.c
+++ b/tests/gem_flink_race.c
@@ -197,10 +197,10 @@ int main(int argc, char **argv)
 
 	drmtest_subtest_init(argc, argv);
 
-	if (drmtest_run_subtest("flink_name"))
+	drmtest_subtest_block("flink_name")
 		test_flink_name();
 
-	if (drmtest_run_subtest("flink_close"))
+	drmtest_subtest_block("flink_close")
 		test_flink_close();
 
 	return 0;
diff --git a/tests/gem_gtt_concurrent_blit.c b/tests/gem_gtt_concurrent_blit.c
index b3ac0b4..63fbcc2 100644
--- a/tests/gem_gtt_concurrent_blit.c
+++ b/tests/gem_gtt_concurrent_blit.c
@@ -120,7 +120,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to overwrite the source values */
-	if (drmtest_run_subtest("overwrite-source")) {
+	drmtest_subtest_block("overwrite-source") {
 		for (i = 0; i < num_buffers; i++) {
 			set_bo(src[i], i, width, height);
 			set_bo(dst[i], i, width, height);
@@ -134,7 +134,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to read the results before the copy completes */
-	if (drmtest_run_subtest("early-read")) {
+	drmtest_subtest_block("early-read") {
 		for (i = num_buffers; i--; )
 			set_bo(src[i], 0xdeadbeef, width, height);
 		for (i = 0; i < num_buffers; i++)
@@ -144,7 +144,7 @@ main(int argc, char **argv)
 	}
 
 	/* and finally try to trick the kernel into loosing the pending write */
-	if (drmtest_run_subtest("gpu-read-after-write")) {
+	drmtest_subtest_block("gpu-read-after-write") {
 		for (i = num_buffers; i--; )
 			set_bo(src[i], 0xabcdabcd, width, height);
 		for (i = 0; i < num_buffers; i++)
@@ -158,7 +158,7 @@ main(int argc, char **argv)
 	drmtest_fork_signal_helper();
 
 	/* try to read the results before the copy completes */
-	if (drmtest_run_subtest("overwrite-source-interruptible")) {
+	drmtest_subtest_block("overwrite-source-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = 0; i < num_buffers; i++) {
@@ -175,7 +175,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to read the results before the copy completes */
-	if (drmtest_run_subtest("early-read-interruptible")) {
+	drmtest_subtest_block("early-read-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = num_buffers; i--; )
@@ -188,7 +188,7 @@ main(int argc, char **argv)
 	}
 
 	/* and finally try to trick the kernel into loosing the pending write */
-	if (drmtest_run_subtest("gpu-read-after-write-interruptible")) {
+	drmtest_subtest_block("gpu-read-after-write-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = num_buffers; i--; )
diff --git a/tests/gem_linear_blits.c b/tests/gem_linear_blits.c
index 0956fd0..661baa8 100644
--- a/tests/gem_linear_blits.c
+++ b/tests/gem_linear_blits.c
@@ -264,10 +264,10 @@ int main(int argc, char **argv)
 		printf("Using %d 1MiB buffers\n", count);
 	}
 
-	if (drmtest_run_subtest("normal"))
+	drmtest_subtest_block("normal")
 		run_test(fd, count);
 
-	if (drmtest_run_subtest("interruptible")) {
+	drmtest_subtest_block("interruptible") {
 		drmtest_fork_signal_helper();
 		run_test(fd, count);
 		drmtest_stop_signal_helper();
diff --git a/tests/gem_mmap_gtt.c b/tests/gem_mmap_gtt.c
index 5151ea3..198dd59 100644
--- a/tests/gem_mmap_gtt.c
+++ b/tests/gem_mmap_gtt.c
@@ -164,19 +164,19 @@ int main(int argc, char **argv)
 
 	fd = drm_open_any();
 
-	if (drmtest_run_subtest("copy"))
+	drmtest_subtest_block("copy")
 		test_copy(fd);
-	if (drmtest_run_subtest("read"))
+	drmtest_subtest_block("read")
 		test_read(fd);
-	if (drmtest_run_subtest("write"))
+	drmtest_subtest_block("write")
 		test_write(fd);
-	if (drmtest_run_subtest("write-gtt"))
+	drmtest_subtest_block("write-gtt")
 		test_write_gtt(fd);
-	if (drmtest_run_subtest("read-no-prefault"))
+	drmtest_subtest_block("read-no-prefault")
 		run_without_prefault(fd, test_read);
-	if (drmtest_run_subtest("write-no-prefault"))
+	drmtest_subtest_block("write-no-prefault")
 		run_without_prefault(fd, test_write);
-	if (drmtest_run_subtest("write-gtt-no-prefault"))
+	drmtest_subtest_block("write-gtt-no-prefault")
 		run_without_prefault(fd, test_write_gtt);
 
 	close(fd);
diff --git a/tests/gem_partial_pwrite_pread.c b/tests/gem_partial_pwrite_pread.c
index 0330216..a27e584 100644
--- a/tests/gem_partial_pwrite_pread.c
+++ b/tests/gem_partial_pwrite_pread.c
@@ -270,15 +270,15 @@ static void do_tests(int cache_level, const char *suffix)
 	}
 
 	snprintf(name, sizeof(name), "reads%s", suffix);
-	if (drmtest_run_subtest(name))
+	drmtest_subtest_block(name)
 		test_partial_reads();
 
 	snprintf(name, sizeof(name), "writes%s", suffix);
-	if (drmtest_run_subtest(name))
+	drmtest_subtest_block(name)
 		test_partial_writes();
 
 	snprintf(name, sizeof(name), "writes-after-reads%s", suffix);
-	if (drmtest_run_subtest(name))
+	drmtest_subtest_block(name)
 		test_partial_read_writes();
 }
 
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index 55caa98..7375000 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -190,37 +190,37 @@ main(int argc, char **argv)
 	dst[0] = drm_intel_bo_alloc(bufmgr, "dst bo", size, 4096);
 	dst[1] = drm_intel_bo_alloc(bufmgr, "dst bo", size, 4096);
 
-	if (drmtest_run_subtest("normal"))
+	drmtest_subtest_block("normal")
 		do_test(fd, -1, src, start, dst, 1);
 
-	if (drmtest_run_subtest("interruptible")) {
+	drmtest_subtest_block("interruptible") {
 		drmtest_fork_signal_helper();
 		do_test(fd, -1, src, start, dst, 100);
 		drmtest_stop_signal_helper();
 	}
 
-	if (drmtest_run_subtest("normal-uncached"))
+	drmtest_subtest_block("normal-uncached")
 		do_test(fd, 0, src, start, dst, 1);
 
-	if (drmtest_run_subtest("interruptible-uncached")) {
+	drmtest_subtest_block("interruptible-uncached") {
 		drmtest_fork_signal_helper();
 		do_test(fd, 0, src, start, dst, 100);
 		drmtest_stop_signal_helper();
 	}
 
-	if (drmtest_run_subtest("normal-snoop"))
+	drmtest_subtest_block("normal-snoop")
 		do_test(fd, 1, src, start, dst, 1);
 
-	if (drmtest_run_subtest("interruptible-snoop")) {
+	drmtest_subtest_block("interruptible-snoop") {
 		drmtest_fork_signal_helper();
 		do_test(fd, 1, src, start, dst, 100);
 		drmtest_stop_signal_helper();
 	}
 
-	if (drmtest_run_subtest("normal-display"))
+	drmtest_subtest_block("normal-display")
 		do_test(fd, 2, src, start, dst, 1);
 
-	if (drmtest_run_subtest("interruptible-display")) {
+	drmtest_subtest_block("interruptible-display") {
 		drmtest_fork_signal_helper();
 		do_test(fd, 2, src, start, dst, 100);
 		drmtest_stop_signal_helper();
diff --git a/tests/gem_prw_concurrent_blit.c b/tests/gem_prw_concurrent_blit.c
index 1765f09..2e0d36f 100644
--- a/tests/gem_prw_concurrent_blit.c
+++ b/tests/gem_prw_concurrent_blit.c
@@ -120,7 +120,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to overwrite the source values */
-	if (drmtest_run_subtest("overwrite-source")) {
+	drmtest_subtest_block("overwrite-source") {
 		for (i = 0; i < num_buffers; i++) {
 			set_bo(src[i], i, width, height);
 			set_bo(dst[i], i, width, height);
@@ -134,7 +134,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to read the results before the copy completes */
-	if (drmtest_run_subtest("early-read")) {
+	drmtest_subtest_block("early-read") {
 		for (i = num_buffers; i--; )
 			set_bo(src[i], 0xdeadbeef, width, height);
 		for (i = 0; i < num_buffers; i++)
@@ -144,7 +144,7 @@ main(int argc, char **argv)
 	}
 
 	/* and finally try to trick the kernel into loosing the pending write */
-	if (drmtest_run_subtest("gpu-read-after-write")) {
+	drmtest_subtest_block("gpu-read-after-write") {
 		for (i = num_buffers; i--; )
 			set_bo(src[i], 0xabcdabcd, width, height);
 		for (i = 0; i < num_buffers; i++)
@@ -158,7 +158,7 @@ main(int argc, char **argv)
 	drmtest_fork_signal_helper();
 
 	/* try to read the results before the copy completes */
-	if (drmtest_run_subtest("overwrite-source-interruptible")) {
+	drmtest_subtest_block("overwrite-source-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = 0; i < num_buffers; i++) {
@@ -175,7 +175,7 @@ main(int argc, char **argv)
 	}
 
 	/* try to read the results before the copy completes */
-	if (drmtest_run_subtest("early-read-interruptible")) {
+	drmtest_subtest_block("early-read-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = num_buffers; i--; )
@@ -188,7 +188,7 @@ main(int argc, char **argv)
 	}
 
 	/* and finally try to trick the kernel into loosing the pending write */
-	if (drmtest_run_subtest("gpu-read-after-write-interruptible")) {
+	drmtest_subtest_block("gpu-read-after-write-interruptible") {
 		for (loop = 0; loop < 10; loop++) {
 			gem_quiescent_gpu(fd);
 			for (i = num_buffers; i--; )
diff --git a/tests/gem_pwrite_pread.c b/tests/gem_pwrite_pread.c
index 65427c3..d29c531 100644
--- a/tests/gem_pwrite_pread.c
+++ b/tests/gem_pwrite_pread.c
@@ -400,9 +400,9 @@ int main(int argc, char **argv)
 
 	if (gem_set_caching(fd, src, 0) == 0 &&
 	    gem_set_caching(fd, dst, 0) == 0) {
-		if (drmtest_run_subtest("uncached-copy-correctness"))
+		drmtest_subtest_block("uncached-copy-correctness")
 			test_copy(fd, src, dst, tmp, object_size);
-		if (drmtest_run_subtest("uncached-copy-performance")) {
+		drmtest_subtest_block("uncached-copy-performance") {
 			for (count = 1; count <= 1<<17; count <<= 1) {
 				struct timeval start, end;
 
@@ -417,9 +417,9 @@ int main(int argc, char **argv)
 			}
 		}
 
-		if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-correctness"))
+		drmtest_subtest_block("uncached-pwrite-blt-gtt_mmap-correctness")
 			test_as_gtt_mmap(fd, src, dst, object_size);
-		if (drmtest_run_subtest("uncached-pwrite-blt-gtt_mmap-performance")) {
+		drmtest_subtest_block("uncached-pwrite-blt-gtt_mmap-performance") {
 			for (count = 1; count <= 1<<17; count <<= 1) {
 				struct timeval start, end;
 
@@ -437,9 +437,9 @@ int main(int argc, char **argv)
 
 	if (gem_set_caching(fd, src, 1) == 0 &&
 	    gem_set_caching(fd, dst, 1) == 0) {
-		if (drmtest_run_subtest("snooped-copy-correctness"))
+		drmtest_subtest_block("snooped-copy-correctness")
 			test_copy(fd, src, dst, tmp, object_size);
-		if (drmtest_run_subtest("snooped-copy-performance")) {
+		drmtest_subtest_block("snooped-copy-performance") {
 			for (count = 1; count <= 1<<17; count <<= 1) {
 				struct timeval start, end;
 
@@ -454,9 +454,9 @@ int main(int argc, char **argv)
 			}
 		}
 
-		if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-correctness"))
+		drmtest_subtest_block("snooped-pwrite-blt-cpu_mmap-correctness")
 			test_as_cpu_mmap(fd, src, dst, object_size);
-		if (drmtest_run_subtest("snooped-pwrite-blt-cpu_mmap-performance")) {
+		drmtest_subtest_block("snooped-pwrite-blt-cpu_mmap-performance") {
 			for (count = 1; count <= 1<<17; count <<= 1) {
 				struct timeval start, end;
 
@@ -474,9 +474,9 @@ int main(int argc, char **argv)
 
 	if (gem_set_caching(fd, src, 2) == 0 &&
 	    gem_set_caching(fd, dst, 2) == 0) {
-		if (drmtest_run_subtest("display-copy-correctness"))
+		drmtest_subtest_block("display-copy-correctness")
 			test_copy(fd, src, dst, tmp, object_size);
-		if (drmtest_run_subtest("display-copy-performance")) {
+		drmtest_subtest_block("display-copy-performance") {
 			for (count = 1; count <= 1<<17; count <<= 1) {
 				struct timeval start, end;
 
@@ -491,9 +491,9 @@ int main(int argc, char **argv)
 			}
 		}
 
-		if (drmtest_run_subtest("display-pwrite-blt-gtt_mmap-correctness"))
+		drmtest_subtest_block("display-pwrite-blt-gtt_mmap-correctness")
 			test_as_gtt_mmap(fd, src, dst, object_size);
-		if (drmtest_run_subtest("display-pwrite-blt-gtt_mmap-performance")) {
+		drmtest_subtest_block("display-pwrite-blt-gtt_mmap-performance") {
 			for (count = 1; count <= 1<<17; count <<= 1) {
 				struct timeval start, end;
 
diff --git a/tests/gem_ringfill.c b/tests/gem_ringfill.c
index db842fe..1f5faf3 100644
--- a/tests/gem_ringfill.c
+++ b/tests/gem_ringfill.c
@@ -214,7 +214,7 @@ int main(int argc, char **argv)
 	drm_intel_bufmgr_gem_enable_reuse(bufmgr);
 	batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
 
-	if (drmtest_run_subtest("blitter"))
+	drmtest_subtest_block("blitter")
 		fails += check_ring(bufmgr, batch, "blt", blt_copy);
 
 	/* Strictly only required on architectures with a separate BLT ring,
@@ -222,8 +222,10 @@ int main(int argc, char **argv)
 	 */
 	copy = get_render_copyfunc(batch->devid);
 
-	if (drmtest_run_subtest("render") && copy)
-		fails += check_ring(bufmgr, batch, "render", copy);
+	drmtest_subtest_block("render") {
+		if (copy)
+			fails += check_ring(bufmgr, batch, "render", copy);
+	}
 
 	intel_batchbuffer_free(batch);
 	drm_intel_bufmgr_destroy(bufmgr);
diff --git a/tests/gem_set_tiling_vs_blt.c b/tests/gem_set_tiling_vs_blt.c
index 398a227..56a8203 100644
--- a/tests/gem_set_tiling_vs_blt.c
+++ b/tests/gem_set_tiling_vs_blt.c
@@ -246,7 +246,7 @@ int main(int argc, char **argv)
 	devid = intel_get_drm_devid(fd);
 	batch = intel_batchbuffer_alloc(bufmgr, devid);
 
-	if (drmtest_run_subtest("untiled-to-tiled")) {
+	drmtest_subtest_block("untiled-to-tiled") {
 		printf("testing untiled->tiled transisition:\n");
 		tiling = I915_TILING_NONE;
 		tiling_after = I915_TILING_X;
@@ -255,7 +255,7 @@ int main(int argc, char **argv)
 		assert(tiling_after == I915_TILING_X);
 	}
 
-	if (drmtest_run_subtest("tiled-to-untiled")) {
+	drmtest_subtest_block("tiled-to-untiled") {
 		printf("testing tiled->untiled transisition:\n");
 		tiling = I915_TILING_X;
 		tiling_after = I915_TILING_NONE;
@@ -264,7 +264,7 @@ int main(int argc, char **argv)
 		assert(tiling_after == I915_TILING_NONE);
 	}
 
-	if (drmtest_run_subtest("tiled-to-tiled")) {
+	drmtest_subtest_block("tiled-to-tiled") {
 		printf("testing tiled->tiled transisition:\n");
 		tiling = I915_TILING_X;
 		tiling_after = I915_TILING_X;
diff --git a/tests/gem_suspend.c b/tests/gem_suspend.c
index a31161d..e252d14 100644
--- a/tests/gem_suspend.c
+++ b/tests/gem_suspend.c
@@ -105,10 +105,10 @@ int main(int argc, char **argv)
 
 	fd = drm_open_any();
 
-	if (drmtest_run_subtest("fence-restore-tiled2untiled"))
+	drmtest_subtest_block("fence-restore-tiled2untiled")
 		test_fence_restore(fd, true);
 
-	if (drmtest_run_subtest("fence-restore-untiled"))
+	drmtest_subtest_block("fence-restore-untiled")
 		test_fence_restore(fd, false);
 
 	close(fd);
diff --git a/tests/gem_tiled_blits.c b/tests/gem_tiled_blits.c
index b879b1c..ddb5b79 100644
--- a/tests/gem_tiled_blits.c
+++ b/tests/gem_tiled_blits.c
@@ -220,10 +220,10 @@ int main(int argc, char **argv)
 	drm_intel_bufmgr_gem_set_vma_cache_size(bufmgr, 32);
 	batch = intel_batchbuffer_alloc(bufmgr, intel_get_drm_devid(fd));
 
-	if (drmtest_run_subtest("normal"))
+	drmtest_subtest_block("normal")
 		run_test(count);
 
-	if (drmtest_run_subtest("interruptible")) {
+	drmtest_subtest_block("interruptible") {
 		drmtest_fork_signal_helper();
 		run_test(count);
 		drmtest_stop_signal_helper();
diff --git a/tests/gem_tiled_partial_pwrite_pread.c b/tests/gem_tiled_partial_pwrite_pread.c
index 48fd506..8e68406 100644
--- a/tests/gem_tiled_partial_pwrite_pread.c
+++ b/tests/gem_tiled_partial_pwrite_pread.c
@@ -303,13 +303,13 @@ int main(int argc, char **argv)
 	drmtest_init_aperture_trashers(bufmgr);
 	mappable_gtt_limit = gem_mappable_aperture_size();
 
-	if (drmtest_run_subtest("reads"))
+	drmtest_subtest_block("reads")
 		test_partial_reads();
 
-	if (drmtest_run_subtest("writes"))
+	drmtest_subtest_block("writes")
 		test_partial_writes();
 
-	if (drmtest_run_subtest("writes-after-reads"))
+	drmtest_subtest_block("writes-after-reads")
 		test_partial_read_writes();
 
 	drmtest_cleanup_aperture_trashers();
diff --git a/tests/gem_write_read_ring_switch.c b/tests/gem_write_read_ring_switch.c
index 162c059..211b530 100644
--- a/tests/gem_write_read_ring_switch.c
+++ b/tests/gem_write_read_ring_switch.c
@@ -206,16 +206,17 @@ int main(int argc, char **argv)
 	}
 
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
-		if (has_ring(tests[i].ring) &&
-		    drmtest_run_subtest(tests[i].name))
-			run_test(tests[i].ring, tests[i].name);
+		drmtest_subtest_block(tests[i].name) {
+			if (has_ring(tests[i].ring))
+				run_test(tests[i].ring, tests[i].name);
+		}
 	}
 
 	drmtest_fork_signal_helper();
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
 		char name[180];
 		snprintf(name, sizeof(name), "%s-interruptible", tests[i].name);
-		if (has_ring(tests[i].ring) && drmtest_run_subtest(name))
+		drmtest_subtest_block(name)
 			run_test(tests[i].ring, name);
 	}
 	drmtest_stop_signal_helper();
diff --git a/tests/kms_flip.c b/tests/kms_flip.c
index 9e0d235..1998bd9 100644
--- a/tests/kms_flip.c
+++ b/tests/kms_flip.c
@@ -1186,7 +1186,7 @@ int main(int argc, char **argv)
 	batch = intel_batchbuffer_alloc(bufmgr, devid);
 
 	for (i = 0; i < sizeof(tests) / sizeof (tests[0]); i++) {
-		if (drmtest_run_subtest(tests[i].name)) {
+		drmtest_subtest_block(tests[i].name) {
 			printf("running testcase: %s\n", tests[i].name);
 			run_test(tests[i].duration, tests[i].flags, tests[i].name);
 		}
@@ -1203,7 +1203,7 @@ int main(int argc, char **argv)
 		    !(tests[i].flags & TEST_VBLANK_ABSOLUTE))
 			continue;
 
-		if (drmtest_run_subtest(name)) {
+		drmtest_subtest_block(name) {
 			printf("running testcase: %s\n", name);
 			run_test(tests[i].duration, tests[i].flags, name);
 		}
diff --git a/tests/kms_render.c b/tests/kms_render.c
index e6d3e93..5670d1b 100644
--- a/tests/kms_render.c
+++ b/tests/kms_render.c
@@ -247,7 +247,7 @@ int main(int argc, char **argv)
 	}
 
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
-		if (drmtest_run_subtest(tests[i].name))
+		drmtest_subtest_block(tests[i].name)
 			run_test(tests[i].name, tests[i].flags);
 	}
 
diff --git a/tests/prime_nv_api.c b/tests/prime_nv_api.c
index f470fd7..ad030b0 100644
--- a/tests/prime_nv_api.c
+++ b/tests/prime_nv_api.c
@@ -569,7 +569,7 @@ int main(int argc, char **argv)
 	intel_batch = intel_batchbuffer_alloc(bufmgr, devid);
 
 #define xtest(name) \
-	if (drmtest_run_subtest(#name)) \
+	drmtest_subtest_block(#name) \
 		if (test_##name()) \
 			exit(2);
 
diff --git a/tests/prime_nv_pcopy.c b/tests/prime_nv_pcopy.c
index 88b14e5..52f5e7b 100644
--- a/tests/prime_nv_pcopy.c
+++ b/tests/prime_nv_pcopy.c
@@ -1295,14 +1295,15 @@ int main(int argc, char **argv)
 	devid = intel_get_drm_devid(intel_fd);
 	batch = intel_batchbuffer_alloc(bufmgr, devid);
 
-#define xtest(x, args...) do { \
-	if (!drmtest_run_subtest( #x )) break; \
-	ret = ((x)(args)); \
-	++run; \
-	if (ret) { \
-		++failed; \
-		fprintf(stderr, "prime_pcopy: failed " #x "\n"); } \
-	} while (0)
+#define xtest(x, args...) \
+	drmtest_subtest_block( #x ) { \
+		ret = ((x)(args)); \
+		++run; \
+		if (ret) { \
+			++failed; \
+			fprintf(stderr, "prime_pcopy: failed " #x "\n"); \
+		} \
+	}
 
 	xtest(test1_macro);
 	xtest(test1_micro);
diff --git a/tests/prime_nv_test.c b/tests/prime_nv_test.c
index c641095..c850eeb 100644
--- a/tests/prime_nv_test.c
+++ b/tests/prime_nv_test.c
@@ -504,7 +504,7 @@ int main(int argc, char **argv)
 	intel_batch = intel_batchbuffer_alloc(bufmgr, devid);
 
 #define xtest(name) \
-	if (drmtest_run_subtest(#name)) \
+	drmtest_subtest_block(#name) \
 		if (test_##name()) \
 			exit(2);
 
diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c
index ed3ff95..1bd0bb5 100644
--- a/tests/prime_self_import.c
+++ b/tests/prime_self_import.c
@@ -386,7 +386,7 @@ int main(int argc, char **argv)
 	drmtest_subtest_init(argc, argv);
 
 	for (i = 0; i < ARRAY_SIZE(tests); i++) {
-		if (drmtest_run_subtest(tests[i].name))
+		drmtest_subtest_block(tests[i].name)
 			tests[i].fn();
 	}
 
-- 
1.8.3.2




More information about the Intel-gfx mailing list