Update contrib.
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
20 #include "egltest_syncobject.h"
21 #include <test/tefunit.h>
23 #include <test/egltestcommonsgimageinfo.h>
25 const TUint32 KThreshold = 0.5*1000*1000; // 0.5 sec
26 const TUint32 KDelaySignalling = 2.5*1000*1000; // 2.5 sec
27 const TUint32 KWaitSyncTimeout = 5*1000*1000; // 5 sec
28 const TUint32 KLongDelaySignalling = 7.5*1000*1000; // 7.5 sec
29 const TInt KNumStressIterations = 1000;
31 typedef void (*TEglDebugHeapMarkStartPtr) (void);
32 typedef EGLint (*TEglDebugHeapMarkEndPtr) (EGLint count);
33 typedef void (*TEglDebugSetBurstAllocFailPtr) (EGLenum type, EGLint rate, EGLint burst);
35 struct TSurfaceToDestroy
41 //the function clean up surface resource. Needs to be push into cleanup stack beforehand
42 void DestroySurface(TAny* aAny)
44 TSurfaceToDestroy* surfaceToDestroy = (TSurfaceToDestroy*)aAny;
45 eglDestroySurface(surfaceToDestroy->iDisplay, surfaceToDestroy->iSurface);
48 CEglTest_SyncObject_Base::CEglTest_SyncObject_Base() :
49 iSyncObject(EGL_NO_SYNC_KHR), iSyncObject1(EGL_NO_SYNC_KHR), iSyncObject2(EGL_NO_SYNC_KHR),
50 iThreshold(KThreshold), iDelaySignalling(KDelaySignalling),
51 iWaitSyncTimeout(KWaitSyncTimeout), iLongDelaySignalling(KLongDelaySignalling),
52 iNumStressIterations(KNumStressIterations)
56 CEglTest_SyncObject_Base::~CEglTest_SyncObject_Base()
58 if(iPfnEglDestroySyncKHR)
60 iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
61 iPfnEglDestroySyncKHR(iDisplay, iSyncObject1);
62 iPfnEglDestroySyncKHR(iDisplay, iSyncObject2);
68 TVerdict CEglTest_SyncObject_Base::doTestStepPreambleL()
70 INFO_PRINTF1(_L("CEglTest_SyncObject_Base::doTestStepPreambleL()"));
71 CEglTestStep::doTestStepPreambleL();
72 TInt res = HAL::Get(HALData::ENanoTickPeriod, iTickPeriodMicroSeconds);
75 ERR_PRINTF2(_L("Can't retrieve tick period, err %d"), res);
78 INFO_PRINTF2(_L("Tick period in micro seconds %d"), iTickPeriodMicroSeconds);
80 _LIT(KKeyThreshold, "Threshold");
81 _LIT(KKeyDelaySignalling, "DelaySignalling");
82 _LIT(KKeyWaitSyncTimeout, "WaitSyncTimeout");
83 _LIT(KKeyLongDelaySignalling, "LongDelaySignalling");
84 _LIT(KKeyNumStressIterations, "NumIterations");
86 //retrive all setting from INI file
87 GetIntFromConfig(ConfigSection(), KKeyThreshold, iThreshold);
88 GetIntFromConfig(ConfigSection(), KKeyDelaySignalling, iDelaySignalling);
89 GetIntFromConfig(ConfigSection(), KKeyWaitSyncTimeout, iWaitSyncTimeout);
90 GetIntFromConfig(ConfigSection(), KKeyLongDelaySignalling, iLongDelaySignalling);
91 GetIntFromConfig(ConfigSection(), KKeyNumStressIterations, iNumStressIterations);
93 INFO_PRINTF2(_L("Level of tolerance %d"), iThreshold);
94 INFO_PRINTF2(_L("Delay before the signal occurs %d"), iDelaySignalling);
95 INFO_PRINTF2(_L("Timeout client waits on sync object %d"), iWaitSyncTimeout);
96 INFO_PRINTF2(_L("Long delay before signalling occurs %d"), iLongDelaySignalling);
97 INFO_PRINTF2(_L("Number of iterations before stress test exits %d"), iNumStressIterations);
99 INFO_PRINTF1(_L("Check if the Sync object Khronos extension is supported"));
100 iIsSyncObjectExtensionSupported = CheckForExtensionL(KEGL_KHR_reusable_sync);
102 INFO_PRINTF1(_L("Check if the Sync object private extension is supported"));
103 iIsSyncObjectPrivateExtensionSupported = CheckForExtensionL(KEGL_NOK__private__signal_sync);
106 TEST(GetProcAddress());
107 INFO_PRINTF1(_L("End of CEglTest_SyncObject_Base::doTestStepPreambleL()"));
108 return TestStepResult();
111 void CEglTest_SyncObject_Base::CreateEglSessionL()
113 delete iEglSess; //just in case it was called twice
114 iEglSess = CTestEglSession::NewL(Logger(), iDisplay, 0);
117 void CEglTest_SyncObject_Base::CheckSyncAttrib(EGLint aAttribute, EGLint aExpectedValue)
120 EGLBoolean res = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject,aAttribute,&value);
121 TEST(res == EGL_TRUE);
122 TEST(value == aExpectedValue);
126 case EGL_SYNC_TYPE_KHR:
128 if (value == EGL_SYNC_REUSABLE_KHR)
130 INFO_PRINTF1(_L(" EGL_SYNC_TYPE_KHR: EGL_SYNC_REUSABLE_KHR"));
134 ERR_PRINTF1(_L(" EGL_SYNC_TYPE_KHR: Invalid attribute"));
138 case EGL_SYNC_STATUS_KHR:
140 if (value == EGL_SIGNALED_KHR)
142 INFO_PRINTF1(_L(" EGL_SYNC_STATUS_KHR: EGL_SIGNALED_KHR"));
144 else if (value == EGL_UNSIGNALED_KHR)
146 INFO_PRINTF1(_L(" EGL_SYNC_STATUS_KHR: EGL_UNSIGNALED_KHR"));
150 ERR_PRINTF1(_L(" EGL_SYNC_STATUS_KHR: Invalid attribute"));
156 ERR_PRINTF1(_L(" Invalid attribute"));
162 Obtain extension functions for the sync object
164 TBool CEglTest_SyncObject_Base::GetProcAddress()
166 if(!iIsSyncObjectExtensionSupported)
168 INFO_PRINTF1(_L("Sync object extension is not defined in test INI file.\
169 The retrieval of the pointers to the extension sync object function will be skipped"));
173 //retrieve the pointers to the EGL sync object extension functions
174 INFO_PRINTF1(_L("retrieve the pointers to the EGL sync object extension functions"));
176 iPfnEglCreateSyncKHR = reinterpret_cast <TFPtrEglCreateSyncKhr> (eglGetProcAddress("eglCreateSyncKHR"));
177 iPfnEglDestroySyncKHR = reinterpret_cast <TFPtrEglDestroySyncKhr> (eglGetProcAddress("eglDestroySyncKHR"));
178 iPfnEglClientWaitSyncKHR = reinterpret_cast <TFPtrEglClientWaitSyncKhr> (eglGetProcAddress("eglClientWaitSyncKHR"));
179 iPfnEglSignalSyncKHR = reinterpret_cast <TFPtrEglSignalSyncKhr> (eglGetProcAddress("eglSignalSyncKHR"));
180 iPfnEglGetSyncAttribKHR = reinterpret_cast <TFPtrEglGetSyncAttribKhr> (eglGetProcAddress("eglGetSyncAttribKHR"));
181 if(iIsSyncObjectPrivateExtensionSupported)
183 iPfnEglPrivateSignalSyncNOK = reinterpret_cast <TFPtrEglPrivateSignalSyncNok> (eglGetProcAddress("egl_Private_SignalSyncNOK"));
184 if(!iPfnEglPrivateSignalSyncNOK)
186 ERR_PRINTF1(_L(" Pointer to function \"egl_Private_SignalSyncNOK\" is not valid"));
189 if(!iPfnEglCreateSyncKHR)
191 ERR_PRINTF1(_L(" Pointer to function \"eglCreateSyncKHR\" is not valid"));
193 if(!iPfnEglDestroySyncKHR)
195 ERR_PRINTF1(_L(" Pointer to function \"eglDestroySyncKHR\" is not valid"));
197 if(!iPfnEglClientWaitSyncKHR)
199 ERR_PRINTF1(_L(" Pointer to function \"eglClientWaitSyncKHR\" is not valid"));
201 if(!iPfnEglSignalSyncKHR)
203 ERR_PRINTF1(_L(" Pointer to function \"eglSignalSyncKHR\" is not valid"));
206 if(!iPfnEglGetSyncAttribKHR)
208 ERR_PRINTF1(_L(" Pointer to function \"eglGetSyncAttribKHR\" is not valid"));
211 if(!(iPfnEglCreateSyncKHR && iPfnEglDestroySyncKHR && iPfnEglClientWaitSyncKHR
212 && iPfnEglSignalSyncKHR && iPfnEglGetSyncAttribKHR &&
213 (!iIsSyncObjectPrivateExtensionSupported || (iPfnEglPrivateSignalSyncNOK))))
214 {//if the private extension is not declared in the test ini file, we won't signal the failure
220 void CEglTest_SyncObject_Base::CleanAll()
227 TRAPD(res, TerminateDisplayL());
228 TEST(res == KErrNone);
229 INFO_PRINTF2(_L("Display termination completed with error %d"), res);
231 INFO_PRINTF1(_L("Main Thread: Calling eglReleaseThread()"));
232 ASSERT_EGL_TRUE(eglReleaseThread())
236 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-001
245 To check that current implementation support EGL sync object extension
248 1. Request supporting extension for the existing display by calling eglQueryString(...) and passing EGL_EXTENSIONS as a second parameter.
249 2. Obtain an EGL sync object extension functions by supplying the following procname to the function void (*eglGetProcAddress(const char *procname)):
252 "eglClientWaitSyncKHR"
254 "eglGetSyncAttribKHR"
256 @SYMTestExpectedResults
257 1. The function must return a string which includes space separated sub-string "EGL_KHR_reusable_sync".
258 2. The pointer to the functions should be non zero.
260 TVerdict CEglTest_SyncObject_Positive_GetProcAddress::doTestStepL()
262 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-001"));
263 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_GetProcAddress::doTestStepL"));
265 if(!iIsSyncObjectExtensionSupported)
267 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
270 CloseTMSGraphicsStep();
271 return TestStepResult();
274 // check that extension "EGL_KHR_reusable_sync" is supported
275 INFO_PRINTF1(_L("Check that extension \"EGL_KHR_reusable_sync\" is supported"));
276 TEST(CheckForExtensionL(KEGL_KHR_reusable_sync));
278 INFO_PRINTF1(_L("Obtain EGL sync object extension functions"));
279 TEST(GetProcAddress());
282 CloseTMSGraphicsStep();
283 INFO_PRINTF1(_L("End of CEglTest_SyncObject_Positive_GetProcAddress::doTestStepL"));
284 return TestStepResult();
288 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-005
297 To validate the creation and deletion of the sync object.
300 1. Create sync object for the default display. NULL are specified in attribute_list.
301 The type parameter is set to EGL_SYNC_REUSABLE_KHR
302 2. Retrieve the following attributes of the sync object: EGL_SYNC_TYPE_KHR ,
304 3. Delete the sync object
305 4. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
306 The type parameter is set to EGL_SYNC_REUSABLE_KHR
307 5. Retrieve the following attributes of the sync object: EGL_SYNC_TYPE_KHR ,
309 6. Delete the sync object
311 @SYMTestExpectedResults
312 1. Sync object handle doesn't equal to EGL_NO_SYNC_KHR
313 2. Sync object attribute EGL_SYNC_STATUS_KHR should be set to EGL_UNSIGNALED_KHR by default,
314 attribute EGL_SYNC_TYPE_KHR should be set to EGL_SYNC_REUSABLE_KHR
315 4. Sync object handle doesn't equal to EGL_NO_SYNC_KHR
316 5. Sync object attribute EGL_SYNC_STATUS_KHR should be set to EGL_UNSIGNALED_KHR by default,
317 attribute EGL_SYNC_TYPE_KHR should be set to EGL_SYNC_REUSABLE_KHR
319 TVerdict CEglTest_SyncObject_Positive_CreateDestroy::doTestStepL()
321 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-005"));
322 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_CreateDestroy::doTestStepL"));
324 if(!iIsSyncObjectExtensionSupported)
326 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
329 CloseTMSGraphicsStep();
330 return TestStepResult();
333 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
336 iEglSess->InitializeL();
338 INFO_PRINTF1(_L("Create sync object - default display, NULL at attributes, type parameter set to EGL_SYNC_REUSABLE_KHR"));
339 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, NULL);
340 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
342 //check attributes of the sync object.
343 INFO_PRINTF1(_L("Check attributes of sync object"));
344 CheckSyncAttrib(EGL_SYNC_TYPE_KHR, EGL_SYNC_REUSABLE_KHR);
345 CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR);
347 INFO_PRINTF1(_L("Delete sync object"));
348 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
349 TEST(res == EGL_TRUE);
351 INFO_PRINTF1(_L("Create sync object - default display, no attribute specified, type parameter set to EGL_SYNC_REUSABLE_KHR "));
352 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
353 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
355 INFO_PRINTF1(_L("Check attributes"));
356 CheckSyncAttrib(EGL_SYNC_TYPE_KHR, EGL_SYNC_REUSABLE_KHR);
357 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
359 INFO_PRINTF1(_L("Delete sync object"));
360 res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
361 TEST(res == EGL_TRUE);
365 CloseTMSGraphicsStep();
366 return TestStepResult();
370 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-010
379 To check that transition from EGL_UNSIGNALED_KHR to EGL_SIGNALED_KHR state will trigger the signal and unblock the client thread
382 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
383 The type parameter is set to EGL_SYNC_REUSABLE_KHR
385 3. Wait on sync object by calling eglClientWaitSyncKHR
386 4. Signal on the sync object from thread A with the flag EGL_SIGNALED_KHR
387 5. Retrieve EGL_SYNC_STATUS_KHR attribute
388 6. Delete the sync object
390 @SYMTestExpectedResults
391 3. The main thread is blocked
392 4. After the signal the main thread should be unblocked and the value returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR
393 5. Status attribute is set to EGL_SIGNALED_KHR
395 TVerdict CEglTest_SyncObject_Positive_WaitSignal::doTestStepL()
397 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-010"));
398 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitSignal::doTestStepL"));
400 if(!iIsSyncObjectExtensionSupported)
402 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
405 CloseTMSGraphicsStep();
406 return TestStepResult();
409 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
412 iEglSess->InitializeL();
415 INFO_PRINTF1(_L("Create sync object"));
416 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
417 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
420 Test_MultiThreadL(1, EFalse);
422 //Stall the main thread
423 TUint32 timestampBefore = User::NTickCount(); //microsecond
424 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
425 TUint32 timestampAfter = User::NTickCount();
426 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
428 INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
429 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
430 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
432 INFO_PRINTF1(_L("Check attributes of sync object"));
433 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
435 INFO_PRINTF1(_L("Delete sync object"));
436 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
437 TEST(res == EGL_TRUE);
441 CloseTMSGraphicsStep();
442 return TestStepResult();
445 void CEglTest_SyncObject_Positive_WaitSignal::doThreadFunctionL(TInt aIdx)
447 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_WaitSignal::doThreadFunctionL, Thread %d"),aIdx);
448 ASSERT_TRUE(aIdx==0);
450 User::After(iDelaySignalling);
452 INFO_PRINTF1(_L("signal sync object from thread A"));
453 EGLBoolean res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_SIGNALED_KHR);
454 TEST(res == EGL_TRUE);
458 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-015
467 To check that the client will not be blocked by waiting on the sync object
468 if the latter is in EGL_SIGNALED_KHR state and will stay blocked until
469 transition from unsignal to signal state occurs.
470 To check that eglSignalSyncKHR sets the state of the sync object correctly.
473 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
474 The type parameter is set to EGL_SYNC_REUSABLE_KHR
475 2. Call eglSignalSyncKHR with EGL_SIGNALED_KHR as a parameter.
476 3. Retrieve an EGL_SYNC_STATUS_KHR attribute.
477 4. Try to wait on the sync object by calling eglClientWaitSyncKHR.
478 5. Call eglSignalSyncKHR with EGL_UNSIGNALED_KHR as a parameter.
479 6. Retrieve an EGL_SYNC_STATUS_KHR attribute.
481 8. Waiting on the sync object by calling eglClientWaitSyncKHR.
482 9. From thread A call eglSignalSyncKHR with EGL_UNSIGNALED_KHR as a parameter.
483 10. From thread A retrieve EGL_SYNC_STATUS_KHR attribute.
484 11. From thread A call eglSignalSyncKHR with EGL_SIGNALED_KHR as a parameter.
485 12. From thread A retrieve EGL_SYNC_STATUS_KHR attribute.
486 13 Delete the sync object.
488 @SYMTestExpectedResults
489 3. EGL_SYNC_STATUS_KHR attribute is set to EGL_SIGNALED_KHR
490 4. The thread is not blocked and an error code returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR
491 6. EGL_SYNC_STATUS_KHR attribute is set to EGL_UNSIGNALED_KHR
492 8. Main thread is blocked
493 9. Main thread stays blocked
494 10. EGL_SYNC_STATUS_KHR attribute is set to EGL_UNSIGNALED_KHR
495 11. Main thread is unblocked
496 12. EGL_SYNC_STATUS_KHR attribute is set to EGL_SIGNALED_KHR
498 TVerdict CEglTest_SyncObject_Positive_WaitSignal2::doTestStepL()
500 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-015"));
501 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitSignal2::doTestStepL"));
503 if(!iIsSyncObjectExtensionSupported)
505 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
508 CloseTMSGraphicsStep();
509 return TestStepResult();
512 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
515 iEglSess->InitializeL();
517 INFO_PRINTF1(_L("Create sync object"));
518 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
519 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
521 //set to signal state, basically we are not changing anything here
522 EGLBoolean res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_SIGNALED_KHR);
523 TEST(res = EGL_TRUE);
524 CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_SIGNALED_KHR);
526 INFO_PRINTF1(_L("Try to wait on the sync object by calling eglClientWaitSyncKHR"));
527 TUint32 timestampBefore = User::NTickCount(); //microsecond
528 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
529 TUint32 timestampAfter = User::NTickCount();
530 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
531 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
532 INFO_PRINTF1(_L(" Check that main thread was not stalled at eglClientWaitSyncKHR()"));
533 TEST(timeElapsed < iThreshold);
535 //set to unsignal state
536 res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_UNSIGNALED_KHR);
537 TEST(res == EGL_TRUE);
538 CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR);
541 Test_MultiThreadL(1, EFalse);
543 //Stall the main thread
544 timestampBefore = User::NTickCount();
545 resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
546 timestampAfter = User::NTickCount();
547 timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
549 INFO_PRINTF5(_L("Main thread waited on eglClientWaitSyncKHR for %d usec (threshold was [%d + %d +- %d])"),timeElapsed, iDelaySignalling*2, iTimeOverhead, iThreshold);
550 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
551 TEST(Abs(timeElapsed - (iDelaySignalling*2 + iTimeOverhead)) < iThreshold);
553 INFO_PRINTF1(_L("Delete sync object"));
554 res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
555 TEST(res == EGL_TRUE);
559 CloseTMSGraphicsStep();
560 return TestStepResult();
563 void CEglTest_SyncObject_Positive_WaitSignal2::doThreadFunctionL(TInt aIdx)
565 TUint32 timeOverheadStart = User::NTickCount();
566 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_WaitSignal2::doThreadFunctionL, Thread %d"),aIdx);
567 ASSERT_TRUE(aIdx==0);
569 User::After(iDelaySignalling);
570 INFO_PRINTF1(_L("unsignal sync object from thread A"));
571 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_UNSIGNALED_KHR);
572 TEST(resSignal == EGL_TRUE);
573 CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR);
575 User::After(iDelaySignalling);
576 INFO_PRINTF1(_L("signal sync object from thread A"));
577 TUint32 timeOverheadEnd = User::NTickCount();
578 iTimeOverhead = ElapsedTime(timeOverheadEnd, timeOverheadStart) - iDelaySignalling*2;
579 resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
580 TEST(resSignal == EGL_TRUE);
581 CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_SIGNALED_KHR);
585 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-020
594 To check that the deletion of the sync object triggers the signalling
597 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
598 The type parameter is set to EGL_SYNC_REUSABLE_KHR
600 3. Stall the main thread by calling eglClientWaitSyncKHR() on the sync object with timeout value EGL_FOREVER_KHR
601 4. Delete the sync object from the thread A
603 @SYMTestExpectedResults
604 3. The main thread which waits for the signal must be stalled
605 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
607 TVerdict CEglTest_SyncObject_Positive_WaitDelete::doTestStepL()
609 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-020"));
610 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitDelete::doTestStepL"));
612 if(!iIsSyncObjectExtensionSupported)
614 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
617 CloseTMSGraphicsStep();
618 return TestStepResult();
621 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
624 iEglSess->InitializeL();
627 INFO_PRINTF1(_L("Create sync object"));
628 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
629 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
632 Test_MultiThreadL(1, EFalse);
634 //Stall the main thread
635 TUint32 timestampBefore = User::NTickCount(); //microsecond
636 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
637 TUint32 timestampAfter = User::NTickCount();
638 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
640 INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
641 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
642 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
646 CloseTMSGraphicsStep();
647 return TestStepResult();
650 void CEglTest_SyncObject_Positive_WaitDelete::doThreadFunctionL(TInt aIdx)
652 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_WaitDelete::doThreadFunctionL, Thread %d"),aIdx);
653 ASSERT_TRUE(aIdx==0);
655 User::After(iDelaySignalling);
656 INFO_PRINTF1(_L("Delete sync object from thread A"));
657 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
658 TEST(res == EGL_TRUE);
662 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-025
671 To check that client will be unblocked once the timeout has expired even if there is no signalling occurred.
674 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
675 The type parameter is set to EGL_SYNC_REUSABLE_KHR
676 2. Take the start time stamp
677 3. Call eglClientWaitSyncKHR() on the sync object with timeout value equals five seconds
678 4. Take the end timestamp
679 5. Retrieve EGL_SYNC_STATUS attribute of the sync object
680 6. Destroy the sync object
682 @SYMTestExpectedResults
683 3. The client thread should stay blocked until timeout is expired
684 4. Check that (timestamp End - timestamp Before) equals (roughly) timeout and an error code returned by
685 eglClientWaitSyncKHR is EGL_TIMEOUTE_EXPIRED_KHR
686 5. The sync object attribute EGL_SYNC_STATUS is set to EGL_UNSIGNALED_KHR
688 TVerdict CEglTest_SyncObject_Positive_WaitWithTimeoutExpired::doTestStepL()
690 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-025"));
691 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitWithTimeoutExpired::doTestStepL started...."));
693 if(!iIsSyncObjectExtensionSupported)
695 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
698 CloseTMSGraphicsStep();
699 return TestStepResult();
702 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
705 iEglSess->InitializeL();
707 INFO_PRINTF1(_L("Create sync object"));
708 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
709 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
711 // calling wait sync without signaling the object should hit the predefined timeout if set to anything different to EGL_FOREVER_KHR
712 INFO_PRINTF2(_L("Calling eglClientWaitSyncKHR on the object with a defined timeout of %d usec"), iWaitSyncTimeout);
713 EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
714 TUint32 timestampBefore = User::NTickCount();
715 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
716 TUint32 timestampAfter = User::NTickCount();
717 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
719 INFO_PRINTF4(_L("Waited on eglClientWaitSyncKHR for %d usec (threshold was [%d +- %d])"),timeElapsed, iWaitSyncTimeout, iThreshold);
720 TEST(resClientWait == EGL_TIMEOUT_EXPIRED_KHR);
721 TEST (Abs(timeElapsed - timeoutNano/1000) < iThreshold);
723 INFO_PRINTF1(_L("Check attributes..."));
724 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
725 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
727 INFO_PRINTF1(_L("Delete sync object"));
728 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
729 TEST(res == EGL_TRUE);
733 CloseTMSGraphicsStep();
734 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_WaitWithTimeoutExpired::doTestStepL completed!"));
735 return TestStepResult();
739 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-030
748 To check that client will be unblocked once the signalling occurs even if the timeout is not expired
751 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
752 The type parameter is set to EGL_SYNC_REUSABLE_KHR.
754 3. Take the start time stamp
755 4. Call eglClientWaitSyncKHR() on the sync object with timeout value equals five seconds
756 5. Signal on the sync object from thread A before timeout is expired (after 2.5 seconds).
757 6. Takes the end timestamp
758 7. Retrieve EGL_SYNC_STATUS attribute of the sync object from thread A
759 8. Destroy the sync object
761 @SYMTestExpectedResults
762 4. The client thread should be blocked
763 6. The main thread is unblocked. Check that (timestamp End - timestamp Before) equals (roughly)
764 2.5 seconds and an error code returned by eglClientWaitSyncKHR is EGL_CONDITION_SATISFIED_KHR
765 7. The sync object attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR
767 TVerdict CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doTestStepL()
769 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-030"));
770 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doTestStepL started...."));
772 if(!iIsSyncObjectExtensionSupported)
774 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
777 CloseTMSGraphicsStep();
778 return TestStepResult();
781 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
784 iEglSess->InitializeL();
786 INFO_PRINTF1(_L("Create sync object"));
787 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
788 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
790 INFO_PRINTF1(_L("Launching thread A..."));
791 Test_MultiThreadL(1, EFalse);
793 INFO_PRINTF2(_L("Main thread waiting for thread A to signal with a defined timeout of %d usec"), iWaitSyncTimeout);
794 EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
795 TUint32 timestampBefore = User::NTickCount();
796 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
797 TUint32 timestampAfter = User::NTickCount();
798 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
800 INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
801 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
802 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
804 INFO_PRINTF1(_L("Check attributes..."));
805 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
806 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
808 INFO_PRINTF1(_L("Delete sync object"));
809 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
810 TEST(res == EGL_TRUE);
814 CloseTMSGraphicsStep();
815 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doTestStepL completed!"));
816 return TestStepResult();
819 void CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doThreadFunctionL(TInt aIdx)
821 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_SignalBeforeTimeoutExpired::doThreadFunctionL, Thread %d"),aIdx);
822 ASSERT_TRUE(aIdx==0);
824 INFO_PRINTF2(_L("Wait for a bit before Signal sync object, Thread %d"),aIdx);
825 User::After(iDelaySignalling);
826 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
827 TEST(resSignal == EGL_TRUE);
828 INFO_PRINTF2(_L("Signal sync object done, Thread %d"),aIdx);
832 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-035
841 To check that client will be unblocked once the sync object has been deleted even if the timeout is not expired
844 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
845 The type parameter is set to EGL_SYNC_REUSABLE_KHR
847 3. Take the start time stamp
848 4. Stall the client thread by calling eglClientWaitSyncKHR() on the sync object with timeout value equals five seconds
849 5. Destroy the sync object from thread A before timeout is expired. (2.5 seconds)
850 6. Takes the end timestamp
851 7. Retrieve EGL_SYNC_STATUS attribute of the sync object
852 8. Destroy the sync object
854 @SYMTestExpectedResults
855 4. The main client thread should be blocked
856 5. The main thread is unblocked. Check that (timestamp End - timestamp Before) equals (roughly)
857 2.5 seconds and an error code returned by eglClientWaitSyncKHR is EGL_CONDITION_SATISFIED_KHR
858 7. eglGetSyncAttribKHR() returns EGL_FALSE and EGL_BAD_PARAMETER is generated
860 TVerdict CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doTestStepL()
862 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-035"));
863 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doTestStepL started...."));
865 if(!iIsSyncObjectExtensionSupported)
867 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
870 CloseTMSGraphicsStep();
871 return TestStepResult();
874 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
877 iEglSess->InitializeL();
879 INFO_PRINTF1(_L("Create sync object"));
880 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
881 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
883 INFO_PRINTF1(_L("Launching thread A..."));
884 Test_MultiThreadL(1, EFalse);
886 INFO_PRINTF2(_L("Main thread waiting for thread A to signal with a defined timeout of %d usec"), iWaitSyncTimeout);
887 EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
888 TUint32 timestampBefore = User::NTickCount();
889 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
890 TUint32 timestampAfter = User::NTickCount();
891 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
893 INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec before sync object was deleted (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
894 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
895 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
897 INFO_PRINTF1(_L("Check attributes..."));
898 EGLint syncTypeValue=-1;
899 EGLBoolean ret = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject,EGL_SYNC_TYPE_KHR,&syncTypeValue);
900 TEST(ret == EGL_FALSE);
901 EGLint error = eglGetError();
902 TEST(error == EGL_BAD_PARAMETER);
903 TEST(syncTypeValue == -1); // due to the error, it wasn't properly retrieved
905 INFO_PRINTF1(_L("(attempt to) Delete sync object (was already deleted by a worker thread)"));
906 ret = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
907 TEST(ret == EGL_FALSE);
908 error = eglGetError();
909 TEST(error == EGL_BAD_PARAMETER);
913 CloseTMSGraphicsStep();
914 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doTestStepL completed!"));
915 return TestStepResult();
918 void CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doThreadFunctionL(TInt aIdx)
920 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_DeleteBeforeTimeoutExpired::doThreadFunctionL, Thread %d"),aIdx);
921 ASSERT_TRUE(aIdx==0);
923 INFO_PRINTF2(_L("Wait for a bit before destroying sync object, Thread %d"),aIdx);
924 User::After(iDelaySignalling);
925 TInt res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
926 TEST(res == EGL_TRUE);
927 INFO_PRINTF2(_L("Delete sync object done, Thread %d"),aIdx);
931 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-040
940 To check that all threads waiting for the signal on the same sync object will be unblocked before the timeout has expired.
943 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
944 The type parameter is set to EGL_SYNC_REUSABLE_KHR
945 2. Launch two threads A and B.
946 3. Call eglClientWaitSyncKHR() (from threads A and B) on the sync object with timeout value equals five seconds
947 in thread A and EGL_FOREVER_KHR in thread B.
948 4. Signal on the sync object with the flag EGL_SIGNALED_KHR from the main thread before timeout expired (after 2.5 seconds)
949 5. Retrieve EGL_SYNC_STATUS attribute of the sync object from the main thread
950 6. Destroy the sync object
952 @SYMTestExpectedResults
953 3. Threads A and B will be stalled
954 4. Both threads A and B will be unblocked and a value returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR.
955 5. The sync object attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR
957 TVerdict CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doTestStepL()
959 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-040"));
960 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doTestStepL started...."));
962 if(!iIsSyncObjectExtensionSupported)
964 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
967 CloseTMSGraphicsStep();
968 return TestStepResult();
971 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
974 iEglSess->InitializeL();
976 INFO_PRINTF1(_L("Create sync object"));
977 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
978 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
980 INFO_PRINTF1(_L("Launching threads A and B..."));
981 Test_MultiThreadL(2, EFalse);
983 INFO_PRINTF1(_L("Main thread, wait for a bit before Signal sync object"));
984 User::After(iDelaySignalling);
985 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
986 TEST(resSignal == EGL_TRUE);
987 INFO_PRINTF1(_L("Main thread Signal sync object done"));
989 INFO_PRINTF1(_L("Check attributes..."));
990 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
991 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
993 INFO_PRINTF1(_L("Delete sync object"));
994 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
995 TEST(res == EGL_TRUE);
999 CloseTMSGraphicsStep();
1000 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doTestStepL completed!"));
1001 return TestStepResult();
1004 void CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doThreadFunctionL(TInt aIdx)
1006 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Multithread_SignalBeforeTimeout::doThreadFunctionL, Thread %d"), aIdx);
1007 ASSERT_TRUE(aIdx==0 || aIdx==1);
1009 //Thread 0 waits for the main thread to signal the sync object, and exits
1012 INFO_PRINTF2(_L("Thread %d waiting for main thread to signal with a timeout EGL_FOREVER_KHR"), aIdx);
1013 TUint32 timestampBefore = User::NTickCount();
1014 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
1015 TUint32 timestampAfter = User::NTickCount();
1016 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1018 INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was signaled (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
1019 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1020 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
1022 //Thread 1 waits for the main thread to signal the sync object, and exits
1025 INFO_PRINTF3(_L("Thread %d waiting for main thread to signal with a defined timeout of %d"), aIdx, iWaitSyncTimeout);
1026 EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
1027 TUint32 timestampBefore = User::NTickCount();
1028 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
1029 TUint32 timestampAfter = User::NTickCount();
1030 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1032 INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was signaled (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
1033 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1034 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
1039 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-045
1048 To check that a thread resumed due to timeout will not unblock another thread waiting for the signal.
1051 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
1052 The type parameter is set to EGL_SYNC_REUSABLE_KHR
1053 2. Launch two threads A and B.
1054 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.
1055 4. Wait for approximately 7.5 seconds
1056 5. Retrieve EGL_SYNC_STATUS attribute of the sync object from the main thread
1057 6. Signal on the sync object with the flag EGL_SIGNALED_KHR from the main thread
1058 7. Retrieve EGL_SYNC_STATUS attribute of the sync object from the main thread
1059 8. Destroy the sync object
1061 @SYMTestExpectedResults
1062 3.Threads A and B will be stalled
1063 4. Thread A will be unblocked after approximately 5 seconds and a value returned by eglClientWaitSyncKHR() is set to EGL_TIMEOUT_EXPIRED_KHR.
1064 5. EGL_SYNC_STATUS attribute of the sync object is set to EGL_UNSIGNALED_KHR
1065 6. Threads B will be unblocked and a value returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR.
1066 7. The sync object attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR
1068 TVerdict CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doTestStepL()
1070 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-045"));
1071 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doTestStepL started...."));
1073 if(!iIsSyncObjectExtensionSupported)
1075 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
1077 RecordTestResultL();
1078 CloseTMSGraphicsStep();
1079 return TestStepResult();
1082 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
1084 CreateEglSessionL();
1085 iEglSess->InitializeL();
1087 INFO_PRINTF1(_L("Create sync object"));
1088 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1089 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
1091 INFO_PRINTF1(_L("Launching threads A and B..."));
1092 Test_MultiThreadL(2, EFalse);
1093 TUint32 timeOverheadStart = User::NTickCount();
1095 INFO_PRINTF1(_L("Main thread, wait for a long time, no Signal sync object yet"));
1096 User::After(iLongDelaySignalling);
1098 INFO_PRINTF1(_L("Check attributes..."));
1099 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
1100 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
1102 INFO_PRINTF1(_L("Main thread, Signal sync object now"));
1103 TUint32 timeOverheadEnd = User::NTickCount();
1104 iTimeOverhead = ElapsedTime(timeOverheadEnd, timeOverheadStart) - iLongDelaySignalling;
1105 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
1106 TEST(resSignal == EGL_TRUE);
1107 INFO_PRINTF1(_L("Main thread, Signal sync object done"));
1109 INFO_PRINTF1(_L("Check attributes..."));
1110 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
1111 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
1113 INFO_PRINTF1(_L("Delete sync object"));
1114 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
1115 TEST(res == EGL_TRUE);
1118 RecordTestResultL();
1119 CloseTMSGraphicsStep();
1120 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doTestStepL completed!"));
1121 return TestStepResult();
1124 void CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doThreadFunctionL(TInt aIdx)
1126 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Multithread_SignalAfterTimeout::doThreadFunctionL, Thread %d"),aIdx);
1127 ASSERT_TRUE(aIdx==0 || aIdx==1);
1129 //Thread 0 waits for the main thread to signal the sync object, and exits
1132 INFO_PRINTF2(_L("Thread %d waiting for main thread to signal with a timeout EGL_FOREVER_KHR"), aIdx);
1133 TUint32 timestampBefore = User::NTickCount();
1134 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
1135 TUint32 timestampAfter = User::NTickCount();
1136 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1138 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);
1139 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1140 TEST (Abs(timeElapsed - (iLongDelaySignalling + iTimeOverhead)) < iThreshold);
1142 //Thread 1 waits for the main thread to signal the sync object, and exits
1145 INFO_PRINTF3(_L("Thread %d waiting for main thread to signal with a defined timeout of %d"), aIdx, iWaitSyncTimeout);
1146 EGLTimeKHR timeoutNano = (TUint64)iWaitSyncTimeout * 1000; // EGLTimeKHR is in nanoseconds!!
1147 TUint32 timestampBefore = User::NTickCount();
1148 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,timeoutNano);
1149 TUint32 timestampAfter = User::NTickCount();
1150 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1152 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);
1153 TEST(resClientWait == EGL_TIMEOUT_EXPIRED_KHR);
1154 TEST (Abs(timeElapsed - iWaitSyncTimeout) < iThreshold);
1159 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-050
1168 To check that signalling on one sync object won't unblock the thread waiting on another sync object.
1171 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
1172 2. Launch two threads A and B.
1173 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.
1174 4. Signal on S1 with the flag EGL_SIGNALED_KHR from main thread
1175 5. Retrieve EGL_SYNC_STATUS attribute of S1 and S2 from main thread
1176 6. Signal on S2 with the flag EGL_SIGNALED_KHR from main thread
1177 7. Retrieve EGL_SYNC_STATUS attribute of S1 and S2 from main thread
1178 8. Destroy the sync objects
1180 @SYMTestExpectedResults
1181 3. Threads A and B will be stalled
1182 4. Thread A will be unblocked and an error code returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR.
1183 Thread B stays blocked.
1184 5. The S1 attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR, S2 attribute EGL_SYNC_STATUS is set to EGL_UNSIGNALED_KHR
1185 6. Thread B will be unblocked and an error code returned by eglClientWaitSyncKHR() is set to EGL_CONDITION_SATISFIED_KHR.
1186 7. The S1 & S2 attribute EGL_SYNC_STATUS is set to EGL_SIGNALED_KHR
1188 TVerdict CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doTestStepL()
1190 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-050"));
1191 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doTestStepL started...."));
1193 if(!iIsSyncObjectExtensionSupported)
1195 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
1197 RecordTestResultL();
1198 CloseTMSGraphicsStep();
1199 return TestStepResult();
1202 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
1204 CreateEglSessionL();
1205 iEglSess->InitializeL();
1207 INFO_PRINTF1(_L("Create two sync objects"));
1208 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1209 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
1210 iSyncObject2 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1211 TESTL(iSyncObject2 != EGL_NO_SYNC_KHR);
1213 INFO_PRINTF1(_L("Launching threads A and B..."));
1214 Test_MultiThreadL(2, EFalse);
1215 TUint32 timeOverheadStart = User::NTickCount();
1217 INFO_PRINTF1(_L("Main thread, wait for a bit before Signal sync object number 1"));
1218 User::After(iDelaySignalling);
1219 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
1220 TEST(resSignal == EGL_TRUE);
1221 INFO_PRINTF1(_L("Main thread Signal sync object number 1 done"));
1223 INFO_PRINTF1(_L("Check attributes for sync object number 1..."));
1224 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
1225 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
1227 INFO_PRINTF1(_L("Check attributes for sync object number 2..."));
1228 // the CheckSyncAttrib uses iSyncObject, so we need to replace it, and restore it later
1229 EGLSyncKHR oldSyncObject=iSyncObject;
1230 iSyncObject=iSyncObject2;
1231 CheckSyncAttrib(EGL_SYNC_TYPE_KHR, EGL_SYNC_REUSABLE_KHR);
1232 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
1233 iSyncObject=oldSyncObject;
1235 INFO_PRINTF1(_L("Main thread, wait for a bit before Signal sync object number 2"));
1236 User::After(iDelaySignalling);
1238 TUint32 timeOverheadEnd = User::NTickCount();
1239 iTimeOverhead = ElapsedTime(timeOverheadEnd, timeOverheadStart) - iDelaySignalling*2;
1240 resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject2, EGL_SIGNALED_KHR);
1241 TEST(resSignal == EGL_TRUE);
1242 INFO_PRINTF1(_L("Main thread Signal sync object number 2 done"));
1244 INFO_PRINTF1(_L("Check attributes for sync object number 1..."));
1245 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
1246 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
1248 INFO_PRINTF1(_L("Check attributes for sync object number 2..."));
1249 oldSyncObject=iSyncObject;
1250 iSyncObject=iSyncObject2;
1251 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
1252 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
1253 iSyncObject=oldSyncObject;
1255 INFO_PRINTF1(_L("Delete both sync objects"));
1256 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
1257 TEST(res == EGL_TRUE);
1258 res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject2);
1259 TEST(res == EGL_TRUE);
1262 RecordTestResultL();
1263 CloseTMSGraphicsStep();
1264 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doTestStepL completed!"));
1265 return TestStepResult();
1268 void CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doThreadFunctionL(TInt aIdx)
1270 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Multithread_WaitOnTwoSyncObject::doThreadFunctionL, Thread %d"),aIdx);
1271 ASSERT_TRUE(aIdx==0 || aIdx==1);
1273 //Thread 0 waits for the main thread to signal the sync object, and exits
1276 INFO_PRINTF2(_L("Thread %d waiting for main thread to signal object 1 with a timeout EGL_FOREVER_KHR"), aIdx);
1277 TUint32 timestampBefore = User::NTickCount();
1278 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
1279 TUint32 timestampAfter = User::NTickCount();
1280 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1282 INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was signaled (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
1283 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1284 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
1286 //Thread 1 waits for the main thread to signal the sync object, and exits
1289 INFO_PRINTF2(_L("Thread %d waiting for main thread to signal object 2 with a timeout EGL_FOREVER_KHR"), aIdx);
1290 TUint32 timestampBefore = User::NTickCount();
1291 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject2,0,EGL_FOREVER_KHR);
1292 TUint32 timestampAfter = User::NTickCount();
1293 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1295 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);
1296 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1297 TEST (Abs(timeElapsed - (2*iDelaySignalling + iTimeOverhead)) < iThreshold);
1302 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-055
1311 To check that if zero timeout is passed to eglClientWaitSyncKHR(), the function just test the current status without attempt to stall the client thread.
1314 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
1315 The type parameter is set to EGL_SYNC_REUSABLE_KHR
1316 2. Take timestamp before
1317 3. Call eglClientWaitSyncKHR() on the sync object with timeout value equals to zero
1318 4. Take timestamp after
1319 5. Call eglSignalSyncKHR on the sync object with the flag EGL_SIGNALED_KHR
1320 6. Repeat steps 2 to 4
1321 7. Destroy the sync object
1323 @SYMTestExpectedResults
1324 3. The client thread is not stalled. The function eglClientWaitSyncKHR() should return EGL_TIMEOUT_EXPIRED_KHR.
1325 4. The difference timestamp (after - before) should be less than a half second
1326 3.1 The client thread is not stalled. The function eglClientWaitSyncKHR() should return EGL_CONDITION_SATISFIED_KHR.
1327 4.1 The difference timestamp (after - before) should be less than a half second
1329 TVerdict CEglTest_SyncObject_Positive_Wait_TestMode::doTestStepL()
1331 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-055"));
1332 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Wait_TestMode::doTestStepL started...."));
1334 if(!iIsSyncObjectExtensionSupported)
1336 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
1338 RecordTestResultL();
1339 CloseTMSGraphicsStep();
1340 return TestStepResult();
1343 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
1345 CreateEglSessionL();
1346 iEglSess->InitializeL();
1348 INFO_PRINTF1(_L("Create sync object"));
1349 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1350 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
1352 // calling wait sync without signaling the object, but with timeout set to 0 ==> no stalling
1353 INFO_PRINTF1(_L("Calling eglClientWaitSyncKHR on the object, without signaling the object, but with timeout set to 0"));
1354 TUint32 timestampBefore = User::NTickCount();
1355 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,0);
1356 TUint32 timestampAfter = User::NTickCount();
1357 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1359 INFO_PRINTF3(_L("Check it didn't wait on eglClientWaitSyncKHR. Elapsed time was %d usec (threshold was [%d])"),timeElapsed, iThreshold);
1360 TEST(resClientWait == EGL_TIMEOUT_EXPIRED_KHR);
1361 TEST (timeElapsed < iThreshold);
1363 INFO_PRINTF1(_L("Check attributes..."));
1364 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
1365 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR);
1367 INFO_PRINTF1(_L("Signal sync object"));
1368 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
1369 TEST(resSignal == EGL_TRUE);
1371 INFO_PRINTF1(_L("Repeat same step, calling eglClientWaitSyncKHR with timeout set to 0"));
1372 timestampBefore = User::NTickCount();
1373 resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,0);
1374 timestampAfter = User::NTickCount();
1375 timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1377 INFO_PRINTF3(_L("Check it didn't wait on eglClientWaitSyncKHR. Elapsed time was %d usec (threshold was [%d])"),timeElapsed, iThreshold);
1378 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1379 TEST (timeElapsed < iThreshold);
1381 INFO_PRINTF1(_L("Check attributes..."));
1382 CheckSyncAttrib(EGL_SYNC_TYPE_KHR,EGL_SYNC_REUSABLE_KHR);
1383 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_SIGNALED_KHR);
1385 INFO_PRINTF1(_L("Delete sync object"));
1386 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
1387 TEST(res == EGL_TRUE);
1390 RecordTestResultL();
1391 CloseTMSGraphicsStep();
1392 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Wait_TestMode::doTestStepL completed!"));
1393 return TestStepResult();
1397 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-060
1406 To check that deletion of the sync object will unblock all threads waiting for the signal.
1409 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
1410 The type parameter is set to EGL_SYNC_REUSABLE_KHR
1411 2. Launch threads A and B
1412 3. Call eglClientWaitSyncKHR() on the sync object in main thread and thread A.
1413 4. Destroy the sync object from thread B
1415 @SYMTestExpectedResults
1416 3. Main thread and thread A will be stalled
1417 4. All client threads which waited for the signal must be unblocked as if eglSignalSyncKHR() has been called.
1418 The function eglClientWaitSyncKHR should return EGL_CONDITION_SATISFIED_KHR
1420 TVerdict CEglTest_SyncObject_Positive_Multithread_Deletion::doTestStepL()
1422 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-060"));
1423 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Multithread_Deletion::doTestStepL started...."));
1425 if(!iIsSyncObjectExtensionSupported)
1427 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
1429 RecordTestResultL();
1430 CloseTMSGraphicsStep();
1431 return TestStepResult();
1434 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
1436 CreateEglSessionL();
1437 iEglSess->InitializeL();
1439 INFO_PRINTF1(_L("Create sync object"));
1440 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1441 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
1443 INFO_PRINTF1(_L("Launching threads A and B..."));
1444 Test_MultiThreadL(2, EFalse);
1446 INFO_PRINTF1(_L("Main thread waiting for thread B to destroy the sync object, with timeout EGL_FOREVER_KHR"));
1447 TUint32 timestampBefore = User::NTickCount();
1448 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
1449 TUint32 timestampAfter = User::NTickCount();
1450 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1452 INFO_PRINTF4(_L("Main thread waited on eglClientWaitSyncKHR for %d usec before sync object was deleted (threshold was [%d +- %d])"),timeElapsed, iDelaySignalling, iThreshold);
1453 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1454 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
1456 INFO_PRINTF1(_L("Check attributes..."));
1457 EGLint syncTypeValue=-1;
1458 EGLBoolean ret = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject,EGL_SYNC_TYPE_KHR,&syncTypeValue);
1459 TEST(ret == EGL_FALSE);
1460 EGLint error = eglGetError();
1461 TEST(error == EGL_BAD_PARAMETER);
1462 TEST(syncTypeValue == -1); // due to the error, it wasn't properly retrieved
1464 INFO_PRINTF1(_L("(attempt to) Delete sync object (was already deleted by a worker thread)"));
1465 ret = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
1466 TEST(ret == EGL_FALSE);
1467 error = eglGetError();
1468 TEST(error == EGL_BAD_PARAMETER);
1471 RecordTestResultL();
1472 CloseTMSGraphicsStep();
1473 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_Multithread_Deletion::doTestStepL completed!"));
1474 return TestStepResult();
1477 void CEglTest_SyncObject_Positive_Multithread_Deletion::doThreadFunctionL(TInt aIdx)
1479 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Multithread_Deletion::doThreadFunctionL, Thread %d"),aIdx);
1480 ASSERT_TRUE(aIdx==0 || aIdx==1);
1482 //Thread 0 waits for a the thread B to delete the sync object, and exits
1485 INFO_PRINTF2(_L("Thread %d waiting for thread B to destroy the sync object, with timeout EGL_FOREVER_KHR"), aIdx);
1486 TUint32 timestampBefore = User::NTickCount();
1487 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
1488 TUint32 timestampAfter = User::NTickCount();
1489 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1491 INFO_PRINTF5(_L("Thread %d waited on eglClientWaitSyncKHR for %d usec before sync object was deleted (threshold was [%d +- %d])"), aIdx, timeElapsed, iDelaySignalling, iThreshold);
1492 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1493 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
1495 //Thread 1 waits for a certain amount of time, deletes the sync object and exits
1498 INFO_PRINTF2(_L("Wait for a bit before destroying sync object, Thread %d"),aIdx);
1499 User::After(iDelaySignalling);
1500 TInt res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
1501 TEST(res == EGL_TRUE);
1502 INFO_PRINTF2(_L("Delete sync object done, Thread %d"),aIdx);
1503 //This Thread now will just exit
1508 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-065
1517 To exercise sync object functionality in stress conditions.
1520 1. Create three sync objects (S1, S2, S3) for the default display with no attributes are specified (containing only EGL_NONE).
1521 The type parameter is set to EGL_SYNC_REUSABLE_KHR.
1522 2. Launch 2 threads (A and B)
1523 3. Make the threads A and B waiting on sync objects S2 and S3 respectively.
1524 4. Make consequential signalling in that order: Client-> A->B->Client->... for some period of time.
1525 Each thread signals the next thread in the chain and then stalls itself on the corresponding sync object.
1526 (Whenever each thread is unstalled, corresponding sync object should be reset by unsignalling it.)
1527 Main thread is waiting on S1
1528 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
1529 6. Delete the sync objects
1531 @SYMTestExpectedResults
1532 4. The functionality is robust, transition from "unsignaled" to "signaled"
1533 state always unblocks the threads
1535 TVerdict CEglTest_SyncObject_Positive_Stress::doTestStepL()
1537 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-065"));
1538 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Stress::doTestStepL"));
1540 if(!iIsSyncObjectExtensionSupported)
1542 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
1544 RecordTestResultL();
1545 CloseTMSGraphicsStep();
1546 return TestStepResult();
1549 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
1551 CreateEglSessionL();
1552 iEglSess->InitializeL();
1554 INFO_PRINTF1(_L("Create sync objects"));
1555 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1556 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
1557 iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1558 TESTL(iSyncObject1 != EGL_NO_SYNC_KHR);
1559 iSyncObject2 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1560 TESTL(iSyncObject2 != EGL_NO_SYNC_KHR);
1562 iLastThreadToSignal = 2;
1564 //launch threadA & threadB
1565 Test_MultiThreadL(2, EFalse);
1566 User::After(iDelaySignalling); //to allow threads start up before we signal
1568 for(TInt index = 0; index < iNumStressIterations; index++)
1570 iLastThreadToSignal = 2;
1571 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject1,EGL_SIGNALED_KHR );
1572 TEST(resSignal == EGL_TRUE);
1574 EGLint res = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
1575 TEST(iLastThreadToSignal == 1);
1576 TEST(res == EGL_CONDITION_SATISFIED_KHR);
1577 resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_UNSIGNALED_KHR );//to set the status of iSyncObject EGL_UNSIGNALED_KHR
1578 TEST(resSignal == EGL_TRUE);
1579 User::After(0);//to yield the processor
1582 INFO_PRINTF2(_L("Threads have been signalling for %d times"), iNumStressIterations);
1583 INFO_PRINTF1(_L("Delete sync objects"));
1584 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
1585 TEST(res == EGL_TRUE);
1586 res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject1);
1587 TEST(res == EGL_TRUE);
1588 res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject2);
1589 TEST(res == EGL_TRUE);
1592 RecordTestResultL();
1593 CloseTMSGraphicsStep();
1594 INFO_PRINTF1(_L("End of CEglTest_SyncObject_Positive_Stress::doTestStepL"));
1595 return TestStepResult();
1598 void CEglTest_SyncObject_Positive_Stress::doThreadFunctionL(TInt aIdx)
1600 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_Stress::doThreadFunctionL, Thread %d"),aIdx);
1601 ASSERT_TRUE(aIdx==0 || aIdx==1);
1608 res = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject1,0,EGL_FOREVER_KHR);
1609 TEST(res == EGL_CONDITION_SATISFIED_KHR);
1610 User::After(0); //to yield the processor
1613 TEST(iLastThreadToSignal == 2);
1614 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject1,EGL_UNSIGNALED_KHR );//to reset the status of iSyncObject1 EGL_UNSIGNALED_KHR
1615 TEST(resSignal == EGL_TRUE);
1617 iLastThreadToSignal = 0;
1618 resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject2,EGL_SIGNALED_KHR );
1619 TEST(resSignal == EGL_TRUE);
1627 res = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject2,0,EGL_FOREVER_KHR);
1628 TEST(res == EGL_CONDITION_SATISFIED_KHR);
1629 User::After(0); //to yield the processor
1632 TEST(iLastThreadToSignal == 0);
1633 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject2,EGL_UNSIGNALED_KHR );//to reset the status of iSyncObject2 EGL_UNSIGNALED_KHR
1634 TEST(resSignal == EGL_TRUE);
1636 iLastThreadToSignal = 1;
1637 resSignal = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,EGL_SIGNALED_KHR );
1638 TEST(resSignal == EGL_TRUE);
1645 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-070
1654 To check that flushing of the client API (bit EGL_SYNC_FLUSH_COMMANDS_BIT_KHR is set
1655 for eglClientWaitSyncKHR()) doesn't cause any problems.
1658 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
1659 The type parameter is set to EGL_SYNC_REUSABLE_KHR
1660 2. Bind Open VG API.
1661 3. Create and make the context current for the bound API.
1662 4. Launch the thread A.
1663 5. Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag.
1664 6. Signal "EGL_UNSIGNALED_KHR" to the sync object.
1665 7. Bind Open GLES API.
1666 8. Repeat steps 3-6.
1667 9. Repeat step 5, but client waits in test mode (timeout is set to zero)
1668 10. Make no context current
1669 11. Repeat steps 3-5.
1670 12. Delete the sync object.
1672 @SYMTestExpectedResults
1673 All functions succeed. Setting the flag on step 5 doesn't cause any problem.
1674 9. The function eglClientWaitSyncKHR()returns EGL_TIMEOUT_EXPIRED_KHR
1676 TVerdict CEglTest_SyncObject_Positive_WaitFlush::doTestStepL()
1678 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-070"));
1679 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_WaitFlush::doTestStepL"));
1681 if(!iIsSyncObjectExtensionSupported)
1683 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
1685 RecordTestResultL();
1686 CloseTMSGraphicsStep();
1687 return TestStepResult();
1690 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
1692 CreateEglSessionL();
1693 iEglSess->InitializeL();
1695 INFO_PRINTF1(_L("Create sync object"));
1696 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1697 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
1699 INFO_PRINTF1(_L("bind OpenVG API"));
1700 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENVG_API));
1701 EGLConfig currentConfig = iEglSess->GetConfigExactMatchL(EPixmapAttribsColor64K);
1702 INFO_PRINTF1(_L("Create and make the context current for the bound API"));
1703 EGLContext context = eglCreateContext(iDisplay, currentConfig, EGL_NO_CONTEXT, NULL);
1704 ASSERT_EGL_TRUE(context != EGL_NO_CONTEXT);
1706 //Create an OffScreen Pixmap to be used as an OpenVg target
1707 TSgImageInfoTest imageInfo = TSgImageInfoTest();
1708 imageInfo.iSizeInPixels = TSize(200, 200);
1709 imageInfo.iPixelFormat = EUidPixelFormatRGB_565;
1710 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
1711 imageInfo.iUsage = ESgUsageBitOpenVgSurface;
1713 imageInfo.iUsage = ESgUsageOpenVgTarget;
1715 RSgImage sgImageTarget;
1716 CleanupClosePushL(sgImageTarget);
1717 TInt ret2 = sgImageTarget.Create(imageInfo, NULL, NULL);
1718 ASSERT_EQUALS(ret2, KErrNone);
1719 EGLSurface surface = eglCreatePixmapSurface(iDisplay, currentConfig,&sgImageTarget, KPixmapAttribsNone );
1720 ASSERT_EGL_TRUE(surface != EGL_NO_SURFACE);
1722 TSurfaceToDestroy surfaceToDestroy;
1723 surfaceToDestroy.iSurface = surface;
1724 surfaceToDestroy.iDisplay = iDisplay;
1725 CleanupStack::PushL(TCleanupItem(DestroySurface, &surfaceToDestroy));
1727 INFO_PRINTF1(_L("Calling eglMakeCurrent"));
1728 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context));
1731 Test_MultiThreadL(1, EFalse);
1732 INFO_PRINTF1(_L("Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag"));
1733 TUint32 timestampBefore = User::NTickCount();
1734 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,EGL_FOREVER_KHR);
1735 TUint32 timestampAfter = User::NTickCount();
1736 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1737 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1738 TEST(Abs(timeElapsed - iDelaySignalling) < iThreshold);
1739 EGLBoolean resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_UNSIGNALED_KHR);
1740 TEST(resSignal == EGL_TRUE);
1742 //make no context current
1743 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1745 //Wait for the thread to finish before starting the next part of the test.
1746 Test_MultiThread_WaitL(ETrue, TThreadStatus::ELogin);
1748 //---- the same test but for OpenGLES
1749 INFO_PRINTF1(_L("bind OpenGLES API"));
1750 ASSERT_EGL_TRUE(eglBindAPI(EGL_OPENGL_ES_API));
1751 EGLContext context1 = eglCreateContext(iDisplay, currentConfig, EGL_NO_CONTEXT, NULL);
1752 ASSERT_EGL_TRUE(context1 != EGL_NO_CONTEXT);
1754 INFO_PRINTF1(_L("Calling eglMakeCurrent"));
1755 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, surface, surface, context1));
1758 Test_MultiThreadL(1, EFalse);
1759 INFO_PRINTF1(_L("Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag"));
1760 timestampBefore = User::NTickCount();
1761 resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,EGL_FOREVER_KHR);
1762 timestampAfter = User::NTickCount();
1763 timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1764 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1765 TEST(Abs(timeElapsed - iDelaySignalling) < iThreshold);
1766 resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_UNSIGNALED_KHR);
1767 TEST(resSignal == EGL_TRUE);
1769 //repeat the same, but in test mode (timeout is set to zero)
1770 INFO_PRINTF1(_L("Wait on sync object by calling eglClientWaitSyncKHR(), pass on EGL_SYNC_FLUSH_COMMANDS_BIT_KHR as a flag"));
1771 timestampBefore = User::NTickCount();
1772 resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,0);
1773 timestampAfter = User::NTickCount();
1774 timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1775 TEST(resClientWait == EGL_TIMEOUT_EXPIRED_KHR);//the sync object is in "unsignaled" state
1776 TEST(timeElapsed < iThreshold);
1777 resSignal = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_UNSIGNALED_KHR);
1778 TEST(resSignal == EGL_TRUE);
1780 INFO_PRINTF1(_L("Make no context current"));
1781 ASSERT_EGL_TRUE(eglMakeCurrent(iDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT));
1783 //Wait for the thread to finish before starting the next part of the test.
1784 Test_MultiThread_WaitL(ETrue, TThreadStatus::ELogin);
1786 //now try to wait with flushing bit on (EGL_SYNC_FLUSH_COMMANDS_BIT_KHR). The flag will be ignored
1788 Test_MultiThreadL(1, EFalse);
1790 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"));
1791 timestampBefore = User::NTickCount();
1792 resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,EGL_SYNC_FLUSH_COMMANDS_BIT_KHR,EGL_FOREVER_KHR);
1793 timestampAfter = User::NTickCount();
1794 timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1795 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1796 TEST(Abs(timeElapsed - iDelaySignalling) < iThreshold);
1798 eglDestroyContext(iDisplay, context1); //Closing eglContext
1799 eglDestroyContext(iDisplay, context); //Closing eglContext
1800 CleanupStack::PopAndDestroy(2, &sgImageTarget);
1801 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
1802 TEST(res == EGL_TRUE);
1805 RecordTestResultL();
1806 CloseTMSGraphicsStep();
1807 INFO_PRINTF1(_L("End of CEglTest_SyncObject_Positive_WaitFlush::doTestStepL"));
1808 return TestStepResult();
1811 void CEglTest_SyncObject_Positive_WaitFlush::doThreadFunctionL(TInt aIdx)
1813 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_WaitFlush::doThreadFunctionL, Thread %d"),aIdx);
1814 ASSERT_TRUE(aIdx==0);
1816 User::After(TTimeIntervalMicroSeconds32(iDelaySignalling));
1817 EGLBoolean res = iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR);
1818 TEST(res == EGL_TRUE);
1822 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-075
1831 To check that eglTerminate() destroys sync object associated with display.
1834 1. Create sync object for the default display. NULL are specified in attribute_list.
1835 The type parameter is set to EGL_SYNC_REUSABLE_KHR.
1836 2. Call eglTerminate() without deleting the sync objects.
1838 @SYMTestExpectedResults
1839 1. Sync object handle doesn't equal to EGL_NO_SYNC_KHR.
1840 2. Test completes without any error and panic. No memory leak.
1843 TVerdict CEglTest_SyncObject_Positive_Terminate::doTestStepL()
1845 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-075"));
1846 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_Terminate::doTestStepL"));
1848 if(!iIsSyncObjectExtensionSupported)
1850 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
1852 RecordTestResultL();
1853 CloseTMSGraphicsStep();
1854 return TestStepResult();
1857 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
1859 CreateEglSessionL();
1860 iEglSess->InitializeL();
1862 INFO_PRINTF1(_L("Create sync object - default display, NULL at attributes, type parameter set to EGL_SYNC_REUSABLE_KHR"));
1863 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, NULL);
1864 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
1866 //check attributes of the sync object.
1867 INFO_PRINTF1(_L("Check attributes of sync object"));
1868 CheckSyncAttrib(EGL_SYNC_TYPE_KHR, EGL_SYNC_REUSABLE_KHR);
1869 CheckSyncAttrib(EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR);
1871 TRAPD(result, TerminateDisplayL());
1872 TEST(result == KErrNone);
1875 RecordTestResultL();
1876 CloseTMSGraphicsStep();
1877 return TestStepResult();
1881 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-080
1890 To check that eglTerminate() destroys sync object and will unblock thread waiting for the signal.
1893 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
1894 The type parameter is set to EGL_SYNC_REUSABLE_KHR
1896 3. Call eglClientWaitSyncKHR() on the sync object in thread A.
1897 4. Call eglTerminate() from main thread without deleting the sync object.
1899 @SYMTestExpectedResults
1900 1. Sync object handle doesn't equal to EGL_NO_SYNC_KHR.
1901 3. Thread A will be stalled
1902 4. Thread A which waited for the signal must be unblocked as if eglSignalSyncKHR() has been called.
1903 The function eglClientWaitSyncKHR should return EGL_CONDITION_SATISFIED_KHR.
1904 Test completes without any error and panic. No memory leak.
1907 TVerdict CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doTestStepL()
1909 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-080"));
1910 INFO_PRINTF1(_L("CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doTestStepL started...."));
1912 if(!iIsSyncObjectExtensionSupported)
1914 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
1916 RecordTestResultL();
1917 CloseTMSGraphicsStep();
1918 return TestStepResult();
1921 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
1923 CreateEglSessionL();
1924 iEglSess->InitializeL();
1926 INFO_PRINTF1(_L("Create sync object"));
1927 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
1928 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
1930 INFO_PRINTF1(_L("Launching threads A"));
1931 Test_MultiThreadL(1, EFalse);
1933 INFO_PRINTF1(_L("Wait for a bit before eglTerminate"));
1934 User::After(iDelaySignalling);
1936 TRAPD(result, TerminateDisplayL());
1937 TEST(result == KErrNone);
1940 RecordTestResultL();
1941 CloseTMSGraphicsStep();
1942 INFO_PRINTF1(_L("....CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doTestStepL completed!"));
1943 return TestStepResult();
1946 void CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doThreadFunctionL(TInt aIdx)
1948 INFO_PRINTF2(_L("CEglTest_SyncObject_Positive_TerminateBeforeTimeoutExpired::doThreadFunctionL, Thread %d"),aIdx);
1949 ASSERT_TRUE(aIdx==0);
1951 INFO_PRINTF2(_L("Thread %d waiting for main thread to call eglTerminate(), with timeout EGL_FOREVER_KHR"), aIdx);
1952 TUint32 timestampBefore = User::NTickCount();
1953 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
1954 TUint32 timestampAfter = User::NTickCount();
1955 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
1957 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);
1958 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);
1959 TEST (Abs(timeElapsed - iDelaySignalling) < iThreshold);
1963 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-100
1972 To ensure that sync object API generates correct errors and returns correct
1973 value if wrong parameters supplied.
1976 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
1977 The type parameter is set to EGL_SYNC_REUSABLE_KHR
1978 2. Call all sync API for the display which doesn't exist in the system.
1979 3. Call eglCreateSyncKHR() with unsupported type parameter.
1980 4. Call eglCreateSyncKHR() with specified attributes, type parameter set to EGL_SYNC_REUSABLE_KHR
1981 5. Call eglCreateSyncKHR() with unspecified attributes, type parameter set to EGL_SYNC_REUSABLE_KHR
1982 6. Call all sync API (with the exception to eglCreateSyncKHR(...), providing invalid EGLSyncKHR as a parameter
1983 7. Call eglClientWaitSyncKHR(), providing unspecified flags.
1984 8. Call eglSignalSyncKHR(), providing unspecified status.
1985 9. Call eglGetSyncAttribSyncKHR(), providing unspecified attributes.
1986 10. Destroy the sync object
1988 @SYMTestExpectedResults
1989 2. eglCreateSyncKHR(...) should return EGL_NO_SYNC_KHR and EGL_BAD_DISPLAY error is generated.
1990 eglClientWaitSyncKHR(...), eglSignalSyncKHR(...), eglGetSyncAttribKHR(...) and eglDestroySyncKHR(...)
1991 should return EGL_FALSE and EGL_BAD_DISPLAY error is generated.
1992 3. Should return EGL_NO_SYNC_KHR and EGL_BAD_ATTRIBUTE error is generated.
1993 4.5 Should return EGL_NO_SYNC_KHR and EGL_BAD_ATTRIBUTE error is generated.
1994 6, 7, 8. Should return EGL_FALSE and EGL_BAD_PARAMETER error is generated
1995 9. Should return EGL_FALSE and EGL_BAD_ATTRIBUTE error is generated
1997 TVerdict CEglTest_SyncObject_Negative_WrongParameters::doTestStepL()
1999 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-100"));
2000 INFO_PRINTF1(_L("CEglTest_SyncObject_Negative_WrongParameters::doTestStepL"));
2002 if(!iIsSyncObjectExtensionSupported)
2004 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
2006 RecordTestResultL();
2007 CloseTMSGraphicsStep();
2008 return TestStepResult();
2011 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
2013 CreateEglSessionL();
2014 iEglSess->InitializeL();
2016 //create a sync object
2017 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
2018 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
2019 TEST(eglGetError() == EGL_SUCCESS);
2021 INFO_PRINTF1(_L("Call all sync API for the display which doesn't exist in the system"));
2022 EGLDisplay invalidDisplay = iDisplay + 1;
2023 iSyncObject1 = iPfnEglCreateSyncKHR(invalidDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
2024 TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
2025 TEST(eglGetError() == EGL_BAD_DISPLAY);
2026 EGLBoolean res = iPfnEglSignalSyncKHR(invalidDisplay,iSyncObject,EGL_UNSIGNALED_KHR );
2027 TEST(res == EGL_FALSE);
2028 TEST(eglGetError() == EGL_BAD_DISPLAY);
2029 EGLint res1 = iPfnEglClientWaitSyncKHR(invalidDisplay,iSyncObject,0,EGL_FOREVER_KHR);
2030 TEST(res1 == EGL_FALSE);
2031 TEST(eglGetError() == EGL_BAD_DISPLAY);
2033 res = iPfnEglGetSyncAttribKHR(invalidDisplay,iSyncObject,EGL_SYNC_STATUS_KHR, &value);
2034 TEST(res == EGL_FALSE);
2035 TEST(eglGetError() == EGL_BAD_DISPLAY);
2036 res = iPfnEglDestroySyncKHR(invalidDisplay, iSyncObject);
2037 TEST(res == EGL_FALSE);
2038 TEST(eglGetError() == EGL_BAD_DISPLAY);
2040 INFO_PRINTF1(_L("Call eglCreateSyncKHR() with unsupported type parameter."));
2041 const EGLint unsupportedType = 0x3fff;
2042 iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, unsupportedType, KEglSyncAttribsNone);
2043 TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
2044 TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
2046 const EGLint KSpecifiedAttrib[] = {
2047 EGL_SYNC_STATUS_KHR, EGL_UNSIGNALED_KHR,
2050 INFO_PRINTF1(_L("Call eglCreateSyncKHR() with specified condition, type parameter set to EGL_SYNC_REUSABLE_KHR"));
2051 iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KSpecifiedAttrib);
2052 TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
2053 TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
2055 INFO_PRINTF1(_L("Call eglCreateSyncKHR() with unspecified attributes, type parameter set to EGL_SYNC_REUSABLE_KHR"));
2056 const TInt KUndefinedAttrib = 0x4000;
2057 const EGLint KUnspecifiedAttrib1[] = {
2058 KUndefinedAttrib, EGL_UNSIGNALED_KHR,
2061 iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KUnspecifiedAttrib1);
2062 TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
2063 TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
2064 const EGLint KUnspecifiedAttrib2[] = {
2065 EGL_SYNC_STATUS_KHR, KUndefinedAttrib,
2068 iSyncObject1 = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KUnspecifiedAttrib2);
2069 TEST(iSyncObject1 == EGL_NO_SYNC_KHR);
2070 TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
2072 INFO_PRINTF1(_L("Call all sync API (with the exception to eglCreateSyncKHR(...), providing invalid EGLSyncKHR as a parameter"));
2073 res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject1,EGL_UNSIGNALED_KHR );
2074 TEST(res == EGL_FALSE);
2075 TEST(eglGetError() == EGL_BAD_PARAMETER);
2076 res1 = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject1,0,EGL_FOREVER_KHR);
2077 TEST(res1 == EGL_FALSE);
2078 TEST(eglGetError() == EGL_BAD_PARAMETER);
2079 res = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject1,EGL_SYNC_STATUS_KHR, &value);
2080 TEST(res == EGL_FALSE);
2081 TEST(eglGetError() == EGL_BAD_PARAMETER);
2082 res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject1);
2083 TEST(res == EGL_FALSE);
2084 TEST(eglGetError() == EGL_BAD_PARAMETER);
2086 INFO_PRINTF1(_L("Call eglClientWaitSyncKHR(), providing unspecified flags"));
2087 const TInt KUnspecifiedFlags = 0x002;
2088 res1 = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,KUnspecifiedFlags,EGL_FOREVER_KHR);
2089 TEST(res1 == EGL_FALSE);
2090 TEST(eglGetError() == EGL_BAD_PARAMETER);
2092 INFO_PRINTF1(_L("Call eglSignalSyncKHR(), providing unspecified status"));
2093 const EGLint unspecifiedStatus = 0x3fff;
2094 res = iPfnEglSignalSyncKHR(iDisplay,iSyncObject,unspecifiedStatus);
2095 TEST(res == EGL_FALSE);
2096 TEST(eglGetError() == EGL_BAD_PARAMETER);
2098 INFO_PRINTF1(_L("Call eglGetSyncAttribSyncKHR(), providing unspecified attributes"));
2099 const EGLint unspecifiedAttribute = 0x3fff;
2100 res = iPfnEglGetSyncAttribKHR(iDisplay,iSyncObject,unspecifiedAttribute, &value);
2101 TEST(res == EGL_FALSE);
2102 TEST(eglGetError() == EGL_BAD_ATTRIBUTE);
2104 res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
2105 TEST(res == EGL_TRUE);
2108 RecordTestResultL();
2109 CloseTMSGraphicsStep();
2110 INFO_PRINTF1(_L("End of CEglTest_SyncObject_Negative_WrongParameters::doTestStepL"));
2111 return TestStepResult();
2115 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-105
2124 To check that internal version of the signal function, which is accessible
2125 via extension mechanism, doesn't generate an error.
2128 1. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
2129 The type parameter is set to EGL_SYNC_REUSABLE_KHR.
2130 2. Call egl_Private_SignalSyncNOK() on sync object supplying invalid status
2131 3. Call eglGetError()
2132 4. Call egl_Private_SignalSyncNOK() on sync object with EGL_SIGNALED_KHR flag supplying invalid display
2133 5. Call eglGetError()
2134 6. Retrieve status attribute
2135 7. Call eglQueryString(..) supplying invalid name parameter (for instance, "OpenGL_Wrong" ).
2136 8. Call egl_Private_SignalSyncNOK() on sync object with EGL_SIGNALED_KHR flag supplying invalid display
2137 9. Call eglGetError()
2138 10. Destroy the sync object
2140 @SYMTestExpectedResults
2141 2. The function returns EGL_BAD_ PARAMETERS
2142 3. An error is set to EGL_SUCCESS
2143 4. The function returns EGL_BAD_DISPLAY.
2144 5. An error is set to EGL_SUCCESS
2145 6. The status attributes indicates that object is still in a signaled state (EGL_UNSIGNALED_KHR)
2146 8. The function returns EGL_BAD_DISPLAY.
2147 9. An error is set to EGL_BAD_PARAMETER
2149 TVerdict CEglTest_SyncObject_Negative_SignalImpl::doTestStepL()
2151 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-105"));
2152 INFO_PRINTF1(_L("CEglTest_SyncObject_Negative_SignalImpl::doTestStepL"));
2154 if(!iIsSyncObjectExtensionSupported || !iIsSyncObjectPrivateExtensionSupported)
2156 INFO_PRINTF1(_L("Sync object extensions (whether EGL_KHR_reusable_sync or EGL_NOK__private__signal_sync or both) \
2157 are not supported, the test will not be executed"));
2159 RecordTestResultL();
2160 CloseTMSGraphicsStep();
2161 return TestStepResult();
2164 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
2166 CreateEglSessionL();
2167 iEglSess->InitializeL();
2169 INFO_PRINTF1(_L("Create the sync object"));
2170 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
2171 TESTL(iSyncObject != EGL_NO_SYNC_KHR);
2173 INFO_PRINTF1(_L("Call egl_Private_SignalSyncNOK() on sync object supplying invalid status"));
2174 const EGLint unspecifiedMode = 0x3fff;
2175 EGLint res1 = iPfnEglPrivateSignalSyncNOK(iDisplay, iSyncObject, unspecifiedMode);
2176 TEST(res1 == EGL_BAD_PARAMETER);
2177 TEST(eglGetError() == EGL_SUCCESS);
2179 INFO_PRINTF1(_L("Call egl_Private_SignalSyncNOK() on sync object with EGL_SIGNALED_KHR flag supplying invalid display"));
2180 const EGLDisplay invalidDisplay = iDisplay + 1;
2181 res1 = iPfnEglPrivateSignalSyncNOK(invalidDisplay, iSyncObject, EGL_SIGNALED_KHR);
2182 TEST(res1 == EGL_BAD_DISPLAY);
2183 TEST(eglGetError() == EGL_SUCCESS);
2184 CheckSyncAttrib(EGL_SYNC_STATUS_KHR,EGL_UNSIGNALED_KHR); //the status is still "unsignaled"
2186 INFO_PRINTF1(_L("Call eglQueryString(..) supplying invalid name parameter ")); //the actual API doesn't matter, we need to generate an error
2187 const TInt invalidExtension = 0xffff;
2188 const char* extensionsString = eglQueryString(iDisplay, invalidExtension); //this should generate EGL_BAD_PARAMETER
2189 TEST(!extensionsString);
2191 res1 = iPfnEglPrivateSignalSyncNOK(invalidDisplay, iSyncObject, EGL_SIGNALED_KHR);
2192 TEST(res1 == EGL_BAD_DISPLAY);
2193 TEST(eglGetError() == EGL_BAD_PARAMETER); //check that error code was not overidden
2195 EGLBoolean res = iPfnEglDestroySyncKHR(iDisplay, iSyncObject);
2196 TEST(res == EGL_TRUE);
2198 RecordTestResultL();
2199 CloseTMSGraphicsStep();
2200 INFO_PRINTF1(_L("End of CEglTest_SyncObject_Negative_SignalImpl::doTestStepL"));
2201 return TestStepResult();
2205 @SYMTestCaseID GRAPHICS-EGL-SYNC-OBJECT-110
2214 To check that system correctly processing errors in the environment with shortage of memory.
2217 1. Run a loop (step 2 to 7) with fail rate counting from 1 upward until
2218 the following operations succeed
2219 2. Set heap failure with the fail rate specifying in step 1
2220 3. Create sync object for the default display. No attributes are specified (containing only EGL_NONE).
2221 The type parameter is set to EGL_SYNC_REUSABLE_KHR. Skip the following test steps if operation doesn't succeed
2223 5. Wait on the sync object
2224 6. Signal from thread A on the sync object the flag EGL_SIGNALED_KHR
2225 7. Destroy the sync object
2228 @SYMTestExpectedResults
2229 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
2230 5. The main thread should be stalled
2231 6. The main thread should be unblocked
2233 TVerdict CEglTest_SyncObject_Negative_OOM::doTestStepL()
2235 SetTestStepID(_L("GRAPHICS-EGL-SYNC-OBJECT-110"));
2236 INFO_PRINTF1(_L("CEglTest_SyncObject_Negative_OOM::doTestStepL"));
2238 WARN_PRINTF1(_L("CEglTest_SyncObject_Negative_OOM can only be run in debug mode"));
2239 RecordTestResultL();
2240 CloseTMSGraphicsStep();
2241 return TestStepResult();
2244 if(!iIsSyncObjectExtensionSupported)
2246 INFO_PRINTF1(_L("Sync object extension is not supported, the test will not be executed"));
2248 RecordTestResultL();
2249 CloseTMSGraphicsStep();
2250 return TestStepResult();
2253 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
2255 CreateEglSessionL();
2256 iEglSess->InitializeL();
2258 INFO_PRINTF1(_L("Retrieving the heapMark functions for memory testing..."));
2259 TEglDebugHeapMarkStartPtr heapMarkStart = reinterpret_cast<TEglDebugHeapMarkStartPtr>(eglGetProcAddress("egliDebugHeapMarkStart"));
2260 TEglDebugHeapMarkEndPtr heapMarkEnd = reinterpret_cast<TEglDebugHeapMarkEndPtr>(eglGetProcAddress("egliDebugHeapMarkEnd"));
2261 TEglDebugSetBurstAllocFailPtr setSyncObjectAllocFail = reinterpret_cast<TEglDebugSetBurstAllocFailPtr>(eglGetProcAddress("egliDebugSetBurstAllocFail"));
2262 TESTL(heapMarkStart && heapMarkEnd && setSyncObjectAllocFail);
2264 EGLint err = EGL_BAD_ALLOC;
2265 for(TUint failAfter=1; (err == EGL_BAD_ALLOC); ++failAfter)
2271 INFO_PRINTF2(_L("Set EGL heap to fail after %u allocations"), failAfter);
2272 setSyncObjectAllocFail(static_cast<EGLenum>(RHeap::EBurstFailNext), failAfter, 742);
2274 INFO_PRINTF1(_L("Create sync object"));
2275 iSyncObject = iPfnEglCreateSyncKHR(iDisplay, EGL_SYNC_REUSABLE_KHR, KEglSyncAttribsNone);
2276 err = eglGetError();
2277 if(err == EGL_SUCCESS)
2279 TEST(iSyncObject != EGL_NO_SYNC_KHR);
2281 Test_MultiThreadL(1, EFalse);
2282 TUint32 timestampBefore = User::NTickCount();
2283 EGLint resClientWait = iPfnEglClientWaitSyncKHR(iDisplay,iSyncObject,0,EGL_FOREVER_KHR);
2284 TUint32 timestampAfter = User::NTickCount();
2285 TInt timeElapsed = ElapsedTime(timestampAfter, timestampBefore);
2286 TEST(resClientWait == EGL_CONDITION_SATISFIED_KHR);//we do not expect failure here, as eglClientWaitSyncKHR function doesn't allocate any memory
2287 TEST(Abs(timeElapsed - iDelaySignalling) < iThreshold);
2289 TEST(iPfnEglDestroySyncKHR(iDisplay, iSyncObject)== EGL_TRUE);
2291 //Wait for the thread to finish before launching the thread with the same index again.
2292 Test_MultiThread_WaitL(ETrue, TThreadStatus::ELogin);
2296 TEST(iSyncObject == EGL_NO_SYNC_KHR);
2298 // Unset heap failure
2299 setSyncObjectAllocFail(static_cast<EGLenum>(RHeap::ENone), 0, 0);
2300 (void)heapMarkEnd(0);
2303 TEST(err == EGL_SUCCESS);
2306 RecordTestResultL();
2307 CloseTMSGraphicsStep();
2308 INFO_PRINTF1(_L("End of CEglTest_SyncObject_Negative_OOM::doTestStepL"));
2309 return TestStepResult();
2313 void CEglTest_SyncObject_Negative_OOM::doThreadFunctionL(TInt aIdx)
2315 INFO_PRINTF2(_L("CEglTest_SyncObject_Negative_OOM::doThreadFunctionL, Thread %d"),aIdx);
2316 ASSERT_TRUE(aIdx==0);
2318 User::After(TTimeIntervalMicroSeconds32(iDelaySignalling));
2319 TEST(iPfnEglSignalSyncKHR(iDisplay, iSyncObject, EGL_SIGNALED_KHR) == EGL_TRUE); //we do not expect failure here, as eglSignalSyncKHR function doesn't allocate a memory