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