os/graphics/egl/egltest/src/egltest_syncobject.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/egl/egltest/src/egltest_syncobject.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,2320 @@
     1.4 +// Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +/**
    1.20 + @file
    1.21 + @test 
    1.22 +*/
    1.23 +#include "egltest_syncobject.h"
    1.24 +#include <test/tefunit.h>
    1.25 +#include <hal.h>
    1.26 +#include <test/egltestcommonsgimageinfo.h>
    1.27 +
    1.28 +const TUint32  KThreshold = 0.5*1000*1000; // 0.5 sec
    1.29 +const TUint32  KDelaySignalling = 2.5*1000*1000; // 2.5 sec
    1.30 +const TUint32  KWaitSyncTimeout = 5*1000*1000; // 5 sec
    1.31 +const TUint32  KLongDelaySignalling = 7.5*1000*1000; // 7.5 sec
    1.32 +const TInt 	   KNumStressIterations = 1000;
    1.33 +
    1.34 +typedef void 	(*TEglDebugHeapMarkStartPtr)		(void);
    1.35 +typedef EGLint	(*TEglDebugHeapMarkEndPtr)			(EGLint count);
    1.36 +typedef void	(*TEglDebugSetBurstAllocFailPtr)	(EGLenum type, EGLint rate, EGLint burst);
    1.37 +
    1.38 +struct TSurfaceToDestroy
    1.39 +	{
    1.40 +	EGLSurface iSurface;
    1.41 +	EGLDisplay	iDisplay;
    1.42 +	};
    1.43 +
    1.44 +//the function clean up surface resource. Needs to be push into cleanup stack beforehand
    1.45 +void DestroySurface(TAny* aAny)
    1.46 +	{
    1.47 +	TSurfaceToDestroy* surfaceToDestroy = (TSurfaceToDestroy*)aAny;
    1.48 +	eglDestroySurface(surfaceToDestroy->iDisplay, surfaceToDestroy->iSurface);
    1.49 +	}
    1.50 +
    1.51 +CEglTest_SyncObject_Base::CEglTest_SyncObject_Base() : 
    1.52 +	iSyncObject(EGL_NO_SYNC_KHR), iSyncObject1(EGL_NO_SYNC_KHR), iSyncObject2(EGL_NO_SYNC_KHR), 
    1.53 +	iThreshold(KThreshold), iDelaySignalling(KDelaySignalling),
    1.54 +	iWaitSyncTimeout(KWaitSyncTimeout), iLongDelaySignalling(KLongDelaySignalling),
    1.55 +	iNumStressIterations(KNumStressIterations)
    1.56 +	{
    1.57 +	}
    1.58 +
    1.59 +CEglTest_SyncObject_Base::~CEglTest_SyncObject_Base()
    1.60 +	{
    1.61 +	if(iPfnEglDestroySyncKHR)
    1.62 +	    {
    1.63 +	    iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
    1.64 +	    iPfnEglDestroySyncKHR(iDisplay, iSyncObject1);
    1.65 +	    iPfnEglDestroySyncKHR(iDisplay, iSyncObject2);
    1.66 +	    }
    1.67 +	CleanAll();
    1.68 +	}
    1.69 +
    1.70 +// from CTestStep
    1.71 +TVerdict CEglTest_SyncObject_Base::doTestStepPreambleL()
    1.72 +	{
    1.73 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Base::doTestStepPreambleL()"));
    1.74 +	CEglTestStep::doTestStepPreambleL();
    1.75 +	TInt res = HAL::Get(HALData::ENanoTickPeriod, iTickPeriodMicroSeconds);
    1.76 +	if(res != KErrNone)
    1.77 +		{
    1.78 +		ERR_PRINTF2(_L("Can't retrieve tick period, err %d"), res);
    1.79 +		User::Leave(res);
    1.80 +		}
    1.81 +	INFO_PRINTF2(_L("Tick period in micro seconds %d"), iTickPeriodMicroSeconds);
    1.82 +	
    1.83 +	_LIT(KKeyThreshold, "Threshold");
    1.84 +	_LIT(KKeyDelaySignalling, "DelaySignalling");
    1.85 +	_LIT(KKeyWaitSyncTimeout, "WaitSyncTimeout");
    1.86 +	_LIT(KKeyLongDelaySignalling, "LongDelaySignalling");
    1.87 +	_LIT(KKeyNumStressIterations, "NumIterations");
    1.88 +
    1.89 +	//retrive all setting from INI file
    1.90 +	GetIntFromConfig(ConfigSection(), KKeyThreshold, iThreshold);
    1.91 +	GetIntFromConfig(ConfigSection(), KKeyDelaySignalling, iDelaySignalling);
    1.92 +	GetIntFromConfig(ConfigSection(), KKeyWaitSyncTimeout, iWaitSyncTimeout);
    1.93 +	GetIntFromConfig(ConfigSection(), KKeyLongDelaySignalling, iLongDelaySignalling);
    1.94 +	GetIntFromConfig(ConfigSection(), KKeyNumStressIterations, iNumStressIterations);
    1.95 +	
    1.96 +	INFO_PRINTF2(_L("Level of tolerance %d"), iThreshold);
    1.97 +	INFO_PRINTF2(_L("Delay before the signal occurs  %d"), iDelaySignalling);
    1.98 +	INFO_PRINTF2(_L("Timeout client waits on sync object %d"), iWaitSyncTimeout);
    1.99 +	INFO_PRINTF2(_L("Long delay before signalling occurs %d"), iLongDelaySignalling);
   1.100 +	INFO_PRINTF2(_L("Number of iterations before stress test exits %d"), iNumStressIterations);
   1.101 +
   1.102 +	INFO_PRINTF1(_L("Check if the Sync object Khronos extension is supported"));
   1.103 +	iIsSyncObjectExtensionSupported = CheckForExtensionL(KEGL_KHR_reusable_sync);
   1.104 +
   1.105 +    INFO_PRINTF1(_L("Check if the Sync object private extension is supported"));
   1.106 +	iIsSyncObjectPrivateExtensionSupported = CheckForExtensionL(KEGL_NOK__private__signal_sync);
   1.107 +	
   1.108 +	CleanAll();
   1.109 +    TEST(GetProcAddress());
   1.110 +	INFO_PRINTF1(_L("End of CEglTest_SyncObject_Base::doTestStepPreambleL()"));
   1.111 +	return TestStepResult();
   1.112 +	}
   1.113 +
   1.114 +void CEglTest_SyncObject_Base::CreateEglSessionL()
   1.115 +	{
   1.116 +	delete iEglSess; //just in case it was called twice
   1.117 +	iEglSess = CTestEglSession::NewL(Logger(), iDisplay, 0);
   1.118 +	}
   1.119 +
   1.120 +void CEglTest_SyncObject_Base::CheckSyncAttrib(EGLint aAttribute, EGLint aExpectedValue)
   1.121 +	{
   1.122 +	EGLint value;
   1.123 +	EGLBoolean res = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject,aAttribute,&value);
   1.124 +	TEST(res == EGL_TRUE);
   1.125 +	TEST(value == aExpectedValue);
   1.126 +	
   1.127 +	switch(aAttribute)
   1.128 +		{
   1.129 +		case EGL_SYNC_TYPE_KHR:
   1.130 +			{
   1.131 +			if (value == EGL_SYNC_REUSABLE_KHR)
   1.132 +				{
   1.133 +				INFO_PRINTF1(_L("  EGL_SYNC_TYPE_KHR: EGL_SYNC_REUSABLE_KHR"));
   1.134 +				}
   1.135 +			else
   1.136 +				{
   1.137 +				ERR_PRINTF1(_L("  EGL_SYNC_TYPE_KHR: Invalid attribute"));
   1.138 +				}
   1.139 +			break;
   1.140 +			}
   1.141 +		case EGL_SYNC_STATUS_KHR:
   1.142 +			{
   1.143 +			if (value == EGL_SIGNALED_KHR)
   1.144 +				{
   1.145 +				INFO_PRINTF1(_L("  EGL_SYNC_STATUS_KHR: EGL_SIGNALED_KHR"));
   1.146 +				}
   1.147 +			else if (value == EGL_UNSIGNALED_KHR)
   1.148 +				{
   1.149 +				INFO_PRINTF1(_L("  EGL_SYNC_STATUS_KHR: EGL_UNSIGNALED_KHR"));
   1.150 +				}
   1.151 +			else
   1.152 +				{
   1.153 +				ERR_PRINTF1(_L("  EGL_SYNC_STATUS_KHR: Invalid attribute"));
   1.154 +				}
   1.155 +			break;
   1.156 +			}
   1.157 +		default:
   1.158 +			{
   1.159 +			ERR_PRINTF1(_L("  Invalid attribute"));
   1.160 +			}
   1.161 +		}
   1.162 +	}
   1.163 +
   1.164 +/**
   1.165 + Obtain extension functions for the sync object 
   1.166 + */
   1.167 +TBool CEglTest_SyncObject_Base::GetProcAddress()
   1.168 +	{
   1.169 +    if(!iIsSyncObjectExtensionSupported)
   1.170 +        {
   1.171 +        INFO_PRINTF1(_L("Sync object extension is not defined in test INI file.\
   1.172 +The retrieval of the pointers to the extension sync object function will be skipped"));
   1.173 +        return ETrue;
   1.174 +        }
   1.175 +
   1.176 +    //retrieve the pointers to the EGL sync object extension functions 
   1.177 +    INFO_PRINTF1(_L("retrieve the pointers to the EGL sync object extension functions"));
   1.178 +    
   1.179 +	iPfnEglCreateSyncKHR = reinterpret_cast <TFPtrEglCreateSyncKhr> (eglGetProcAddress("eglCreateSyncKHR"));
   1.180 +	iPfnEglDestroySyncKHR = reinterpret_cast <TFPtrEglDestroySyncKhr> (eglGetProcAddress("eglDestroySyncKHR"));
   1.181 +	iPfnEglClientWaitSyncKHR = reinterpret_cast <TFPtrEglClientWaitSyncKhr> (eglGetProcAddress("eglClientWaitSyncKHR"));
   1.182 +	iPfnEglSignalSyncKHR = reinterpret_cast <TFPtrEglSignalSyncKhr> (eglGetProcAddress("eglSignalSyncKHR"));
   1.183 +	iPfnEglGetSyncAttribKHR = reinterpret_cast <TFPtrEglGetSyncAttribKhr> (eglGetProcAddress("eglGetSyncAttribKHR"));
   1.184 +    if(iIsSyncObjectPrivateExtensionSupported)
   1.185 +        {
   1.186 +        iPfnEglPrivateSignalSyncNOK = reinterpret_cast <TFPtrEglPrivateSignalSyncNok> (eglGetProcAddress("egl_Private_SignalSyncNOK"));
   1.187 +        if(!iPfnEglPrivateSignalSyncNOK)
   1.188 +            {
   1.189 +            ERR_PRINTF1(_L("   Pointer to function \"egl_Private_SignalSyncNOK\" is not valid"));
   1.190 +            }
   1.191 +        }
   1.192 +	if(!iPfnEglCreateSyncKHR)
   1.193 +		{
   1.194 +		ERR_PRINTF1(_L("   Pointer to function \"eglCreateSyncKHR\" is not valid"));
   1.195 +		}
   1.196 +	if(!iPfnEglDestroySyncKHR)
   1.197 +		{
   1.198 +		ERR_PRINTF1(_L("   Pointer to function \"eglDestroySyncKHR\" is not valid"));
   1.199 +		}
   1.200 +	if(!iPfnEglClientWaitSyncKHR)
   1.201 +		{
   1.202 +		ERR_PRINTF1(_L("   Pointer to function \"eglClientWaitSyncKHR\" is not valid"));
   1.203 +		}
   1.204 +	if(!iPfnEglSignalSyncKHR)
   1.205 +		{
   1.206 +		ERR_PRINTF1(_L("   Pointer to function \"eglSignalSyncKHR\" is not valid"));
   1.207 +		}
   1.208 +
   1.209 +	if(!iPfnEglGetSyncAttribKHR)
   1.210 +		{
   1.211 +		ERR_PRINTF1(_L("   Pointer to function \"eglGetSyncAttribKHR\" is not valid"));
   1.212 +		}
   1.213 +
   1.214 +	if(!(iPfnEglCreateSyncKHR && iPfnEglDestroySyncKHR && iPfnEglClientWaitSyncKHR 
   1.215 +	        && iPfnEglSignalSyncKHR && iPfnEglGetSyncAttribKHR && 
   1.216 +	        (!iIsSyncObjectPrivateExtensionSupported || (iPfnEglPrivateSignalSyncNOK))))
   1.217 +		{//if the private extension is not declared in the test ini file, we won't signal the failure
   1.218 +		return EFalse;
   1.219 +		}
   1.220 +	return ETrue;
   1.221 +	}
   1.222 +
   1.223 +void CEglTest_SyncObject_Base::CleanAll()
   1.224 +	{
   1.225 +	if(iEglSess)
   1.226 +		{
   1.227 +		delete iEglSess;
   1.228 +		iEglSess = NULL;
   1.229 +		}
   1.230 +	TRAPD(res, TerminateDisplayL());
   1.231 +	TEST(res == KErrNone);
   1.232 +	INFO_PRINTF2(_L("Display termination completed with error %d"), res);
   1.233 +	
   1.234 +	INFO_PRINTF1(_L("Main Thread: Calling eglReleaseThread()"));
   1.235 +	ASSERT_EGL_TRUE(eglReleaseThread())
   1.236 +	}
   1.237 +
   1.238 +/**
   1.239 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-001
   1.240 +
   1.241 +@SYMTestPriority 1
   1.242 +
   1.243 +@SYMPREQ 2400
   1.244 +
   1.245 +@SYMREQ 12326
   1.246 +
   1.247 +@SYMTestCaseDesc
   1.248 +To check that current implementation support EGL sync object extension
   1.249 +
   1.250 +@SYMTestActions
   1.251 +1.	Request supporting extension for the existing display by calling eglQueryString(...) and passing EGL_EXTENSIONS as a second parameter.
   1.252 +2.	Obtain an EGL sync object extension functions by supplying the following procname to the function  void (*eglGetProcAddress(const char *procname)):
   1.253 +"eglCreateSyncKHR"
   1.254 +"eglDestroySyncKHR"
   1.255 +"eglClientWaitSyncKHR"
   1.256 +"eglSignalSyncKHR"
   1.257 +"eglGetSyncAttribKHR"
   1.258 +
   1.259 +@SYMTestExpectedResults
   1.260 +1. The function must return a string which includes space separated sub-string "EGL_KHR_reusable_sync".
   1.261 +2. The pointer to the functions should be non zero.
   1.262 +*/
   1.263 +TVerdict CEglTest_SyncObject_Positive_GetProcAddress::doTestStepL()
   1.264 +	{
   1.265 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-001"));
   1.266 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_GetProcAddress::doTestStepL"));
   1.267 +
   1.268 +   if(!iIsSyncObjectExtensionSupported)
   1.269 +        {
   1.270 +        INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.271 +        CleanAll();
   1.272 +        RecordTestResultL();
   1.273 +        CloseTMSGraphicsStep();
   1.274 +        return TestStepResult();
   1.275 +        }
   1.276 +	
   1.277 +	// check that extension "EGL_KHR_reusable_sync" is supported
   1.278 +	INFO_PRINTF1(_L("Check that extension \"EGL_KHR_reusable_sync\" is supported"));
   1.279 +	TEST(CheckForExtensionL(KEGL_KHR_reusable_sync));
   1.280 +
   1.281 +	INFO_PRINTF1(_L("Obtain EGL sync object extension functions"));
   1.282 +	TEST(GetProcAddress());
   1.283 +	
   1.284 +	RecordTestResultL();
   1.285 +	CloseTMSGraphicsStep();
   1.286 +	INFO_PRINTF1(_L("End of CEglTest_SyncObject_Positive_GetProcAddress::doTestStepL"));
   1.287 +	return TestStepResult();
   1.288 +	}
   1.289 +
   1.290 +/**
   1.291 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-005
   1.292 +
   1.293 +@SYMTestPriority 1
   1.294 +
   1.295 +@SYMPREQ 2400
   1.296 +
   1.297 +@SYMREQ 12326
   1.298 +
   1.299 +@SYMTestCaseDesc
   1.300 +To validate the creation and deletion of the sync object.
   1.301 +
   1.302 +@SYMTestActions
   1.303 +1. Create sync object for the default display. NULL are specified in attribute_list. 
   1.304 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR 
   1.305 +2. Retrieve the following attributes of the sync object: EGL_SYNC_TYPE_KHR , 
   1.306 +   EGL_SYNC_STATUS_KHR
   1.307 +3. Delete the sync object 
   1.308 +4. Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
   1.309 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR 
   1.310 +5. Retrieve the following attributes of the sync object: EGL_SYNC_TYPE_KHR , 
   1.311 +   EGL_SYNC_STATUS_KHR
   1.312 +6. Delete the sync object 
   1.313 +   
   1.314 +@SYMTestExpectedResults
   1.315 +1. Sync object handle doesn't equal to EGL_NO_SYNC_KHR 
   1.316 +2. Sync object attribute EGL_SYNC_STATUS_KHR should be set to EGL_UNSIGNALED_KHR by default,  
   1.317 +   attribute EGL_SYNC_TYPE_KHR should be set to EGL_SYNC_REUSABLE_KHR
   1.318 +4. Sync object handle doesn't equal to EGL_NO_SYNC_KHR 
   1.319 +5. Sync object attribute EGL_SYNC_STATUS_KHR should be set to EGL_UNSIGNALED_KHR by default,  
   1.320 +   attribute EGL_SYNC_TYPE_KHR should be set to EGL_SYNC_REUSABLE_KHR
   1.321 + */
   1.322 +TVerdict CEglTest_SyncObject_Positive_CreateDestroy::doTestStepL()
   1.323 +	{
   1.324 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-005"));
   1.325 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_CreateDestroy::doTestStepL"));
   1.326 +	
   1.327 +	if(!iIsSyncObjectExtensionSupported)
   1.328 +		{
   1.329 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.330 +		CleanAll();
   1.331 +		RecordTestResultL();
   1.332 +		CloseTMSGraphicsStep();
   1.333 +		return TestStepResult();
   1.334 +		}
   1.335 +		
   1.336 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   1.337 +	GetDisplayL();
   1.338 +	CreateEglSessionL();
   1.339 +	iEglSess->InitializeL();
   1.340 +	
   1.341 +	INFO_PRINTF1(_L("Create sync object - default display, NULL at attributes, type parameter set to EGL_SYNC_REUSABLE_KHR"));
   1.342 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, NULL);
   1.343 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.344 +	
   1.345 +	//check attributes of the sync object.
   1.346 +	INFO_PRINTF1(_L("Check attributes of sync object"));	
   1.347 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR, EGL_SYNC_REUSABLE_KHR);
   1.348 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR);
   1.349 +	
   1.350 +	INFO_PRINTF1(_L("Delete sync object"));
   1.351 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.352 +	TEST(res == EGL_TRUE);
   1.353 +	
   1.354 +	INFO_PRINTF1(_L("Create sync object - default display, no attribute specified, type parameter set to EGL_SYNC_REUSABLE_KHR "));
   1.355 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
   1.356 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.357 +	
   1.358 +	INFO_PRINTF1(_L("Check attributes"));
   1.359 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR, EGL_SYNC_REUSABLE_KHR);
   1.360 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
   1.361 +
   1.362 +	INFO_PRINTF1(_L("Delete sync object"));
   1.363 +	res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.364 +	TEST(res == EGL_TRUE);
   1.365 +	
   1.366 +	CleanAll();
   1.367 +	RecordTestResultL();
   1.368 +	CloseTMSGraphicsStep();
   1.369 +	return TestStepResult();
   1.370 +	}
   1.371 +
   1.372 +/**
   1.373 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-010
   1.374 +
   1.375 +@SYMTestPriority 1
   1.376 +
   1.377 +@SYMPREQ 2400
   1.378 +
   1.379 +@SYMREQ 12326
   1.380 +
   1.381 +@SYMTestCaseDesc
   1.382 +To check that transition from EGL_UNSIGNALED_KHR to EGL_SIGNALED_KHR state will trigger the signal and unblock the client thread  
   1.383 +
   1.384 +@SYMTestActions
   1.385 +1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
   1.386 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR  
   1.387 +2. Launch thread A
   1.388 +3. Wait on sync object by calling eglClientWaitSyncKHR  
   1.389 +4. Signal on the sync object from thread A with the flag EGL_SIGNALED_KHR
   1.390 +5. Retrieve EGL_SYNC_STATUS_KHR attribute
   1.391 +6. Delete the sync object
   1.392 +   
   1.393 +@SYMTestExpectedResults
   1.394 +3. The main thread is blocked
   1.395 +4. After the signal the main thread should be unblocked and the value returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR
   1.396 +5. Status attribute is set to EGL_SIGNALED_KHR
   1.397 +*/
   1.398 +TVerdict CEglTest_SyncObject_Positive_WaitSignal::doTestStepL()
   1.399 +	{
   1.400 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-010"));
   1.401 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitSignal::doTestStepL"));
   1.402 +		
   1.403 +	if(!iIsSyncObjectExtensionSupported)
   1.404 +		{
   1.405 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.406 +		CleanAll();
   1.407 +		RecordTestResultL();
   1.408 +		CloseTMSGraphicsStep();
   1.409 +		return TestStepResult();
   1.410 +		}
   1.411 +
   1.412 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   1.413 +	GetDisplayL();
   1.414 +	CreateEglSessionL();
   1.415 +	iEglSess->InitializeL();
   1.416 +	
   1.417 +	//create sync object
   1.418 +	INFO_PRINTF1(_L("Create sync object"));
   1.419 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
   1.420 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.421 +	
   1.422 +	//launch threadA
   1.423 +	Test_MultiThreadL(1, EFalse);
   1.424 +	
   1.425 +	//Stall the main thread
   1.426 +	TUint32 timestampBefore = User::NTickCount();	//microsecond
   1.427 +	EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
   1.428 +	TUint32 timestampAfter = User::NTickCount();
   1.429 +	TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
   1.430 +	
   1.431 +	INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
   1.432 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
   1.433 +	TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
   1.434 +			
   1.435 +	INFO_PRINTF1(_L("Check attributes of sync object"));	
   1.436 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
   1.437 +
   1.438 +	INFO_PRINTF1(_L("Delete sync object"));
   1.439 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.440 +	TEST(res == EGL_TRUE);
   1.441 +	
   1.442 +	CleanAll();
   1.443 +	RecordTestResultL();
   1.444 +	CloseTMSGraphicsStep();
   1.445 +	return TestStepResult();
   1.446 +	}
   1.447 +
   1.448 +void CEglTest_SyncObject_Positive_WaitSignal::doThreadFunctionL(TInt aIdx)
   1.449 +	{
   1.450 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_WaitSignal::doThreadFunctionL, Thread %d"),aIdx);
   1.451 +	ASSERT_TRUE(aIdx==0);
   1.452 +	
   1.453 +	User::After(iDelaySignalling);
   1.454 +	
   1.455 +	INFO_PRINTF1(_L("signal sync object from thread A"));
   1.456 +	EGLBoolean res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_SIGNALED_KHR);
   1.457 +	TEST(res == EGL_TRUE);
   1.458 +	}
   1.459 +
   1.460 +/**
   1.461 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-015
   1.462 +
   1.463 +@SYMTestPriority 1
   1.464 +
   1.465 +@SYMPREQ 2400
   1.466 +
   1.467 +@SYMREQ 12326
   1.468 +
   1.469 +@SYMTestCaseDesc
   1.470 +To check that the client will not be blocked by waiting on the sync object 
   1.471 +if the latter is in EGL_SIGNALED_KHR state and will stay blocked until 
   1.472 +transition from unsignal to signal state occurs.
   1.473 +To check that eglSignalSyncKHR sets the state of the sync object correctly.
   1.474 +
   1.475 +@SYMTestActions
   1.476 +1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
   1.477 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR
   1.478 +2. Call eglSignalSyncKHR with EGL_SIGNALED_KHR as a parameter.
   1.479 +3. Retrieve an EGL_SYNC_STATUS_KHR attribute.
   1.480 +4. Try to wait on the sync object by calling eglClientWaitSyncKHR.
   1.481 +5. Call eglSignalSyncKHR with EGL_UNSIGNALED_KHR as a parameter.
   1.482 +6. Retrieve an EGL_SYNC_STATUS_KHR attribute. 
   1.483 +7. Launch thread A.
   1.484 +8. Waiting on the sync object by calling eglClientWaitSyncKHR.
   1.485 +9. From thread A call eglSignalSyncKHR with EGL_UNSIGNALED_KHR as a parameter. 
   1.486 +10. From thread A retrieve EGL_SYNC_STATUS_KHR attribute.
   1.487 +11. From thread A call eglSignalSyncKHR with EGL_SIGNALED_KHR as a parameter.
   1.488 +12. From thread A retrieve EGL_SYNC_STATUS_KHR attribute.
   1.489 +13  Delete the sync object.
   1.490 +
   1.491 +@SYMTestExpectedResults
   1.492 +3. EGL_SYNC_STATUS_KHR attribute is set to EGL_SIGNALED_KHR
   1.493 +4. The thread is not blocked and an error code returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR
   1.494 +6. EGL_SYNC_STATUS_KHR attribute is set to EGL_UNSIGNALED_KHR
   1.495 +8. Main thread is blocked
   1.496 +9. Main thread stays blocked
   1.497 +10. EGL_SYNC_STATUS_KHR attribute is set to EGL_UNSIGNALED_KHR
   1.498 +11. Main thread is unblocked
   1.499 +12. EGL_SYNC_STATUS_KHR attribute is set to EGL_SIGNALED_KHR
   1.500 +*/
   1.501 +TVerdict CEglTest_SyncObject_Positive_WaitSignal2::doTestStepL()
   1.502 +	{
   1.503 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-015"));
   1.504 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitSignal2::doTestStepL"));
   1.505 +		
   1.506 +	if(!iIsSyncObjectExtensionSupported)
   1.507 +		{
   1.508 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.509 +		CleanAll();
   1.510 +		RecordTestResultL();
   1.511 +		CloseTMSGraphicsStep();
   1.512 +		return TestStepResult();
   1.513 +		}
   1.514 +
   1.515 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   1.516 +	GetDisplayL();
   1.517 +	CreateEglSessionL();
   1.518 +	iEglSess->InitializeL();
   1.519 +		
   1.520 +	INFO_PRINTF1(_L("Create sync object"));
   1.521 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
   1.522 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.523 +
   1.524 +	//set to signal state, basically we are not changing anything here 
   1.525 +	EGLBoolean res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_SIGNALED_KHR);
   1.526 +	TEST(res = EGL_TRUE);
   1.527 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_SIGNALED_KHR);
   1.528 +
   1.529 +	INFO_PRINTF1(_L("Try to wait on the sync object by calling eglClientWaitSyncKHR"));
   1.530 +	TUint32 timestampBefore = User::NTickCount();	//microsecond
   1.531 +	EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
   1.532 +	TUint32 timestampAfter = User::NTickCount();
   1.533 +	TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
   1.534 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
   1.535 +	INFO_PRINTF1(_L(" Check that main thread was not stalled at eglClientWaitSyncKHR()"));
   1.536 +	TEST(timeElapsed <  iThreshold);
   1.537 +
   1.538 +	//set to unsignal state 
   1.539 +	res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_UNSIGNALED_KHR);
   1.540 +	TEST(res == EGL_TRUE);
   1.541 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR);
   1.542 +	
   1.543 +	//launch threadA
   1.544 +	Test_MultiThreadL(1, EFalse);
   1.545 +	
   1.546 +	//Stall the main thread
   1.547 +	timestampBefore = User::NTickCount();
   1.548 +	resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
   1.549 +	timestampAfter = User::NTickCount();
   1.550 +	timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
   1.551 +	
   1.552 +	INFO_PRINTF5(_L("Main thread waited on eglClientWaitSyncKHR for %d usec (threshold was [%d + %d +- %d])"),timeElapsed, iDelaySignalling*2, iTimeOverhead, iThreshold);
   1.553 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
   1.554 +	TEST(Abs(timeElapsed - (iDelaySignalling*2 + iTimeOverhead)) < iThreshold);
   1.555 +
   1.556 +	INFO_PRINTF1(_L("Delete sync object"));
   1.557 +	res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.558 +	TEST(res == EGL_TRUE);
   1.559 +	
   1.560 +	CleanAll();
   1.561 +	RecordTestResultL();
   1.562 +	CloseTMSGraphicsStep();
   1.563 +	return TestStepResult();
   1.564 +	}
   1.565 +
   1.566 +void CEglTest_SyncObject_Positive_WaitSignal2::doThreadFunctionL(TInt aIdx)
   1.567 +	{
   1.568 +	TUint32 timeOverheadStart = User::NTickCount();
   1.569 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_WaitSignal2::doThreadFunctionL, Thread %d"),aIdx);
   1.570 +	ASSERT_TRUE(aIdx==0);
   1.571 +	
   1.572 +	User::After(iDelaySignalling);
   1.573 +	INFO_PRINTF1(_L("unsignal sync object from thread A"));
   1.574 +	EGLBoolean 	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_UNSIGNALED_KHR);
   1.575 +	TEST(resSignal == EGL_TRUE);
   1.576 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR);
   1.577 +	
   1.578 +	User::After(iDelaySignalling);
   1.579 +	INFO_PRINTF1(_L("signal sync object from thread A"));
   1.580 +	TUint32 timeOverheadEnd = User::NTickCount();
   1.581 +	iTimeOverhead = ElapsedTime(timeOverheadEnd, timeOverheadStart) - iDelaySignalling*2;
   1.582 +	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
   1.583 +	TEST(resSignal == EGL_TRUE);
   1.584 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_SIGNALED_KHR);
   1.585 +	}
   1.586 +
   1.587 +/**
   1.588 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-020
   1.589 +
   1.590 +@SYMTestPriority 1
   1.591 +
   1.592 +@SYMPREQ 2400
   1.593 +
   1.594 +@SYMREQ 12326
   1.595 +
   1.596 +@SYMTestCaseDesc
   1.597 +To check that the deletion of the sync object triggers the signalling 
   1.598 +
   1.599 +@SYMTestActions
   1.600 +1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
   1.601 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR 
   1.602 +2. Launch a thread A
   1.603 +3. Stall the main thread by calling eglClientWaitSyncKHR() on the sync object with timeout value EGL_FOREVER_KHR
   1.604 +4. Delete the sync object from the thread A
   1.605 +   
   1.606 +@SYMTestExpectedResults
   1.607 +3. The main thread which waits for the signal must be stalled
   1.608 +4. After the sync object has been deleted the main client thread will be unblocked and an error code returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR
   1.609 +*/
   1.610 +TVerdict CEglTest_SyncObject_Positive_WaitDelete::doTestStepL()
   1.611 +    {
   1.612 +    SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-020"));
   1.613 +    INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitDelete::doTestStepL"));
   1.614 +    
   1.615 +	if(!iIsSyncObjectExtensionSupported)
   1.616 +		{
   1.617 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.618 +		CleanAll();
   1.619 +		RecordTestResultL();
   1.620 +		CloseTMSGraphicsStep();
   1.621 +		return TestStepResult();
   1.622 +		}
   1.623 +
   1.624 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   1.625 +    GetDisplayL();
   1.626 +    CreateEglSessionL();
   1.627 +	iEglSess->InitializeL();
   1.628 +    
   1.629 +    //create sync object
   1.630 +    INFO_PRINTF1(_L("Create sync object"));
   1.631 +    iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
   1.632 +    TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.633 +
   1.634 +    //launch threadA
   1.635 +    Test_MultiThreadL(1, EFalse);
   1.636 + 
   1.637 +    //Stall the main thread
   1.638 +    TUint32 timestampBefore = User::NTickCount();  //microsecond
   1.639 +    EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
   1.640 +    TUint32 timestampAfter = User::NTickCount();
   1.641 +    TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
   1.642 +    
   1.643 +    INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
   1.644 +    TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
   1.645 +    TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
   1.646 +    
   1.647 +    CleanAll();
   1.648 +    RecordTestResultL();
   1.649 +    CloseTMSGraphicsStep();
   1.650 +    return TestStepResult();
   1.651 +    }
   1.652 +
   1.653 +void CEglTest_SyncObject_Positive_WaitDelete::doThreadFunctionL(TInt aIdx)
   1.654 +    {
   1.655 +    INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_WaitDelete::doThreadFunctionL, Thread %d"),aIdx);
   1.656 +	ASSERT_TRUE(aIdx==0);
   1.657 +    
   1.658 +    User::After(iDelaySignalling);
   1.659 +    INFO_PRINTF1(_L("Delete sync object from thread A"));
   1.660 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.661 +    TEST(res == EGL_TRUE);
   1.662 +    }
   1.663 +
   1.664 +/**
   1.665 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-025
   1.666 +
   1.667 +@SYMTestPriority 1
   1.668 +
   1.669 +@SYMPREQ 2400
   1.670 +
   1.671 +@SYMREQ 12326
   1.672 +
   1.673 +@SYMTestCaseDesc
   1.674 +To check that client will be unblocked once the timeout has expired even if there is no signalling occurred.
   1.675 +
   1.676 +@SYMTestActions
   1.677 +1.	Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
   1.678 +    The type parameter is set to EGL_SYNC_REUSABLE_KHR
   1.679 +2.	Take the start time stamp
   1.680 +3.	Call eglClientWaitSyncKHR() on the sync object with timeout value equals five seconds
   1.681 +4.	Take the end timestamp
   1.682 +5.	Retrieve EGL_SYNC_STATUS attribute of the sync object
   1.683 +6.	Destroy the sync object
   1.684 +
   1.685 +@SYMTestExpectedResults
   1.686 +3. The client thread should stay blocked until timeout is expired
   1.687 +4. Check that (timestamp End - timestamp Before)  equals (roughly) timeout and an error code returned by 
   1.688 +   eglClientWaitSyncKHR is EGL_TIMEOUTE_EXPIRED_KHR
   1.689 +5. The sync object attribute EGL_SYNC_STATUS is set to EGL_UNSIGNALED_KHR   
   1.690 +*/
   1.691 +TVerdict CEglTest_SyncObject_Positive_WaitWithTimeoutExpired::doTestStepL()
   1.692 +	{
   1.693 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-025"));
   1.694 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitWithTimeoutExpired::doTestStepL started...."));
   1.695 +
   1.696 +	if(!iIsSyncObjectExtensionSupported)
   1.697 +		{
   1.698 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.699 +		CleanAll();
   1.700 +		RecordTestResultL();
   1.701 +		CloseTMSGraphicsStep();
   1.702 +		return TestStepResult();
   1.703 +		}
   1.704 +
   1.705 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   1.706 +	GetDisplayL();
   1.707 +	CreateEglSessionL();
   1.708 +	iEglSess->InitializeL();
   1.709 +	
   1.710 +	INFO_PRINTF1(_L("Create sync object"));
   1.711 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
   1.712 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.713 +
   1.714 +	// calling wait sync without signaling the object should hit the predefined timeout if set to anything different to EGL_FOREVER_KHR
   1.715 +	INFO_PRINTF2(_L("Calling eglClientWaitSyncKHR on the object with a defined timeout of %d usec"), iWaitSyncTimeout);
   1.716 +	EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
   1.717 +	TUint32 timestampBefore = User::NTickCount();
   1.718 +	EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
   1.719 +	TUint32 timestampAfter = User::NTickCount();
   1.720 +	TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
   1.721 +
   1.722 +	INFO_PRINTF4(_L("Waited on eglClientWaitSyncKHR for %d usec (threshold was [%d +- %d])"),timeElapsed, iWaitSyncTimeout, iThreshold);
   1.723 +	TEST(resClientWait == EGL_TIMEOUT_EXPIRED_KHR);
   1.724 +	TEST (Abs(timeElapsed - timeoutNano/1000) < iThreshold);
   1.725 +
   1.726 +	INFO_PRINTF1(_L("Check attributes..."));
   1.727 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
   1.728 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
   1.729 +
   1.730 +	INFO_PRINTF1(_L("Delete sync object"));
   1.731 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.732 +	TEST(res == EGL_TRUE);
   1.733 +
   1.734 +	CleanAll();
   1.735 +	RecordTestResultL();
   1.736 +	CloseTMSGraphicsStep();
   1.737 +	INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_WaitWithTimeoutExpired::doTestStepL completed!"));
   1.738 +	return TestStepResult();
   1.739 +	}
   1.740 +
   1.741 +/**
   1.742 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-030
   1.743 +
   1.744 +@SYMTestPriority 1
   1.745 +
   1.746 +@SYMPREQ 2400
   1.747 +
   1.748 +@SYMREQ 12326
   1.749 +
   1.750 +@SYMTestCaseDesc
   1.751 +To check that client will be unblocked once the signalling occurs even if the timeout is not expired
   1.752 +
   1.753 +@SYMTestActions
   1.754 +1.	Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
   1.755 +    The type parameter is set to EGL_SYNC_REUSABLE_KHR.
   1.756 +2.	Launch thread A
   1.757 +3.	Take the start time stamp
   1.758 +4.	Call eglClientWaitSyncKHR() on the sync object with timeout value equals five seconds
   1.759 +5.	Signal on the sync object from thread A before timeout is expired (after 2.5 seconds).
   1.760 +6.	Takes the end timestamp
   1.761 +7.	Retrieve EGL_SYNC_STATUS attribute of the sync object from thread A
   1.762 +8.	Destroy the sync object
   1.763 +
   1.764 +@SYMTestExpectedResults
   1.765 +4. The client thread should be blocked
   1.766 +6. The main thread is unblocked. Check that (timestamp End - timestamp Before)  equals (roughly)
   1.767 +   2.5 seconds and an error code returned by eglClientWaitSyncKHR is EGL_CONDITION_SATISFIED_KHR
   1.768 +7. The sync object attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR 
   1.769 +*/
   1.770 +TVerdict CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doTestStepL()
   1.771 +	{
   1.772 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-030"));
   1.773 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doTestStepL started...."));
   1.774 +
   1.775 +	if(!iIsSyncObjectExtensionSupported)
   1.776 +		{
   1.777 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.778 +		CleanAll();
   1.779 +		RecordTestResultL();
   1.780 +		CloseTMSGraphicsStep();
   1.781 +		return TestStepResult();
   1.782 +		}
   1.783 +
   1.784 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   1.785 +	GetDisplayL();
   1.786 +	CreateEglSessionL();
   1.787 +	iEglSess->InitializeL();
   1.788 +	
   1.789 +	INFO_PRINTF1(_L("Create sync object"));
   1.790 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
   1.791 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.792 +
   1.793 +	INFO_PRINTF1(_L("Launching thread A..."));
   1.794 +	Test_MultiThreadL(1, EFalse);
   1.795 +
   1.796 +	INFO_PRINTF2(_L("Main thread waiting for thread A to signal with a defined timeout of %d usec"), iWaitSyncTimeout);
   1.797 +	EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
   1.798 +	TUint32 timestampBefore = User::NTickCount();
   1.799 +	EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
   1.800 +	TUint32 timestampAfter = User::NTickCount();
   1.801 +	TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
   1.802 +
   1.803 +	INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
   1.804 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
   1.805 +	TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
   1.806 +
   1.807 +	INFO_PRINTF1(_L("Check attributes..."));
   1.808 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
   1.809 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
   1.810 +
   1.811 +	INFO_PRINTF1(_L("Delete sync object"));
   1.812 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.813 +	TEST(res == EGL_TRUE);
   1.814 +
   1.815 +	CleanAll();
   1.816 +	RecordTestResultL();
   1.817 +	CloseTMSGraphicsStep();
   1.818 +	INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doTestStepL completed!"));
   1.819 +	return TestStepResult();
   1.820 +	}
   1.821 +
   1.822 +void CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doThreadFunctionL(TInt aIdx)
   1.823 +	{
   1.824 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doThreadFunctionL, Thread %d"),aIdx);
   1.825 +	ASSERT_TRUE(aIdx==0);
   1.826 +
   1.827 +	INFO_PRINTF2(_L("Wait for a bit before Signal sync object, Thread %d"),aIdx);
   1.828 +	User::After(iDelaySignalling);
   1.829 +	EGLBoolean 	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
   1.830 +	TEST(resSignal == EGL_TRUE);
   1.831 +	INFO_PRINTF2(_L("Signal sync object done, Thread %d"),aIdx);
   1.832 +	}
   1.833 +
   1.834 +/**
   1.835 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-035
   1.836 +
   1.837 +@SYMTestPriority 1
   1.838 +
   1.839 +@SYMPREQ 2400
   1.840 +
   1.841 +@SYMREQ 12326
   1.842 +
   1.843 +@SYMTestCaseDesc
   1.844 +To check that client will be unblocked once the sync object has been deleted  even if the timeout is not expired
   1.845 +
   1.846 +@SYMTestActions
   1.847 +1.	Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
   1.848 +    The type parameter is set to EGL_SYNC_REUSABLE_KHR
   1.849 +2.	Launch thread A
   1.850 +3.	Take the start time stamp
   1.851 +4.	Stall the client thread by calling eglClientWaitSyncKHR() on the sync object with timeout value equals five seconds
   1.852 +5.	Destroy the sync object from thread A before timeout is expired. (2.5 seconds)
   1.853 +6.	Takes the end timestamp
   1.854 +7.	Retrieve EGL_SYNC_STATUS attribute of the sync object
   1.855 +8.	Destroy the sync object
   1.856 +
   1.857 +@SYMTestExpectedResults
   1.858 +4. The main client thread should be blocked
   1.859 +5. The main thread is unblocked. Check that (timestamp End - timestamp Before)  equals (roughly) 
   1.860 +   2.5 seconds and an error code returned by eglClientWaitSyncKHR is EGL_CONDITION_SATISFIED_KHR
   1.861 +7. eglGetSyncAttribKHR() returns EGL_FALSE and EGL_BAD_PARAMETER is generated
   1.862 +*/
   1.863 +TVerdict CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doTestStepL()
   1.864 +	{
   1.865 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-035"));
   1.866 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doTestStepL started...."));
   1.867 +
   1.868 +	if(!iIsSyncObjectExtensionSupported)
   1.869 +		{
   1.870 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.871 +		CleanAll();
   1.872 +		RecordTestResultL();
   1.873 +		CloseTMSGraphicsStep();
   1.874 +		return TestStepResult();
   1.875 +		}
   1.876 +
   1.877 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   1.878 +	GetDisplayL();
   1.879 +	CreateEglSessionL();
   1.880 +	iEglSess->InitializeL();
   1.881 +	
   1.882 +	INFO_PRINTF1(_L("Create sync object"));
   1.883 +    iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
   1.884 +    TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.885 +
   1.886 +	INFO_PRINTF1(_L("Launching thread A..."));
   1.887 +	Test_MultiThreadL(1, EFalse);
   1.888 +
   1.889 +	INFO_PRINTF2(_L("Main thread waiting for thread A to signal with a defined timeout of %d usec"), iWaitSyncTimeout);
   1.890 +	EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
   1.891 +	TUint32 timestampBefore = User::NTickCount();
   1.892 +	EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
   1.893 +	TUint32 timestampAfter = User::NTickCount();
   1.894 +	TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
   1.895 +
   1.896 +	INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec before sync object was deleted (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
   1.897 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
   1.898 +	TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
   1.899 +
   1.900 +	INFO_PRINTF1(_L("Check attributes..."));
   1.901 +	EGLint syncTypeValue=-1;
   1.902 +	EGLBoolean ret = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject,EGL_SYNC_TYPE_KHR,&syncTypeValue);
   1.903 +	TEST(ret == EGL_FALSE);
   1.904 +	EGLint error = eglGetError();
   1.905 +	TEST(error == EGL_BAD_PARAMETER);
   1.906 +	TEST(syncTypeValue == -1); // due to the error, it wasn't properly retrieved
   1.907 +
   1.908 +	INFO_PRINTF1(_L("(attempt to) Delete sync object (was already deleted by a worker thread)"));
   1.909 +	ret = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.910 +	TEST(ret == EGL_FALSE);
   1.911 +	error = eglGetError();
   1.912 +	TEST(error == EGL_BAD_PARAMETER);
   1.913 +
   1.914 +	CleanAll();
   1.915 +	RecordTestResultL();
   1.916 +	CloseTMSGraphicsStep();
   1.917 +	INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doTestStepL completed!"));
   1.918 +	return TestStepResult();
   1.919 +	}
   1.920 +
   1.921 +void CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doThreadFunctionL(TInt aIdx)
   1.922 +	{
   1.923 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doThreadFunctionL, Thread %d"),aIdx);
   1.924 +	ASSERT_TRUE(aIdx==0);
   1.925 +
   1.926 +	INFO_PRINTF2(_L("Wait for a bit before destroying sync object, Thread %d"),aIdx);
   1.927 +	User::After(iDelaySignalling);
   1.928 +	TInt res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.929 +	TEST(res == EGL_TRUE);
   1.930 +	INFO_PRINTF2(_L("Delete sync object done, Thread %d"),aIdx);
   1.931 +	}
   1.932 +
   1.933 +/**
   1.934 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-040
   1.935 +
   1.936 +@SYMTestPriority 1
   1.937 +
   1.938 +@SYMPREQ 2400
   1.939 +
   1.940 +@SYMREQ 12326
   1.941 +
   1.942 +@SYMTestCaseDesc
   1.943 +To check that all threads waiting for the signal on the same sync object will be unblocked before the timeout has expired.
   1.944 +
   1.945 +@SYMTestActions
   1.946 +1.	Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
   1.947 +    The type parameter is set to EGL_SYNC_REUSABLE_KHR
   1.948 +2.	Launch two threads A and B.
   1.949 +3.	Call eglClientWaitSyncKHR() (from threads A and B) on the sync object with timeout value equals five seconds 
   1.950 +    in thread A and EGL_FOREVER_KHR in thread B.
   1.951 +4.	Signal on the sync object with the flag EGL_SIGNALED_KHR from the main thread before timeout expired (after 2.5 seconds)
   1.952 +5.	Retrieve EGL_SYNC_STATUS attribute of the sync object from the main thread
   1.953 +6.	Destroy the sync object
   1.954 +
   1.955 +@SYMTestExpectedResults
   1.956 +3. Threads A and B will be stalled
   1.957 +4. Both threads A and B will be unblocked and a value returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR.  
   1.958 +5. The sync object attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR
   1.959 +*/
   1.960 +TVerdict CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doTestStepL()
   1.961 +	{
   1.962 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-040"));
   1.963 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doTestStepL started...."));
   1.964 +
   1.965 +	if(!iIsSyncObjectExtensionSupported)
   1.966 +		{
   1.967 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
   1.968 +		CleanAll();
   1.969 +		RecordTestResultL();
   1.970 +		CloseTMSGraphicsStep();
   1.971 +		return TestStepResult();
   1.972 +		}
   1.973 +
   1.974 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
   1.975 +	GetDisplayL();
   1.976 +	CreateEglSessionL();
   1.977 +	iEglSess->InitializeL();
   1.978 +
   1.979 +	INFO_PRINTF1(_L("Create sync object"));
   1.980 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
   1.981 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
   1.982 +
   1.983 +	INFO_PRINTF1(_L("Launching threads A and B..."));
   1.984 +	Test_MultiThreadL(2, EFalse);
   1.985 +
   1.986 +	INFO_PRINTF1(_L("Main thread, wait for a bit before Signal sync object"));
   1.987 +	User::After(iDelaySignalling);
   1.988 +	EGLBoolean 	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
   1.989 +	TEST(resSignal == EGL_TRUE);
   1.990 +	INFO_PRINTF1(_L("Main thread Signal sync object done"));
   1.991 +
   1.992 +	INFO_PRINTF1(_L("Check attributes..."));
   1.993 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
   1.994 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
   1.995 +
   1.996 +	INFO_PRINTF1(_L("Delete sync object"));
   1.997 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
   1.998 +	TEST(res == EGL_TRUE);
   1.999 +
  1.1000 +	CleanAll();
  1.1001 +	RecordTestResultL();
  1.1002 +	CloseTMSGraphicsStep();
  1.1003 +	INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doTestStepL completed!"));
  1.1004 +	return TestStepResult();
  1.1005 +	}
  1.1006 +
  1.1007 +void CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doThreadFunctionL(TInt aIdx)
  1.1008 +	{
  1.1009 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doThreadFunctionL, Thread %d"), aIdx);
  1.1010 +	ASSERT_TRUE(aIdx==0 || aIdx==1);
  1.1011 +
  1.1012 +	//Thread 0 waits for the main thread to signal the sync object, and exits
  1.1013 +	if(aIdx == 0)	
  1.1014 +		{
  1.1015 +		INFO_PRINTF2(_L("Thread %d waiting for main thread to signal with a timeout EGL_FOREVER_KHR"), aIdx);
  1.1016 +		TUint32 timestampBefore = User::NTickCount();
  1.1017 +		EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.1018 +		TUint32 timestampAfter = User::NTickCount();
  1.1019 +		TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1020 +
  1.1021 +		INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was signaled (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
  1.1022 +		TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1023 +		TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1024 +		}
  1.1025 +	//Thread 1 waits for the main thread to signal the sync object, and exits
  1.1026 +	else if(aIdx == 1)
  1.1027 +		{
  1.1028 +		INFO_PRINTF3(_L("Thread %d waiting for main thread to signal with a defined timeout of %d"), aIdx, iWaitSyncTimeout);
  1.1029 +		EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
  1.1030 +		TUint32 timestampBefore = User::NTickCount();
  1.1031 +		EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
  1.1032 +		TUint32 timestampAfter = User::NTickCount();
  1.1033 +		TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1034 +
  1.1035 +		INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was signaled (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
  1.1036 +		TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1037 +		TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1038 +		}
  1.1039 +	}
  1.1040 +
  1.1041 +/**
  1.1042 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-045
  1.1043 +
  1.1044 +@SYMTestPriority 1
  1.1045 +
  1.1046 +@SYMPREQ 2400
  1.1047 +
  1.1048 +@SYMREQ 12326
  1.1049 +
  1.1050 +@SYMTestCaseDesc
  1.1051 +To check that a thread resumed due to timeout will not unblock another thread waiting for the signal.
  1.1052 +
  1.1053 +@SYMTestActions
  1.1054 +1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
  1.1055 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR
  1.1056 +2. Launch two threads A and B.
  1.1057 +3. Call eglClientWaitSyncKHR() (from threads A and B) on the sync object with timeout value equals five seconds in thread A and EGL_FOREVER_KHR in thread B.
  1.1058 +4. Wait for approximately 7.5 seconds
  1.1059 +5. Retrieve EGL_SYNC_STATUS attribute of the sync object from the main thread
  1.1060 +6. Signal on the sync object with the flag EGL_SIGNALED_KHR from the main thread
  1.1061 +7. Retrieve EGL_SYNC_STATUS attribute of the sync object from the main thread
  1.1062 +8. Destroy the sync object
  1.1063 +
  1.1064 +@SYMTestExpectedResults
  1.1065 +3.Threads A and B will be stalled
  1.1066 +4. Thread A will be unblocked after approximately 5 seconds and a value returned by eglClientWaitSyncKHR() is set to EGL_TIMEOUT_EXPIRED_KHR.
  1.1067 +5. EGL_SYNC_STATUS attribute of the sync object is set to EGL_UNSIGNALED_KHR
  1.1068 +6. Threads B will be unblocked and a value returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR.  
  1.1069 +7. The sync object attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR
  1.1070 +*/
  1.1071 +TVerdict CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doTestStepL()
  1.1072 +	{
  1.1073 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-045"));
  1.1074 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doTestStepL started...."));
  1.1075 +
  1.1076 +	if(!iIsSyncObjectExtensionSupported)
  1.1077 +		{
  1.1078 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.1079 +		CleanAll();
  1.1080 +		RecordTestResultL();
  1.1081 +		CloseTMSGraphicsStep();
  1.1082 +		return TestStepResult();
  1.1083 +		}
  1.1084 +
  1.1085 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.1086 +	GetDisplayL();
  1.1087 +	CreateEglSessionL();
  1.1088 +	iEglSess->InitializeL();
  1.1089 +	
  1.1090 +	INFO_PRINTF1(_L("Create sync object"));
  1.1091 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1092 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.1093 +
  1.1094 +	INFO_PRINTF1(_L("Launching threads A and B..."));
  1.1095 +	Test_MultiThreadL(2, EFalse);
  1.1096 +	TUint32 timeOverheadStart = User::NTickCount();
  1.1097 +	
  1.1098 +	INFO_PRINTF1(_L("Main thread, wait for a long time, no Signal sync object yet"));
  1.1099 +	User::After(iLongDelaySignalling);
  1.1100 +
  1.1101 +	INFO_PRINTF1(_L("Check attributes..."));
  1.1102 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
  1.1103 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
  1.1104 +
  1.1105 +	INFO_PRINTF1(_L("Main thread, Signal sync object now"));
  1.1106 +	TUint32 timeOverheadEnd = User::NTickCount();
  1.1107 +	iTimeOverhead = ElapsedTime(timeOverheadEnd, timeOverheadStart) - iLongDelaySignalling;
  1.1108 +	EGLBoolean 	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
  1.1109 +	TEST(resSignal == EGL_TRUE);
  1.1110 +	INFO_PRINTF1(_L("Main thread, Signal sync object done"));
  1.1111 +
  1.1112 +	INFO_PRINTF1(_L("Check attributes..."));
  1.1113 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
  1.1114 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
  1.1115 +
  1.1116 +	INFO_PRINTF1(_L("Delete sync object"));
  1.1117 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.1118 +	TEST(res == EGL_TRUE);
  1.1119 +
  1.1120 +	CleanAll();
  1.1121 +	RecordTestResultL();
  1.1122 +	CloseTMSGraphicsStep();
  1.1123 +	INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doTestStepL completed!"));
  1.1124 +	return TestStepResult();
  1.1125 +	}
  1.1126 +
  1.1127 +void CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doThreadFunctionL(TInt aIdx)
  1.1128 +	{
  1.1129 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doThreadFunctionL, Thread %d"),aIdx);
  1.1130 +	ASSERT_TRUE(aIdx==0 || aIdx==1);
  1.1131 +
  1.1132 +	//Thread 0 waits for the main thread to signal the sync object, and exits
  1.1133 +	if(aIdx == 0)	
  1.1134 +		{
  1.1135 +		INFO_PRINTF2(_L("Thread %d waiting for main thread to signal with a timeout EGL_FOREVER_KHR"), aIdx);
  1.1136 +		TUint32 timestampBefore = User::NTickCount();
  1.1137 +		EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.1138 +		TUint32 timestampAfter = User::NTickCount();
  1.1139 +		TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1140 +
  1.1141 +		INFO_PRINTF6(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was signaled (threshold was [%d + %d +- %d])"), aIdx, timeElapsed, iLongDelaySignalling, iTimeOverhead, iThreshold);
  1.1142 +		TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1143 +		TEST (Abs(timeElapsed - (iLongDelaySignalling + iTimeOverhead)) < iThreshold);
  1.1144 +		}
  1.1145 +	//Thread 1 waits for the main thread to signal the sync object, and exits
  1.1146 +	else if(aIdx == 1)
  1.1147 +		{
  1.1148 +		INFO_PRINTF3(_L("Thread %d waiting for main thread to signal with a defined timeout of %d"), aIdx, iWaitSyncTimeout);
  1.1149 +		EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
  1.1150 +		TUint32 timestampBefore = User::NTickCount();
  1.1151 +		EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
  1.1152 +		TUint32 timestampAfter = User::NTickCount();
  1.1153 +		TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1154 +
  1.1155 +		INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was timeout'ed (threshold was [%d +- %d])"), aIdx, timeElapsed, iWaitSyncTimeout, iThreshold);
  1.1156 +		TEST(resClientWait == EGL_TIMEOUT_EXPIRED_KHR);
  1.1157 +		TEST (Abs(timeElapsed - iWaitSyncTimeout) < iThreshold);
  1.1158 +		}
  1.1159 +	}
  1.1160 +
  1.1161 +/**
  1.1162 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-050
  1.1163 +
  1.1164 +@SYMTestPriority 1
  1.1165 +
  1.1166 +@SYMPREQ 2400
  1.1167 +
  1.1168 +@SYMREQ 12326
  1.1169 +
  1.1170 +@SYMTestCaseDesc
  1.1171 +To check that signalling on one sync object won't unblock the thread waiting on another sync object.
  1.1172 +
  1.1173 +@SYMTestActions
  1.1174 +1.	Create two sync objects (S1 and S2) for the default display with no attributes are specified and the type parameter is set to EGL_SYNC_REUSABLE_KHR
  1.1175 +2.	Launch two threads A and B.
  1.1176 +3.	Wait on the sync objects S1 and S2 from threads A and B respectively by calling eglClientWaitSyncKHR()  with timeout set to EGL_FOREVER_KHR.
  1.1177 +4.	Signal on S1 with the flag EGL_SIGNALED_KHR from main thread
  1.1178 +5.	Retrieve EGL_SYNC_STATUS attribute of S1 and S2 from main thread
  1.1179 +6.	Signal on S2 with the flag EGL_SIGNALED_KHR from main thread
  1.1180 +7.	Retrieve EGL_SYNC_STATUS attribute of S1 and S2 from main thread
  1.1181 +8.	Destroy the sync objects
  1.1182 +
  1.1183 +@SYMTestExpectedResults
  1.1184 +3. Threads A and B will be stalled
  1.1185 +4. Thread A will be unblocked and an error code returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR.
  1.1186 +   Thread B stays blocked.  
  1.1187 +5. The S1 attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR, S2 attribute EGL_SYNC_STATUS is set to EGL_UNSIGNALED_KHR
  1.1188 +6. Thread B will be unblocked and an error code returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR.
  1.1189 +7. The S1 & S2 attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR
  1.1190 +*/
  1.1191 +TVerdict CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doTestStepL()
  1.1192 +	{
  1.1193 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-050"));
  1.1194 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doTestStepL started...."));
  1.1195 +
  1.1196 +	if(!iIsSyncObjectExtensionSupported)
  1.1197 +		{
  1.1198 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.1199 +		CleanAll();
  1.1200 +		RecordTestResultL();
  1.1201 +		CloseTMSGraphicsStep();
  1.1202 +		return TestStepResult();
  1.1203 +		}
  1.1204 +
  1.1205 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.1206 +	GetDisplayL();
  1.1207 +	CreateEglSessionL();
  1.1208 +	iEglSess->InitializeL();
  1.1209 +
  1.1210 +	INFO_PRINTF1(_L("Create two sync objects"));
  1.1211 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1212 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.1213 +	iSyncObject2 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1214 +	TESTL(iSyncObject2 != EGL_NO_SYNC_KHR);
  1.1215 +
  1.1216 +	INFO_PRINTF1(_L("Launching threads A and B..."));
  1.1217 +	Test_MultiThreadL(2, EFalse);
  1.1218 +	TUint32 timeOverheadStart = User::NTickCount();
  1.1219 +	
  1.1220 +	INFO_PRINTF1(_L("Main thread, wait for a bit before Signal sync object number 1"));
  1.1221 +	User::After(iDelaySignalling);
  1.1222 +	EGLBoolean 	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
  1.1223 +	TEST(resSignal == EGL_TRUE);
  1.1224 +	INFO_PRINTF1(_L("Main thread Signal sync object number 1 done"));
  1.1225 +
  1.1226 +	INFO_PRINTF1(_L("Check attributes for sync object number 1..."));
  1.1227 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
  1.1228 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
  1.1229 +
  1.1230 +	INFO_PRINTF1(_L("Check attributes for sync object number 2..."));
  1.1231 +	// the CheckSyncAttrib uses iSyncObject, so we need to replace it, and restore it later
  1.1232 +	EGLSyncKHR oldSyncObject=iSyncObject;
  1.1233 +	iSyncObject=iSyncObject2;
  1.1234 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR, EGL_SYNC_REUSABLE_KHR);
  1.1235 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
  1.1236 +	iSyncObject=oldSyncObject;
  1.1237 +
  1.1238 +	INFO_PRINTF1(_L("Main thread, wait for a bit before Signal sync object number 2"));
  1.1239 +	User::After(iDelaySignalling);
  1.1240 +	
  1.1241 +	TUint32 timeOverheadEnd = User::NTickCount();
  1.1242 +	iTimeOverhead = ElapsedTime(timeOverheadEnd, timeOverheadStart) - iDelaySignalling*2;
  1.1243 +	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject2, EGL_SIGNALED_KHR);
  1.1244 +	TEST(resSignal == EGL_TRUE);
  1.1245 +	INFO_PRINTF1(_L("Main thread Signal sync object number 2 done"));
  1.1246 +
  1.1247 +	INFO_PRINTF1(_L("Check attributes for sync object number 1..."));
  1.1248 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
  1.1249 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
  1.1250 +
  1.1251 +	INFO_PRINTF1(_L("Check attributes for sync object number 2..."));
  1.1252 +	oldSyncObject=iSyncObject;
  1.1253 +	iSyncObject=iSyncObject2;
  1.1254 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
  1.1255 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
  1.1256 +	iSyncObject=oldSyncObject;
  1.1257 +
  1.1258 +	INFO_PRINTF1(_L("Delete both sync objects"));
  1.1259 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.1260 +	TEST(res == EGL_TRUE);
  1.1261 +	res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject2);
  1.1262 +	TEST(res == EGL_TRUE);
  1.1263 +
  1.1264 +	CleanAll();
  1.1265 +	RecordTestResultL();
  1.1266 +	CloseTMSGraphicsStep();
  1.1267 +	INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doTestStepL completed!"));
  1.1268 +	return TestStepResult();
  1.1269 +	}
  1.1270 +
  1.1271 +void CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doThreadFunctionL(TInt aIdx)
  1.1272 +	{
  1.1273 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doThreadFunctionL, Thread %d"),aIdx);
  1.1274 +	ASSERT_TRUE(aIdx==0 || aIdx==1);
  1.1275 +
  1.1276 +	//Thread 0 waits for the main thread to signal the sync object, and exits
  1.1277 +	if(aIdx == 0)	
  1.1278 +		{
  1.1279 +		INFO_PRINTF2(_L("Thread %d waiting for main thread to signal object 1 with a timeout EGL_FOREVER_KHR"), aIdx);
  1.1280 +		TUint32 timestampBefore = User::NTickCount();
  1.1281 +		EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.1282 +		TUint32 timestampAfter = User::NTickCount();
  1.1283 +		TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1284 +
  1.1285 +		INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was signaled (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
  1.1286 +		TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1287 +		TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1288 +		}
  1.1289 +	//Thread 1 waits for the main thread to signal the sync object, and exits
  1.1290 +	else if(aIdx == 1)	
  1.1291 +		{
  1.1292 +		INFO_PRINTF2(_L("Thread %d waiting for main thread to signal object 2 with a timeout EGL_FOREVER_KHR"), aIdx);
  1.1293 +		TUint32 timestampBefore = User::NTickCount();
  1.1294 +		EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject2,0,EGL_FOREVER_KHR);
  1.1295 +		TUint32 timestampAfter = User::NTickCount();
  1.1296 +		TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1297 +
  1.1298 +		INFO_PRINTF6(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was signaled (threshold was [%d + %d +- %d])"), aIdx, timeElapsed, 2*iDelaySignalling, iTimeOverhead, iThreshold);
  1.1299 +		TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1300 +		TEST (Abs(timeElapsed - (2*iDelaySignalling + iTimeOverhead)) < iThreshold);
  1.1301 +		}
  1.1302 +	}
  1.1303 +
  1.1304 +/**
  1.1305 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-055
  1.1306 +
  1.1307 +@SYMTestPriority 1
  1.1308 +
  1.1309 +@SYMPREQ 2400
  1.1310 +
  1.1311 +@SYMREQ 12326
  1.1312 +
  1.1313 +@SYMTestCaseDesc
  1.1314 +To check that if zero timeout is passed to eglClientWaitSyncKHR(), the function just test the current status without attempt to stall the client thread.
  1.1315 +
  1.1316 +@SYMTestActions
  1.1317 +1.	Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
  1.1318 +    The type parameter is set to EGL_SYNC_REUSABLE_KHR
  1.1319 +2.	Take timestamp before
  1.1320 +3.	Call eglClientWaitSyncKHR() on the sync object with timeout value equals to zero
  1.1321 +4.	Take timestamp after
  1.1322 +5.	Call eglSignalSyncKHR on the sync object with the flag EGL_SIGNALED_KHR
  1.1323 +6.	Repeat steps 2 to 4
  1.1324 +7.	Destroy the sync object
  1.1325 +
  1.1326 +@SYMTestExpectedResults
  1.1327 +3.  The client thread is not stalled.  The function eglClientWaitSyncKHR() should return EGL_TIMEOUT_EXPIRED_KHR. 
  1.1328 +4.  The difference timestamp (after - before) should be less than a half second
  1.1329 +3.1 The client thread is not stalled.  The function eglClientWaitSyncKHR() should return EGL_CONDITION_SATISFIED_KHR.    
  1.1330 +4.1 The difference timestamp (after - before) should be less than a half second 
  1.1331 +*/
  1.1332 +TVerdict CEglTest_SyncObject_Positive_Wait_TestMode::doTestStepL()
  1.1333 +	{
  1.1334 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-055"));
  1.1335 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Wait_TestMode::doTestStepL started...."));
  1.1336 +
  1.1337 +	if(!iIsSyncObjectExtensionSupported)
  1.1338 +		{
  1.1339 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.1340 +		CleanAll();
  1.1341 +		RecordTestResultL();
  1.1342 +		CloseTMSGraphicsStep();
  1.1343 +		return TestStepResult();
  1.1344 +		}
  1.1345 +
  1.1346 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.1347 +	GetDisplayL();
  1.1348 +	CreateEglSessionL();
  1.1349 +	iEglSess->InitializeL();
  1.1350 +
  1.1351 +	INFO_PRINTF1(_L("Create sync object"));
  1.1352 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1353 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.1354 +
  1.1355 +	// calling wait sync without signaling the object, but with timeout set to 0 ==> no stalling
  1.1356 +	INFO_PRINTF1(_L("Calling eglClientWaitSyncKHR on the object, without signaling the object, but with timeout set to 0"));
  1.1357 +	TUint32 timestampBefore = User::NTickCount();
  1.1358 +	EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,0);
  1.1359 +	TUint32 timestampAfter = User::NTickCount();
  1.1360 +	TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1361 +
  1.1362 +	INFO_PRINTF3(_L("Check it didn't wait on eglClientWaitSyncKHR. Elapsed time was %d usec (threshold was [%d])"),timeElapsed, iThreshold);
  1.1363 +	TEST(resClientWait == EGL_TIMEOUT_EXPIRED_KHR);
  1.1364 +	TEST (timeElapsed < iThreshold);
  1.1365 +
  1.1366 +	INFO_PRINTF1(_L("Check attributes..."));
  1.1367 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
  1.1368 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
  1.1369 +	
  1.1370 +	INFO_PRINTF1(_L("Signal sync object"));
  1.1371 +	EGLBoolean 	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
  1.1372 +	TEST(resSignal == EGL_TRUE);
  1.1373 +
  1.1374 +	INFO_PRINTF1(_L("Repeat same step,  calling eglClientWaitSyncKHR with timeout set to 0"));
  1.1375 +	timestampBefore = User::NTickCount();
  1.1376 +	resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,0);
  1.1377 +	timestampAfter = User::NTickCount();
  1.1378 +	timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1379 +
  1.1380 +	INFO_PRINTF3(_L("Check it didn't wait on eglClientWaitSyncKHR. Elapsed time was %d usec (threshold was [%d])"),timeElapsed, iThreshold);
  1.1381 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1382 +	TEST (timeElapsed < iThreshold);
  1.1383 +
  1.1384 +	INFO_PRINTF1(_L("Check attributes..."));
  1.1385 +	CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
  1.1386 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
  1.1387 +
  1.1388 +	INFO_PRINTF1(_L("Delete sync object"));
  1.1389 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.1390 +	TEST(res == EGL_TRUE);
  1.1391 +
  1.1392 +	CleanAll();
  1.1393 +	RecordTestResultL();
  1.1394 +	CloseTMSGraphicsStep();
  1.1395 +	INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Wait_TestMode::doTestStepL completed!"));
  1.1396 +	return TestStepResult();
  1.1397 +	}
  1.1398 +
  1.1399 +/**
  1.1400 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-060
  1.1401 +
  1.1402 +@SYMTestPriority 1
  1.1403 +
  1.1404 +@SYMPREQ 2400
  1.1405 +
  1.1406 +@SYMREQ 12326
  1.1407 +
  1.1408 +@SYMTestCaseDesc
  1.1409 +To check that deletion of the sync object will unblock all threads waiting for the signal.
  1.1410 +
  1.1411 +@SYMTestActions
  1.1412 +1.	Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
  1.1413 +    The type parameter is set to EGL_SYNC_REUSABLE_KHR
  1.1414 +2.	Launch threads A and B
  1.1415 +3.	Call eglClientWaitSyncKHR() on the sync object in main thread and thread A.
  1.1416 +4.	Destroy the sync object from thread B
  1.1417 +
  1.1418 +@SYMTestExpectedResults
  1.1419 +3. Main thread and thread A will be stalled
  1.1420 +4. All client threads which waited for the signal must be unblocked as if eglSignalSyncKHR() has been called. 
  1.1421 +   The function eglClientWaitSyncKHR should return EGL_CONDITION_SATISFIED_KHR
  1.1422 +*/
  1.1423 +TVerdict CEglTest_SyncObject_Positive_Multithread_Deletion::doTestStepL()
  1.1424 +	{
  1.1425 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-060"));
  1.1426 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Multithread_Deletion::doTestStepL started...."));
  1.1427 +
  1.1428 +	if(!iIsSyncObjectExtensionSupported)
  1.1429 +		{
  1.1430 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.1431 +		CleanAll();
  1.1432 +		RecordTestResultL();
  1.1433 +		CloseTMSGraphicsStep();
  1.1434 +		return TestStepResult();
  1.1435 +		}
  1.1436 +
  1.1437 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.1438 +	GetDisplayL();
  1.1439 +	CreateEglSessionL();
  1.1440 +	iEglSess->InitializeL();
  1.1441 +	
  1.1442 +	INFO_PRINTF1(_L("Create sync object"));
  1.1443 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1444 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.1445 +
  1.1446 +	INFO_PRINTF1(_L("Launching threads A and B..."));
  1.1447 +	Test_MultiThreadL(2, EFalse);
  1.1448 +
  1.1449 +	INFO_PRINTF1(_L("Main thread waiting for thread B to destroy the sync object, with timeout EGL_FOREVER_KHR"));
  1.1450 +	TUint32 timestampBefore = User::NTickCount();
  1.1451 +	EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.1452 +	TUint32 timestampAfter = User::NTickCount();
  1.1453 +	TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1454 +
  1.1455 +	INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec before sync object was deleted (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
  1.1456 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1457 +	TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1458 +
  1.1459 +	INFO_PRINTF1(_L("Check attributes..."));
  1.1460 +	EGLint syncTypeValue=-1;
  1.1461 +	EGLBoolean ret = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject,EGL_SYNC_TYPE_KHR,&syncTypeValue);
  1.1462 +	TEST(ret == EGL_FALSE);
  1.1463 +	EGLint error = eglGetError();
  1.1464 +	TEST(error == EGL_BAD_PARAMETER);
  1.1465 +	TEST(syncTypeValue == -1); // due to the error, it wasn't properly retrieved
  1.1466 +
  1.1467 +	INFO_PRINTF1(_L("(attempt to) Delete sync object (was already deleted by a worker thread)"));
  1.1468 +	ret = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.1469 +	TEST(ret == EGL_FALSE);
  1.1470 +	error = eglGetError();
  1.1471 +	TEST(error == EGL_BAD_PARAMETER);
  1.1472 +
  1.1473 +	CleanAll();
  1.1474 +	RecordTestResultL();
  1.1475 +	CloseTMSGraphicsStep();
  1.1476 +	INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Multithread_Deletion::doTestStepL completed!"));
  1.1477 +	return TestStepResult();
  1.1478 +	}
  1.1479 +
  1.1480 +void CEglTest_SyncObject_Positive_Multithread_Deletion::doThreadFunctionL(TInt aIdx)
  1.1481 +	{
  1.1482 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Multithread_Deletion::doThreadFunctionL, Thread %d"),aIdx);
  1.1483 +	ASSERT_TRUE(aIdx==0 || aIdx==1);
  1.1484 +
  1.1485 +	//Thread 0 waits for a the thread B to delete the sync object, and exits
  1.1486 +	if(aIdx == 0)	
  1.1487 +		{
  1.1488 +		INFO_PRINTF2(_L("Thread %d waiting for thread B to destroy the sync object, with timeout EGL_FOREVER_KHR"), aIdx);
  1.1489 +		TUint32 timestampBefore = User::NTickCount();
  1.1490 +		EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.1491 +		TUint32 timestampAfter = User::NTickCount();
  1.1492 +		TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1493 +
  1.1494 +		INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was deleted (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
  1.1495 +		TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1496 +		TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1497 +		}
  1.1498 +	//Thread 1 waits for a certain amount of time, deletes the sync object and exits
  1.1499 +	else if(aIdx == 1)	
  1.1500 +		{
  1.1501 +		INFO_PRINTF2(_L("Wait for a bit before destroying sync object, Thread %d"),aIdx);
  1.1502 +		User::After(iDelaySignalling);
  1.1503 +		TInt res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.1504 +		TEST(res == EGL_TRUE);
  1.1505 +		INFO_PRINTF2(_L("Delete sync object done, Thread %d"),aIdx);
  1.1506 +		//This Thread now will just exit
  1.1507 +		}
  1.1508 +	}
  1.1509 +
  1.1510 +/**
  1.1511 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-065
  1.1512 +
  1.1513 +@SYMTestPriority 1
  1.1514 +
  1.1515 +@SYMPREQ 2400
  1.1516 +
  1.1517 +@SYMREQ 12326
  1.1518 +
  1.1519 +@SYMTestCaseDesc
  1.1520 +To exercise sync object functionality in stress conditions.
  1.1521 +
  1.1522 +@SYMTestActions
  1.1523 +1. Create three sync objects (S1, S2, S3) for the default display with no attributes are specified (containing only EGL_NONE). 
  1.1524 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR.
  1.1525 +2. Launch 2 threads (A and B)
  1.1526 +3. Make the threads A and B waiting on sync objects S2 and S3 respectively.
  1.1527 +4. Make consequential signalling in that order: Client-> A->B->Client->... for some period of time. 
  1.1528 +   Each thread signals the next thread in the chain and then stalls itself on the corresponding sync object. 
  1.1529 +   (Whenever each thread is unstalled, corresponding sync object should be reset by unsignalling it.)
  1.1530 +   Main thread is waiting on S1 
  1.1531 +5. When the number of iteration exceeds some predefined value (by default is 1000, but could be reconfigured in ini file) the sequence, defined in step 4 will stop executing
  1.1532 +6. Delete the sync objects
  1.1533 +
  1.1534 +@SYMTestExpectedResults
  1.1535 +4. The functionality is robust, transition from "unsignaled" to "signaled" 
  1.1536 +state always unblocks the threads  
  1.1537 +*/
  1.1538 +TVerdict CEglTest_SyncObject_Positive_Stress::doTestStepL()
  1.1539 +	{
  1.1540 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-065"));
  1.1541 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Stress::doTestStepL"));
  1.1542 +	
  1.1543 +	if(!iIsSyncObjectExtensionSupported)
  1.1544 +		{
  1.1545 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.1546 +		CleanAll();
  1.1547 +		RecordTestResultL();
  1.1548 +		CloseTMSGraphicsStep();
  1.1549 +		return TestStepResult();
  1.1550 +		}
  1.1551 +
  1.1552 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.1553 +	GetDisplayL();
  1.1554 +	CreateEglSessionL();
  1.1555 +	iEglSess->InitializeL();
  1.1556 +	
  1.1557 +	INFO_PRINTF1(_L("Create sync objects"));
  1.1558 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1559 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.1560 +	iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1561 +	TESTL(iSyncObject1 != EGL_NO_SYNC_KHR);
  1.1562 +	iSyncObject2 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1563 +	TESTL(iSyncObject2 != EGL_NO_SYNC_KHR);
  1.1564 +	
  1.1565 +	iLastThreadToSignal = 2;
  1.1566 +	
  1.1567 +	//launch threadA & threadB
  1.1568 +	Test_MultiThreadL(2, EFalse);
  1.1569 +	User::After(iDelaySignalling); //to allow threads start up before we signal
  1.1570 +	
  1.1571 +	for(TInt index = 0; index < iNumStressIterations; index++)
  1.1572 +		{
  1.1573 +		iLastThreadToSignal = 2;
  1.1574 +		EGLBoolean 	resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject1,EGL_SIGNALED_KHR );
  1.1575 +		TEST(resSignal == EGL_TRUE);
  1.1576 +		
  1.1577 +		EGLint res = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.1578 +		TEST(iLastThreadToSignal == 1);
  1.1579 +		TEST(res == EGL_CONDITION_SATISFIED_KHR);
  1.1580 +		resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_UNSIGNALED_KHR );//to set the status of iSyncObject EGL_UNSIGNALED_KHR
  1.1581 +		TEST(resSignal == EGL_TRUE);    	
  1.1582 +		User::After(0);//to yield the processor 
  1.1583 +		}
  1.1584 +	iStopTest = ETrue;
  1.1585 +	INFO_PRINTF2(_L("Threads have been signalling for %d times"), iNumStressIterations);
  1.1586 +	INFO_PRINTF1(_L("Delete sync objects"));
  1.1587 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.1588 +	TEST(res == EGL_TRUE);
  1.1589 +	res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject1);
  1.1590 +	TEST(res == EGL_TRUE);
  1.1591 +	res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject2);
  1.1592 +	TEST(res == EGL_TRUE);
  1.1593 +	
  1.1594 +	CleanAll();
  1.1595 +	RecordTestResultL();
  1.1596 +	CloseTMSGraphicsStep();
  1.1597 +	INFO_PRINTF1(_L("End of CEglTest_SyncObject_Positive_Stress::doTestStepL"));
  1.1598 +	return TestStepResult();
  1.1599 +	}
  1.1600 +
  1.1601 +void CEglTest_SyncObject_Positive_Stress::doThreadFunctionL(TInt aIdx)
  1.1602 +	{
  1.1603 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Stress::doThreadFunctionL, Thread %d"),aIdx);
  1.1604 +	ASSERT_TRUE(aIdx==0 || aIdx==1);
  1.1605 +	
  1.1606 +	EGLint res;
  1.1607 +	if(aIdx == 0)
  1.1608 +		{
  1.1609 +		while(!iStopTest)
  1.1610 +			{
  1.1611 +			res = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject1,0,EGL_FOREVER_KHR);
  1.1612 +			TEST(res == EGL_CONDITION_SATISFIED_KHR);
  1.1613 +			User::After(0); //to yield the processor 
  1.1614 +			if(!iStopTest)
  1.1615 +				{
  1.1616 +				TEST(iLastThreadToSignal == 2);
  1.1617 +				EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject1,EGL_UNSIGNALED_KHR );//to reset the status of iSyncObject1 EGL_UNSIGNALED_KHR
  1.1618 +                TEST(resSignal == EGL_TRUE);
  1.1619 +                
  1.1620 +				iLastThreadToSignal = 0;
  1.1621 +				resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject2,EGL_SIGNALED_KHR );
  1.1622 +				TEST(resSignal == EGL_TRUE);
  1.1623 +				}
  1.1624 +			}
  1.1625 +		}
  1.1626 +	else if(aIdx == 1)
  1.1627 +		{
  1.1628 +		while(!iStopTest)
  1.1629 +			{
  1.1630 +			res = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject2,0,EGL_FOREVER_KHR);
  1.1631 +			TEST(res == EGL_CONDITION_SATISFIED_KHR);
  1.1632 +			User::After(0); //to yield the processor  
  1.1633 +			if(!iStopTest)
  1.1634 +				{
  1.1635 +				TEST(iLastThreadToSignal == 0);
  1.1636 +	            EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject2,EGL_UNSIGNALED_KHR );//to reset the status of iSyncObject2 EGL_UNSIGNALED_KHR
  1.1637 +	            TEST(resSignal == EGL_TRUE); 
  1.1638 +				
  1.1639 +				iLastThreadToSignal = 1;
  1.1640 +				resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_SIGNALED_KHR );
  1.1641 +				TEST(resSignal == EGL_TRUE);
  1.1642 +				}
  1.1643 +			}
  1.1644 +		}
  1.1645 +	}
  1.1646 +
  1.1647 +/**
  1.1648 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-070
  1.1649 +
  1.1650 +@SYMTestPriority 1
  1.1651 +
  1.1652 +@SYMPREQ 2400
  1.1653 +
  1.1654 +@SYMREQ 12326
  1.1655 +
  1.1656 +@SYMTestCaseDesc
  1.1657 +To check that flushing of the client API (bit EGL_SYNC_FLUSH_COMMANDS_BIT_KHR is set 
  1.1658 +for eglClientWaitSyncKHR()) doesn't cause any problems.
  1.1659 +
  1.1660 +@SYMTestActions
  1.1661 +1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
  1.1662 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR
  1.1663 +2. Bind Open VG API.
  1.1664 +3. Create and make the context current for the bound API.
  1.1665 +4. Launch the thread A.
  1.1666 +5. Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag.
  1.1667 +6. Signal "EGL_UNSIGNALED_KHR" to the sync object.
  1.1668 +7. Bind Open GLES API.
  1.1669 +8. Repeat steps 3-6.
  1.1670 +9. Repeat step 5, but client waits in test mode (timeout is set to zero)
  1.1671 +10. Make no context current
  1.1672 +11. Repeat steps 3-5.
  1.1673 +12. Delete the sync object.
  1.1674 +
  1.1675 +@SYMTestExpectedResults
  1.1676 +All functions succeed. Setting the flag on step 5 doesn't cause any problem.
  1.1677 +9. The function eglClientWaitSyncKHR()returns  EGL_TIMEOUT_EXPIRED_KHR 
  1.1678 +*/
  1.1679 +TVerdict CEglTest_SyncObject_Positive_WaitFlush::doTestStepL()
  1.1680 +	{
  1.1681 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-070"));
  1.1682 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitFlush::doTestStepL"));
  1.1683 +	
  1.1684 +	if(!iIsSyncObjectExtensionSupported)
  1.1685 +		{
  1.1686 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.1687 +		CleanAll();
  1.1688 +		RecordTestResultL();
  1.1689 +		CloseTMSGraphicsStep();
  1.1690 +		return TestStepResult();
  1.1691 +		}
  1.1692 +
  1.1693 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.1694 +	GetDisplayL();
  1.1695 +	CreateEglSessionL();
  1.1696 +	iEglSess->InitializeL();
  1.1697 +	
  1.1698 +	INFO_PRINTF1(_L("Create sync object"));
  1.1699 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1700 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.1701 +
  1.1702 +	INFO_PRINTF1(_L("bind OpenVG API"));
  1.1703 +	ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
  1.1704 +	EGLConfig currentConfig = iEglSess->GetConfigExactMatchL(EPixmapAttribsColor64K);
  1.1705 +	INFO_PRINTF1(_L("Create and make the context current for the bound  API"));
  1.1706 +	EGLContext context = eglCreateContext(iDisplay, currentConfig, EGL_NO_CONTEXT, NULL);
  1.1707 +	ASSERT_EGL_TRUE(context != EGL_NO_CONTEXT);
  1.1708 +	
  1.1709 +	//Create an OffScreen Pixmap to be used as an OpenVg target
  1.1710 +	TSgImageInfoTest imageInfo = TSgImageInfoTest();
  1.1711 +	imageInfo.iSizeInPixels = TSize(200, 200);
  1.1712 +	imageInfo.iPixelFormat = EUidPixelFormatRGB_565;
  1.1713 +#ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
  1.1714 +	imageInfo.iUsage = ESgUsageBitOpenVgSurface;
  1.1715 +#else
  1.1716 +    imageInfo.iUsage = ESgUsageOpenVgTarget;
  1.1717 +#endif	
  1.1718 +	RSgImage sgImageTarget;
  1.1719 +	CleanupClosePushL(sgImageTarget);
  1.1720 +	TInt ret2 = sgImageTarget.Create(imageInfo, NULL, NULL);
  1.1721 +	ASSERT_EQUALS(ret2, KErrNone);
  1.1722 +	EGLSurface surface = eglCreatePixmapSurface(iDisplay, currentConfig,&sgImageTarget, KPixmapAttribsNone );
  1.1723 +	ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
  1.1724 +	
  1.1725 +	TSurfaceToDestroy surfaceToDestroy;
  1.1726 +	surfaceToDestroy.iSurface = surface;
  1.1727 +	surfaceToDestroy.iDisplay = iDisplay;
  1.1728 +	CleanupStack::PushL(TCleanupItem(DestroySurface, &surfaceToDestroy));
  1.1729 +
  1.1730 +	INFO_PRINTF1(_L("Calling eglMakeCurrent"));
  1.1731 +	ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context));
  1.1732 +
  1.1733 +	//launch threadA
  1.1734 +	Test_MultiThreadL(1, EFalse);
  1.1735 +	INFO_PRINTF1(_L("Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag"));
  1.1736 +	TUint32 timestampBefore = User::NTickCount();
  1.1737 +	EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,EGL_FOREVER_KHR);
  1.1738 +	TUint32 timestampAfter = User::NTickCount();
  1.1739 +	TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1740 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1741 +	TEST(Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1742 +	EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_UNSIGNALED_KHR);
  1.1743 +	TEST(resSignal == EGL_TRUE); 
  1.1744 +	
  1.1745 +	//make no context current
  1.1746 +	ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
  1.1747 +	
  1.1748 +	//Wait for the thread to finish before starting the next part of the test.
  1.1749 +	Test_MultiThread_WaitL(ETrue, TThreadStatus::ELogin);
  1.1750 +	
  1.1751 +	//---- the same test but for OpenGLES	
  1.1752 +	INFO_PRINTF1(_L("bind OpenGLES API"));
  1.1753 +	ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENGL_ES_API));
  1.1754 +	EGLContext context1 = eglCreateContext(iDisplay, currentConfig, EGL_NO_CONTEXT, NULL);
  1.1755 +	ASSERT_EGL_TRUE(context1 != EGL_NO_CONTEXT);
  1.1756 +	
  1.1757 +	INFO_PRINTF1(_L("Calling eglMakeCurrent"));
  1.1758 +	ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context1));
  1.1759 +	
  1.1760 +	//launch threadA
  1.1761 +	Test_MultiThreadL(1, EFalse);
  1.1762 +	INFO_PRINTF1(_L("Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag"));
  1.1763 +	timestampBefore = User::NTickCount();
  1.1764 +	resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,EGL_FOREVER_KHR);
  1.1765 +	timestampAfter = User::NTickCount();
  1.1766 +	timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1767 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1768 +	TEST(Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1769 +	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_UNSIGNALED_KHR);
  1.1770 +	TEST(resSignal == EGL_TRUE);
  1.1771 +	
  1.1772 +	//repeat the same, but in test mode (timeout  is set to zero)
  1.1773 +	INFO_PRINTF1(_L("Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag"));
  1.1774 +	timestampBefore = User::NTickCount();
  1.1775 +	resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,0);
  1.1776 +	timestampAfter = User::NTickCount();
  1.1777 +	timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1778 +	TEST(resClientWait == EGL_TIMEOUT_EXPIRED_KHR);//the sync object is in "unsignaled" state
  1.1779 +	TEST(timeElapsed < iThreshold);
  1.1780 +	resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_UNSIGNALED_KHR);
  1.1781 +	TEST(resSignal == EGL_TRUE);
  1.1782 +	
  1.1783 +	INFO_PRINTF1(_L("Make no context current"));
  1.1784 +	ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
  1.1785 +	
  1.1786 +	//Wait for the thread to finish before starting the next part of the test.
  1.1787 +	Test_MultiThread_WaitL(ETrue, TThreadStatus::ELogin);
  1.1788 +	
  1.1789 +	//now try to wait with flushing bit on (EGL_SYNC_FLUSH_COMMANDS_BIT_KHR). The flag will be ignored
  1.1790 +	//launch threadA
  1.1791 +	Test_MultiThreadL(1, EFalse);
  1.1792 +	
  1.1793 +	INFO_PRINTF1(_L("Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag, when no context is current"));
  1.1794 +	timestampBefore = User::NTickCount();
  1.1795 +	resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,EGL_FOREVER_KHR);
  1.1796 +	timestampAfter = User::NTickCount();
  1.1797 +	timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1798 +	TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1799 +	TEST(Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1800 +	
  1.1801 +	eglDestroyContext(iDisplay, context1);		//Closing eglContext
  1.1802 +	eglDestroyContext(iDisplay, context);		//Closing eglContext
  1.1803 +	CleanupStack::PopAndDestroy(2, &sgImageTarget);
  1.1804 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.1805 +	TEST(res == EGL_TRUE);
  1.1806 +	
  1.1807 +	CleanAll();
  1.1808 +	RecordTestResultL();
  1.1809 +	CloseTMSGraphicsStep();
  1.1810 +	INFO_PRINTF1(_L("End of CEglTest_SyncObject_Positive_WaitFlush::doTestStepL"));
  1.1811 +	return TestStepResult();
  1.1812 +	}
  1.1813 +
  1.1814 +void CEglTest_SyncObject_Positive_WaitFlush::doThreadFunctionL(TInt aIdx)
  1.1815 +	{
  1.1816 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_WaitFlush::doThreadFunctionL, Thread %d"),aIdx);
  1.1817 +	ASSERT_TRUE(aIdx==0);
  1.1818 +
  1.1819 +	User::After(TTimeIntervalMicroSeconds32(iDelaySignalling));
  1.1820 +	EGLBoolean res = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
  1.1821 +	TEST(res == EGL_TRUE); 
  1.1822 +	}
  1.1823 +
  1.1824 +/**
  1.1825 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-075
  1.1826 +
  1.1827 +@SYMTestPriority 1
  1.1828 +
  1.1829 +@SYMPREQ 2400
  1.1830 +
  1.1831 +@SYMREQ 12326
  1.1832 +
  1.1833 +@SYMTestCaseDesc
  1.1834 +To check that eglTerminate() destroys sync object associated with display.
  1.1835 +
  1.1836 +@SYMTestActions
  1.1837 +1. Create sync object for the default display. NULL are specified in attribute_list. 
  1.1838 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR.
  1.1839 +2. Call eglTerminate() without deleting the sync objects.
  1.1840 +
  1.1841 +@SYMTestExpectedResults
  1.1842 +1. Sync object handle doesn't equal to EGL_NO_SYNC_KHR.
  1.1843 +2. Test completes without any error and panic. No memory leak.
  1.1844 +*/
  1.1845 +
  1.1846 +TVerdict CEglTest_SyncObject_Positive_Terminate::doTestStepL()
  1.1847 +    {
  1.1848 +    SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-075"));
  1.1849 +    INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Terminate::doTestStepL"));
  1.1850 +    
  1.1851 +    if(!iIsSyncObjectExtensionSupported)
  1.1852 +        {
  1.1853 +        INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.1854 +        CleanAll();
  1.1855 +        RecordTestResultL();
  1.1856 +        CloseTMSGraphicsStep();
  1.1857 +        return TestStepResult();
  1.1858 +        }
  1.1859 +        
  1.1860 +    ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.1861 +    GetDisplayL();
  1.1862 +    CreateEglSessionL();
  1.1863 +	iEglSess->InitializeL();
  1.1864 +    
  1.1865 +    INFO_PRINTF1(_L("Create sync object - default display, NULL at attributes, type parameter set to EGL_SYNC_REUSABLE_KHR"));
  1.1866 +    iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, NULL);
  1.1867 +    TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.1868 +    
  1.1869 +    //check attributes of the sync object.
  1.1870 +    INFO_PRINTF1(_L("Check attributes of sync object"));    
  1.1871 +    CheckSyncAttrib(EGL_SYNC_TYPE_KHR, EGL_SYNC_REUSABLE_KHR);
  1.1872 +    CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR);
  1.1873 +    
  1.1874 +    TRAPD(result, TerminateDisplayL());
  1.1875 +    TEST(result == KErrNone);
  1.1876 +    
  1.1877 +    CleanAll();
  1.1878 +    RecordTestResultL();
  1.1879 +    CloseTMSGraphicsStep();
  1.1880 +    return TestStepResult();
  1.1881 +    }
  1.1882 +
  1.1883 +/**
  1.1884 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-080
  1.1885 +
  1.1886 +@SYMTestPriority 1
  1.1887 +
  1.1888 +@SYMPREQ 2400
  1.1889 +
  1.1890 +@SYMREQ 12326
  1.1891 +
  1.1892 +@SYMTestCaseDesc
  1.1893 +To check that eglTerminate() destroys sync object and will unblock thread waiting for the signal.
  1.1894 +
  1.1895 +@SYMTestActions
  1.1896 +1.  Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
  1.1897 +    The type parameter is set to EGL_SYNC_REUSABLE_KHR
  1.1898 +2.  Launch thread A
  1.1899 +3.  Call eglClientWaitSyncKHR() on the sync object in thread A.
  1.1900 +4.  Call eglTerminate() from main thread without deleting the sync object.
  1.1901 +
  1.1902 +@SYMTestExpectedResults
  1.1903 +1. Sync object handle doesn't equal to EGL_NO_SYNC_KHR.
  1.1904 +3. Thread A will be stalled
  1.1905 +4. Thread A which waited for the signal must be unblocked as if eglSignalSyncKHR() has been called. 
  1.1906 +   The function eglClientWaitSyncKHR should return EGL_CONDITION_SATISFIED_KHR.
  1.1907 +   Test completes without any error and panic. No memory leak.
  1.1908 +*/
  1.1909 +
  1.1910 +TVerdict CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doTestStepL()
  1.1911 +    {
  1.1912 +    SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-080"));
  1.1913 +    INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doTestStepL started...."));
  1.1914 +
  1.1915 +    if(!iIsSyncObjectExtensionSupported)
  1.1916 +        {
  1.1917 +        INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.1918 +        CleanAll();
  1.1919 +        RecordTestResultL();
  1.1920 +        CloseTMSGraphicsStep();
  1.1921 +        return TestStepResult();
  1.1922 +        }
  1.1923 +
  1.1924 +    ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.1925 +    GetDisplayL();
  1.1926 +    CreateEglSessionL();
  1.1927 +	iEglSess->InitializeL();
  1.1928 +    
  1.1929 +    INFO_PRINTF1(_L("Create sync object"));
  1.1930 +    iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.1931 +    TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.1932 +
  1.1933 +    INFO_PRINTF1(_L("Launching threads A"));
  1.1934 +    Test_MultiThreadL(1, EFalse);
  1.1935 +
  1.1936 +    INFO_PRINTF1(_L("Wait for a bit before eglTerminate"));
  1.1937 +    User::After(iDelaySignalling);
  1.1938 +
  1.1939 +    TRAPD(result, TerminateDisplayL());
  1.1940 +    TEST(result == KErrNone);
  1.1941 +    
  1.1942 +    CleanAll();
  1.1943 +    RecordTestResultL();
  1.1944 +    CloseTMSGraphicsStep();
  1.1945 +    INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doTestStepL completed!"));
  1.1946 +    return TestStepResult();
  1.1947 +    }
  1.1948 +
  1.1949 +void CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doThreadFunctionL(TInt aIdx)
  1.1950 +    {
  1.1951 +    INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doThreadFunctionL, Thread %d"),aIdx);
  1.1952 +    ASSERT_TRUE(aIdx==0);
  1.1953 +
  1.1954 +    INFO_PRINTF2(_L("Thread %d waiting for main thread to call eglTerminate(), with timeout EGL_FOREVER_KHR"), aIdx);
  1.1955 +    TUint32 timestampBefore = User::NTickCount();
  1.1956 +    EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.1957 +    TUint32 timestampAfter = User::NTickCount();
  1.1958 +    TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.1959 +
  1.1960 +    INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was destroyed by eglTerminate() (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
  1.1961 +    TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
  1.1962 +    TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.1963 +    }
  1.1964 +
  1.1965 +/**
  1.1966 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-100
  1.1967 +
  1.1968 +@SYMTestPriority 1
  1.1969 +
  1.1970 +@SYMPREQ 2400
  1.1971 +
  1.1972 +@SYMREQ 12326
  1.1973 +
  1.1974 +@SYMTestCaseDesc
  1.1975 +To ensure that sync object API generates correct errors and returns correct 
  1.1976 +value if wrong parameters supplied.
  1.1977 +
  1.1978 +@SYMTestActions
  1.1979 +1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
  1.1980 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR
  1.1981 +2. Call all sync API for the display which doesn't exist in the system.
  1.1982 +3. Call eglCreateSyncKHR() with unsupported type parameter.
  1.1983 +4. Call eglCreateSyncKHR() with specified attributes, type parameter set to EGL_SYNC_REUSABLE_KHR
  1.1984 +5. Call eglCreateSyncKHR() with unspecified attributes, type parameter set to EGL_SYNC_REUSABLE_KHR
  1.1985 +6. Call all sync API (with the exception to eglCreateSyncKHR(...), providing invalid EGLSyncKHR as a parameter 
  1.1986 +7. Call eglClientWaitSyncKHR(), providing unspecified flags.
  1.1987 +8. Call eglSignalSyncKHR(), providing unspecified status.
  1.1988 +9. Call eglGetSyncAttribSyncKHR(), providing unspecified attributes.
  1.1989 +10. Destroy the sync object
  1.1990 +
  1.1991 +@SYMTestExpectedResults
  1.1992 +2. eglCreateSyncKHR(...) should return EGL_NO_SYNC_KHR and EGL_BAD_DISPLAY error is generated. 
  1.1993 +   eglClientWaitSyncKHR(...), eglSignalSyncKHR(...), eglGetSyncAttribKHR(...) and eglDestroySyncKHR(...) 
  1.1994 +   should return EGL_FALSE and EGL_BAD_DISPLAY error is generated.
  1.1995 +3. Should return EGL_NO_SYNC_KHR and EGL_BAD_ATTRIBUTE error is generated.
  1.1996 +4.5 Should return EGL_NO_SYNC_KHR and EGL_BAD_ATTRIBUTE error is generated.
  1.1997 +6, 7, 8. Should return EGL_FALSE and EGL_BAD_PARAMETER error is generated
  1.1998 +9. Should return EGL_FALSE and EGL_BAD_ATTRIBUTE error is generated
  1.1999 +*/
  1.2000 +TVerdict CEglTest_SyncObject_Negative_WrongParameters::doTestStepL()
  1.2001 +	{
  1.2002 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-100"));
  1.2003 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Negative_WrongParameters::doTestStepL"));
  1.2004 +	
  1.2005 +	if(!iIsSyncObjectExtensionSupported)
  1.2006 +		{
  1.2007 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.2008 +		CleanAll();
  1.2009 +		RecordTestResultL();
  1.2010 +		CloseTMSGraphicsStep();
  1.2011 +		return TestStepResult();
  1.2012 +		}
  1.2013 +
  1.2014 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.2015 +	GetDisplayL();
  1.2016 +	CreateEglSessionL();
  1.2017 +	iEglSess->InitializeL();
  1.2018 +
  1.2019 +	//create a sync object
  1.2020 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.2021 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.2022 +	TEST(eglGetError() == EGL_SUCCESS);
  1.2023 +
  1.2024 +	INFO_PRINTF1(_L("Call all sync API for the display which doesn't exist in the system"));
  1.2025 +	EGLDisplay	invalidDisplay = iDisplay + 1;
  1.2026 +	iSyncObject1 = iPfnEglCreateSyncKHR(invalidDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.2027 +	TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
  1.2028 +	TEST(eglGetError() == EGL_BAD_DISPLAY);
  1.2029 +	EGLBoolean res = iPfnEglSignalSyncKHR(invalidDisplay,iSyncObject,EGL_UNSIGNALED_KHR );
  1.2030 +	TEST(res == EGL_FALSE);
  1.2031 +	TEST(eglGetError() == EGL_BAD_DISPLAY);
  1.2032 +	EGLint res1 = iPfnEglClientWaitSyncKHR(invalidDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.2033 +	TEST(res1 == EGL_FALSE);
  1.2034 +	TEST(eglGetError() == EGL_BAD_DISPLAY);
  1.2035 +	EGLint value;
  1.2036 +	res = iPfnEglGetSyncAttribKHR(invalidDisplay,iSyncObject,EGL_SYNC_STATUS_KHR, &value);
  1.2037 +	TEST(res == EGL_FALSE);
  1.2038 +	TEST(eglGetError() == EGL_BAD_DISPLAY);
  1.2039 +	res = iPfnEglDestroySyncKHR(invalidDisplay, iSyncObject);
  1.2040 +	TEST(res == EGL_FALSE);
  1.2041 +	TEST(eglGetError() == EGL_BAD_DISPLAY);
  1.2042 +	
  1.2043 +	INFO_PRINTF1(_L("Call eglCreateSyncKHR() with unsupported type parameter."));
  1.2044 +	const EGLint unsupportedType = 0x3fff;
  1.2045 +	iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, unsupportedType, KEglSyncAttribsNone);
  1.2046 +	TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
  1.2047 +	TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
  1.2048 +	
  1.2049 +	const EGLint KSpecifiedAttrib[] = {
  1.2050 +								EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR,
  1.2051 +								EGL_NONE
  1.2052 +								};
  1.2053 +	INFO_PRINTF1(_L("Call eglCreateSyncKHR() with specified condition, type parameter set to EGL_SYNC_REUSABLE_KHR"));
  1.2054 +	iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KSpecifiedAttrib);
  1.2055 +	TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
  1.2056 +	TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
  1.2057 +	
  1.2058 +	INFO_PRINTF1(_L("Call eglCreateSyncKHR() with unspecified attributes, type parameter set to EGL_SYNC_REUSABLE_KHR"));
  1.2059 +	const TInt KUndefinedAttrib = 0x4000; 
  1.2060 +	const EGLint KUnspecifiedAttrib1[] = {	
  1.2061 +								KUndefinedAttrib, EGL_UNSIGNALED_KHR,
  1.2062 +								EGL_NONE
  1.2063 +								};
  1.2064 +	iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KUnspecifiedAttrib1);
  1.2065 +	TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
  1.2066 +	TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
  1.2067 +	const EGLint KUnspecifiedAttrib2[] = {	
  1.2068 +								EGL_SYNC_STATUS_KHR, KUndefinedAttrib,
  1.2069 +								EGL_NONE
  1.2070 +								};
  1.2071 +	iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KUnspecifiedAttrib2);
  1.2072 +	TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
  1.2073 +	TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
  1.2074 +	
  1.2075 +	INFO_PRINTF1(_L("Call all sync API (with the exception to eglCreateSyncKHR(...), providing invalid EGLSyncKHR as a parameter"));
  1.2076 +	res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject1,EGL_UNSIGNALED_KHR );
  1.2077 +	TEST(res == EGL_FALSE);
  1.2078 +	TEST(eglGetError() == EGL_BAD_PARAMETER);
  1.2079 +	res1 = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject1,0,EGL_FOREVER_KHR);
  1.2080 +	TEST(res1 == EGL_FALSE);
  1.2081 +	TEST(eglGetError() == EGL_BAD_PARAMETER);
  1.2082 +	res = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject1,EGL_SYNC_STATUS_KHR, &value);
  1.2083 +	TEST(res == EGL_FALSE);
  1.2084 +	TEST(eglGetError() == EGL_BAD_PARAMETER);
  1.2085 +	res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject1);
  1.2086 +	TEST(res == EGL_FALSE);
  1.2087 +	TEST(eglGetError() == EGL_BAD_PARAMETER);
  1.2088 +	
  1.2089 +	INFO_PRINTF1(_L("Call eglClientWaitSyncKHR(), providing unspecified flags"));
  1.2090 +	const TInt KUnspecifiedFlags = 0x002;
  1.2091 +	res1 = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,KUnspecifiedFlags,EGL_FOREVER_KHR);
  1.2092 +	TEST(res1 == EGL_FALSE);
  1.2093 +	TEST(eglGetError() == EGL_BAD_PARAMETER);
  1.2094 +		
  1.2095 +	INFO_PRINTF1(_L("Call eglSignalSyncKHR(), providing unspecified status"));
  1.2096 +	const EGLint unspecifiedStatus = 0x3fff;
  1.2097 +	res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,unspecifiedStatus);
  1.2098 +	TEST(res == EGL_FALSE);
  1.2099 +	TEST(eglGetError() == EGL_BAD_PARAMETER);
  1.2100 +
  1.2101 +	INFO_PRINTF1(_L("Call eglGetSyncAttribSyncKHR(), providing unspecified attributes"));
  1.2102 +	const EGLint unspecifiedAttribute = 0x3fff;
  1.2103 +	res = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject,unspecifiedAttribute, &value);
  1.2104 +	TEST(res == EGL_FALSE);
  1.2105 +	TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
  1.2106 +	//close sync object
  1.2107 +	res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.2108 +	TEST(res == EGL_TRUE);
  1.2109 +
  1.2110 +	CleanAll();
  1.2111 +	RecordTestResultL();
  1.2112 +	CloseTMSGraphicsStep();
  1.2113 +	INFO_PRINTF1(_L("End of CEglTest_SyncObject_Negative_WrongParameters::doTestStepL"));
  1.2114 +	return TestStepResult();
  1.2115 +	}
  1.2116 +
  1.2117 +/**
  1.2118 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-105
  1.2119 +
  1.2120 +@SYMTestPriority 1
  1.2121 +
  1.2122 +@SYMPREQ 2400
  1.2123 +
  1.2124 +@SYMREQ 12326
  1.2125 +
  1.2126 +@SYMTestCaseDesc
  1.2127 +To check that internal version of the signal function, which is accessible 
  1.2128 +via extension mechanism, doesn't generate an error.
  1.2129 +
  1.2130 +@SYMTestActions
  1.2131 +1.	Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
  1.2132 +    The type parameter is set to EGL_SYNC_REUSABLE_KHR.
  1.2133 +2.	Call egl_Private_SignalSyncNOK() on sync object supplying invalid status
  1.2134 +3.	Call eglGetError()
  1.2135 +4.	Call egl_Private_SignalSyncNOK() on sync object with EGL_SIGNALED_KHR flag supplying invalid display
  1.2136 +5.	Call eglGetError()
  1.2137 +6.	Retrieve status attribute 
  1.2138 +7.	Call eglQueryString(..) supplying invalid name parameter (for instance, "OpenGL_Wrong" ).
  1.2139 +8.	Call egl_Private_SignalSyncNOK() on sync object with EGL_SIGNALED_KHR flag supplying invalid display
  1.2140 +9.	Call eglGetError()
  1.2141 +10. Destroy the sync object
  1.2142 +
  1.2143 +@SYMTestExpectedResults
  1.2144 +2. The function returns EGL_BAD_ PARAMETERS
  1.2145 +3. An error is set to EGL_SUCCESS
  1.2146 +4. The function returns EGL_BAD_DISPLAY.
  1.2147 +5. An error is set to EGL_SUCCESS
  1.2148 +6. The status attributes indicates that object is still in a signaled state (EGL_UNSIGNALED_KHR)
  1.2149 +8. The function returns EGL_BAD_DISPLAY.
  1.2150 +9. An error is set to EGL_BAD_PARAMETER
  1.2151 +*/
  1.2152 +TVerdict CEglTest_SyncObject_Negative_SignalImpl::doTestStepL()
  1.2153 +	{
  1.2154 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-105"));
  1.2155 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Negative_SignalImpl::doTestStepL"));
  1.2156 +	
  1.2157 +	if(!iIsSyncObjectExtensionSupported || !iIsSyncObjectPrivateExtensionSupported)
  1.2158 +		{
  1.2159 +		INFO_PRINTF1(_L("Sync object extensions (whether EGL_KHR_reusable_sync or EGL_NOK__private__signal_sync or both) \
  1.2160 +are not supported, the test will not be executed"));
  1.2161 +		CleanAll();
  1.2162 +		RecordTestResultL();
  1.2163 +		CloseTMSGraphicsStep();
  1.2164 +		return TestStepResult();
  1.2165 +		}
  1.2166 +
  1.2167 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.2168 +	GetDisplayL();
  1.2169 +	CreateEglSessionL();
  1.2170 +	iEglSess->InitializeL();
  1.2171 +	
  1.2172 +	INFO_PRINTF1(_L("Create the sync object"));
  1.2173 +	iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.2174 +	TESTL(iSyncObject != EGL_NO_SYNC_KHR);
  1.2175 +	
  1.2176 +	INFO_PRINTF1(_L("Call egl_Private_SignalSyncNOK() on sync object supplying invalid status"));
  1.2177 +	const EGLint unspecifiedMode = 0x3fff;
  1.2178 +	EGLint res1 = iPfnEglPrivateSignalSyncNOK(iDisplay, iSyncObject, unspecifiedMode);
  1.2179 +	TEST(res1 == EGL_BAD_PARAMETER);
  1.2180 +	TEST(eglGetError() == EGL_SUCCESS);
  1.2181 +	
  1.2182 +	INFO_PRINTF1(_L("Call egl_Private_SignalSyncNOK() on sync object with EGL_SIGNALED_KHR flag supplying invalid display"));
  1.2183 +	const EGLDisplay invalidDisplay = iDisplay + 1;
  1.2184 +	res1 = iPfnEglPrivateSignalSyncNOK(invalidDisplay, iSyncObject, EGL_SIGNALED_KHR);
  1.2185 +	TEST(res1 == EGL_BAD_DISPLAY);
  1.2186 +	TEST(eglGetError() == EGL_SUCCESS);
  1.2187 +	CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR); //the status is still "unsignaled"
  1.2188 +	
  1.2189 +	INFO_PRINTF1(_L("Call eglQueryString(..) supplying invalid name parameter ")); //the actual API doesn't matter, we need to generate an error 
  1.2190 +	const TInt invalidExtension = 0xffff;
  1.2191 +	const char* extensionsString = eglQueryString(iDisplay, invalidExtension); //this should generate EGL_BAD_PARAMETER
  1.2192 +	TEST(!extensionsString);
  1.2193 +	
  1.2194 +	res1 = iPfnEglPrivateSignalSyncNOK(invalidDisplay, iSyncObject, EGL_SIGNALED_KHR);
  1.2195 +	TEST(res1 == EGL_BAD_DISPLAY);
  1.2196 +	TEST(eglGetError() == EGL_BAD_PARAMETER); //check that error code was not overidden
  1.2197 +	
  1.2198 +	EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
  1.2199 +	TEST(res == EGL_TRUE);	
  1.2200 +	CleanAll();
  1.2201 +	RecordTestResultL();
  1.2202 +	CloseTMSGraphicsStep();
  1.2203 +	INFO_PRINTF1(_L("End of CEglTest_SyncObject_Negative_SignalImpl::doTestStepL"));
  1.2204 +	return TestStepResult();
  1.2205 +	}
  1.2206 +
  1.2207 +/**
  1.2208 +@SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-110
  1.2209 +
  1.2210 +@SYMTestPriority 1
  1.2211 +
  1.2212 +@SYMPREQ 2400
  1.2213 +
  1.2214 +@SYMREQ 12326
  1.2215 +
  1.2216 +@SYMTestCaseDesc
  1.2217 +To check that system correctly processing errors in the environment with shortage of memory.
  1.2218 +
  1.2219 +@SYMTestActions
  1.2220 +1. Run a loop (step 2 to 7) with fail rate counting from 1 upward until 
  1.2221 +   the following operations succeed
  1.2222 +2. Set heap failure with the fail rate specifying in step 1
  1.2223 +3. Create sync object for the default display. No attributes are specified (containing only EGL_NONE). 
  1.2224 +   The type parameter is set to EGL_SYNC_REUSABLE_KHR. Skip the following test steps if operation doesn't succeed
  1.2225 +4. Launch thread A
  1.2226 +5. Wait on the sync object
  1.2227 +6. Signal from thread A on the sync object the flag EGL_SIGNALED_KHR 
  1.2228 +7. Destroy the sync object
  1.2229 +8. Reset heap
  1.2230 +
  1.2231 +@SYMTestExpectedResults
  1.2232 +3. If memory is not enough to fulfil an operation EGL_NO_SYNC_KHR is returned. Otherwise it should return a handle to a valid sync object
  1.2233 +5. The main thread should be stalled
  1.2234 +6. The main thread should be unblocked
  1.2235 +*/
  1.2236 +TVerdict CEglTest_SyncObject_Negative_OOM::doTestStepL()
  1.2237 +	{
  1.2238 +	SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-110"));
  1.2239 +	INFO_PRINTF1(_L("CEglTest_SyncObject_Negative_OOM::doTestStepL"));
  1.2240 +#ifndef _DEBUG
  1.2241 +	WARN_PRINTF1(_L("CEglTest_SyncObject_Negative_OOM can only be run in debug mode"));
  1.2242 +	RecordTestResultL();
  1.2243 +	CloseTMSGraphicsStep();
  1.2244 +	return TestStepResult();
  1.2245 +#else
  1.2246 +	
  1.2247 +	if(!iIsSyncObjectExtensionSupported)
  1.2248 +		{
  1.2249 +		INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
  1.2250 +		CleanAll();
  1.2251 +		RecordTestResultL();
  1.2252 +		CloseTMSGraphicsStep();
  1.2253 +		return TestStepResult();
  1.2254 +		}
  1.2255 +
  1.2256 +	ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
  1.2257 +	GetDisplayL();
  1.2258 +	CreateEglSessionL();
  1.2259 +	iEglSess->InitializeL();
  1.2260 + 	
  1.2261 +	INFO_PRINTF1(_L("Retrieving the heapMark functions for memory testing..."));
  1.2262 +	TEglDebugHeapMarkStartPtr		heapMarkStart			= reinterpret_cast<TEglDebugHeapMarkStartPtr>(eglGetProcAddress("egliDebugHeapMarkStart"));
  1.2263 +	TEglDebugHeapMarkEndPtr			heapMarkEnd				= reinterpret_cast<TEglDebugHeapMarkEndPtr>(eglGetProcAddress("egliDebugHeapMarkEnd"));
  1.2264 +	TEglDebugSetBurstAllocFailPtr	setSyncObjectAllocFail	= reinterpret_cast<TEglDebugSetBurstAllocFailPtr>(eglGetProcAddress("egliDebugSetBurstAllocFail"));
  1.2265 +	TESTL(heapMarkStart && heapMarkEnd && setSyncObjectAllocFail);
  1.2266 +	
  1.2267 +	EGLint err = EGL_BAD_ALLOC;
  1.2268 +	for(TUint failAfter=1; (err == EGL_BAD_ALLOC); ++failAfter)
  1.2269 +		{
  1.2270 +		__UHEAP_MARK;
  1.2271 +		heapMarkStart();
  1.2272 +		
  1.2273 +		// Set heap failure
  1.2274 +		INFO_PRINTF2(_L("Set EGL heap to fail after %u allocations"), failAfter);
  1.2275 +		setSyncObjectAllocFail(static_cast<EGLenum>(RHeap::EBurstFailNext), failAfter, 742);
  1.2276 +
  1.2277 +		INFO_PRINTF1(_L("Create sync object"));
  1.2278 +		iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
  1.2279 +		err = eglGetError();
  1.2280 +		if(err == EGL_SUCCESS)
  1.2281 +			{
  1.2282 +			TEST(iSyncObject != EGL_NO_SYNC_KHR);
  1.2283 +			//launch threadA
  1.2284 +			Test_MultiThreadL(1, EFalse);
  1.2285 +			TUint32 timestampBefore = User::NTickCount();
  1.2286 +			EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
  1.2287 +			TUint32 timestampAfter = User::NTickCount();
  1.2288 +			TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
  1.2289 +			TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);//we do not expect failure here, as eglClientWaitSyncKHR function doesn't allocate any memory
  1.2290 +			TEST(Abs(timeElapsed - iDelaySignalling) < iThreshold);
  1.2291 +			//close sync object
  1.2292 +			TEST(iPfnEglDestroySyncKHR(iDisplay, iSyncObject)== EGL_TRUE);
  1.2293 +			
  1.2294 +			//Wait for the thread to finish before launching the thread with the same index again.
  1.2295 +			Test_MultiThread_WaitL(ETrue, TThreadStatus::ELogin);
  1.2296 +			}
  1.2297 +		else
  1.2298 +			{
  1.2299 +			TEST(iSyncObject == EGL_NO_SYNC_KHR);
  1.2300 +			}
  1.2301 +		// Unset heap failure
  1.2302 +		setSyncObjectAllocFail(static_cast<EGLenum>(RHeap::ENone), 0, 0);
  1.2303 +		(void)heapMarkEnd(0);
  1.2304 +		__UHEAP_MARKEND;
  1.2305 +		}
  1.2306 +	TEST(err == EGL_SUCCESS);
  1.2307 +	
  1.2308 +	CleanAll();
  1.2309 +	RecordTestResultL();
  1.2310 +	CloseTMSGraphicsStep();
  1.2311 +	INFO_PRINTF1(_L("End of CEglTest_SyncObject_Negative_OOM::doTestStepL"));
  1.2312 +	return TestStepResult();
  1.2313 +#endif	
  1.2314 +	}
  1.2315 +
  1.2316 +void CEglTest_SyncObject_Negative_OOM::doThreadFunctionL(TInt aIdx)
  1.2317 +	{
  1.2318 +	INFO_PRINTF2(_L("CEglTest_SyncObject_Negative_OOM::doThreadFunctionL, Thread %d"),aIdx);
  1.2319 +	ASSERT_TRUE(aIdx==0);
  1.2320 +
  1.2321 +	User::After(TTimeIntervalMicroSeconds32(iDelaySignalling));
  1.2322 +	TEST(iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR) == EGL_TRUE); //we do not expect failure here, as eglSignalSyncKHR function doesn't allocate a memory
  1.2323 +	}