1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
29 |
29 |
30 |
30 |
31 const TInt KThrottleTime = 15000000; //15s |
31 const TInt KThrottleTime = 15000000; //15s |
32 const TInt KStartMonStopperTimeout = 5000000; // Could (probably) be shaved. |
32 const TInt KStartMonStopperTimeout = 5000000; // Could (probably) be shaved. |
33 |
33 |
|
34 _LIT(KTestProcGoodFullPath, "z:\\sys\\bin\\ssmtestprocgood1.exe"); |
|
35 _LIT(KTestProcName, "ssmtestprocgood1.exe"); |
34 |
36 |
35 TVerdict CSsTestStepProcStartMon::doTestStepL( void ) |
37 TVerdict CSsTestStepProcStartMon::doTestStepL( void ) |
36 { |
38 { |
37 //Creating the semaphore |
39 //Creating the semaphore |
38 TInt err = iSem.CreateGlobal(KStartProcSignalSemaphore, 0); |
40 TInt err = iSem.CreateGlobal(KStartProcSignalSemaphore, 0); |
39 INFO_PRINTF2(_L("Created semaphore with err %d"),err); |
41 INFO_PRINTF2(_L("Created semaphore with err %d"),err); |
40 TEST(err == KErrNone); |
42 TEST(err == KErrNone); |
41 |
43 |
42 __UHEAP_MARK; |
44 __UHEAP_MARK; |
43 |
45 |
44 TRAP(err, DoTestMonForAlreadyStartedProcL()); |
46 TRAP(err, DoTestMonForAlreadyStartedProcL(KTestProcGoodFullPath, KTestProcName)); |
45 TEST(err == KErrNone); |
47 TEST(err == KErrNone); |
46 INFO_PRINTF2(_L("DoTestMonForAlreadyStartedProcL completed with err = %d"), err); |
48 INFO_PRINTF2(_L("DoTestMonForAlreadyStartedProcL using exe name with full path completed with err = %d"), err); |
47 |
49 |
|
50 TRAP(err, DoTestMonForAlreadyStartedProcL(KTestProcGood, KTestProcGood)); |
|
51 TEST(err == KErrNone); |
|
52 INFO_PRINTF2(_L("DoTestMonForAlreadyStartedProcL using only exe name[without path] completed with err = %d"), err); |
|
53 |
48 TRAP(err, DoTestMonSyncL()); |
54 TRAP(err, DoTestMonSyncL()); |
49 TEST(err == KErrNone); |
55 TEST(err == KErrNone); |
50 INFO_PRINTF2(_L("DoTestMonSyncL completed with err = %d"), err); |
56 INFO_PRINTF2(_L("DoTestMonSyncL completed with err = %d"), err); |
51 |
57 |
52 __UHEAP_MARKEND; |
58 __UHEAP_MARKEND; |
119 TEST( 0 == FindAndKill(KTestProcGood) ); |
125 TEST( 0 == FindAndKill(KTestProcGood) ); |
120 |
126 |
121 CleanupStack::PopAndDestroy( 4, startupProperties ); |
127 CleanupStack::PopAndDestroy( 4, startupProperties ); |
122 } |
128 } |
123 |
129 |
124 void CSsTestStepProcStartMon::DoTestMonForAlreadyStartedProcL() |
130 void CSsTestStepProcStartMon::DoTestMonForAlreadyStartedProcL(const TDesC& aFileNameWithPath, const TDesC& aProcName) |
125 { |
131 { |
126 INFO_PRINTF1( _L("Performing Process-monitor test for already started process") ); |
132 INFO_PRINTF1( _L("Performing Process-monitor test for already started process") ); |
127 |
133 |
128 RProcess process; |
134 RProcess process; |
129 CleanupClosePushL(process); |
135 CleanupClosePushL(process); |
130 User::LeaveIfError(process.Create(KTestProcGood, KLaunchServerCommandLineOption)); |
136 User::LeaveIfError(process.Create(aProcName, KLaunchServerCommandLineOption)); |
131 |
137 |
132 TRequestStatus status; |
138 TRequestStatus status; |
133 process.Rendezvous(status); |
139 process.Rendezvous(status); |
134 if (status == KRequestPending) |
140 if (status == KRequestPending) |
135 { |
141 { |
149 |
155 |
150 CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL(); |
156 CSsmStartupProperties* startupProperties = CSsmStartupProperties::NewL(); |
151 CleanupStack::PushL( startupProperties ); |
157 CleanupStack::PushL( startupProperties ); |
152 |
158 |
153 // Need to start testprocess as a server so that we can tell it to stop being monitored. |
159 // Need to start testprocess as a server so that we can tell it to stop being monitored. |
154 startupProperties->SetFileParamsL(KTestProcGood, KLaunchServerCommandLineOption); |
160 startupProperties->SetFileParamsL(aFileNameWithPath, KLaunchServerCommandLineOption); |
155 startupProperties->SetCommandTypeL(ESsmCmdStartProcess); |
161 startupProperties->SetCommandTypeL(ESsmCmdStartProcess); |
156 startupProperties->SetExecutionBehaviour(ESsmWaitForSignal); |
162 startupProperties->SetExecutionBehaviour(ESsmWaitForSignal); |
157 |
163 |
158 const TInt KMonitorTimeout = 3000; // milliseconds I presume |
164 const TInt KMonitorTimeout = 3000; // milliseconds I presume |
159 TSsmMonitorInfo monitorInfo; |
165 TSsmMonitorInfo monitorInfo; |
199 if(KErrNone == testProcServerSession.Connect()) |
205 if(KErrNone == testProcServerSession.Connect()) |
200 { |
206 { |
201 testProcServerSession.CancelMonitor(); |
207 testProcServerSession.CancelMonitor(); |
202 testProcServerSession.Close(); |
208 testProcServerSession.Close(); |
203 } |
209 } |
204 TEST(1 == FindAndKill(KTestProcGood)); |
210 TEST(1 == FindAndKill(aProcName)); |
|
211 |
205 CleanupStack::PopAndDestroy(3, &process); |
212 CleanupStack::PopAndDestroy(3, &process); |
206 } |
213 } |
207 |
214 |
208 void CSsTestStepProcStartMon::SsTestNotify( TInt aNotify ) |
215 void CSsTestStepProcStartMon::SsTestNotify( TInt aNotify ) |
209 { |
216 { |