sysstatemgmt/systemstatemgr/test/tipcfuzz/src/tipcfuzz_server.cpp
changeset 0 4e1aa6a622a0
equal deleted inserted replaced
-1:000000000000 0:4e1aa6a622a0
       
     1 // Copyright (c) 2008-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  @internalComponent - Internal Symbian test code 
       
    20 */
       
    21  
       
    22 
       
    23 #include "tipcfuzz_server.h"
       
    24 #include "tipcfuzz_step.h"
       
    25 
       
    26 
       
    27 _LIT(KIpcFuzzTestServerName, "IpcFuzzTestServer");
       
    28 
       
    29 CIpcFuzzTestServer* CIpcFuzzTestServer::NewLC( )
       
    30 	{
       
    31 	CIpcFuzzTestServer * server = new (ELeave) CIpcFuzzTestServer();
       
    32 	CleanupStack::PushL(server);
       
    33 	TParsePtrC serverName(RProcess().FileName());	
       
    34 	server->StartL(serverName.Name());
       
    35 	return server;
       
    36 	}
       
    37 
       
    38 static void MainL()
       
    39 	{
       
    40 	CActiveScheduler* sched = new(ELeave) CActiveScheduler;
       
    41 	CleanupStack::PushL (sched);
       
    42 	CActiveScheduler::Install (sched);
       
    43 
       
    44 	CIpcFuzzTestServer* server = CIpcFuzzTestServer::NewLC( );
       
    45 	RProcess::Rendezvous (KErrNone );
       
    46 	sched->Start( );
       
    47 
       
    48 	CleanupStack::PopAndDestroy (server );
       
    49 	CleanupStack::PopAndDestroy (sched );
       
    50 	}
       
    51 
       
    52 /**
       
    53  Process entry point. Called by client using RProcess API
       
    54  @return - Standard Epoc error code on process exit
       
    55  */
       
    56 TInt E32Main(void) //lint -e765 -e714 Suppress 'not referenced' and 'could be static'
       
    57 	{
       
    58 	__UHEAP_MARK;
       
    59 	CTrapCleanup* cleanup = CTrapCleanup::New();
       
    60 	if(cleanup == NULL)
       
    61 		{
       
    62 		return KErrNoMemory;
       
    63 		}
       
    64 	TRAPD(err,MainL());	
       
    65 	if (err)
       
    66 		{
       
    67 		_LIT(KMainErrorStatement, "IpcFuzzTestServer::MainL - Error: %d");
       
    68 		RDebug::Print(KMainErrorStatement, err);
       
    69 	   	User::Panic(KIpcFuzzTestServerName, err);
       
    70 		}		
       
    71 	delete cleanup;
       
    72 		
       
    73 	__UHEAP_MARKEND;
       
    74 	return KErrNone;
       
    75 	}
       
    76 
       
    77 /**
       
    78  @return - A CTestStep derived instance
       
    79  */
       
    80 CTestStep* CIpcFuzzTestServer::CreateTestStep(const TDesC& aStepName )
       
    81 	{
       
    82 	CTestStep* testStep = NULL;
       
    83 	if (aStepName == KTIpcFuzzStep)
       
    84 		{
       
    85 		testStep = new CIpcFuzzTest();
       
    86 		}
       
    87 	else
       
    88 		{
       
    89 		RDebug::Printf ("Unknown IpcFuzzTest step %S", &aStepName );
       
    90 		}
       
    91 
       
    92 	return testStep;
       
    93 	}