|
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 // Performs the Out of Memory Tests.\n |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include <sysmonclisess.h> |
|
25 #include <startupproperties.h> |
|
26 #include "tsysmon_stepoomsysmon.h" |
|
27 #include "testapps.h" |
|
28 |
|
29 /** |
|
30 Constructor |
|
31 */ |
|
32 CTOOMSysMonTestStep::CTOOMSysMonTestStep() |
|
33 { |
|
34 // Call base class method to set up the human readable name for logging |
|
35 SetTestStepName(KOOMTestCaseSysMon); |
|
36 } |
|
37 |
|
38 /** |
|
39 Old Test CaseID APPFWK-SYSMON-0062 |
|
40 New Test CaseID DEVSRVS-SHMA-SYSMON-0062 |
|
41 */ |
|
42 |
|
43 TVerdict CTOOMSysMonTestStep::doTestStepL() |
|
44 { |
|
45 INFO_PRINTF1(_L("Testing System Monitor...OOM tests")); |
|
46 |
|
47 TInt fail = 0; |
|
48 TInt ret = 0; |
|
49 |
|
50 RSysMonSession sysMonSes; |
|
51 |
|
52 //OOM test for RSysMonSession::OpenL() method. |
|
53 for (fail = 1;; fail++) |
|
54 { |
|
55 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
56 __UHEAP_MARK; |
|
57 TRAP(ret, sysMonSes.OpenL()); |
|
58 TEST((ret == KErrNone) || (ret == KErrNoMemory)); |
|
59 if (ret == KErrNone) |
|
60 { |
|
61 sysMonSes.Close(); |
|
62 INFO_PRINTF1(_L("Created a session with system monitor")); |
|
63 __UHEAP_MARKEND; |
|
64 break; |
|
65 } |
|
66 __UHEAP_MARKEND; |
|
67 } |
|
68 __UHEAP_RESET; |
|
69 |
|
70 INFO_PRINTF1(_L("Going to set process running")); |
|
71 |
|
72 RProcess proc; |
|
73 CleanupClosePushL(proc); |
|
74 User::LeaveIfError(proc.Create(KTestProcGood, KNullDesC)); |
|
75 ResumeL(proc); |
|
76 |
|
77 INFO_PRINTF1(_L("Going to request process monitoring using startupproperties")); |
|
78 CStartupProperties *prop = CStartupProperties::NewLC(KTestProcGood, KNullDesC); |
|
79 prop->SetMonitored(ETrue); |
|
80 prop->SetNoOfRetries(0); // SysMon will not do any restart attempts |
|
81 |
|
82 sysMonSes.OpenL(); |
|
83 |
|
84 //OOM test for RSysMonSession::MonitorL() method. |
|
85 for (fail = 1;; fail++) |
|
86 { |
|
87 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
88 __UHEAP_MARK; |
|
89 TRAP(ret, sysMonSes.MonitorL(*prop, proc)); |
|
90 TEST((ret == KErrNone) || (ret == KErrNoMemory)); |
|
91 if (ret == KErrNone) |
|
92 { |
|
93 INFO_PRINTF1(_L("Successfully setup monitoring of process.")); |
|
94 TRAP(ret, sysMonSes.CancelMonitorSelfL()); |
|
95 TEST(ret == KErrNone); |
|
96 sysMonSes.Close(); |
|
97 __UHEAP_MARKEND; |
|
98 break; |
|
99 } |
|
100 __UHEAP_MARKEND; |
|
101 } |
|
102 __UHEAP_RESET; |
|
103 proc.Kill(KErrNone); |
|
104 |
|
105 RProcess proc1; |
|
106 CleanupClosePushL(proc1); |
|
107 User::LeaveIfError(proc1.Create(KTestProcGood, KNullDesC)); |
|
108 ResumeL(proc1); |
|
109 |
|
110 sysMonSes.OpenL(); |
|
111 CleanupClosePushL(sysMonSes); |
|
112 TRAP(ret, sysMonSes.MonitorL(*prop, proc1)); |
|
113 TEST(ret == KErrNone); |
|
114 |
|
115 //OOM test for RSysMonSession::CancelMonitorSelfL() method. |
|
116 for (fail = 1;; fail++) |
|
117 { |
|
118 __UHEAP_SETFAIL(RHeap::EDeterministic, fail); |
|
119 __UHEAP_MARK; |
|
120 TRAP(ret, sysMonSes.CancelMonitorSelfL()); |
|
121 TEST((ret == KErrNone) || (ret == KErrNoMemory)); |
|
122 if (ret == KErrNone) |
|
123 { |
|
124 sysMonSes.Close(); |
|
125 INFO_PRINTF1(_L("Successfully cancelled the monitoring of process.")); |
|
126 __UHEAP_MARKEND; |
|
127 break; |
|
128 } |
|
129 __UHEAP_MARKEND; |
|
130 } |
|
131 __UHEAP_RESET; |
|
132 |
|
133 proc1.Kill(KErrNone); |
|
134 CleanupStack::PopAndDestroy(4, &proc); |
|
135 |
|
136 INFO_PRINTF1(_L("System Monitor...OOM tests completed")); |
|
137 return TestStepResult(); |
|
138 } |
|
139 |
|
140 |