|
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 <sysmonclisess.h> |
|
23 #include <startupproperties.h> |
|
24 #include "testapps.h" |
|
25 #include "tsysmon_stepmultiprocmon.h" |
|
26 |
|
27 |
|
28 CStepMultiProcMon::CStepMultiProcMon() |
|
29 { |
|
30 SetTestStepName(KCTestCaseMultiProcMon); |
|
31 } |
|
32 |
|
33 /** |
|
34 Old Test CaseID APPFWK-SYSMON-0002 |
|
35 New Test CaseID DEVSRVS-SYSSTART-SYSMON-0002 |
|
36 */ |
|
37 |
|
38 TVerdict CStepMultiProcMon::doTestStepL() |
|
39 { |
|
40 INFO_PRINTF1(_L("TEST APPFWK-SYSMON-0002")); |
|
41 |
|
42 // Launch two instances of the same executable |
|
43 |
|
44 INFO_PRINTF1(_L("Going to set first process running")); |
|
45 RProcess process1; |
|
46 CleanupClosePushL(process1); |
|
47 User::LeaveIfError(process1.Create(KTestProcGood, KNullDesC)); |
|
48 ResumeL(process1); |
|
49 |
|
50 INFO_PRINTF1(_L("Starting a second instance of the same executable")); |
|
51 RProcess process2; |
|
52 CleanupClosePushL(process2); |
|
53 User::LeaveIfError(process2.Create(KTestProcGood, KNullDesC)); |
|
54 ResumeL(process2); |
|
55 |
|
56 // Do the testing |
|
57 DoTestMonitorL(process1, process2); |
|
58 |
|
59 // Tidy up |
|
60 process1.Kill(KErrNone); |
|
61 process2.Kill(KErrNone); |
|
62 CleanupStack::PopAndDestroy(&process2); |
|
63 CleanupStack::PopAndDestroy(&process1); |
|
64 |
|
65 |
|
66 return TestStepResult(); |
|
67 } |
|
68 |
|
69 /** |
|
70 * Contains the actual testing. Verifying that it is possible to monitor more than one |
|
71 * instance of the same executable. |
|
72 */ |
|
73 void CStepMultiProcMon::DoTestMonitorL(const RProcess& aProc1, const RProcess& aProc2) |
|
74 { |
|
75 RSysMonSession sess; |
|
76 CleanupClosePushL(sess); |
|
77 sess.OpenL(); |
|
78 |
|
79 |
|
80 CStartupProperties *prop = CStartupProperties::NewLC(KTestProcGood, KNullDesC); |
|
81 prop->SetMonitored(ETrue); |
|
82 prop->SetNoOfRetries(0); // SysMon will not do any restart attempts |
|
83 |
|
84 INFO_PRINTF1(_L("Going to monitor first process")); |
|
85 sess.MonitorL(*prop, aProc1); |
|
86 INFO_PRINTF1(_L("Successfully setup monitoring of first process.")); |
|
87 |
|
88 INFO_PRINTF1(_L("Going to monitor second process")); |
|
89 sess.MonitorL(*prop, aProc2); |
|
90 INFO_PRINTF1(_L("Successfully setup monitoring of second process.")); |
|
91 |
|
92 INFO_PRINTF1(_L("Try to register monitoring for second time")); |
|
93 TRAPD(err, sess.MonitorL(*prop, aProc1)); |
|
94 TESTE(err == KErrAlreadyExists, err); |
|
95 if(err == KErrAlreadyExists) |
|
96 { |
|
97 INFO_PRINTF1(_L("Second monitor request for first process returned KErrAlreadyExists as expected")); |
|
98 } |
|
99 TRAP(err, sess.MonitorL(*prop, aProc2)); |
|
100 TESTE(err == KErrAlreadyExists, err); |
|
101 if(err == KErrAlreadyExists) |
|
102 { |
|
103 INFO_PRINTF1(_L("Second monitor request for second process returned KErrAlreadyExists as expected")); |
|
104 } |
|
105 |
|
106 CleanupStack::PopAndDestroy(prop); |
|
107 CleanupStack::PopAndDestroy(&sess); |
|
108 } |