|
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 // This file contains test classes and their implementations |
|
15 // to test CDiscoverer will not discover plug-ins on C: and E: |
|
16 // if the two drives are disabled by the patchable constants. |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalComponent |
|
23 */ |
|
24 #include "RegistryData.h" |
|
25 #include "Discoverer.h" |
|
26 #include "ImplementationInformation.h" |
|
27 #include "RegistryData.h" |
|
28 #include "Registrar.h" |
|
29 #include "RegistrarObserver.h" |
|
30 #include "../EcomTestUtils/EcomTestUtils.h" |
|
31 #include "DriveInfo.h" |
|
32 #include "EComPatchDataConstantv2.h" |
|
33 |
|
34 #include <e32test.h> |
|
35 #include <f32file.h> |
|
36 #include <bautils.h> |
|
37 #include <startup.hrh> |
|
38 |
|
39 _LIT (KDataDir, "C:\\private\\10009D8F\\ECom*"); |
|
40 |
|
41 // plugins to discover |
|
42 _LIT(KNewResourceFileNameC, "C:\\resource\\plugins\\EComExample5.rsc"); |
|
43 _LIT(KNewDllFileNameC, "C:\\sys\\bin\\EComExample5.dll"); |
|
44 _LIT(KNewResourceFileNameZ, "z:\\RAMOnly\\EComExample5.rsc"); |
|
45 _LIT(KNewDllFileNameZ,"z:\\RAMOnly\\EComExample5.dll"); |
|
46 |
|
47 const TInt KOneSecond = 1000000; |
|
48 |
|
49 LOCAL_D RTest test(_L("Disable drives")); |
|
50 LOCAL_D RFs TheFs; |
|
51 LOCAL_D CTrapCleanup* TheTrapCleanup = NULL; |
|
52 |
|
53 class CDerivedActiveScheduler; |
|
54 LOCAL_D CDerivedActiveScheduler* TheActiveScheduler = NULL; |
|
55 |
|
56 LOCAL_D TInt oomStep; |
|
57 |
|
58 //It is used by some test methods which are called two times: |
|
59 //from normal test and from OOM test. |
|
60 static void LeaveIfErrNoMemoryL(TInt aError) |
|
61 { |
|
62 if(aError == KErrNoMemory) |
|
63 { |
|
64 User::Leave(aError); |
|
65 } |
|
66 } |
|
67 |
|
68 // Copies the Plugins to specific folder for testing purpose |
|
69 LOCAL_C void CopyPlugins() |
|
70 { |
|
71 TInt err=KErrNone; |
|
72 TRAP(err, EComTestUtils::FileManCopyFileL(KNewResourceFileNameZ, KNewResourceFileNameC)); |
|
73 test(err==KErrNone); |
|
74 TRAP(err, EComTestUtils::FileManCopyFileL(KNewDllFileNameZ, KNewDllFileNameC)); |
|
75 test(err==KErrNone); |
|
76 } |
|
77 |
|
78 // Deleting plugin from the RAM for cleanup purpose |
|
79 LOCAL_C void DeleteTestPlugin(TAny* /* aUnused */) |
|
80 { |
|
81 TInt err=KErrNone; |
|
82 TRAP(err, EComTestUtils::FileManDeleteFileL(KNewResourceFileNameC)); |
|
83 TRAP(err, EComTestUtils::FileManDeleteFileL(KNewDllFileNameC)); |
|
84 } |
|
85 |
|
86 // flags indicating a set of pre-conditions to fullfil before running |
|
87 // CDisableDrivesTest. |
|
88 enum TPreTestSetup |
|
89 { |
|
90 EPreTest_UnitializeCachedDriveInfo = 0x1, |
|
91 EPreTest_EnableAllDrives = 0x2, |
|
92 EPreTest_CopyPlugins = 0x4 |
|
93 }; |
|
94 |
|
95 const TUint32 KStartupDiscoveryDrivesDisabledMask = |
|
96 EPreTest_UnitializeCachedDriveInfo | EPreTest_CopyPlugins; |
|
97 |
|
98 const TUint32 KStartupDiscoveryDrivesEnabledMask = |
|
99 EPreTest_EnableAllDrives | EPreTest_CopyPlugins; |
|
100 |
|
101 const TUint32 KRediscoveryDrivesDisabledMask = |
|
102 EPreTest_UnitializeCachedDriveInfo; |
|
103 |
|
104 const TUint32 KRediscoveryDrivesEnabledMask = |
|
105 EPreTest_EnableAllDrives; |
|
106 |
|
107 /** |
|
108 TRegistryData_StateAccessor class allows access to private and protected |
|
109 members of production code class CRegistryData, as its a friend class. |
|
110 */ |
|
111 class TRegistryData_StateAccessor |
|
112 { |
|
113 public: |
|
114 TInt FindImplementation(CRegistryData& aRegistryData, |
|
115 const TUid aImplUid, |
|
116 const TUid aInterfaceUid, |
|
117 CRegistryData::CImplementationData*& aImplData) const; |
|
118 }; |
|
119 |
|
120 /** TRegistrar_StateAccessor class allows access to private members |
|
121 of CRegistrar. */ |
|
122 class TRegistrar_StateAccessor |
|
123 { |
|
124 static void SetCompletedStateL(CRegistrar& aRegistrar, |
|
125 TStartupStateIdentifier aKnownState); |
|
126 }; |
|
127 |
|
128 /** TDiscoverer_StateAccessor allows manipulation of CDiscoverer |
|
129 private members. */ |
|
130 class TDiscoverer_StateAccessor |
|
131 { |
|
132 static void SetCompletedStateL(CDiscoverer& aDiscoverer, |
|
133 CDiscoverer::TDiscovererState aState); |
|
134 }; |
|
135 |
|
136 /** TDriveInfo_StateAccessor class allows access to private members |
|
137 of CEComCachedDriveInfo. */ |
|
138 class TDriveInfo_StateAccessor |
|
139 { |
|
140 public: |
|
141 static void ClearCachedDriveInfo(); |
|
142 |
|
143 static void SetDriveDisableMaskL(TUint32 aMask); |
|
144 }; |
|
145 |
|
146 /** |
|
147 @return KErrNone if found otherwise KErrNotFound |
|
148 @param aRegistryData The CRegistryData class object |
|
149 @param aImplUid The implementation to find. |
|
150 @param aInterfaceUid If greater than 0 the interface associated with the |
|
151 implementation to find. |
|
152 @param aImplData The found implementation data. |
|
153 @pre CRegistrar is fully constructed |
|
154 */ |
|
155 TInt TRegistryData_StateAccessor::FindImplementation(CRegistryData& aRegistryData, |
|
156 const TUid aImplUid, |
|
157 const TUid aInterfaceUid, |
|
158 CRegistryData::CImplementationData*& aImplData) const |
|
159 { |
|
160 return aRegistryData.FindImplementation(aImplUid, aInterfaceUid, aImplData); |
|
161 } |
|
162 |
|
163 /** Mark the static drive info array uninitialized. Then the |
|
164 next instantiation of CEComCachedDriveInfo will need to setup |
|
165 the drive info again. |
|
166 */ |
|
167 void TDriveInfo_StateAccessor::ClearCachedDriveInfo() |
|
168 { |
|
169 CEComCachedDriveInfo::iInitialized = EFalse; |
|
170 } |
|
171 |
|
172 /** Instantiate a CEComCachedDriveInfo object with a special drive |
|
173 mask. The object is destroyed right away but the static drive info |
|
174 array is fixed to the special mask. |
|
175 @param aMask the drive disable mask to set. |
|
176 */ |
|
177 void TDriveInfo_StateAccessor::SetDriveDisableMaskL(TUint32 aMask) |
|
178 { |
|
179 // Set this bool to false otherwise ConstructL will do nothing. |
|
180 CEComCachedDriveInfo::iInitialized = EFalse; |
|
181 |
|
182 CEComCachedDriveInfo* ptr = new (ELeave) CEComCachedDriveInfo(); |
|
183 CleanupStack::PushL(ptr); |
|
184 ptr->ConstructL(TheFs, aMask); |
|
185 CleanupStack::PopAndDestroy(); |
|
186 } |
|
187 |
|
188 /** Need a CActive to wait for CDiscoverer dir change notifiers. */ |
|
189 class CSimpleTimer : public CTimer |
|
190 { |
|
191 public: |
|
192 inline CSimpleTimer(TInt aPriority); |
|
193 inline void ConstructL(); |
|
194 inline void StartTimer(TTimeIntervalMicroSeconds32 aTimeInterval); |
|
195 |
|
196 private: |
|
197 void RunL(); |
|
198 }; |
|
199 |
|
200 inline CSimpleTimer::CSimpleTimer(TInt aPriority) |
|
201 : CTimer(aPriority) |
|
202 { |
|
203 CActiveScheduler::Add(this); |
|
204 } |
|
205 |
|
206 inline void CSimpleTimer::ConstructL() |
|
207 { |
|
208 CTimer::ConstructL(); |
|
209 } |
|
210 |
|
211 inline void CSimpleTimer::StartTimer(TTimeIntervalMicroSeconds32 aTimeInterval) |
|
212 { |
|
213 After(aTimeInterval); |
|
214 } |
|
215 |
|
216 void CSimpleTimer::RunL() |
|
217 { |
|
218 CActiveScheduler::Stop(); |
|
219 } |
|
220 |
|
221 /** Avoid E32User::Case 47 panic in OOM test */ |
|
222 class CDerivedActiveScheduler : public CActiveScheduler |
|
223 { |
|
224 public: |
|
225 virtual void Error(TInt aError) const; |
|
226 }; |
|
227 |
|
228 void CDerivedActiveScheduler::Error(TInt aError) const |
|
229 { |
|
230 Halt(aError); |
|
231 } |
|
232 |
|
233 /** |
|
234 The implementation of the abstract Registrar Observer class, |
|
235 used for recieving notifications of registry changes. |
|
236 Stub class(for CEComServer) used for the creation of CRegistrar class object. |
|
237 CEComServer class acts as observer for CRegistrar. |
|
238 */ |
|
239 class CTestRegistrarObserver : public MRegistrarObserver |
|
240 { |
|
241 public: |
|
242 // This function is used by RegistrarObserver (i.e.CEComServer) to notify its |
|
243 // clients(REComSession objects) that some change has happened in Registry. |
|
244 // Here we have no clients to notify, so no implementaion. |
|
245 void Notification( TInt /*aNotification*/ ) {} |
|
246 }; |
|
247 |
|
248 /** |
|
249 Test class for object CRegistrar. |
|
250 This class provides the parameters and behaviour that |
|
251 allows this class to behave normally under a test |
|
252 scenario. |
|
253 */ |
|
254 class CDisableDrivesTest : public CBase |
|
255 { |
|
256 public: |
|
257 static CDisableDrivesTest* NewL(TBool aDrivesEnabled); |
|
258 virtual ~CDisableDrivesTest(); |
|
259 void startupDiscoveryL(); |
|
260 void RediscoveryL(); |
|
261 |
|
262 private: |
|
263 CDisableDrivesTest(TBool aDrivesEnabled); |
|
264 void ConstructL(); |
|
265 void WaitForDiscovererAOL(); |
|
266 |
|
267 public: |
|
268 /** The instance of the class under test */ |
|
269 CRegistrar* iRegistrar; |
|
270 |
|
271 /** The instance of the State Accessor class */ |
|
272 TRegistrar_StateAccessor* iStateAccessor; |
|
273 |
|
274 /** The registry data instance required to construct a CRegistrar object */ |
|
275 CRegistryData* iRegistryData; |
|
276 |
|
277 /** The instance of the Registry Data State Accessor class */ |
|
278 TRegistryData_StateAccessor* iRegistryDataStateAccessor; |
|
279 |
|
280 /** The instance of the observer of CRegistrar class */ |
|
281 MRegistrarObserver* iRegistrarObserver; |
|
282 |
|
283 /** The destination for the data discovered during a parse */ |
|
284 CRegistryData::CDllData* iDllData; |
|
285 |
|
286 /** Unique Id of the ECOM dll */ |
|
287 TUid iDllUid; |
|
288 |
|
289 /** Unique Id of an interface implementation */ |
|
290 TUid iImplementationUid; |
|
291 |
|
292 /** Unique Id of an interface */ |
|
293 TUid iInterfaceUid; |
|
294 |
|
295 /** The drive on which interface implementations can be found */ |
|
296 TDriveUnit iDriveUnit; |
|
297 |
|
298 /** Ecom plugin which contains interface implementations. Used in Registration APIs.*/ |
|
299 TEntry iDllEntry; |
|
300 |
|
301 TBool iDrivesEnabled; |
|
302 }; |
|
303 |
|
304 /** |
|
305 Standardised safe construction which |
|
306 leaves nothing on the cleanup stack. |
|
307 |
|
308 @post CDisableDrivesTest is fully constructed and initialised. |
|
309 */ |
|
310 CDisableDrivesTest* CDisableDrivesTest::NewL(TBool aDrivesEnabled) |
|
311 { |
|
312 CDisableDrivesTest* self = new (ELeave) CDisableDrivesTest(aDrivesEnabled); |
|
313 CleanupStack::PushL(self); |
|
314 self->ConstructL(); |
|
315 CleanupStack::Pop(self); |
|
316 return self; |
|
317 } |
|
318 |
|
319 /** |
|
320 Standardized default c'tor |
|
321 |
|
322 @post CDisableDrivesTest is fully constructed. |
|
323 */ |
|
324 CDisableDrivesTest::CDisableDrivesTest(TBool aDrivesEnabled) |
|
325 : CBase(), |
|
326 iDriveUnit(EDriveC), |
|
327 iDrivesEnabled(aDrivesEnabled) |
|
328 { |
|
329 iDllUid.iUid = 0x101F847B; // Dlluid for Ecom plugin EComExample5.dll |
|
330 iInterfaceUid.iUid = 0x10009DC0; // Interface uid for interface contained in above plugin |
|
331 iImplementationUid.iUid = 0x101f847C; // Implementaion uid for above interface |
|
332 TUid uid1 = {0}; |
|
333 TUid uid2 = {0}; |
|
334 iDllEntry.iType = TUidType(uid1, uid2, iDllUid);//Setting Dlluid to plugin entry |
|
335 } |
|
336 |
|
337 /** |
|
338 Destructor. |
|
339 |
|
340 @post This object is properly destroyed. |
|
341 */ |
|
342 CDisableDrivesTest::~CDisableDrivesTest() |
|
343 { |
|
344 delete iDllData; |
|
345 delete iRegistrar; |
|
346 delete iRegistryData; |
|
347 delete iRegistrarObserver; |
|
348 delete iStateAccessor; |
|
349 delete iRegistryDataStateAccessor; |
|
350 } |
|
351 |
|
352 /** |
|
353 Standardized 2nd(Initialization) phase of two phase construction. |
|
354 |
|
355 @post CDisableDrivesTest is fully constructed. |
|
356 */ |
|
357 void CDisableDrivesTest::ConstructL() |
|
358 { |
|
359 CRegistryData::CDriveData* driveData=NULL; |
|
360 iRegistrarObserver = new (ELeave) CTestRegistrarObserver; |
|
361 iStateAccessor = new (ELeave) TRegistrar_StateAccessor; |
|
362 iRegistryDataStateAccessor = new (ELeave) TRegistryData_StateAccessor; |
|
363 iRegistryData = CRegistryData::NewL(TheFs); |
|
364 iRegistrar = CRegistrar::NewL(*iRegistryData, *iRegistrarObserver, TheFs); |
|
365 iDllData = CRegistryData::CDllData::NewLC(driveData); |
|
366 CleanupStack::Pop(iDllData); |
|
367 } |
|
368 |
|
369 /** |
|
370 @SYMTestCaseID SYSLIB-ECOM-CT-3541 |
|
371 @SYMTestCaseDesc Verify ECOM's patchdata scheme works. |
|
372 @SYMTestPriority High |
|
373 @SYMTestActions Check the value of the constant KDiscoveryDisabledDriveList. |
|
374 @SYMTestExpectedResults It should be 0x14 in hw. |
|
375 @SYMCR CR1049 |
|
376 */ |
|
377 void PatchableConstantTest() |
|
378 { |
|
379 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3541 Patch constant value ")); |
|
380 |
|
381 // check the patchable constant has the patched value. |
|
382 #ifdef __ARMCC__ |
|
383 test(KDiscoveryDisabledDriveList == 0x14); |
|
384 #else |
|
385 // On emulator the constant is not patchable. Thus the RTest links |
|
386 // with a different .cpp file. |
|
387 test(KDiscoveryDisabledDriveList == 0x00800004); |
|
388 #endif |
|
389 } |
|
390 |
|
391 /** |
|
392 @SYMTestCaseID SYSLIB-ECOM-CT-4014 |
|
393 @SYMTestCaseDesc Check that the patchables for custom resolver caching |
|
394 can be patched. |
|
395 @SYMTestPriority High |
|
396 @SYMTestActions Check the values of KCustomResolverCacheSize and |
|
397 KCustomResolverCacheTimeout |
|
398 @SYMTestExpectedResults disabledrivestest.hby sets KCustomResolverCacheSize |
|
399 to 1182 and KCustomResolverCacheTimeout to 4001182. Note that this test |
|
400 only runs on hw. |
|
401 @SYMCR CR1182 |
|
402 */ |
|
403 void CR1182PatchableConstantTest() |
|
404 { |
|
405 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-4014 CR1182 patchable constants ")); |
|
406 |
|
407 // check the patchable constants have the patched values. |
|
408 #ifdef __ARMCC__ |
|
409 test(KCustomResolverCacheSize == 1182); |
|
410 test(KCustomResolverCacheTimeout == 4001182); |
|
411 #else |
|
412 test.Printf(_L("This test only runs in armv5.")); |
|
413 #endif |
|
414 } |
|
415 |
|
416 /** |
|
417 @SYMTestCaseID SYSLIB-ECOM-CT-3542 |
|
418 @SYMTestCaseDesc Check that CDiscoverer will not discover plug-ins in disabled drives at boot time. |
|
419 @SYMTestPriority High |
|
420 @SYMTestActions Use CRegistrar::ProcessSSAEventL to trigger boot up discovery. |
|
421 @SYMTestExpectedResults No plugins registered if C: drive is disabled. In the |
|
422 control test, C: is enabled and the plugin is registered. |
|
423 @SYMCR CR1049 |
|
424 */ |
|
425 void CDisableDrivesTest::startupDiscoveryL() |
|
426 { |
|
427 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3542 ")); |
|
428 |
|
429 // Do not scan ReadOnly internal drive in OOM. Will take an hour. |
|
430 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
431 |
|
432 iRegistrar->ProcessSSAEventL(EStartupStateCriticalStatic); |
|
433 |
|
434 if (oomStep) |
|
435 { |
|
436 __UHEAP_SETFAIL(RHeap::EDeterministic, oomStep); |
|
437 } |
|
438 |
|
439 iRegistrar->ProcessSSAEventL(EStartupStateNonCritical); |
|
440 |
|
441 CRegistryData::CImplementationData *implementationData=NULL; |
|
442 TUid dummyUid; |
|
443 dummyUid.iUid = 0; |
|
444 |
|
445 TInt err = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, iImplementationUid, dummyUid, implementationData); |
|
446 ::LeaveIfErrNoMemoryL(err); |
|
447 |
|
448 if (iDrivesEnabled) |
|
449 { |
|
450 test(err == KErrNone); |
|
451 } |
|
452 else |
|
453 { |
|
454 test(err == KErrNotFound); |
|
455 } |
|
456 } |
|
457 |
|
458 /** |
|
459 @SYMTestCaseID SYSLIB-ECOM-CT-3543 |
|
460 @SYMTestCaseDesc Check that CDiscoverer will not discover plug-ins via dir |
|
461 change notification if drive is disabled. |
|
462 @SYMTestPriority High |
|
463 @SYMTestActions After startup discovery completed, copy .rsc to |
|
464 C:\resource\plugins and the .dll to C:\sys\bin. |
|
465 @SYMTestExpectedResults The plugin is not registered if C: is disabled. In the |
|
466 control test, C: is enabled and the plugin is registered. |
|
467 @SYMCR CR1049 |
|
468 */ |
|
469 void CDisableDrivesTest::RediscoveryL() |
|
470 { |
|
471 test.Next(_L(" @SYMTestCaseID:SYSLIB-ECOM-CT-3543 ")); |
|
472 // Do not scan ReadOnly internal drive in OOM. Will take an hour. |
|
473 __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
474 |
|
475 iRegistrar->ProcessSSAEventL(EStartupStateNonCritical); |
|
476 |
|
477 if (oomStep) |
|
478 { |
|
479 __UHEAP_SETFAIL(RHeap::EDeterministic, oomStep); |
|
480 } |
|
481 |
|
482 CopyPlugins(); |
|
483 CleanupStack::PushL(TCleanupItem(DeleteTestPlugin, NULL)); |
|
484 |
|
485 WaitForDiscovererAOL(); |
|
486 |
|
487 CRegistryData::CImplementationData *implementationData=NULL; |
|
488 TUid dummyUid = KNullUid; |
|
489 |
|
490 TInt err = iRegistryDataStateAccessor->FindImplementation(*iRegistryData, iImplementationUid, dummyUid, implementationData); |
|
491 ::LeaveIfErrNoMemoryL(err); |
|
492 |
|
493 CleanupStack::PopAndDestroy(1); |
|
494 |
|
495 if (iDrivesEnabled) |
|
496 { |
|
497 test(err == KErrNone); |
|
498 } |
|
499 else |
|
500 { |
|
501 test(err == KErrNotFound); |
|
502 } |
|
503 } |
|
504 |
|
505 void CDisableDrivesTest::WaitForDiscovererAOL() |
|
506 { |
|
507 // Yield priority to CDiscoverer's AO |
|
508 CSimpleTimer* timer = new(ELeave) CSimpleTimer(CActive::EPriorityLow); |
|
509 CleanupStack::PushL(timer); |
|
510 timer->ConstructL(); |
|
511 timer->StartTimer(KOneSecond * 2); |
|
512 CActiveScheduler::Start(); |
|
513 CleanupStack::PopAndDestroy(timer); |
|
514 } |
|
515 |
|
516 typedef void (CDisableDrivesTest::*ClassFuncPtrL) (void); |
|
517 |
|
518 /** |
|
519 Wrapper function to call all test functions |
|
520 |
|
521 @param aTestFuncL pointer to test function |
|
522 @param aUseZeroMask if false, let the test use the patchable constant else |
|
523 initialize the static drive info array with zero, i.e. enabled all. |
|
524 @param aTestDesc test function name |
|
525 */ |
|
526 LOCAL_C void DoBasicTestL(ClassFuncPtrL aTestFuncL, const TUint32 aTaskMask, const TDesC& aTestDesc) |
|
527 { |
|
528 test.Next(aTestDesc); |
|
529 |
|
530 __UHEAP_MARK; |
|
531 // find out the number of open handles |
|
532 TInt startProcessHandleCount; |
|
533 TInt startThreadHandleCount; |
|
534 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
535 |
|
536 // A series of tasks to perform before calling the test method. |
|
537 |
|
538 // Delete the previous data files to ensure rediscover from scratch |
|
539 TRAP_IGNORE(EComTestUtils::FileManDeleteFileL(KDataDir)); |
|
540 |
|
541 // The two flags below are mutually exclusive. |
|
542 if (aTaskMask & EPreTest_UnitializeCachedDriveInfo) |
|
543 { |
|
544 TDriveInfo_StateAccessor::ClearCachedDriveInfo(); |
|
545 } |
|
546 else if (aTaskMask & EPreTest_EnableAllDrives) |
|
547 { |
|
548 TDriveInfo_StateAccessor::SetDriveDisableMaskL(0); |
|
549 } |
|
550 |
|
551 if (aTaskMask & EPreTest_CopyPlugins) |
|
552 { |
|
553 CopyPlugins(); |
|
554 User::After(KOneSecond); |
|
555 CleanupStack::PushL(TCleanupItem(DeleteTestPlugin, NULL)); |
|
556 } |
|
557 |
|
558 // All set to start the test |
|
559 TBool drivesEnabled = (aTaskMask & EPreTest_EnableAllDrives) != 0; |
|
560 CDisableDrivesTest* disableDrvTest = CDisableDrivesTest::NewL(drivesEnabled); |
|
561 CleanupStack::PushL(disableDrvTest); |
|
562 |
|
563 (disableDrvTest->*aTestFuncL)(); |
|
564 |
|
565 CleanupStack::PopAndDestroy(disableDrvTest); |
|
566 |
|
567 if (aTaskMask & EPreTest_CopyPlugins) |
|
568 { |
|
569 CleanupStack::PopAndDestroy(1); |
|
570 } |
|
571 |
|
572 // check that no handles have leaked |
|
573 TInt endProcessHandleCount; |
|
574 TInt endThreadHandleCount; |
|
575 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
576 |
|
577 test(startProcessHandleCount == endProcessHandleCount); |
|
578 test(startThreadHandleCount == endThreadHandleCount); |
|
579 |
|
580 __UHEAP_MARKEND; |
|
581 } |
|
582 |
|
583 /** |
|
584 Wrapper function to call all OOM test functions |
|
585 |
|
586 @param aTestFuncL pointer to OOM test function |
|
587 @param aTaskMask indicates tasks need to be done before entering |
|
588 the OOM loop. |
|
589 @param aTestDesc test function name |
|
590 */ |
|
591 //LOCAL_C void DoOOMTestL(ClassFuncPtrL aTestFuncL, |
|
592 // const TUint32 aTaskMask, |
|
593 // const TDesC& aTestDesc) |
|
594 // { |
|
595 // test.Next(aTestDesc); |
|
596 |
|
597 // TInt err(KErrNone); |
|
598 // A series of tasks to perform before calling the test method. |
|
599 |
|
600 // Delete the previous data files to ensure rediscover from scratch |
|
601 // TRAP(err, EComTestUtils::FileManDeleteFileL(KDataDir)); |
|
602 |
|
603 // The two flags below are mutually exclusive. |
|
604 // if (aTaskMask & EPreTest_UnitializeCachedDriveInfo) |
|
605 // { |
|
606 // TDriveInfo_StateAccessor::ClearCachedDriveInfo(); |
|
607 // } |
|
608 // else if (aTaskMask & EPreTest_EnableAllDrives) |
|
609 // { |
|
610 // TDriveInfo_StateAccessor::SetDriveDisableMaskL(0); |
|
611 // } |
|
612 |
|
613 // if (aTaskMask & EPreTest_CopyPlugins) |
|
614 // { |
|
615 // CopyPlugins(); |
|
616 // User::After(KOneSecond); |
|
617 // CleanupStack::PushL(TCleanupItem(DeleteTestPlugin, NULL)); |
|
618 // } |
|
619 |
|
620 // TBool drivesEnabled = (aTaskMask & EPreTest_EnableAllDrives) != 0; |
|
621 // oomStep = 0; |
|
622 |
|
623 // do |
|
624 // { |
|
625 // __UHEAP_MARK; |
|
626 // find out the number of open handles |
|
627 // TInt startProcessHandleCount; |
|
628 // TInt startThreadHandleCount; |
|
629 // RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
630 |
|
631 // Need to create object here as ECom has embedded TRAPs |
|
632 // that will fail the test if memory not available |
|
633 // CDisableDrivesTest* disableDrvTest = CDisableDrivesTest::NewL(drivesEnabled); |
|
634 // CleanupStack::PushL(disableDrvTest); |
|
635 |
|
636 // Setting Heap failure for OOM test |
|
637 // __UHEAP_SETFAIL(RHeap::EDeterministic, ++oomStep); |
|
638 |
|
639 // TRAP(err, (disableDrvTest->*aTestFuncL)()); |
|
640 |
|
641 // __UHEAP_SETFAIL(RHeap::ENone, 0); |
|
642 |
|
643 // CleanupStack::PopAndDestroy(disableDrvTest); |
|
644 // disableDrvTest = NULL; |
|
645 |
|
646 // check that no handles have leaked |
|
647 // TInt endProcessHandleCount; |
|
648 // TInt endThreadHandleCount; |
|
649 // RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
650 |
|
651 // test(startProcessHandleCount == endProcessHandleCount); |
|
652 // test(startThreadHandleCount == endThreadHandleCount); |
|
653 |
|
654 // __UHEAP_MARKEND; |
|
655 // } while(err == KErrNoMemory); |
|
656 |
|
657 // if (aTaskMask & EPreTest_CopyPlugins) |
|
658 // { |
|
659 // CleanupStack::PopAndDestroy(1); |
|
660 // } |
|
661 |
|
662 // test(err == KErrNone); |
|
663 // test.Printf(_L("- server succeeded at heap failure rate of %i\n"), oomStep); |
|
664 // } |
|
665 |
|
666 LOCAL_C void DoTestsL() |
|
667 { |
|
668 __UHEAP_MARK; |
|
669 |
|
670 // Basic tests |
|
671 PatchableConstantTest(); |
|
672 CR1182PatchableConstantTest(); |
|
673 |
|
674 DoBasicTestL(&CDisableDrivesTest::startupDiscoveryL, |
|
675 KStartupDiscoveryDrivesDisabledMask, |
|
676 _L("startupDiscoveryL scan disabled")); |
|
677 |
|
678 // Control step to proof that the method is sound. |
|
679 DoBasicTestL(&CDisableDrivesTest::startupDiscoveryL, |
|
680 KStartupDiscoveryDrivesEnabledMask, |
|
681 _L("startupDiscoveryL scan enabled")); |
|
682 |
|
683 DoBasicTestL(&CDisableDrivesTest::RediscoveryL, |
|
684 KRediscoveryDrivesDisabledMask, |
|
685 _L("RediscoveryL scan disabled")); |
|
686 |
|
687 // Control step to proof that the method is sound. |
|
688 DoBasicTestL(&CDisableDrivesTest::RediscoveryL, |
|
689 KRediscoveryDrivesEnabledMask, |
|
690 _L("RediscoveryL scan enabled")); |
|
691 |
|
692 // OOM tests are left in here as instructed by the component owner. |
|
693 // In case we need to investigate OOM issues in the future then the |
|
694 // SWE can follow the instructions below to run OOM test manually: |
|
695 // |
|
696 // CDiscoverer::CDirScanner::DoScanDriveL in discoverer.cpp ignores |
|
697 // all errors from RFs::GetDir(). |
|
698 // Go there and manually add if (error == KErrNoMemory) User::LeaveNoMemory() |
|
699 // Also the three RunError of the CActive in discoverer.cpp need to return |
|
700 // KErrNoMemory instead of panic. |
|
701 // NB: after adding the above changes, some OOM tests in t_discoverer and |
|
702 // t_registrar will timeout in ONB (RTests are given 40 minutes to run but OOM |
|
703 // test on discovery takes couple hours). |
|
704 // But if these changes are manual and not submitted in perforce, then |
|
705 // there is no effect on ONB. |
|
706 |
|
707 // DoOOMTestL(&CDisableDrivesTest::startupDiscoveryL, |
|
708 // KStartupDiscoveryDrivesDisabledMask, |
|
709 // _L("OOM startupDiscoveryL scan disabled")); |
|
710 |
|
711 // DoOOMTestL(&CDisableDrivesTest::startupDiscoveryL, |
|
712 // KStartupDiscoveryDrivesEnabledMask, |
|
713 // _L("OOM startupDiscoveryL scan enabled")); |
|
714 |
|
715 // DoOOMTestL(&CDisableDrivesTest::RediscoveryL, |
|
716 // KRediscoveryDrivesDisabledMask, |
|
717 // _L("OOM RediscoveryL scan disabled")); |
|
718 |
|
719 // Control step to proof that the method is sound. |
|
720 // DoOOMTestL(&CDisableDrivesTest::RediscoveryL, |
|
721 // KRediscoveryDrivesEnabledMask, |
|
722 // _L("OOM RediscoveryL scan enabled")); |
|
723 __UHEAP_MARKEND; |
|
724 } |
|
725 |
|
726 //Initialise the Active Scheduler |
|
727 LOCAL_C void SetupL() |
|
728 { |
|
729 // Construct and install the Active Scheduler. The Active Schedular is needed |
|
730 // by components used by this test as they are ActiveObjects. |
|
731 TheActiveScheduler = new(ELeave)CDerivedActiveScheduler; |
|
732 CActiveScheduler::Install(TheActiveScheduler); |
|
733 } |
|
734 |
|
735 GLDEF_C TInt E32Main() |
|
736 { |
|
737 __UHEAP_MARK; |
|
738 |
|
739 test.Printf(_L("\n")); |
|
740 test.Title(); |
|
741 test.Start( _L("Disable scanning on selected drives via patchable constant") ); |
|
742 |
|
743 TheTrapCleanup = CTrapCleanup::New(); |
|
744 |
|
745 // Connect the file server instance |
|
746 User::LeaveIfError(TheFs.Connect()); |
|
747 |
|
748 TRAPD(err, SetupL()); |
|
749 test(err == KErrNone); |
|
750 |
|
751 // Call the main tests |
|
752 TRAP(err, DoTestsL()); |
|
753 test(err == KErrNone); |
|
754 |
|
755 delete TheActiveScheduler; |
|
756 delete TheTrapCleanup; |
|
757 |
|
758 TheFs.Close(); |
|
759 |
|
760 test.End(); |
|
761 test.Close(); |
|
762 |
|
763 __UHEAP_MARKEND; |
|
764 return (KErrNone); |
|
765 } |