summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-12 10:43:59 +0200
committerDaniel Vetter <daniel.vetter@ffwll.ch>2013-08-12 11:17:58 +0200
commit7553ad6e10f76aa703359a10e08138e14501d54d (patch)
tree1e778fa0a06bf91bdc43aa2574be555396e42d5c /tests
parenta4038d3853b98707a803f5d1fb5c9ebe32f0b84b (diff)
tests: use drmtest_skip() in caching ioctl helpers
This way we can rip out all the skip handling from the test control flow, and additionally (by using drmtest_retval()) even get correct exit codes. The only tricky part is that when we only want ot skip parts of a test (like for gem_pread and gem_pwrite) we need to split out those parts as subtests. But no addition of control-flow is required, the set/longjmp magic in the helpers all makes it happen. Also we make extensive use of the behaviour of drmtest_skip to skip all subsequent subtests if it is called outside of a subtest. This allows us to re-flatten the control flow a lot. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am4
-rw-r--r--tests/gem_caching.c5
-rw-r--r--tests/gem_partial_pwrite_pread.c15
-rw-r--r--tests/gem_pread.c50
-rw-r--r--tests/gem_pread_after_blit.c9
-rw-r--r--tests/gem_pwrite.c48
-rw-r--r--tests/gem_pwrite_pread.c194
7 files changed, 162 insertions, 163 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 8fff22c3d..f3475adaa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -30,8 +30,10 @@ TESTS_progs_M = \
gem_linear_blits \
gem_mmap_gtt \
gem_partial_pwrite_pread \
+ gem_pread \
gem_pread_after_blit \
gem_prw_concurrent_blit \
+ gem_pwrite \
gem_pwrite_pread \
gem_ringfill \
gem_set_tiling_vs_blt \
@@ -73,8 +75,6 @@ TESTS_progs = \
gem_mmap_offset_exhaustion \
gem_pin \
gem_pipe_control_store_loop \
- gem_pread \
- gem_pwrite \
gem_readwrite \
gem_reg_read \
gem_reloc_overflow \
diff --git a/tests/gem_caching.c b/tests/gem_caching.c
index 259662f5b..ed58c28f9 100644
--- a/tests/gem_caching.c
+++ b/tests/gem_caching.c
@@ -118,10 +118,7 @@ int main(int argc, char **argv)
fd = drm_open_any();
- if (!gem_has_caching(fd)) {
- printf("no set_caching support detected\n");
- return 77;
- }
+ gem_check_caching(fd);
devid = intel_get_drm_devid(fd);
if (IS_GEN2(devid)) /* chipset only handles cached -> uncached */
diff --git a/tests/gem_partial_pwrite_pread.c b/tests/gem_partial_pwrite_pread.c
index a27e584bf..f6e6e32df 100644
--- a/tests/gem_partial_pwrite_pread.c
+++ b/tests/gem_partial_pwrite_pread.c
@@ -257,17 +257,8 @@ static void do_tests(int cache_level, const char *suffix)
{
char name[80];
- if (cache_level != -1) {
- switch (gem_set_caching(fd, scratch_bo->handle, cache_level)) {
- case 0: break;
- case -EINVAL:
- case -ENOTTY:
- return;
- default:
- assert(0);
- return;
- }
- }
+ if (cache_level != -1)
+ gem_set_caching(fd, scratch_bo->handle, cache_level);
snprintf(name, sizeof(name), "reads%s", suffix);
drmtest_subtest_block(name)
@@ -315,5 +306,5 @@ int main(int argc, char **argv)
close(fd);
- return 0;
+ return drmtest_retval();
}
diff --git a/tests/gem_pread.c b/tests/gem_pread.c
index 7c2f18f3a..b5c0e95dc 100644
--- a/tests/gem_pread.c
+++ b/tests/gem_pread.c
@@ -93,9 +93,10 @@ int main(int argc, char **argv)
{ -1 },
}, *c;
+ drmtest_subtest_init(argc, argv);
drmtest_skip_on_simulation();
- if (argc > 1)
+ if (argc > 1 && atoi(argv[1]))
object_size = atoi(argv[1]);
if (object_size == 0)
object_size = OBJECT_SIZE;
@@ -106,41 +107,44 @@ int main(int argc, char **argv)
dst = gem_create(fd, object_size);
src = malloc(object_size);
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- do_gem_read(fd, dst, src, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to pread %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
- }
-
- for (c = cache; c->level != -1; c++) {
- if (gem_set_caching(fd, dst, c->level))
- continue;
-
+ drmtest_subtest_block("normal") {
for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end;
gettimeofday(&start, NULL);
do_gem_read(fd, dst, src, object_size, count);
gettimeofday(&end, NULL);
- printf("Time to %s pread %d bytes x %6d: %7.3fµs, %s\n",
- c->name, object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ printf("Time to pread %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout);
}
}
+ for (c = cache; c->level != -1; c++) {
+ drmtest_subtest_block(c->name) {
+ gem_set_caching(fd, dst, c->level);
+
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ do_gem_read(fd, dst, src, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to %s pread %d bytes x %6d: %7.3fµs, %s\n",
+ c->name, object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
+ }
+ }
+
free(src);
gem_close(fd, dst);
close(fd);
- return 0;
+ return drmtest_retval();
}
diff --git a/tests/gem_pread_after_blit.c b/tests/gem_pread_after_blit.c
index 7375000ad..71dab3451 100644
--- a/tests/gem_pread_after_blit.c
+++ b/tests/gem_pread_after_blit.c
@@ -131,11 +131,12 @@ static void do_test(int fd, int cache_level,
int loop)
{
if (cache_level != -1) {
- if (gem_set_caching(fd, tmp[0]->handle, cache_level) ||
- gem_set_caching(fd, tmp[1]->handle, cache_level))
- return;
+ gem_set_caching(fd, tmp[0]->handle, cache_level);
+ gem_set_caching(fd, tmp[1]->handle, cache_level);
}
+ printf("meh");
+
do {
/* First, do a full-buffer read after blitting */
intel_copy_bo(batch, tmp[0], src[0], width, height);
@@ -235,5 +236,5 @@ main(int argc, char **argv)
close(fd);
- return 0;
+ return drmtest_retval();
}
diff --git a/tests/gem_pwrite.c b/tests/gem_pwrite.c
index 87acbf553..bceba28ee 100644
--- a/tests/gem_pwrite.c
+++ b/tests/gem_pwrite.c
@@ -102,7 +102,10 @@ int main(int argc, char **argv)
drmtest_skip_on_simulation();
- if (argc > 1)
+ drmtest_subtest_init(argc, argv);
+ drmtest_skip_on_simulation();
+
+ if (argc > 1 && atoi(argv[1]))
object_size = atoi(argv[1]);
if (object_size == 0)
object_size = OBJECT_SIZE;
@@ -113,41 +116,44 @@ int main(int argc, char **argv)
dst = gem_create(fd, object_size);
src = malloc(object_size);
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- do_gem_write(fd, dst, src, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to pwrite %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
- }
-
- for (c = cache; c->level != -1; c++) {
- if (gem_set_caching(fd, dst, c->level))
- continue;
-
+ drmtest_subtest_block("normal") {
for (count = 1; count <= 1<<17; count <<= 1) {
struct timeval start, end;
gettimeofday(&start, NULL);
do_gem_write(fd, dst, src, object_size, count);
gettimeofday(&end, NULL);
- printf("Time to %s pwrite %d bytes x %6d: %7.3fµs, %s\n",
- c->name, object_size, count,
+ printf("Time to pwrite %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
elapsed(&start, &end, count),
bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
fflush(stdout);
}
}
+ for (c = cache; c->level != -1; c++) {
+ drmtest_subtest_block(c->name) {
+ gem_set_caching(fd, dst, c->level);
+
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ do_gem_write(fd, dst, src, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to %s pwrite %d bytes x %6d: %7.3fµs, %s\n",
+ c->name, object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
+ }
+ }
+ }
+
free(src);
gem_close(fd, dst);
close(fd);
- return 0;
+ return drmtest_retval();
}
diff --git a/tests/gem_pwrite_pread.c b/tests/gem_pwrite_pread.c
index d29c53128..c86760936 100644
--- a/tests/gem_pwrite_pread.c
+++ b/tests/gem_pwrite_pread.c
@@ -398,114 +398,114 @@ int main(int argc, char **argv)
src = gem_create(fd, object_size);
tmp = malloc(object_size);
- if (gem_set_caching(fd, src, 0) == 0 &&
- gem_set_caching(fd, dst, 0) == 0) {
- drmtest_subtest_block("uncached-copy-correctness")
- test_copy(fd, src, dst, tmp, object_size);
- drmtest_subtest_block("uncached-copy-performance") {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- copy(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to uncached copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
- }
+ gem_set_caching(fd, src, 0);
+ gem_set_caching(fd, dst, 0);
+
+ drmtest_subtest_block("uncached-copy-correctness")
+ test_copy(fd, src, dst, tmp, object_size);
+ drmtest_subtest_block("uncached-copy-performance") {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ copy(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to uncached copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
}
+ }
- drmtest_subtest_block("uncached-pwrite-blt-gtt_mmap-correctness")
- test_as_gtt_mmap(fd, src, dst, object_size);
- drmtest_subtest_block("uncached-pwrite-blt-gtt_mmap-performance") {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- as_gtt_mmap(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("** mmap uncached copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
- }
+ drmtest_subtest_block("uncached-pwrite-blt-gtt_mmap-correctness")
+ test_as_gtt_mmap(fd, src, dst, object_size);
+ drmtest_subtest_block("uncached-pwrite-blt-gtt_mmap-performance") {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ as_gtt_mmap(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("** mmap uncached copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
}
}
- if (gem_set_caching(fd, src, 1) == 0 &&
- gem_set_caching(fd, dst, 1) == 0) {
- drmtest_subtest_block("snooped-copy-correctness")
- test_copy(fd, src, dst, tmp, object_size);
- drmtest_subtest_block("snooped-copy-performance") {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- copy(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to snooped copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
- }
+ gem_set_caching(fd, src, 1);
+ gem_set_caching(fd, dst, 1);
+
+ drmtest_subtest_block("snooped-copy-correctness")
+ test_copy(fd, src, dst, tmp, object_size);
+ drmtest_subtest_block("snooped-copy-performance") {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ copy(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to snooped copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
}
+ }
- drmtest_subtest_block("snooped-pwrite-blt-cpu_mmap-correctness")
- test_as_cpu_mmap(fd, src, dst, object_size);
- drmtest_subtest_block("snooped-pwrite-blt-cpu_mmap-performance") {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- as_cpu_mmap(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("** mmap snooped copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
- }
+ drmtest_subtest_block("snooped-pwrite-blt-cpu_mmap-correctness")
+ test_as_cpu_mmap(fd, src, dst, object_size);
+ drmtest_subtest_block("snooped-pwrite-blt-cpu_mmap-performance") {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ as_cpu_mmap(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("** mmap snooped copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
}
}
- if (gem_set_caching(fd, src, 2) == 0 &&
- gem_set_caching(fd, dst, 2) == 0) {
- drmtest_subtest_block("display-copy-correctness")
- test_copy(fd, src, dst, tmp, object_size);
- drmtest_subtest_block("display-copy-performance") {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- copy(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("Time to display copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
- }
+ gem_set_caching(fd, src, 2);
+ gem_set_caching(fd, dst, 2);
+
+ drmtest_subtest_block("display-copy-correctness")
+ test_copy(fd, src, dst, tmp, object_size);
+ drmtest_subtest_block("display-copy-performance") {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ copy(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("Time to display copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
}
+ }
- drmtest_subtest_block("display-pwrite-blt-gtt_mmap-correctness")
- test_as_gtt_mmap(fd, src, dst, object_size);
- drmtest_subtest_block("display-pwrite-blt-gtt_mmap-performance") {
- for (count = 1; count <= 1<<17; count <<= 1) {
- struct timeval start, end;
-
- gettimeofday(&start, NULL);
- as_gtt_mmap(fd, src, dst, tmp, object_size, count);
- gettimeofday(&end, NULL);
- printf("** mmap display copy %d bytes x %6d: %7.3fµs, %s\n",
- object_size, count,
- elapsed(&start, &end, count),
- bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
- fflush(stdout);
- }
+ drmtest_subtest_block("display-pwrite-blt-gtt_mmap-correctness")
+ test_as_gtt_mmap(fd, src, dst, object_size);
+ drmtest_subtest_block("display-pwrite-blt-gtt_mmap-performance") {
+ for (count = 1; count <= 1<<17; count <<= 1) {
+ struct timeval start, end;
+
+ gettimeofday(&start, NULL);
+ as_gtt_mmap(fd, src, dst, tmp, object_size, count);
+ gettimeofday(&end, NULL);
+ printf("** mmap display copy %d bytes x %6d: %7.3fµs, %s\n",
+ object_size, count,
+ elapsed(&start, &end, count),
+ bytes_per_sec((char *)buf, object_size/elapsed(&start, &end, count)*1e6));
+ fflush(stdout);
}
}
@@ -515,5 +515,5 @@ int main(int argc, char **argv)
close(fd);
- return 0;
+ return drmtest_retval();
}