|
1 // Copyright (c) 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 //These tests are only for the Cleserver when it reconstructs the |
|
15 //commands from the commandlist. |
|
16 |
|
17 /** |
|
18 @file |
|
19 @test |
|
20 @internalComponent - Internal Symbian test code |
|
21 */ |
|
22 |
|
23 #include <ssm/ssmstartupproperties.h> |
|
24 #include <f32file.h> |
|
25 #include <e32property.h> |
|
26 |
|
27 #include "clesrv.h" |
|
28 #include "clecli.h" |
|
29 #include "cmdpublishswp.h" |
|
30 #include "ssmcustomcommandinfo.h" |
|
31 #include "cmdcustomcommand.h" |
|
32 #include "cmdloadsup.h" |
|
33 #include "cmdpublishsystemstate.h" |
|
34 #include "cmdreqswpchange.h" |
|
35 #include "ssmtestapps.h" |
|
36 #include "cmdstartapp.h" |
|
37 #include "cmdstartprocess.h" |
|
38 #include "ssmtestprocgoodsession.h" |
|
39 #include "cmdpoweroff.h" |
|
40 #include "cmdamastarter.h" |
|
41 #include "cmdmultiplewait.h" |
|
42 #include "cmdcreateswp.h" |
|
43 #include "cmdpersisthalattributes.h" |
|
44 #include "cmdfinalisedrives.h" |
|
45 #include "cmdsetpandskey.h" |
|
46 #include "cmdwaitforapparcinit.h" |
|
47 #include "tcmd_runclecmdtest.h" |
|
48 |
|
49 static const TUint KSwpNullUid = {0}; |
|
50 static const TUint KNewSwpKey = 0xAEAE; |
|
51 static const TUint KNewSwpKey2 = 0xEAEA; |
|
52 const TUid KTestPropertyCat={0x1234}; |
|
53 const TUint KTestKey = 678; |
|
54 const TUid KTestDscId = {0x1234}; |
|
55 const TInt KNumOfRetries = 5; |
|
56 const TInt KThrottleTime = 10000000; //10s |
|
57 |
|
58 _LIT(KBadFileName, "c:\\badfile.exe"); //this file does not exist |
|
59 _LIT(KSlowStartApp, "ssmtestappslow.exe"); |
|
60 _LIT(KEmptyArgs, ""); |
|
61 _LIT(KGoodProc, "ssmtestprocgood.exe"); |
|
62 _LIT(KPolicyFilename, "ssm.swp.policy.test.cmdreqswp"); |
|
63 _LIT(KNoSuchDll, "nosuchdll.dll"); |
|
64 |
|
65 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
66 typedef TDmTraverseDirection TTestSsmDirection; |
|
67 TTestSsmDirection testTraverseDefault = ETraverseDefault; |
|
68 #else //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
69 typedef TSsmDmTraverseDirection TTestSsmDirection; |
|
70 TTestSsmDirection testTraverseDefault = ESsmTraverseDefault; |
|
71 #endif //SYMBIAN_ENABLE_SPLIT_HEADERS |
|
72 |
|
73 CCmdRunCleTest::CCmdRunCleTest() |
|
74 { |
|
75 } |
|
76 |
|
77 CCmdRunCleTest::~CCmdRunCleTest() |
|
78 { |
|
79 delete iActiveScheduler; |
|
80 delete iAsyncStopScheduler; |
|
81 delete iStartupProperties; |
|
82 iStartupProperties = NULL; |
|
83 iSem.Close(); |
|
84 } |
|
85 |
|
86 static TInt StopScheduler(TAny* /*aCCmdRunCleTest*/) |
|
87 { |
|
88 CActiveScheduler::Stop(); |
|
89 return KErrNone; |
|
90 } |
|
91 |
|
92 TVerdict CCmdRunCleTest::doTestStepPreambleL() |
|
93 { |
|
94 iStartupProperties = CSsmStartupProperties::NewL(); |
|
95 |
|
96 INFO_PRINTF1(_L("Starting scheduler...")); |
|
97 iActiveScheduler = new(ELeave) CActiveScheduler; |
|
98 CActiveScheduler::Install( iActiveScheduler ); |
|
99 |
|
100 iAsyncStopScheduler = new(ELeave) CAsyncCallBack(CActive::EPriorityIdle); |
|
101 TCallBack stop(StopScheduler, this); |
|
102 iAsyncStopScheduler->Set(stop); |
|
103 |
|
104 return CTestStep::doTestStepPreambleL(); |
|
105 } |
|
106 |
|
107 TVerdict CCmdRunCleTest::doTestStepPostambleL() |
|
108 { |
|
109 delete iStartupProperties; |
|
110 iStartupProperties = NULL; |
|
111 return CTestStep::doTestStepPostambleL(); |
|
112 } |
|
113 |
|
114 TVerdict CCmdRunCleTest::doTestStepL() |
|
115 { |
|
116 __UHEAP_MARK; |
|
117 TRAPD(err, doTestRunClePublishSwpL()); |
|
118 TEST(err == KErrNone); |
|
119 __UHEAP_MARKEND; |
|
120 |
|
121 __UHEAP_MARK; |
|
122 TRAP(err, doTestRunCleCustomCommandL()); |
|
123 TEST(err == KErrNone); |
|
124 __UHEAP_MARKEND; |
|
125 |
|
126 __UHEAP_MARK; |
|
127 TRAP(err, doTestRunCleCmdLoadSupL()); |
|
128 TEST(err == KErrNone); |
|
129 __UHEAP_MARKEND; |
|
130 |
|
131 __UHEAP_MARK; |
|
132 TRAP(err, doTestRunCleCmdpublishSystemStateL()); |
|
133 TEST(err == KErrNone); |
|
134 __UHEAP_MARKEND; |
|
135 |
|
136 __UHEAP_MARK; |
|
137 TRAP(err, doTestRunCmdCreateSwpL()); |
|
138 TEST(err == KErrNone); |
|
139 __UHEAP_MARKEND; |
|
140 |
|
141 __UHEAP_MARK; |
|
142 TRAP(err, doTestRunCleCcmdreqSwpchangeL()); |
|
143 TEST(err == KErrNone); |
|
144 __UHEAP_MARKEND; |
|
145 |
|
146 __UHEAP_MARK; |
|
147 TRAP(err, doTestRunCleCmdAmaStarterL()); |
|
148 TEST(err == KErrNone); |
|
149 __UHEAP_MARKEND; |
|
150 |
|
151 __UHEAP_MARK; |
|
152 TRAP(err, doTesTRunCleCmdMultipleWaitL()); |
|
153 TEST(err == KErrNone); |
|
154 __UHEAP_MARKEND; |
|
155 |
|
156 __UHEAP_MARK; |
|
157 TRAP(err, doTestRunCmdPowerOffL()); |
|
158 TEST(err == KErrNone); |
|
159 __UHEAP_MARKEND; |
|
160 |
|
161 __UHEAP_MARK; |
|
162 TRAP(err, doTestRunCleCmdStartAppL()); |
|
163 TEST(err == KErrNone); |
|
164 __UHEAP_MARKEND; |
|
165 |
|
166 __UHEAP_MARK; |
|
167 TRAP(err, doTestRunCleCmdStartProcessL()); |
|
168 TEST(err == KErrNone); |
|
169 __UHEAP_MARKEND; |
|
170 |
|
171 __UHEAP_MARK; |
|
172 TRAP(err, doTestRunCleCmdPersistHalAttributesL()); |
|
173 TEST(err == KErrNone); |
|
174 __UHEAP_MARKEND; |
|
175 |
|
176 __UHEAP_MARK; |
|
177 TRAP(err, doTestRunCleCmdFinaliseDrivesL()); |
|
178 TEST(err == KErrNone); |
|
179 __UHEAP_MARKEND; |
|
180 |
|
181 __UHEAP_MARK; |
|
182 TRAP(err, doTestRunCleCmdSetPAndSKeyL()); |
|
183 TEST(err == KErrNone); |
|
184 __UHEAP_MARKEND; |
|
185 |
|
186 __UHEAP_MARK; |
|
187 TRAP(err, doTestRunCleCmdWaitForApparcInitL()); |
|
188 TEST(err == KErrNone); |
|
189 __UHEAP_MARKEND; |
|
190 |
|
191 err = iSem.CreateGlobal(KStartAppSignalSemaphore, 0); |
|
192 INFO_PRINTF2(_L("Created semaphore with err %d"),err); |
|
193 |
|
194 __UHEAP_MARK; |
|
195 TRAP(err, doTestRunCleFandFAppWithMonitorL()); |
|
196 TEST(err == KErrNone); |
|
197 __UHEAP_MARKEND; |
|
198 |
|
199 iSem.Close(); |
|
200 |
|
201 err = iSem.CreateGlobal(KStartProcSignalSemaphore, 0); |
|
202 INFO_PRINTF2(_L("Created semaphore with err %d"),err); |
|
203 TEST(err == KErrNone); |
|
204 |
|
205 __UHEAP_MARK; |
|
206 TRAP(err, doTestRunCleFandFProcWithMonitorL()); |
|
207 TEST(err == KErrNone); |
|
208 __UHEAP_MARKEND; |
|
209 |
|
210 __UHEAP_MARK; |
|
211 TRAP(err, doTestRunCleFandFAlreadyRunWithMonitorL()); |
|
212 TEST(err == KErrNone); |
|
213 __UHEAP_MARKEND; |
|
214 |
|
215 iSem.Close(); |
|
216 return TestStepResult(); |
|
217 } |
|
218 |
|
219 //create cle server in separate thread within the Test server process |
|
220 TInt CCmdRunCleTest::RunTestWithCleAndWaitL(MSsmCommand* aCommand, TBool aMultipleWait) |
|
221 { |
|
222 _LIT(KCleSrver, "TestCleSrv"); |
|
223 RCleSession cleSession;// CLE session to execute commands |
|
224 CleanupClosePushL(cleSession); |
|
225 cleSession.ConnectL(KCleSrver); |
|
226 CSsmCommandList* iCmdList = CSsmCommandList::NewL(); |
|
227 CleanupStack::PushL(iCmdList); |
|
228 iCmdList->AppendL(aCommand); |
|
229 if(aMultipleWait) |
|
230 { |
|
231 TInt32 timeout = 10000; |
|
232 CCmdMultipleWait* iCmd = CCmdMultipleWait::NewL(timeout); |
|
233 CleanupStack::PushL(iCmd); |
|
234 iCmdList->AppendL(iCmd); |
|
235 CleanupStack::Pop(iCmd); |
|
236 } |
|
237 //run engine, stop when there are no further transition |
|
238 iAsyncStopScheduler->CallBack(); |
|
239 iActiveScheduler->Start(); |
|
240 TRequestStatus trs; |
|
241 TCmdErrorSeverity severity; |
|
242 cleSession.ExecuteCommandList(*iCmdList, trs, severity); |
|
243 |
|
244 INFO_PRINTF1(_L("Waiting for syscle command to finish...")); |
|
245 User::WaitForRequest(trs); |
|
246 |
|
247 CleanupStack::PopAndDestroy(iCmdList); |
|
248 CleanupStack::PopAndDestroy();//for cle session |
|
249 return trs.Int(); |
|
250 } |
|
251 |
|
252 void CCmdRunCleTest::doTestRunCleCmdWaitForApparcInitL() |
|
253 { |
|
254 TInt expectedErr = KErrNone; |
|
255 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
256 |
|
257 INFO_PRINTF1(_L("doTestRunCleCmdWaitForApparcInitL, severity:ECmdIgnoreFailure")); |
|
258 iCmd = CCmdWaitForApparcInit::NewL(severity); |
|
259 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
260 iCmd = NULL; |
|
261 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
262 |
|
263 severity = ECmdCriticalSeverity; |
|
264 INFO_PRINTF1(_L("doTestRunCleCmdWaitForApparcInitL, severity:ECmdCriticalSeverity")); |
|
265 iCmd = CCmdWaitForApparcInit::NewL(severity); |
|
266 err = RunTestWithCleAndWaitL(iCmd); |
|
267 iCmd = NULL; |
|
268 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
269 } |
|
270 |
|
271 void CCmdRunCleTest::doTestRunCleCmdSetPAndSKeyL() |
|
272 { |
|
273 TInt expectedErr = KErrNone; |
|
274 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
275 TInt actualValue; |
|
276 |
|
277 INFO_PRINTF1(_L("doTestRunCleCmdSetPAndSKeyL, severity:ECmdIgnoreFailure")); |
|
278 iCmd = CCmdSetPAndSKey::NewL(severity, KTestPropertyCat, KTestKey, 589); |
|
279 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
280 iCmd = NULL; |
|
281 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
282 TEST(err == expectedErr); |
|
283 err = RProperty::Get(KTestPropertyCat,KTestKey,actualValue); |
|
284 TEST(actualValue == 589); |
|
285 |
|
286 severity = ECmdCriticalSeverity; |
|
287 INFO_PRINTF1(_L("doTestRunCleCmdSetPAndSKeyL, severity:ECmdCriticalSeverity")); |
|
288 iCmd = CCmdSetPAndSKey::NewL(severity, KTestPropertyCat, KTestKey, 589); |
|
289 err = RunTestWithCleAndWaitL(iCmd); |
|
290 iCmd = NULL; |
|
291 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
292 TEST(actualValue == 589); |
|
293 TEST(err == expectedErr); |
|
294 err = err = RProperty::Get(KTestPropertyCat,KTestKey,actualValue); |
|
295 TEST(actualValue == 589); |
|
296 } |
|
297 |
|
298 void CCmdRunCleTest::doTestRunCleCmdFinaliseDrivesL() |
|
299 { |
|
300 TInt expectedErr = KErrNone; |
|
301 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
302 |
|
303 INFO_PRINTF1(_L("doTestRunCleCmdFinaliseDrivesL, severity:ECmdIgnoreFailure")); |
|
304 iCmd = CCmdFinaliseDrives::NewL(severity); |
|
305 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
306 iCmd = NULL; |
|
307 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
308 |
|
309 severity = ECmdCriticalSeverity; |
|
310 INFO_PRINTF1(_L("doTestRunCleCmdFinaliseDrivesL, severity:ECmdCriticalSeverity")); |
|
311 iCmd = CCmdFinaliseDrives::NewL(severity); |
|
312 err = RunTestWithCleAndWaitL(iCmd); |
|
313 iCmd = NULL; |
|
314 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
315 } |
|
316 |
|
317 void CCmdRunCleTest::doTestRunCleCmdPersistHalAttributesL() |
|
318 { |
|
319 TInt expectedErr = KErrNone; |
|
320 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
321 |
|
322 INFO_PRINTF1(_L("doTestRunCleCmdPersistHalAttributesL, severity:ECmdIgnoreFailure")); |
|
323 iCmd = CCmdPersistHalAttributes::NewL(severity); |
|
324 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
325 iCmd = NULL; |
|
326 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
327 |
|
328 severity = ECmdCriticalSeverity; |
|
329 INFO_PRINTF1(_L("doTestRunCleCmdPersistHalAttributesL, severity:ECmdCriticalSeverity")); |
|
330 iCmd = CCmdPersistHalAttributes::NewL(severity); |
|
331 err = RunTestWithCleAndWaitL(iCmd); |
|
332 iCmd = NULL; |
|
333 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
334 } |
|
335 |
|
336 void CCmdRunCleTest::doTestRunCmdCreateSwpL() |
|
337 { |
|
338 TInt expectedType = ESsmCmdCreateSwp; |
|
339 TInt expectedErr = KErrNone; |
|
340 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
341 TSsmSwp swpInfo(KNewSwpKey, 876); |
|
342 TPtrC filename = KPolicyFilename(); |
|
343 |
|
344 INFO_PRINTF1(_L("doTestRunCmdCreateSwpL, severity:ECmdIgnoreFailure")); |
|
345 iCmd = CCmdCreateSwp::NewL(severity, swpInfo, filename); |
|
346 TEST(iCmd->Type() == expectedType); |
|
347 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
348 iCmd = NULL; |
|
349 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
350 |
|
351 severity = ECmdCriticalSeverity; |
|
352 swpInfo.Set(KNewSwpKey2, 767); |
|
353 INFO_PRINTF1(_L("doTestRunCmdCreateSwpL, severity:ECmdCriticalSeverity")); |
|
354 iCmd = CCmdCreateSwp::NewL(severity, swpInfo, filename); |
|
355 TEST(iCmd->Type() == expectedType); |
|
356 err = RunTestWithCleAndWaitL(iCmd); |
|
357 iCmd = NULL; |
|
358 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
359 } |
|
360 |
|
361 void CCmdRunCleTest::doTestRunCmdPowerOffL() |
|
362 { |
|
363 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
364 TInt err = KErrNone; |
|
365 TInt expectedErr = KErrNone; |
|
366 TPowerState powerEvent = EPwActive; |
|
367 |
|
368 INFO_PRINTF1(_L("doTestRunCmdPowerOffL, severity:ECmdIgnoreFailure, powerEvent:EPwActive")); |
|
369 iCmd = CCmdPowerOff::NewL(severity, powerEvent); |
|
370 err = RunTestWithCleAndWaitL(iCmd); |
|
371 iCmd = NULL; //ownership of iCmd is with Cle server |
|
372 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
373 TEST(err == expectedErr); |
|
374 |
|
375 severity = ECmdCriticalSeverity; |
|
376 INFO_PRINTF1(_L("doTestRunCmdPowerOffL, severity:ECmdCriticalSeverity, powerEvent:EPwActive")); |
|
377 iCmd = CCmdPowerOff::NewL(severity, powerEvent); |
|
378 err = RunTestWithCleAndWaitL(iCmd); |
|
379 iCmd = NULL; //ownership of iCmd is with Cle server |
|
380 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, KErrArgument); |
|
381 TEST(err == expectedErr | KErrArgument);//we are not testing the power event functionality |
|
382 } |
|
383 |
|
384 void CCmdRunCleTest::doTesTRunCleCmdMultipleWaitL() |
|
385 { |
|
386 TInt err = KErrNone; |
|
387 TInt expectedErr = KErrNone; |
|
388 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
389 TBool multipleWait = TRUE; |
|
390 |
|
391 INFO_PRINTF1(_L("doTesTRunCleCmdMultipleWaitL, Test:ESsmDeferredWaitForSignal, severity:ECmdIgnoreFailure")); |
|
392 SetStartupPropertiesL(KBadFileName, KEmptyArgs, ESsmDeferredWaitForSignal, ESsmCmdStartApp); |
|
393 iCmd = CCmdStartApp::NewL(severity,iStartupProperties); |
|
394 err = RunTestWithCleAndWaitL(iCmd,multipleWait); |
|
395 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
396 TEST(err == expectedErr); |
|
397 |
|
398 Reset(); |
|
399 iCmd = NULL; //ownership of iCmd is with Cle server |
|
400 TEST(err == expectedErr); |
|
401 } |
|
402 |
|
403 void CCmdRunCleTest::doTestRunCleCmdAmaStarterL() |
|
404 { |
|
405 TInt expectedErr = KErrNone; |
|
406 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
407 |
|
408 INFO_PRINTF1(_L("doTestRunCleCmdAmaStarterL, Test:ESsmFireAndForget, severity:ECmdIgnoreFailure")); |
|
409 iCmd = CCmdAmaStarter::NewL(severity, ESsmFireAndForget, KTestDscId); |
|
410 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
411 iCmd = NULL; //ownership of iCmd is with Cle server |
|
412 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
413 TEST(err == expectedErr); |
|
414 |
|
415 severity = ECmdCriticalSeverity; |
|
416 INFO_PRINTF1(_L("doTestRunCleCmdAmaStarterL, Test:ESsmFireAndForget, severity:ECmdCriticalSeverity")); |
|
417 iCmd = CCmdAmaStarter::NewL(severity, ESsmFireAndForget, KTestDscId); |
|
418 err = RunTestWithCleAndWaitL(iCmd); |
|
419 iCmd = NULL; //ownership of iCmd is with Cle server |
|
420 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
421 TEST(err == expectedErr); |
|
422 } |
|
423 |
|
424 void CCmdRunCleTest::doTestRunClePublishSwpL() |
|
425 { |
|
426 TInt expectedErr = KErrNone; |
|
427 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
428 TSsmSwp info(KSwpNullUid, 0); |
|
429 |
|
430 INFO_PRINTF1(_L("doTestRunClePublishSwp, Test:ESsmFireAndForget, severity:ECmdIgnoreFailure")); |
|
431 iCmd = CCmdPublishSwp::NewL(severity, ESsmFireAndForget, info); |
|
432 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
433 iCmd = NULL; //ownership of iCmd is with Cle server |
|
434 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
435 TEST(err == expectedErr); |
|
436 |
|
437 severity = ECmdCriticalSeverity; |
|
438 INFO_PRINTF1(_L("doTestRunClePublishSwp, Test:ESsmFireAndForget, severity:ECmdCriticalSeverity")); |
|
439 iCmd = CCmdPublishSwp::NewL(severity, ESsmFireAndForget, info); |
|
440 err = RunTestWithCleAndWaitL(iCmd); |
|
441 iCmd = NULL; //ownership of iCmd is with Cle server |
|
442 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
443 TEST(err == expectedErr); |
|
444 |
|
445 severity = ECmdHighSeverity; |
|
446 TSsmSwp info2(KNewSwpKey, 789); |
|
447 INFO_PRINTF1(_L("doTestRunClePublishSwp, Test:ESsmFireAndForget, severity:ECmdHighSeverity")); |
|
448 iCmd = CCmdPublishSwp::NewL(severity, ESsmFireAndForget, info2); |
|
449 err = RunTestWithCleAndWaitL(iCmd); |
|
450 iCmd = NULL; //ownership of iCmd is with Cle server |
|
451 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
452 TEST(err == expectedErr); |
|
453 } |
|
454 |
|
455 void CCmdRunCleTest::doTestRunCleCustomCommandL() |
|
456 { |
|
457 TInt expectedErr = KErrNone; |
|
458 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
459 TPtrC filename = KNoSuchDll(); |
|
460 TInt32 ordinal = 1; |
|
461 TPtrC8 params = KNullDesC8(); |
|
462 TCmdCustomCommandLibUnloading unloading = EUnloadOnCommandCompletion; |
|
463 |
|
464 CSsmCustomCommandInfo* info = new (ELeave) CSsmCustomCommandInfo(); |
|
465 CleanupStack::PushL(info); |
|
466 info->SetL(filename, ordinal, unloading, KNumOfRetries, params); |
|
467 |
|
468 INFO_PRINTF1(_L("doTestRunCleCustomCommand, Test:ESsmFireAndForget, severity:ECmdIgnoreFailure")); |
|
469 iCmd = CCmdCustomCommand::NewL(severity, ESsmFireAndForget, *info); |
|
470 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
471 iCmd = NULL; //ownership of iCmd is with Cle server |
|
472 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
473 TEST(err == expectedErr); |
|
474 |
|
475 severity = ECmdCriticalSeverity; |
|
476 INFO_PRINTF1(_L("doTestRunCleCustomCommand, Test:ESsmFireAndForget, severity:ECmdCriticalSeverity")); |
|
477 iCmd = CCmdCustomCommand::NewL(severity, ESsmFireAndForget, *info); |
|
478 err = RunTestWithCleAndWaitL(iCmd); |
|
479 iCmd = NULL; //ownership of iCmd is with Cle server |
|
480 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
481 TEST(err == expectedErr); |
|
482 |
|
483 severity = ECmdHighSeverity; |
|
484 INFO_PRINTF1(_L("doTestRunCleCustomCommand, Test:ESsmFireAndForget, severity:ECmdHighSeverity")); |
|
485 iCmd = CCmdCustomCommand::NewL(severity, ESsmFireAndForget, *info); |
|
486 err = RunTestWithCleAndWaitL(iCmd); |
|
487 iCmd = NULL; //ownership of iCmd is with Cle server |
|
488 CleanupStack::PopAndDestroy(info); |
|
489 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
490 TEST(err == expectedErr); |
|
491 } |
|
492 |
|
493 void CCmdRunCleTest::doTestRunCleCmdLoadSupL() |
|
494 { |
|
495 TInt err = KErrNone; |
|
496 TInt expectedErr = KErrNone; |
|
497 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
498 |
|
499 TUid uid; |
|
500 uid.iUid = 0; |
|
501 TInt32 ordinal = 1; |
|
502 TSsmSupInfo info; |
|
503 _LIT(KFileName, "tiCmdgoodsup.dll"); |
|
504 info.SetL(KFileName, ordinal, uid); |
|
505 |
|
506 INFO_PRINTF1(_L("doTestRunCleiCmdLoadSup, Test:ESsmFireAndForget, severity:ECmdIgnoreFailure")); |
|
507 iCmd = CCmdLoadSup::NewL(severity, ESsmFireAndForget, KNumOfRetries, info); |
|
508 err = RunTestWithCleAndWaitL(iCmd); |
|
509 iCmd = NULL;//ownership of iCmd is with Cle server |
|
510 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
511 TEST(err == expectedErr); |
|
512 |
|
513 severity = ECmdCriticalSeverity; |
|
514 INFO_PRINTF1(_L("doTestRunCleiCmdLoadSup, Test:ESsmFireAndForget, severity:ECmdCriticalSeverity")); |
|
515 iCmd = CCmdLoadSup::NewL(severity, ESsmFireAndForget, KNumOfRetries, info); |
|
516 err = RunTestWithCleAndWaitL(iCmd); |
|
517 iCmd = NULL;//ownership of iCmd is with Cle server |
|
518 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
519 TEST(err == expectedErr); |
|
520 } |
|
521 |
|
522 void CCmdRunCleTest::doTestRunCleCmdpublishSystemStateL() |
|
523 { |
|
524 TInt err = KErrNone; |
|
525 TInt expectedErr = KErrNone; |
|
526 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
527 TSsmPublishSystemStateInfo info; |
|
528 TSsmState state(ESsmEmergencyCallsOnly, 0); |
|
529 TTestSsmDirection direction = testTraverseDefault; |
|
530 |
|
531 info.Set(state, direction, KNumOfRetries); |
|
532 |
|
533 INFO_PRINTF1(_L("doTestRunCleCmdpublishSystemState Test:ESsmFireAndForget severity:ECmdIgnoreFailure")); |
|
534 iCmd = CCmdPublishSystemState::NewL(severity, ESsmFireAndForget, info); |
|
535 err = RunTestWithCleAndWaitL(iCmd); |
|
536 iCmd = NULL; |
|
537 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
538 TEST(err == expectedErr); |
|
539 |
|
540 severity = ECmdCriticalSeverity; |
|
541 INFO_PRINTF1(_L("doTestRunCleCmdpublishSystemState Test:ESsmFireAndForget severity:ECmdCriticalSeverity")); |
|
542 iCmd = CCmdPublishSystemState::NewL(severity, ESsmFireAndForget, info); |
|
543 err = RunTestWithCleAndWaitL(iCmd); |
|
544 iCmd = NULL; |
|
545 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
546 TEST(err == expectedErr); |
|
547 } |
|
548 |
|
549 void CCmdRunCleTest::doTestRunCleCcmdreqSwpchangeL() |
|
550 { |
|
551 TInt err = KErrNone; |
|
552 TInt expectedErr = KErrNone; |
|
553 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
554 TSsmExecutionBehaviour executionBehaviour = ESsmWaitForSignal; |
|
555 TSsmSwp info(KNewSwpKey, 876); |
|
556 |
|
557 INFO_PRINTF1(_L("Test:doTestRunCleCiCmdreqSwpchangeL Test:ESsmWaitForSignal severity:ECmdIgnoreFailure")); |
|
558 iCmd = CCmdReqSwpChange::NewL(severity, executionBehaviour, info); |
|
559 err = RunTestWithCleAndWaitL(iCmd); |
|
560 iCmd = NULL; |
|
561 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
562 TEST(err == expectedErr); |
|
563 |
|
564 severity = ECmdCriticalSeverity; |
|
565 info.Set(KNewSwpKey2, 767); |
|
566 INFO_PRINTF1(_L("Test:doTestRunCleCiCmdreqSwpchangeL Test:ESsmWaitForSignal severity:ECmdCriticalSeverity")); |
|
567 iCmd = CCmdReqSwpChange::NewL(severity, executionBehaviour, info); |
|
568 err = RunTestWithCleAndWaitL(iCmd); |
|
569 iCmd = NULL; |
|
570 INFO_PRINTF3(_L("Command execution finished with error : %d, expectedErr : %d. "), err, expectedErr); |
|
571 TEST(err == expectedErr); |
|
572 } |
|
573 |
|
574 void CCmdRunCleTest::doTestRunCleCmdStartAppL() |
|
575 { |
|
576 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
577 TInt expectedErr = KErrNone; |
|
578 |
|
579 INFO_PRINTF1(_L("doTestRunCleCmdStartAppL Start a non existing application Test:ESsmFireAndForget severity:ECmdIgnoreFailure")); |
|
580 SetStartupPropertiesL(KBadFileName, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartApp); |
|
581 iCmd = CCmdStartApp::NewL(severity,iStartupProperties); |
|
582 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
583 iCmd = NULL; |
|
584 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
585 TEST(err == expectedErr); |
|
586 Reset(); |
|
587 |
|
588 INFO_PRINTF2(_L("doTestRunCleCmdStartAppL Start a non existing application Test:ESsmFireAndForget severity:ECmdIgnoreFailure and retries %d"), KNumOfRetries); |
|
589 SetStartupPropertiesL(KBadFileName, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartApp, KNumOfRetries); |
|
590 iCmd = CCmdStartApp::NewL(severity,iStartupProperties); |
|
591 err = RunTestWithCleAndWaitL(iCmd); |
|
592 iCmd = NULL; |
|
593 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
594 TEST(err == expectedErr); |
|
595 Reset(); |
|
596 |
|
597 INFO_PRINTF2(_L("doTestRunCleCmdStartAppL Start a non existing application Test:ESsmFireAndForget severity:ECmdIgnoreFailure and timeout %d "), 10); |
|
598 SetStartupPropertiesL(KSlowStartApp, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartApp, 0, 10); //time out is given 10ms so that F&F iCmd finishes before below tests are finished |
|
599 iCmd = CCmdStartApp::NewL(severity,iStartupProperties); |
|
600 err = RunTestWithCleAndWaitL(iCmd); |
|
601 iCmd = NULL; |
|
602 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
603 TEST(err == expectedErr); |
|
604 Reset(); |
|
605 |
|
606 severity = ECmdHighSeverity; |
|
607 INFO_PRINTF1(_L("doTestRunCleCmdStartAppL Start a non existing application Test:ESsmFireAndForget severity:ECmdHighSeverity")); |
|
608 SetStartupPropertiesL(KBadFileName, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartApp); |
|
609 iCmd = CCmdStartApp::NewL(severity,iStartupProperties); |
|
610 err = RunTestWithCleAndWaitL(iCmd); |
|
611 iCmd = NULL; |
|
612 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
613 TEST(err == expectedErr); |
|
614 Reset(); |
|
615 |
|
616 INFO_PRINTF2(_L("doTestRunCleCmdStartAppL Start a non existing application Test:ESsmFireAndForget severity:ECmdHighSeverity and retries %d"), KNumOfRetries); |
|
617 SetStartupPropertiesL(KBadFileName, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartApp, KNumOfRetries); |
|
618 iCmd = CCmdStartApp::NewL(severity,iStartupProperties); |
|
619 err = RunTestWithCleAndWaitL(iCmd); |
|
620 iCmd = NULL; |
|
621 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
622 TEST(err == expectedErr); |
|
623 Reset(); |
|
624 |
|
625 INFO_PRINTF2(_L("doTestRunCleCmdStartAppL Start a non existing application Test:ESsmFireAndForget severity:ECmdHighSeverity and timeout %d "), 10); |
|
626 SetStartupPropertiesL(KSlowStartApp, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartApp, 0, 10); //time out is given 10ms so that F&F iCmd finishes before below tests are finished |
|
627 iCmd = CCmdStartApp::NewL(severity,iStartupProperties); |
|
628 err = RunTestWithCleAndWaitL(iCmd); |
|
629 iCmd = NULL; |
|
630 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
631 TEST(err == expectedErr); |
|
632 Reset(); |
|
633 } |
|
634 |
|
635 void CCmdRunCleTest::doTestRunCleFandFAppWithMonitorL() |
|
636 { |
|
637 // The KIntervalForReLaunchRateOfFailure time interval is 30mins by default, its patched to 25secs on emulator in epoc.ini file |
|
638 // and for hardware in iby file. |
|
639 INFO_PRINTF1(_L("For test to pass in Winscw - (patchdata_sysmon_exe_KIntervalForReLaunchRateOfFailure 25) should be added to epoc32\\data\\epoc.ini file")); |
|
640 |
|
641 INFO_PRINTF1(_L("Test:doTestRunCleFandFAppWithMonitorL - command ECmdIgnoreFailure Severity")); |
|
642 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
643 SetStartupPropertiesL(KTestAppGood, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartApp, 1, 0); |
|
644 TSsmMonitorInfo monitorInfo; |
|
645 monitorInfo.iRestartPolicy = ESsmIgnoreOnFailure; |
|
646 monitorInfo.iRestartMode = 0; |
|
647 monitorInfo.iRetries = 1; |
|
648 monitorInfo.iTimeout = 0; |
|
649 iStartupProperties->SetMonitorInfoL(monitorInfo); |
|
650 INFO_PRINTF1(_L("doTestRunCleFandFAppWithMonitorL:Start a application with execution behaviour as ESsmFireAndForget")); |
|
651 iCmd = CCmdStartApp::NewL(severity,iStartupProperties); |
|
652 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
653 |
|
654 //Waiting to decrement the count of the semaphore which is being signalled as the application is started first time |
|
655 iSem.Wait(); |
|
656 |
|
657 INFO_PRINTF1(_L("Call Find and Kill now - instances should be one")); |
|
658 User::After(1000000); |
|
659 //find and kill the application |
|
660 TEST(1 == FindAndKill(KTestAppGood)); |
|
661 |
|
662 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
663 INFO_PRINTF1(_L("Wait for one second and call Find and Kill again - instances should be zero")); |
|
664 User::After(KThrottleTime); |
|
665 // system monitor waits for 15secs(throttle time) before restarting the application |
|
666 TEST(0 == FindAndKill(KTestAppGood)); |
|
667 |
|
668 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
669 INFO_PRINTF1(_L("Wait for Throttle time and call find and kill again - instances should be one")); |
|
670 //Waiting for the application to restart using semaphore |
|
671 iSem.Wait(); |
|
672 |
|
673 // application is restarted by system monitor |
|
674 TEST(1 == FindAndKill(KTestAppGood)); |
|
675 |
|
676 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
677 INFO_PRINTF1(_L("Wait for one second and call Find and Kill again - instances should be zero")); |
|
678 User::After(KThrottleTime); |
|
679 // application is restarted by system monitor |
|
680 TEST(0 == FindAndKill(KTestAppGood)); |
|
681 |
|
682 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
683 INFO_PRINTF1(_L("Wait for Throttle time and call find and kill again - instances should be one")); |
|
684 //Waiting for the application to restart using semaphore |
|
685 iSem.Wait(); |
|
686 |
|
687 // application is restarted by system monitor |
|
688 TEST(1 == FindAndKill(KTestAppGood)); |
|
689 |
|
690 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
691 INFO_PRINTF1(_L("Wait for more than throttle time and call find and kill again - instances should be one")); |
|
692 INFO_PRINTF1(_L("Done to ensure that the app is closed and not hanging around")); |
|
693 //Waiting for the application to restart using semaphore |
|
694 iSem.Wait(); |
|
695 |
|
696 TEST(1 == FindAndKill(KTestAppGood)); |
|
697 //As this test case is successfully executed, reset all data |
|
698 INFO_PRINTF1(_L("Waiting simply now - just to check no proc is leftover")); |
|
699 User::After(KThrottleTime); |
|
700 TEST(0 == FindAndKill(KTestAppGood)); |
|
701 iCmd = NULL; |
|
702 Reset(); |
|
703 } |
|
704 |
|
705 void CCmdRunCleTest::doTestRunCleCmdStartProcessL() |
|
706 { |
|
707 TCmdErrorSeverity severity = ECmdHighSeverity; |
|
708 TInt expectedErr = KErrNotFound; |
|
709 |
|
710 INFO_PRINTF1(_L("doTestRunCleCmdStartProcessL Start a non existing application Test:ESsmFireAndForget severity:ECmdHighSeverity")); |
|
711 // FireAndForget execution behaviour does not dependent on completion code so it will always return KErrNone |
|
712 expectedErr = KErrNone; |
|
713 SetStartupPropertiesL(KBadFileName, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartProcess); |
|
714 iCmd = CCmdStartProcess::NewL(severity,iStartupProperties); |
|
715 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
716 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
717 iCmd = NULL; |
|
718 TEST(err == expectedErr); |
|
719 Reset(); |
|
720 |
|
721 INFO_PRINTF2(_L("doTestRunCleCmdStartProcessL Start a non existing application Test:ESsmFireAndForget severity:ECmdHighSeverity and retries %d"), KNumOfRetries); |
|
722 SetStartupPropertiesL(KBadFileName, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartProcess, KNumOfRetries); |
|
723 iCmd = CCmdStartProcess::NewL(severity,iStartupProperties); |
|
724 err = RunTestWithCleAndWaitL(iCmd); |
|
725 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
726 iCmd = NULL; |
|
727 TEST(err == expectedErr); |
|
728 Reset(); |
|
729 |
|
730 INFO_PRINTF2(_L("doTestRunCleCmdStartProcessL Start a non existing application Test:ESsmFireAndForget severity:ECmdHighSeverity and timeout %d "), 10); |
|
731 SetStartupPropertiesL(KSlowStartApp, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartProcess, 0, 10); |
|
732 iCmd = CCmdStartProcess::NewL(severity,iStartupProperties); |
|
733 err = RunTestWithCleAndWaitL(iCmd); |
|
734 iCmd = NULL; |
|
735 INFO_PRINTF3(_L("Test completed with err: %d. Expected err : %d "), err,expectedErr); |
|
736 TEST(err == expectedErr); |
|
737 Reset(); |
|
738 } |
|
739 |
|
740 void CCmdRunCleTest::doTestRunCleFandFProcWithMonitorL() |
|
741 { |
|
742 // The KIntervalForReLaunchRateOfFailure time interval is 30mins by default, its patched to 25secs on emulator in epoc.ini file |
|
743 // and for hardware in iby file. |
|
744 INFO_PRINTF1(_L("For test to pass in Winscw - (patchdata_sysmon_exe_KIntervalForReLaunchRateOfFailure 25) should be added to epoc32\\data\\epoc.ini file")); |
|
745 |
|
746 INFO_PRINTF1(_L("Test:doTestRunCleFandFProcWithMonitorL - command ECmdIgnoreFailure Severity")); |
|
747 |
|
748 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
749 SetStartupPropertiesL(KGoodProc, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartProcess, 1, 0); |
|
750 TSsmMonitorInfo monitorInfo; |
|
751 monitorInfo.iRestartPolicy = ESsmIgnoreOnFailure; |
|
752 monitorInfo.iRestartMode = 0; |
|
753 monitorInfo.iRetries = 1; |
|
754 monitorInfo.iTimeout = 0; |
|
755 iStartupProperties->SetMonitorInfoL(monitorInfo); |
|
756 INFO_PRINTF1(_L("doTestRunCleFandFProcWithMonitorL:Start a process with execution behaviour as ESsmFireAndForget")); |
|
757 iCmd = CCmdStartProcess::NewL(severity,iStartupProperties); |
|
758 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
759 iCmd = NULL; |
|
760 |
|
761 //Waiting to decrement the count of the semaphore which is being signalled as the application is started first time |
|
762 iSem.Wait(); |
|
763 |
|
764 INFO_PRINTF1(_L("Call Find and Kill now - instances should be one")); |
|
765 User::After(1000000); |
|
766 //find and kill the process |
|
767 TEST(1 == FindAndKill(KGoodProc)); |
|
768 |
|
769 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
770 INFO_PRINTF1(_L("Wait for one second and call Find and Kill again - instances should be zero")); |
|
771 User::After(KThrottleTime); |
|
772 // system monitor waits for 15secs(throttle time) before restarting the process |
|
773 TEST(0 == FindAndKill(KGoodProc)); |
|
774 |
|
775 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
776 INFO_PRINTF1(_L("Wait for Throttle time and call find and kill again - instances should be one")); |
|
777 //Waiting for the process to restart using semaphore |
|
778 iSem.Wait(); |
|
779 // Process is restarted by system monitor |
|
780 TEST(1 == FindAndKill(KGoodProc)); |
|
781 |
|
782 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
783 INFO_PRINTF1(_L("Wait for one second and call Find and Kill again - instances should be zero")); |
|
784 User::After(KThrottleTime); |
|
785 // application is restarted by system monitor |
|
786 TEST(0 == FindAndKill(KGoodProc)); |
|
787 |
|
788 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
789 INFO_PRINTF1(_L("Wait for Throttle time and call find and kill again - instances should be one")); |
|
790 //Waiting for the process to restart using semaphore |
|
791 iSem.Wait(); |
|
792 // application is restarted by system monitor |
|
793 TEST(1 == FindAndKill(KGoodProc)); |
|
794 |
|
795 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
796 INFO_PRINTF1(_L("Wait for more than throttle time and call find and kill again - instances should be one")); |
|
797 //INFO_PRINTF1(_L("Done to ensure that the app is closed and not hanging around")); |
|
798 //Waiting for the process to restart using semaphore |
|
799 iSem.Wait(); |
|
800 TEST(1 == FindAndKill(KGoodProc)); |
|
801 |
|
802 //As this test case is successfully executed, reset all data |
|
803 Reset(); |
|
804 } |
|
805 |
|
806 void CCmdRunCleTest::doTestRunCleFandFAlreadyRunWithMonitorL() |
|
807 { |
|
808 // The KIntervalForReLaunchRateOfFailure time interval is 30mins by default, its patched to 25secs on emulator in epoc.ini file |
|
809 // and for hardware in iby file. |
|
810 INFO_PRINTF1(_L("For test to pass in Winscw - (patchdata_sysmon_exe_KIntervalForReLaunchRateOfFailure 25) should be added to epoc32\\data\\epoc.ini file")); |
|
811 |
|
812 INFO_PRINTF1(_L("Test:doTestRunCleFandFAlreadyRunWithMonitorL - command ECmdIgnoreFailure Severity")); |
|
813 |
|
814 //Create and launch the process |
|
815 RProcess process; |
|
816 CleanupClosePushL(process); |
|
817 User::LeaveIfError(process.Create(KGoodProc, KLaunchServerCommandLineOption)); |
|
818 |
|
819 TCmdErrorSeverity severity = ECmdIgnoreFailure; |
|
820 SetStartupPropertiesL(KGoodProc, KEmptyArgs, ESsmFireAndForget, ESsmCmdStartProcess, 1, 0); |
|
821 TSsmMonitorInfo monitorInfo; |
|
822 monitorInfo.iRestartPolicy = ESsmIgnoreOnFailure; |
|
823 monitorInfo.iRestartMode = 0; |
|
824 monitorInfo.iRetries = 1; |
|
825 monitorInfo.iTimeout = 0; |
|
826 iStartupProperties->SetMonitorInfoL(monitorInfo); |
|
827 INFO_PRINTF1(_L("doTestRunCleFandFAlreadyRunWithMonitorL:Start an already running process with execution behaviour as ESsmFireAndForget")); |
|
828 |
|
829 //Try and launch the process again, SysMon will monitor already running process |
|
830 iCmd = CCmdStartProcess::NewL(severity,iStartupProperties); |
|
831 TInt err = RunTestWithCleAndWaitL(iCmd); |
|
832 iCmd = NULL; |
|
833 |
|
834 //Waiting to decrement the count of the semaphore which is being signalled as the application is started first time |
|
835 iSem.Wait(); |
|
836 |
|
837 INFO_PRINTF1(_L("Call Find and Kill now - instances should be two")); |
|
838 //find and kill both the processes |
|
839 User::After(1000000); |
|
840 TEST(2 == FindAndKill(KGoodProc)); |
|
841 |
|
842 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
843 INFO_PRINTF1(_L("Wait for one second and call Find and Kill again - instances should be zero")); |
|
844 User::After(KThrottleTime); |
|
845 // system monitor waits for 15secs(throttle time) before restarting the process |
|
846 TEST(0 == FindAndKill(KGoodProc)); |
|
847 |
|
848 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
849 INFO_PRINTF1(_L("Wait for Throttle time and call find and kill again - instances should be one")); |
|
850 //Waiting for the process to restart using semaphore |
|
851 iSem.Wait(); |
|
852 // Process is restarted by system monitor |
|
853 TEST(1 == FindAndKill(KGoodProc)); |
|
854 |
|
855 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
856 INFO_PRINTF1(_L("Wait for one second and call Find and Kill again - instances should be zero")); |
|
857 User::After(KThrottleTime); |
|
858 // Process is restarted by system monitor |
|
859 TEST(0 == FindAndKill(KGoodProc)); |
|
860 |
|
861 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
862 INFO_PRINTF1(_L("Wait for Throttle time and call find and kill again - instances should be one")); |
|
863 //Waiting for the process to restart using semaphore |
|
864 iSem.Wait(); |
|
865 // Process is restarted by system monitor |
|
866 TEST(1 == FindAndKill(KGoodProc)); |
|
867 |
|
868 INFO_PRINTF1(_L("-----------------------------------------------------------------------------")); |
|
869 INFO_PRINTF1(_L("Wait for more than throttle time and call find and kill again - instances should be one")); |
|
870 INFO_PRINTF1(_L("Done to ensure that the app is closed and not hanging around")); |
|
871 //Waiting for the process to restart using semaphore |
|
872 iSem.Wait(); |
|
873 TEST(1 == FindAndKill(KGoodProc)); |
|
874 |
|
875 //As this test case is successfully executed, reset all data |
|
876 Reset(); |
|
877 CleanupStack::PopAndDestroy(); |
|
878 } |
|
879 |
|
880 /** |
|
881 Helper functiosn to set specified values in iStartupProperties. |
|
882 */ |
|
883 void CCmdRunCleTest::SetStartupPropertiesL(const TDesC& aFileName, const TDesC& aArgs, TSsmExecutionBehaviour aExecutionBehaviour, TSsmCommandType aSsmCommandType, TInt aNumOfRetries, TInt32 aTimeout) |
|
884 { |
|
885 iStartupProperties->Reset(); |
|
886 iStartupProperties->SetFileParamsL(aFileName, aArgs); |
|
887 iStartupProperties->SetCommandTypeL(aSsmCommandType); |
|
888 iStartupProperties->SetExecutionBehaviour(aExecutionBehaviour); |
|
889 iStartupProperties->SetRetries(aNumOfRetries); |
|
890 iStartupProperties->SetTimeout(aTimeout); |
|
891 } |
|
892 |
|
893 /** |
|
894 Resets iStartupProperties |
|
895 */ |
|
896 void CCmdRunCleTest::Reset() |
|
897 { |
|
898 iStartupProperties->Reset(); |
|
899 } |
|
900 |
|
901 // |
|
902 // Helper functions for StartApp and StartProcess commands |
|
903 // |
|
904 /** |
|
905 Helper function to find and kill the specified process |
|
906 */ |
|
907 TInt CCmdRunCleTest::FindAndKill(const TDesC& aProcessName) |
|
908 { |
|
909 TFullName searchTerm(aProcessName); |
|
910 StripExtension(searchTerm); |
|
911 searchTerm += _L("*"); |
|
912 TFindProcess find(searchTerm); |
|
913 TFullName name; |
|
914 TInt instancesFound = 0; |
|
915 while(find.Next(name) == KErrNone) |
|
916 { |
|
917 RProcess process; |
|
918 const TInt err = process.Open(find); |
|
919 |
|
920 if (KErrNone == err) |
|
921 { |
|
922 if (process.ExitType() == EExitPending) |
|
923 { |
|
924 instancesFound++; |
|
925 process.Kill(KErrCancel); |
|
926 INFO_PRINTF3(_L("Process %S found and killed with Exit Reason = %d"), &aProcessName, process.ExitReason()); |
|
927 } |
|
928 process.Close(); |
|
929 } |
|
930 } |
|
931 INFO_PRINTF2(_L("No of instances of process killed = %d"), instancesFound); |
|
932 return instancesFound; |
|
933 } |
|
934 |
|
935 /** |
|
936 Helper function to strip extension |
|
937 */ |
|
938 void CCmdRunCleTest::StripExtension(TDes& aFilename) |
|
939 { |
|
940 TInt dot = aFilename.Find(_L(".")); |
|
941 |
|
942 if(KErrNotFound != dot) |
|
943 { |
|
944 aFilename.SetLength(dot); |
|
945 } |
|
946 } |