|
1 // Copyright (c) 2010 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 #include "t_cenrep_helper.h" |
|
17 #include <e32test.h> |
|
18 #include <f32file.h> |
|
19 #include <utf.h> |
|
20 #include "srvsess.h" |
|
21 #include "sessmgr.h" |
|
22 #include "srvres.h" |
|
23 #include "srvreqs.h" |
|
24 #include "cachemgr.h" |
|
25 #include "clientrequest.h" |
|
26 #include "install.h" |
|
27 #include <bautils.h> |
|
28 |
|
29 LOCAL_D RTest TheTest(_L("t_cenrep_pma_oom.exe")); |
|
30 |
|
31 _LIT( KCentralRepositoryServerName, "Centralrepositorysrv"); |
|
32 |
|
33 _LIT(KInstallDirFile, "c:\\private\\10202BE9\\persists\\installdir.bin"); |
|
34 |
|
35 _LIT(KInstallPMATxtFileSrc, "z:\\private\\10202BE9\\f1000701.txi"); |
|
36 _LIT(KInstallPMATxtFileTgt, "c:\\private\\10202BE9\\f1000701.txt"); |
|
37 |
|
38 _LIT(KInstallPMACreFileSrc, "z:\\private\\10202BE9\\f1000700.cri"); |
|
39 _LIT(KInstallPMACreFileTgt, "c:\\private\\10202BE9\\f1000700.cre"); |
|
40 |
|
41 //Test repositories Uid |
|
42 const TUid KTestRepositoryUid={0xf1000701}; |
|
43 |
|
44 static TUid KCurrentTestUid; |
|
45 |
|
46 //Burst rate for __UHEAP_SETBURSTFAIL |
|
47 #ifdef _DEBUG |
|
48 const TInt KBurstRate = 20; |
|
49 #endif |
|
50 |
|
51 /////////////////////////////////////////////////////////////////////////////////////// |
|
52 //Test macros and functions |
|
53 LOCAL_C void Check(TInt aValue, TInt aLine) |
|
54 { |
|
55 if(!aValue) |
|
56 { |
|
57 TRAPD(err, CleanupCDriveL()); |
|
58 if (err != KErrNone) |
|
59 { |
|
60 RDebug::Print( _L( "*** CleanupCDriveL also failed with error %d expecting KErrNone\r\n"), err ); |
|
61 } |
|
62 TheTest(EFalse, aLine); |
|
63 } |
|
64 } |
|
65 LOCAL_C void Check(TInt aValue, TInt aExpected, TInt aLine, TBool aIsHexFormat=EFalse) |
|
66 { |
|
67 if(aValue != aExpected) |
|
68 { |
|
69 if(aIsHexFormat) |
|
70 { |
|
71 RDebug::Print(_L("*** Expected error: 0x%x, got: 0x%x\r\n"), aExpected, aValue); |
|
72 } |
|
73 else |
|
74 { |
|
75 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
|
76 } |
|
77 TRAPD(err, CleanupCDriveL()); |
|
78 if (err != KErrNone) |
|
79 { |
|
80 RDebug::Print( _L( "*** CleanupCDriveL also failed with error %d expecting KErrNone\r\n"), err ); |
|
81 } |
|
82 TheTest(EFalse, aLine); |
|
83 } |
|
84 } |
|
85 #define TEST(arg) ::Check((arg), __LINE__) |
|
86 #define TEST2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__) |
|
87 #define TESTHEX2(aValue, aExpected) ::Check(aValue, aExpected, __LINE__, ETrue) |
|
88 #define TESTKErrNone(aValue) ::Check(aValue,0,__LINE__); |
|
89 |
|
90 /////////////////////////////////////////////////////////////////////////////////////// |
|
91 /////////////////////////////////////////////////////////////////////////////////////// |
|
92 static void CloseTServerResources(TAny*) |
|
93 { |
|
94 TServerResources::Close(); |
|
95 } |
|
96 |
|
97 ///////////////////////////////////////////////////////////////////////////////////////// |
|
98 class CenrepSrvOOMTest :public CBase |
|
99 { |
|
100 public: |
|
101 void GetL(); |
|
102 void FindL(); |
|
103 void ResetL(); |
|
104 void NotifyL(); |
|
105 void SetL(); |
|
106 void CreateL(); |
|
107 void DeleteL(); |
|
108 void MoveL(); |
|
109 |
|
110 CenrepSrvOOMTest(); |
|
111 ~CenrepSrvOOMTest(); |
|
112 static CenrepSrvOOMTest* NewL(); |
|
113 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
|
114 void DoHeapRepositoryContentCheckL(); |
|
115 #endif |
|
116 private: |
|
117 void ConstructL(); |
|
118 public: |
|
119 CServerRepository* iServerRepo; |
|
120 CSessionNotifier* iSessionNotif; |
|
121 }; |
|
122 |
|
123 ////////////////////////////////////////////////////////////////////////////////////////////////// |
|
124 class CenrepSwiOOMTest :public CBase |
|
125 { |
|
126 public: |
|
127 void InstallTxtPmaL(TBool aIsSetup); |
|
128 void InstallCrePmaL(TBool aIsSetup); |
|
129 |
|
130 CenrepSwiOOMTest(); |
|
131 ~CenrepSwiOOMTest(); |
|
132 static CenrepSwiOOMTest* NewL(); |
|
133 private: |
|
134 void ConstructL(); |
|
135 CCentRepSWIWatcher* iSwiWatcher; |
|
136 public: |
|
137 }; |
|
138 ////////////////////////////////////////////////////////////////////////////////////////////////// |
|
139 |
|
140 CenrepSrvOOMTest::CenrepSrvOOMTest(){} |
|
141 |
|
142 CenrepSrvOOMTest::~CenrepSrvOOMTest() |
|
143 { |
|
144 if(iServerRepo) |
|
145 { |
|
146 if(iSessionNotif) |
|
147 { |
|
148 iServerRepo->Close(); |
|
149 } |
|
150 delete iServerRepo; |
|
151 } |
|
152 if(iSessionNotif) |
|
153 { |
|
154 delete iSessionNotif; |
|
155 } |
|
156 |
|
157 // Cache must be disabled here. Otherwise, if any idle repositories exists, they will |
|
158 // still be open (have their pointers in the iOpenRepositories list) and the list will leak. |
|
159 TServerResources::iCacheManager->DisableCache(); |
|
160 TServerResources::iObserver->CloseiOpenRepositories(); |
|
161 } |
|
162 |
|
163 CenrepSrvOOMTest* CenrepSrvOOMTest::NewL() |
|
164 { |
|
165 CenrepSrvOOMTest* self=new (ELeave)CenrepSrvOOMTest; |
|
166 CleanupStack::PushL(self); |
|
167 self->ConstructL(); |
|
168 CleanupStack::Pop(self); |
|
169 return self; |
|
170 } |
|
171 |
|
172 void CenrepSrvOOMTest::ConstructL() |
|
173 { |
|
174 iServerRepo=new (ELeave)CServerRepository(); |
|
175 iSessionNotif=new (ELeave) CSessionNotifier(); |
|
176 |
|
177 iServerRepo->OpenL(KCurrentTestUid,*iSessionNotif); |
|
178 } |
|
179 |
|
180 ////////////////////////////////////////////////////////////////////////////////////////////////// |
|
181 |
|
182 CenrepSwiOOMTest::CenrepSwiOOMTest(){} |
|
183 |
|
184 CenrepSwiOOMTest::~CenrepSwiOOMTest() |
|
185 { |
|
186 delete iSwiWatcher; |
|
187 } |
|
188 |
|
189 CenrepSwiOOMTest* CenrepSwiOOMTest::NewL() |
|
190 { |
|
191 CenrepSwiOOMTest* self=new (ELeave)CenrepSwiOOMTest; |
|
192 CleanupStack::PushL(self); |
|
193 self->ConstructL(); |
|
194 CleanupStack::Pop(self); |
|
195 return self; |
|
196 } |
|
197 |
|
198 void CenrepSwiOOMTest::ConstructL() |
|
199 { |
|
200 iSwiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs); |
|
201 } |
|
202 |
|
203 //Getting various information and security policy from the repository |
|
204 //TInt CServerRepository::Get(TUint32 aId,T& aVal) |
|
205 //TServerSetting* CServerRepository::GetSetting(TUint32 aId) |
|
206 void CenrepSrvOOMTest::GetL() |
|
207 { |
|
208 TInt err=KErrNone; |
|
209 TInt keyInt=0; |
|
210 TServerSetting* srvsetting; |
|
211 //----------Getting the TInt(1-15)----------------------------- |
|
212 for(TInt i=1;i<=15;i++) |
|
213 { |
|
214 err=iServerRepo->Get(i,keyInt); |
|
215 //Remember the policy check is done at the session level |
|
216 TESTKErrNone(err); |
|
217 TEST2(i,keyInt); |
|
218 srvsetting=iServerRepo->GetSetting(i); |
|
219 TEST(srvsetting->Key()==static_cast<TUint32>(i)); |
|
220 } |
|
221 //---------Getting the TReal(16-19)--------------------------- |
|
222 TReal keyValue; |
|
223 err=iServerRepo->Get(16,keyValue); |
|
224 TESTKErrNone(err); |
|
225 TEST(keyValue==10.1010); |
|
226 srvsetting=iServerRepo->GetSetting(16); |
|
227 TESTHEX2(srvsetting->Key(),16); |
|
228 |
|
229 err=iServerRepo->Get(19,keyValue); |
|
230 TESTKErrNone(err); |
|
231 TEST(keyValue==13.1313); |
|
232 |
|
233 //----------Getting the String(20-23)----------------------- |
|
234 TBuf8<50> keyString; |
|
235 _LIT(KFourteen,"fourteen"); |
|
236 err=iServerRepo->Get(20,keyString); |
|
237 TESTKErrNone(err); |
|
238 //Even ascii(8 bytes) are stored as 16 bytes!!! |
|
239 TPtr16 str16((TUint16*) keyString.Ptr(),keyString.Length()/2,keyString.Length()/2); |
|
240 TEST(str16.Compare(KFourteen)==0); |
|
241 srvsetting=iServerRepo->GetSetting(20); |
|
242 TESTHEX2(srvsetting->Key(),20); |
|
243 |
|
244 //---------Getting the String8(0x79)------------------------ |
|
245 TBuf8<50> keyString8; |
|
246 _LIT8(KString8,"string8"); |
|
247 err=iServerRepo->Get(0x79,keyString8); |
|
248 TESTKErrNone(err); |
|
249 TEST(keyString8.Compare(KString8)==0); |
|
250 srvsetting=iServerRepo->GetSetting(0x79); |
|
251 TESTHEX2(srvsetting->Key(),0x79); |
|
252 |
|
253 //---------Getting the binary(0x82)------------------------- |
|
254 TBuf8<50> keyBinary; |
|
255 _LIT8(KBinary8,"\x12\x34\xAB\xCD"); |
|
256 err=iServerRepo->Get(0x82,keyBinary); |
|
257 TESTKErrNone(err); |
|
258 //temporarily added to solve coverage problem in WINSCW |
|
259 TEST(keyBinary.Compare(KBinary8)==0); |
|
260 srvsetting=iServerRepo->GetSetting(0x82); |
|
261 TESTHEX2(srvsetting->Key(),0x82); |
|
262 |
|
263 //----------Getting individual policy----------------------- |
|
264 //Current Exe has caps AllFiles+WriteDeviceData+ReadDeviceData |
|
265 RThread currentThread; |
|
266 TSecurityPolicy secPolicy; |
|
267 //default policy |
|
268 secPolicy=iServerRepo->GetDefaultReadAccessPolicy(); |
|
269 TEST(secPolicy.CheckPolicy(currentThread)==1); |
|
270 secPolicy=iServerRepo->GetDefaultWriteAccessPolicy(); |
|
271 TEST(secPolicy.CheckPolicy(currentThread)==1); |
|
272 |
|
273 //check settings policies |
|
274 //0x2 int 2 1 cap_rd=CommDD cap_wr=WriteDeviceData |
|
275 //0x19 int 25 0 //defined in range policies with cap_rd=NetworkServices |
|
276 secPolicy=iServerRepo->GetReadAccessPolicy(2); |
|
277 TEST(secPolicy.CheckPolicy(currentThread)==0); |
|
278 secPolicy=iServerRepo->GetWriteAccessPolicy(2); |
|
279 TEST(secPolicy.CheckPolicy(currentThread)==1); |
|
280 secPolicy=iServerRepo->GetReadAccessPolicy(25); |
|
281 TEST(secPolicy.CheckPolicy(currentThread)==0); |
|
282 |
|
283 } |
|
284 |
|
285 // now that write operations must be done in transactions, setting up this helper |
|
286 // function to perform single Sets for the purpose of this test. |
|
287 template<class T> |
|
288 static TInt RepositorySingleSetL(CServerRepository& aRep, TUint32 aKey, const T& aValue) |
|
289 { |
|
290 aRep.StartTransaction(EConcurrentReadWriteTransaction); |
|
291 aRep.CleanupCancelTransactionPushL(); |
|
292 aRep.TransactionSetL(aKey, aValue); |
|
293 CleanupStack::Pop(); |
|
294 TUint32 keyInfo; |
|
295 return User::LeaveIfError(aRep.CommitTransaction(keyInfo)); |
|
296 }; |
|
297 |
|
298 //Setting OOM testing |
|
299 void CenrepSrvOOMTest::SetL() |
|
300 { |
|
301 TInt ret=KErrNone; |
|
302 TInt intValue=0; |
|
303 TReal realValue=0; |
|
304 |
|
305 //---------------SetL----------------------------------- |
|
306 //Setting an integer key |
|
307 ret = RepositorySingleSetL(*iServerRepo, 0x60, 600); |
|
308 TESTKErrNone(ret); |
|
309 ret=iServerRepo->Get(0x60,intValue); |
|
310 TESTHEX2(intValue, 600); |
|
311 |
|
312 //Setting a real key |
|
313 ret = RepositorySingleSetL(*iServerRepo, 0x66, 99.99); |
|
314 TESTKErrNone(ret); |
|
315 ret=iServerRepo->Get(0x66,realValue); |
|
316 TEST(realValue==99.99); |
|
317 |
|
318 //Setting a string key |
|
319 //Even ascii(8 bytes) are stored as 16 bytes!!! |
|
320 _LIT8(KString,"sixhundred"); |
|
321 TBuf8<50> stringChangeValue=KString(); |
|
322 ret = RepositorySingleSetL(*iServerRepo, 0x69, stringChangeValue); |
|
323 TESTKErrNone(ret); |
|
324 |
|
325 TBuf8<50> keyString; |
|
326 ret=iServerRepo->Get(0x69,keyString); |
|
327 TESTKErrNone(ret); |
|
328 TEST(keyString.Compare(KString)==0); |
|
329 } |
|
330 |
|
331 // now that write operations must be done in transactions, setting up this helper |
|
332 // function to perform single Creates for the purpose of this test. |
|
333 template<class T> |
|
334 static TInt RepositorySingleCreateL(CServerRepository& aRep, TUint32 aKey, const T& aValue, TUint32* aMeta) |
|
335 { |
|
336 aRep.StartTransaction(EConcurrentReadWriteTransaction); |
|
337 aRep.CleanupCancelTransactionPushL(); |
|
338 aRep.TransactionCreateL(aKey, aValue, aMeta); |
|
339 CleanupStack::Pop(); |
|
340 TUint32 keyInfo; |
|
341 return User::LeaveIfError(aRep.CommitTransaction(keyInfo)); |
|
342 }; |
|
343 |
|
344 void CenrepSrvOOMTest::CreateL() |
|
345 { |
|
346 TInt ret=KErrNone; |
|
347 TInt intValue=0; |
|
348 TReal realValue=0; |
|
349 |
|
350 //--------------CreateL----------------------------------- |
|
351 //Creating an integer key |
|
352 TInt intRetValue; |
|
353 intValue=9000; |
|
354 RepositorySingleCreateL(*iServerRepo, 0x90, intValue, NULL); |
|
355 TESTKErrNone(ret); |
|
356 ret=iServerRepo->Get(0x90,intRetValue); |
|
357 TESTKErrNone(ret); |
|
358 TESTHEX2(intRetValue, intValue); |
|
359 |
|
360 //Creating a real key |
|
361 TReal realRetValue; |
|
362 realValue=33.3333; |
|
363 RepositorySingleCreateL(*iServerRepo, 0x92, realValue, NULL); |
|
364 TESTKErrNone(ret); |
|
365 ret=iServerRepo->Get(0x92,realRetValue); |
|
366 TESTKErrNone(ret); |
|
367 TEST(realValue==realRetValue); |
|
368 |
|
369 //Creating a string key |
|
370 _LIT8(KStringValue,"creatingkey"); |
|
371 TBuf8<50> stringCreateValue=KStringValue(); |
|
372 RepositorySingleCreateL(*iServerRepo, 0x93, stringCreateValue, NULL); |
|
373 TESTKErrNone(ret); |
|
374 } |
|
375 |
|
376 // now that write operations must be done in transactions, setting up this helper |
|
377 // function to perform single Creates for the purpose of this test. |
|
378 static TInt RepositorySingleDeleteL(CServerRepository& aRep, TUint32 aKey) |
|
379 { |
|
380 aRep.StartTransaction(EConcurrentReadWriteTransaction); |
|
381 aRep.CleanupCancelTransactionPushL(); |
|
382 aRep.TransactionDeleteL(aKey); |
|
383 CleanupStack::Pop(); |
|
384 TUint32 keyInfo; |
|
385 return User::LeaveIfError(aRep.CommitTransaction(keyInfo)); |
|
386 }; |
|
387 |
|
388 void CenrepSrvOOMTest::DeleteL() |
|
389 { |
|
390 TInt ret=KErrNone; |
|
391 //--------------Delete----------------------------------- |
|
392 //Find the settings 0x10A-0x10C to ensure it is still there |
|
393 RSettingPointerArray matchingArray; |
|
394 TUint32 partialId=0x100; |
|
395 TUint32 idMask=0xFFFFFFF0; |
|
396 ret=iServerRepo->FindSettings(partialId,idMask,matchingArray); |
|
397 if(ret==KErrNoMemory) |
|
398 { |
|
399 matchingArray.Close(); |
|
400 User::LeaveNoMemory(); |
|
401 } |
|
402 |
|
403 TESTKErrNone(ret); |
|
404 TEST2(matchingArray.Count(),3); |
|
405 matchingArray.Close(); |
|
406 |
|
407 //Deleting settings 0x10A to 0x10C |
|
408 for(TInt i=0x10A;i<=0x10C;i++) |
|
409 { |
|
410 RepositorySingleDeleteL(*iServerRepo, i); |
|
411 TESTKErrNone(ret); |
|
412 } |
|
413 //After deleting try to find the persistent settings again |
|
414 ret=iServerRepo->FindSettings(partialId,idMask,matchingArray); |
|
415 if(ret==KErrNoMemory) |
|
416 { |
|
417 matchingArray.Close(); |
|
418 User::LeaveNoMemory(); |
|
419 } |
|
420 TESTKErrNone(ret); |
|
421 TEST2(matchingArray.Count(),0); |
|
422 matchingArray.Close(); |
|
423 |
|
424 //-------------DeleteRange--------------------------------- |
|
425 //Deleting settings 0x1 to 0xF |
|
426 TClientRequest dummyrequest; |
|
427 TUint32 errId=0; |
|
428 partialId=0; |
|
429 idMask=0xFFFFFFF0; |
|
430 ret=iServerRepo->FindSettings(partialId,idMask,matchingArray); |
|
431 if(ret==KErrNoMemory) |
|
432 { |
|
433 matchingArray.Close(); |
|
434 User::LeaveNoMemory(); |
|
435 } |
|
436 TESTKErrNone(ret); |
|
437 TEST2(matchingArray.Count(),15); |
|
438 matchingArray.Close(); |
|
439 |
|
440 //Deleting settings using the DeleteRange |
|
441 dummyrequest.SetParam(0,partialId); |
|
442 dummyrequest.SetParam(1,idMask); |
|
443 dummyrequest.SetPolicyCheck(ETrue); |
|
444 |
|
445 // write operation must take place in a transaction |
|
446 iServerRepo->StartTransaction(EConcurrentReadWriteTransaction); |
|
447 iServerRepo->CleanupCancelTransactionPushL(); |
|
448 iServerRepo->TransactionDeleteRangeL(dummyrequest,errId); |
|
449 CleanupStack::Pop(); |
|
450 TUint32 keyInfo; |
|
451 User::LeaveIfError(iServerRepo->CommitTransaction(keyInfo)); |
|
452 |
|
453 //Now try to find the key being deleted |
|
454 ret=iServerRepo->FindSettings(partialId,idMask,matchingArray); |
|
455 if(ret==KErrNoMemory) |
|
456 { |
|
457 matchingArray.Close(); |
|
458 User::LeaveNoMemory(); |
|
459 } |
|
460 TESTKErrNone(ret); |
|
461 TEST2(matchingArray.Count(),0); |
|
462 matchingArray.Close(); |
|
463 } |
|
464 |
|
465 //Setting existing key value then follow by commit |
|
466 void CenrepSrvOOMTest::MoveL() |
|
467 { |
|
468 RSettingPointerArray matchingArray; |
|
469 TUint32 idMask=0xFFFFFFF0; |
|
470 |
|
471 TClientRequest dummyrequest; |
|
472 TUint32 errId=0; |
|
473 TUint32 sourcePartialId=0x110; |
|
474 TUint32 targetPartialId=0x120; |
|
475 idMask=0xFFFFFFF0; |
|
476 |
|
477 TKeyFilter srcKeyIdentifier = {sourcePartialId, idMask}; |
|
478 TPckg<TKeyFilter> pSrcIdentifier(srcKeyIdentifier); |
|
479 TKeyFilter tgtKeyIdentifier = {targetPartialId, idMask}; |
|
480 TPckg<TKeyFilter> pTgtIdentifier(tgtKeyIdentifier); |
|
481 |
|
482 //First check to ensure the target key before move does not exist |
|
483 User::LeaveIfError(iServerRepo->FindSettings(targetPartialId,idMask,matchingArray)); |
|
484 TEST2(matchingArray.Count(),0); |
|
485 matchingArray.Close(); |
|
486 |
|
487 //moving from 0x110(0x11B,0x11C,0x11E) to 0x120 |
|
488 dummyrequest.SetParam(0, &pSrcIdentifier); |
|
489 dummyrequest.SetParam(1, &pTgtIdentifier); |
|
490 dummyrequest.SetPolicyCheck(ETrue); |
|
491 |
|
492 // write operation must take place in a transaction |
|
493 User::LeaveIfError(iServerRepo->StartTransaction(EConcurrentReadWriteTransaction)); |
|
494 iServerRepo->CleanupCancelTransactionPushL(); |
|
495 User::LeaveIfError(iServerRepo->TransactionMoveL(dummyrequest,errId)); |
|
496 CleanupStack::Pop(); |
|
497 TUint32 keyInfo; |
|
498 User::LeaveIfError(iServerRepo->CommitTransaction(keyInfo)); |
|
499 |
|
500 //Now try to find the key being moved |
|
501 User::LeaveIfError(iServerRepo->FindSettings(targetPartialId,idMask,matchingArray)); |
|
502 TEST2(matchingArray.Count(),3); |
|
503 matchingArray.Close(); |
|
504 } |
|
505 |
|
506 //Finding keys from the settings |
|
507 //TInt FindSettings(TUint32 aPartialId,TUint32 aIdMask,RSettingPointerArray& aMatches) |
|
508 //Guarantees the heap free in aMatches if this function fail |
|
509 void CenrepSrvOOMTest::FindL() |
|
510 { |
|
511 TInt ret=KErrNone; |
|
512 RSettingPointerArray foundIdArray; |
|
513 TUint32 partialId=0; |
|
514 TUint32 idMask=0; |
|
515 //-----------Finding settings array using partial id & mask------ |
|
516 |
|
517 //------------------Real type--------------------------------- |
|
518 //0x42,0x44,0x45,0x48 |
|
519 partialId=0x40; |
|
520 idMask=0xFFFFFFF0; |
|
521 User::LeaveIfError(iServerRepo->FindSettings(partialId,idMask,foundIdArray)); |
|
522 TESTKErrNone(ret); |
|
523 TEST2(foundIdArray.Count(),4); |
|
524 foundIdArray.Close(); |
|
525 |
|
526 //-----------------String type------------------------------- |
|
527 //0x51,0x54,0x5B |
|
528 partialId=0x50; |
|
529 idMask=0xFFFFFFF0; |
|
530 User::LeaveIfError(iServerRepo->FindSettings(partialId,idMask,foundIdArray)); |
|
531 TESTKErrNone(ret); |
|
532 TEST2(foundIdArray.Count(),3); |
|
533 foundIdArray.Close(); |
|
534 |
|
535 //--------------------Int type---------------------------------------------------- |
|
536 partialId=0x30; |
|
537 idMask=0xFFFFFFF0; |
|
538 //This should return only 0x30,0x34,0x35,0x39,0x3B( 5 items) |
|
539 User::LeaveIfError(iServerRepo->FindSettings(partialId,idMask,foundIdArray)); |
|
540 TESTKErrNone(ret); |
|
541 TEST2(foundIdArray.Count(),5); |
|
542 |
|
543 //----------------Find comparison using EEqual & ENotEqual------------------------ |
|
544 TInt searchValue=100; |
|
545 TClientRequest dummyrequest; |
|
546 RArray<TUint32> idArray; |
|
547 //Set the policycheck to always pass |
|
548 dummyrequest.SetPolicyCheck(ETrue); |
|
549 //Comparison using Equal |
|
550 TRAP(ret,iServerRepo->FindCompareL(foundIdArray,searchValue,EEqual,idArray)); |
|
551 if(ret==KErrNoMemory) |
|
552 { |
|
553 //do not need to reset idArray as it is done inside the function itself when it returns not KErrNone |
|
554 foundIdArray.Close(); |
|
555 User::LeaveNoMemory(); |
|
556 } |
|
557 TEST2(idArray.Count(),2); |
|
558 TEST((idArray[0]==0x30 && idArray[1]==0x34) || (idArray[0]==0x34 && idArray[1]==0x30)); |
|
559 idArray.Close(); |
|
560 //Comparison using ENotEqual |
|
561 TRAP(ret,iServerRepo->FindCompareL(foundIdArray,searchValue,ENotEqual,idArray)); |
|
562 if(ret==KErrNoMemory) |
|
563 { |
|
564 //do not need to reset idArray as it is done inside the function itself when it returns not KErrNone |
|
565 foundIdArray.Close(); |
|
566 User::LeaveNoMemory(); |
|
567 } |
|
568 TEST2(idArray.Count(),3); |
|
569 idArray.Close(); |
|
570 foundIdArray.Close(); |
|
571 |
|
572 } |
|
573 |
|
574 //Resetting settings |
|
575 void CenrepSrvOOMTest::ResetL() |
|
576 { |
|
577 TInt ret=KErrNone; |
|
578 TInt retValue=0; |
|
579 TReal realValue=0; |
|
580 |
|
581 //-------------Single key reset---------------------------- |
|
582 |
|
583 ret = RepositorySingleSetL(*iServerRepo, 1, 500); |
|
584 TESTKErrNone(ret); |
|
585 ret=iServerRepo->Get(1,retValue); |
|
586 TESTHEX2(retValue, 500); |
|
587 |
|
588 //Resetting individual settings |
|
589 ret=iServerRepo->ResetL(1); |
|
590 TEST2(ret, KErrNotSupported); |
|
591 |
|
592 //Check for value once being reset |
|
593 ret=iServerRepo->Get(1,retValue); |
|
594 TEST(retValue==500); |
|
595 |
|
596 //------------All keys reset------------------------------ |
|
597 ret = RepositorySingleSetL(*iServerRepo, 17, 3.1343424); |
|
598 TESTKErrNone(ret); |
|
599 |
|
600 //Reset all settings from Rom |
|
601 ret = iServerRepo->ResetAllL(); |
|
602 TEST2(ret, KErrNotSupported); |
|
603 |
|
604 //Check for value once all being reset |
|
605 |
|
606 ret=iServerRepo->Get(17,realValue); |
|
607 TEST(realValue==3.1343424); |
|
608 } |
|
609 |
|
610 void CenrepSrvOOMTest::NotifyL() |
|
611 { |
|
612 TInt err=KErrNone; |
|
613 |
|
614 //addding individual requests |
|
615 for(TInt i=0;i<10;i++) |
|
616 { |
|
617 TClientRequest dummyRequest; |
|
618 User::LeaveIfError(iSessionNotif->AddRequest(i,dummyRequest)); |
|
619 } |
|
620 |
|
621 //adding group requests |
|
622 for(TInt i=0;i<10;i++) |
|
623 { |
|
624 TClientRequest dummyRequest; |
|
625 TUint32 partialId=100*i; |
|
626 TUint32 idMask=0xFFFFFFF0; |
|
627 User::LeaveIfError(iSessionNotif->AddRequest(partialId,idMask,dummyRequest)); |
|
628 } |
|
629 |
|
630 //cancelling individual requests |
|
631 User::LeaveIfError(iSessionNotif->CancelRequest(5)); |
|
632 //Check to ensure that it has been deleted so calling cancel again will return KErrNotFound |
|
633 err=iSessionNotif->CancelRequest(5); |
|
634 TEST2(err,KErrNotFound); |
|
635 |
|
636 //cancelling group requests |
|
637 User::LeaveIfError(iSessionNotif->CancelRequest(500,0xFFFFFFF0)); |
|
638 err=iSessionNotif->CancelRequest(500,0xFFFFFF0); |
|
639 TEST2(err,KErrNotFound); |
|
640 |
|
641 //Finally cancel ALL requests |
|
642 iSessionNotif->CancelAllRequests(); |
|
643 |
|
644 } |
|
645 |
|
646 //Deletes the CServerRepository object properly |
|
647 LOCAL_C void ReleaseRepository(TAny* aServerRepository) |
|
648 { |
|
649 CServerRepository* serverRepository = static_cast<CServerRepository*>(aServerRepository); |
|
650 |
|
651 TServerResources::iCacheManager->DisableCache(); |
|
652 TServerResources::iObserver->CloseiOpenRepositories(); |
|
653 delete serverRepository; |
|
654 TServerResources::iCacheManager->EnableCache(); |
|
655 } |
|
656 |
|
657 //Opening a repository and closing the repository |
|
658 LOCAL_C void OpenCloseL(TBool /*aOOMMode*/) |
|
659 { |
|
660 CServerRepository* serverRepo=new (ELeave)CServerRepository(); |
|
661 TCleanupItem cleanupItem(&ReleaseRepository, serverRepo); |
|
662 CleanupStack::PushL(cleanupItem); |
|
663 |
|
664 CSessionNotifier* sessNotif=new (ELeave)CSessionNotifier(); |
|
665 CleanupStack::PushL(sessNotif); |
|
666 |
|
667 // test access to a valid repository |
|
668 serverRepo->OpenL(KCurrentTestUid,*sessNotif); |
|
669 serverRepo->Close(); |
|
670 |
|
671 CleanupStack::PopAndDestroy(sessNotif); |
|
672 CleanupStack::PopAndDestroy(1); |
|
673 } |
|
674 |
|
675 LOCAL_C void DoMultiRofsReposTestL( TUid aReposUid, const TDesC& aTestDesc, TInt aExpectedResult) |
|
676 { |
|
677 |
|
678 TheTest.Next(aTestDesc); |
|
679 |
|
680 TInt err; |
|
681 TInt tryCount = 0; |
|
682 KCurrentTestUid = aReposUid; |
|
683 do |
|
684 { |
|
685 __UHEAP_MARK; |
|
686 |
|
687 //Initializing the server resources |
|
688 TServerResources::InitialiseL(); |
|
689 CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0)); |
|
690 |
|
691 // find out the number of open handles |
|
692 TInt startProcessHandleCount; |
|
693 TInt startThreadHandleCount; |
|
694 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
695 |
|
696 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, ++tryCount, KBurstRate); |
|
697 |
|
698 TRAP(err, OpenCloseL(ETrue)); |
|
699 if(err!=KErrNoMemory) |
|
700 { |
|
701 TEST2(err, aExpectedResult); |
|
702 } |
|
703 |
|
704 __UHEAP_RESET; |
|
705 |
|
706 // check that no handles have leaked |
|
707 TInt endProcessHandleCount; |
|
708 TInt endThreadHandleCount; |
|
709 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
710 TEST2(startProcessHandleCount, endProcessHandleCount); |
|
711 TEST2(startThreadHandleCount, endThreadHandleCount); |
|
712 |
|
713 //Freeing the server resources |
|
714 CleanupStack::Pop(); //CloseTServerResources |
|
715 TServerResources::Close(); |
|
716 |
|
717 __UHEAP_MARKEND; |
|
718 } while(err == KErrNoMemory); |
|
719 |
|
720 TEST2(err, aExpectedResult); |
|
721 TheTest.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount); |
|
722 |
|
723 } |
|
724 |
|
725 void CenrepSwiOOMTest::InstallTxtPmaL(TBool aIsSetup) |
|
726 { |
|
727 if(aIsSetup) |
|
728 { |
|
729 RFs fs; |
|
730 User::LeaveIfError(fs.Connect()); |
|
731 CleanupClosePushL(fs); |
|
732 CFileMan* fm = CFileMan::NewL(fs); |
|
733 CleanupStack::PushL(fm); |
|
734 |
|
735 // Copy a txt PMA keyspace into install dir & Reset read-only bit |
|
736 // This keyspace also exists in ROM as PMA keyspace |
|
737 User::LeaveIfError(fm->Copy(KInstallPMATxtFileSrc, KInstallPMATxtFileTgt)); |
|
738 User::LeaveIfError(fm->Attribs(KInstallPMATxtFileTgt,0,KEntryAttReadOnly,TTime(0))); |
|
739 |
|
740 CleanupStack::PopAndDestroy(2); // fs and fm |
|
741 } |
|
742 else |
|
743 { |
|
744 iSwiWatcher->HandleSWIEventL(ESASwisInstall | ESASwisStatusSuccess); |
|
745 } |
|
746 } |
|
747 |
|
748 void CenrepSwiOOMTest::InstallCrePmaL(TBool aIsSetup) |
|
749 { |
|
750 if(aIsSetup) |
|
751 { |
|
752 RFs fs; |
|
753 User::LeaveIfError(fs.Connect()); |
|
754 CleanupClosePushL(fs); |
|
755 CFileMan* fm = CFileMan::NewL(fs); |
|
756 CleanupStack::PushL(fm); |
|
757 |
|
758 // Copy a cre PMA keyspace into install dir & Reset read-only bit |
|
759 User::LeaveIfError(fm->Copy(KInstallPMACreFileSrc, KInstallPMACreFileTgt)); |
|
760 User::LeaveIfError(fm->Attribs(KInstallPMACreFileTgt,0,KEntryAttReadOnly,TTime(0))); |
|
761 |
|
762 CleanupStack::PopAndDestroy(2); // fs and fm |
|
763 } |
|
764 else |
|
765 { |
|
766 iSwiWatcher->HandleSWIEventL(ESASwisInstall | ESASwisStatusSuccess); |
|
767 } |
|
768 } |
|
769 |
|
770 LOCAL_C void StartupInstallL(TBool aIsSetup) |
|
771 { |
|
772 if(aIsSetup) |
|
773 { |
|
774 // Set up files for test |
|
775 RFs fs; |
|
776 User::LeaveIfError(fs.Connect()); |
|
777 CleanupClosePushL(fs); |
|
778 CFileMan* fm = CFileMan::NewL(fs); |
|
779 CleanupStack::PushL(fm); |
|
780 |
|
781 // Clean out files |
|
782 TInt err=fs.Delete(KInstallDirFile); |
|
783 if((err!=KErrNone)&&(err!=KErrNotFound)) |
|
784 { |
|
785 User::Leave(err); |
|
786 } |
|
787 |
|
788 // Cause directory listing with no files to be written |
|
789 CCentRepSWIWatcher* swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs); |
|
790 delete swiWatcher; |
|
791 |
|
792 // Copy a txt PMA keyspace into install dir & Reset read-only bit |
|
793 User::LeaveIfError(fm->Copy(KInstallPMATxtFileSrc, KInstallPMATxtFileTgt)); |
|
794 User::LeaveIfError(fm->Attribs(KInstallPMATxtFileTgt,0,KEntryAttReadOnly,TTime(0))); |
|
795 |
|
796 // Copy a cre PMA keyspace into install dir & Reset read-only bit |
|
797 User::LeaveIfError(fm->Copy(KInstallPMACreFileSrc, KInstallPMACreFileTgt)); |
|
798 User::LeaveIfError(fm->Attribs(KInstallPMACreFileTgt,0,KEntryAttReadOnly,TTime(0))); |
|
799 |
|
800 |
|
801 CleanupStack::PopAndDestroy(2); // fs and fm |
|
802 } |
|
803 else |
|
804 { |
|
805 CCentRepSWIWatcher* swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs); |
|
806 delete swiWatcher; |
|
807 } |
|
808 } |
|
809 |
|
810 // Type definition for pointer to function |
|
811 // Used for functions that can't use CenrepSrvOOMTest::ConstructL |
|
812 typedef void (*FuncPtrL) (TBool); |
|
813 /** |
|
814 Wrapper function to call all OOM test functions |
|
815 @param testFuncL pointer to OOM test function |
|
816 @param aTestDesc test function name |
|
817 */ |
|
818 LOCAL_C void DoOOMNoServReposL( FuncPtrL atestFuncL, const TDesC& aTestDesc, TBool aOOMMode) |
|
819 { |
|
820 TheTest.Next(aTestDesc); |
|
821 |
|
822 TInt err; |
|
823 TInt tryCount = 0; |
|
824 do |
|
825 { |
|
826 __UHEAP_MARK; |
|
827 |
|
828 //Initializing the server resources |
|
829 TServerResources::InitialiseL(); |
|
830 CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0)); |
|
831 |
|
832 // find out the number of open handles |
|
833 TInt startProcessHandleCount; |
|
834 TInt startThreadHandleCount; |
|
835 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
836 |
|
837 (*atestFuncL)(ETrue); |
|
838 |
|
839 if(aOOMMode) |
|
840 { |
|
841 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, ++tryCount, KBurstRate); |
|
842 } |
|
843 |
|
844 TRAP(err, (*atestFuncL)(EFalse)); |
|
845 if(err!=KErrNoMemory) |
|
846 { |
|
847 TESTKErrNone(err); |
|
848 } |
|
849 |
|
850 if(aOOMMode) |
|
851 { |
|
852 __UHEAP_RESET; |
|
853 } |
|
854 |
|
855 // check that no handles have leaked |
|
856 TInt endProcessHandleCount; |
|
857 TInt endThreadHandleCount; |
|
858 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
859 TEST2(startProcessHandleCount, endProcessHandleCount); |
|
860 TEST2(startThreadHandleCount, endThreadHandleCount); |
|
861 |
|
862 //Freeing the server resources |
|
863 CleanupStack::Pop(); //CloseTServerResources |
|
864 TServerResources::Close(); |
|
865 |
|
866 __UHEAP_MARKEND; |
|
867 } while(err == KErrNoMemory); |
|
868 |
|
869 TESTKErrNone(err); |
|
870 if(aOOMMode) |
|
871 { |
|
872 TheTest.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount); |
|
873 } |
|
874 } |
|
875 |
|
876 // Type definition for pointer to member function. |
|
877 // Used in calling the CRegistryDataTest member function for testing. |
|
878 typedef void (CenrepSrvOOMTest::*ClassFuncPtrL) (void); |
|
879 /** |
|
880 Wrapper function to call all OOM test functions |
|
881 @param testFuncL pointer to OOM test function |
|
882 @param aTestDesc test function name |
|
883 @param aOOMMode to enable/disable the OOM environment |
|
884 */ |
|
885 LOCAL_C void DoOOMTestL(ClassFuncPtrL testFuncL, const TDesC& aTestDesc,TBool aOOMMode) |
|
886 { |
|
887 TheTest.Next(aTestDesc); |
|
888 |
|
889 TInt err=KErrNone; |
|
890 TInt tryCount = 0; |
|
891 do |
|
892 { |
|
893 __UHEAP_MARK; |
|
894 //Clear any files in the persist directory |
|
895 CleanupCDriveL(); |
|
896 |
|
897 //Initializing the server resources |
|
898 TServerResources::InitialiseL(); |
|
899 CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0)); |
|
900 |
|
901 CenrepSrvOOMTest* theTest=CenrepSrvOOMTest::NewL(); |
|
902 CleanupStack::PushL(theTest); |
|
903 |
|
904 TInt startProcessHandleCount; |
|
905 TInt startThreadHandleCount; |
|
906 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
907 |
|
908 if(aOOMMode) |
|
909 { |
|
910 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, ++tryCount, KBurstRate); |
|
911 } |
|
912 TRAP(err, (theTest->*testFuncL)()); |
|
913 |
|
914 if(aOOMMode) |
|
915 { |
|
916 __UHEAP_RESET; |
|
917 } |
|
918 |
|
919 if(err!=KErrNoMemory) |
|
920 { |
|
921 TESTKErrNone(err); |
|
922 } |
|
923 |
|
924 CleanupStack::PopAndDestroy(theTest); |
|
925 |
|
926 // check that no handles have leaked |
|
927 TInt endProcessHandleCount; |
|
928 TInt endThreadHandleCount; |
|
929 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
930 |
|
931 TEST2(startProcessHandleCount, endProcessHandleCount); |
|
932 TEST2(startThreadHandleCount, endThreadHandleCount); |
|
933 |
|
934 //Freeing the server resources |
|
935 CleanupStack::Pop(); //CleanupTServerResources |
|
936 TServerResources::Close(); |
|
937 __UHEAP_MARKEND; |
|
938 } while(err == KErrNoMemory); |
|
939 |
|
940 TESTKErrNone(err); |
|
941 if(aOOMMode) |
|
942 { |
|
943 TheTest.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount); |
|
944 } |
|
945 } |
|
946 |
|
947 // Type definition for pointer to member function. |
|
948 // Used in calling the CRegistryDataTest member function for testing. |
|
949 typedef void (CenrepSwiOOMTest::*ClassSwiFuncPtrL) (TBool); |
|
950 /** |
|
951 Wrapper function to call all OOM test functions |
|
952 @param testFuncL pointer to OOM test function |
|
953 @param aTestDesc test function name |
|
954 @param aOOMMode to enable/disable the OOM environment |
|
955 */ |
|
956 LOCAL_C void DoOOMSwiTestL(ClassSwiFuncPtrL aTestFuncL, const TDesC& aTestDesc,TBool aOOMMode, TInt aExpectedError) |
|
957 { |
|
958 TheTest.Next(aTestDesc); |
|
959 |
|
960 TInt err=KErrNone; |
|
961 TInt tryCount = 0; |
|
962 do |
|
963 { |
|
964 __UHEAP_MARK; |
|
965 |
|
966 CleanupCDriveL(); |
|
967 //Initializing the server resources |
|
968 TServerResources::InitialiseL(); |
|
969 CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0)); |
|
970 |
|
971 TInt startProcessHandleCount; |
|
972 TInt startThreadHandleCount; |
|
973 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
974 |
|
975 CenrepSwiOOMTest* theTest=CenrepSwiOOMTest::NewL(); |
|
976 CleanupStack::PushL(theTest); |
|
977 |
|
978 // Set up test |
|
979 (theTest->*aTestFuncL)(ETrue); |
|
980 |
|
981 if(aOOMMode) |
|
982 { |
|
983 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, ++tryCount, KBurstRate); |
|
984 } |
|
985 RDebug::Print(_L("tryCount = %d"),tryCount); |
|
986 |
|
987 TRAP(err, (theTest->*aTestFuncL)(EFalse)); |
|
988 |
|
989 if(aOOMMode) |
|
990 { |
|
991 __UHEAP_RESET; |
|
992 } |
|
993 |
|
994 if(err!=KErrNoMemory) |
|
995 { |
|
996 TEST2(err, aExpectedError); |
|
997 } |
|
998 |
|
999 CleanupStack::PopAndDestroy(theTest); |
|
1000 |
|
1001 // check that no handles have leaked |
|
1002 TInt endProcessHandleCount; |
|
1003 TInt endThreadHandleCount; |
|
1004 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
1005 |
|
1006 TEST2(startProcessHandleCount, endProcessHandleCount); |
|
1007 TEST2(startThreadHandleCount, endThreadHandleCount); |
|
1008 |
|
1009 //Freeing the server resources |
|
1010 CleanupStack::Pop(); //CleanupTServerResources |
|
1011 TServerResources::Close(); |
|
1012 __UHEAP_MARKEND; |
|
1013 } while(err == KErrNoMemory); |
|
1014 |
|
1015 TEST2(err, aExpectedError); |
|
1016 if(aOOMMode) |
|
1017 { |
|
1018 TheTest.Printf(_L("- server succeeded at heap failure rate of %i\n"), tryCount); |
|
1019 } |
|
1020 } |
|
1021 |
|
1022 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
|
1023 void CenrepSrvOOMTest::DoHeapRepositoryContentCheckL() |
|
1024 { |
|
1025 CServerRepository* srv=iServerRepo; |
|
1026 //check setting and its meta |
|
1027 TServerSetting* setting=NULL; |
|
1028 |
|
1029 setting=srv->GetSetting(1); |
|
1030 TESTHEX2(setting->iKey,1); |
|
1031 TESTHEX2(setting->iMeta,0x80000010); |
|
1032 //points to global default policy here |
|
1033 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
1034 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1035 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
1036 |
|
1037 setting=srv->GetSetting(2); |
|
1038 TESTHEX2(setting->iKey,2); |
|
1039 TESTHEX2(setting->iMeta,0xA0000010); |
|
1040 //points to global default policy here |
|
1041 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
1042 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1043 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
1044 |
|
1045 setting=srv->GetSetting(3); |
|
1046 TESTHEX2(setting->iKey,3); |
|
1047 TESTHEX2(setting->iMeta,0x800000FF); |
|
1048 //points to global default policy here |
|
1049 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
1050 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1051 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
1052 |
|
1053 setting=srv->GetSetting(4); |
|
1054 TESTHEX2(setting->iKey,4); |
|
1055 TESTHEX2(setting->iMeta,0x80000010); |
|
1056 TESTHEX2(setting->iAccessPolicy->LowKey(),4); |
|
1057 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1058 TESTHEX2(setting->iAccessPolicy->KeyMask(),0); |
|
1059 |
|
1060 setting=srv->GetSetting(5); |
|
1061 TESTHEX2(setting->iKey,5); |
|
1062 TESTHEX2(setting->iMeta,0xC0000063); |
|
1063 //points to global default policy here |
|
1064 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
1065 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1066 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
1067 |
|
1068 setting=srv->GetSetting(6); |
|
1069 TESTHEX2(setting->iKey,6); |
|
1070 TESTHEX2(setting->iMeta,0x90000010); |
|
1071 TESTHEX2(setting->iAccessPolicy->LowKey(),6); |
|
1072 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1073 TESTHEX2(setting->iAccessPolicy->KeyMask(),0); |
|
1074 |
|
1075 setting=srv->GetSetting(7); |
|
1076 TESTHEX2(setting->iKey,7); |
|
1077 TESTHEX2(setting->iMeta,0x80000010); |
|
1078 TESTHEX2(setting->iAccessPolicy->LowKey(),7); |
|
1079 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1080 TESTHEX2(setting->iAccessPolicy->KeyMask(),0); |
|
1081 |
|
1082 setting=srv->GetSetting(9); |
|
1083 TESTHEX2(setting->iKey,9); |
|
1084 TESTHEX2(setting->iMeta,0x80000010); |
|
1085 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
1086 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1087 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
1088 |
|
1089 setting=srv->GetSetting(10); |
|
1090 TESTHEX2(setting->iKey,10); |
|
1091 TESTHEX2(setting->iMeta,0x80000010); |
|
1092 TESTHEX2(setting->iAccessPolicy->LowKey(),10); |
|
1093 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1094 TESTHEX2(setting->iAccessPolicy->KeyMask(),0); |
|
1095 |
|
1096 setting=srv->GetSetting(300); |
|
1097 TESTHEX2(setting->iKey,300); |
|
1098 TESTHEX2(setting->iMeta,0x900003E7); |
|
1099 TESTHEX2(setting->iAccessPolicy->LowKey(),KUnspecifiedKey); |
|
1100 TESTHEX2(setting->iAccessPolicy->HighKey(),1); |
|
1101 TESTHEX2(setting->iAccessPolicy->KeyMask(),1); |
|
1102 } |
|
1103 |
|
1104 LOCAL_C void DoAdditionalCheckingL(TUid aReposUid) |
|
1105 { |
|
1106 TServerResources::InitialiseL(); |
|
1107 CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0)); |
|
1108 |
|
1109 KCurrentTestUid = aReposUid; |
|
1110 CenrepSrvOOMTest* test=CenrepSrvOOMTest::NewL(); |
|
1111 CleanupStack::PushL(test); |
|
1112 test->DoHeapRepositoryContentCheckL(); |
|
1113 |
|
1114 CleanupStack::PopAndDestroy(); |
|
1115 CleanupStack::Pop(); //CloseTServerResources |
|
1116 |
|
1117 TServerResources::Close(); |
|
1118 } |
|
1119 |
|
1120 /** |
|
1121 @SYMTestCaseID PDS-CENTRALREPOSITORY-UT-4126 |
|
1122 @SYMTestCaseDesc Verifying that CRE generated will have the latest CRE version which is currently 3 |
|
1123 @SYMTestPriority High |
|
1124 @SYMTestActions Validating that CRE files generated with post REQ42876 code will always contain at least version 3. |
|
1125 The unit test will load a txt repository and then modify some settings so that it gets persisted |
|
1126 in the persists directory. The test then read the cre files to verify that the version persisted |
|
1127 is the latest which is 3. |
|
1128 @SYMTestExpectedResults The correct file version is returned. |
|
1129 @SYMREQ REQ42876 |
|
1130 */ |
|
1131 LOCAL_C void DoPersistedVersionCheckingL() |
|
1132 { |
|
1133 TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4126 Verifying CRE generated will always be version 3 ")); |
|
1134 TServerResources::InitialiseL(); |
|
1135 CleanupStack::PushL(TCleanupItem(CloseTServerResources, 0)); |
|
1136 |
|
1137 const TUid KTestUid={0xF1000702}; |
|
1138 KCurrentTestUid=KTestUid; |
|
1139 |
|
1140 CenrepSrvOOMTest* test=CenrepSrvOOMTest::NewL(); |
|
1141 CleanupStack::PushL(test); |
|
1142 |
|
1143 //persist immediately |
|
1144 test->iServerRepo->CommitChangesL(EPma); |
|
1145 |
|
1146 //now check the version of the CRE file |
|
1147 CHeapRepository* heap=CHeapRepository::NewL(KTestUid); |
|
1148 CleanupStack::PushL(heap); |
|
1149 TUint8 creVersion; |
|
1150 heap->CreateRepositoryFromCreFileL(TServerResources::iFs,_L("c:\\private\\10202be9\\persists\\protected\\f1000702.cre"),creVersion); |
|
1151 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
1152 TEST2(creVersion,KPersistFormatSupportsPma); |
|
1153 #else |
|
1154 TEST2(creVersion,KPersistFormatSupportsIndMetaIndicator); |
|
1155 #endif |
|
1156 CleanupStack::PopAndDestroy(2,test); |
|
1157 CleanupStack::Pop(); //CloseTServerResources |
|
1158 TServerResources::Close(); |
|
1159 } |
|
1160 |
|
1161 /** |
|
1162 @SYMTestCaseID PDS-CENTRALREPOSITORY-UT-4127 |
|
1163 @SYMTestCaseDesc Server side OOM loading of a multiple ROFS PMA repository files |
|
1164 @SYMTestPriority High |
|
1165 @SYMTestActions - Create the server class CServerRepository and use it to load the multi ROFS PMA keyspace. |
|
1166 - Test are repeated for the following keyspace combination such as TXT/TXT, CRE/TXT or TXT/CRE and CRE/CRE. |
|
1167 - Test will also verify the resulting merged settings which includes checking |
|
1168 individual metadata bits and security policy bits |
|
1169 - Test will also be repeated for opening PMA keyspace with non-PMA keyspace in different ROFS layers. |
|
1170 @SYMTestExpectedResults - Server loading of the multi rofs keyspace should not fail and leak memory under OOM condition. |
|
1171 @SYMREQ REQ42876 |
|
1172 */ |
|
1173 LOCAL_C void DoOOMMultiRofsTestL() |
|
1174 { |
|
1175 TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4127 Centrep Server PMA MultiROFS OOM Test ")); |
|
1176 |
|
1177 const TUid KMultiRofsRepositoryUid0={0xF1000900}; |
|
1178 const TUid KMultiRofsRepositoryUid1={0xF1000901}; |
|
1179 const TUid KMultiRofsRepositoryUid2={0xF1000902}; |
|
1180 const TUid KMultiRofsRepositoryUid3={0xF1000903}; |
|
1181 const TUid KMultiRofsRepositoryUid4={0xF1000904}; |
|
1182 const TUid KMultiRofsRepositoryUid5={0xF1000905};//TXT1(core) - TXT0(rofs1) |
|
1183 const TUid KMultiRofsRepositoryUid6={0xF1000906};//TXT0(core) - TXT1(rofs1) |
|
1184 const TUid KMultiRofsRepositoryUid7={0xF1000907};//CRE1(core) - CRE0(rofs1) |
|
1185 const TUid KMultiRofsRepositoryUid8={0xF1000908};//CRE0(core) - CRE1(rofs1) |
|
1186 const TUid KMultiRofsRepositoryUid9={0xF1000909};//CRE1(core) - TXT0(rofs1) |
|
1187 const TUid KMultiRofsRepositoryUid10={0xF100090A};//CRE0(core) - TXT1(rofs1) |
|
1188 const TUid KMultiRofsRepositoryUid11={0xF100090B};//TXT1(core) - CRE0(rofs1) |
|
1189 const TUid KMultiRofsRepositoryUid12={0xF100090C};//TXT0(core) - CRE1(rofs1) |
|
1190 const TUid KMultiRofsRepositoryUid13={0xF100090D};//TXT1(core) - CRE1(rofs1) - TXT1(rofs2) - CRE0(rofs3) |
|
1191 // Note: TXT1 means the file is PMA repository with .txt format |
|
1192 // TXT0 means the file is non-PMA repository with .txt format |
|
1193 // CRE1 means the file is PMA repository with .cre format |
|
1194 // CRE0 means the file is non-PMA repository with .cre format |
|
1195 |
|
1196 //Testing the OOM of multi rofs processing |
|
1197 DoMultiRofsReposTestL(KMultiRofsRepositoryUid0, _L("Open Close OOM Multi ROFS Test 0"),KErrNone); |
|
1198 DoAdditionalCheckingL(KMultiRofsRepositoryUid0); |
|
1199 DoMultiRofsReposTestL(KMultiRofsRepositoryUid1, _L("Open Close OOM Multi ROFS Test 1"),KErrNone); |
|
1200 DoAdditionalCheckingL(KMultiRofsRepositoryUid1); |
|
1201 DoMultiRofsReposTestL(KMultiRofsRepositoryUid2, _L("Open Close OOM Multi ROFS Test 2"),KErrNone); |
|
1202 DoAdditionalCheckingL(KMultiRofsRepositoryUid2); |
|
1203 DoMultiRofsReposTestL(KMultiRofsRepositoryUid3, _L("Open Close OOM Multi ROFS Test 3"),KErrNone); |
|
1204 DoAdditionalCheckingL(KMultiRofsRepositoryUid3); |
|
1205 DoMultiRofsReposTestL(KMultiRofsRepositoryUid4, _L("Open Close OOM Multi ROFS Test 4"),KErrNone); |
|
1206 DoAdditionalCheckingL(KMultiRofsRepositoryUid4); |
|
1207 DoMultiRofsReposTestL(KMultiRofsRepositoryUid5, _L("Open Close OOM Multi ROFS Test 5"),KErrCorrupt); |
|
1208 DoMultiRofsReposTestL(KMultiRofsRepositoryUid6, _L("Open Close OOM Multi ROFS Test 6"),KErrCorrupt); |
|
1209 DoMultiRofsReposTestL(KMultiRofsRepositoryUid7, _L("Open Close OOM Multi ROFS Test 7"),KErrCorrupt); |
|
1210 DoMultiRofsReposTestL(KMultiRofsRepositoryUid8, _L("Open Close OOM Multi ROFS Test 8"),KErrCorrupt); |
|
1211 DoMultiRofsReposTestL(KMultiRofsRepositoryUid9, _L("Open Close OOM Multi ROFS Test 9"),KErrCorrupt); |
|
1212 DoMultiRofsReposTestL(KMultiRofsRepositoryUid10, _L("Open Close OOM Multi ROFS Test 10"),KErrCorrupt); |
|
1213 DoMultiRofsReposTestL(KMultiRofsRepositoryUid11, _L("Open Close OOM Multi ROFS Test 11"),KErrCorrupt); |
|
1214 DoMultiRofsReposTestL(KMultiRofsRepositoryUid12, _L("Open Close OOM Multi ROFS Test 12"),KErrCorrupt); |
|
1215 DoMultiRofsReposTestL(KMultiRofsRepositoryUid13, _L("Open Close OOM Multi ROFS Test 13"),KErrCorrupt); |
|
1216 |
|
1217 } |
|
1218 #endif |
|
1219 |
|
1220 /** |
|
1221 @SYMTestCaseID PDS-CENTRALREPOSITORY-UT-4125 |
|
1222 @SYMTestCaseDesc Server side OOM test on Centrep functionalities |
|
1223 @SYMTestPriority High |
|
1224 @SYMTestActions - Call Get, Set, Create, Delete, Move, Find, Notify, Reset on a repository. |
|
1225 - Simulate SWI install and upgrade install on a repository. |
|
1226 - Do the above steps on again under OOM condition. |
|
1227 - Open and Close repository under OOM condition. |
|
1228 - Verify the resulting merged settings which includes checking |
|
1229 individual metadata bits and security policy bits |
|
1230 @SYMTestExpectedResults - Server loading of the multi rofs keyspace should not fail and leak memory under OOM condition. |
|
1231 @SYMREQ REQ42876 |
|
1232 */ |
|
1233 LOCAL_C void DoOOMTestsL() |
|
1234 { |
|
1235 TheTest.Next(_L(" @SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4125 Starting CENREPSRV OOM Test ")); |
|
1236 RFs fs; |
|
1237 User::LeaveIfError(fs.Connect()); |
|
1238 CleanupClosePushL(fs); |
|
1239 CFileMan* fm = CFileMan::NewL(fs); |
|
1240 CleanupStack::PushL(fm); |
|
1241 |
|
1242 //Clear any files in the persist directory |
|
1243 CleanupCDriveL(); |
|
1244 |
|
1245 //First Testuid=KTestRepositoryUid |
|
1246 KCurrentTestUid=KTestRepositoryUid; |
|
1247 |
|
1248 DoOOMTestL(&CenrepSrvOOMTest::GetL,_L("Get Basic Test"),EFalse); |
|
1249 DoOOMTestL(&CenrepSrvOOMTest::FindL,_L("FindL Basic Test"),EFalse); |
|
1250 DoOOMTestL(&CenrepSrvOOMTest::NotifyL,_L("NotifyL Basic Test"),EFalse); |
|
1251 DoOOMTestL(&CenrepSrvOOMTest::ResetL,_L("ResetL Basic Test"),EFalse); |
|
1252 DoOOMTestL(&CenrepSrvOOMTest::SetL,_L("SetL Basic Test"),EFalse); |
|
1253 DoOOMTestL(&CenrepSrvOOMTest::CreateL,_L("CreateL Basic Test"),EFalse); |
|
1254 DoOOMTestL(&CenrepSrvOOMTest::DeleteL,_L("DeleteL Basic Test"),EFalse); |
|
1255 DoOOMTestL(&CenrepSrvOOMTest::MoveL,_L("MoveL Basic Test"),EFalse); |
|
1256 |
|
1257 // Simulate response to SWI rom-upgrade and downgrade events |
|
1258 DoOOMSwiTestL(&CenrepSwiOOMTest::InstallTxtPmaL,_L("SwiUpgradeROMRev1L Basic Test"),EFalse, KErrNotSupported); |
|
1259 |
|
1260 // Simulate response to SWI new rep install/uninstall event events |
|
1261 DoOOMSwiTestL(&CenrepSwiOOMTest::InstallCrePmaL,_L("SwiInstallL Basic Test"),EFalse, KErrNotSupported); |
|
1262 |
|
1263 // Simulate SWI events before server startup |
|
1264 DoOOMNoServReposL(&StartupInstallL, _L("Startup Upgrade Basic Test"), EFalse); |
|
1265 |
|
1266 //OOM Test aOOMMode=ETrue |
|
1267 DoOOMNoServReposL(&OpenCloseL, _L("Open Close OOM Test"),ETrue); |
|
1268 |
|
1269 //Clear any files in the persist directory |
|
1270 CleanupCDriveL(); |
|
1271 TInt r = KillProcess(KCentralRepositoryServerName); |
|
1272 TEST2(r,KErrNone); |
|
1273 |
|
1274 DoOOMTestL(&CenrepSrvOOMTest::GetL,_L("Get OOM Test"),ETrue); |
|
1275 DoOOMTestL(&CenrepSrvOOMTest::FindL,_L("FindL OOM Test"),ETrue); |
|
1276 DoOOMTestL(&CenrepSrvOOMTest::NotifyL,_L("NotifyL OOM Test"),ETrue); |
|
1277 DoOOMTestL(&CenrepSrvOOMTest::ResetL,_L("ResetL OOM Test"),ETrue); |
|
1278 DoOOMTestL(&CenrepSrvOOMTest::SetL,_L("SetL OOM Test"),ETrue); |
|
1279 DoOOMTestL(&CenrepSrvOOMTest::CreateL,_L("CreateL OOM Test"),ETrue); |
|
1280 DoOOMTestL(&CenrepSrvOOMTest::DeleteL,_L("DeleteL OOM Test"),ETrue); |
|
1281 DoOOMTestL(&CenrepSrvOOMTest::MoveL,_L("MoveL OOM Test"),ETrue); |
|
1282 |
|
1283 //Clear any files in the persist directory |
|
1284 CleanupCDriveL(); |
|
1285 |
|
1286 DoOOMSwiTestL(&CenrepSwiOOMTest::InstallTxtPmaL,_L("SwiUpgradeROMRev1L OOM Test"),ETrue, KErrNotSupported); |
|
1287 |
|
1288 DoOOMSwiTestL(&CenrepSwiOOMTest::InstallCrePmaL,_L("SwiInstallL OOM Test"),ETrue, KErrNotSupported); |
|
1289 |
|
1290 DoOOMNoServReposL(&StartupInstallL, _L("Startup Upgrade OOM Test"), ETrue); |
|
1291 |
|
1292 DoPersistedVersionCheckingL(); |
|
1293 #ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS |
|
1294 DoOOMMultiRofsTestL(); |
|
1295 #endif |
|
1296 |
|
1297 CleanupCDriveL(); |
|
1298 |
|
1299 CleanupStack::PopAndDestroy(2); // fs and fm |
|
1300 } |
|
1301 |
|
1302 LOCAL_C void MainL() |
|
1303 { |
|
1304 CActiveScheduler* scheduler = new(ELeave)CActiveScheduler; |
|
1305 CActiveScheduler::Install(scheduler); |
|
1306 |
|
1307 DoOOMTestsL(); |
|
1308 CleanupCDriveL(); |
|
1309 |
|
1310 delete scheduler; |
|
1311 } |
|
1312 |
|
1313 TInt E32Main() |
|
1314 { |
|
1315 TheTest.Title (); |
|
1316 TheTest.Start(_L("PMA OOM Cenrepserv Test")); |
|
1317 |
|
1318 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
1319 TheTest(cleanup != NULL); |
|
1320 |
|
1321 __UHEAP_MARK; |
|
1322 |
|
1323 TRAPD(err, MainL()); |
|
1324 TEST2(err, KErrNone); |
|
1325 |
|
1326 __UHEAP_MARKEND; |
|
1327 |
|
1328 TheTest.End (); |
|
1329 TheTest.Close (); |
|
1330 |
|
1331 delete cleanup; |
|
1332 |
|
1333 User::Heap().Check(); |
|
1334 return KErrNone; |
|
1335 } |