First public contribution.
1 // Copyright (c) 2007-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.
21 #include <test/tefunit.h> // for ASSERT macros
22 #include <iniparser.h>
25 #include <e32msgqueue.h>
27 #include "egltestcommonstep.h"
28 #include "egltestcommonsession.h"
29 #include "egltestcommonutils.h"
30 #include "egltestcommonprocess.h"
32 static const TUint KDefaultHeapSize = 0x100000;
33 CEglTestStep::TThreadStatus::TThreadStatus()
35 for(TInt i=0; i<ESize; i++)
41 EXPORT_C CEglTestStep::CEglTestStep() :
42 iWaitForCompletionOnPostamble(EFalse),
43 iSourceFormat(KDefaultSourceFormat),
44 iSurfaceFormat(KDefaultSurfaceFormat)
48 EXPORT_C CEglTestStep::~CEglTestStep()
50 for (TInt i=0; i<KMaxProcessNumber; i++)
52 iProcessStatus[i].iProcess.Close();
54 TInt countThread = iThreadStatus.Count();
55 for (TInt i=0; i<countThread; i++)
57 iThreadStatus[i].iThread.Close();
59 iThreadStatus.Close();
61 iSemaphore[0].Close();
62 iSemaphore[1].Close();
68 EXPORT_C TVerdict CEglTestStep::doTestStepPreambleL()
70 User::LeaveIfError(Logger().ShareAuto());
71 //When EGL Logging is enabled this causes a file server session to be allocated
72 //Which needs to be done before any handle checks otherwise the test will fail
73 ASSERT_EGL_TRUE(eglReleaseThread());
76 return TestStepResult();
79 EXPORT_C TVerdict CEglTestStep::doTestStepPostambleL()
81 if(iWaitForCompletionOnPostamble && (iThreadStatus.Count() > 0))
83 INFO_PRINTF1(_L("Main thread waits for other threads to be terminated!!"));
84 Test_MultiThread_WaitL(ETrue, TThreadStatus::ELogin);
87 if (iDisplay != EGL_NO_DISPLAY)
89 // Output a warning because this should be done by the test
90 WARN_PRINTF1(_L("Terminating Display during doTestStepPostambleL"));
91 ASSERT_EGL_TRUE(eglTerminate(iDisplay));
92 iDisplay = EGL_NO_DISPLAY;
95 ASSERT_EGL_TRUE(eglReleaseThread());
99 return TestStepResult();
102 EXPORT_C void CEglTestStep::CleanAll()
107 if (iDisplay != EGL_NO_DISPLAY)
109 ASSERT_EGL_TRUE(eglTerminate(iDisplay));
110 iDisplay = EGL_NO_DISPLAY;
112 ASSERT_EGL_TRUE(eglReleaseThread());
115 /*****************************************************************************
117 *****************************************************************************/
119 void CEglTestStep::HandleMark()
121 RThread().HandleCount(iProcHandleMark, iThreadHandleMark);
122 INFO_PRINTF3(_L("MARK: (%d) process-owned handle(s) / (%d) thread-owned handle(s)"), iProcHandleMark, iThreadHandleMark);
125 void CEglTestStep::HandleMarkEnd()
127 RThread().HandleCount(iProcHandleMarkEnd, iThreadHandleMarkEnd);
128 INFO_PRINTF3(_L("MARK-END: (%d) process-owned handle(s) / (%d) thread-owned handle(s)"), iProcHandleMarkEnd, iThreadHandleMarkEnd);
130 WARN_PRINTF1(_L("Process-owned handle test is ignored on WINS build due to Pls() behaviour."));
132 // When using Pls() on WINS build, it inteferes with handle count assert here due to Pls() behaviour which initialises PLS object
133 // on first call of Pls() rather than during DLL loading, which cause extra count into iProcHandleMark.
134 // ARMV5 build does not suffer this problem as proper WSD support is used.
136 ASSERT_EQUALS(iProcHandleMarkEnd, iProcHandleMark);
138 ASSERT_EQUALS(iThreadHandleMarkEnd, iThreadHandleMark);
141 /** Initialises the window server session and window group objects. */
142 EXPORT_C void CEglTestStep::OpenWsSessionL(TInt aGroupId)
144 User::LeaveIfError(iWsSession.Connect());
145 iWindowGroup = RWindowGroup(iWsSession);
146 User::LeaveIfError(iWindowGroup.Construct(aGroupId));
149 /** Uninitialises the window group object and the window server session. */
150 EXPORT_C void CEglTestStep::CloseWsSession()
152 iWindowGroup.Close();
157 Uses the Eikon Environment to construct a window and put it on top.
158 @param aWindow A non-constructed window object
159 @param aRect The intial position and size of the window
160 @leave Standard system errors
162 EXPORT_C void CEglTestStep::ConstructWindowL(RWindow& aWindow, const TRect& aRect)
164 INFO_PRINTF1(_L("CEglTestStep::CreateWindowL()"));
166 const TUint32 ENullWsHandle = 0xFFFFFFFF; // Events delivered to this handle are thrown away
167 aWindow = RWindow(iWsSession);
168 CleanupClosePushL(aWindow);
169 User::LeaveIfError(aWindow.Construct(iWindowGroup, ENullWsHandle));
170 aWindow.SetExtent(aRect.iTl, aRect.Size());
172 CleanupStack::Pop(&aWindow);
176 Prints both the Source pixel format and the target pixel format
178 EXPORT_C void CEglTestStep::PrintUsedPixelConfiguration()
180 INFO_PRINTF1(_L("******UsedPixelConfiguration******"));
181 INFO_PRINTF1(_L("Source Pixel Format"));
182 PrintPixelFormat(iSourceFormat);
184 INFO_PRINTF1(_L("Target Format"));
185 PrintVGImageFormat(iSurfaceFormat);
186 INFO_PRINTF1(_L("**********************************"));
189 EXPORT_C void CEglTestStep::PrintPixelFormat(TUidPixelFormat aFormat)
193 case EUidPixelFormatA_8:
194 INFO_PRINTF1(_L("EUidPixelFormatA_8"));
196 case EUidPixelFormatRGB_565:
197 INFO_PRINTF1(_L("EUidPixelFormatRGB_565"));
199 case EUidPixelFormatXRGB_8888:
200 INFO_PRINTF1(_L("EUidPixelFormatXRGB_8888"));
202 case EUidPixelFormatARGB_8888:
203 INFO_PRINTF1(_L("EUidPixelFormatARGB_8888"));
205 case EUidPixelFormatARGB_8888_PRE:
206 INFO_PRINTF1(_L("EUidPixelFormatARGB_8888_PRE"));
209 ERR_PRINTF2(_L("Unsupported pixel format (%d)"), aFormat);
214 EXPORT_C void CEglTestStep::PrintVGImageFormat(VGImageFormat aAttr)
219 INFO_PRINTF1(_L("VG_sRGB_565"));
222 INFO_PRINTF1(_L("VG_sXRGB_8888"));
225 INFO_PRINTF1(_L("VG_sARGB_8888"));
227 case VG_sARGB_8888_PRE:
228 INFO_PRINTF1(_L("VG_sARGB_8888_PRE"));
231 ERR_PRINTF2(_L("Unsupported VGImage format (%d)"), aAttr);
237 /*****************************************************************************
238 ** Multiprocess test utils
239 *****************************************************************************/
242 Launches the specified number of processes, where each process will perform the actions specified in
243 the doProcessFunctionL of the calling test. As no images TSgDrawableId has been passed, an
244 an array of one (NULL) TSgDrawableId will be created.
245 @param aProcessCount Number of processes
246 @param aTestName Name of the calling test case (so that it can call it's doProcessFunctionL method
247 @leave Standard system errors
249 EXPORT_C void CEglTestStep::Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName)
252 Mem::FillZ(&sgId, sizeof(TSgDrawableId));
253 Test_MultiProcessL(aTestDllName, aProcessCount, aTestStepName, sgId);
257 Launches the specified number of processes, where each process will perform the actions specified in
258 the doProcessFunctionL of the calling test.
259 @param aProcessCount Number of processes
260 @param aTestName Name of the calling test case (so that it can call it's doProcessFunctionL method
261 @param aSgId Images TSgDrawableId which will be used to create an array of one TSgDrawableId
262 @leave Standard system errors
264 EXPORT_C void CEglTestStep::Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName, const TSgDrawableId& aSgId)
266 // we assume we pass the same Id to all the processes (array of one)
267 RArray<TSgDrawableId> sgIdList;
268 ASSERT_EQUALS(sgIdList.Insert(aSgId,0), KErrNone);
269 Test_MultiProcessL(aTestDllName, aProcessCount, aTestStepName, sgIdList);
274 Launches the specified number of processes, where each process will perform the actions specified in
275 the doProcessFunctionL of the calling test. The association of images and processes is done via the
276 predefined ImageIndexFromProcessId() method.
277 @param aProcessCount Number of processes
278 @param aTestName Name of the calling test case (so that it can call it's doProcessFunctionL method
279 @param aSgIdList Array containing the list of images' TSgDrawableId
280 @leave Standard system errors
282 EXPORT_C void CEglTestStep::Test_MultiProcessL(const TDesC& aTestDllName, TInt aProcessCount, const TDesC& aTestStepName, const RArray<TSgDrawableId>& aSgIdList)
284 TInt imageCount = aSgIdList.Count();
285 if(aProcessCount <= 0 || imageCount <=0 || aProcessCount > KMaxProcessNumber || imageCount > aProcessCount)
287 ERR_PRINTF1(_L("Invalid process request!"));
288 User::Leave(KErrArgument);
291 // create MsgQueue (only used in some test to pass data between 2 processes)
292 RMsgQueue<TSgDrawableId> messageQueueSgId;
293 TInt ret = messageQueueSgId.CreateGlobal(KNullDesC, 1, EOwnerProcess);
294 ASSERT_EQUALS(ret, KErrNone);
295 CleanupClosePushL(messageQueueSgId);
297 RMsgQueue<TProcessId> messageQueueProcId;
298 ret = messageQueueProcId.CreateGlobal(KNullDesC, 1, EOwnerProcess);
299 ASSERT_EQUALS(ret, KErrNone);
300 CleanupClosePushL(messageQueueProcId);
302 // Create semphores that can be shared (only used in some test to synch between 2 process)
303 ret = iSemaphore[0].CreateGlobal(KNullDesC(), 0, EOwnerProcess);
304 ASSERT_EQUALS(ret, KErrNone);
305 ret = iSemaphore[1].CreateGlobal(KNullDesC(), 0, EOwnerProcess);
306 ASSERT_EQUALS(ret, KErrNone);
308 // create MsgQueue (only used in some tests to pass data from client processes to the main process)
309 RMsgQueue<TEglStepMessageBuffer> messageQueueClientProcParam;
310 ret = messageQueueClientProcParam.CreateGlobal(KNullDesC, 1, EOwnerProcess);
311 ASSERT_EQUALS(ret, KErrNone);
312 CleanupClosePushL(messageQueueClientProcParam);
314 for (TInt i=0; i<aProcessCount; i++)
318 info.iSgId= aSgIdList[ImageIndexFromProcessId(i, imageCount)];
320 ret = iProcessStatus[i].iProcess.Create(KEglTestServerWrapperProcess, KNullDesC);
321 User::LeaveIfError(ret);
323 // Specify the test for the process
324 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotTestDllName, aTestDllName);
325 User::LeaveIfError(ret);
326 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotTestStepName, aTestStepName);
327 User::LeaveIfError(ret);
329 // Specify the non-handle params passed to the process
330 TPckg<TProcessInfo> pckgInfo(info);
331 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotParams, pckgInfo);
332 User::LeaveIfError(ret);
334 // Pass in the semaphores
335 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotSemaphore0, iSemaphore[0]);
336 User::LeaveIfError(ret);
337 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotSemaphore1, iSemaphore[1]);
338 User::LeaveIfError(ret);
339 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotMsgQueueSgId, messageQueueSgId);
340 User::LeaveIfError(ret);
341 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotMsgQueueProcId, messageQueueProcId);
342 User::LeaveIfError(ret);
343 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotSourceFormat, static_cast<TInt>(iSourceFormat));
344 User::LeaveIfError(ret);
345 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotSurfaceFormat, static_cast<TInt>(iSurfaceFormat));
346 User::LeaveIfError(ret);
347 ret = iProcessStatus[i].iProcess.SetParameter(EProcSlotCustomClientParam, messageQueueClientProcParam);
348 User::LeaveIfError(ret);
350 iProcessStatus[i].iProcess.Logon(iProcessStatus[i].iStatus);
351 iProcessStatus[i].iProcess.Resume();
354 //by default an empty implementation
355 ReceiveMessageFromClient(messageQueueClientProcParam);
357 // wait for all processes to complete (not worried about the order)
358 // This is needed, as the only way to determine whether the process step has failed is to check
359 // the return value (using TEST(EFalse) has no effect on the spawned process)
360 for (TInt i=0; i<aProcessCount; i++)
362 User::WaitForRequest(iProcessStatus[i].iStatus);
363 CheckProcessStatusL(i, iProcessStatus[i].iStatus, iProcessStatus[i].iProcess);
364 RDebug::Print(_L(">>>>>(%d)>> status :%d"), i, iProcessStatus[i].iStatus.Int());
365 iProcessStatus[i].iProcess.Close();
368 // close MsgQueue and semaphores (as used in some test with 2 spawned processes)
369 CleanupStack::PopAndDestroy(3, &messageQueueSgId); //messageQueueClientProcParam, messageQueueProcId
370 iSemaphore[1].Close();
371 iSemaphore[0].Close();
375 Check the status of a process running as part of the current teststep.
376 @param aIndex Index of the process
377 @param aStatus The request status of the process in question.
378 @param aProcess The process object itself.
379 @leave Standard system errors
381 void CEglTestStep::CheckProcessStatusL(TInt aIndex, const TRequestStatus& aStatus, const RProcess& aProcess)
383 TInt status = aStatus.Int();
384 if (status == KErrNone)
388 if (status == KRequestPending)
390 // If the process is still running, that's an error, as we waited for the status
391 ERR_PRINTF2(_L("Error in process %d - status should not be KRequestPending"), aIndex);
392 User::Leave(KErrTEFUnitFail);
394 // Something went wrong
395 switch (aProcess.ExitType())
397 case EExitPanic: // The thread or process has been panicked.
399 TPtrC ptrExitCategory = aProcess.ExitCategory();
400 ERR_PRINTF4(_L("Panic in process %d - category:[%S] reason: %d"), aIndex, &ptrExitCategory, aProcess.ExitReason());
401 // Propagate the panic
402 User::Panic(aProcess.ExitCategory(), aProcess.ExitReason());
405 case EExitKill: // The thread or process has ended as a result of a kill, i.e. Kill() has been called on the RThread or RProcess handle. Or a thread was ended as a result of calling User::Exit().
406 case EExitTerminate: // The thread or process has ended as a result of a terminate, i.e. Terminate() has been called on the RThread or RProcess handle.
407 case EExitPending: // The thread or process is alive.
409 // Propagate the error
410 ERR_PRINTF3(_L("Error in process %d - code %d"), aIndex, aStatus.Int());
411 User::Leave(aStatus.Int());
417 /*****************************************************************************
418 ** Multithread test utils
419 *****************************************************************************/
422 Launches the specified number of threads, where each thread will perform the actions specified in
423 the doThreadFunctionL of the calling test.
424 @param aThreadCount Number of threads
425 @param aWaitForCompletion To wait until the launched thread has completed
426 @leave Standard system errors
428 EXPORT_C void CEglTestStep::Test_MultiThreadL(TInt aThreadCount, TBool aWaitForCompletion)
430 if(aThreadCount <= 0 || aThreadCount > KMaxThreadNumber)
432 ERR_PRINTF1(_L("Invalid thread request!"));
433 User::Leave(KErrArgument);
436 iWaitForCompletionOnPostamble = !aWaitForCompletion;
438 //we just care for these 2 semaphores
439 ASSERT_EQUALS(iSemaphore[0].CreateLocal(0, EOwnerProcess), KErrNone);
440 ASSERT_EQUALS(iSemaphore[1].CreateLocal(0, EOwnerProcess), KErrNone);
442 _LIT(KThread, "CEglTestStep_Thread");
443 _LIT(KUnderScore, "_");
446 ASSERT_EQUALS(iThreadStatus.Count(),0);
447 // Reserve space to avoid reallocation of iThreadStatus.iStatus
448 iThreadStatus.ReserveL(aThreadCount);
449 for (TInt i=0; i<aThreadCount; i++)
451 iThreadInfos[i].iSelf=this;
452 iThreadInfos[i].iIdx=i;
457 tm.FormatL(bufTime, _L("_%H%T%S%C_"));
459 // guaranteed unique thread name (useful if several threads are created with aWaitForCompletion = false)
460 TName threadName(KThread);
461 threadName.Append(KUnderScore);
462 threadName.AppendNum(i, EDecimal);
463 threadName.Append(KUnderScore);
464 threadName.Append(bufTime);
465 threadName.AppendNum(Math::Random(), EHex);
467 iThreadStatus.AppendL(TThreadStatus());
468 ret = iThreadStatus[i].iThread.Create(threadName, ThreadFunction, KDefaultStackSize, KMinHeapSize, KDefaultHeapSize, &iThreadInfos[i], EOwnerProcess);
469 User::LeaveIfError(ret);
471 if(!aWaitForCompletion)
473 // We want to wait for the notification that the extra thread is about to be launched
474 // Improves timing issues within a hardware WDP environment
475 iThreadStatus[i].iThread.Rendezvous(iThreadStatus[i].iStatus[TThreadStatus::ERendezvous]);
477 iThreadStatus[i].iThread.Logon(iThreadStatus[i].iStatus[TThreadStatus::ELogin]);
478 iThreadStatus[i].iThread.Resume();
480 Test_MultiThread_WaitL(aWaitForCompletion, aWaitForCompletion ? TThreadStatus::ELogin : TThreadStatus::ERendezvous);
483 EXPORT_C void CEglTestStep::Test_MultiThread_WaitL(TBool aCloseThreads, TThreadStatus::TStatusId aStatusId)
485 // Close handles and wait for all threads to complete (not worried about the order). Note that some
486 // tests do not require to wait for completion. Nevertheless, care should be taken to ensure that the
487 // spawned thread is capable of modifying the main TEF process TestStepResult.
489 TInt countThread = iThreadStatus.Count();
490 for (TInt i=0; i<countThread; i++)
492 User::WaitForRequest(iThreadStatus[i].iStatus[aStatusId]);
493 CheckThreadStatusL(i, iThreadStatus[i].iStatus[aStatusId], iThreadStatus[i].iThread);
494 INFO_PRINTF3(_L(">>>>>(%d)>> status :%d"), i, iThreadStatus[i].iStatus[aStatusId].Int());
498 iThreadStatus[i].iThread.Close();
503 iThreadStatus.Reset();
505 iSemaphore[0].Close();
506 iSemaphore[1].Close();
511 Check the status of a thread running as part of the current teststep.
512 @param aIndex Index of the thread
513 @param aStatus The request status of the thread in question.
514 @param aThread The thread object itself.
515 @leave Standard system errors
517 void CEglTestStep::CheckThreadStatusL(TInt aIndex, const TRequestStatus& aStatus, const RThread& aThread)
519 TInt status = aStatus.Int();
520 if (status == KErrNone)
525 if (status == KRequestPending)
527 // If the thread is still running, that's an error, as we waited for the status
528 ERR_PRINTF2(_L("Error in thread %d - status should not be KRequestPending"), aIndex);
529 User::Leave(KErrTEFUnitFail);
531 // Something went wrong
532 switch (aThread.ExitType())
534 case EExitPanic: // The thread or process has been panicked.
536 TPtrC ptrExitCategory = aThread.ExitCategory();
537 ERR_PRINTF4(_L("Panic in thread %d - category:[%S] reason: %d"), aIndex, &ptrExitCategory, aThread.ExitReason());
538 User::Panic(aThread.ExitCategory(), aThread.ExitReason());
541 case EExitKill: // The thread or process has ended as a result of a kill, i.e. Kill() has been called on the RThread or RProcess handle. Or a thread was ended as a result of calling User::Exit().
542 case EExitTerminate: // The thread or process has ended as a result of a terminate, i.e. Terminate() has been called on the RThread or RProcess handle.
543 case EExitPending: // The thread or process is alive.
545 // Propagate the error
546 ERR_PRINTF3(_L("Error in thread %d - code %d"), aIndex, status);
547 User::Leave(aStatus.Int());
549 // We should not get here!
553 TInt CEglTestStep::ThreadFunction(TAny* aInfo)
557 CTrapCleanup* cleanup = CTrapCleanup::New();
563 CEglTestStep::TThreadInfo* info = reinterpret_cast<CEglTestStep::TThreadInfo*>(aInfo);
564 TRAPD(err, info->iSelf->ThreadFunctionL(*info));
571 void CEglTestStep::ThreadFunctionL(TThreadInfo& aInfo)
573 // Mark the handle count for this thread
574 TInt processHandleMark=0;
575 TInt threadHandleMark=0;
576 RThread().HandleCount(processHandleMark, threadHandleMark);
577 INFO_PRINTF4(_L("MARK: THREAD %d: (%d) process-owned handle(s) / (%d) thread-owned handle(s)"), aInfo.iIdx, processHandleMark, threadHandleMark);
579 // Notify the main thread that we are about to launch the extra thread
580 RThread::Rendezvous(KErrNone);
582 // Run the real thread funciton
583 aInfo.iSelf->doThreadFunctionL(aInfo.iIdx);
585 // Release EGL thread state
586 INFO_PRINTF2(_L("thread %d: Calling eglReleaseThread()"), aInfo.iIdx);
587 ASSERT_EGL_TRUE(eglReleaseThread());
589 // Check the handle count for this thread has not changed
590 TInt processHandleMarkEnd=0;
591 TInt threadHandleMarkEnd=0;
592 RThread().HandleCount(processHandleMarkEnd, threadHandleMarkEnd);
593 INFO_PRINTF4(_L("MARK-END: THREAD %d: (%d) process-owned handle(s) / (%d) thread-owned handle(s)"), aInfo.iIdx, processHandleMarkEnd, threadHandleMarkEnd);
595 //Not testing equality of process-owned handles as these should only be tested from the main thread.
596 //Process handlecount is dependent on all threads, therefore process handle imbalances could be the responsibility of other threads.
597 ASSERT_EQUALS(threadHandleMark, threadHandleMarkEnd);
601 Tests should override this method for multithreaded testing
603 EXPORT_C void CEglTestStep::doThreadFunctionL(TInt aIdx)
605 // Not supported for this test step
606 ERR_PRINTF2(_L("thread %d: Calling CEglTestStep::doThreadFunctionL() - should be overriden"), aIdx);
607 User::Leave(KErrNotSupported);
610 EXPORT_C void CEglTestStep::doThreadFunctionL(TInt aIdx,const TSgDrawableId& aSgId)
612 // Not supported for this test step
613 ERR_PRINTF3(_L("thread %d: Calling CEglTestStep::doThreadFunctionL() - should be overriden, TSgDrawableId %lu."), aIdx, aSgId.iId);
614 User::Leave(KErrNotSupported);
618 Tests should override this method for multiprocess testing
620 EXPORT_C void CEglTestStep::doProcessFunctionL(TInt aIdx)
622 // Not supported for this test step
623 ERR_PRINTF2(_L("Process %d: Calling CEglTestStep::doProcessFunctionL() - should be overriden"), aIdx);
624 User::Leave(KErrNotSupported);
627 EXPORT_C void CEglTestStep::doProcessFunctionL(TInt aIdx,const TSgDrawableId& aSgId)
629 // Not supported for this test step
630 ERR_PRINTF3(_L("Process %d: Calling CEglTestStep::doProcessFunctionL() - should be overriden, TSgDrawableId %lu."), aIdx, aSgId.iId);
631 User::Leave(KErrNotSupported);
636 Rendezvous: Ensures that both threads get to this point before continuing
637 @param aIdx The thread index value that was passed into
638 the override of CEglTestStep::doThreadFunctionL()
640 EXPORT_C void CEglTestStep::Rendezvous(TInt aIdx)
644 // Currently Rendezvous is only supported between threads with index 0 and index 1
645 INFO_PRINTF2(_L("CEglTestStep::Rendezvous() - aIdx (%d) is too big!!"), aIdx);
648 INFO_PRINTF2(_L("thread %d: ...At Rendezvous..."), aIdx);
649 iSemaphore[aIdx].Signal();
650 iSemaphore[1-aIdx].Wait();
654 /*****************************************************************************
656 *****************************************************************************/
659 Temporarily initializes the EGL thread and display in order to check for the
660 supplied extension string.
661 The display is then released and terminated.
662 Use this method to pre-check for the existence of an extension string prior
664 There are 2 ways to ask for an extension, via the ID (the default way to do it)
665 or passing a string containing the full name of the extension (used in some tests only)
666 @param aExtensions The extension ID to look for
667 @param aExtensionName The extension name to look for
668 @return Whether the extension string can be found
670 EXPORT_C TBool CEglTestStep::CheckForExtensionL(TInt aExtensions, const TDesC& aExtensionName)
672 ASSERT_TRUE(iDisplay == EGL_NO_DISPLAY);
674 CTestEglSession* eglSess = CTestEglSession::NewLC(Logger(), iDisplay, -1);
675 eglSess->InitializeL();
677 TBool bFoundExtensions = eglSess->CheckNeededExtensionL(aExtensions, aExtensionName);
679 // Cleanup EGL Completely
680 CleanupStack::PopAndDestroy(eglSess);
683 ASSERT_EGL_TRUE(eglReleaseThread());
685 // return whether the extension string was found
686 return bFoundExtensions;
690 Uses eglGetDisplay() to initialise iDisplay, and to check the result of the call
692 EXPORT_C void CEglTestStep::GetDisplayL()
694 INFO_PRINTF1(_L("Calling eglGetDisplay..."));
696 iDisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);
697 ASSERT_EGL_TRUE(iDisplay != EGL_NO_DISPLAY);
701 If the iDisplay has been initialised then this method uses eglTerminate()
702 to terminate iDisplay, and to check the result of the call.
703 This method also resets the value of iDisplay to EGL_NO_DISPLAY to indicate
704 that the display is no longer initialised.
706 EXPORT_C void CEglTestStep::TerminateDisplayL()
708 if (iDisplay != EGL_NO_DISPLAY)
710 INFO_PRINTF1(_L("Calling eglTerminate..."));
711 ASSERT_EGL_TRUE(eglTerminate(iDisplay));
712 iDisplay = EGL_NO_DISPLAY;
717 Cut and paste from CTestStep::SetLogger() - which is not exported
718 As the name suggests, this is for use by the egl test process wrapper
720 void CEglTestStep::SetLoggerForProcessWrapperL()
722 // Create a cinidata object for parsing the testexecute.ini
723 CTestExecuteIniData* parseTestExecuteIni = NULL;
724 TBuf<KMaxTestExecuteNameLength> resultFilePath;
725 TBuf<KMaxTestExecuteNameLength> xmlFilePath;
729 TRAPD(err,parseTestExecuteIni = CTestExecuteIniData::NewL());
732 CleanupStack::PushL(parseTestExecuteIni);
733 parseTestExecuteIni->ExtractValuesFromIni();
734 parseTestExecuteIni->GetKeyValueFromIni(KTEFHtmlKey, resultFilePath);
735 parseTestExecuteIni->GetKeyValueFromIni(KTEFXmlKey, xmlFilePath);
736 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogMode, logMode);
737 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogSeverityKey, logLevel);
738 parseTestExecuteIni->GetKeyValueFromIni(KTEFEnableIniAccessLog, IniAccessLog());
742 resultFilePath.Copy(KTestExecuteLogPath);
743 xmlFilePath.Copy(KTestExecuteLogPath);
744 logMode = TLoggerOptions(ELogHTMLOnly);
745 logLevel = RFileFlogger::TLogSeverity(ESevrAll);
746 IniAccessLog() = ETrue;
748 Logger().SetLoggerOptions(logMode);
750 // Initialise a handle to the file logger
751 User::LeaveIfError(Logger().Connect());
753 User::LeaveIfError(fS.Connect());
754 CleanupClosePushL(fS);
756 TBuf<KMaxTestExecuteNameLength> xmlLogFile(xmlFilePath);
757 TBuf<KMaxTestExecuteNameLength> logFile;
758 TBuf<KMaxTestExecuteNameLength> logFileNameFile(resultFilePath);
759 logFileNameFile.Append(KTestExecuteScheduleTestLogCompatibilityNameFile);
760 if(file.Open(fS,logFileNameFile,EFileRead | EFileShareAny) != KErrNone)
762 // For the old flogger we have to create an individual file
763 logFile.Copy(TestStepName());
764 _LIT(KTxtExtension,".txt");
765 logFile.Append(KTxtExtension);
766 logMode = TLoggerOptions(0);
767 Logger().SetLoggerOptions(logMode);
771 CleanupClosePushL(file);
772 TBuf8<KMaxTestExecuteNameLength> logFile8;
774 User::LeaveIfError(file.Size(fileSize));
775 User::LeaveIfError(file.Read(logFile8,fileSize));
776 logFile.Copy(logFile8);
777 xmlLogFile.Append(logFile);
778 _LIT(KXmlExtension,".xml");
779 xmlLogFile.Append(KXmlExtension);
780 _LIT(KHtmExtension,".htm");
781 logFile.Append(KHtmExtension);
782 CleanupStack::Pop(&file);
785 TBuf<KMaxTestExecuteLogFilePath> logFilePath(resultFilePath);
786 logFilePath.Append(logFile);
787 CleanupStack::Pop(&fS);
790 if (logMode == 0 || logMode == 2)
792 User::LeaveIfError(Logger().HtmlLogger().CreateLog(logFilePath,RTestExecuteLogServ::ELogModeAppend));
793 Logger().HtmlLogger().SetLogLevel(TLogSeverity(logLevel));
795 if (logMode == 1 || logMode == 2)
797 User::LeaveIfError(Logger().XmlLogger().CreateLog(xmlLogFile,RFileFlogger::ELogModeAppend));
798 Logger().XmlLogger().SetLogLevel(RFileFlogger::TLogSeverity(logLevel));
800 if (parseTestExecuteIni != NULL)
802 CleanupStack::PopAndDestroy(parseTestExecuteIni);
806 EXPORT_C void CEglTestStep::PartialInitialiseL(const TDesC& aStepName)
808 SetTestStepName(aStepName);
809 SetLoggerForProcessWrapperL();
811 SetTestStepResult(EPass);
814 EXPORT_C void CEglTestStep::CreateEglSessionL(TInt aIdx)
816 delete iEglSess; //just in case it was called twice
817 iEglSess = CTestEglSession::NewL(Logger(), iDisplay, aIdx);