From 907377da0e9c2d878f45201230b8d3900310cb0b Mon Sep 17 00:00:00 2001 From: Daniel Vetter Date: Tue, 13 Aug 2013 12:45:14 +0200 Subject: [PATCH] tests/gem_readwrite: convert to subtests A bit lazy since the read/write tests are all smashed together. But since we have really evil partial write/read tests for coherency checking that doesn't matter that much really. Signed-off-by: Daniel Vetter --- tests/Makefile.am | 2 +- tests/gem_readwrite.c | 93 ++++++++++++++++++++++++++++----------------------- 2 files changed, 53 insertions(+), 42 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index f07b547..43369c5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,6 +36,7 @@ TESTS_progs_M = \ gem_prw_concurrent_blit \ gem_pwrite \ gem_pwrite_pread \ + gem_readwrite \ gem_ringfill \ gem_set_tiling_vs_blt \ gem_suspend \ @@ -76,7 +77,6 @@ TESTS_progs = \ gem_mmap_offset_exhaustion \ gem_pin \ gem_pipe_control_store_loop \ - gem_readwrite \ gem_reg_read \ gem_reloc_overflow \ gem_reloc_vs_gpu \ diff --git a/tests/gem_readwrite.c b/tests/gem_readwrite.c index bc7a47e..df3ecee 100644 --- a/tests/gem_readwrite.c +++ b/tests/gem_readwrite.c @@ -82,52 +82,63 @@ int main(int argc, char **argv) int handle; igt_skip_on_simulation(); + igt_subtest_init(argc, argv); fd = drm_open_any(); handle = gem_create(fd, OBJECT_SIZE); - printf("Testing contents of newly created object.\n"); - ret = do_read(fd, handle, buf, 0, OBJECT_SIZE); - igt_assert(ret == 0); - memset(&expected, 0, sizeof(expected)); - igt_assert(memcmp(expected, buf, sizeof(expected)) == 0); - - printf("Testing read beyond end of buffer.\n"); - ret = do_read(fd, handle, buf, OBJECT_SIZE / 2, OBJECT_SIZE); - igt_assert(ret == -1 && errno == EINVAL); - - printf("Testing full write of buffer\n"); - memset(buf, 0, sizeof(buf)); - memset(buf + 1024, 0x01, 1024); - memset(expected + 1024, 0x01, 1024); - ret = do_write(fd, handle, buf, 0, OBJECT_SIZE); - igt_assert(ret == 0); - ret = do_read(fd, handle, buf, 0, OBJECT_SIZE); - igt_assert(ret == 0); - igt_assert(memcmp(buf, expected, sizeof(buf)) == 0); - - printf("Testing partial write of buffer\n"); - memset(buf + 4096, 0x02, 1024); - memset(expected + 4096, 0x02, 1024); - ret = do_write(fd, handle, buf + 4096, 4096, 1024); - igt_assert(ret == 0); - ret = do_read(fd, handle, buf, 0, OBJECT_SIZE); - igt_assert(ret == 0); - igt_assert(memcmp(buf, expected, sizeof(buf)) == 0); - - printf("Testing partial read of buffer\n"); - ret = do_read(fd, handle, buf, 512, 1024); - igt_assert(ret == 0); - igt_assert(memcmp(buf, expected + 512, 1024) == 0); - - printf("Testing read of bad buffer handle\n"); - ret = do_read(fd, 1234, buf, 0, 1024); - igt_assert(ret == -1 && errno == ENOENT); - - printf("Testing write of bad buffer handle\n"); - ret = do_write(fd, 1234, buf, 0, 1024); - igt_assert(ret == -1 && errno == ENOENT); + igt_subtest("new-obj") { + printf("Testing contents of newly created object.\n"); + ret = do_read(fd, handle, buf, 0, OBJECT_SIZE); + igt_assert(ret == 0); + memset(&expected, 0, sizeof(expected)); + igt_assert(memcmp(expected, buf, sizeof(expected)) == 0); + } + + igt_subtest("beyond-EOB") { + printf("Testing read beyond end of buffer.\n"); + ret = do_read(fd, handle, buf, OBJECT_SIZE / 2, OBJECT_SIZE); + igt_assert(ret == -1 && errno == EINVAL); + } + + igt_subtest("read-write") { + printf("Testing full write of buffer\n"); + memset(buf, 0, sizeof(buf)); + memset(buf + 1024, 0x01, 1024); + memset(expected + 1024, 0x01, 1024); + ret = do_write(fd, handle, buf, 0, OBJECT_SIZE); + igt_assert(ret == 0); + ret = do_read(fd, handle, buf, 0, OBJECT_SIZE); + igt_assert(ret == 0); + igt_assert(memcmp(buf, expected, sizeof(buf)) == 0); + + printf("Testing partial write of buffer\n"); + memset(buf + 4096, 0x02, 1024); + memset(expected + 4096, 0x02, 1024); + ret = do_write(fd, handle, buf + 4096, 4096, 1024); + igt_assert(ret == 0); + ret = do_read(fd, handle, buf, 0, OBJECT_SIZE); + igt_assert(ret == 0); + igt_assert(memcmp(buf, expected, sizeof(buf)) == 0); + + printf("Testing partial read of buffer\n"); + ret = do_read(fd, handle, buf, 512, 1024); + igt_assert(ret == 0); + igt_assert(memcmp(buf, expected + 512, 1024) == 0); + } + + igt_subtest("read-bad-handle") { + printf("Testing read of bad buffer handle\n"); + ret = do_read(fd, 1234, buf, 0, 1024); + igt_assert(ret == -1 && errno == ENOENT); + } + + igt_subtest("write-bad-handle") { + printf("Testing write of bad buffer handle\n"); + ret = do_write(fd, 1234, buf, 0, 1024); + igt_assert(ret == -1 && errno == ENOENT); + } close(fd); -- 2.7.4