diff mbox

[v2,6/13] tests/sw_sync: Add subtest test_sync_wait

Message ID f6abe8a547dbe1c8616ee7be03f44f68d1ae49e8.1472071238.git-series.robert.foss@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Robert Foss Aug. 24, 2016, 8:41 p.m. UTC
From: Robert Foss <robert.foss@collabora.com>

This subtest verifies that waiting on fences works properly.

Signed-off-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
---
 tests/sw_sync.c | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+), 0 deletions(-)
diff mbox

Patch

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 851430e..07e9638 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -80,6 +80,41 @@  static void test_alloc_merge_fence(void)
 	sw_sync_timeline_destroy(timeline[1]);
 }
 
+static void test_sync_wait(void)
+{
+	int fence, ret;
+	int timeline;
+
+	timeline = sw_sync_timeline_create();
+	fence = sw_sync_fence_create(timeline, 5);
+
+	/* Wait on fence until timeout */
+	ret = sw_sync_wait(fence, 0);
+	igt_assert_f(ret == 0, "Failure waiting on fence until timeout\n");
+
+	/* Advance timeline from 0 -> 1 */
+	sw_sync_timeline_inc(timeline, 1);
+
+	/* Wait on fence until timeout */
+	ret = sw_sync_wait(fence, 0);
+	igt_assert_f(ret == 0, "Failure waiting on fence until timeout\n");
+
+	/* Signal the fence */
+	sw_sync_timeline_inc(timeline, 4);
+
+	/* Wait successfully */
+	ret = sw_sync_wait(fence, 0);
+	igt_assert_f(ret > 0, "Failure waiting on fence\n");
+
+	/* Go even further, and confirm wait still succeeds */
+	sw_sync_timeline_inc(timeline, 10);
+	ret = sw_sync_wait(fence, 0);
+	igt_assert_f(ret > 0, "Failure waiting ahead\n");
+
+	sw_sync_fence_destroy(fence);
+	sw_sync_timeline_destroy(timeline);
+}
+
 igt_main
 {
 	igt_subtest("alloc_timeline")
@@ -93,5 +128,8 @@  igt_main
 
 	igt_subtest("alloc_merge_fence")
 		test_alloc_merge_fence();
+
+	igt_subtest("sync_wait")
+		test_sync_wait();
 }