os/security/cryptomgmtlibs/securitytestfw/test/testutil/server/testutilstartup.cpp
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/security/cryptomgmtlibs/securitytestfw/test/testutil/server/testutilstartup.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,94 @@
1.4 +/*
1.5 +* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of the License "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +* TestUtil - entry point
1.19 +*
1.20 +*/
1.21 +
1.22 +
1.23 +/**
1.24 + @file
1.25 + @test
1.26 + @internalComponent
1.27 +*/
1.28 +
1.29 +#include <e32std.h>
1.30 +#include <e32base.h>
1.31 +
1.32 +#include "testutilserver.h"
1.33 +#include "testutilclientserver.h"
1.34 +
1.35 +//
1.36 +// Perform server initialisation, in particular creation of the scheduler and
1.37 +// server and then run the scheduler
1.38 +//
1.39 +static void RunServerL()
1.40 +//
1.41 +// Perform all server initialisation, in particular creation of the
1.42 +// scheduler and server and then run the scheduler
1.43 +//
1.44 + {
1.45 + // naming the server thread after the server helps to debug panics
1.46 + User::LeaveIfError(RThread().RenameMe(KTestUtilServerName));
1.47 + //
1.48 + // create and install the active scheduler we need
1.49 + CActiveScheduler* s=new(ELeave) CActiveScheduler;
1.50 + CleanupStack::PushL(s);
1.51 + CActiveScheduler::Install(s);
1.52 + //
1.53 + // create the server (leave it on the cleanup stack)
1.54 + CTestUtilServer::NewLC();
1.55 + //
1.56 + // Initialisation complete, now signal the client
1.57 +
1.58 + RProcess::Rendezvous(KErrNone);
1.59 +
1.60 + //
1.61 + // Ready to run
1.62 + CActiveScheduler::Start();
1.63 + //
1.64 + // Cleanup the server and scheduler
1.65 + CleanupStack::PopAndDestroy(2);
1.66 + }
1.67 +
1.68 +//
1.69 +// Server process entry-point
1.70 +//
1.71 +TInt E32Main()
1.72 + {
1.73 + __UHEAP_MARK;
1.74 + //
1.75 + CTrapCleanup* cleanup=CTrapCleanup::New();
1.76 + TInt r=KErrNoMemory;
1.77 + if (cleanup)
1.78 + {
1.79 + TRAP(r,RunServerL());
1.80 + delete cleanup;
1.81 + }
1.82 + //
1.83 + __UHEAP_MARKEND;
1.84 + return r;
1.85 + }
1.86 +
1.87 +
1.88 +void PanicClient(const RMessagePtr2& aMessage,TTestUtilPanic aPanic)
1.89 +//
1.90 +// RMessagePtr2::Panic() also completes the message. This is:
1.91 +// (a) important for efficient cleanup within the kernel
1.92 +// (b) a problem if the message is completed a second time
1.93 +//
1.94 + {
1.95 + _LIT(KPanic,"TestUtilServer");
1.96 + aMessage.Panic(KPanic,aPanic);
1.97 + }