61 // FindL range data |
68 // FindL range data |
62 const TUint32 KFindPartialKey = 0x08440000ul; |
69 const TUint32 KFindPartialKey = 0x08440000ul; |
63 const TUint32 KFindMask = 0x0FFF0000ul; |
70 const TUint32 KFindMask = 0x0FFF0000ul; |
64 const TInt KFindKeyCount = 15; |
71 const TInt KFindKeyCount = 15; |
65 |
72 |
66 |
|
67 /////////////////////////////////////////////////////////////////////////////////////// |
73 /////////////////////////////////////////////////////////////////////////////////////// |
68 |
74 void DestroyTestEnvL() |
69 TInt DeleteCreFile() |
|
70 { |
|
71 RFs fs; |
|
72 fs.Connect(); |
|
73 TInt err = fs.Delete(KFileName); |
|
74 fs.Close(); |
|
75 |
|
76 // it's fine if the file or path wasn't found as there's nothing to |
|
77 // delete so return KErrNone |
|
78 return (err == KErrNotFound || err == KErrPathNotFound) ? KErrNone : err; |
|
79 } |
|
80 |
|
81 /////////////////////////////////////////////////////////////////////////////////////// |
|
82 |
|
83 void DestroyTestEnv() |
|
84 { |
75 { |
85 delete TheRepository; |
76 delete TheRepository; |
|
77 TheRepository = NULL; |
86 |
78 |
87 // delete the CRE file to clear out any changes made during the test |
79 // delete the CRE file to clear out any changes made during the test |
88 DeleteCreFile(); |
80 CleanupCDriveL(); |
89 } |
81 } |
90 |
82 |
91 /////////////////////////////////////////////////////////////////////////////////////// |
83 /////////////////////////////////////////////////////////////////////////////////////// |
92 |
84 |
93 //Test macros and functions |
85 //Test macros and functions |
94 void Check(TInt aValue, TInt aLine) |
86 void Check(TInt aValue, TInt aLine) |
95 { |
87 { |
96 if(!aValue) |
88 if(!aValue) |
97 { |
89 { |
98 DestroyTestEnv(); |
90 TRAPD(err, DestroyTestEnvL()); |
|
91 if (err != KErrNone) |
|
92 { |
|
93 RDebug::Print( _L( "*** DestroyTestEnvL also failed with error %d expecting KErrNone\r\n"), err ); |
|
94 } |
99 RDebug::Print(_L("*** Test failure. Boolean expression evaluates to false.\r\n")); |
95 RDebug::Print(_L("*** Test failure. Boolean expression evaluates to false.\r\n")); |
100 TheTest(EFalse, aLine); |
96 TheTest(EFalse, aLine); |
101 } |
97 } |
102 } |
98 } |
103 void Check2(TInt aValue, TInt aExpected, TInt aLine) |
99 void Check2(TInt aValue, TInt aExpected, TInt aLine) |
104 { |
100 { |
105 if(aValue != aExpected) |
101 if(aValue != aExpected) |
106 { |
102 { |
107 DestroyTestEnv(); |
103 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
108 RDebug::Print(_L("*** Expected error: %d, got: %d\r\n"), aExpected, aValue); |
104 TRAPD(err, DestroyTestEnvL()); |
|
105 if (err != KErrNone) |
|
106 { |
|
107 RDebug::Print( _L( "*** DestroyTestEnvL also failed with error %d expecting KErrNone\r\n"), err ); |
|
108 } |
109 TheTest(EFalse, aLine); |
109 TheTest(EFalse, aLine); |
110 } |
110 } |
111 } |
111 } |
112 #define TEST(arg) ::Check((arg), __LINE__) |
112 #define TEST(arg) ::Check((arg), __LINE__) |
113 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__) |
113 #define TEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__) |
114 |
114 |
115 /////////////////////////////////////////////////////////////////////////////////////// |
115 /////////////////////////////////////////////////////////////////////////////////////// |
116 |
116 |
117 // leaves if it can't successfully delete the cre file if it exists |
117 // leaves if it can't successfully delete the cre file if it exists |
118 void CreateTestEnvL() |
118 void CreateTestEnvL(const TUid& aRepUid) |
119 { |
119 { |
120 // delete the CRE file to clear out any changes leftover from previous test runs |
120 // delete the CRE file to clear out any changes leftover from previous test runs |
121 User::LeaveIfError(DeleteCreFile()); |
121 CleanupCDriveL(); |
122 |
122 |
123 TRAPD(err, TheRepository = CRepository::NewL(KTestCenRepUid)); |
123 #if defined(SYMBIAN_INCLUDE_APP_CENTRIC) |
|
124 RFs fs; |
|
125 User::LeaveIfError(fs.Connect()); |
|
126 CleanupClosePushL(fs); |
|
127 |
|
128 CFileMan* fm = CFileMan::NewL(fs); |
|
129 CleanupStack::PushL(fm); |
|
130 |
|
131 _LIT(KPMASourcePath, "z:\\private\\10202BE9\\f100031*.pma"); |
|
132 _LIT(KPMATargetPath, "c:\\private\\10202BE9\\persists\\protected\\f100031*.cre"); |
|
133 |
|
134 //Copying test PMA files to PMA drive to simulate there is 16 PMA keyspaces to see if performance degrades |
|
135 CopyTestFilesL(*fm,KPMASourcePath, KPMATargetPath); |
|
136 CleanupStack::PopAndDestroy(2); //fs and fm |
|
137 #endif |
|
138 |
|
139 TRAPD(err, TheRepository = CRepository::NewL(aRepUid)); |
124 TEST2(err, KErrNone); |
140 TEST2(err, KErrNone); |
125 } |
141 } |
126 |
142 |
127 |
143 |
128 //Prints aTicks parameter (converted to us) |
144 //Prints aTicks parameter (converted to us) |
460 |
475 |
461 TUint32 start(0); |
476 TUint32 start(0); |
462 TUint32 end(0); |
477 TUint32 end(0); |
463 |
478 |
464 // Set the new value |
479 // Set the new value |
465 start = aTestType == ESetTest ? User::FastCounter() : start; |
480 start = User::FastCounter(); |
466 err = SetNewVal(aValType); |
481 err = SetNewVal(aValType); |
467 end = aTestType == ESetTest ? User::FastCounter() : end; |
482 end = User::FastCounter(); |
468 TEST2(err, KErrNone); |
483 TEST2(err, KErrNone); |
469 |
484 |
470 // Test we get the new value to check it's worked |
485 // Test we get the new value to check it's worked |
471 err = GetNewVal(aValType, ESetTest, result); |
486 err = GetNewVal(aValType, ESetTest, result); |
472 TEST2(err, KErrNone); |
487 TEST2(err, KErrNone); |
473 TEST(result); |
488 TEST(result); |
474 |
489 |
475 // Restore the old value |
|
476 start = aTestType == EResetTest ? User::FastCounter() : start; |
|
477 err = ResetSetting(aValType); |
|
478 end = aTestType == EResetTest ? User::FastCounter() : end; |
|
479 TEST2(err, KErrNone); |
|
480 |
|
481 // Check reset's worked |
|
482 err = GetOldVal(aValType, result); |
|
483 TEST2(err, KErrNone); |
|
484 TEST(result); |
|
485 |
490 |
486 PrintStats(start, end); |
491 PrintStats(start, end); |
487 } |
492 } |
488 |
493 |
|
494 /** |
|
495 * Common code for performing the Reset() tests |
|
496 * |
|
497 * @param aValType enum indicating which data type to test |
|
498 * (EIntVal, ERealVal, EBinaryVal or EStringVal -- any other value will fail with KErrArgument). |
|
499 * @param aExpectedResult indicating the expected return value of Reset |
|
500 * (Any valid Symbian OS error codes) |
|
501 */ |
|
502 void DoResetTest(TValType aValType, TInt aExpectedResult) |
|
503 { |
|
504 TInt err(KErrNone); |
|
505 TInt result(EFalse); |
|
506 TUint32 start(0); |
|
507 TUint32 end(0); |
|
508 |
|
509 // Set the new value |
|
510 err = SetNewVal(aValType); |
|
511 TEST2(err, KErrNone); |
|
512 |
|
513 // Test we get the new value to check it's worked |
|
514 err = GetNewVal(aValType, ESetTest, result); |
|
515 TEST2(err, KErrNone); |
|
516 TEST(result); |
|
517 |
|
518 // Restore the old value |
|
519 start = User::FastCounter(); |
|
520 err = ResetSetting(aValType); |
|
521 end = User::FastCounter(); |
|
522 TEST2(err, aExpectedResult); |
|
523 |
|
524 // Check reset's worked |
|
525 if (aExpectedResult == KErrNone) |
|
526 { |
|
527 err = GetOldVal(aValType, result); |
|
528 TEST2(err, KErrNone); |
|
529 TEST(result); |
|
530 } |
|
531 // If aExpectedResult is not KErrNone, Reset should have failed |
|
532 // The value should be still be the modified value (not reverted back to old value) |
|
533 else |
|
534 { |
|
535 err = GetNewVal(aValType, ESetTest, result); |
|
536 TEST2(err, KErrNone); |
|
537 TEST(result); |
|
538 } |
|
539 |
|
540 PrintStats(start, end); |
|
541 } |
489 |
542 |
490 /** |
543 /** |
491 * Common code for performing all the Create() tests |
544 * Common code for performing all the Create() tests |
492 * |
545 * |
493 * @param aValType enum indicating which data type to test |
546 * @param aValType enum indicating which data type to test |
1193 err = GetNewVal(EBinaryVal, ECreateTest, result); |
1246 err = GetNewVal(EBinaryVal, ECreateTest, result); |
1194 TEST2(err, KErrNotFound); |
1247 TEST2(err, KErrNotFound); |
1195 PrintStats(start, end); |
1248 PrintStats(start, end); |
1196 } |
1249 } |
1197 |
1250 |
|
1251 |
|
1252 /** |
|
1253 @SYMTestCaseID PDS-CENTRALREPOSITORY-CT-4129 |
|
1254 @SYMTestCaseDesc CRepository::Reset(TUint32 aKey) - performance test |
|
1255 The test measures the time needed for resetting a single PMA integer setting. |
|
1256 @SYMTestPriority High |
|
1257 @SYMTestActions CRepository::Reset(TUint32 aKey) |
|
1258 @SYMTestExpectedResults Test must not fail |
|
1259 @SYMPREQ PREQ2505 |
|
1260 @SYMREQ REQ13142 |
|
1261 */ |
|
1262 void PMAResetTest() |
|
1263 { |
|
1264 DoResetTest(EIntVal, KErrNotSupported); |
|
1265 } |
|
1266 |
|
1267 |
|
1268 /** |
|
1269 @SYMTestCaseID PDS-CENTRALREPOSITORY-CT-4130 |
|
1270 @SYMTestCaseDesc CRepository::Reset() - performance test |
|
1271 The test measures the time needed for resetting the whole PMA keyspace. |
|
1272 @SYMTestPriority High |
|
1273 @SYMTestActions CRepository::Reset() |
|
1274 @SYMTestExpectedResults Test must not fail |
|
1275 @SYMPREQ PREQ2505 |
|
1276 @SYMREQ REQ13142 |
|
1277 */ |
|
1278 void PMAResetAllTest() |
|
1279 { |
|
1280 // Reset the whole keyspace |
|
1281 TInt start = User::FastCounter(); |
|
1282 TInt err = TheRepository->Reset(); |
|
1283 TInt end = User::FastCounter(); |
|
1284 TEST2(err, KErrNotSupported); |
|
1285 PrintStats(start, end); |
|
1286 } |
|
1287 |
1198 /////////////////////////////////////////////////////////////////////////////////////// |
1288 /////////////////////////////////////////////////////////////////////////////////////// |
1199 |
1289 |
1200 // MAIN |
1290 // MAIN |
1201 |
1291 |
1202 void DoTestsL() |
1292 void DoTestsL() |
1203 { |
1293 { |
1204 TheTest.Start(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4047 Get Int test")); |
1294 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-UT-4047 Get Int test")); |
1205 GetIntTest(); |
1295 GetIntTest(); |
1206 |
1296 |
1207 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4087 Get Real test")); |
1297 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4087 Get Real test")); |
1208 GetRealTest(); |
1298 GetRealTest(); |
1209 |
1299 |
1279 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4109 Delete test")); |
1369 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4109 Delete test")); |
1280 DeleteTest(); |
1370 DeleteTest(); |
1281 |
1371 |
1282 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4110 Delete test")); |
1372 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4110 Delete test")); |
1283 DeleteRangeTestL(); |
1373 DeleteRangeTestL(); |
1284 |
1374 |
1285 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4111 Reset Single test")); |
1375 } |
1286 ResetTest(); |
1376 |
1287 |
1377 void DoResetTests() |
1288 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4112 Reset All test")); |
1378 { |
1289 ResetAllTest(); |
1379 |
1290 } |
1380 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4111 Reset Single test")); |
|
1381 ResetTest(); |
|
1382 |
|
1383 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4112 Reset All test")); |
|
1384 ResetAllTest(); |
|
1385 } |
|
1386 |
|
1387 void DoPMAResetTests() |
|
1388 { |
|
1389 |
|
1390 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4129 Reset Single test")); |
|
1391 PMAResetTest(); |
|
1392 |
|
1393 TheTest.Next(_L("@SYMTestCaseID:PDS-CENTRALREPOSITORY-CT-4130 Reset All test")); |
|
1394 PMAResetAllTest(); |
|
1395 } |
|
1396 |
|
1397 LOCAL_C void MainL() |
|
1398 { |
|
1399 //Non-PMA test |
|
1400 CreateTestEnvL(KTestCenRepUid); |
|
1401 |
|
1402 DoTestsL(); |
|
1403 DoResetTests(); |
|
1404 |
|
1405 #if defined(SYMBIAN_INCLUDE_APP_CENTRIC) |
|
1406 DestroyTestEnvL(); |
|
1407 CreateTestEnvL(KPMATestCenRepUid); |
|
1408 DoTestsL(); |
|
1409 DoPMAResetTests(); |
|
1410 #endif |
|
1411 DestroyTestEnvL(); |
|
1412 } |
1291 |
1413 |
1292 |
1414 |
1293 TInt E32Main() |
1415 TInt E32Main() |
1294 { |
1416 { |
1295 TheTest.Title(); |
1417 TheTest.Title (); |
1296 |
1418 TheTest.Start(_L("Centrep Performance Test")); |
1297 CTrapCleanup* tc = CTrapCleanup::New(); |
1419 |
1298 TheTest(tc != NULL); |
1420 CTrapCleanup* cleanup = CTrapCleanup::New(); |
1299 |
1421 TheTest(cleanup != NULL); |
1300 __UHEAP_MARK; |
1422 |
1301 |
1423 __UHEAP_MARK; |
1302 TRAPD(err, CreateTestEnvL()); |
1424 |
1303 TEST2(err, KErrNone); |
1425 KillProcess(KCentralRepositoryServerName); |
1304 |
1426 TRAPD(err, MainL()); |
1305 TRAP(err, DoTestsL()); |
1427 KillProcess(KCentralRepositoryServerName); |
1306 DestroyTestEnv(); |
1428 TEST2(err, KErrNone); |
1307 TEST2(err, KErrNone); |
1429 |
1308 |
1430 |
1309 __UHEAP_MARKEND; |
1431 __UHEAP_MARKEND; |
1310 |
1432 |
1311 TheTest.End(); |
1433 TheTest.End (); |
1312 TheTest.Close(); |
1434 TheTest.Close (); |
1313 |
1435 |
1314 delete tc; |
1436 delete cleanup; |
1315 |
1437 |
1316 User::Heap().Check(); |
1438 User::Heap().Check(); |
1317 return KErrNone; |
1439 return KErrNone; |
1318 } |
1440 } |