|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @test |
|
19 @internalComponent - Internal Symbian test code |
|
20 */ |
|
21 |
|
22 #include "sysmontesthelper.h" |
|
23 |
|
24 |
|
25 TInt MainL() |
|
26 { |
|
27 RDebug::Print(_L("appfwk-sysmon-0034: MainL")); |
|
28 |
|
29 TInt runCount = 0; |
|
30 CCommandLineArguments* args = CCommandLineArguments::NewLC(); |
|
31 runCount = CSysMonTestHelper::ReadRunCountL(args->Arg(0)); |
|
32 CSysMonTestHelper::IncrementRunCountL(args->Arg(0)); |
|
33 CleanupStack::PopAndDestroy(args); |
|
34 |
|
35 |
|
36 switch (runCount) |
|
37 { |
|
38 case 0: |
|
39 { |
|
40 RProcess::Rendezvous(KErrNone); |
|
41 RSysMonSession sysmon; |
|
42 sysmon.OpenL(); |
|
43 CleanupClosePushL(sysmon); |
|
44 |
|
45 CStartupProperties* props = CStartupProperties::NewLC(_L("tsysmon_app_dontrendezvous.exe"), KNullDesC); |
|
46 props->SetMonitored(ETrue); |
|
47 props->SetStartupType(EStartProcess); |
|
48 props->SetStartMethod(EWaitForStart); |
|
49 props->SetNoOfRetries(1); |
|
50 props->SetTimeout(0); |
|
51 props->SetRecoveryParams(EIgnoreOnFailure, 0); |
|
52 |
|
53 RProcess slave1; |
|
54 slave1.Create(_L("tsysmon_app_dontrendezvous.exe"), _L("5000")); |
|
55 CleanupClosePushL(slave1); |
|
56 slave1.Resume(); |
|
57 |
|
58 // Register with SysMon |
|
59 sysmon.MonitorL(*props, slave1); |
|
60 slave1.Terminate(KErrNone); |
|
61 CleanupStack::PopAndDestroy(3, &sysmon); |
|
62 break; |
|
63 } |
|
64 default: //Run normally |
|
65 { |
|
66 RProcess::Rendezvous(KErrNone); |
|
67 break; |
|
68 } |
|
69 } |
|
70 |
|
71 |
|
72 RDebug::Print(_L("appfwk-sysmon-0034: End MainL")); |
|
73 return KErrNone; |
|
74 } |
|
75 |
|
76 |
|
77 // Global Functions |
|
78 |
|
79 GLDEF_C TInt E32Main() |
|
80 { |
|
81 // Create cleanup stack |
|
82 RDebug::Print(_L("appfwk-sysmon-0034: E32Main")); |
|
83 __UHEAP_MARK; |
|
84 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
85 // Run application code inside TRAP harness |
|
86 TRAPD(testError, MainL()); |
|
87 if (testError) |
|
88 { |
|
89 User::Panic(_L("Test failure"), testError); |
|
90 } |
|
91 |
|
92 delete cleanup; |
|
93 __UHEAP_MARKEND; |
|
94 RDebug::Print(_L("appfwk-sysmon-0034: End E32Main")); |
|
95 return KErrNone; |
|
96 } //lint -e714 Suppress 'not referenced' |