testexecfw/tef/tefutilities/TEFUtilityServer/src/tefutilityserver.cpp
changeset 0 3e07fef1e154
equal deleted inserted replaced
-1:000000000000 0:3e07fef1e154
       
     1 /*
       
     2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  
       
    15 * Basic Test Server implementation to instantiate tests and return a pointer to run tests
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file TEFUtilityServer.cpp
       
    23 */
       
    24 
       
    25 #include "TEFUtiltityServer.h"
       
    26 #include "TEFBuildInfoLogStep.h"
       
    27 #include "TEFFormatDrive.h"
       
    28 
       
    29 /**
       
    30  * @name Constant Literals used
       
    31  */
       
    32 _LIT(KServerName,"TEFUtilityServer");
       
    33 
       
    34 /**
       
    35  * @return - Instance of the test server
       
    36  * Same code for Secure and non-secure variants
       
    37  * Called inside the MainL() function to create and start the
       
    38  * CTestServer derived server.
       
    39  */
       
    40 CTEFUtilityServer* CTEFUtilityServer::NewL()
       
    41 	{
       
    42 	CTEFUtilityServer*	server = new (ELeave) CTEFUtilityServer();
       
    43 	CleanupStack::PushL(server);
       
    44 	// CServer base class call
       
    45 	server->ConstructL(KServerName);
       
    46 	CleanupStack::Pop(server);
       
    47 	return server;
       
    48 	}
       
    49 
       
    50 /**
       
    51  * Secure variant
       
    52  * Much simpler, uses the new Rendezvous() call to sync with the client
       
    53  */
       
    54 LOCAL_C void MainL()
       
    55 	{
       
    56 	#if (defined __DATA_CAGING__)
       
    57 		RProcess().DataCaging(RProcess::EDataCagingOn);
       
    58 		RProcess().SecureApi(RProcess::ESecureApiOn);
       
    59 	#endif
       
    60 	CActiveScheduler*	sched=NULL;
       
    61 	sched=new(ELeave) CActiveScheduler;
       
    62 	CActiveScheduler::Install(sched);
       
    63 	CTEFUtilityServer*	server = NULL;
       
    64 	// Create the CTestServer derived server
       
    65 	TRAPD(err,server = CTEFUtilityServer::NewL());
       
    66 	if(!err)
       
    67 		{
       
    68 		// Sync with the client and enter the active scheduler
       
    69 		RProcess::Rendezvous(KErrNone);
       
    70 		sched->Start();
       
    71 		}
       
    72 	delete server;
       
    73 	delete sched;
       
    74 	}
       
    75 
       
    76 /**
       
    77  * @return - Standard Epoc error code on process exit
       
    78  * Secure variant only
       
    79  * Process entry point. Called by client using RProcess API
       
    80  */
       
    81 GLDEF_C TInt E32Main()
       
    82 	{
       
    83 	__UHEAP_MARK;
       
    84 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    85 	if(cleanup == NULL)
       
    86 		{
       
    87 		return KErrNoMemory;
       
    88 		}
       
    89 	TRAP_IGNORE(MainL());
       
    90 	delete cleanup;
       
    91 	__UHEAP_MARKEND;
       
    92 	return KErrNone;
       
    93     }
       
    94 
       
    95 /**
       
    96  * @return - A CTestStep derived instance
       
    97  * Implementation of CTestServer pure virtual
       
    98  */
       
    99 CTestStep* CTEFUtilityServer::CreateTestStep(const TDesC& aStepName)
       
   100 	{
       
   101 	CTestStep* testStep = NULL;
       
   102 	
       
   103 	if(aStepName == KPrintBuildInfo)
       
   104 		{
       
   105 #if !(defined TEF_LITE)
       
   106 		testStep = new CTEFBuildInfoLogStep();
       
   107 #endif
       
   108 		}
       
   109 	
       
   110 	if(aStepName == KFormatDrive)
       
   111 		{
       
   112 		testStep = new CTEFFormatDrive();
       
   113 		}
       
   114 			 
       
   115 	return testStep;
       
   116 	}