|
1 /* |
|
2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @test |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #include <test/testexecutelog.h> |
|
26 |
|
27 #include "sessionstep.h" |
|
28 #include "sisregistrysession.h" |
|
29 #include "sisregistryentry.h" |
|
30 #include "sisregistrypackage.h" |
|
31 #include "installtypes.h" |
|
32 #include "cleanuputils.h" |
|
33 #include "hashcontainer.h" |
|
34 #include "testutilclientswi.h" |
|
35 #include "arrayutils.h" |
|
36 #include "sisregistrytoken.h" |
|
37 #include "sisregistrylog.h" |
|
38 #include <s32file.h> |
|
39 |
|
40 |
|
41 ///////////////////////////////////////////////////////////////////// |
|
42 // defs, Constants used by test steps |
|
43 ///////////////////////////////////////////////////////////////////// |
|
44 |
|
45 _LIT(KNoUid, "nouid"); |
|
46 _LIT(KUid, "uid"); |
|
47 _LIT(KDrivebitmapcount, "drivebitmapcout"); |
|
48 _LIT(KSid, "sid"); |
|
49 _LIT(KPackage, "package"); |
|
50 _LIT(KVendor, "vendor"); |
|
51 _LIT(KController, "ctl"); |
|
52 _LIT(KKeyFormat, "-%02d"); |
|
53 _LIT(KSidFileNameSec, "file"); |
|
54 _LIT(KModFileName, "file"); |
|
55 _LIT(KModTag, "modtag"); |
|
56 _LIT(KHashFileName, "file"); |
|
57 _LIT(KHashFileValue, "hashvalue"); |
|
58 _LIT(KRootCertTag, "rootcert"); |
|
59 _LIT(KResultTag, "expectedresult"); |
|
60 _LIT(KDateTime, "datetime"); //YYYYMMDD:HHMMSS.MMMMMM |
|
61 _LIT(KPkgCount, "embeddingpkgcount"); |
|
62 _LIT(KLanguage, "language"); |
|
63 |
|
64 _LIT(KSisRegistryPath, "\\sys\\install\\sisregistry\\"); |
|
65 _LIT(KCacheBackupFile, "\\sys\\install\\sisregistry\\backup.lst"); |
|
66 _LIT(KCorruptCacheBackupFile, "z:\\tswi\\tsisregistrytest\\data\\hashforlang_txt.dat"); |
|
67 _LIT(KSysBackupFileBackup, "\\sys\\install\\sisregistry\\backup.bak"); |
|
68 |
|
69 ///////////////////////////////////////////////////////////////////// |
|
70 // Tags used by test steps |
|
71 ///////////////////////////////////////////////////////////////////// |
|
72 using namespace Swi; |
|
73 |
|
74 ///////////////////////////////////////////////////////////////////// |
|
75 // CSisRegistryStep |
|
76 ///////////////////////////////////////////////////////////////////// |
|
77 TVerdict CSisRegistrySessionStep::doTestStepPreambleL() |
|
78 { |
|
79 __UHEAP_MARK; |
|
80 |
|
81 // Install an active scheduler |
|
82 CActiveScheduler* s = new (ELeave) CActiveScheduler; |
|
83 s->Install(s); |
|
84 |
|
85 INFO_PRINTF1(_L("Connecting to SisRegistry..")); |
|
86 User::LeaveIfError(iSisRegistry.Connect()); |
|
87 INFO_PRINTF1(_L("Connected!")); |
|
88 |
|
89 return TestStepResult(); |
|
90 } |
|
91 |
|
92 TVerdict CSisRegistrySessionStep::doTestStepPostambleL() |
|
93 { |
|
94 // Remove the installed active scheduler |
|
95 CActiveScheduler* s = CActiveScheduler::Current(); |
|
96 s->Install(NULL); |
|
97 delete s; |
|
98 |
|
99 iSisRegistry.Close(); |
|
100 |
|
101 __UHEAP_MARKEND; |
|
102 |
|
103 return TestStepResult(); |
|
104 } |
|
105 ///////////////////////////////////////////////////////////////////// |
|
106 // CEmbeddingPackageStep - Checks the embedding packages for a given package |
|
107 ///////////////////////////////////////////////////////////////////// |
|
108 CEmbeddingPackageStep::CEmbeddingPackageStep() |
|
109 { |
|
110 SetTestStepName(KEmbeddingPackageStep); |
|
111 } |
|
112 |
|
113 TVerdict CEmbeddingPackageStep::doTestStepL() |
|
114 { |
|
115 RSisRegistryEntry entry; |
|
116 RPointerArray<Swi::CSisRegistryPackage> packages; |
|
117 SetTestStepResult(EPass); |
|
118 |
|
119 TUid uidOpen; |
|
120 TInt embeddingPkgCount; |
|
121 if(!GetUidFromConfig(ConfigSection(), KUid, uidOpen) || !GetIntFromConfig(ConfigSection(), KPkgCount, embeddingPkgCount)) |
|
122 { |
|
123 ERR_PRINTF1(_L("Missing package Uid or expected package count")); |
|
124 SetTestStepResult(EFail); |
|
125 return TestStepResult(); |
|
126 } |
|
127 |
|
128 if (KErrNone != entry.Open(iSisRegistry, uidOpen)) |
|
129 { |
|
130 SetTestStepResult(EFail); |
|
131 return TestStepResult(); |
|
132 } |
|
133 CleanupClosePushL(entry); |
|
134 |
|
135 entry.EmbeddingPackagesL(packages); |
|
136 CleanupResetAndDestroyPushL(packages); |
|
137 |
|
138 |
|
139 if(packages.Count() != embeddingPkgCount) |
|
140 { |
|
141 ERR_PRINTF3(_L("The actual number of embedding packages does not meet expected. Expected: %d Actual: %d"), embeddingPkgCount, packages.Count()); |
|
142 SetTestStepResult(EFail); |
|
143 } |
|
144 CleanupStack::PopAndDestroy(2, &entry); |
|
145 return TestStepResult(); |
|
146 } |
|
147 |
|
148 ///////////////////////////////////////////////////////////////////// |
|
149 // CSidFileStep - Checks the filename to sid mapping |
|
150 ///////////////////////////////////////////////////////////////////// |
|
151 CSidFileStep::CSidFileStep() |
|
152 { |
|
153 SetTestStepName(KSidFileName); |
|
154 } |
|
155 |
|
156 TVerdict CSidFileStep::doTestStepL() |
|
157 { |
|
158 RArray<TUid> theSids; |
|
159 CleanupClosePushL(theSids); |
|
160 GetUidArrayFromConfigL(ConfigSection(), KSid, theSids); |
|
161 |
|
162 //RArray<TUid> thePackageUids; |
|
163 //CleanupClosePushL(thePackageUids); |
|
164 //GetUidArrayFromConfigL(ConfigSection(), KUid, thePackageUids); |
|
165 |
|
166 RArray<TPtrC> expectedSidNames; |
|
167 CleanupClosePushL(expectedSidNames); |
|
168 GetStringArrayFromConfigL(ConfigSection(), KSidFileNameSec, expectedSidNames); |
|
169 |
|
170 SetTestStepResult(EPass); |
|
171 |
|
172 if (theSids.Count() != expectedSidNames.Count()) |
|
173 { |
|
174 User::LeaveIfError(KErrCorrupt); |
|
175 } |
|
176 |
|
177 TBuf<KMaxFileName> fileName; |
|
178 |
|
179 for (TInt sidCount(0); sidCount<theSids.Count(); sidCount++) |
|
180 { |
|
181 iSisRegistry.SidToFileNameL(theSids[sidCount],fileName); |
|
182 if (expectedSidNames[sidCount].Compare(fileName) != 0) |
|
183 { |
|
184 SetTestStepResult(EFail); |
|
185 break; |
|
186 } |
|
187 } |
|
188 |
|
189 CleanupStack::PopAndDestroy(&expectedSidNames); |
|
190 //CleanupStack::PopAndDestroy(&thePackageUids); |
|
191 CleanupStack::PopAndDestroy(&theSids); |
|
192 return TestStepResult(); |
|
193 } |
|
194 |
|
195 //////////////////////////////////////////////////////////////////////// |
|
196 // CModifiableFileStep - Checks whether the file is tagged as modifiable |
|
197 //////////////////////////////////////////////////////////////////////// |
|
198 CModifiableFileStep::CModifiableFileStep() |
|
199 { |
|
200 SetTestStepName(KModifiableFile); |
|
201 } |
|
202 |
|
203 TVerdict CModifiableFileStep::doTestStepL() |
|
204 { |
|
205 RArray<TPtrC> theFileNames; |
|
206 CleanupClosePushL(theFileNames); |
|
207 GetStringArrayFromConfigL(ConfigSection(), KModFileName, theFileNames); |
|
208 |
|
209 RArray<TInt> expectedModifiableTags; |
|
210 CleanupClosePushL(expectedModifiableTags); |
|
211 GetIntArrayFromConfigL(ConfigSection(), KModTag, expectedModifiableTags); |
|
212 |
|
213 SetTestStepResult(EPass); |
|
214 |
|
215 if (theFileNames.Count() != expectedModifiableTags.Count()) |
|
216 { |
|
217 User::LeaveIfError(KErrCorrupt); |
|
218 } |
|
219 |
|
220 TInt numModFiles = theFileNames.Count(); |
|
221 |
|
222 for (TInt i=0; i<numModFiles; i++) |
|
223 { |
|
224 TBool isFileModifiable = iSisRegistry.ModifiableL(theFileNames[i]); |
|
225 |
|
226 INFO_PRINTF2(_L("File '%d':"), i); |
|
227 INFO_PRINTF2(_L(" expected modifiable tag = %d"), expectedModifiableTags[i]); |
|
228 INFO_PRINTF2(_L(" calculated modifiable tag = %d"), isFileModifiable); |
|
229 |
|
230 if (expectedModifiableTags[i] != isFileModifiable) |
|
231 { |
|
232 SetTestStepResult(EFail); |
|
233 break; |
|
234 } |
|
235 } |
|
236 |
|
237 // Items popped and cleaned up from the stack (in this order): |
|
238 // &expectedModifiableTags and &theFileNames. |
|
239 CleanupStack::PopAndDestroy(2, &theFileNames); |
|
240 |
|
241 return TestStepResult(); |
|
242 } |
|
243 |
|
244 //////////////////////////////////////////////////////////////////////// |
|
245 // CFileHashStep - Checks the hash of a file |
|
246 //////////////////////////////////////////////////////////////////////// |
|
247 CFileHashStep::CFileHashStep() |
|
248 { |
|
249 SetTestStepName(KFileHash); |
|
250 } |
|
251 |
|
252 TVerdict CFileHashStep::doTestStepL() |
|
253 { |
|
254 // Get the filenames (for which the hash will be calculated) |
|
255 // from the test section. |
|
256 RArray<TPtrC> theFileNames; |
|
257 CleanupClosePushL(theFileNames); |
|
258 GetStringArrayFromConfigL(ConfigSection(), KHashFileName, theFileNames); |
|
259 |
|
260 // Get the filenames that contain the expected hash values, |
|
261 // from the test section. |
|
262 RArray<TPtrC> expectedHashFiles; |
|
263 CleanupClosePushL(expectedHashFiles); |
|
264 GetStringArrayFromConfigL(ConfigSection(), KHashFileValue, expectedHashFiles); |
|
265 |
|
266 // Initialise the test step result to pass. |
|
267 SetTestStepResult(EPass); |
|
268 |
|
269 // Ensure that there are as many filenames whose hash will be calculated, |
|
270 // as there are files with expected hash values. |
|
271 TInt numModFiles = theFileNames.Count(); |
|
272 if (numModFiles != expectedHashFiles.Count()) |
|
273 { |
|
274 User::LeaveIfError(KErrCorrupt); |
|
275 } |
|
276 |
|
277 // For each file in config section KHashFileName, calculate its hash |
|
278 // value and compare it with the corresponding expected hash value. |
|
279 // Fail the test case if they don't match. |
|
280 for (TInt i=0; i<numModFiles; i++) |
|
281 { |
|
282 INFO_PRINTF2(_L("Using SisRegistry to calculate hash for: %S"), &theFileNames[i]); |
|
283 // Use SisRegistry to calculate the hash value for this file. |
|
284 CHashContainer* hashContainer = iSisRegistry.HashL(theFileNames[i]); |
|
285 CleanupStack::PushL(hashContainer); |
|
286 |
|
287 const TDesC8& calcHashValue = hashContainer->Data(); |
|
288 |
|
289 // NOTE: The following block of code is temporary, |
|
290 // so we can get the hash values first. |
|
291 // ----------------------------------------------- |
|
292 // Name the file that will contain the expected hash value; |
|
293 // on the 2nd iteration, this would have to be substituted |
|
294 // by "c:\\system\\data\\hashForLang_txt.dat". |
|
295 //_LIT(KHashFile, "c:\\system\\data\\hashForTestsidcheck_A_exe.dat"); |
|
296 |
|
297 // Create and open the (binary) file for writing later. |
|
298 //RFs fs_util; |
|
299 //User::LeaveIfError(fs_util.Connect()); |
|
300 //CleanupClosePushL(fs_util); |
|
301 |
|
302 //RFile fileToWrite; |
|
303 |
|
304 //User::LeaveIfError(fileToWrite.Create(fs_util, KHashFile, |
|
305 // EFileWrite | EFileStream)); |
|
306 //CleanupClosePushL(fileToWrite); |
|
307 |
|
308 //User::LeaveIfError(fileToWrite.Write(calcHashValue)); |
|
309 //CleanupStack::PopAndDestroy(&fileToWrite); |
|
310 //CleanupStack::PopAndDestroy(&fs_util); |
|
311 // ----------------------------------------------- |
|
312 |
|
313 // Open for reading the file that has the expected hash value. |
|
314 INFO_PRINTF2(_L("Reading Expected hash value from: %S"), &expectedHashFiles[i]); |
|
315 RFs fs; |
|
316 User::LeaveIfError(fs.Connect()); |
|
317 CleanupClosePushL(fs); |
|
318 |
|
319 RFile fileToRead; |
|
320 User::LeaveIfError(fileToRead.Open(fs, expectedHashFiles[i], |
|
321 EFileRead | EFileShareReadersOnly | EFileStream)); |
|
322 CleanupClosePushL(fileToRead); |
|
323 |
|
324 // Create a block of memory to store the expected hash value. |
|
325 TInt fileSize = 0; |
|
326 User::LeaveIfError(fileToRead.Size(fileSize)); |
|
327 HBufC8* memForExpectedHashValue = HBufC8::NewLC(fileSize); |
|
328 |
|
329 // Read the expected hash value into the previously created memory block. |
|
330 TPtr8 expectedHashValue(memForExpectedHashValue->Des()); |
|
331 User::LeaveIfError(fileToRead.Read(0, expectedHashValue, fileSize)); |
|
332 |
|
333 INFO_PRINTF1(_L("Comparing hash values")); |
|
334 |
|
335 // Compare the calculated has value against its expected value. |
|
336 if (calcHashValue.Compare(expectedHashValue) != KErrNone) |
|
337 { |
|
338 SetTestStepResult(EFail); |
|
339 |
|
340 // Items popped and cleaned up from the stack (in this order): |
|
341 // memForExpectedHashValue, &fileToRead, &fs and hashContainer. |
|
342 CleanupStack::PopAndDestroy(4, hashContainer); |
|
343 |
|
344 break; |
|
345 } |
|
346 |
|
347 // Items popped and cleaned up from the stack (in this order): |
|
348 // memForExpectedHashValue, &fileToRead, &fs and hashContainer. |
|
349 CleanupStack::PopAndDestroy(4, hashContainer); |
|
350 } |
|
351 |
|
352 // Items popped and cleaned up from the stack (in this order): |
|
353 // &expectedHashFiles and &theFileNames. |
|
354 CleanupStack::PopAndDestroy(2, &theFileNames); |
|
355 |
|
356 return TestStepResult(); |
|
357 } |
|
358 |
|
359 ///////////////////////////////////////////////////////////////////// |
|
360 // CInstalledUidsStep - checks installed packages Uids list |
|
361 ///////////////////////////////////////////////////////////////////// |
|
362 CInstalledUidsStep::CInstalledUidsStep() |
|
363 { |
|
364 SetTestStepName(KInstalledUids); |
|
365 } |
|
366 |
|
367 TVerdict CInstalledUidsStep::doTestStepL() |
|
368 { |
|
369 RArray<TUid> expectedUids; |
|
370 CleanupClosePushL(expectedUids); |
|
371 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
372 |
|
373 RArray<TUid> actualUids; |
|
374 CleanupClosePushL(actualUids); |
|
375 iSisRegistry.InstalledUidsL(actualUids); |
|
376 |
|
377 SetTestStepResult(EPass); |
|
378 |
|
379 for (TInt index=0; index < expectedUids.Count(); index++) |
|
380 { |
|
381 if(actualUids.Find(expectedUids[index]) != KErrNotFound) |
|
382 { |
|
383 INFO_PRINTF2(_L("Uid: 0x%08x was found!"), expectedUids[index]); |
|
384 } |
|
385 else |
|
386 { |
|
387 SetTestStepResult(EFail); |
|
388 ERR_PRINTF2(_L("Uid: 0x%08x not found!"), expectedUids[index]); |
|
389 } |
|
390 } |
|
391 |
|
392 CleanupStack::PopAndDestroy(2, &expectedUids); //actualUids |
|
393 |
|
394 return TestStepResult(); |
|
395 } |
|
396 |
|
397 ///////////////////////////////////////////////////////////////////// |
|
398 // CInstalledPackagesStep - checks installed packages names and vendor list |
|
399 ///////////////////////////////////////////////////////////////////// |
|
400 CInstalledPackagesStep::CInstalledPackagesStep() |
|
401 { |
|
402 SetTestStepName(KInstalledPackages); |
|
403 } |
|
404 |
|
405 TVerdict CInstalledPackagesStep::doTestStepL() |
|
406 { |
|
407 RArray<TUid> expectedUids; |
|
408 CleanupClosePushL(expectedUids); |
|
409 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
410 |
|
411 RArray<TPtrC> expectedPackageNames; |
|
412 CleanupClosePushL(expectedPackageNames); |
|
413 GetStringArrayFromConfigL(ConfigSection(), KPackage, expectedPackageNames); |
|
414 |
|
415 RArray<TPtrC> expectedVendorNames; |
|
416 CleanupClosePushL(expectedVendorNames); |
|
417 GetStringArrayFromConfigL(ConfigSection(), KVendor, expectedVendorNames); |
|
418 |
|
419 RPointerArray<CSisRegistryPackage> packages; |
|
420 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
421 |
|
422 iSisRegistry.InstalledPackagesL(packages); |
|
423 |
|
424 SetTestStepResult(EPass); |
|
425 |
|
426 for (TInt expected = 0; expected < expectedPackageNames.Count(); expected++) |
|
427 { |
|
428 TBool result = EFalse; |
|
429 for (TInt actual = 0; actual < packages.Count(); ++actual) |
|
430 { |
|
431 if (packages[actual]->Uid() == expectedUids[expected] && |
|
432 !packages[actual]->Name().CompareF(expectedPackageNames[expected]) && |
|
433 !packages[actual]->Vendor().CompareF(expectedVendorNames[expected])) |
|
434 { |
|
435 result = ETrue; |
|
436 break; |
|
437 } |
|
438 } |
|
439 |
|
440 if(result) |
|
441 { |
|
442 INFO_PRINTF3(_L("Package %S by Vendor %S was found!"), &expectedPackageNames[expected], &expectedVendorNames[expected]); |
|
443 } |
|
444 else |
|
445 { |
|
446 SetTestStepResult(EFail); |
|
447 ERR_PRINTF3(_L("Package %S by Vendor %S was not found!"), &expectedPackageNames[expected], &expectedVendorNames[expected]); |
|
448 } |
|
449 } |
|
450 |
|
451 CleanupStack::PopAndDestroy(4, &expectedUids); //packages, expectedVendorNames, expectedPackageNames |
|
452 |
|
453 return TestStepResult(); |
|
454 } |
|
455 |
|
456 ///////////////////////////////////////////////////////////////////// |
|
457 // CRemovablePackagesStep - checks removable packages names and vendor list |
|
458 ///////////////////////////////////////////////////////////////////// |
|
459 CRemovablePackagesStep::CRemovablePackagesStep() |
|
460 { |
|
461 SetTestStepName(KRemovablePackages); |
|
462 } |
|
463 |
|
464 TVerdict CRemovablePackagesStep::doTestStepL() |
|
465 { |
|
466 RArray<TUid> expectedNoUids; |
|
467 CleanupClosePushL(expectedNoUids); |
|
468 GetUidArrayFromConfigL(ConfigSection(), KNoUid, expectedNoUids); |
|
469 |
|
470 RArray<TUid> expectedUids; |
|
471 CleanupClosePushL(expectedUids); |
|
472 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
473 |
|
474 RArray<TPtrC> expectedPackageNames; |
|
475 CleanupClosePushL(expectedPackageNames); |
|
476 GetStringArrayFromConfigL(ConfigSection(), KPackage, expectedPackageNames); |
|
477 |
|
478 RArray<TPtrC> expectedVendorNames; |
|
479 CleanupClosePushL(expectedVendorNames); |
|
480 GetStringArrayFromConfigL(ConfigSection(), KVendor, expectedVendorNames); |
|
481 |
|
482 RPointerArray<CSisRegistryPackage> packages; |
|
483 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
484 |
|
485 iSisRegistry.RemovablePackagesL(packages); |
|
486 |
|
487 TInt expected = 0; |
|
488 for (expected = 0; expected < expectedPackageNames.Count(); expected++) |
|
489 { |
|
490 TBool result = EFalse; |
|
491 for (TInt actual = 0; actual < packages.Count(); ++actual) |
|
492 { |
|
493 if (packages[actual]->Uid() == expectedUids[expected] && |
|
494 !packages[actual]->Name().CompareF(expectedPackageNames[expected]) && |
|
495 !packages[actual]->Vendor().CompareF(expectedVendorNames[expected])) |
|
496 { |
|
497 result = ETrue; |
|
498 break; |
|
499 } |
|
500 } |
|
501 |
|
502 if(result) |
|
503 { |
|
504 INFO_PRINTF3(_L("Package %S by Vendor %S was found!"), &expectedPackageNames[expected], &expectedVendorNames[expected]); |
|
505 } |
|
506 else |
|
507 { |
|
508 SetTestStepResult(EFail); |
|
509 ERR_PRINTF3(_L("Package %S by Vendor %S was not found!"), &expectedPackageNames[expected], &expectedVendorNames[expected]); |
|
510 } |
|
511 } |
|
512 |
|
513 for (expected = 0; expected < expectedNoUids.Count(); expected++) |
|
514 { |
|
515 TBool result = ETrue; |
|
516 for (TInt actual = 0; actual < packages.Count(); ++actual) |
|
517 { |
|
518 if (packages[actual]->Uid() == expectedNoUids[expected]) |
|
519 { |
|
520 result = EFalse; |
|
521 break; |
|
522 } |
|
523 } |
|
524 |
|
525 if(result) |
|
526 { |
|
527 INFO_PRINTF2(_L("Non-Removable Package %d was not found!"), &expectedNoUids[expected]); |
|
528 } |
|
529 else |
|
530 { |
|
531 SetTestStepResult(EFail); |
|
532 ERR_PRINTF2(_L("Non-Removable Package %d was found!"), &expectedNoUids[expected]); |
|
533 } |
|
534 } |
|
535 |
|
536 CleanupStack::PopAndDestroy(5, &expectedNoUids); //packages, expectedVendorNames, expectedPackageNames |
|
537 |
|
538 return TestStepResult(); |
|
539 } |
|
540 |
|
541 ///////////////////////////////////////////////////////////////////// |
|
542 // CNonRemovablePackagesStep - checks Non-removable packages in rom |
|
543 ///////////////////////////////////////////////////////////////////// |
|
544 CInRomNonRemovablePackage::CInRomNonRemovablePackage() |
|
545 { |
|
546 SetTestStepName(KInRomNonRemovablePackages); |
|
547 } |
|
548 |
|
549 TVerdict CInRomNonRemovablePackage::doTestStepL() |
|
550 { |
|
551 RPointerArray<CSisRegistryPackage> packages; |
|
552 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
553 |
|
554 iSisRegistry.RemovablePackagesL(packages); |
|
555 |
|
556 RSisRegistryEntry entry; |
|
557 TBool inrom = EFalse; |
|
558 for (TInt i = 0; i < packages.Count(); ++i) |
|
559 { |
|
560 User::LeaveIfError(entry.OpenL(iSisRegistry, *packages[i])); |
|
561 inrom = entry.IsInRomL(); |
|
562 |
|
563 if(inrom) |
|
564 { |
|
565 SetTestStepResult(EFail); |
|
566 } |
|
567 } |
|
568 INFO_PRINTF1(_L("Packages which are removable are not in ROM")); |
|
569 CleanupStack::PopAndDestroy(&packages); |
|
570 |
|
571 return TestStepResult(); |
|
572 } |
|
573 |
|
574 ////////////////////////////////////////////////////////////////////////////// |
|
575 // CInstalledDrives - check all the drives where files are installed from SIS |
|
576 ////////////////////////////////////////////////////////////////////////////// |
|
577 CInstalledDrives::CInstalledDrives() |
|
578 { |
|
579 SetTestStepName(KInstalledDrives); |
|
580 } |
|
581 |
|
582 TVerdict CInstalledDrives::doTestStepL() |
|
583 { |
|
584 TInt drivebitmapcount=0; |
|
585 TUid expectedUid; |
|
586 GetUidFromConfig(ConfigSection(), KUid, expectedUid); |
|
587 GetIntFromConfig(ConfigSection(), KDrivebitmapcount, drivebitmapcount); |
|
588 |
|
589 RPointerArray<CSisRegistryPackage> packages; |
|
590 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
591 |
|
592 iSisRegistry.RemovablePackagesL(packages); |
|
593 |
|
594 RSisRegistryEntry entry; |
|
595 CleanupClosePushL(entry); |
|
596 |
|
597 for (TInt i=0; i<packages.Count(); i++) |
|
598 { |
|
599 if(expectedUid == packages[i]->Uid()) |
|
600 { |
|
601 User::LeaveIfError(entry.OpenL(iSisRegistry, *packages[i])); |
|
602 TUint drives = entry.InstalledDrivesL(); |
|
603 if(drives != drivebitmapcount) |
|
604 { |
|
605 SetTestStepResult(EFail); |
|
606 INFO_PRINTF1(_L("Drive bitmask count is not Correct...")); |
|
607 } |
|
608 else |
|
609 { |
|
610 INFO_PRINTF1(_L("Drive bitmask count is OK...")); |
|
611 } |
|
612 } |
|
613 } |
|
614 |
|
615 CleanupStack::PopAndDestroy(2,&packages); //entry |
|
616 |
|
617 return TestStepResult(); |
|
618 } |
|
619 |
|
620 |
|
621 ///////////////////////////////////////////////////////////////////// |
|
622 // CIsUidInstalledStep - checks whether an Uid is registered |
|
623 ///////////////////////////////////////////////////////////////////// |
|
624 CIsUidInstalledStep::CIsUidInstalledStep() |
|
625 { |
|
626 SetTestStepName(KIsUidInstalled); |
|
627 } |
|
628 |
|
629 TVerdict CIsUidInstalledStep::doTestStepL() |
|
630 { |
|
631 RArray<TUid> expectedUids; |
|
632 CleanupClosePushL(expectedUids); |
|
633 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
634 |
|
635 SetTestStepResult(EPass); |
|
636 for (TInt index = 0; index < expectedUids.Count(); index++) |
|
637 { |
|
638 if(iSisRegistry.IsInstalledL(expectedUids[index])) |
|
639 { |
|
640 INFO_PRINTF2(_L("Uid: 0x%08x was found!"), expectedUids[index]); |
|
641 } |
|
642 else |
|
643 { |
|
644 SetTestStepResult(EFail); |
|
645 ERR_PRINTF2(_L("Uid: 0x%08x not found!"), expectedUids[index]); |
|
646 } |
|
647 } |
|
648 CleanupStack::PopAndDestroy(&expectedUids); |
|
649 |
|
650 return TestStepResult(); |
|
651 } |
|
652 |
|
653 ///////////////////////////////////////////////////////////////////// |
|
654 // CIsPackageInstalledStep - checks if packages are registered |
|
655 ///////////////////////////////////////////////////////////////////// |
|
656 |
|
657 CIsPackageInstalledStep::CIsPackageInstalledStep() |
|
658 { |
|
659 SetTestStepName(KIsPackageInstalled); |
|
660 } |
|
661 |
|
662 TVerdict CIsPackageInstalledStep::doTestStepL() |
|
663 { |
|
664 RArray<TUid> expectedUids; |
|
665 CleanupClosePushL(expectedUids); |
|
666 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
667 |
|
668 RArray<TPtrC> expectedPackageNames; |
|
669 CleanupClosePushL(expectedPackageNames); |
|
670 GetStringArrayFromConfigL(ConfigSection(), KPackage, expectedPackageNames); |
|
671 |
|
672 RArray<TPtrC> expectedVendorNames; |
|
673 CleanupClosePushL(expectedVendorNames); |
|
674 GetStringArrayFromConfigL(ConfigSection(), KVendor, expectedVendorNames); |
|
675 |
|
676 RPointerArray<CSisRegistryPackage> packages; |
|
677 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
678 |
|
679 SetTestStepResult(EPass); |
|
680 for (TInt i = 0; i < expectedUids.Count(); ++i) |
|
681 { |
|
682 CSisRegistryPackage* package = CSisRegistryPackage::NewLC(expectedUids[i], |
|
683 expectedPackageNames[i], expectedVendorNames[i]); |
|
684 package->SetIndex(0); |
|
685 |
|
686 RSisRegistryEntry entry; |
|
687 CleanupClosePushL(entry); |
|
688 |
|
689 TInt err = entry.Open(iSisRegistry, package->Name(), package->Vendor()); |
|
690 if (err != KErrNone) |
|
691 { |
|
692 SetTestStepResult(EFail); |
|
693 ERR_PRINTF2(_L("Uid: 0x%08x not found!"), expectedUids[i]); |
|
694 } |
|
695 |
|
696 CleanupStack::PopAndDestroy(2, package); // entry |
|
697 } |
|
698 |
|
699 CleanupStack::PopAndDestroy(4, &expectedUids); // expectedVendorNames, expectedPackageNames |
|
700 |
|
701 return TestStepResult(); |
|
702 } |
|
703 |
|
704 ///////////////////////////////////////////////////////////////////// |
|
705 // CIsControllerInstalledStep - checks whether a Controller is present |
|
706 ///////////////////////////////////////////////////////////////////// |
|
707 CIsControllerInstalledStep::CIsControllerInstalledStep() |
|
708 { |
|
709 SetTestStepName(KIsControllerInstalled); |
|
710 } |
|
711 |
|
712 TVerdict CIsControllerInstalledStep::doTestStepL() |
|
713 { |
|
714 RArray<TPtrC> expectedControllers; |
|
715 CleanupClosePushL(expectedControllers); |
|
716 GetStringArrayFromConfigL(ConfigSection(), KController, expectedControllers); |
|
717 |
|
718 SetTestStepResult(EPass); |
|
719 RFs fs; |
|
720 User::LeaveIfError(fs.Connect()); |
|
721 CleanupClosePushL(fs); |
|
722 for (TInt index = 0; index < expectedControllers.Count(); index++) |
|
723 { |
|
724 RFile file; |
|
725 CleanupClosePushL(file); |
|
726 // open file and read the data |
|
727 User::LeaveIfError(file.Open(fs, expectedControllers[index], EFileRead | EFileShareReadersOnly)); |
|
728 // read the data from the file |
|
729 TInt fileSize; |
|
730 file.Size(fileSize); |
|
731 HBufC8* buffer = HBufC8::NewLC(fileSize); |
|
732 TPtr8 ptr(buffer->Des()); |
|
733 file.Read(0, ptr, fileSize); |
|
734 |
|
735 if(iSisRegistry.IsInstalledL(*buffer)) |
|
736 { |
|
737 INFO_PRINTF2(_L("%S matching controller was found!"), &expectedControllers[index]); |
|
738 } |
|
739 else |
|
740 { |
|
741 SetTestStepResult(EFail); |
|
742 INFO_PRINTF2(_L("%S controller did not match expected!"), &expectedControllers[index]); |
|
743 } |
|
744 CleanupStack::PopAndDestroy(2, &file); //buffer |
|
745 } |
|
746 CleanupStack::PopAndDestroy(2, &expectedControllers); //fs |
|
747 |
|
748 return TestStepResult(); |
|
749 } |
|
750 |
|
751 ///////////////////////////////////////////////////////////////////// |
|
752 // CGetControllersStep - checks whether one can get the binary version |
|
753 // of entry controllers present |
|
754 ///////////////////////////////////////////////////////////////////// |
|
755 CGetControllersStep::CGetControllersStep() |
|
756 { |
|
757 SetTestStepName(KGetControllers); |
|
758 } |
|
759 |
|
760 TVerdict CGetControllersStep::doTestStepL() |
|
761 { |
|
762 SetTestStepResult(EPass); |
|
763 |
|
764 RArray<TUid> expectedUids; |
|
765 CleanupClosePushL(expectedUids); |
|
766 GetUidArrayFromConfigL(ConfigSection(), KUid, expectedUids); |
|
767 |
|
768 RFs fs; |
|
769 CleanupClosePushL(fs); |
|
770 User::LeaveIfError(fs.Connect()); |
|
771 |
|
772 for (TInt index = 0; index < expectedUids.Count(); index++) |
|
773 { |
|
774 TInt res; |
|
775 RSisRegistryEntry entry; |
|
776 CleanupClosePushL(entry); |
|
777 INFO_PRINTF3(_L("Open: %08x %d entry!"), expectedUids[index],index); |
|
778 res = entry.Open(iSisRegistry, expectedUids[index]); |
|
779 if (res == KErrNone) |
|
780 { |
|
781 RPointerArray<HBufC8> actualControllers; |
|
782 CleanupResetAndDestroy<RPointerArray<HBufC8> >::PushL(actualControllers); |
|
783 TRAP(res, entry.ControllersL(actualControllers)); |
|
784 if (res != KErrNone) |
|
785 { |
|
786 INFO_PRINTF3(_L("Accessing controllers for uid: %08x left with %d!"), expectedUids[index], res); |
|
787 SetTestStepResult(EFail); |
|
788 User::Leave(res); |
|
789 } |
|
790 |
|
791 HBufC* keyName = HBufC::NewLC(KUid().Length() + KKeyFormat().Length() |
|
792 + KController().Length() + KKeyFormat().Length()); |
|
793 TPtr ptr(keyName->Des()); |
|
794 ptr = KUid(); |
|
795 ptr.AppendFormat(KKeyFormat(), index + 1); |
|
796 ptr.Append(KController); |
|
797 |
|
798 RArray<TPtrC> controllerFilenames; |
|
799 CleanupClosePushL(controllerFilenames); |
|
800 GetStringArrayFromConfigL(ConfigSection(), ptr, controllerFilenames); |
|
801 |
|
802 if (controllerFilenames.Count() != actualControllers.Count()) |
|
803 { |
|
804 ERR_PRINTF3(_L("Actual Controllers = %d, Expected Controllers = %d"), actualControllers.Count(), controllerFilenames.Count()); |
|
805 SetTestStepResult(EFail); |
|
806 } |
|
807 |
|
808 for (TInt filename = 0; filename < controllerFilenames.Count(); filename++) |
|
809 { |
|
810 RFile file; |
|
811 CleanupClosePushL(file); |
|
812 // open file and read the data |
|
813 User::LeaveIfError(file.Open(fs, controllerFilenames[filename], EFileRead | EFileShareReadersOnly)); |
|
814 // read the data from the file |
|
815 TInt fileSize; |
|
816 file.Size(fileSize); |
|
817 // create a buffer according to file size and load it with data |
|
818 HBufC8* buffer = HBufC8::NewLC(fileSize); |
|
819 TPtr8 ptr(buffer->Des()); |
|
820 file.Read(0, ptr, fileSize); |
|
821 |
|
822 TBool found = EFalse; |
|
823 for (TInt controller = 0; controller < actualControllers.Count(); controller++) |
|
824 { |
|
825 if(*actualControllers[controller] == *buffer) |
|
826 { |
|
827 found = ETrue; |
|
828 break; |
|
829 } |
|
830 } |
|
831 |
|
832 if(found) |
|
833 { |
|
834 INFO_PRINTF3(_L("Matching controller #%d found for Uid: %08x!"), filename, expectedUids[index]); |
|
835 } |
|
836 else |
|
837 { |
|
838 SetTestStepResult(EFail); |
|
839 ERR_PRINTF3(_L("Matching controller #%d not found for Uid: %08x!"), filename, expectedUids[index]); |
|
840 } |
|
841 |
|
842 // cleanup |
|
843 CleanupStack::PopAndDestroy(2, &file); //buffer |
|
844 } |
|
845 |
|
846 CleanupStack::PopAndDestroy(3, &actualControllers); // controllerFilenames, keyNames |
|
847 } |
|
848 else |
|
849 { |
|
850 SetTestStepResult(EFail); |
|
851 INFO_PRINTF2(_L("Failed Open Uid: %08x entry!"), expectedUids[index]); |
|
852 } |
|
853 |
|
854 CleanupStack::PopAndDestroy(&entry); |
|
855 } |
|
856 |
|
857 CleanupStack::PopAndDestroy(2, &expectedUids); |
|
858 |
|
859 return TestStepResult(); |
|
860 } |
|
861 |
|
862 ///////////////////////////////////////////////////////////////////// |
|
863 // CEntryUidOpenCloseStep |
|
864 ///////////////////////////////////////////////////////////////////// |
|
865 CEntryUidOpenCloseStep::CEntryUidOpenCloseStep() |
|
866 { |
|
867 SetTestStepName(KEntryUidOpenClose); |
|
868 } |
|
869 |
|
870 TVerdict CEntryUidOpenCloseStep::doTestStepL() |
|
871 { |
|
872 RArray<TUid> uids; |
|
873 CleanupClosePushL(uids); |
|
874 iSisRegistry.InstalledUidsL(uids); |
|
875 |
|
876 SetTestStepResult(EPass); |
|
877 for(TInt index = 0; index < uids.Count(); index++) |
|
878 { |
|
879 Swi::RSisRegistryEntry entry; |
|
880 CleanupClosePushL(entry); |
|
881 TInt result = entry.Open(iSisRegistry, uids[index]); |
|
882 if (result == KErrNone) |
|
883 { |
|
884 INFO_PRINTF2(_L("Uid: 0x%08x was opened successfully!"), uids[index]); |
|
885 entry.Close(); |
|
886 INFO_PRINTF2(_L("Uid: 0x%08x was closed successfully!"), uids[index]); |
|
887 } |
|
888 else |
|
889 { |
|
890 SetTestStepResult(EFail); |
|
891 ERR_PRINTF3(_L("Uid: 0x%08x not opened, error %d!"), uids[index], result); |
|
892 } |
|
893 CleanupStack::PopAndDestroy(&entry); |
|
894 } |
|
895 |
|
896 CleanupStack::PopAndDestroy(&uids); |
|
897 |
|
898 return TestStepResult(); |
|
899 } |
|
900 |
|
901 ///////////////////////////////////////////////////////////////////// |
|
902 // CEntryPackageOpenCloseStep |
|
903 ///////////////////////////////////////////////////////////////////// |
|
904 CEntryPackageOpenCloseStep::CEntryPackageOpenCloseStep() |
|
905 { |
|
906 SetTestStepName(KEntryPackageOpenClose); |
|
907 } |
|
908 |
|
909 TVerdict CEntryPackageOpenCloseStep::doTestStepL() |
|
910 { |
|
911 RPointerArray<CSisRegistryPackage> packages; |
|
912 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
913 |
|
914 iSisRegistry.InstalledPackagesL(packages); |
|
915 |
|
916 SetTestStepResult(EPass); |
|
917 for(TInt index = 0; index < packages.Count(); index++) |
|
918 { |
|
919 TPtrC package = packages[index]->Name(); |
|
920 TPtrC vendor = packages[index]->Vendor(); |
|
921 |
|
922 Swi::RSisRegistryEntry entry; |
|
923 |
|
924 TInt result = entry.OpenL(iSisRegistry, *packages[index]); |
|
925 if (result == KErrNone) |
|
926 { |
|
927 CleanupClosePushL(entry); |
|
928 INFO_PRINTF3(_L("Package %S by Vendor %S was opened successfully!"), &package, &vendor); |
|
929 CleanupStack::PopAndDestroy(&entry); |
|
930 INFO_PRINTF3(_L("Package %S by Vendor %S was closed successfully!"), &package, &vendor); |
|
931 } |
|
932 else |
|
933 { |
|
934 SetTestStepResult(EFail); |
|
935 ERR_PRINTF4(_L("Package %S by Vendor %S not opened, error %d!"), &package, &vendor, result); |
|
936 } |
|
937 } |
|
938 |
|
939 CleanupStack::PopAndDestroy(&packages); |
|
940 |
|
941 return TestStepResult(); |
|
942 } |
|
943 |
|
944 ///////////////////////////////////////////////////////////////////// |
|
945 // CEntryNameOpenCloseStep |
|
946 ///////////////////////////////////////////////////////////////////// |
|
947 CEntryNameOpenCloseStep::CEntryNameOpenCloseStep() |
|
948 { |
|
949 SetTestStepName(KEntryNameOpenClose); |
|
950 } |
|
951 |
|
952 TVerdict CEntryNameOpenCloseStep::doTestStepL() |
|
953 { |
|
954 RPointerArray<CSisRegistryPackage> packages; |
|
955 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
956 |
|
957 iSisRegistry.InstalledPackagesL(packages); |
|
958 |
|
959 SetTestStepResult(EPass); |
|
960 for(TInt index = 0; index < packages.Count(); index++) |
|
961 { |
|
962 TPtrC package = packages[index]->Name(); |
|
963 TPtrC vendor = packages[index]->Vendor(); |
|
964 |
|
965 Swi::RSisRegistryEntry entry; |
|
966 |
|
967 TInt result = entry.Open(iSisRegistry, package, vendor); |
|
968 if (result == KErrNone) |
|
969 { |
|
970 CleanupClosePushL(entry); |
|
971 INFO_PRINTF3(_L("Package %S by Vendor %S was opened successfully!"), &package, &vendor); |
|
972 CleanupStack::PopAndDestroy(&entry); |
|
973 INFO_PRINTF3(_L("Package %S by Vendor %S was closed successfully!"), &package, &vendor); |
|
974 } |
|
975 else |
|
976 { |
|
977 SetTestStepResult(EFail); |
|
978 ERR_PRINTF4(_L("Package %S by Vendor %S not opened, error %d!"), &package, &vendor, result); |
|
979 } |
|
980 } |
|
981 |
|
982 CleanupStack::PopAndDestroy(&packages); |
|
983 |
|
984 return TestStepResult(); |
|
985 } |
|
986 |
|
987 ///////////////////////////////////////////////////////////////////// |
|
988 // CEntryMethodsTestStep - tests specific to entry methods |
|
989 ///////////////////////////////////////////////////////////////////// |
|
990 CEntryMethodsStep::CEntryMethodsStep() |
|
991 { |
|
992 SetTestStepName(KEntryMethods); |
|
993 } |
|
994 |
|
995 TVerdict CEntryMethodsStep::doTestStepL() |
|
996 { |
|
997 RPointerArray<CSisRegistryPackage> packages; |
|
998 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
999 |
|
1000 iSisRegistry.InstalledPackagesL(packages); |
|
1001 |
|
1002 SetTestStepResult(EPass); |
|
1003 for(TInt index = 0; index < packages.Count(); index++) |
|
1004 { |
|
1005 TPtrC package = packages[index]->Name(); |
|
1006 TPtrC vendor = packages[index]->Vendor(); |
|
1007 |
|
1008 Swi::RSisRegistryEntry entry; |
|
1009 |
|
1010 INFO_PRINTF3(_L("Opening Package %S by Vendor %S..."), &package, &vendor); |
|
1011 User::LeaveIfError(entry.OpenL(iSisRegistry, *packages[index])); |
|
1012 CleanupClosePushL(entry); |
|
1013 // get the version |
|
1014 TVersion packageVersion = entry.VersionL(); |
|
1015 INFO_PRINTF4(_L("Version %d %d %d"), packageVersion.iMajor, packageVersion.iMinor, packageVersion.iBuild ); |
|
1016 |
|
1017 // get sids |
|
1018 RArray<TUid> sids; |
|
1019 CleanupClosePushL(sids); |
|
1020 entry.SidsL(sids); |
|
1021 if (sids.Count() <= 0) |
|
1022 { |
|
1023 INFO_PRINTF1(_L("No sids installed!")); |
|
1024 } |
|
1025 else |
|
1026 { |
|
1027 for (TInt sid = 0; sid < sids.Count(); sid++) |
|
1028 { |
|
1029 INFO_PRINTF2(_L("Sid: 0x%08x was found!"), sids[sid]); |
|
1030 } |
|
1031 } |
|
1032 |
|
1033 CleanupStack::PopAndDestroy(&sids); |
|
1034 |
|
1035 // get the vendor; package name |
|
1036 HBufC* reportedVendor = entry.UniqueVendorNameL(); |
|
1037 CleanupStack::PushL(reportedVendor); |
|
1038 HBufC* reportedPackage = entry.PackageNameL(); |
|
1039 CleanupStack::PushL(reportedPackage); |
|
1040 |
|
1041 INFO_PRINTF3(_L("Package: %S from Vendor: %S"), reportedPackage, reportedVendor); |
|
1042 |
|
1043 CleanupStack::PopAndDestroy(reportedPackage); |
|
1044 CleanupStack::PopAndDestroy(reportedVendor); |
|
1045 |
|
1046 // get the localised vendor name |
|
1047 HBufC* vendorLocal = entry.LocalizedVendorNameL(); |
|
1048 CleanupStack::PushL(vendorLocal); |
|
1049 INFO_PRINTF2(_L("Localised Vendor Name: %S"), vendorLocal); |
|
1050 |
|
1051 CleanupStack::PopAndDestroy(vendorLocal); |
|
1052 |
|
1053 // get uid |
|
1054 TUid uid = entry.UidL(); |
|
1055 INFO_PRINTF3(_L("Package Uid: %d 0x%08x"), uid.iUid, uid.iUid); |
|
1056 |
|
1057 // get language |
|
1058 TLanguage language = entry.LanguageL(); |
|
1059 INFO_PRINTF3(_L("Package Language: %d 0x%08x"), language, language); |
|
1060 |
|
1061 // get property |
|
1062 TInt32 propertyKey = 10; |
|
1063 TInt32 propertyValue = entry.PropertyL(propertyKey); |
|
1064 INFO_PRINTF3(_L("Package property: key %d value %d"), propertyKey, propertyValue); |
|
1065 |
|
1066 // is present - currenty relies on default value |
|
1067 TBool isPresent = entry.IsPresentL(); |
|
1068 INFO_PRINTF2(_L("Package present is %d"), isPresent); |
|
1069 |
|
1070 // is signed |
|
1071 TBool isSigned = entry.IsSignedL(); |
|
1072 INFO_PRINTF2(_L("Package signed is %d"), isSigned); |
|
1073 |
|
1074 |
|
1075 // check Trust |
|
1076 switch(entry.TrustL()) |
|
1077 { |
|
1078 case ESisPackageUnsignedOrSelfSigned: |
|
1079 INFO_PRINTF1(_L("Packaged Trust: Unsigned or self signed")); |
|
1080 break; |
|
1081 case ESisPackageCertificateChainNoTrustAnchor: |
|
1082 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain has no trust anchor in Cert store")); |
|
1083 break; |
|
1084 case ESisPackageCertificateChainValidatedToTrustAnchor: |
|
1085 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated to Trust Anchor in Cert store")); |
|
1086 break; |
|
1087 case ESisPackageChainValidatedToTrustAnchorOCSPTransientError: |
|
1088 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated and OCSP Transient Error")); |
|
1089 break; |
|
1090 case ESisPackageChainValidatedToTrustAnchorAndOCSPValid: |
|
1091 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validated and OCSP Valid")); |
|
1092 break; |
|
1093 case ESisPackageBuiltIntoRom: |
|
1094 INFO_PRINTF1(_L("Packaged Trust: Built into ROM")); |
|
1095 break; |
|
1096 case ESisPackageValidationFailed: |
|
1097 INFO_PRINTF1(_L("Packaged Trust: Certificate Chain Validation Failed")); |
|
1098 break; |
|
1099 default: |
|
1100 INFO_PRINTF1(_L("Packaged Trust: Unknown")); |
|
1101 break; |
|
1102 }; |
|
1103 |
|
1104 // Time at which the trust was established |
|
1105 TTime timeStamp = entry.TrustTimeStampL(); |
|
1106 TBuf <32> dateTimeText; |
|
1107 TRAP_IGNORE(timeStamp.FormatL(dateTimeText, _L("%H%:1%T%:2%S on %1%/1%2%/2%3"))); |
|
1108 INFO_PRINTF2(_L("Package Trust Established: %S"), &dateTimeText); |
|
1109 |
|
1110 // is in rom |
|
1111 TBool inRom = entry.IsInRomL(); |
|
1112 INFO_PRINTF2(_L("Package inRom is %d"), inRom); |
|
1113 |
|
1114 // is an augmentation |
|
1115 TBool isAug = entry.IsAugmentationL(); |
|
1116 INFO_PRINTF2(_L("Package isAug is %d"), isAug); |
|
1117 |
|
1118 // installation size |
|
1119 TInt64 size = entry.SizeL(); |
|
1120 INFO_PRINTF3(_L("Package size is %d %d"), I64HIGH(size), I64LOW(size)); |
|
1121 |
|
1122 // get list of files |
|
1123 RPointerArray<HBufC> files; |
|
1124 CleanupResetAndDestroy<RPointerArray<HBufC> >::PushL(files); |
|
1125 entry.FilesL(files); |
|
1126 INFO_PRINTF2(_L("Package has %d files"), files.Count()); |
|
1127 for (TInt file = 0; file < files.Count(); file++) |
|
1128 { |
|
1129 // INFO_PRINTF3(_L("File %d file path %S"),file + 1, files[file]); |
|
1130 } |
|
1131 CleanupStack::PopAndDestroy(&files); |
|
1132 |
|
1133 CleanupStack::PopAndDestroy(&entry); |
|
1134 } |
|
1135 |
|
1136 CleanupStack::PopAndDestroy(&packages); |
|
1137 |
|
1138 return TestStepResult(); |
|
1139 } |
|
1140 |
|
1141 |
|
1142 ///////////////////////////////////////////////////////////////////// |
|
1143 // CEntrySidsStep - obtain a list of Sids from an entry |
|
1144 ///////////////////////////////////////////////////////////////////// |
|
1145 CEntrySidsStep::CEntrySidsStep() |
|
1146 { |
|
1147 SetTestStepName(KEntrySids); |
|
1148 } |
|
1149 |
|
1150 TVerdict CEntrySidsStep::doTestStepL() |
|
1151 { |
|
1152 SetTestStepResult(EFail); |
|
1153 |
|
1154 RArray<TUid> expectedSids; |
|
1155 CleanupClosePushL(expectedSids); |
|
1156 GetUidArrayFromConfigL(ConfigSection(), KSid, expectedSids); |
|
1157 |
|
1158 TPtrC package; |
|
1159 TPtrC vendor; |
|
1160 if(GetStringFromConfig(ConfigSection(), KPackage, package) |
|
1161 && GetStringFromConfig(ConfigSection(), KVendor, vendor)) |
|
1162 { |
|
1163 Swi::RSisRegistryEntry entry; |
|
1164 User::LeaveIfError(entry.Open(iSisRegistry, package, vendor)); |
|
1165 CleanupClosePushL(entry); |
|
1166 |
|
1167 RArray<TUid> sids; |
|
1168 CleanupClosePushL(sids); |
|
1169 entry.SidsL(sids); |
|
1170 |
|
1171 if (sids.Count() != expectedSids.Count()) |
|
1172 { |
|
1173 ERR_PRINTF3(_L("Actual Sids = %d, Expected Sids = %d"), sids.Count(), expectedSids.Count()); |
|
1174 } |
|
1175 else |
|
1176 { |
|
1177 SetTestStepResult(EPass); |
|
1178 for (TInt index=0; index < expectedSids.Count(); index++) |
|
1179 { |
|
1180 if(sids.Find(expectedSids[index]) != KErrNotFound) |
|
1181 { |
|
1182 INFO_PRINTF2(_L("Sid: 0x%08x was found!"), expectedSids[index]); |
|
1183 } |
|
1184 else |
|
1185 { |
|
1186 SetTestStepResult(EFail); |
|
1187 ERR_PRINTF2(_L("Sid: 0x%08x not found!"), expectedSids[index]); |
|
1188 } |
|
1189 } |
|
1190 } |
|
1191 |
|
1192 CleanupStack::PopAndDestroy(&sids); |
|
1193 CleanupStack::PopAndDestroy(&entry); |
|
1194 } |
|
1195 |
|
1196 CleanupStack::PopAndDestroy(&expectedSids); |
|
1197 return TestStepResult(); |
|
1198 } |
|
1199 |
|
1200 ///////////////////////////////////////////////////////////////////// |
|
1201 // CIsSidPresentStep - test package SIDs are reported as present. |
|
1202 ///////////////////////////////////////////////////////////////////// |
|
1203 |
|
1204 CIsSidPresentStep::CIsSidPresentStep() |
|
1205 { |
|
1206 SetTestStepName(KIsSidPresentStep); |
|
1207 } |
|
1208 |
|
1209 TVerdict CIsSidPresentStep::doTestStepL() |
|
1210 { |
|
1211 // iterate through every sid which is installed in a package |
|
1212 RPointerArray<CSisRegistryPackage> packages; |
|
1213 CleanupResetAndDestroy<RPointerArray<CSisRegistryPackage> >::PushL(packages); |
|
1214 |
|
1215 iSisRegistry.InstalledPackagesL(packages); |
|
1216 |
|
1217 TInt32 minSid = KMaxTInt32; |
|
1218 TInt32 maxSid = KMinTInt32; |
|
1219 |
|
1220 for (TInt i = packages.Count() - 1; i >= 0; --i) |
|
1221 { |
|
1222 const CSisRegistryPackage& pkg = *packages[i]; |
|
1223 |
|
1224 Swi::RSisRegistryEntry e; |
|
1225 TInt r = e.Open(iSisRegistry, pkg.Uid()); |
|
1226 User::LeaveIfError(r); |
|
1227 CleanupClosePushL(e); |
|
1228 |
|
1229 RArray<TUid> sids; |
|
1230 e.SidsL(sids); |
|
1231 CleanupClosePushL(sids); |
|
1232 |
|
1233 for (TInt j = sids.Count() - 1; j >= 0; --j) |
|
1234 { |
|
1235 TUid sid = sids[j]; |
|
1236 minSid = Min(minSid, sid.iUid); |
|
1237 maxSid = Max(maxSid, sid.iUid); |
|
1238 |
|
1239 TBool sidPresent = iSisRegistry.IsSidPresentL(sid); |
|
1240 TESTL(sidPresent); |
|
1241 } |
|
1242 |
|
1243 CleanupStack::PopAndDestroy(2, &e); |
|
1244 } |
|
1245 |
|
1246 TUid minSidM1(TUid::Uid(minSid - 1)); |
|
1247 TESTL(! iSisRegistry.IsSidPresentL(minSidM1)); |
|
1248 TUid maxSidP1(TUid::Uid(minSid + 1)); |
|
1249 TESTL(! iSisRegistry.IsSidPresentL(maxSidP1)); |
|
1250 |
|
1251 CleanupStack::PopAndDestroy(&packages); |
|
1252 |
|
1253 SetTestStepResult(EPass); |
|
1254 return TestStepResult(); |
|
1255 } |
|
1256 |
|
1257 ///////////////////////////////////////////////////////////////////// |
|
1258 // CIsPackagePresentStep - Test the IsPresent method |
|
1259 ///////////////////////////////////////////////////////////////////// |
|
1260 |
|
1261 CIsPackagePresentStep::CIsPackagePresentStep() |
|
1262 { |
|
1263 SetTestStepName(KIsPackagePresentStep); |
|
1264 } |
|
1265 |
|
1266 TVerdict CIsPackagePresentStep::doTestStepL() |
|
1267 { |
|
1268 SetTestStepResult(EPass); |
|
1269 |
|
1270 RArray<TUid> pUids; |
|
1271 CleanupClosePushL(pUids); |
|
1272 GetUidArrayFromConfigL(ConfigSection(), KUid, pUids); |
|
1273 |
|
1274 TInt count(pUids.Count()); |
|
1275 for (TInt i = 0; i < count; ++i) |
|
1276 { |
|
1277 // before each step, reset the registry state |
|
1278 |
|
1279 RTestUtilSessionSwi util; |
|
1280 User::LeaveIfError(util.Connect()); |
|
1281 CleanupClosePushL(util); |
|
1282 util.RegenerateRegistryCacheL(); |
|
1283 CleanupStack::PopAndDestroy(&util); |
|
1284 |
|
1285 // query the registry to see if this entry is present |
|
1286 RSisRegistryEntry entry; |
|
1287 //Since the SisRegistry is inconsistent from hardware and emulator, we won't check |
|
1288 //whether a package is presented on device if it's not installed at all thus no registry entry (e.g. MIDP) |
|
1289 #ifdef __WINS__ |
|
1290 User::LeaveIfError(entry.Open(iSisRegistry, pUids[i])); |
|
1291 #else |
|
1292 TInt err = entry.Open(iSisRegistry, pUids[i]); |
|
1293 if(KErrNotFound == err) |
|
1294 { |
|
1295 INFO_PRINTF2(_L("Package with UID 0x%08x is not installed on HW. IsPresent test skipped"), |
|
1296 pUids[i]); |
|
1297 continue; |
|
1298 } |
|
1299 User::LeaveIfError(err); |
|
1300 #endif |
|
1301 CleanupClosePushL(entry); |
|
1302 |
|
1303 if (!entry.IsPresentL()) |
|
1304 { |
|
1305 INFO_PRINTF2(_L("Package with UID 0x%08x is marked as not present!"), |
|
1306 pUids[i]); |
|
1307 SetTestStepResult(EFail); |
|
1308 } |
|
1309 |
|
1310 CleanupStack::PopAndDestroy(&entry); |
|
1311 } |
|
1312 CleanupStack::PopAndDestroy(&pUids); |
|
1313 return TestStepResult(); |
|
1314 } |
|
1315 CIntegrityCheckStep::CIntegrityCheckStep() |
|
1316 { |
|
1317 SetTestStepName(KIntegrityCheckStep); |
|
1318 } |
|
1319 CIntegrityCheckStep::~CIntegrityCheckStep() |
|
1320 { |
|
1321 } |
|
1322 |
|
1323 TVerdict CIntegrityCheckStep::doTestStepL() |
|
1324 { |
|
1325 TInt result=0; |
|
1326 |
|
1327 |
|
1328 CleanupResetAndDestroy<RPointerArray<CX509Certificate> >::PushL(iCertArray); |
|
1329 |
|
1330 InitializeL(); |
|
1331 TUid pUid; |
|
1332 GetUidFromConfig(ConfigSection(), KUid, pUid); |
|
1333 GetIntFromConfig(ConfigSection(),KResultTag,result); |
|
1334 |
|
1335 RSisRegistryEntry entry; |
|
1336 |
|
1337 SetTestStepResult(EFail); |
|
1338 |
|
1339 |
|
1340 // query the registry to see if this entry is present |
|
1341 User::LeaveIfError (entry.Open(iSisRegistry, pUid)); |
|
1342 |
|
1343 //Call the controller |
|
1344 TBool check = EFalse; |
|
1345 |
|
1346 check = entry.VerifyControllerSignatureL(iCertArray); |
|
1347 |
|
1348 if(check!=result) |
|
1349 { |
|
1350 SetTestStepResult(EFail); |
|
1351 } |
|
1352 else |
|
1353 { |
|
1354 SetTestStepResult(EPass); |
|
1355 } |
|
1356 entry.Close(); |
|
1357 CleanupStack::PopAndDestroy(&iCertArray); |
|
1358 return TestStepResult(); |
|
1359 } |
|
1360 |
|
1361 void CIntegrityCheckStep::InitializeL() |
|
1362 { |
|
1363 CX509Certificate* cert = NULL; |
|
1364 RArray<TPtrC> rootCertificates; |
|
1365 CleanupClosePushL(rootCertificates); |
|
1366 GetStringArrayFromConfigL(ConfigSection(), KRootCertTag, rootCertificates); |
|
1367 |
|
1368 User::LeaveIfError (fs.Connect()); |
|
1369 //opens the data file |
|
1370 CleanupClosePushL(fs); |
|
1371 |
|
1372 //Loop through all the X509 root certificates and load them |
|
1373 for (TInt i=0; i<rootCertificates.Count(); i++) |
|
1374 { |
|
1375 HBufC8* rawData = ReadFileLC(rootCertificates[i]); |
|
1376 cert = CX509Certificate::NewL(*rawData); |
|
1377 CleanupStack::PopAndDestroy(rawData); |
|
1378 CleanupStack::PushL(cert); |
|
1379 iCertArray.AppendL(cert); |
|
1380 CleanupStack::Pop(); |
|
1381 } |
|
1382 |
|
1383 //closes the file session |
|
1384 CleanupStack::PopAndDestroy(&fs); |
|
1385 CleanupStack::PopAndDestroy(&rootCertificates); |
|
1386 } |
|
1387 |
|
1388 HBufC8* CIntegrityCheckStep::ReadFileLC(const TDesC& aDatapath) |
|
1389 { |
|
1390 RFile file; |
|
1391 User::LeaveIfError(file.Open(fs, aDatapath, EFileRead)) ; |
|
1392 |
|
1393 TInt fileSize = 0; |
|
1394 User::LeaveIfError(file.Size(fileSize)); |
|
1395 |
|
1396 HBufC8* rawData = HBufC8::NewLC(fileSize); |
|
1397 TPtr8 rawDataPtr(rawData->Des()); |
|
1398 rawDataPtr.SetLength(fileSize); |
|
1399 file.Read (rawDataPtr); |
|
1400 |
|
1401 file.Close(); |
|
1402 |
|
1403 return rawData; |
|
1404 } |
|
1405 |
|
1406 ///////////////////////////////////////////////////////////////////// |
|
1407 // CIntegrityDateAndTimeCheckStep - |
|
1408 ///////////////////////////////////////////////////////////////////// |
|
1409 |
|
1410 |
|
1411 CIntegrityDateAndTimeCheckStep::CIntegrityDateAndTimeCheckStep() |
|
1412 { |
|
1413 SetTestStepName(KDateAndTimeIntegrityCheckStep); |
|
1414 } |
|
1415 |
|
1416 |
|
1417 TVerdict CIntegrityDateAndTimeCheckStep::doTestStepPreambleL() |
|
1418 { |
|
1419 CIntegrityCheckStep::doTestStepPreambleL(); |
|
1420 |
|
1421 GetUidFromConfig(ConfigSection(), KUid, iPackageUid); |
|
1422 GetIntFromConfig(ConfigSection(),KResultTag,iExpectedResult); |
|
1423 |
|
1424 TPtrC dateAndTime; |
|
1425 GetStringFromConfig(ConfigSection(), KDateTime, dateAndTime); |
|
1426 iTime = TTime(dateAndTime); |
|
1427 |
|
1428 iOriginalTime.UniversalTime(); |
|
1429 User::SetUTCTime(iTime); |
|
1430 |
|
1431 return EPass; |
|
1432 } |
|
1433 |
|
1434 TVerdict CIntegrityDateAndTimeCheckStep::doTestStepPostambleL() |
|
1435 { |
|
1436 TTime timeNow; |
|
1437 timeNow.UniversalTime(); |
|
1438 |
|
1439 TTimeIntervalMicroSeconds timeInterval = timeNow.MicroSecondsFrom(iTime); |
|
1440 timeNow = iOriginalTime + timeInterval; |
|
1441 |
|
1442 User::SetUTCTime(timeNow); |
|
1443 |
|
1444 return TestStepResult(); |
|
1445 } |
|
1446 |
|
1447 TVerdict CIntegrityDateAndTimeCheckStep::doTestStepL() |
|
1448 { |
|
1449 CleanupResetAndDestroy<RPointerArray<CX509Certificate> >::PushL(iCertArray); |
|
1450 |
|
1451 InitializeL(); |
|
1452 |
|
1453 RSisRegistryEntry entry; |
|
1454 |
|
1455 SetTestStepResult(EPass); |
|
1456 // query the registry to see if this entry is present |
|
1457 User::LeaveIfError(entry.Open(iSisRegistry, iPackageUid)); |
|
1458 CleanupClosePushL(entry); |
|
1459 |
|
1460 //Call the controller |
|
1461 TBool check = EFalse; |
|
1462 |
|
1463 check = entry.VerifyControllerSignatureL(iCertArray, ETrue); |
|
1464 if(check!=iExpectedResult) |
|
1465 { |
|
1466 ERR_PRINTF3(_L("ERROR: First call to verify failed. Result: %d. Expected Result: %d"), check, iExpectedResult); |
|
1467 SetTestStepResult(EFail); |
|
1468 } |
|
1469 |
|
1470 check = entry.VerifyControllerSignatureL(iCertArray, EFalse); |
|
1471 if(check==EFalse) |
|
1472 { |
|
1473 ERR_PRINTF2(_L("ERROR: Second call to verify failed. Result: %d. Expected Result: ETrue"), check); |
|
1474 SetTestStepResult(EFail); |
|
1475 } |
|
1476 |
|
1477 check = entry.VerifyControllerSignatureL(iCertArray, ETrue); |
|
1478 if(check!=iExpectedResult) |
|
1479 { |
|
1480 ERR_PRINTF3(_L("ERROR: Third call to verify failed. Result: %d. Expected Result: %d"), check, iExpectedResult); |
|
1481 SetTestStepResult(EFail); |
|
1482 } |
|
1483 |
|
1484 CleanupStack::PopAndDestroy(2, &iCertArray); |
|
1485 |
|
1486 return TestStepResult(); |
|
1487 } |
|
1488 |
|
1489 |
|
1490 ///////////////////////////////////////////////////////////////////// |
|
1491 // CLoggingFileInfoStep - |
|
1492 ///////////////////////////////////////////////////////////////////// |
|
1493 |
|
1494 CLoggingFileInfoStep::CLoggingFileInfoStep() |
|
1495 { |
|
1496 SetTestStepName(KLoggingFileInfo); |
|
1497 } |
|
1498 |
|
1499 TVerdict CLoggingFileInfoStep::doTestStepL() |
|
1500 { |
|
1501 SetTestStepResult(EPass); |
|
1502 __UHEAP_MARK; |
|
1503 RPointerArray<CLogEntry> fileInfo; |
|
1504 CleanupResetAndDestroy<RPointerArray<CLogEntry> >::PushL(fileInfo); |
|
1505 iSisRegistry.RetrieveLogFileL(fileInfo); |
|
1506 |
|
1507 if (fileInfo.Count()>0) |
|
1508 { |
|
1509 for (TInt i = 0; i < 5; i++) |
|
1510 { |
|
1511 TInt var = 1; |
|
1512 TBuf<16> entry; |
|
1513 entry.Format(_L("LOGENTRY%d.%d"),i,var); |
|
1514 TPtrC text0; |
|
1515 GetStringFromConfig(ConfigSection(), entry, text0); |
|
1516 entry.Format(_L("LOGENTRY%d.%d"),i,++var); |
|
1517 TPtrC text1; |
|
1518 GetStringFromConfig(ConfigSection(), entry, text1); |
|
1519 entry.Format(_L("LOGENTRY%d.%d"),i,++var); |
|
1520 TPtrC text2; |
|
1521 GetStringFromConfig(ConfigSection(), entry, text2); |
|
1522 entry.Format(_L("LOGENTRY%d.%d"),i,++var); |
|
1523 TPtrC text3; |
|
1524 GetStringFromConfig(ConfigSection(), entry, text3); |
|
1525 |
|
1526 TBuf<16> pkgName = fileInfo[0]->GetPkgName(); |
|
1527 TBuf<20> versiontext; |
|
1528 versiontext.Format(_L("%d.%d.%d"),fileInfo[i]->GetMajorVersion(),fileInfo[i]->GetMinorVersion(),fileInfo[i]->GetBuildVersion()); |
|
1529 |
|
1530 enum Swi::TSwiLogTypes s = fileInfo[i]->GetInstallType(); |
|
1531 TBuf<16> installType ; |
|
1532 switch (s) |
|
1533 { |
|
1534 case 0: // Swi::TSwiLogTypes::ESwiLogInstall : |
|
1535 installType.Format(_L("Install")); |
|
1536 break; |
|
1537 case 1: |
|
1538 installType.Format(_L("UnInstall")); |
|
1539 |
|
1540 break; |
|
1541 case 2: // Swi::TSwiLogTypes::ESwiLogUpgrade : |
|
1542 installType.Format(_L("Upgrade")); |
|
1543 |
|
1544 break; |
|
1545 default: |
|
1546 installType.Format(_L("Error unknown value")); |
|
1547 |
|
1548 break; |
|
1549 } |
|
1550 |
|
1551 TBuf<16> uidOfPkg; |
|
1552 uidOfPkg.Format(_L("%x"),fileInfo[i]->GetUid()); |
|
1553 |
|
1554 if(pkgName == text0 && versiontext == text1 |
|
1555 && installType ==text2 && uidOfPkg ==text3) |
|
1556 { |
|
1557 SetTestStepResult(EPass); |
|
1558 } |
|
1559 else |
|
1560 { |
|
1561 SetTestStepResult(EFail); |
|
1562 } |
|
1563 } |
|
1564 } |
|
1565 else |
|
1566 { |
|
1567 SetTestStepResult(EPass); |
|
1568 } |
|
1569 CleanupStack::PopAndDestroy(&fileInfo); |
|
1570 __UHEAP_MARKEND; |
|
1571 return TestStepResult(); |
|
1572 } |
|
1573 |
|
1574 CRomStubPerformanceStep::CRomStubPerformanceStep() |
|
1575 { |
|
1576 SetTestStepName(KRomStubPerformanceStep); |
|
1577 } |
|
1578 |
|
1579 TVerdict CRomStubPerformanceStep::doTestStepL() |
|
1580 { |
|
1581 // Simple test step to determine how long it takes to |
|
1582 // regenerate the cache. |
|
1583 |
|
1584 // Make sure the sisregistry is deleted before regenerating the cache. This |
|
1585 // will ensure that the registry entries are created from the ROM stub, instead |
|
1586 // of being read from the harddisk |
|
1587 RTestUtilSessionSwi util; |
|
1588 User::LeaveIfError(util.Connect()); |
|
1589 CleanupClosePushL(util); |
|
1590 |
|
1591 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
1592 TBuf<128> sisRegistryPath (sysDrive.Name()); |
|
1593 sisRegistryPath.Append(KSisRegistryPath); |
|
1594 |
|
1595 TInt err = util.RmDir(sisRegistryPath); |
|
1596 if(err != KErrNone && err != KErrPathNotFound && err != KErrNotFound) |
|
1597 { |
|
1598 User::Leave(err); |
|
1599 } |
|
1600 else |
|
1601 { |
|
1602 INFO_PRINTF1(_L("Sis Registry Deleted!")); |
|
1603 } |
|
1604 |
|
1605 INFO_PRINTF1(_L("Regenerate the cache. Starting the timer...")); |
|
1606 TTime startTime; |
|
1607 startTime.UniversalTime(); |
|
1608 |
|
1609 RTestUtilSessionSwi utilswi; |
|
1610 User::LeaveIfError(utilswi.Connect()); |
|
1611 CleanupClosePushL(utilswi); |
|
1612 |
|
1613 utilswi.RegenerateRegistryCacheL(); |
|
1614 |
|
1615 // Stop the timer |
|
1616 TTime endTime; |
|
1617 endTime.UniversalTime(); |
|
1618 INFO_PRINTF1(_L("Cache regenerated. Timer stopped.")); |
|
1619 |
|
1620 TInt64 durationMicro=endTime.MicroSecondsFrom(startTime).Int64(); |
|
1621 TInt durationMilli=durationMicro/1000; |
|
1622 |
|
1623 INFO_PRINTF2(_L("Duration (milliseconds): %d"),durationMilli); |
|
1624 |
|
1625 CleanupStack::PopAndDestroy(&utilswi); |
|
1626 CleanupStack::PopAndDestroy(&util); |
|
1627 |
|
1628 SetTestStepResult(EPass); |
|
1629 |
|
1630 return TestStepResult(); |
|
1631 } |
|
1632 |
|
1633 ////////////////////////////////////////////////////////////// |
|
1634 // CCorruptCacheStep - The Sis Registry will leave backup.bak |
|
1635 // around when it encounters a corrupt cache file |
|
1636 ////////////////////////////////////////////////////////////// |
|
1637 |
|
1638 CCorruptCacheStep::CCorruptCacheStep() |
|
1639 { |
|
1640 SetTestStepName(KCorruptCacheStep); |
|
1641 } |
|
1642 |
|
1643 TVerdict CCorruptCacheStep::doTestStepL() |
|
1644 { |
|
1645 SetTestStepResult(EFail); |
|
1646 |
|
1647 __UHEAP_MARK; |
|
1648 |
|
1649 RTestUtilSessionSwi util; |
|
1650 User::LeaveIfError(util.Connect()); |
|
1651 CleanupClosePushL(util); |
|
1652 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
1653 TDriveName sysDriveName (sysDrive.Name()); |
|
1654 |
|
1655 // Close the Sis Registry and wait for 3 secs for |
|
1656 // server to shut down |
|
1657 iSisRegistry.Close(); |
|
1658 |
|
1659 INFO_PRINTF1(_L("Sis Registry shut down")); |
|
1660 User::After(3000000); |
|
1661 |
|
1662 // Delete the "good" backup.lst (if present) |
|
1663 TInt err = util.Delete(KCacheBackupFile); |
|
1664 |
|
1665 if (err == KErrNone) |
|
1666 { |
|
1667 INFO_PRINTF2(_L("Deleted '%S'"), &KCacheBackupFile); |
|
1668 } |
|
1669 |
|
1670 // Use hashforlang_txt.dat as a corrupt backup.lst and connect to the |
|
1671 // Sis Registry. |
|
1672 util.Copy(KCorruptCacheBackupFile, KCacheBackupFile); |
|
1673 |
|
1674 INFO_PRINTF3(_L("Copied '%S' to '%S'"), &KCorruptCacheBackupFile, &KCacheBackupFile); |
|
1675 |
|
1676 INFO_PRINTF1(_L("Connecting to SisRegistry...")); |
|
1677 |
|
1678 RProcess sisRegistryServer; |
|
1679 TInt retVal = sisRegistryServer.Create(_L("SisRegistryServer"),KNullDesC); |
|
1680 |
|
1681 if (retVal == KErrNone) |
|
1682 { |
|
1683 TRequestStatus status; |
|
1684 sisRegistryServer.Logon(status); |
|
1685 sisRegistryServer.Resume(); |
|
1686 User::WaitForRequest(status); |
|
1687 |
|
1688 TExitCategoryName panicName = sisRegistryServer.ExitCategory(); |
|
1689 TPtrC name(panicName); |
|
1690 TInt reasonNumber = sisRegistryServer.ExitReason(); |
|
1691 |
|
1692 if (reasonNumber == 0 && name.Compare(_L("Kill")) == KErrNone) |
|
1693 { |
|
1694 if (util.FileExistsL(KSysBackupFileBackup)) |
|
1695 { |
|
1696 if (util.FileExistsL(KCacheBackupFile)) |
|
1697 { |
|
1698 INFO_PRINTF4(_L("'%S' and '%S' exist in System Drive: %S\\"), |
|
1699 &KSysBackupFileBackup, &KCacheBackupFile, &sysDriveName); |
|
1700 SetTestStepResult(EPass); |
|
1701 } |
|
1702 else |
|
1703 { |
|
1704 INFO_PRINTF3(_L("Expecting '%S' exist in System Drive: %S\\ but not found"), |
|
1705 &KCacheBackupFile, &sysDriveName); |
|
1706 } |
|
1707 } |
|
1708 else |
|
1709 { |
|
1710 INFO_PRINTF3(_L("Expecting '%S' exist in System Drive: %S\\ but not found"), |
|
1711 &KSysBackupFileBackup, &sysDriveName); |
|
1712 } |
|
1713 } |
|
1714 |
|
1715 INFO_PRINTF3(_L("CCorruptCacheStep - Exit Reason Number: %d Exit Reason Code: %S"), |
|
1716 reasonNumber, &name); |
|
1717 } |
|
1718 |
|
1719 sisRegistryServer.Terminate(0); |
|
1720 sisRegistryServer.Close(); |
|
1721 |
|
1722 CleanupStack::PopAndDestroy(&util); |
|
1723 |
|
1724 __UHEAP_MARKEND; |
|
1725 |
|
1726 return TestStepResult(); |
|
1727 } |
|
1728 |
|
1729 //////////////////////////////////////////////////////////////// |
|
1730 // CCorruptCacheRecoverStep - Checks to see if the Sis Registry |
|
1731 // recovers from a corrupt token cache file |
|
1732 //////////////////////////////////////////////////////////////// |
|
1733 |
|
1734 CCorruptCacheRecoverStep::CCorruptCacheRecoverStep() |
|
1735 { |
|
1736 SetTestStepName(KCorruptCacheRecoverStep); |
|
1737 } |
|
1738 |
|
1739 TVerdict CCorruptCacheRecoverStep::doTestStepL() |
|
1740 { |
|
1741 SetTestStepResult(EFail); |
|
1742 |
|
1743 RTestUtilSessionSwi util; |
|
1744 User::LeaveIfError(util.Connect()); |
|
1745 CleanupClosePushL(util); |
|
1746 TDriveUnit sysDrive (RFs::GetSystemDrive()); |
|
1747 TDriveName sysDriveName (sysDrive.Name()); |
|
1748 |
|
1749 // Close the Sis Registry and wait for 3 secs for |
|
1750 // the server to shut down |
|
1751 iSisRegistry.Close(); |
|
1752 INFO_PRINTF1(_L("Sis Registry shut down")); |
|
1753 User::After(3000000); |
|
1754 |
|
1755 // Attempt to read from the token cache file |
|
1756 RFs fs; |
|
1757 User::LeaveIfError(fs.Connect()); |
|
1758 CleanupClosePushL(fs); |
|
1759 |
|
1760 RFileReadStream stream; |
|
1761 User::LeaveIfError(stream.Open(fs, KCacheBackupFile, EFileRead | EFileShareReadersOnly)); |
|
1762 CleanupClosePushL(stream); |
|
1763 |
|
1764 INFO_PRINTF2(_L("'%S' regenerated successfully. Check by reading and internalizing..."), &KCacheBackupFile); |
|
1765 |
|
1766 RPointerArray<CSisRegistryToken> tokens; |
|
1767 CleanupResetAndDestroy<RPointerArray<CSisRegistryToken> >::PushL(tokens); |
|
1768 |
|
1769 // Will not catch a panic, but still a worthwhile check to make |
|
1770 TRAPD(err, stream.ReadUint32L()); |
|
1771 TRAP(err, InternalizePointerArrayL(tokens, stream)); |
|
1772 |
|
1773 if (err == KErrNone) |
|
1774 { |
|
1775 INFO_PRINTF2(_L("'%S' successfully read!"), &KCacheBackupFile); |
|
1776 |
|
1777 if (!util.FileExistsL(KSysBackupFileBackup)) |
|
1778 { |
|
1779 if (util.FileExistsL(KCacheBackupFile)) |
|
1780 { |
|
1781 INFO_PRINTF3(_L("'%S' exist in System Drive: %S\\"), |
|
1782 &KCacheBackupFile, &sysDriveName); |
|
1783 |
|
1784 SetTestStepResult(EPass); |
|
1785 } |
|
1786 else |
|
1787 { |
|
1788 INFO_PRINTF3(_L("Expecting '%S' exist in System Drive: %S\\ but not found"), |
|
1789 &KCacheBackupFile, &sysDriveName); |
|
1790 } |
|
1791 } |
|
1792 else |
|
1793 { |
|
1794 INFO_PRINTF3(_L("'%S' exist in System Drive: %S\\ but shouldn't"), |
|
1795 &KSysBackupFileBackup, &sysDriveName); |
|
1796 } |
|
1797 } |
|
1798 |
|
1799 CleanupStack::PopAndDestroy(4, &util); |
|
1800 |
|
1801 return TestStepResult(); |
|
1802 } |
|
1803 |
|
1804 ///////////////////////////////////////////////////////////////////// |
|
1805 // CChangeLocaleStep - Changes the locale |
|
1806 ///////////////////////////////////////////////////////////////////// |
|
1807 |
|
1808 CChangeLocaleStep::CChangeLocaleStep() |
|
1809 { |
|
1810 SetTestStepName(KChangeLocale); |
|
1811 } |
|
1812 |
|
1813 TVerdict CChangeLocaleStep::doTestStepL() |
|
1814 { |
|
1815 SetTestStepResult(EFail); |
|
1816 |
|
1817 TInt language=0; |
|
1818 if (!GetIntFromConfig(ConfigSection(), KLanguage, language)) |
|
1819 { |
|
1820 INFO_PRINTF1(_L("Missing language in config section")); |
|
1821 return EFail; |
|
1822 } |
|
1823 |
|
1824 #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL |
|
1825 _LIT(KLitLanguageLocaleDllNameBase, "elocl_lan"); |
|
1826 //Region and collation code values are hard coded, as the check, after changing the locale is made for the language only. |
|
1827 _LIT(KLitRegionLocaleDllNameBase, "elocl_reg.826"); |
|
1828 _LIT(KLitCollationLocaleDllNameBase, "elocl_col.001"); |
|
1829 _LIT(ThreeDigExt,".%03d"); |
|
1830 |
|
1831 TExtendedLocale localeDll; |
|
1832 const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); |
|
1833 TBuf<16> languageLocaleDllName(KLitLanguageLocaleDllNameBase); |
|
1834 languageLocaleDllName.AppendFormat(ThreeDigExt, language); |
|
1835 TBuf<16> regionLocaleDllName(KLitRegionLocaleDllNameBase); |
|
1836 TBuf<16> collationLocaleDllName(KLitCollationLocaleDllNameBase); |
|
1837 // Try to load the locale dll |
|
1838 TInt error=localeDll.LoadLocale(languageLocaleDllName, regionLocaleDllName, collationLocaleDllName); |
|
1839 |
|
1840 if (error==KErrNotFound) |
|
1841 { |
|
1842 // Locale dll is not found for the asked language. |
|
1843 ERR_PRINTF2(_L("Failed to find the locale dll for %d"), language); |
|
1844 } |
|
1845 |
|
1846 User::LeaveIfError(error); |
|
1847 localeDll.SaveSystemSettings(); |
|
1848 |
|
1849 #else |
|
1850 _LIT(KLitLocaleDllNameBase, "ELOCL"); |
|
1851 _LIT(TwoDigExt,".%02d"); |
|
1852 |
|
1853 RLibrary localeDll; |
|
1854 CleanupClosePushL(localeDll); |
|
1855 |
|
1856 const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); |
|
1857 TBuf<16> localeDllName(KLitLocaleDllNameBase); |
|
1858 localeDllName.AppendFormat(TwoDigExt, language); |
|
1859 |
|
1860 // Try to load the locale dll |
|
1861 TInt error=localeDll.Load(localeDllName, uidType); |
|
1862 if (error==KErrNotFound) |
|
1863 { |
|
1864 // Locale dll is not found for the asked language. |
|
1865 ERR_PRINTF2(_L("Failed to find the locale dll for %d"), language); |
|
1866 } |
|
1867 |
|
1868 User::LeaveIfError(error); |
|
1869 User::LeaveIfError(UserSvr::ChangeLocale(localeDllName)); |
|
1870 CleanupStack::PopAndDestroy(); // localeDll |
|
1871 #endif |
|
1872 |
|
1873 // Check if the device locale has changed |
|
1874 if (language == User::Language()) |
|
1875 { |
|
1876 SetTestStepResult(EPass); |
|
1877 } |
|
1878 else |
|
1879 { |
|
1880 ERR_PRINTF3(_L("Failed to change the locale to %d whereas the current locale is"), language, User::Language()); |
|
1881 } |
|
1882 |
|
1883 return TestStepResult(); |
|
1884 } |
|
1885 |
|
1886 |
|
1887 |