|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 //#include <centralrepository.h> |
|
17 #include <e32test.h> |
|
18 #include <f32file.h> |
|
19 #include <badesca.h> |
|
20 #include <connect/sbdefs.h> |
|
21 #include <connect/sbeclient.h> |
|
22 |
|
23 #include "srvrepos_noc.h" |
|
24 #include "srvres.h" |
|
25 #include "cachemgr.h" |
|
26 #include "backup.h" |
|
27 |
|
28 RTest TheTest(_L("Central Repository Backup & Restore Tests")); |
|
29 |
|
30 enum FileSet |
|
31 { |
|
32 EOriginals, |
|
33 EChanged, |
|
34 ERemoved, |
|
35 EDEF058823L |
|
36 }; |
|
37 |
|
38 _LIT_SECURE_ID( SecureId1, 0x12345 ); |
|
39 |
|
40 TBool oomRunning; |
|
41 HBufC* iniRomDir=NULL; |
|
42 |
|
43 CRepositoryBackupClient* backupClient; |
|
44 |
|
45 CDesC8ArraySeg* originalData1; |
|
46 CDesC8ArraySeg* changedData1; |
|
47 CDesC8ArraySeg* originalData2; |
|
48 CDesC8ArraySeg* changedData2; |
|
49 CDesC8ArraySeg* changedData3; |
|
50 |
|
51 CActiveScheduler* globalAS; |
|
52 |
|
53 const TUid KUidBackupTestRepository = { 0xbabababa }; |
|
54 const TUid KUidBackupTestRepository1 = { 0x00000100 }; |
|
55 |
|
56 const TUint32 KBackupInt1 = 0x02010100; |
|
57 const TInt KIntOrigValue1 = 10; |
|
58 const TUint32 KBackupInt2 = 0x03010200; |
|
59 const TInt KIntChangedValue2 = 200; |
|
60 const TUint32 KBackupInt3 = 0x04010300; |
|
61 const TInt KIntOrigValue3 = 30; |
|
62 |
|
63 const TUint32 KBackupString1 = 0x02010600; |
|
64 _LIT8(KStringOrigValue, "test original"); |
|
65 _LIT8(KStringChangedValue, "test changed"); |
|
66 const TUint32 KBackupString2 = 0x03010600; |
|
67 const TUint32 KBackupReal1 = 0x02010700; |
|
68 const TReal KRealOrigValue = 1.1; |
|
69 const TUint32 KBackupReal2 = 0x03010700; |
|
70 const TReal KRealChangedValue = 2.5; |
|
71 |
|
72 /////////////////////////////////////////////////////////////////////////////////////// |
|
73 /////////////////////////////////////////////////////////////////////////////////////// |
|
74 //Test macroses and functions |
|
75 |
|
76 |
|
77 LOCAL_C void NextTest(TPtrC aMsg) |
|
78 { |
|
79 if (!oomRunning) |
|
80 { |
|
81 TheTest.Next( aMsg ); |
|
82 } |
|
83 } |
|
84 |
|
85 LOCAL_C void DeleteFilesL() |
|
86 { |
|
87 _LIT( KOldInstallFiles, "c:\\private\\102081E4\\*.*" ); |
|
88 _LIT( KOldPersistFiles, "c:\\private\\102081E4\\persists\\*.*" ); |
|
89 |
|
90 CFileMan* fm = CFileMan::NewL( TServerResources::iFs ); |
|
91 CleanupStack::PushL( fm ); |
|
92 |
|
93 TInt r = KErrNone; |
|
94 |
|
95 r = fm->Delete( KOldInstallFiles ); |
|
96 #ifndef __WINSCW__ |
|
97 if (r == KErrAccessDenied) |
|
98 { |
|
99 // we are not able to delete the files on ARM if their attributes are not set correctly. |
|
100 // Only set attributes when got KErrAccessDenied because it's time consuming in OOM test. |
|
101 r = fm->Attribs( KOldInstallFiles, KEntryAttArchive, KEntryAttReadOnly, TTime( 0 ), CFileMan::ERecurse ); |
|
102 User::LeaveIfError(r); |
|
103 r = fm->Delete( KOldInstallFiles ); |
|
104 } |
|
105 #endif |
|
106 if ( r != KErrNone && r != KErrNotFound && r != KErrPathNotFound ) |
|
107 User::Leave(r); |
|
108 |
|
109 r = fm->Delete( KOldPersistFiles ); |
|
110 #ifndef __WINSCW__ |
|
111 if (r == KErrAccessDenied) |
|
112 { |
|
113 // we are not able to delete the files on ARM if their attributes are not set correctly. |
|
114 // Only set attributes when got KErrAccessDenied because it's time consuming in OOM test. |
|
115 r = fm->Attribs( KOldPersistFiles, KEntryAttArchive, KEntryAttReadOnly, TTime( 0 ), CFileMan::ERecurse ); |
|
116 User::LeaveIfError(r); |
|
117 r = fm->Delete( KOldPersistFiles ); |
|
118 } |
|
119 #endif |
|
120 if ( r != KErrNone && r != KErrNotFound && r != KErrPathNotFound ) |
|
121 User::Leave(r); |
|
122 |
|
123 CleanupStack::PopAndDestroy( fm ); |
|
124 } |
|
125 |
|
126 LOCAL_C void CheckL( TInt aValue, TInt aLine ) |
|
127 { |
|
128 if ( !aValue ) |
|
129 { |
|
130 DeleteFilesL(); |
|
131 TheTest( EFalse, aLine ); |
|
132 } |
|
133 } |
|
134 |
|
135 LOCAL_C void CheckL( TInt aValue, TInt aExpected, TInt aLine ) |
|
136 { |
|
137 if ( aValue != aExpected ) |
|
138 { |
|
139 DeleteFilesL(); |
|
140 RDebug::Print( _L( "*** Expected error: %d, got: %d\r\n"), aExpected, aValue ); |
|
141 TheTest( EFalse, aLine ); |
|
142 } |
|
143 } |
|
144 |
|
145 #define TEST(arg) ::CheckL((arg), __LINE__) |
|
146 #define TEST2(aValue, aExpected) ::CheckL(aValue, aExpected, __LINE__) |
|
147 |
|
148 /////////////////////////////////////////////////////////////////////////////////////// |
|
149 /////////////////////////////////////////////////////////////////////////////////////// |
|
150 |
|
151 LOCAL_C void InitializationL() |
|
152 { |
|
153 originalData1 = new(ELeave)CDesC8ArraySeg( 128 ); |
|
154 CleanupStack::PushL( originalData1 ); |
|
155 changedData1 = new(ELeave)CDesC8ArraySeg( 128 ); |
|
156 CleanupStack::PushL( changedData1 ); |
|
157 originalData2 = new(ELeave)CDesC8ArraySeg( 128 ); |
|
158 CleanupStack::PushL( originalData2 ); |
|
159 changedData2 = new(ELeave)CDesC8ArraySeg( 128 ); |
|
160 CleanupStack::PushL( changedData2 ); |
|
161 changedData3 = new(ELeave)CDesC8ArraySeg( 128 ); |
|
162 CleanupStack::PushL( changedData3 ); |
|
163 } |
|
164 |
|
165 LOCAL_C void Cleanup() |
|
166 { |
|
167 CleanupStack::PopAndDestroy( changedData3 ); |
|
168 CleanupStack::PopAndDestroy( changedData2 ); |
|
169 CleanupStack::PopAndDestroy( originalData2 ); |
|
170 CleanupStack::PopAndDestroy( changedData1 ); |
|
171 CleanupStack::PopAndDestroy( originalData1 ); |
|
172 } |
|
173 |
|
174 LOCAL_C void InstallFileSetL( FileSet aFileSet ) |
|
175 { |
|
176 _LIT(KSourceFiles_V1, "z:\\private\\10202BE9\\*.cra"); |
|
177 _LIT(KSourceFiles_V2, "z:\\private\\10202BE9\\*.crb"); |
|
178 _LIT(KDestForInstallFiles, "c:\\private\\102081E4\\*.cre"); |
|
179 _LIT(KDestForPersistFiles, "c:\\private\\102081E4\\persists\\*.cre"); |
|
180 _LIT(KDEF058823DestFile, "c:\\private\\102081E4\\persists\\*.*"); |
|
181 _LIT(KDEF058823SrcFile, "z:\\private\\10202BE9\\babababa.cre"); |
|
182 |
|
183 DeleteFilesL(); |
|
184 // When the contents of the repository directories change, the cached iOwnerIdLookUpTable becomes invalid |
|
185 TServerResources::iOwnerIdLookUpTable.Reset(); |
|
186 |
|
187 CFileMan* fm = CFileMan::NewL( TServerResources::iFs ); |
|
188 CleanupStack::PushL( fm ); |
|
189 |
|
190 TInt r; |
|
191 |
|
192 switch ( aFileSet ) |
|
193 { |
|
194 case EOriginals: |
|
195 { |
|
196 r = TServerResources::iFs.MkDirAll( KDestForPersistFiles ); |
|
197 if ( r != KErrNone && r != KErrAlreadyExists ) |
|
198 User::Leave( r ); |
|
199 |
|
200 User::LeaveIfError( fm->Copy( KSourceFiles_V1, KDestForInstallFiles ) ); |
|
201 User::LeaveIfError( fm->Copy( KSourceFiles_V1, KDestForPersistFiles ) ); |
|
202 |
|
203 r = fm->Attribs( KDestForInstallFiles, KEntryAttArchive, KEntryAttReadOnly, TTime( 0 ), CFileMan::ERecurse ); |
|
204 if(r == KErrNoMemory) |
|
205 User::Leave(r); |
|
206 TEST2( r, KErrNone ); |
|
207 |
|
208 break; |
|
209 } |
|
210 case EChanged: |
|
211 { |
|
212 r = TServerResources::iFs.MkDirAll( KDestForPersistFiles ); |
|
213 if ( r != KErrNone && r != KErrAlreadyExists ) |
|
214 User::Leave( r ); |
|
215 |
|
216 User::LeaveIfError( fm->Copy( KSourceFiles_V1, KDestForInstallFiles ) ); |
|
217 User::LeaveIfError( fm->Copy( KSourceFiles_V2, KDestForPersistFiles ) ); |
|
218 |
|
219 r = fm->Attribs( KDestForInstallFiles, KEntryAttArchive, KEntryAttReadOnly, TTime( 0 ), CFileMan::ERecurse ); |
|
220 if(r == KErrNoMemory) |
|
221 User::Leave(r); |
|
222 TEST2( r, KErrNone ); |
|
223 |
|
224 break; |
|
225 } |
|
226 case ERemoved: |
|
227 { |
|
228 r = TServerResources::iFs.MkDirAll( KDestForInstallFiles ); |
|
229 if ( r != KErrNone && r != KErrAlreadyExists ) |
|
230 User::Leave( r ); |
|
231 |
|
232 User::LeaveIfError( fm->Copy( KSourceFiles_V1, KDestForInstallFiles ) ); |
|
233 |
|
234 r = fm->Attribs( KDestForInstallFiles, KEntryAttArchive, KEntryAttReadOnly, TTime( 0 ), CFileMan::ERecurse ); |
|
235 if(r == KErrNoMemory) |
|
236 User::Leave(r); |
|
237 TEST2( r, KErrNone ); |
|
238 |
|
239 break; |
|
240 } |
|
241 case EDEF058823L: |
|
242 { |
|
243 r = TServerResources::iFs.MkDirAll( KDEF058823DestFile ); |
|
244 if ( r != KErrNone && r != KErrAlreadyExists ) |
|
245 User::Leave( r ); |
|
246 |
|
247 User::LeaveIfError( fm->Copy( KDEF058823SrcFile, KDEF058823DestFile ) ); |
|
248 |
|
249 r = fm->Attribs( KDEF058823DestFile, KEntryAttArchive, KEntryAttReadOnly, TTime( 0 ), CFileMan::ERecurse ); |
|
250 if(r == KErrNoMemory) |
|
251 User::Leave(r); |
|
252 TEST2( r, KErrNone ); |
|
253 |
|
254 break; |
|
255 } |
|
256 default: |
|
257 RDebug::Print( _L( "Illegal parameter to function: %d\r\n" ), aFileSet ); |
|
258 TheTest( EFalse, __LINE__ ); |
|
259 } |
|
260 |
|
261 CleanupStack::PopAndDestroy( fm ); |
|
262 } |
|
263 |
|
264 LOCAL_C void CleanupActiveScheduler(TAny* aShc) |
|
265 { |
|
266 CActiveScheduler::Replace( globalAS ); |
|
267 delete aShc; |
|
268 } |
|
269 |
|
270 LOCAL_C TBool StreamsAreIdenticalL( CDesC8ArraySeg* aDataStream1, CDesC8ArraySeg* aDataStream2) |
|
271 { |
|
272 TInt count1 = 0; |
|
273 TInt count2 = 0; |
|
274 TInt element = 0; |
|
275 TInt length = 0; |
|
276 TInt total1 = 0; |
|
277 TInt total2 = 0; |
|
278 TBool retVal = EFalse; |
|
279 |
|
280 count1 = aDataStream1->Count(); |
|
281 for ( element = 0; element < count1; element++ ) |
|
282 { |
|
283 length = (*aDataStream1)[ element ].Length(); |
|
284 total1 += length; |
|
285 } |
|
286 count2 = aDataStream2->Count(); |
|
287 for ( element = 0; element < count2; element++ ) |
|
288 { |
|
289 length = (*aDataStream2)[ element ].Length(); |
|
290 total2 += length; |
|
291 } |
|
292 if ( total1 != total2 ) |
|
293 return retVal; |
|
294 |
|
295 // Copying each array into a single descriptor before comparison is deliberate |
|
296 // to make it easier to inspect the contents in a debugger |
|
297 HBufC8* buffer1 = HBufC8::NewLC( total1 ); |
|
298 TPtr8 tPtr1( buffer1->Des() ); |
|
299 HBufC8* buffer2 = HBufC8::NewLC( total2 ); |
|
300 TPtr8 tPtr2( buffer2->Des() ); |
|
301 |
|
302 for ( element = 0; element < count1; element++ ) |
|
303 { |
|
304 tPtr1.Append( (*aDataStream1)[ element ] ); |
|
305 } |
|
306 for ( element = 0; element < count2; element++ ) |
|
307 { |
|
308 tPtr2.Append( (*aDataStream2)[ element ] ); |
|
309 } |
|
310 |
|
311 if ( tPtr1.Compare( tPtr2 ) == 0 ) |
|
312 retVal = ETrue; |
|
313 CleanupStack::PopAndDestroy( buffer2 ); |
|
314 CleanupStack::PopAndDestroy( buffer1 ); |
|
315 return retVal; |
|
316 } |
|
317 |
|
318 |
|
319 LOCAL_C void BackupRepositoryL( CDesC8ArraySeg* aDataStream ) |
|
320 { |
|
321 backupClient->CompleteOwnerIdLookupTableL(); |
|
322 backupClient->InitialiseGetProxyBackupDataL( SecureId1, EDriveC ); |
|
323 |
|
324 HBufC8* transferBuffer = HBufC8::NewL( 128 ); |
|
325 CleanupStack::PushL( transferBuffer ); |
|
326 TPtr8 bufferToSend = transferBuffer->Des(); |
|
327 TBool finished = EFalse; |
|
328 |
|
329 aDataStream->Reset(); |
|
330 |
|
331 do |
|
332 { |
|
333 bufferToSend.Zero(); |
|
334 backupClient->GetBackupDataSectionL( bufferToSend, finished ); |
|
335 aDataStream->AppendL( bufferToSend ); |
|
336 } while ( !finished ); |
|
337 |
|
338 CleanupStack::PopAndDestroy( transferBuffer ); |
|
339 } |
|
340 |
|
341 LOCAL_C void RestoreRepositoryL( CDesC8ArraySeg* aDataStream ) |
|
342 { |
|
343 backupClient->InitialiseRestoreProxyBaseDataL( SecureId1, EDriveC ); |
|
344 |
|
345 HBufC8* transferBuffer = HBufC8::NewL( 128 ); |
|
346 CleanupStack::PushL( transferBuffer ); |
|
347 |
|
348 TBool finished = EFalse; |
|
349 TInt count = aDataStream->Count(); |
|
350 TInt element = 0; |
|
351 |
|
352 for ( element = 0; element < count; element++ ) |
|
353 { |
|
354 TPtrC8 ptr = (*aDataStream)[ element ]; |
|
355 if (ptr.Size()>transferBuffer->Des().MaxSize()) |
|
356 { |
|
357 transferBuffer = transferBuffer->ReAlloc(ptr.Size()); |
|
358 } |
|
359 TPtr8 bufferToSend = transferBuffer->Des(); |
|
360 bufferToSend.Zero(); |
|
361 bufferToSend.Append( ptr ); |
|
362 if ( element + 1 == count ) |
|
363 finished = ETrue; |
|
364 backupClient->RestoreBaseDataSectionL( bufferToSend, finished ); |
|
365 } |
|
366 backupClient->RestoreComplete( EDriveC ); |
|
367 |
|
368 CleanupStack::PopAndDestroy( transferBuffer ); |
|
369 } |
|
370 |
|
371 |
|
372 /** |
|
373 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-0115 |
|
374 @SYMTestCaseDesc Test Backup functionality. |
|
375 @SYMTestPriority High |
|
376 @SYMTestActions Test Backup functionality. |
|
377 @SYMTestExpectedResults The test must not fail. |
|
378 @SYMPREQ PREQ752 |
|
379 PREQ908 |
|
380 */ |
|
381 LOCAL_C void BackupTestsL() |
|
382 { |
|
383 NextTest( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0115 Backup repository " ) ); |
|
384 |
|
385 // create and install the active scheduler we need |
|
386 CActiveScheduler* s = new(ELeave) CActiveScheduler; |
|
387 |
|
388 TCleanupItem tc(CleanupActiveScheduler, s); |
|
389 CleanupStack::PushL(tc); |
|
390 |
|
391 CActiveScheduler::Replace( s ); |
|
392 |
|
393 backupClient = CRepositoryBackupClient::NewLC( TServerResources::iFs ); |
|
394 TEST( backupClient != 0 ); |
|
395 |
|
396 // These tests don't test Backup&Restore functionality over Secure Backup Server so cache management |
|
397 // is not possible. For that reason, cache is disabled manually. |
|
398 TServerResources::iCacheManager->DisableCache(); |
|
399 |
|
400 NextTest( _L( "Backup original version" ) ); |
|
401 // Install known files |
|
402 InstallFileSetL( EOriginals ); |
|
403 BackupRepositoryL( originalData1 ); |
|
404 |
|
405 NextTest( _L( "Backup changed version" ) ); |
|
406 InstallFileSetL( EChanged ); |
|
407 BackupRepositoryL( changedData1 ); |
|
408 |
|
409 DeleteFilesL(); |
|
410 NextTest( _L( "Confirm streams different" ) ); |
|
411 TEST( !StreamsAreIdenticalL( originalData1, changedData1 ) ); |
|
412 |
|
413 CleanupStack::PopAndDestroy( backupClient ); |
|
414 // Cleanup the scheduler |
|
415 CleanupStack::PopAndDestroy( s ); |
|
416 } |
|
417 |
|
418 |
|
419 /** |
|
420 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-0116 |
|
421 @SYMTestCaseDesc Test Restore functionality. |
|
422 @SYMTestPriority High |
|
423 @SYMTestActions Test Restore functionality. |
|
424 @SYMTestExpectedResults The test must not fail. |
|
425 @SYMPREQ PREQ752 |
|
426 PREQ908 |
|
427 */ |
|
428 |
|
429 /** |
|
430 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CIT-1376 |
|
431 @SYMTestCaseDesc Test for defect |
|
432 @SYMTestPriority High |
|
433 @SYMTestActions Test that default meta doesn't override individual meta |
|
434 @SYMTestExpectedResults Test must not fail |
|
435 @SYMDEF INC067080 |
|
436 */ |
|
437 LOCAL_C void RestoreTestsL() |
|
438 { |
|
439 NextTest( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0116 " ) ); |
|
440 NextTest( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CIT-1376 Restore repository " ) ); |
|
441 |
|
442 // create and install the active scheduler we need |
|
443 CActiveScheduler* s = new(ELeave) CActiveScheduler; |
|
444 |
|
445 TCleanupItem tc(CleanupActiveScheduler, s); |
|
446 CleanupStack::PushL(tc); |
|
447 |
|
448 CActiveScheduler::Replace( s ); |
|
449 |
|
450 backupClient = CRepositoryBackupClient::NewLC(TServerResources::iFs); |
|
451 TEST( backupClient != 0 ); |
|
452 |
|
453 CServerRepository* aServerRepo=new (ELeave)CServerRepository(); |
|
454 CleanupStack::PushL(aServerRepo); |
|
455 CSessionNotifier* aSessionNotif=new (ELeave) CSessionNotifier(); |
|
456 CleanupStack::PushL(aSessionNotif); |
|
457 |
|
458 TServerResources::iCacheManager->DisableCache(); |
|
459 |
|
460 NextTest( _L( "Restore original version over changed version" ) ); |
|
461 InstallFileSetL( EChanged ); |
|
462 RestoreRepositoryL( originalData1 ); |
|
463 |
|
464 NextTest( _L( "Confirm settings restored" ) ); |
|
465 |
|
466 // Open merged repository to check for values of individual settings |
|
467 aServerRepo->OpenL(KUidBackupTestRepository1,*aSessionNotif); |
|
468 |
|
469 TInt r, a; |
|
470 r = aServerRepo->Get(KBackupInt1, a); |
|
471 TEST2(r, KErrNone); |
|
472 // This setting is backed up, so it must be restored to original |
|
473 TEST(a==KIntOrigValue1); |
|
474 |
|
475 r = aServerRepo->Get(KBackupInt2, a); |
|
476 TEST2(r, KErrNone); |
|
477 // This setting isn't backed up, so it must still have changed value |
|
478 TEST(a==KIntChangedValue2); |
|
479 |
|
480 r = aServerRepo->Get(KBackupInt3, a); |
|
481 TEST2(r, KErrNone); |
|
482 // This setting is backed up, so it must be restored to original |
|
483 TEST(a==KIntOrigValue3); |
|
484 |
|
485 TBuf8<KMaxBinaryLength> str; |
|
486 |
|
487 r = aServerRepo->Get(KBackupString1, str); |
|
488 TEST(r==KErrNone); |
|
489 // This setting is backed up, so it must be restored to original |
|
490 TEST(str==KStringOrigValue); |
|
491 |
|
492 r = aServerRepo->Get(KBackupString2, str); |
|
493 TEST(r==KErrNone); |
|
494 // This setting isn't backed up, so it must still have changed value |
|
495 TEST(str==KStringChangedValue); |
|
496 |
|
497 TReal realval; |
|
498 |
|
499 r = aServerRepo->Get(KBackupReal1, realval); |
|
500 TEST(r==KErrNone); |
|
501 // This setting is backed up, so it must be restored to original |
|
502 TEST(realval==KRealOrigValue); |
|
503 |
|
504 r = aServerRepo->Get(KBackupReal2, realval); |
|
505 TEST(r==KErrNone); |
|
506 // This setting isn't backed up, so it must still have changed value |
|
507 TEST(realval==KRealChangedValue); |
|
508 |
|
509 aServerRepo->Close(); |
|
510 |
|
511 NextTest( _L( "Restore changed version over original version" ) ); |
|
512 InstallFileSetL( EOriginals ); |
|
513 RestoreRepositoryL( changedData1 ); |
|
514 |
|
515 NextTest( _L( "Confirm settings restored 2" ) ); |
|
516 |
|
517 // Open merged repository to check for values of individual settings |
|
518 aServerRepo->OpenL(KUidBackupTestRepository1,*aSessionNotif); |
|
519 |
|
520 r = aServerRepo->Get(KBackupInt1, a); |
|
521 TEST2(r, KErrNone); |
|
522 // This setting is not backed up, so it must still have original value |
|
523 TEST(a==KIntOrigValue1); |
|
524 |
|
525 r = aServerRepo->Get(KBackupInt2, a); |
|
526 TEST2(r, KErrNone); |
|
527 // This setting is backed up, so it must be restored to changed |
|
528 TEST(a==KIntChangedValue2); |
|
529 |
|
530 r = aServerRepo->Get(KBackupInt3, a); |
|
531 TEST2(r, KErrNone); |
|
532 // This setting is not backed up, so it must still have original value |
|
533 TEST(a==KIntOrigValue3); |
|
534 |
|
535 r = aServerRepo->Get(KBackupString1, str); |
|
536 TEST(r==KErrNone); |
|
537 // This setting is not backed up, so it must still have original value |
|
538 TEST(str==KStringOrigValue); |
|
539 |
|
540 r = aServerRepo->Get(KBackupString2, str); |
|
541 TEST(r==KErrNone); |
|
542 // This setting is backed up, so it must be restored to changed |
|
543 TEST(str==KStringChangedValue); |
|
544 |
|
545 r = aServerRepo->Get(KBackupReal1, realval); |
|
546 TEST(r==KErrNone); |
|
547 // This setting is not backed up, so it must still have original value |
|
548 TEST(realval==KRealOrigValue); |
|
549 |
|
550 r = aServerRepo->Get(KBackupReal2, realval); |
|
551 TEST(r==KErrNone); |
|
552 // This setting is backed up, so it must be restored to changed |
|
553 TEST(realval==KRealChangedValue); |
|
554 |
|
555 aServerRepo->Close(); |
|
556 |
|
557 NextTest( _L( "Restore changed version of deleted repository" ) ); |
|
558 InstallFileSetL( ERemoved ); |
|
559 RestoreRepositoryL( changedData1 ); |
|
560 |
|
561 NextTest( _L( "Confirm settings restored 3" ) ); |
|
562 |
|
563 // Open merged repository to check for values of individual settings |
|
564 aServerRepo->OpenL(KUidBackupTestRepository1,*aSessionNotif); |
|
565 |
|
566 // This one should be the same as first one, only this time the values |
|
567 // to be merged had been read from the file in install directory instead |
|
568 // of the file in persists. |
|
569 |
|
570 r = aServerRepo->Get(KBackupInt1, a); |
|
571 TEST2(r, KErrNone); |
|
572 // This setting is backed up, so it must be restored to original |
|
573 TEST(a==KIntOrigValue1); |
|
574 |
|
575 r = aServerRepo->Get(KBackupInt2, a); |
|
576 TEST2(r, KErrNone); |
|
577 // This setting isn't backed up, so it must still have changed value |
|
578 TEST(a==KIntChangedValue2); |
|
579 |
|
580 r = aServerRepo->Get(KBackupInt3, a); |
|
581 TEST2(r, KErrNone); |
|
582 // This setting is backed up, so it must be restored to original |
|
583 TEST(a==KIntOrigValue3); |
|
584 |
|
585 r = aServerRepo->Get(KBackupString1, str); |
|
586 TEST(r==KErrNone); |
|
587 // This setting is backed up, so it must be restored to original |
|
588 TEST(str==KStringOrigValue); |
|
589 |
|
590 r = aServerRepo->Get(KBackupString2, str); |
|
591 TEST(r==KErrNone); |
|
592 // This setting isn't backed up, so it must still have changed value |
|
593 TEST(str==KStringChangedValue); |
|
594 |
|
595 r = aServerRepo->Get(KBackupReal1, realval); |
|
596 TEST(r==KErrNone); |
|
597 // This setting is backed up, so it must be restored to original |
|
598 TEST(realval==KRealOrigValue); |
|
599 |
|
600 r = aServerRepo->Get(KBackupReal2, realval); |
|
601 TEST(r==KErrNone); |
|
602 // This setting isn't backed up, so it must still have changed value |
|
603 TEST(realval==KRealChangedValue); |
|
604 |
|
605 aServerRepo->Close(); |
|
606 |
|
607 DeleteFilesL(); |
|
608 |
|
609 CleanupStack::PopAndDestroy(aSessionNotif); |
|
610 CleanupStack::PopAndDestroy(aServerRepo); |
|
611 |
|
612 CleanupStack::PopAndDestroy( backupClient ); |
|
613 // Cleanup the scheduler |
|
614 CleanupStack::PopAndDestroy( s ); |
|
615 } |
|
616 |
|
617 |
|
618 // --------------------------------------------------- |
|
619 // OomTest |
|
620 // |
|
621 |
|
622 /** |
|
623 @SYMTestCaseID PDS-CENTRALREPOSITORY-UT-4079 |
|
624 @SYMTestCaseDesc Make the OOM test able to handle "Silent Fail" |
|
625 @SYMTestPriority Medium |
|
626 @SYMTestActions Add a walk around function to handle the "Silent Fail" in OOM test, so that the |
|
627 testing loop won't exit at silent fail ponits. |
|
628 @SYMTestExpectedResults OOM could reach the last iteration needed |
|
629 @SYMDEF DEF130486 |
|
630 */ |
|
631 // This is a walk around to fix the "Silent Fail" in OOM test |
|
632 LOCAL_C TBool TestExit(const TInt& aErr) |
|
633 { |
|
634 #ifdef _DEBUG |
|
635 TEST(aErr == KErrNone || aErr == KErrNoMemory); |
|
636 if (aErr == KErrNone ) |
|
637 { |
|
638 // if the error is KErrNone and it is the exit point of testing loop then the next memory allocation must fail |
|
639 // otherwise this is a silent fail. |
|
640 TAny* const ptr = User::Alloc(1); |
|
641 if (ptr == NULL) |
|
642 return ETrue; |
|
643 User::Free(ptr); |
|
644 } |
|
645 return EFalse; |
|
646 #else |
|
647 // User::__DbgSetAllocFail does not work in release build, this function should always return ETrue. |
|
648 TEST(aErr == KErrNone); |
|
649 return ETrue; |
|
650 #endif |
|
651 } |
|
652 |
|
653 // We don't do full close & initialize because it's time consuming |
|
654 LOCAL_C void ClearServerResources() |
|
655 { |
|
656 TServerResources::iObserver->CloseiOpenRepositories(); |
|
657 TServerResources::iObserver->CloseiRepositoryInfo(); |
|
658 TServerResources::iObserver->Reset(); |
|
659 |
|
660 // To get rid of the array leaking problems during OOM testing. |
|
661 TServerResources::iOwnerIdLookUpTable.Reset(); |
|
662 |
|
663 // change TServerResources::iRomDirectory back |
|
664 if (iniRomDir != TServerResources::iRomDirectory) |
|
665 { |
|
666 delete TServerResources::iRomDirectory; |
|
667 TServerResources::iRomDirectory = iniRomDir; |
|
668 } |
|
669 } |
|
670 |
|
671 // a Wrap Function for OOM |
|
672 LOCAL_C void WrapFunctionL(void (*testFunc)()) |
|
673 { |
|
674 InitializationL(); |
|
675 (testFunc)(); |
|
676 Cleanup(); |
|
677 } |
|
678 |
|
679 // Function to convert a test into an OOM test |
|
680 /** |
|
681 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CT-0117 |
|
682 @SYMTestCaseDesc Test functionality under OOM. |
|
683 @SYMTestPriority High |
|
684 @SYMTestActions Test functionality under OOM. |
|
685 @SYMTestExpectedResults The test must not fail. |
|
686 @SYMPREQ PREQ752 |
|
687 PREQ908 |
|
688 */ |
|
689 LOCAL_C void OomTest(void (*testFunc)()) |
|
690 { |
|
691 oomRunning = ETrue; |
|
692 |
|
693 TInt error; |
|
694 TBool exit = EFalse; |
|
695 TInt count; |
|
696 |
|
697 // Number of continues KErrNone, this is used to control exiting just in case the |
|
698 // TestExit() doesn't catch the exit point and OOM goes to infinate loop. |
|
699 TInt contErrNone = 0; |
|
700 |
|
701 for (count = 1; !exit; count++) |
|
702 { |
|
703 if(count%100 == 1) |
|
704 { |
|
705 TheTest.Printf( _L( "OOM test running at failure rates %d - %d\n" ), count, count + 99); |
|
706 } |
|
707 User::__DbgMarkStart( RHeap::EUser ); |
|
708 |
|
709 // find out the number of open handles |
|
710 TInt startProcessHandleCount; |
|
711 TInt startThreadHandleCount; |
|
712 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
|
713 |
|
714 User::__DbgSetAllocFail( RHeap::EUser, RHeap::EFailNext, count ); |
|
715 |
|
716 TRAP(error, WrapFunctionL(testFunc)); |
|
717 |
|
718 if (error == KErrNone) |
|
719 contErrNone++; |
|
720 else |
|
721 contErrNone = 0; |
|
722 |
|
723 exit = (TestExit(error) || contErrNone >= 15); |
|
724 |
|
725 User::__DbgSetAllocFail( RHeap::EUser, RHeap::ENone, 1 ); |
|
726 |
|
727 // check that no handles have leaked |
|
728 TInt endProcessHandleCount; |
|
729 TInt endThreadHandleCount; |
|
730 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
|
731 |
|
732 TEST(startProcessHandleCount == endProcessHandleCount); |
|
733 TEST(startThreadHandleCount == endThreadHandleCount); |
|
734 |
|
735 ClearServerResources(); |
|
736 |
|
737 User::__DbgMarkEnd( RHeap::EUser, 0 ); |
|
738 } |
|
739 |
|
740 _LIT( KTestFailed, "Out of memory test failure on iteration %d\n" ); |
|
741 __ASSERT_ALWAYS( error == KErrNone, TheTest.Panic( error, KTestFailed, count ) ); |
|
742 |
|
743 TheTest.Printf( _L( "Out of memory tests succeeded at heap failure rate of %i\n" ), count ); |
|
744 TheTest.Printf( _L( "Process handle count preserved\n" ) ); |
|
745 TheTest.Printf( _L( "Thread handle count preserved\n" ) ); |
|
746 |
|
747 oomRunning = EFalse; |
|
748 } |
|
749 |
|
750 /** |
|
751 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-CIT-1388 |
|
752 @SYMTestCaseDesc CenRep backup data is not restored when repository doesn't already exist |
|
753 @SYMTestPriority High |
|
754 @SYMTestActions backup original file, delete files, restore, check if successful |
|
755 @SYMTestExpectedResults The test must not fail. |
|
756 @SYMDEF INC066873 |
|
757 */ |
|
758 LOCAL_C void INC066873L() |
|
759 { |
|
760 NextTest( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CIT-1388 " ) ); |
|
761 // create and install the active scheduler we need |
|
762 CActiveScheduler* s = new(ELeave) CActiveScheduler; |
|
763 |
|
764 TCleanupItem tc(CleanupActiveScheduler, s); |
|
765 CleanupStack::PushL(tc); |
|
766 |
|
767 CActiveScheduler::Replace( s ); |
|
768 |
|
769 backupClient = CRepositoryBackupClient::NewLC(TServerResources::iFs); |
|
770 TEST( backupClient != 0 ); |
|
771 TServerResources::iCacheManager->DisableCache(); |
|
772 |
|
773 // Install known files |
|
774 InstallFileSetL( EOriginals ); |
|
775 // backup known files, |
|
776 BackupRepositoryL( originalData1 ); |
|
777 // delete files |
|
778 DeleteFilesL(); |
|
779 |
|
780 // Create a iRomDirectory pointing to a ROM directory where repositories do not exist |
|
781 _LIT( KEmptyRomDirectory, "Z:\\private\\" ); |
|
782 if (!oomRunning) |
|
783 { |
|
784 delete TServerResources::iRomDirectory ; |
|
785 } |
|
786 TServerResources::iRomDirectory = HBufC::NewL(KEmptyRomDirectory().Length()); |
|
787 TPtr ptr(TServerResources::iRomDirectory->Des()); |
|
788 ptr.Copy(KEmptyRomDirectory); |
|
789 |
|
790 // restore when other files do not exist |
|
791 RestoreRepositoryL( originalData1 ); |
|
792 // read from restored file |
|
793 BackupRepositoryL( originalData2 ); |
|
794 |
|
795 DeleteFilesL(); |
|
796 // Test to see if previously backed up data is correctly restored |
|
797 TEST( StreamsAreIdenticalL( originalData1, originalData2 ) ); |
|
798 |
|
799 CleanupStack::PopAndDestroy( backupClient ); |
|
800 // Cleanup the scheduler |
|
801 CleanupStack::PopAndDestroy( s ); |
|
802 } |
|
803 |
|
804 /** |
|
805 DEF058823: Central Repository client requests are unsafely blocked during Backup & Restore |
|
806 |
|
807 Test checks if a transaction started before BUR process will be failed properly. |
|
808 It also checks if changes made in a transaction before BUR process will be succesfully |
|
809 reverted. |
|
810 |
|
811 Other test for this defect can be found in t_cenrep_defects.cpp |
|
812 */ |
|
813 LOCAL_C void DEF058823L() |
|
814 { |
|
815 TInt err; |
|
816 TInt getValue; |
|
817 TUint32 KInt = 0x1; |
|
818 TUint32 KInt1 = 0x02010100; |
|
819 TUint32 errorId; |
|
820 const TInt KIntValue = 100; |
|
821 const TInt KIntOriginalValue = 1; |
|
822 const TInt KInt1OriginalValue = 10; |
|
823 |
|
824 // create and install the active scheduler we need |
|
825 CActiveScheduler* s = new(ELeave) CActiveScheduler; |
|
826 |
|
827 TCleanupItem tc(CleanupActiveScheduler, s); |
|
828 CleanupStack::PushL(tc); |
|
829 |
|
830 CActiveScheduler::Replace( s ); |
|
831 |
|
832 backupClient = CRepositoryBackupClient::NewLC( TServerResources::iFs ); |
|
833 TEST( backupClient != 0 ); |
|
834 |
|
835 TServerResources::iCacheManager->DisableCache(); |
|
836 |
|
837 // Notifier needed to open repositories. |
|
838 CSessionNotifier* notifier; |
|
839 notifier = new(ELeave)CSessionNotifier; |
|
840 CleanupStack::PushL(notifier); |
|
841 |
|
842 InstallFileSetL(EDEF058823L); |
|
843 //=========================tests during backup process============================ |
|
844 |
|
845 /** |
|
846 |
|
847 Start transaction, set a setting and than perform a backup. |
|
848 Backup process should fail running transaction and discard |
|
849 its changes to the repository. |
|
850 |
|
851 */ |
|
852 |
|
853 CServerRepository* repository = new(ELeave) CServerRepository(); |
|
854 CleanupStack::PushL(repository); |
|
855 repository->OpenL(KUidBackupTestRepository,*notifier); |
|
856 |
|
857 // Begin concurrent read write transaction |
|
858 err = repository->StartTransaction(CRepository::EConcurrentReadWriteTransaction); |
|
859 TEST2(err, KErrNone); |
|
860 |
|
861 //perform write operation before backup process |
|
862 err = repository->TransactionSetL(KInt, KIntValue); |
|
863 if (err == KErrNoMemory) |
|
864 User::Leave(err); |
|
865 TEST2(err, KErrNone); |
|
866 |
|
867 //this will perform backup process |
|
868 BackupRepositoryL(originalData1); |
|
869 |
|
870 //can not commit transaction because it was failed by a backup process |
|
871 err = repository->CommitTransaction(errorId); |
|
872 TEST2(err,KErrLocked); |
|
873 |
|
874 err = repository->TransactionState(); |
|
875 TEST2(err, ENoTransaction); |
|
876 |
|
877 //check if the data was successfully reverted |
|
878 err = repository->Get(KInt, getValue); |
|
879 TEST2(err, KErrNone); |
|
880 TEST(getValue == KIntOriginalValue); |
|
881 |
|
882 /** |
|
883 |
|
884 Start transaction,perform a backup than set a setting. |
|
885 Backup process should fail running transaction and its all |
|
886 consecutive operations. |
|
887 |
|
888 */ |
|
889 |
|
890 // Begin concurrent read write transaction |
|
891 err = repository->StartTransaction(CRepository::EReadWriteTransaction); |
|
892 TEST2(err, KErrNone); |
|
893 |
|
894 //this will perform backup process |
|
895 BackupRepositoryL(originalData1); |
|
896 |
|
897 //backup process has failed current transaction thus the call |
|
898 //to the TransactionSetL would result in a panic. |
|
899 //client side simulation can be found in t_cenrep_defects.cpp |
|
900 err = repository->IsInActiveReadWriteTransaction(); |
|
901 TEST(err==EFalse); |
|
902 |
|
903 //can not commit transaction because it was failed by a backup process |
|
904 err = repository->CommitTransaction(errorId); |
|
905 TEST2(err,KErrLocked); |
|
906 |
|
907 err = repository->TransactionState(); |
|
908 TEST2(err, ENoTransaction); |
|
909 |
|
910 repository->Close(); |
|
911 |
|
912 CleanupStack::PopAndDestroy(repository); |
|
913 CleanupStack::PopAndDestroy(notifier); |
|
914 CleanupStack::PopAndDestroy( backupClient ); |
|
915 CleanupStack::PopAndDestroy( s ); |
|
916 |
|
917 Cleanup(); |
|
918 InitializationL(); |
|
919 // |
|
920 //==============tests during restore process==================================== |
|
921 // |
|
922 InstallFileSetL( EOriginals ); |
|
923 |
|
924 // create and install the active scheduler we need |
|
925 s = new(ELeave) CActiveScheduler; |
|
926 |
|
927 TCleanupItem tc1(CleanupActiveScheduler, s); |
|
928 CleanupStack::PushL(tc1); |
|
929 |
|
930 CActiveScheduler::Replace( s ); |
|
931 |
|
932 backupClient = CRepositoryBackupClient::NewLC( TServerResources::iFs ); |
|
933 TEST( backupClient != 0 ); |
|
934 |
|
935 TServerResources::iCacheManager->DisableCache(); |
|
936 |
|
937 // Notifier needed to open repositories. |
|
938 notifier = new(ELeave)CSessionNotifier; |
|
939 CleanupStack::PushL(notifier); |
|
940 |
|
941 repository = new(ELeave) CServerRepository(); |
|
942 CleanupStack::PushL(repository); |
|
943 repository->OpenL(KUidBackupTestRepository1,*notifier); |
|
944 |
|
945 /** |
|
946 |
|
947 Start transaction, set a setting and than perform a restore. |
|
948 restore process should fail running transaction and discard |
|
949 its changes to the repository. |
|
950 |
|
951 */ |
|
952 |
|
953 //check original value |
|
954 err = repository->Get(KInt1, getValue); |
|
955 TEST2(err, KErrNone); |
|
956 TEST(getValue == KInt1OriginalValue); |
|
957 |
|
958 //backup repository |
|
959 BackupRepositoryL(originalData1); |
|
960 |
|
961 // Begin concurrent read write transaction |
|
962 err = repository->StartTransaction(CRepository::EConcurrentReadWriteTransaction); |
|
963 TEST2(err, KErrNone); |
|
964 |
|
965 //try to perform another write operation before restore process |
|
966 err = repository->TransactionSetL(KInt1, KIntValue); |
|
967 if (err == KErrNoMemory) |
|
968 User::Leave(err); |
|
969 |
|
970 TEST2(err, KErrNone); |
|
971 |
|
972 err = repository->Get(KInt1, getValue); |
|
973 TEST2(err, KErrNone); |
|
974 TEST(getValue == KIntValue); |
|
975 |
|
976 RestoreRepositoryL( originalData1 ); |
|
977 |
|
978 //can not commit transaction because it was failed by a restore process |
|
979 err = repository->CommitTransaction(errorId); |
|
980 TEST2(err,KErrLocked); |
|
981 |
|
982 err = repository->TransactionState(); |
|
983 TEST2(err, ENoTransaction); |
|
984 |
|
985 //check if original value was restored |
|
986 err = repository->Get(KInt1, getValue); |
|
987 TEST2(err, KErrNone); |
|
988 TEST(getValue == KInt1OriginalValue); |
|
989 |
|
990 repository->Close(); |
|
991 CleanupStack::PopAndDestroy(repository); |
|
992 CleanupStack::PopAndDestroy(notifier); |
|
993 CleanupStack::PopAndDestroy( backupClient ); |
|
994 CleanupStack::PopAndDestroy( s ); |
|
995 DeleteFilesL(); |
|
996 } |
|
997 |
|
998 /** |
|
999 @SYMTestCaseID SYSLIB-CENTRALREPOSITORY-UT-3520 |
|
1000 @SYMTestCaseDesc Exercise the unsupported methods that must be implemented for CRepositoryBackupClient |
|
1001 @SYMTestPriority High |
|
1002 @SYMTestActions Call the unsupported methods and check that the appropriate error code is returned. |
|
1003 @SYMTestExpectedResults The test must not fail. |
|
1004 @SYMDEF DEF109469 |
|
1005 */ |
|
1006 LOCAL_C void DEF109469L() |
|
1007 { |
|
1008 NextTest( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-UT-3520 Check unsupported methods " ) ); |
|
1009 |
|
1010 // create and install the active scheduler we need |
|
1011 CActiveScheduler* s = new(ELeave) CActiveScheduler; |
|
1012 |
|
1013 TCleanupItem tc(CleanupActiveScheduler, s); |
|
1014 CleanupStack::PushL(tc); |
|
1015 |
|
1016 CActiveScheduler::Replace( s ); |
|
1017 |
|
1018 backupClient = CRepositoryBackupClient::NewLC( TServerResources::iFs ); |
|
1019 TEST( backupClient != 0 ); |
|
1020 |
|
1021 TDriveNumber drive=EDriveC; // Not required to test unsupported methods, initialised to fix compiler warning |
|
1022 HBufC8* transferBuffer = HBufC8::NewL( 128 ); |
|
1023 CleanupStack::PushL( transferBuffer ); |
|
1024 TPtr8 bufferToSend = transferBuffer->Des(); |
|
1025 TBool finished ; |
|
1026 TUint result; |
|
1027 |
|
1028 result=backupClient->GetDataChecksum(drive); |
|
1029 TEST2(result,KArbitraryNumber); |
|
1030 |
|
1031 result=backupClient->GetExpectedDataSize(drive); |
|
1032 TEST2(result,KArbitraryNumber); |
|
1033 |
|
1034 TRAPD( err, backupClient->GetSnapshotDataL( drive, bufferToSend, finished)); |
|
1035 TEST2(err,KErrNotSupported); |
|
1036 |
|
1037 TRAP( err, backupClient->InitialiseGetBackupDataL(drive)); |
|
1038 TEST2(err,KErrNotSupported); |
|
1039 |
|
1040 TRAP( err, backupClient->InitialiseRestoreBaseDataL(drive)); |
|
1041 TEST2(err,KErrNotSupported); |
|
1042 |
|
1043 TRAP( err, backupClient->InitialiseRestoreIncrementDataL(drive)); |
|
1044 TEST2(err,KErrNotSupported); |
|
1045 |
|
1046 TRAP( err, backupClient->RestoreIncrementDataSectionL(bufferToSend, finished)); |
|
1047 TEST2(err,KErrNotSupported); |
|
1048 |
|
1049 TRAP( err, backupClient->ReceiveSnapshotDataL(drive, bufferToSend, finished)); |
|
1050 TEST2(err,KErrNotSupported); |
|
1051 |
|
1052 //this method does nothing. Call it to exercise it which at least ensures that it doesn't panic |
|
1053 //it shouldn't leave so don't trap it. |
|
1054 backupClient->AllSnapshotsSuppliedL(); |
|
1055 |
|
1056 CleanupStack::PopAndDestroy( transferBuffer ); |
|
1057 CleanupStack::PopAndDestroy( backupClient ); |
|
1058 // Cleanup the scheduler |
|
1059 CleanupStack::PopAndDestroy( s ); |
|
1060 } |
|
1061 |
|
1062 LOCAL_C void DoBackupRestoreTestsL() |
|
1063 { |
|
1064 NextTest( _L( "Backup tests" ) ); |
|
1065 BackupTestsL(); |
|
1066 |
|
1067 NextTest( _L( "Restore tests" ) ); |
|
1068 RestoreTestsL(); |
|
1069 } |
|
1070 |
|
1071 LOCAL_C void DoTestsL() |
|
1072 { |
|
1073 TServerResources::InitialiseL(); |
|
1074 |
|
1075 NextTest( _L( "Do initialization" ) ); |
|
1076 InitializationL(); |
|
1077 |
|
1078 DoBackupRestoreTestsL(); |
|
1079 |
|
1080 NextTest( _L( "DEF058823 tests" ) ); |
|
1081 DEF058823L(); |
|
1082 |
|
1083 NextTest( _L( "INC066873 tests" ) ); |
|
1084 INC066873L(); |
|
1085 |
|
1086 NextTest( _L( "DEF109469: Title Central repository code coverage could be increased" ) ); |
|
1087 DEF109469L(); |
|
1088 |
|
1089 NextTest( _L( "Cleanup" ) ); |
|
1090 Cleanup(); |
|
1091 |
|
1092 TServerResources::Close(); |
|
1093 } |
|
1094 |
|
1095 LOCAL_C void DoOomTestL() |
|
1096 { |
|
1097 NextTest( _L( " @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-CT-0117 " ) ); |
|
1098 |
|
1099 NextTest( _L( " OOM test for backup and restore tests " ) ); |
|
1100 TServerResources::InitialiseL(); |
|
1101 iniRomDir = TServerResources::iRomDirectory; |
|
1102 OomTest(DoBackupRestoreTestsL); |
|
1103 TServerResources::Close(); |
|
1104 |
|
1105 NextTest( _L( " OOM test for DEF058823L " ) ); |
|
1106 TServerResources::InitialiseL(); |
|
1107 iniRomDir = TServerResources::iRomDirectory; |
|
1108 OomTest(DEF058823L); |
|
1109 TServerResources::Close(); |
|
1110 |
|
1111 NextTest( _L( " OOM test for INC066873L " ) ); |
|
1112 TServerResources::InitialiseL(); |
|
1113 iniRomDir = TServerResources::iRomDirectory; |
|
1114 OomTest(INC066873L); |
|
1115 TServerResources::Close(); |
|
1116 |
|
1117 NextTest( _L( " OOM test for DEF109469L " ) ); |
|
1118 TServerResources::InitialiseL(); |
|
1119 iniRomDir = TServerResources::iRomDirectory; |
|
1120 OomTest(DEF109469L); |
|
1121 TServerResources::Close(); |
|
1122 } |
|
1123 |
|
1124 LOCAL_C void MainL() |
|
1125 { |
|
1126 __UHEAP_MARK; |
|
1127 TheTest.Start( _L( "Backup and restore tests" ) ); |
|
1128 |
|
1129 oomRunning = EFalse; |
|
1130 |
|
1131 // create and install the active scheduler we need for the cache manager in TServerResources::InitialiseL |
|
1132 globalAS=new(ELeave) CActiveScheduler; |
|
1133 CleanupStack::PushL(globalAS); |
|
1134 CActiveScheduler::Install(globalAS); |
|
1135 |
|
1136 DoTestsL(); |
|
1137 |
|
1138 // TServerResources is left in an invalid state by previous tests! |
|
1139 NextTest( _L( "Out of memory tests" ) ); |
|
1140 DoOomTestL(); |
|
1141 |
|
1142 CleanupStack::PopAndDestroy(globalAS); |
|
1143 |
|
1144 TheTest.End(); |
|
1145 TheTest.Close(); |
|
1146 __UHEAP_MARKEND; |
|
1147 } |
|
1148 |
|
1149 TInt E32Main() |
|
1150 { |
|
1151 __UHEAP_MARK; |
|
1152 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
1153 if ( !cleanup ) |
|
1154 return KErrNoMemory; |
|
1155 |
|
1156 TRAPD( err, MainL() ); |
|
1157 if ( err != KErrNone ) |
|
1158 User::Panic( _L( "Testing failed: " ), err ); |
|
1159 |
|
1160 delete cleanup; |
|
1161 __UHEAP_MARKEND; |
|
1162 |
|
1163 return 0; |
|
1164 } |
|
1165 |