[Intel-gfx] [PATCH igt 9/9] igt/vc4_wait_bo: Add tests with rendering performed.

Eric Anholt eric at anholt.net
Wed Feb 3 21:41:43 UTC 2016


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 at anholt.net>
---
 tests/vc4_wait_bo.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/tests/vc4_wait_bo.c b/tests/vc4_wait_bo.c
index 642b941..511c03a 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(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 ret;
@@ -82,6 +114,15 @@ igt_main
 		igt_assert(ret == 0);
 	}
 
+	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);
 }
-- 
2.7.0



More information about the Intel-gfx mailing list