os/graphics/egl/egltest/src/egltestcommonprocess.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 /**
    17  @file
    18  @test
    19 */
    20 
    21 
    22 #include <e32debug.h>
    23 
    24 #include "egltestcommonprocess.h"
    25 #include "egltestcommonstep.h"
    26 
    27 // static
    28 void EglTestCommonProcess::MainL()
    29 	{
    30 	TPckgBuf<TProcessInfo> pckgInfo;
    31 	TInt ret = User::GetDesParameter(EProcSlotParams, pckgInfo);
    32 	User::LeaveIfError(ret);
    33 	TProcessInfo& info = pckgInfo();
    34 	
    35 	TBuf<200> bufTestDllName;
    36 	ret = User::GetDesParameter(EProcSlotTestDllName, bufTestDllName);
    37 	User::LeaveIfError(ret);
    38 
    39     TBuf<200> bufTestStepName;
    40     ret = User::GetDesParameter(EProcSlotTestStepName, bufTestStepName);
    41     User::LeaveIfError(ret);
    42 
    43 #ifdef __WINS__
    44 	// Construct and destroy a process-wide state object in emulator builds.
    45 	// This will cause initialisation of PLS for EGL and SgDriver
    46 	// and allow checking for leaks in tests
    47 	eglReleaseThread();
    48 #endif //__WINS__ 
    49 
    50     // Create test step and perform CTestStep style initialisation (e.g. logging)
    51 	CEglTestStep* testStep = NULL;
    52     RLibrary library;
    53     if(library.Load(bufTestDllName) == KErrNone)
    54         {
    55         typedef CEglTestStep* (* TFnPtrGetEglTestStep) (const TDesC&);
    56         TFnPtrGetEglTestStep fnGetEglTestStep = reinterpret_cast<TFnPtrGetEglTestStep>(library.Lookup(1));
    57         testStep = fnGetEglTestStep(bufTestStepName);
    58         }
    59 	
    60 	if (testStep == NULL)
    61 		{
    62 		User::Leave(KErrNotFound);
    63 		}
    64 	CleanupStack::PushL(testStep);
    65 
    66 	// perform CTestStep style initialisation (e.g. logging)
    67 	testStep->PartialInitialiseL(bufTestStepName);
    68 	
    69 	User::LeaveIfError(testStep->iSemaphore[0].Open(EProcSlotSemaphore0, EOwnerThread));
    70 	User::LeaveIfError(testStep->iSemaphore[1].Open(EProcSlotSemaphore1, EOwnerThread));
    71 		
    72 	// perform CTestStep pre-amble
    73 	User::LeaveIfError(testStep->doTestStepPreambleL());
    74 	
    75 #ifdef SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    76 	TBool sgIdHasBeenPassed = info.iSgId.iId != TUint64(0);
    77 #else
    78 	TBool sgIdHasBeenPassed = EFalse;
    79 	for(TUint i = 0; i < 5; i++)
    80 		{
    81 		if((info.iSgId).iId[i] != 0)
    82 			{
    83 			sgIdHasBeenPassed = ETrue;
    84 			break;
    85 			}		
    86 		}
    87 #endif //SYMBIAN_GRAPHICS_EGL_SGIMAGELITE
    88 	
    89 	if(!sgIdHasBeenPassed)
    90 		{
    91 		testStep->doProcessFunctionL(info.iIdx);
    92 		}
    93 	else
    94 		{
    95 		testStep->doProcessFunctionL(info.iIdx, info.iSgId);
    96 		}
    97 
    98 	// perform CTestStep post-amble
    99 	User::LeaveIfError(testStep->doTestStepPostambleL());
   100 	
   101 	//clean-up
   102 	CleanupStack::PopAndDestroy(testStep);
   103 	}
   104 
   105 
   106 GLDEF_C TInt E32Main()
   107 	{
   108 	//When EGL Logging is enabled this causes a file server session to be allocated
   109 	//Which needs to be done before any allocation checks otherwise the test will fail
   110 	eglReleaseThread();
   111 
   112 	__UHEAP_MARK;
   113 	CTrapCleanup* cleanup = CTrapCleanup::New();
   114 	if(cleanup == NULL)
   115 		{
   116 		return KErrNoMemory;
   117 		}
   118 	
   119 	TRAPD(err, EglTestCommonProcess::MainL());
   120 	
   121 	delete cleanup;
   122 	__UHEAP_MARKEND;
   123 
   124 	return err;	
   125 	}