author | sl |
Tue, 10 Jun 2014 14:32:02 +0200 | |
changeset 1 | 260cb5ec6c19 |
permissions | -rw-r--r-- |
sl@0 | 1 |
/* |
sl@0 | 2 |
* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
sl@0 | 3 |
* All rights reserved. |
sl@0 | 4 |
* This component and the accompanying materials are made available |
sl@0 | 5 |
* under the terms of the License "Eclipse Public License v1.0" |
sl@0 | 6 |
* which accompanies this distribution, and is available |
sl@0 | 7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
sl@0 | 8 |
* |
sl@0 | 9 |
* Initial Contributors: |
sl@0 | 10 |
* Nokia Corporation - initial contribution. |
sl@0 | 11 |
* |
sl@0 | 12 |
* Contributors: |
sl@0 | 13 |
* |
sl@0 | 14 |
* Description: |
sl@0 | 15 |
* TestUtil - entry point |
sl@0 | 16 |
* |
sl@0 | 17 |
*/ |
sl@0 | 18 |
|
sl@0 | 19 |
|
sl@0 | 20 |
/** |
sl@0 | 21 |
@file |
sl@0 | 22 |
@test |
sl@0 | 23 |
@internalComponent |
sl@0 | 24 |
*/ |
sl@0 | 25 |
|
sl@0 | 26 |
#include <e32std.h> |
sl@0 | 27 |
#include <e32base.h> |
sl@0 | 28 |
|
sl@0 | 29 |
#include "testutilserver.h" |
sl@0 | 30 |
#include "testutilclientserver.h" |
sl@0 | 31 |
|
sl@0 | 32 |
// |
sl@0 | 33 |
// Perform server initialisation, in particular creation of the scheduler and |
sl@0 | 34 |
// server and then run the scheduler |
sl@0 | 35 |
// |
sl@0 | 36 |
static void RunServerL() |
sl@0 | 37 |
// |
sl@0 | 38 |
// Perform all server initialisation, in particular creation of the |
sl@0 | 39 |
// scheduler and server and then run the scheduler |
sl@0 | 40 |
// |
sl@0 | 41 |
{ |
sl@0 | 42 |
// naming the server thread after the server helps to debug panics |
sl@0 | 43 |
User::LeaveIfError(RThread().RenameMe(KTestUtilServerName)); |
sl@0 | 44 |
// |
sl@0 | 45 |
// create and install the active scheduler we need |
sl@0 | 46 |
CActiveScheduler* s=new(ELeave) CActiveScheduler; |
sl@0 | 47 |
CleanupStack::PushL(s); |
sl@0 | 48 |
CActiveScheduler::Install(s); |
sl@0 | 49 |
// |
sl@0 | 50 |
// create the server (leave it on the cleanup stack) |
sl@0 | 51 |
CTestUtilServer::NewLC(); |
sl@0 | 52 |
// |
sl@0 | 53 |
// Initialisation complete, now signal the client |
sl@0 | 54 |
|
sl@0 | 55 |
RProcess::Rendezvous(KErrNone); |
sl@0 | 56 |
|
sl@0 | 57 |
// |
sl@0 | 58 |
// Ready to run |
sl@0 | 59 |
CActiveScheduler::Start(); |
sl@0 | 60 |
// |
sl@0 | 61 |
// Cleanup the server and scheduler |
sl@0 | 62 |
CleanupStack::PopAndDestroy(2); |
sl@0 | 63 |
} |
sl@0 | 64 |
|
sl@0 | 65 |
// |
sl@0 | 66 |
// Server process entry-point |
sl@0 | 67 |
// |
sl@0 | 68 |
TInt E32Main() |
sl@0 | 69 |
{ |
sl@0 | 70 |
__UHEAP_MARK; |
sl@0 | 71 |
// |
sl@0 | 72 |
CTrapCleanup* cleanup=CTrapCleanup::New(); |
sl@0 | 73 |
TInt r=KErrNoMemory; |
sl@0 | 74 |
if (cleanup) |
sl@0 | 75 |
{ |
sl@0 | 76 |
TRAP(r,RunServerL()); |
sl@0 | 77 |
delete cleanup; |
sl@0 | 78 |
} |
sl@0 | 79 |
// |
sl@0 | 80 |
__UHEAP_MARKEND; |
sl@0 | 81 |
return r; |
sl@0 | 82 |
} |
sl@0 | 83 |
|
sl@0 | 84 |
|
sl@0 | 85 |
void PanicClient(const RMessagePtr2& aMessage,TTestUtilPanic aPanic) |
sl@0 | 86 |
// |
sl@0 | 87 |
// RMessagePtr2::Panic() also completes the message. This is: |
sl@0 | 88 |
// (a) important for efficient cleanup within the kernel |
sl@0 | 89 |
// (b) a problem if the message is completed a second time |
sl@0 | 90 |
// |
sl@0 | 91 |
{ |
sl@0 | 92 |
_LIT(KPanic,"TestUtilServer"); |
sl@0 | 93 |
aMessage.Panic(KPanic,aPanic); |
sl@0 | 94 |
} |