summaryrefslogtreecommitdiff
path: root/tests/gem_pread.c
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/gem_pread.c
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/gem_pread.c')
-rw-r--r--tests/gem_pread.c50
1 files changed, 27 insertions, 23 deletions
diff --git a/tests/gem_pread.c b/tests/gem_pread.c
index 7c2f18f3..b5c0e95d 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();
}