diff mbox

[v2,8/13] tests/sw_sync: Add subtest test_sync_merge_same

Message ID 16f89ef817d3990034a571eeb9db3e20ad1e823b.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 merging a fence with itself does not fail.

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

Patch

diff --git a/tests/sw_sync.c b/tests/sw_sync.c
index 00ac44b..db03f48 100644
--- a/tests/sw_sync.c
+++ b/tests/sw_sync.c
@@ -179,6 +179,30 @@  static void test_sync_merge(void)
 	sw_sync_timeline_destroy(timeline);
 }
 
+static void test_sync_merge_same(void)
+{
+	int in_fence[2];
+	int timeline;
+	int signaled;
+
+	timeline = sw_sync_timeline_create();
+	in_fence[0] = sw_sync_fence_create(timeline, 1);
+	in_fence[1] = sw_sync_merge(in_fence[0], in_fence[0]);
+
+	signaled = sw_sync_fence_count_status(in_fence[0],
+					      SW_SYNC_FENCE_STATUS_SIGNALED);
+	igt_assert_f(signaled == 0, "fence signaled too early\n");
+
+	sw_sync_timeline_inc(timeline, 1);
+	signaled = sw_sync_fence_count_status(in_fence[0],
+					      SW_SYNC_FENCE_STATUS_SIGNALED);
+	igt_assert_f(signaled == 1, "fence did not signal\n");
+
+	sw_sync_fence_destroy(in_fence[0]);
+	sw_sync_fence_destroy(in_fence[1]);
+	sw_sync_timeline_destroy(timeline);
+}
+
 igt_main
 {
 	igt_subtest("alloc_timeline")
@@ -198,5 +222,8 @@  igt_main
 
 	igt_subtest("sync_merge")
 		test_sync_merge();
+
+	igt_subtest("sync_merge_same")
+		test_sync_merge_same();
 }