Add timeout to eglClientWaitSync() tests.

Require that eglClientWaitSync() with timeout 0 and without rendering
anything finishes in 100us.

Bug: 18183346
Change-Id: Id1c8e9793cb96a95022f2d051a7b27ac03e92f53
diff --git a/modules/egl/teglSyncTests.cpp b/modules/egl/teglSyncTests.cpp
index 97bc654..25a3016 100644
--- a/modules/egl/teglSyncTests.cpp
+++ b/modules/egl/teglSyncTests.cpp
@@ -38,6 +38,8 @@
 #include "glwFunctions.hpp"
 #include "glwEnums.hpp"
 
+#include "deClock.h"
+
 #include <vector>
 #include <string>
 #include <sstream>
@@ -461,14 +463,20 @@
 
 	IterateResult	iterate					(void)
 	{
-		const Library&	egl		= m_eglTestCtx.getLibrary();
-		TestLog&		log		= m_testCtx.getLog();
+		const deUint64	timeoutUs	= 100;
+		const Library&	egl			= m_eglTestCtx.getLibrary();
+		TestLog&		log			= m_testCtx.getLog();
+		deUint64		beginTimeUs;
+		deUint64		endTimeUs;
 
 		m_sync = egl.createSyncKHR(m_eglDisplay, m_syncType, NULL);
 		log << TestLog::Message << m_sync << " = eglCreateSyncKHR(" << m_eglDisplay << ", " << getSyncTypeName(m_syncType) << ", NULL)" << TestLog::EndMessage;
 		EGLU_CHECK_MSG(egl, "eglCreateSyncKHR()");
 
+		beginTimeUs = deGetMicroseconds();
 		EGLint status = egl.clientWaitSyncKHR(m_eglDisplay, m_sync, 0, 0);
+		endTimeUs = deGetMicroseconds();
+
 		log << TestLog::Message << status << " = eglClientWaitSyncKHR(" << m_eglDisplay << ", " << m_sync << ", 0, 0)" << TestLog::EndMessage;
 
 		if (m_syncType == EGL_SYNC_FENCE_KHR)
@@ -478,6 +486,15 @@
 		else
 			DE_ASSERT(DE_FALSE);
 
+		log << TestLog::Message << "eglClientWaitSyncKHR() took " << (endTimeUs - beginTimeUs) << "us to finish." << TestLog::EndMessage;
+
+		if (endTimeUs - beginTimeUs > timeoutUs)
+		{
+			log << TestLog::Message << "Call without timeout should finish in less than: " << timeoutUs << "us." << TestLog::EndMessage;
+			m_testCtx.setTestResult(QP_TEST_RESULT_FAIL, "eglClientWaitSyncKHR(timeout=0) didn't finish fast enough");
+			return STOP;
+		}
+
 		m_testCtx.setTestResult(QP_TEST_RESULT_PASS, "Pass");
 		return STOP;
 	}