Commit 907377da authored by Daniel Vetter's avatar Daniel Vetter

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's avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent ef9e6457
......@@ -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 \
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment