os/security/cryptomgmtlibs/securitytestfw/test/testutil/server/testutilstartup.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2004-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 the License "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 * TestUtil - entry point
    16 *
    17 */
    18 
    19 
    20 /**
    21  @file 
    22  @test
    23  @internalComponent
    24 */
    25 
    26 #include <e32std.h>
    27 #include <e32base.h>
    28 
    29 #include "testutilserver.h"
    30 #include "testutilclientserver.h"
    31 
    32 //
    33 // Perform server initialisation, in particular creation of the scheduler and 
    34 // server and then run the scheduler
    35 //
    36 static void RunServerL()
    37 //
    38 // Perform all server initialisation, in particular creation of the
    39 // scheduler and server and then run the scheduler
    40 //
    41 	{
    42 	// naming the server thread after the server helps to debug panics
    43 	User::LeaveIfError(RThread().RenameMe(KTestUtilServerName));
    44 	//
    45 	// create and install the active scheduler we need
    46 	CActiveScheduler* s=new(ELeave) CActiveScheduler;
    47 	CleanupStack::PushL(s);
    48 	CActiveScheduler::Install(s);
    49 	//
    50 	// create the server (leave it on the cleanup stack)
    51 	CTestUtilServer::NewLC();
    52 	//
    53 	// Initialisation complete, now signal the client
    54 
    55 	RProcess::Rendezvous(KErrNone);
    56 
    57 	//
    58 	// Ready to run
    59 	CActiveScheduler::Start();
    60 	//
    61 	// Cleanup the server and scheduler
    62 	CleanupStack::PopAndDestroy(2);
    63 	}
    64 
    65 //
    66 // Server process entry-point
    67 //
    68 TInt E32Main()
    69 	{
    70 	__UHEAP_MARK;
    71 	//
    72 	CTrapCleanup* cleanup=CTrapCleanup::New();
    73 	TInt r=KErrNoMemory;
    74 	if (cleanup)
    75 		{
    76 		TRAP(r,RunServerL());
    77 		delete cleanup;
    78 		}
    79 	//
    80 	__UHEAP_MARKEND;
    81 	return r;
    82 	}
    83 
    84 
    85 void PanicClient(const RMessagePtr2& aMessage,TTestUtilPanic aPanic)
    86 //
    87 // RMessagePtr2::Panic() also completes the message. This is:
    88 // (a) important for efficient cleanup within the kernel
    89 // (b) a problem if the message is completed a second time
    90 //
    91 	{
    92 	_LIT(KPanic,"TestUtilServer");
    93 	aMessage.Panic(KPanic,aPanic);
    94 	}