1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of "Eclipse Public License v1.0" |
4 // under the terms of "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
27 #include "clientrequest.h" |
26 #include "clientrequest.h" |
28 #include "install.h" |
27 #include "install.h" |
29 #include <bautils.h> |
28 #include <bautils.h> |
30 |
29 |
31 LOCAL_D RFs TheFs; |
30 LOCAL_D RFs TheFs; |
32 LOCAL_D RTest TheTest (_L ("t_oomcenrep.exe")); |
31 LOCAL_D RTest TheTest (_L ("t_oomcenrepsrv.exe")); |
33 |
32 |
34 #ifdef __SECURE_DATA__ |
33 #ifdef __SECURE_DATA__ |
35 _LIT(KInstallDirFile, "c:\\private\\10202BE9\\persists\\installdir.bin"); |
34 _LIT(KInstallDirFile, "c:\\private\\10202BE9\\persists\\installdir.bin"); |
36 |
35 |
37 _LIT(KPersistsFile, "c:\\private\\10202BE9\\persists\\11111111.cre"); |
36 _LIT(KPersistsFile, "c:\\private\\10202BE9\\persists\\11111111.cre"); |
41 |
40 |
42 _LIT(KRomUpgradeRev1File, "z:\\private\\10202BE9\\11111111.txu"); |
41 _LIT(KRomUpgradeRev1File, "z:\\private\\10202BE9\\11111111.txu"); |
43 _LIT(KRomUpgradeRev2File, "z:\\private\\10202BE9\\11111112.txu"); |
42 _LIT(KRomUpgradeRev2File, "z:\\private\\10202BE9\\11111112.txu"); |
44 _LIT(KUpgradeFile, "c:\\private\\10202BE9\\11111111.txt"); |
43 _LIT(KUpgradeFile, "c:\\private\\10202BE9\\11111111.txt"); |
45 |
44 |
|
45 _LIT(KRomUpgradeFile2, "z:\\private\\10202BE9\\11111113.txi"); |
|
46 _LIT(KUpgradeFile2, "c:\\private\\10202BE9\\11111113.txt"); |
|
47 _LIT(KPersistedUpgradeFile2, "c:\\private\\10202BE9\\persists\\11111113.cre"); |
|
48 |
46 _LIT(KInstallOnlyFile, "z:\\private\\10202BE9\\11111110.cri"); |
49 _LIT(KInstallOnlyFile, "z:\\private\\10202BE9\\11111110.cri"); |
47 _LIT(KInstallOnlyUpgradeFile, "z:\\private\\10202BE9\\11111110.cru"); |
50 _LIT(KInstallOnlyUpgradeFile, "z:\\private\\10202BE9\\11111110.cru"); |
48 _LIT(KInstallFile, "c:\\private\\10202BE9\\11111110.cre"); |
51 _LIT(KInstallFile, "c:\\private\\10202BE9\\11111110.cre"); |
49 |
52 |
50 #else |
53 #else |
55 //Test repositories Uid |
58 //Test repositories Uid |
56 const TUid KTestRepositoryUid={0x11111111}; |
59 const TUid KTestRepositoryUid={0x11111111}; |
57 const TUid KCorruptRepositoryUid={0xBADBADBB}; |
60 const TUid KCorruptRepositoryUid={0xBADBADBB}; |
58 |
61 |
59 static TUid KCurrentTestUid; |
62 static TUid KCurrentTestUid; |
|
63 |
|
64 //Burst rate for __UHEAP_SETBURSTFAIL |
|
65 #ifdef _DEBUG |
|
66 const TInt KBurstRate = 20; |
|
67 #endif |
60 |
68 |
61 /////////////////////////////////////////////////////////////////////////////////////// |
69 /////////////////////////////////////////////////////////////////////////////////////// |
62 //Test macroses and functions |
70 //Test macroses and functions |
63 LOCAL_C void CheckL(TInt aValue, TInt aLine) |
71 LOCAL_C void CheckL(TInt aValue, TInt aLine) |
64 { |
72 { |
884 // Clean out files |
892 // Clean out files |
885 TInt err=fs.Delete(KInstallDirFile); |
893 TInt err=fs.Delete(KInstallDirFile); |
886 if((err!=KErrNone)&&(err!=KErrNotFound)) |
894 if((err!=KErrNone)&&(err!=KErrNotFound)) |
887 User::Leave(err); |
895 User::Leave(err); |
888 |
896 |
889 // Cause directory listing with no files to be written |
|
890 CCentRepSWIWatcher* swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs); |
|
891 delete swiWatcher; |
|
892 |
|
893 User::LeaveIfError(fm->Copy(KPersistsFileNoUpgrade, KPersistsFile)); |
897 User::LeaveIfError(fm->Copy(KPersistsFileNoUpgrade, KPersistsFile)); |
894 User::LeaveIfError(fm->Attribs(KPersistsFile,0,KEntryAttReadOnly,TTime(0))); |
898 User::LeaveIfError(fm->Attribs(KPersistsFile,0,KEntryAttReadOnly,TTime(0))); |
895 |
899 |
896 User::LeaveIfError(fm->Copy(KRomUpgradeRev1File, KUpgradeFile)); |
900 User::LeaveIfError(fm->Copy(KRomUpgradeRev1File, KUpgradeFile)); |
897 User::LeaveIfError(fm->Attribs(KUpgradeFile,0,KEntryAttReadOnly,TTime(0))); |
901 User::LeaveIfError(fm->Attribs(KUpgradeFile,0,KEntryAttReadOnly,TTime(0))); |
898 |
902 |
899 CleanupStack::PopAndDestroy(2); // fs and fm |
903 User::LeaveIfError(fm->Copy(KRomUpgradeFile2, KUpgradeFile2)); |
|
904 User::LeaveIfError(fm->Attribs(KUpgradeFile2,0,KEntryAttReadOnly,TTime(0))); |
|
905 |
|
906 CleanupStack::PopAndDestroy(2, &fs); //fm and fs |
900 } |
907 } |
901 else |
908 else |
902 { |
909 { |
903 CCentRepSWIWatcher* swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs); |
910 CCentRepSWIWatcher* swiWatcher = CCentRepSWIWatcher::NewL(TServerResources::iFs); |
904 delete swiWatcher; |
911 delete swiWatcher; |
993 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
1000 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
994 |
1001 |
995 (*atestFuncL)(ETrue); |
1002 (*atestFuncL)(ETrue); |
996 |
1003 |
997 if (aOOMMode) |
1004 if (aOOMMode) |
998 __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); |
1005 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, ++tryCount, KBurstRate); |
999 |
1006 |
1000 TRAP(err, (*atestFuncL)(EFalse)); |
1007 TRAP(err, (*atestFuncL)(EFalse)); |
1001 if (err!=KErrNoMemory) |
1008 if (err!=KErrNoMemory) |
1002 TESTKErrNoneL(err); |
1009 TESTKErrNoneL(err); |
1003 |
1010 |
1004 if (aOOMMode) |
1011 if (aOOMMode) |
1005 __UHEAP_SETFAIL(RHeap::ENone, 0); |
1012 __UHEAP_RESET; |
1006 |
1013 |
1007 // check that no handles have leaked |
1014 // check that no handles have leaked |
1008 TInt endProcessHandleCount; |
1015 TInt endProcessHandleCount; |
1009 TInt endThreadHandleCount; |
1016 TInt endThreadHandleCount; |
1010 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
1017 RThread().HandleCount(endProcessHandleCount, endThreadHandleCount); |
1053 TInt startProcessHandleCount; |
1060 TInt startProcessHandleCount; |
1054 TInt startThreadHandleCount; |
1061 TInt startThreadHandleCount; |
1055 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
1062 RThread().HandleCount(startProcessHandleCount, startThreadHandleCount); |
1056 |
1063 |
1057 if (aOOMMode) |
1064 if (aOOMMode) |
1058 __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); |
1065 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, ++tryCount, KBurstRate); |
1059 |
1066 |
1060 TRAP(err, (theTest->*testFuncL)()); |
1067 TRAP(err, (theTest->*testFuncL)()); |
1061 |
1068 |
1062 if (aOOMMode) |
1069 if (aOOMMode) |
1063 __UHEAP_SETFAIL(RHeap::ENone, 0); |
1070 __UHEAP_RESET; |
1064 |
1071 |
1065 if (err!=KErrNoMemory) |
1072 if (err!=KErrNoMemory) |
1066 TESTKErrNoneL(err); |
1073 TESTKErrNoneL(err); |
1067 |
1074 |
1068 CleanupStack::PopAndDestroy(theTest); |
1075 CleanupStack::PopAndDestroy(theTest); |
1118 |
1125 |
1119 // Set up test |
1126 // Set up test |
1120 (theTest->*aTestFuncL)(ETrue); |
1127 (theTest->*aTestFuncL)(ETrue); |
1121 |
1128 |
1122 if (aOOMMode) |
1129 if (aOOMMode) |
1123 __UHEAP_SETFAIL(RHeap::EDeterministic, ++tryCount); |
1130 __UHEAP_SETBURSTFAIL(RAllocator::EBurstFailNext, ++tryCount, KBurstRate); |
1124 |
1131 |
1125 TRAP(err, (theTest->*aTestFuncL)(EFalse)); |
1132 TRAP(err, (theTest->*aTestFuncL)(EFalse)); |
1126 |
1133 |
1127 if (aOOMMode) |
1134 if (aOOMMode) |
1128 __UHEAP_SETFAIL(RHeap::ENone, 0); |
1135 __UHEAP_RESET; |
1129 |
1136 |
1130 if (err!=KErrNoMemory) |
1137 if (err!=KErrNoMemory) |
1131 TESTKErrNoneL(err); |
1138 TESTKErrNoneL(err); |
1132 |
1139 |
1133 CleanupStack::PopAndDestroy(theTest); |
1140 CleanupStack::PopAndDestroy(theTest); |
1273 //now check the version of the CRE file |
1280 //now check the version of the CRE file |
1274 CHeapRepository* heap=CHeapRepository::NewL(KTestUid); |
1281 CHeapRepository* heap=CHeapRepository::NewL(KTestUid); |
1275 CleanupStack::PushL(heap); |
1282 CleanupStack::PushL(heap); |
1276 TUint8 creVersion; |
1283 TUint8 creVersion; |
1277 heap->CreateRepositoryFromCreFileL(TServerResources::iFs,_L("c:\\private\\10202be9\\persists\\88880000.cre"),creVersion); |
1284 heap->CreateRepositoryFromCreFileL(TServerResources::iFs,_L("c:\\private\\10202be9\\persists\\88880000.cre"),creVersion); |
|
1285 #ifdef SYMBIAN_INCLUDE_APP_CENTRIC |
|
1286 TESTL(creVersion==KPersistFormatSupportsPma); |
|
1287 #else |
1278 TESTL(creVersion==KPersistFormatSupportsIndMetaIndicator); |
1288 TESTL(creVersion==KPersistFormatSupportsIndMetaIndicator); |
1279 |
1289 #endif |
1280 CleanupStack::PopAndDestroy(2,test); |
1290 CleanupStack::PopAndDestroy(2,test); |
1281 TServerResources::Close(); |
1291 TServerResources::Close(); |
1282 } |
1292 } |
1283 /** |
1293 /** |
1284 @SYMTestCaseID PDS-CENTRALREPOSITORY-UT-4051 |
1294 @SYMTestCaseID PDS-CENTRALREPOSITORY-UT-4051 |
1319 |
1329 |
1320 LOCAL_C void DoOOMTestsL() |
1330 LOCAL_C void DoOOMTestsL() |
1321 { |
1331 { |
1322 TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-LEGACY-T_OOMCENREP-0001 Starting CENREPSRV OOM Test ")); |
1332 TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-CENTRALREPOSITORY-LEGACY-T_OOMCENREP-0001 Starting CENREPSRV OOM Test ")); |
1323 RFs fs; |
1333 RFs fs; |
|
1334 TEntry entry; |
|
1335 TInt err; |
1324 User::LeaveIfError(fs.Connect()); |
1336 User::LeaveIfError(fs.Connect()); |
1325 CleanupClosePushL(fs); |
1337 CleanupClosePushL(fs); |
1326 CFileMan* fm = CFileMan::NewL(fs); |
1338 CFileMan* fm = CFileMan::NewL(fs); |
1327 CleanupStack::PushL(fm); |
1339 CleanupStack::PushL(fm); |
1328 |
1340 |
1358 DoOOMSwiTestL(&CenrepSwiOOMTest::UpgradeInstallL,_L("SwiUpgradeInstallL Basic Test"),EFalse); |
1370 DoOOMSwiTestL(&CenrepSwiOOMTest::UpgradeInstallL,_L("SwiUpgradeInstallL Basic Test"),EFalse); |
1359 DoOOMSwiTestL(&CenrepSwiOOMTest::UninstallL,_L("SwiUninstallL Basic Test"),EFalse); |
1371 DoOOMSwiTestL(&CenrepSwiOOMTest::UninstallL,_L("SwiUninstallL Basic Test"),EFalse); |
1360 |
1372 |
1361 // Simulate SWI events before server startup |
1373 // Simulate SWI events before server startup |
1362 DoOOMNoServReposL(&StartupUpgradeL, _L("Startup Upgrade Basic Test"), EFalse); |
1374 DoOOMNoServReposL(&StartupUpgradeL, _L("Startup Upgrade Basic Test"), EFalse); |
1363 DoOOMNoServReposL(&StartupDowngradeL, _L("Startup Downgrade Basic Test"), EFalse); |
1375 err = fs.Entry(KPersistedUpgradeFile2, entry); |
|
1376 TEST2L(err, KErrNone); // the installed keyspace (11111113.txt) should be persisted on start up. |
|
1377 |
|
1378 DoOOMNoServReposL(&StartupDowngradeL, _L("Startup Downgrade Basic Test"), EFalse); |
1364 DoOOMNoServReposL(&StartupUninstallL,_L("Startup Uninstall Basic Test"), EFalse); |
1379 DoOOMNoServReposL(&StartupUninstallL,_L("Startup Uninstall Basic Test"), EFalse); |
1365 |
1380 |
1366 //OOM Test aOOMMode=ETrue |
1381 //OOM Test aOOMMode=ETrue |
1367 DoOOMNoServReposL(&CreateDeleteL, _L("Create Delete OOM Test"),ETrue); |
1382 DoOOMNoServReposL(&CreateDeleteL, _L("Create Delete OOM Test"),ETrue); |
1368 DoOOMNoServReposL(&CreateDeleteCorruptL, _L("Create Delete Corrupt OOM Test"),ETrue); |
1383 DoOOMNoServReposL(&CreateDeleteCorruptL, _L("Create Delete Corrupt OOM Test"),ETrue); |
1395 DoOOMMultiRofsTestL(); |
1410 DoOOMMultiRofsTestL(); |
1396 #endif |
1411 #endif |
1397 |
1412 |
1398 // Delete files from bur dir |
1413 // Delete files from bur dir |
1399 User::LeaveIfError(fm->Attribs(KPersistsFileNoUpgrade,0,KEntryAttReadOnly,TTime(0))); |
1414 User::LeaveIfError(fm->Attribs(KPersistsFileNoUpgrade,0,KEntryAttReadOnly,TTime(0))); |
1400 TInt err=fs.Delete(KPersistsFileNoUpgrade); |
1415 err=fs.Delete(KPersistsFileNoUpgrade); |
1401 if((err!=KErrNone)&&(err!=KErrNotFound)) |
1416 if((err!=KErrNone)&&(err!=KErrNotFound)) |
1402 User::Leave(err); |
1417 User::Leave(err); |
1403 |
1418 |
1404 User::LeaveIfError(fm->Attribs(KPersistsFileUpgraded,0,KEntryAttReadOnly,TTime(0))); |
1419 User::LeaveIfError(fm->Attribs(KPersistsFileUpgraded,0,KEntryAttReadOnly,TTime(0))); |
1405 err=fs.Delete(KPersistsFileUpgraded); |
1420 err=fs.Delete(KPersistsFileUpgraded); |