summaryrefslogtreecommitdiff
path: root/tests/vc4_wait_bo.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2016-01-25 10:36:12 -0800
committerEric Anholt <eric@anholt.net>2016-02-08 16:34:13 -0800
commit467a9fac9bbb6385c0372a6c6a0f1d2f891984e9 (patch)
tree30199d8ea7d13b2deffb0792cd896e758887e1d5 /tests/vc4_wait_bo.c
parente7e094f444ac59ee93b96d9021d8c11d51fecd59 (diff)
igt/vc4_wait_bo: Add tests with rendering performed.
These caught an unexpected bug with clear colors (we'd get the last executed clear's color in our new BO), while failing to catch the bug I'd been hoping to find all along. Signed-off-by: Eric Anholt <eric@anholt.net> Reviewed-by: Daniel Stone <daniels@collabora.com>
Diffstat (limited to 'tests/vc4_wait_bo.c')
-rw-r--r--tests/vc4_wait_bo.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/vc4_wait_bo.c b/tests/vc4_wait_bo.c
index 1b924642..65a085a3 100644
--- a/tests/vc4_wait_bo.c
+++ b/tests/vc4_wait_bo.c
@@ -34,6 +34,38 @@
#include <sys/ioctl.h>
#include "vc4_drm.h"
+static void
+test_used_bo(int fd, uint64_t timeout)
+{
+ size_t size = 4096;
+ uint32_t clearval = 0xaabbccdd + timeout;
+ int handle = igt_vc4_get_cleared_bo(fd, size, clearval);
+ struct drm_vc4_wait_bo wait = {
+ .timeout_ns = timeout,
+ .handle = handle,
+ };
+ int ret, i;
+
+ ret = ioctl(fd, DRM_IOCTL_VC4_WAIT_BO, &wait);
+ if (timeout == ~0ull) {
+ igt_assert_eq_u32(ret, 0);
+ } else {
+ if (ret == -1 && errno == ETIME)
+ igt_debug("Timeout triggered\n");
+ igt_assert(ret == 0 || (ret == -1 && errno == ETIME));
+ }
+
+ if (ret == 0) {
+ uint32_t *map = igt_vc4_mmap_bo(fd, handle, size, PROT_READ);
+ for (i = 0; i < size / 4; i++) {
+ igt_assert_eq_u32(map[i], clearval);
+ }
+ munmap((void *)map, size);
+ }
+
+ gem_close(fd, handle);
+}
+
igt_main
{
int fd;
@@ -77,6 +109,15 @@ igt_main
do_ioctl(fd, DRM_IOCTL_VC4_WAIT_BO, &arg);
}
+ igt_subtest("used-bo-0ns")
+ test_used_bo(fd, 0);
+
+ igt_subtest("used-bo-1ns")
+ test_used_bo(fd, 1);
+
+ igt_subtest("used-bo")
+ test_used_bo(fd, ~0ull);
+
igt_fixture
close(fd);
}