[Piglit] [PATCH 09/11] egl_android_native_fence_sync: Test for wait with zero timeout.

Rafael Antognolli rafael.antognolli at intel.com
Thu Oct 27 23:19:08 UTC 2016


Verify that eglClientWaitSyncKHR() correctly handles zero timeout before
and after the sw sync fence is signaled.

Signed-off-by: Rafael Antognolli <rafael.antognolli at intel.com>
---
 .../egl_android_native_fence_sync.c                | 97 ++++++++++++++++++++++
 1 file changed, 97 insertions(+)

diff --git a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
index 9f3ad51..1047f41 100644
--- a/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
+++ b/tests/egl/spec/egl_android_native_fence_sync/egl_android_native_fence_sync.c
@@ -788,6 +788,98 @@ cleanup:
 	return result;
 }
 
+/**
+ * Verify that eglClientWaitSyncKHR() correctly handles zero timeout before and
+ * after glFinish().
+ *
+ * From the EGL_KHR_fence_sync:
+ *
+ *     If the value of <timeout> is zero, then eglClientWaitSyncKHR simply
+ *     tests the current status of <sync>.
+ *
+ *     [...]
+ *
+ *     eglClientWaitSyncKHR returns one of three status values describing
+ *     the reason for returning. A return value of EGL_TIMEOUT_EXPIRED_KHR
+ *     indicates that the specified timeout period expired before <sync>
+ *     was signaled. A return value of EGL_CONDITION_SATISFIED_KHR
+ *     indicates that <sync> was signaled before the timeout expired, which
+ *     includes the case when <sync> was already signaled when
+ *     eglClientWaitSyncKHR was called. If an error occurs then an error is
+ *     generated and EGL_FALSE is returned.
+ */
+static enum piglit_result
+test_eglClientWaitSyncKHR_native_zero_timeout(void *test_data)
+{
+	enum piglit_result result = PIGLIT_PASS;
+	EGLSyncKHR sync = 0;
+	int wait_status1 = 0, wait_status2 = 0;
+	int sync_fd = canary;
+	int timeline = canary;
+
+	result = test_setup();
+	if (result != PIGLIT_PASS) {
+		return result;
+	}
+
+	if (!sw_sync_is_supported()) {
+		result = PIGLIT_SKIP;
+		goto cleanup;
+	}
+
+	/* Create timeline and sw_sync */
+	timeline = sw_sync_timeline_create();
+	if (timeline < 0) {
+		piglit_loge("sw_sync_timeline_create() failed");
+		result = PIGLIT_FAIL;
+		goto cleanup;
+	}
+
+	sync_fd = sw_sync_fence_create(timeline, 1);
+	if (sync_fd < 0) {
+		piglit_loge("sw_sync_fence_create() failed");
+		result = PIGLIT_FAIL;
+		goto cleanup_timeline;
+	}
+
+	sync = test_create_fence_from_fd(sync_fd);
+	if (sync == EGL_NO_SYNC_KHR) {
+		piglit_loge("eglCreateSyncKHR(EGL_SYNC_NATIVE_FENCE_ANDROID) failed");
+		result = PIGLIT_FAIL;
+		goto cleanup_sw_fence;
+	}
+
+	glFlush();
+
+	wait_status1 = peglClientWaitSyncKHR(g_dpy, sync, 0, 0);
+	sw_sync_timeline_inc(timeline, 1);
+	wait_status2 = peglClientWaitSyncKHR(g_dpy, sync, 0, 0);
+
+	if (wait_status1 != EGL_TIMEOUT_EXPIRED_KHR) {
+		piglit_loge("eglClientWaitSyncKHR() before glFinish:\n"
+			    "  Expected status: EGL_TIMEOUT_EXPIRED_KHR (0x%x)\n"
+			    "  Actual status:  0x%x\n",
+			    EGL_TIMEOUT_EXPIRED_KHR, wait_status1);
+		result = PIGLIT_FAIL;
+	}
+	if (wait_status2 != EGL_CONDITION_SATISFIED_KHR) {
+		piglit_loge("eglClientWaitSyncKHR() after glFinish:\n"
+			    "  Expected status: EGL_CONDITION_SATISFIED_KHR\n"
+			    "  Actual status:  0x%x\n", wait_status2);
+		result = PIGLIT_FAIL;
+	}
+
+cleanup_sw_fence:
+	sw_sync_fence_destroy(sync_fd);
+
+cleanup_timeline:
+	sw_sync_timeline_destroy(timeline);
+
+cleanup:
+	test_cleanup(sync, &result);
+	return result;
+}
+
 static const struct piglit_subtest fence_sync_subtests[] = {
 	{
 		"eglCreateSyncKHR_native_no_fence",
@@ -829,6 +921,11 @@ static const struct piglit_subtest fence_sync_subtests[] = {
 		"eglGetSyncAttribKHR_native_invalid_attrib",
 		test_eglGetSyncAttribKHR_native_invalid_attrib,
 	},
+	{
+		"eglClientWaitSyncKHR_native_zero_timeout",
+		"eglClientWaitSyncKHR_native_zero_timeout",
+		test_eglClientWaitSyncKHR_native_zero_timeout,
+	},
 	{0},
 };
 
-- 
2.7.4



More information about the Piglit mailing list