sl@0: /* sl@0: * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of the License "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * TestUtil - entry point sl@0: * sl@0: */ sl@0: sl@0: sl@0: /** sl@0: @file sl@0: @test sl@0: @internalComponent sl@0: */ sl@0: sl@0: #include sl@0: #include sl@0: sl@0: #include "testutilserver.h" sl@0: #include "testutilclientserver.h" sl@0: sl@0: // sl@0: // Perform server initialisation, in particular creation of the scheduler and sl@0: // server and then run the scheduler sl@0: // sl@0: static void RunServerL() sl@0: // sl@0: // Perform all server initialisation, in particular creation of the sl@0: // scheduler and server and then run the scheduler sl@0: // sl@0: { sl@0: // naming the server thread after the server helps to debug panics sl@0: User::LeaveIfError(RThread().RenameMe(KTestUtilServerName)); sl@0: // sl@0: // create and install the active scheduler we need sl@0: CActiveScheduler* s=new(ELeave) CActiveScheduler; sl@0: CleanupStack::PushL(s); sl@0: CActiveScheduler::Install(s); sl@0: // sl@0: // create the server (leave it on the cleanup stack) sl@0: CTestUtilServer::NewLC(); sl@0: // sl@0: // Initialisation complete, now signal the client sl@0: sl@0: RProcess::Rendezvous(KErrNone); sl@0: sl@0: // sl@0: // Ready to run sl@0: CActiveScheduler::Start(); sl@0: // sl@0: // Cleanup the server and scheduler sl@0: CleanupStack::PopAndDestroy(2); sl@0: } sl@0: sl@0: // sl@0: // Server process entry-point sl@0: // sl@0: TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: // sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: TInt r=KErrNoMemory; sl@0: if (cleanup) sl@0: { sl@0: TRAP(r,RunServerL()); sl@0: delete cleanup; sl@0: } sl@0: // sl@0: __UHEAP_MARKEND; sl@0: return r; sl@0: } sl@0: sl@0: sl@0: void PanicClient(const RMessagePtr2& aMessage,TTestUtilPanic aPanic) sl@0: // sl@0: // RMessagePtr2::Panic() also completes the message. This is: sl@0: // (a) important for efficient cleanup within the kernel sl@0: // (b) a problem if the message is completed a second time sl@0: // sl@0: { sl@0: _LIT(KPanic,"TestUtilServer"); sl@0: aMessage.Panic(KPanic,aPanic); sl@0: }