|
1 // Copyright (c) 2003-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 // This contains RootServer Test cases from section 6 |
|
15 // |
|
16 // |
|
17 |
|
18 // EPOC includes |
|
19 #include <e32base.h> |
|
20 #include <es_mbman.h> |
|
21 |
|
22 // Test system includes |
|
23 //#include <networking/log.h> |
|
24 //#include <networking/teststep.h> |
|
25 //#include <networking/testsuite.h> |
|
26 |
|
27 #include "TestStepRootServer.h" |
|
28 #include "TestAsynchHandler.h" |
|
29 #include "RootServerTestSection5.h" |
|
30 #include "RootServerTest.h" |
|
31 // Test step 3.5 - Retrieve Module Information |
|
32 CRootServerTest_GracefulUnload::CRootServerTest_GracefulUnload(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 TVerdict CRootServerTest_GracefulUnload::UnloadGracefullyL(TThreadPriority aPriority) |
|
38 { |
|
39 SetTestStepResult(EFail); |
|
40 // Create scheduler/active object framework |
|
41 CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC(); |
|
42 CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess()); |
|
43 |
|
44 //*****************step 2************************ |
|
45 INFO_PRINTF1(_L("02 Load test module")); |
|
46 |
|
47 TRSStartModuleParams startParams; |
|
48 TTestModuleIniData iniData; |
|
49 DefaultStartParams(startParams, iniData); |
|
50 startParams.iParams.iName = KModule1; |
|
51 startParams.iParams.iPriority = aPriority; |
|
52 |
|
53 asynchHandler->TryLoad(startParams, iniData); |
|
54 CActiveScheduler::Start(); |
|
55 if (asynchHandler->iStatus != KErrNone) |
|
56 { |
|
57 INFO_PRINTF2(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
58 SetTestStepResult(EInconclusive); |
|
59 } |
|
60 else |
|
61 { |
|
62 //*****************step 4*********************** |
|
63 INFO_PRINTF1(_L("04 Unload Test Module")); |
|
64 |
|
65 asynchHandler->TryUnLoad(startParams.iParams.iName, EGraceful); |
|
66 |
|
67 CActiveScheduler::Start(); |
|
68 |
|
69 if (asynchHandler->iStatus != KErrNone) |
|
70 { |
|
71 INFO_PRINTF2(_L("Unload returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
72 SetTestStepResult(EInconclusive); |
|
73 } |
|
74 else |
|
75 { |
|
76 SetTestStepResult(EPass); } |
|
77 } |
|
78 |
|
79 // uninstall and destroy active scheduler |
|
80 CleanupStack::PopAndDestroy(asynchHandler); |
|
81 CleanupStack::PopAndDestroy(scheduler); |
|
82 return TestStepResult(); |
|
83 } |
|
84 |
|
85 |
|
86 // Test step 5.1 - UnLoad Gracefully (normal priority) |
|
87 CRootServerTest5_1::CRootServerTest5_1(CTE_RootServerServer *aSuite) : CRootServerTest_GracefulUnload(aSuite) |
|
88 { |
|
89 // store the name of this test case |
|
90 SetTestStepName(_L("Test5.1")); |
|
91 } |
|
92 |
|
93 TVerdict CRootServerTest5_1::doTestStepL( void ) |
|
94 { |
|
95 INFO_PRINTF1(_L("Test Purpose: UnLoad Comms Provider Module gracefully (normal priority)")); |
|
96 return UnloadGracefullyL(EPriorityNormal); |
|
97 } |
|
98 |
|
99 |
|
100 // Test step 5.2 - UnLoad Gracefully (elevated priority) |
|
101 CRootServerTest5_2::CRootServerTest5_2(CTE_RootServerServer *aSuite) : CRootServerTest_GracefulUnload(aSuite) |
|
102 { |
|
103 // store the name of this test case |
|
104 SetTestStepName(_L("Test5.2")); |
|
105 } |
|
106 |
|
107 TVerdict CRootServerTest5_2::doTestStepL( void ) |
|
108 { |
|
109 INFO_PRINTF1(_L("Test Purpose: UnLoad Comms Provider Module gracefully (elevated priority)")); |
|
110 return UnloadGracefullyL(EPriorityRealTime); |
|
111 } |
|
112 |
|
113 |
|
114 // Test step 5.3 - Cancel UnLoad Gracefully |
|
115 CRootServerTest5_3::CRootServerTest5_3(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
116 { |
|
117 // store the name of this test case |
|
118 SetTestStepName(_L("Test5.3")); |
|
119 } |
|
120 |
|
121 TVerdict CRootServerTest5_3::doTestStepL( void ) |
|
122 { |
|
123 INFO_PRINTF1(_L("Test Purpose: Cancel UnLoad Comms Provider Module gracefully")); |
|
124 SetTestStepResult(EPass); |
|
125 // Create scheduler/active object framework |
|
126 CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC(); |
|
127 CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess()); |
|
128 |
|
129 //*****************step 2************************ |
|
130 INFO_PRINTF1(_L("02 Load Test Module")); |
|
131 TRSStartModuleParams startParams; |
|
132 TTestModuleIniData iniData; |
|
133 DefaultStartParams(startParams, iniData); |
|
134 startParams.iParams.iName = KModule1; |
|
135 |
|
136 asynchHandler->TryLoad(startParams, iniData); |
|
137 CActiveScheduler::Start(); |
|
138 if (asynchHandler->iStatus != KErrNone) |
|
139 { |
|
140 INFO_PRINTF2(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
141 SetTestStepResult(EInconclusive); |
|
142 } |
|
143 else |
|
144 { |
|
145 //*****************step 3*********************** |
|
146 INFO_PRINTF1(_L("03 Unload Test Module")); |
|
147 asynchHandler->TryUnLoad(startParams.iParams.iName, EGraceful); |
|
148 |
|
149 //*****************step 4*********************** |
|
150 INFO_PRINTF2(_L("04 Cancelling UnLoad: %S"), &startParams.iParams.iName); |
|
151 iRootServerSuite->RootSess().CancelUnloadCpm(startParams.iParams.iName); |
|
152 |
|
153 CActiveScheduler::Start(); |
|
154 |
|
155 if ((asynchHandler->iStatus != KErrNone) && (asynchHandler->iStatus != KErrCancel)) |
|
156 { |
|
157 INFO_PRINTF2(_L("Unload returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
158 SetTestStepResult(EFail); } |
|
159 |
|
160 } |
|
161 |
|
162 // uninstall and destroy active scheduler |
|
163 CleanupStack::PopAndDestroy(asynchHandler); |
|
164 CleanupStack::PopAndDestroy(scheduler); |
|
165 return TestStepResult(); |
|
166 } |
|
167 |
|
168 // Test step 3.5 - Retrieve Module Information |
|
169 CRootServerTest_UngracefulUnload::CRootServerTest_UngracefulUnload(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
170 { |
|
171 } |
|
172 |
|
173 |
|
174 TVerdict CRootServerTest_UngracefulUnload::UnloadNonGracefullyL(TThreadPriority aPriority) |
|
175 { |
|
176 SetTestStepResult(EFail); |
|
177 // Create scheduler/active object framework |
|
178 CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC(); |
|
179 CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess()); |
|
180 |
|
181 //*****************step 3************************ |
|
182 INFO_PRINTF1(_L("03 Load Test Module")); |
|
183 TRSStartModuleParams startParams; |
|
184 TTestModuleIniData iniData; |
|
185 DefaultStartParams(startParams, iniData); |
|
186 startParams.iParams.iName = KModule1; |
|
187 startParams.iParams.iPriority = aPriority; |
|
188 |
|
189 asynchHandler->TryLoad(startParams, iniData); |
|
190 CActiveScheduler::Start(); |
|
191 if (asynchHandler->iStatus != KErrNone) |
|
192 { |
|
193 INFO_PRINTF2(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
194 SetTestStepResult(EInconclusive); |
|
195 } |
|
196 else |
|
197 { |
|
198 //*****************step 4*********************** |
|
199 INFO_PRINTF1(_L("04 Unload Test Module")); |
|
200 asynchHandler->TryUnLoad(startParams.iParams.iName, EUnGraceful); |
|
201 |
|
202 CActiveScheduler::Start(); |
|
203 |
|
204 if (asynchHandler->iStatus != KErrNone) |
|
205 { |
|
206 INFO_PRINTF2(_L("Unload returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
207 SetTestStepResult(EInconclusive); |
|
208 } |
|
209 else |
|
210 { |
|
211 SetTestStepResult(EPass); |
|
212 } |
|
213 } |
|
214 |
|
215 // uninstall and destroy active scheduler |
|
216 CleanupStack::PopAndDestroy(asynchHandler); |
|
217 CleanupStack::PopAndDestroy(scheduler); |
|
218 return TestStepResult(); |
|
219 } |
|
220 |
|
221 |
|
222 // Test step 5.4 - UnLoad Ungracefully - normal priority |
|
223 CRootServerTest5_4::CRootServerTest5_4(CTE_RootServerServer *aSuite) : CRootServerTest_UngracefulUnload(aSuite) |
|
224 { |
|
225 // store the name of this test case |
|
226 SetTestStepName(_L("Test5.4")); |
|
227 } |
|
228 |
|
229 TVerdict CRootServerTest5_4::doTestStepL( void ) |
|
230 { |
|
231 INFO_PRINTF1(_L("Test Purpose: UnLoad Comms Provider Module Ungracefully (normal priority)")); |
|
232 return UnloadNonGracefullyL(EPriorityNormal); |
|
233 } |
|
234 |
|
235 // Test step 5.5 - UnLoad Ungracefully - elevated priority |
|
236 CRootServerTest5_5::CRootServerTest5_5(CTE_RootServerServer *aSuite) : CRootServerTest_UngracefulUnload(aSuite) |
|
237 { |
|
238 // store the name of this test case |
|
239 SetTestStepName(_L("Test5.5")); |
|
240 } |
|
241 |
|
242 TVerdict CRootServerTest5_5::doTestStepL( void ) |
|
243 { |
|
244 INFO_PRINTF1(_L("Test Purpose: UnLoad Comms Provider Module Ungracefully (elevated priority)")); |
|
245 return UnloadNonGracefullyL(EPriorityRealTime); |
|
246 } |
|
247 |
|
248 |
|
249 // Test step 5.6 - Cancel UnLoad Ungracefully |
|
250 CRootServerTest5_6::CRootServerTest5_6(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
251 { |
|
252 // store the name of this test case |
|
253 SetTestStepName(_L("Test5.6")); |
|
254 } |
|
255 |
|
256 TVerdict CRootServerTest5_6::doTestStepL( void ) |
|
257 { |
|
258 INFO_PRINTF1(_L("Test Purpose: Cancel UnLoad Comms Provider Module Ungracefully")); |
|
259 SetTestStepResult(EPass); |
|
260 // Create scheduler/active object framework |
|
261 CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC(); |
|
262 CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess()); |
|
263 |
|
264 //*****************step 2************************ |
|
265 INFO_PRINTF1(_L("02 Load Test Module")); |
|
266 TRSStartModuleParams startParams; |
|
267 TTestModuleIniData iniData; |
|
268 DefaultStartParams(startParams, iniData); |
|
269 startParams.iParams.iName = KModule1; |
|
270 |
|
271 asynchHandler->TryLoad(startParams, iniData); |
|
272 CActiveScheduler::Start(); |
|
273 if (asynchHandler->iStatus != KErrNone) |
|
274 { |
|
275 INFO_PRINTF2(_L("Load returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
276 SetTestStepResult(EInconclusive); |
|
277 } |
|
278 else |
|
279 { |
|
280 //*****************step 3*********************** |
|
281 INFO_PRINTF1(_L("03 Unload Test Module")); |
|
282 asynchHandler->TryUnLoad(startParams.iParams.iName, EUnGraceful); |
|
283 |
|
284 //*****************step 4*********************** |
|
285 INFO_PRINTF2(_L("04 Cancelling UnLoad: %S"), &startParams.iParams.iName); |
|
286 iRootServerSuite->RootSess().CancelUnloadCpm(startParams.iParams.iName); |
|
287 |
|
288 CActiveScheduler::Start(); |
|
289 |
|
290 // Unload the CPM anyway in case we were too late to cancel the load. |
|
291 TRequestStatus status; |
|
292 iRootServerSuite->RootSess().UnloadCpm(status, startParams.iParams.iName, EImmediate); |
|
293 User::WaitForRequest(status); |
|
294 |
|
295 if (asynchHandler->iStatus != KErrNone) |
|
296 { |
|
297 INFO_PRINTF2(_L("Unload returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
298 SetTestStepResult(EFail); |
|
299 } |
|
300 } |
|
301 |
|
302 // uninstall and destroy active scheduler |
|
303 CleanupStack::PopAndDestroy(asynchHandler); |
|
304 CleanupStack::PopAndDestroy(scheduler); |
|
305 return TestStepResult(); |
|
306 } |
|
307 |
|
308 |
|
309 // Test step 5.7 - UnLoad 2 modules sharing the same heap |
|
310 CRootServerTest5_7::CRootServerTest5_7(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
311 { |
|
312 // store the name of this test case |
|
313 SetTestStepName(_L("Test5.7")); |
|
314 } |
|
315 |
|
316 TVerdict CRootServerTest5_7::doTestStepL( void ) |
|
317 { |
|
318 INFO_PRINTF1(_L("Test Purpose: UnLoad 2 modules sharing the same heap")); |
|
319 SetTestStepResult(EFail); |
|
320 // Create scheduler/active object framework |
|
321 CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC(); |
|
322 CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess()); |
|
323 |
|
324 //*****************step 3************************ |
|
325 INFO_PRINTF1(_L("03 Load Test Module_Share1")); |
|
326 TRSStartModuleParams startParams; |
|
327 TTestModuleIniData iniData; |
|
328 DefaultStartParams(startParams, iniData); |
|
329 _LIT8(KShareModule1, "Test ModuleShare1"); |
|
330 _LIT8(KShareModule2, "Test ModuleShare2"); |
|
331 startParams.iParams.iName = KShareModule1; |
|
332 |
|
333 asynchHandler->TryLoad(startParams, iniData); |
|
334 CActiveScheduler::Start(); |
|
335 if (asynchHandler->iStatus != KErrNone) |
|
336 { |
|
337 INFO_PRINTF2(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
338 User::Leave(asynchHandler->iStatus.Int()); |
|
339 } |
|
340 |
|
341 //*****************step 3************************ |
|
342 INFO_PRINTF1(_L("03 Load Test Module")); |
|
343 startParams.iParams.iName = KShareModule2; |
|
344 startParams.iParams.iHeapType = EShareHeap; |
|
345 startParams.iParams.iShareHeapWith = KShareModule1; |
|
346 |
|
347 asynchHandler->TryLoad(startParams, iniData); |
|
348 CActiveScheduler::Start(); |
|
349 |
|
350 if (asynchHandler->iStatus != KErrNone) |
|
351 { |
|
352 INFO_PRINTF2(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
353 User::Leave(asynchHandler->iStatus.Int()); |
|
354 } |
|
355 |
|
356 //*****************step 5*********************** |
|
357 INFO_PRINTF1(_L("05 Unload Test Module_Share1")); |
|
358 startParams.iParams.iName = KShareModule1; |
|
359 asynchHandler->TryUnLoad(startParams.iParams.iName, EGraceful); |
|
360 CActiveScheduler::Start(); |
|
361 |
|
362 if (asynchHandler->iStatus != KErrNone) |
|
363 { |
|
364 INFO_PRINTF2(_L("Unload returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
365 User::Leave(asynchHandler->iStatus.Int()); |
|
366 } |
|
367 |
|
368 //*****************step 6*********************** |
|
369 INFO_PRINTF1(_L("06 Unload Test Module_Share2")); |
|
370 startParams.iParams.iName = KShareModule2; |
|
371 asynchHandler->TryUnLoad(startParams.iParams.iName, EGraceful); |
|
372 |
|
373 CActiveScheduler::Start(); |
|
374 |
|
375 if (asynchHandler->iStatus != KErrNone) |
|
376 { |
|
377 INFO_PRINTF2(_L("Unload returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
378 SetTestStepResult(EInconclusive); |
|
379 } |
|
380 else |
|
381 { |
|
382 SetTestStepResult(EPass); |
|
383 } |
|
384 |
|
385 // uninstall and destroy active scheduler |
|
386 CleanupStack::PopAndDestroy(asynchHandler); |
|
387 CleanupStack::PopAndDestroy(scheduler); |
|
388 return TestStepResult(); |
|
389 } |
|
390 |
|
391 |
|
392 // Test step 5.8 - Unload Sluggish CPM Gracefully with intervening Close of Session |
|
393 CRootServerTest5_8::CRootServerTest5_8(CTE_RootServerServer *aSuite) : CTestStepRootServer(aSuite) |
|
394 { |
|
395 // store the name of this test case |
|
396 SetTestStepName(_L("Test5.8")); |
|
397 } |
|
398 |
|
399 TVerdict CRootServerTest5_8::doTestStepL( void ) |
|
400 { |
|
401 INFO_PRINTF1(_L("Test Purpose: Unload Sluggish CPM Gracefully with intervening Close of Session")); |
|
402 SetTestStepResult(EPass); |
|
403 // Create scheduler/active object framework |
|
404 CSelfPopScheduler* scheduler = CSelfPopScheduler::CreateLC(); |
|
405 CTestAsynchHandler* asynchHandler = CTestAsynchHandler::NewLC(&iRootServerSuite->RootSess()); |
|
406 |
|
407 TRSStartModuleParams startParams; |
|
408 TTestModuleIniData iniData; |
|
409 DefaultStartParams(startParams, iniData); |
|
410 startParams.iParams.iName = KModule1; |
|
411 iniData.iParams.iShutdownDelay = isTestServerLifeTime; |
|
412 INFO_PRINTF2(_L("01 Loading sluggish module: %S"), &startParams.iParams.iName); |
|
413 asynchHandler->TryLoad(startParams, iniData); |
|
414 |
|
415 CActiveScheduler::Start(); |
|
416 if (asynchHandler->iStatus != KErrNone) |
|
417 { |
|
418 INFO_PRINTF2(_L("LoadServer returned error: <%d> "), asynchHandler->iStatus.Int()); |
|
419 User::Leave(asynchHandler->iStatus.Int()); |
|
420 } |
|
421 |
|
422 INFO_PRINTF1(_L("02 Unload sluggish Module")); |
|
423 asynchHandler->TryUnLoad(startParams.iParams.iName, EGraceful); |
|
424 |
|
425 // Brief wait to give unload chance to start |
|
426 User::After(250 * 1000); |
|
427 |
|
428 // Close the session |
|
429 INFO_PRINTF1(_L("03 Closing RRootServ")); |
|
430 iRootServerSuite->RootSess().Close(); |
|
431 // Brief wait for any fireworks |
|
432 User::After(250 * 1000); |
|
433 |
|
434 // Let the request complete |
|
435 CActiveScheduler::Start(); |
|
436 |
|
437 // Reconnect the session |
|
438 INFO_PRINTF1(_L("04 Reconnecting RRootServ")); |
|
439 TInt ret = iRootServerSuite->RootSess().Connect(); |
|
440 if (ret != KErrNone) |
|
441 { |
|
442 INFO_PRINTF2(_L("Reconnect of RRootServ failed with error: <%d> "), ret); |
|
443 User::Leave(ret); |
|
444 } |
|
445 // Brief wait for any fireworks |
|
446 User::After(250 * 1000); |
|
447 |
|
448 // now try to retrieve information about the module; should be ERunning after session close |
|
449 // causes unload handler to be canceled |
|
450 INFO_PRINTF1(_L("05 Getting module information")); |
|
451 TRSModuleInfo info; |
|
452 TCFModuleName moduleName = startParams.iParams.iName; |
|
453 ret = iRootServerSuite->RootSess().GetModuleInfo(moduleName, info); |
|
454 INFO_PRINTF4(_L("GetModuleInfo for %S returned %d, state %c= ERunning"), &moduleName, ret, info.iParams.iState == EStopping? '=': '!'); |
|
455 |
|
456 if(KErrNone != ret || info.iParams.iState != ERunning) |
|
457 { |
|
458 CleanupStack::PopAndDestroy(asynchHandler); |
|
459 CleanupStack::PopAndDestroy(scheduler); |
|
460 SetTestStepResult(EFail); |
|
461 return TestStepResult(); |
|
462 } |
|
463 |
|
464 // Wait for it to finish stopping, query again |
|
465 INFO_PRINTF1(_L("06 Getting module information after waiting for stop")); |
|
466 User::After((iniData.iParams.iShutdownDelay + 500) * 1000); |
|
467 moduleName = startParams.iParams.iName; |
|
468 ret = iRootServerSuite->RootSess().GetModuleInfo(moduleName, info); |
|
469 INFO_PRINTF3(_L("GetModuleInfo for %S returned %d"), &moduleName, ret); |
|
470 |
|
471 if(KErrRSModuleUnknown != ret) |
|
472 { |
|
473 CleanupStack::PopAndDestroy(asynchHandler); |
|
474 CleanupStack::PopAndDestroy(scheduler); |
|
475 SetTestStepResult(EFail); |
|
476 return TestStepResult(); |
|
477 } |
|
478 |
|
479 CleanupStack::PopAndDestroy(asynchHandler); |
|
480 CleanupStack::PopAndDestroy(scheduler); |
|
481 return TestStepResult(); |
|
482 } |
|
483 |