|
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 "testprocgoodsession.h" |
|
23 #include "tsysmon_steprestartthrottle.h" |
|
24 |
|
25 |
|
26 CStepRestartThrottle::CStepRestartThrottle() |
|
27 { |
|
28 SetTestStepName(KCTestCaseRestartThrottle); |
|
29 } |
|
30 /** |
|
31 Old Test CaseID APPFWK-SYSMON-0004 |
|
32 New Test CaseID DEVSRVS-SHMA-SYSMON-0004 |
|
33 */ |
|
34 |
|
35 TVerdict CStepRestartThrottle::doTestStepL() |
|
36 { |
|
37 TInt err = iProcStartSignalSem.CreateGlobal(KStartShmaTestProcGood,0); |
|
38 INFO_PRINTF2(_L("Semaphore created with err %d"), err); |
|
39 TEST(KErrNone == err); |
|
40 |
|
41 INFO_PRINTF1(_L("TEST APPFWK-SYSMON-0004")); |
|
42 |
|
43 INFO_PRINTF1(_L("New Test step")); |
|
44 INFO_PRINTF1(_L("Test System Monitor functionality using startupproperties")); |
|
45 RProcess process; |
|
46 CleanupClosePushL(process); |
|
47 StartAndMonitorUsingStartupPropL(process, EWaitForStart); |
|
48 |
|
49 iProcStartSignalSem.Wait(); |
|
50 //Killing the process will cause sysmon to restart after KWaitTime (declared in sysmon_patch.h) |
|
51 process.Kill(KErrNone); |
|
52 CleanupStack::Pop(&process); |
|
53 INFO_PRINTF1(_L("Killed monitored process.")); |
|
54 DoTestMonitor(); |
|
55 |
|
56 INFO_PRINTF1(_L("Test System Monitor functionality using ssmstartupproperties")); |
|
57 CleanupClosePushL(process); |
|
58 StartAndMonitorUsingSsmStartupPropL(process, EWaitForStart); |
|
59 |
|
60 iProcStartSignalSem.Wait(); |
|
61 //Killing the process will cause sysmon to restart after KWaitTime (declared in sysmon_patch.h) |
|
62 process.Kill(KErrNone); |
|
63 CleanupStack::PopAndDestroy(&process); |
|
64 INFO_PRINTF1(_L("Killed monitored process.")); |
|
65 DoTestMonitor(); |
|
66 |
|
67 INFO_PRINTF1(_L("Test complete")); |
|
68 iProcStartSignalSem.Close(); |
|
69 return TestStepResult(); |
|
70 } |
|
71 |
|
72 void CStepRestartThrottle::DoTestMonitor() |
|
73 { |
|
74 //Sleep 14 seconds and then assert that the server is not yet restarted |
|
75 INFO_PRINTF1(_L("Going to sleep for 14 seconds.")); |
|
76 User::After(KThrottleTime - 1000000); |
|
77 RTestProcGoodSession server; |
|
78 TInt err = server.Connect(); |
|
79 TESTE(KErrNotFound == err, err); |
|
80 server.Close(); |
|
81 if(KErrNotFound == err) |
|
82 { |
|
83 INFO_PRINTF1(_L("Asserted that server is not yet restarted.")); |
|
84 } |
|
85 else |
|
86 { |
|
87 ERR_PRINTF1(_L("Error - the restart took place too soon.")); |
|
88 } |
|
89 |
|
90 //Allow the process to be restarted |
|
91 INFO_PRINTF1(_L("Waiting till the process is restarted using semaphore.")); |
|
92 //Wait for the process to be restarted |
|
93 iProcStartSignalSem.Wait(); |
|
94 |
|
95 //Assert that the server is running |
|
96 INFO_PRINTF1(_L("Woke up, now the server should be restarted (sysmon KWaitTime is 15s).")); |
|
97 err = server.Connect(); |
|
98 TESTE(KErrNone == err, err); |
|
99 if(KErrNone == err) |
|
100 { |
|
101 INFO_PRINTF1(_L("Yes, asserted that server is running, going to cancel monitoring shutdown server")); |
|
102 } |
|
103 server.CancelMonitor(); |
|
104 server.ShutDown(); |
|
105 server.Close(); |
|
106 } |