diff mbox

[igt,9/9] igt/vc4_wait_bo: Add tests with rendering performed.

Message ID 1454535703-660-9-git-send-email-eric@anholt.net (mailing list archive)
State New, archived
Headers show

Commit Message

Eric Anholt Feb. 3, 2016, 9:41 p.m. UTC
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>
---
 tests/vc4_wait_bo.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)
diff mbox

Patch

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);
 }