Update contrib.
1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\server\t_misc.cpp
23 // Solve compilation problem caused by non-English locale
24 #pragma setlocale("english")
27 GLDEF_D RTest test(_L("T_MISC"));
31 // Open, write to and read from a file
35 test.Next(_L("Open, write to and read from a file"));
36 TInt r=TheFs.SetSessionPath(gSessionPath);
39 r=file.Create(TheFs,_L("Hello.Wld"),EFileWrite);
41 r=file.Write(_L8("Hello World"),11);
45 r=file.Open(TheFs,_L("Hello.Wld"),EFileRead);
50 test(buf==_L8("Hello World"));
56 // Open and read from a file
60 test.Next(_L("Open and read from a file"));
61 TInt r=TheFs.SetSessionPath(gSessionPath);
64 r=file.Open(TheFs,_L("Hello.Wld"),EFileRead);
69 test(buf==_L8("Hello World"));
71 r=TheFs.Delete(_L("HELLO.WLD"));
77 // Create nested directories
81 test.Next(_L("Create nested directories"));
82 TInt r=TheFs.SetSessionPath(gSessionPath);
84 TheFs.ResourceCountMarkStart();
86 r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\A.B"));
87 test(r==KErrNone || r==KErrAlreadyExists);
88 r=TheFs.MkDir(_L("\\F32-TST\\RIGHT\\"));
89 test(r==KErrNone || r==KErrAlreadyExists);
91 r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\ONE\\"));
92 test(r==KErrNone || r==KErrAlreadyExists);
93 r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\TWO\\"));
94 test(r==KErrNone || r==KErrAlreadyExists);
95 r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\THREE\\"));
96 test(r==KErrNone || r==KErrAlreadyExists);
97 r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\TWO\\BOTTOM\\"));
98 test(r==KErrNone || r==KErrAlreadyExists);
100 r=TheFs.MkDirAll(_L("\\F32-TST\\RIGHT\\TOP\\MID\\BOT\\"));
101 test(r==KErrNone || r==KErrAlreadyExists);
106 // Test returned error values
110 test.Next(_L("Test returned error values"));
111 TInt r=TheFs.SetSessionPath(gSessionPath);
113 TheFs.ResourceCountMarkStart();
115 r=TheFs.MkDir(_L("\\"));
116 test(r==KErrAlreadyExists);
117 r=TheFs.MkDir(_L("\\LEFT"));
118 test(r==KErrAlreadyExists);
119 r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\"));
120 test(r==KErrAlreadyExists);
121 r=TheFs.MkDir(_L("\\F32-TST\\LEFT\\..\\NEWDIR\\"));
122 test(r==KErrBadName);
123 r=TheFs.MkDir(_L("\\F32-TST\\NEWDIR\\SUBDIR\\"));
124 test(r==KErrPathNotFound);
126 r=TheFs.RmDir(_L("\\"));
128 r=TheFs.RmDir(_L("\\PROG"));
130 r=TheFs.RmDir(_L("\\F32-TST\\"));
135 r=dir.Open(TheFs,_L("V:\\asdf"),KEntryAttNormal);
136 test(r==KErrNone || r==KErrNotReady || r==KErrNotFound);
139 r=dir.Open(TheFs,_L("L:\\asdf"),KEntryAttNormal);
140 test(r==KErrNone || r==KErrNotReady || r==KErrNotFound);
144 r=TheFs.Entry(_L("z:\\NOTEXiSTS\\file.txt"),entry);
145 test(r==KErrPathNotFound);
146 r=TheFs.Entry(_L("z:\\NOTEXiSTS\\"),entry);
147 test(r==KErrNotFound);
148 r=TheFs.Entry(_L("z:\\SYSTEM\\"),entry);
150 r=TheFs.Entry(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("z:\\SYS\\BIN\\ESHELL.EXE"):_L("z:\\SYSTEM\\BIN\\ESHELL.EXE"),entry);
153 r=dir.Open(TheFs,_L("\\*"),NULL);
156 r=dir.Read(dirEntry);
157 test(r==KErrNone || r==KErrEof);
159 test.Printf(_L("%S\n"),&dirEntry.iName);
162 r=dir.Open(TheFs,_L("A:\\*"),NULL);
163 test(r==KErrNotReady || r==KErrNone);
169 // Read files directly from the rom
173 test.Next(_L("Read Files directly from the rom"));
177 _LIT(KTFileCpp, "Z:\\test\\T_FILE.CPP");
178 _LIT(KTFsrvCpp, "Z:\\test\\T_FSRV.CPP");
180 if ( TheFs.IsFileInRom(KTFileCpp) != NULL && TheFs.IsFileInRom(KTFsrvCpp) != NULL )
183 r=f.Open(TheFs,KTFileCpp,EFileRead);
185 r=f.Seek(ESeekAddress,pos);
186 TText8* ptrPos=*(TText8**)&pos;
191 test(readBuf.Length()==readBuf.MaxLength());
192 TPtrC8 memBuf(ptrPos,readBuf.Length());
193 test(memBuf==readBuf);
197 r=f.Seek(ESeekStart,pos);
199 readBuf.SetLength(0);
202 test(readBuf.Length()==readBuf.MaxLength());
203 memBuf.Set(ptrPos,readBuf.Length());
204 test(memBuf==readBuf);
208 r=f2.Open(TheFs,KTFsrvCpp,EFileRead);
211 r=f2.Seek(ESeekAddress,pos);
212 ptrPos=*(TText8**)&pos;
214 readBuf.SetLength(0);
216 r=f2.Seek(ESeekStart,pos);
220 test(readBuf.Length()==readBuf.MaxLength());
221 memBuf.Set(ptrPos,readBuf.Length());
222 test(memBuf==readBuf);
226 r=f2.Seek(ESeekStart,pos);
228 readBuf.SetLength(0);
231 test(readBuf.Length()==readBuf.MaxLength());
232 memBuf.Set(ptrPos,readBuf.Length());
233 test(memBuf==readBuf);
236 r=f.Seek(ESeekAddress,pos);
237 ptrPos=*(TText8**)&pos;
239 readBuf.SetLength(0);
241 r=f.Seek(ESeekStart,pos);
245 test(readBuf.Length()==readBuf.MaxLength());
246 memBuf.Set(ptrPos,readBuf.Length());
247 test(memBuf==readBuf);
251 r=f.Seek(ESeekStart,pos);
253 readBuf.SetLength(0);
256 test(readBuf.Length()==readBuf.MaxLength());
257 memBuf.Set(ptrPos,readBuf.Length());
258 test(memBuf==readBuf);
267 // Test rom return values
270 test.Next(_L("Test rom return values"));
273 TInt r=f.Replace(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead);
274 test(r==KErrAccessDenied);
275 r=f.Create(TheFs,_L("Z:\\Test\\newT_Fsrv.Cpp"),EFileRead);
276 test(r==KErrAccessDenied);
277 r=f.Open(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead);
280 r=f.Open(TheFs,_L("Z:\\Test\\T_Fsrv.Cpp"),EFileRead|EFileWrite);
281 test(r==KErrAccessDenied);
290 test.Next(_L("Test cache updated when writing to a file"));
291 TUidType uid1(TUid::Uid(1),TUid::Uid(2),TUid::Uid(3));
292 TBuf8<32> contents1=_L8("asdf asdf asdf");
293 TBuf<32> file1=_L("\\TMISC\\CACHE.FILE");
294 MakeFile(file1,uid1,contents1);
297 TInt r=TheFs.Entry(file1,entry);
299 test(entry.iType==uid1);
301 TUidType uid2(TUid::Uid(4),TUid::Uid(5),TUid::Uid(6));
302 TCheckedUid checkedUid(uid2);
303 TPtrC8 uidData((TUint8*)&checkedUid,sizeof(TCheckedUid));
305 r=f.Open(TheFs,file1,EFileRead|EFileWrite);
312 r=TheFs.Entry(file1,entry);
314 test(entry.iType==uid2);
317 r=TheFs.Entry(file1,entry);
319 test(entry.iType==uid2);
327 test.Next(_L("Test RFs::IsValidName(TDesC)"));
329 // tests calling IsValidName() with invalid name as first call to session
330 // see defect EXT-57KH9K
331 _LIT(KInvalidName, "test\\i1.jpg");
333 test(KErrNone==fs.Connect());
334 test(fs.IsValidName(KInvalidName)==EFalse);
337 test(TheFs.IsValidName(_L("*"))==EFalse);
338 test(TheFs.IsValidName(_L("?"))==EFalse);
339 test(TheFs.IsValidName(_L(">"))==EFalse);
340 test(TheFs.IsValidName(_L("<"))==EFalse);
341 test(TheFs.IsValidName(_L(":"))==EFalse);
342 test(TheFs.IsValidName(_L("\""))==EFalse);
343 test(TheFs.IsValidName(_L("/"))==EFalse);
344 test(TheFs.IsValidName(_L("|"))==EFalse);
345 test(TheFs.IsValidName(_L("\\"))==EFalse);
347 test(TheFs.IsValidName(_L("xx*yy"))==EFalse);
348 test(TheFs.IsValidName(_L("xx?yy"))==EFalse);
349 test(TheFs.IsValidName(_L("xx>yy"))==EFalse);
350 test(TheFs.IsValidName(_L("xx<yy"))==EFalse);
351 test(TheFs.IsValidName(_L("xx:yy"))==EFalse);
352 test(TheFs.IsValidName(_L("xx\"yy"))==EFalse);
353 test(TheFs.IsValidName(_L("xx/yy"))==EFalse);
354 test(TheFs.IsValidName(_L("xx|yy"))==EFalse);
356 test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"))==EFalse);
357 test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"))==EFalse);
358 test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"))==EFalse);
359 test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"))==EFalse);
360 test(TheFs.IsValidName(_L("C:\\:\\group\\release.txt"))==EFalse);
361 test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"))==EFalse);
362 test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"))==EFalse);
363 test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"))==EFalse);
365 test(TheFs.IsValidName(_L(""))==EFalse); // must be a name or extension present
366 test(TheFs.IsValidName(_L(".ext")));
367 test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"))==EFalse);
368 test(TheFs.IsValidName(_L("\\"))==EFalse);
370 test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"))); // Valid names
371 test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"))); // Valid names
372 test(TheFs.IsValidName(_L("\'"))); // Valid names
374 test.Next(_L("Test RFs::IsValidName(TDesC, TDes) overload"));
377 test(TheFs.IsValidName(_L("*"),testChar)==EFalse);
379 test(TheFs.IsValidName(_L("?"),testChar)==EFalse);
381 test(TheFs.IsValidName(_L(">"),testChar)==EFalse);
383 test(TheFs.IsValidName(_L("<"),testChar)==EFalse);
385 test(TheFs.IsValidName(_L(":"),testChar)==EFalse);
387 test(TheFs.IsValidName(_L("\""),testChar)==EFalse);
388 test(testChar=='\"'); // Tests that " is illegal
389 test(TheFs.IsValidName(_L("/"),testChar)==EFalse);
391 test(TheFs.IsValidName(_L("|"),testChar)==EFalse);
393 test(TheFs.IsValidName(_L("\\"),testChar)==EFalse);
396 test(TheFs.IsValidName(_L("xx*yy"),testChar)==EFalse);
398 test(TheFs.IsValidName(_L("xx?yy"),testChar)==EFalse);
400 test(TheFs.IsValidName(_L("xx>yy"),testChar)==EFalse);
402 test(TheFs.IsValidName(_L("xx<yy"),testChar)==EFalse);
404 test(TheFs.IsValidName(_L("xx:yy"),testChar)==EFalse);
406 test(TheFs.IsValidName(_L("xx\"yy"),testChar)==EFalse);
407 test(testChar=='\"'); // Tests that " is illegal
408 test(TheFs.IsValidName(_L("xx/yy"),testChar)==EFalse);
410 test(TheFs.IsValidName(_L("xx|yy"),testChar)==EFalse);
413 test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"),testChar)==EFalse);
415 test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"),testChar)==EFalse);
417 test(TheFs.IsValidName(_L("C:\\..\\group\\release.txt"),testChar)==EFalse);
418 test(testChar=='.'); // Only one "." returned however many are in filename
419 test(TheFs.IsValidName(_L("C:\\.\\group\\release.txt"),testChar)==EFalse);
421 test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"),testChar)==EFalse);
423 test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"),testChar)==EFalse);
425 test(TheFs.IsValidName(_L("C:\\HelloWorld\\:\\group\\release.txt"),testChar)==EFalse);
429 test(TheFs.IsValidName(_L("C::\\group\\release.txt"),testChar)==EFalse);
431 test(TheFs.IsValidName(_L(">\\group\\release.txt"),testChar)==EFalse);
433 test(TheFs.IsValidName(_L("C|group\\release.txt"),testChar)==EFalse);
435 test(TheFs.IsValidName(_L("C\\|\\group\\release.txt"),testChar)==EFalse);
438 test(TheFs.IsValidName(_L("\\>"),testChar)==EFalse);
440 test(TheFs.IsValidName(_L("C:\\|group\\release.txt"),testChar)==EFalse);
443 test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"),testChar)==EFalse);
444 test(testChar=='\"');
445 test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"),testChar)==EFalse);
447 test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"),testChar)==EFalse);
449 test(TheFs.IsValidName(_L("C:\\ \\group\\release.txt"),testChar)==EFalse); // must be a name or extension present
452 // Test that \ is not allowed in filenames
454 filename=_L("C:\\HelloWorld\\\\\\group\\release.txt");
455 TPtr pChar(&testChar,sizeof(TText),sizeof(TText));
456 test(TheFs.IsValidName(filename,testChar)==EFalse);
457 test(pChar.Find(_L("\\"))!=KErrNotFound);
458 filename=_L("C:\\\\\\group\\release.txt");
459 test(TheFs.IsValidName(filename,testChar)==EFalse);
460 test(pChar.Find(_L("\\"))!=KErrNotFound);
461 filename=_L("C:\\Hello World\\group\\release.txt");
462 filename[8]=KPathDelimiter; // Makes C:\\Hello World\\group\\release.txt
463 test(TheFs.IsValidName(filename,testChar));
464 filename=_L("C:\\HelloWorld\\::\\group\\release.txt");
465 test(TheFs.IsValidName(filename,testChar)==EFalse);
466 test(pChar.Find(_L(":"))!=KErrNotFound);
468 filename=_L("C:\\>>\\group\\release.txt");
469 test(TheFs.IsValidName(filename,testChar)==EFalse);
470 test(pChar.Find(_L(">"))!=KErrNotFound);
472 test(TheFs.IsValidName(_L(""),testChar)==EFalse); // Must be a name
474 test(TheFs.IsValidName(_L(".ext"),testChar));
475 test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"),testChar)==EFalse);
476 test(testChar==' '); // Must be a name else testChar is set to blank
477 test(TheFs.IsValidName(_L("C:\\asdf.blarg"),testChar));
479 test(TheFs.IsValidName(_L("C:\\asdf..blarg\\"),testChar)==EFalse);
480 test(testChar==' '); // Must be a name else testChar is set to blank
481 test(TheFs.IsValidName(_L("C:\\asdf..blarg"),testChar));
483 test(TheFs.IsValidName(_L("\\"),testChar)==EFalse);
486 // Test multiple evil characters - parsing occurs from right to left
487 // except that wildcarded characters take priority and are picked out first
488 test(TheFs.IsValidName(_L("abc>def|ghi?jkl:mno<pqr*stu"),testChar)==EFalse);
490 test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno?pqr"),testChar)==EFalse);
492 test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),testChar)==EFalse);
494 test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),testChar)==EFalse);
496 test(TheFs.IsValidName(_L("abc>def|ghi"),testChar)==EFalse);
498 test(TheFs.IsValidName(_L("abc>def"),testChar)==EFalse);
501 test(!TheFs.IsValidName(_L("C:\\v123456.."),testChar)); // Valid name
502 test(TheFs.IsValidName(_L("abc"),testChar)); // Valid name
503 test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),testChar)); // Valid name
504 test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),testChar)); // Valid name
505 test(TheFs.IsValidName(_L("\'"),testChar)); // Valid name
507 //PDEF133084: The wild character in the extension was not being detected.
508 _LIT( KTestString, "E:\\My Videos\\Downloads\\1\\1\\Name.3gp?" );
511 TBool validName( EFalse );
513 TInt badCharLoc( KErrNotFound );
515 while ( ! validName )
517 validName = TheFs.IsValidName( path, badChar );
521 badCharLoc = path.LocateReverse( badChar );
523 if ( KErrNotFound != badCharLoc )
525 path[badCharLoc] = '_';
537 test.Next(_L("Test RFs::IsFileInRom"));
539 CFileMan* fMan=CFileMan::NewL(TheFs);
540 TInt r=fMan->Copy(_L("Z:\\TEST\\T_FILE.CPP"),_L("C:\\T_FILE.CPP"));
541 test(r==KErrNone || r==KErrAccessDenied);
543 TUint8* addr=TheFs.IsFileInRom(_L("C:\\ESHELL.EXE"));
545 addr=TheFs.IsFileInRom(_L("Z:\\TEST\\T_FILE.CPP"));
549 TPtrC8 startOfFile(addr,12);
550 test(startOfFile==_L8("// Copyright"));
558 LOCAL_C void Test10()
564 test.Next(_L("Test Drive Names"));
567 for(i=0;i<KMaxDrives;i++)
569 TInt r=TheFs.GetDriveName(i,driveName);
571 if (driveName.Length())
572 test.Printf(_L("Default name of %c: == %S\n"),'A'+i,&driveName);
575 TBuf<64> drive0=_L("Dilbert");
576 TBuf<64> drive4=_L("Dogbert");
577 TBuf<64> drive17=_L("Flibble");
578 TBuf<64> drive25=_L("RAMDRIVE");
579 TInt r=TheFs.SetDriveName(0,drive0);
581 r=TheFs.SetDriveName(4,drive4);
583 r=TheFs.SetDriveName(17,drive17);
585 r=TheFs.SetDriveName(25,drive25);
588 r=TheFs.GetDriveName(0,driveName);
590 test(driveName==drive0);
591 r=TheFs.GetDriveName(4,driveName);
593 test(driveName==drive4);
594 r=TheFs.GetDriveName(17,driveName);
596 test(driveName==drive17);
597 r=TheFs.GetDriveName(25,driveName);
599 test(driveName==drive25);
601 drive0=_L("askdjflsdfourewoqiuroiuaksjdvx,cvsdhwjhjhalsjhfshfkjhslj");
602 r=TheFs.SetDriveName(0,drive0);
604 r=TheFs.GetDriveName(0,driveName);
606 test(driveName==drive0);
608 // Test with illegal characters in drive name
609 drive0=_L("Dil>bert");
610 drive4=_L("Dog?bert");
611 drive17=_L("Fli*bble");
612 drive25=_L("RAMD//RIVE");
614 r=TheFs.SetDriveName(0,drive0);
615 test(r==KErrBadName);
616 r=TheFs.SetDriveName(4,drive4);
617 test(r==KErrBadName);
618 r=TheFs.SetDriveName(17,drive17);
619 test(r==KErrBadName);
620 r=TheFs.SetDriveName(25,drive25);
621 test(r==KErrBadName);
623 // Test that it is OK to set the name to no characters
630 r=TheFs.SetDriveName(0,drive0);
632 r=TheFs.SetDriveName(4,drive4);
634 r=TheFs.SetDriveName(17,drive17);
636 r=TheFs.SetDriveName(25,drive25);
639 r=TheFs.GetDriveName(0,driveName);
641 test(driveName==drive0);
642 r=TheFs.GetDriveName(4,driveName);
644 test(driveName==drive4);
645 r=TheFs.GetDriveName(17,driveName);
647 test(driveName==drive17);
648 r=TheFs.GetDriveName(25,driveName);
650 test(driveName==drive25);
655 LOCAL_C void Test11()
657 // Miscellaneous tests
661 test.Next(_L("Miscellaneous tests"));
663 TInt r=TheFs.Volume(vol);
664 test.Printf(_L("VolumeName = %S\n"),&vol.iName);
666 r=TheFs.RmDir(_L("\\asdfasdf.\\"));
667 test(r==KErrBadName);
668 r=TheFs.MkDir(_L("\\asdfasdf.\\"));
669 test(r==KErrBadName);
672 LOCAL_C void Test12()
674 // Test SetNotifyUser and GetNotifyUser
678 test.Next(_L("Test Set and GetNotifyUser"));
679 TBool notifyState=TheFs.GetNotifyUser();
682 TheFs.SetNotifyUser(notifyState);
683 notifyState=TheFs.GetNotifyUser();
684 test(notifyState==EFalse);
686 TheFs.SetNotifyUser(notifyState);
687 notifyState=TheFs.GetNotifyUser();
691 LOCAL_C void Test13()
693 // Test return values from RFs::Volume on cf-cards
697 test.Next(_L("Test RFs::Volume"));
699 TInt r=TheFs.Volume(vol,EDriveB);
700 test(r==KErrNotReady || r==KErrNone || KErrPathNotFound);
701 test.Printf(_L("RFs::Volume EDriveB returned %d\n"),r);
703 r=TheFs.Volume(vol,EDriveC);
704 test(r==KErrNotReady || r==KErrNone || KErrPathNotFound);
705 test.Printf(_L("RFs::Volume EDriveC returned %d\n"),r);
707 r=TheFs.Volume(vol,EDriveD);
708 test(r==KErrNotReady || r==KErrNone || KErrPathNotFound);
709 test.Printf(_L("RFs::Volume EDriveD returned %d\n"),r);
711 r=TheFs.Volume(vol,EDriveE);
712 test(r==KErrNotReady || r==KErrNone || KErrPathNotFound);
713 test.Printf(_L("RFs::Volume EDriveE returned %d\n"),r);
715 r=TheFs.Volume(vol,EDriveF);
716 test(r==KErrNotReady || r==KErrNone || KErrPathNotFound);
717 test.Printf(_L("RFs::Volume EDriveF returned %d\n"),r);
721 void DoTest14(TInt aDrvNum);
722 TInt CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize);
723 TInt CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize);
724 TBool CheckFileContents(RFs& aFs, const TDesC& aFileName);
725 TBool CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr=0);
728 Testing unallocated data initialization vulnerability in RFile
729 This test is performed on RAM drives and non-removable media that supports DeleteNotify (KMediaAttDeleteNotify flag)
732 LOCAL_C void Test14()
736 test.Next(_L("Testing unallocated data initialization vulnerability in RFile"));
738 TDriveList driveList;
739 TDriveInfo driveInfo;
741 //-- 1. get drives list
742 nRes=TheFs.DriveList(driveList);
743 test(nRes == KErrNone);
745 //-- 2. walk through all drives, performing the test only on suitable ones
746 for (TInt drvNum=0; drvNum<KMaxDrives; ++drvNum)
748 if(!driveList[drvNum])
749 continue; //-- skip unexisting drive
752 test(TheFs.Drive(driveInfo, drvNum) == KErrNone);
754 //-- select a suitable drive for the testing. It shall be RAM drive, of FLASH but not removable
755 //-- and not read only, if it is FLASH, it shall support "Delete Notify" facility
756 switch(driveInfo.iType)
764 case EMediaNANDFlash:
765 if(driveInfo.iMediaAtt & KMediaAttDeleteNotify)
766 break; //-- this type of media shall support DeleteNotify flag, otherwise this test is inconsistent
769 //break; //unreacable
773 }//switch(driveInfo.iType)
775 if (driveInfo.iDriveAtt & KDriveAttSubsted)
777 // skip subst drives.
781 TBool readOnly = driveInfo.iMediaAtt & KMediaAttWriteProtected;
783 continue; //-- nothing to do, can't create any file etc.
785 //-- skip test on the emulator's C: drive, doesn't make any sense because
786 //-- in this case we deal with WIN32 API and filesystem.
790 test.Printf(_L("Skipping test on emulator's C: drive\n"));
797 }// for (TInt drvNum=0; ...
801 //--------------------------------------------------------
804 Actually perform the test on a drive aDrvNum.
805 @param aDrvNum drive number
807 void DoTest14(TInt aDrvNum)
811 fileName.Format(_L("Testing drive %c:"), 'A'+aDrvNum);
814 const TInt KFileSize = 0x1000; //-- size of the files t be created
817 fileName.Format(_L("%c:\\TestFile.bin"), aDrvNum+'A');
818 TheFs.Delete(fileName); //-- just in case
820 //==============================
822 //== Create an empty file; AllocateSingleClusterL, ExtendClusterListL will be involved.
823 //== Check that the file doesn't contain any meaningful information
824 //==============================
825 test.Printf(_L("Testing scenario 1\n"));
827 //-- 1. create an empty file
828 nRes = CreateEmptyFile(TheFs, fileName, KFileSize);
829 test(nRes == KErrNone);
831 //-- 1.1 check that this file doesn't contain illegitimate information.
832 nRes = CheckFileContents(TheFs, fileName);
833 test(nRes == KErrNone);
835 //-- 1.2 delete the empty file
836 nRes = TheFs.Delete(fileName);
837 test(nRes == KErrNone);
839 //==============================
841 //== Create file, filling it with some pattern.
842 //== Delete this file, FreeClusterListL() will be involved.
843 //== Create an empty file supposedly of the place of just deleted one
844 //== Check that the file doesn't contain any meaningful information
845 //==============================
846 test.Printf(_L("Testing scenario 2\n"));
848 //-- 2. create file filled with some data pattern
849 nRes = CreateStuffedFile(TheFs, fileName, KFileSize);
850 test(nRes == KErrNone);
852 //-- 2.1 delete this file
853 TheFs.Delete(fileName);
855 //-- 2.1 create an empty file on the place of just deleted one (hopefully)
856 nRes = CreateEmptyFile(TheFs, fileName, KFileSize);
857 test(nRes == KErrNone);
859 //-- 2.2 check that this file doesn't contain illegitimate information.
860 nRes = CheckFileContents(TheFs, fileName);
861 test(nRes == KErrNone);
863 //-- 2.3 delete this file
864 TheFs.Delete(fileName);
868 LOCAL_C void Test15()
873 test.Next(_L("Test RFs::IsValidName(TDesC& ,RFs::TNameValidParam& )"));
874 TBool useDefaultSessionPath = EFalse;
875 //tests under this loop are run twice
876 //first, when the sessionPath is not used.
877 //second, when the sessionPath is used.
878 for(TInt i = 0; i<2; i++)
880 RFs::TNameValidParam param(useDefaultSessionPath);
881 test(TheFs.IsValidName(_L("*"),param)==EFalse);
882 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
883 test(param.InvalidCharPos() == 1);
885 test(TheFs.IsValidName(_L("?"),param)==EFalse);
886 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
887 test(param.InvalidCharPos() == 1);
889 test(TheFs.IsValidName(_L(">"),param)==EFalse);
890 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
891 test(param.InvalidCharPos() == 1);
893 test(TheFs.IsValidName(_L("<"),param)==EFalse);
894 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
895 test(param.InvalidCharPos() == 1);
897 test(TheFs.IsValidName(_L(":"),param)==EFalse);
898 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
899 test(param.InvalidCharPos() == 1);
901 test(TheFs.IsValidName(_L("\""),param)==EFalse);
902 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
903 test(param.InvalidCharPos() == 1);
905 test(TheFs.IsValidName(_L("/"),param)==EFalse);
906 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
907 test(param.InvalidCharPos() == 1);
909 test(TheFs.IsValidName(_L("|"),param)==EFalse);
910 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
911 test(param.InvalidCharPos() == 1);
913 test(TheFs.IsValidName(_L("xx*yy"),param)==EFalse);
914 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
915 test(param.InvalidCharPos() == 3);
917 test(TheFs.IsValidName(_L("xx?yy"),param)==EFalse);
918 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
919 test(param.InvalidCharPos() == 3);
921 test(TheFs.IsValidName(_L("xx>yy"),param)==EFalse);
922 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
923 test(param.InvalidCharPos() == 3);
925 test(TheFs.IsValidName(_L("xx<yy"),param)==EFalse);
926 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
927 test(param.InvalidCharPos() == 3);
929 test(TheFs.IsValidName(_L("xx:yy"),param)==EFalse);
930 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
931 test(param.InvalidCharPos() == 3);
933 test(TheFs.IsValidName(_L("xx\"yy"),param)==EFalse);
934 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
935 test(param.InvalidCharPos() == 3);
937 test(TheFs.IsValidName(_L("xx/yy"),param)==EFalse);
938 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
939 test(param.InvalidCharPos() == 3);
941 test(TheFs.IsValidName(_L("xx|yy"),param)==EFalse);
942 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
943 test(param.InvalidCharPos() == 3);
945 test(TheFs.IsValidName(_L("C:\\*\\group\\release.txt"),param)==EFalse);
946 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
947 test(param.InvalidCharPos() == 4);
949 test(TheFs.IsValidName(_L("C:\\?\\group\\release.txt"),param)==EFalse);
950 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
951 test(param.InvalidCharPos() == 4);
953 test(TheFs.IsValidName(_L("C:\\..\\group\\release.txt"),param)==EFalse);
954 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
955 test(param.InvalidCharPos() == 4);
957 test(TheFs.IsValidName(_L("C:\\.\\group\\release.txt"),param)==EFalse);
958 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
959 test(param.InvalidCharPos() == 4);
961 test(TheFs.IsValidName(_L("C:\\>\\group\\release.txt"),param)==EFalse);
962 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
963 test(param.InvalidCharPos() == 4);
965 test(TheFs.IsValidName(_L("C:\\<\\group\\release.txt"),param)==EFalse);
966 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
967 test(param.InvalidCharPos() == 4);
969 test(TheFs.IsValidName(_L("C:\\HelloWorld\\:\\group\\release.txt"),param)==EFalse);
970 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
971 test(param.InvalidCharPos() == 15);
973 test(TheFs.IsValidName(_L("C::\\group\\release.txt"),param)==EFalse);
974 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
975 test(param.InvalidCharPos() == 3);
977 test(TheFs.IsValidName(_L(">\\group\\release.txt"),param)==EFalse);
978 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
979 test(param.InvalidCharPos() == 1);
981 test(TheFs.IsValidName(_L("C|group\\release.txt"),param)==EFalse);
982 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
983 test(param.InvalidCharPos() == 2);
985 test(TheFs.IsValidName(_L("C\\|\\group\\release.txt"),param)==EFalse);
986 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
987 test(param.InvalidCharPos() == 3);
989 test(TheFs.IsValidName(_L("\\>"),param)==EFalse);
990 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
991 test(param.InvalidCharPos() == 2);
993 test(TheFs.IsValidName(_L("C:\\|group\\release.txt"),param)==EFalse);
994 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
995 test(param.InvalidCharPos() == 4);
997 test(TheFs.IsValidName(_L("C:\\\"\\group\\release.txt"),param)==EFalse);
998 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
999 test(param.InvalidCharPos() == 4);
1001 test(TheFs.IsValidName(_L("C:\\/\\group\\release.txt"),param)==EFalse);
1002 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1003 test(param.InvalidCharPos() == 4);
1005 test(TheFs.IsValidName(_L("C:\\|\\group\\release.txt"),param)==EFalse);
1006 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1007 test(param.InvalidCharPos() == 4);
1009 test(TheFs.IsValidName(_L("C:\\ \\group\\release.txt"),param)==EFalse);//intermediate directory names cannot be blank
1010 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName);
1012 // Test that \ is not allowed in filenames
1014 filename=_L("C:\\HelloWorld\\\\\\group\\release.txt");
1016 test(TheFs.IsValidName(filename,param)==EFalse);
1017 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1018 test(param.InvalidCharPos() == 22);
1020 filename=_L("C:\\\\\\group\\release.txt");
1021 test(TheFs.IsValidName(filename,param)==EFalse);
1022 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1023 test(param.InvalidCharPos() == 11);
1025 filename=_L("C:\\Hello World\\group\\release.txt");
1026 filename[8]=KPathDelimiter;
1027 test(TheFs.IsValidName(filename,param));
1028 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1030 filename=_L("C:\\HelloWorld\\::\\group\\release.txt");
1031 test(TheFs.IsValidName(filename,param)==EFalse);
1032 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1033 test(param.InvalidCharPos() == 16);
1035 filename=_L("C:\\>>\\group\\release.txt");
1036 test(TheFs.IsValidName(filename,param)==EFalse);
1037 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1038 test(param.InvalidCharPos() == 5);
1040 test(TheFs.IsValidName(_L(""),param)==EFalse); // Must be a name
1041 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName);
1043 test(TheFs.IsValidName(_L(".ext"),param));
1044 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1046 test(TheFs.IsValidName(_L("C:\\asdf.blarg"),param));
1047 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1049 test(TheFs.IsValidName(_L("C:\\asdf..blarg"),param));
1050 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1052 // Test multiple evil characters - parsing occurs from right to left
1053 // except that wildcarded characters take priority and are picked out first
1055 test(TheFs.IsValidName(_L("abc>def|ghi?jkl:mno<pqr*stu"),param)==EFalse);
1056 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1057 test(param.InvalidCharPos() == 24);
1059 test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno?pqr"),param)==EFalse);
1060 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1061 test(param.InvalidCharPos() == 20);
1063 test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),param)==EFalse);
1064 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1065 test(param.InvalidCharPos() == 16);
1067 test(TheFs.IsValidName(_L("abc>def|ghi<jkl:mno"),param)==EFalse);
1068 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1069 test(param.InvalidCharPos() == 16);
1071 test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),param)==EFalse);
1072 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1073 test(param.InvalidCharPos() == 12);
1075 test(TheFs.IsValidName(_L("abc>def|ghi<jkl"),param)==EFalse);
1076 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1077 test(param.InvalidCharPos() == 12);
1079 test(TheFs.IsValidName(_L("abc>def|ghi"),param)==EFalse);
1080 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1081 test(param.InvalidCharPos() == 8);
1083 test(TheFs.IsValidName(_L("abc>def|ghi"),param)==EFalse);
1084 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1085 test(param.InvalidCharPos() == 8);
1087 test(TheFs.IsValidName(_L("abc>def"),param)==EFalse);
1088 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1089 test(param.InvalidCharPos() == 4);
1091 test(TheFs.IsValidName(_L("abc>def"),param)==EFalse);
1092 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1093 test(param.InvalidCharPos() == 4);
1095 test(!TheFs.IsValidName(_L("C:\\v123456.."),param));
1096 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1097 test(param.InvalidCharPos() == 11);
1099 test(!TheFs.IsValidName(_L("C:\\v123456.."),param));
1100 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadCharacter);
1101 test(param.InvalidCharPos() == 11);
1103 test(TheFs.IsValidName(_L("abc"),param)); // Valid name
1104 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1106 test(TheFs.IsValidName(_L("abc"),param)); // Valid name
1107 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1109 test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),param)); // Valid name
1110 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1112 test(TheFs.IsValidName(_L("as(){}@~#;!\xA3$%^&()df.blarg"),param)); // Valid name
1113 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1115 test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),param)); // Valid name
1116 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1118 test(TheFs.IsValidName(_L("C:\\asdf.blarg\\asdf.blarg"),param)); // Valid name
1119 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1121 test(TheFs.IsValidName(_L("\'"),param)); // Valid name
1122 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1124 test(TheFs.IsValidName(_L("\'"),param)); // Valid name
1125 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1127 //testing directory names
1128 test(TheFs.IsValidName(_L("\\"),param));
1129 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name
1131 test(TheFs.IsValidName(_L("C:\\asdf.blarg\\"),param));
1132 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name
1135 test(TheFs.IsValidName(_L("C:\\asdf..blarg\\"),param));
1136 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone); // Valid Name
1138 test(TheFs.IsValidName(_L("file1.txt\\\\"),param) == EFalse);
1139 test(param.ErrorCode() == RFs::TNameValidParam::ErrBadName);
1141 // test name which exceeds KMaxFileName only on prepending the session path
1142 _LIT(KNameLength250, "AAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAABBBBBBBBBBAAAAAAAAAA");
1143 if(useDefaultSessionPath)
1145 test(TheFs.IsValidName(KNameLength250, param)==EFalse);
1146 test(param.ErrorCode() == RFs::TNameValidParam::ErrNameTooLong);
1151 test(TheFs.IsValidName(KNameLength250, param));
1152 test(param.ErrorCode() == RFs::TNameValidParam::ErrNone);
1154 useDefaultSessionPath = ETrue;
1160 void TestGetMediaSerialNumber()
1162 test.Next(_L("Test RFs::GetMediaSerialNumber"));
1164 TInt r = TheFs.CharToDrive(gDriveToTest,theDrive);
1165 test(r == KErrNone);
1166 TMediaSerialNumber serNum;
1167 r = TheFs.GetMediaSerialNumber(serNum, theDrive);
1168 if (r) test.Printf(_L("RFs::GetMediaSerialNumber returned error %d"), r);
1169 test(r == KErrNotSupported || r == KErrNotReady || r == KErrNone);
1170 if (r == KErrNotSupported)
1172 test.Printf(_L("MediaSerialNumber: Not Supported\n"));
1176 test.Printf(_L("MediaSerialNumber: length=%d\n"), serNum.Length());
1178 _LIT(KNumberString, "%02X");
1179 _LIT(KNewLine, "\n");
1181 for (i = 0; i < serNum.Length(); i++)
1183 str.AppendFormat(KNumberString, serNum[i]);
1186 str.Append(KNewLine);
1187 test.Printf(_L("%S"), &str);
1193 test.Printf(KNewLine);
1199 //--------------------------------------------------------
1202 Create an empty file of specified size.
1203 @param aFs ref. to the FS
1204 @param aFileName name of the file
1205 @param aFileSize size of the file to be created
1206 @return KErrNone on success, system-wide error code otherwise
1208 TInt CreateEmptyFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize)
1213 nRes = file.Create(aFs, aFileName, EFileRead|EFileWrite);
1214 if(nRes != KErrNone)
1217 nRes = file.SetSize(aFileSize);
1218 if(nRes != KErrNone)
1226 //--------------------------------------------------------
1229 Create a file of specified size filled with some data pattern.
1230 @param aFs ref. to the FS
1231 @param aFileName name of the file
1232 @param aFileSize size of the file to be created
1233 @return KErrNone on success, system-wide error code otherwise
1235 TInt CreateStuffedFile(RFs& aFs, const TDesC& aFileName, TUint aFileSize)
1240 //-- create a buffer with some data
1241 const TUint KBufLength = 0x100;
1242 TBuf8<KBufLength> buffer;
1243 buffer.SetLength(KBufLength);
1247 for(i = 0; i < KBufLength; i++)
1248 buffer[i] = static_cast<TUint8> (i) ;
1251 nRes = file.Create(aFs, aFileName, EFileRead|EFileWrite);
1252 if(nRes != KErrNone)
1255 const TUint n1 = aFileSize / KBufLength;
1256 const TUint n2 = aFileSize % KBufLength;
1258 //-- fill the file with the data from buffer
1261 nRes = file.Write(buffer);
1262 if(nRes != KErrNone)
1268 nRes = file.Write(buffer, n2); //-- write the rest of the data
1269 if(nRes != KErrNone)
1278 //--------------------------------------------------------
1281 Check if the specified file contains illegitimate information i.e. something different from 0x00, 0xff, 0x03, 0xcc
1283 @param aFs ref. to the FS
1284 @param aFileName name of the file
1285 @return KErrNone on success, KErrCorrupt otherwise
1287 TInt CheckFileContents(RFs& aFs, const TDesC& aFileName)
1289 TInt nRes = KErrNone;
1292 const TInt KBufLength = 0x100;
1293 TBuf8<KBufLength> buffer;
1294 buffer.SetLength(0);
1297 nRes = file.Open(aFs, aFileName, EFileRead);
1298 test(nRes == KErrNone);
1300 //-- check file contents
1304 //-- read data from the file into the buffer
1305 nRes = file.Read(buffer);
1306 test(nRes == KErrNone);
1308 if(buffer.Length() == 0)
1310 nRes = KErrNone; //-- read all the file, no illegitimate information found
1314 //-- check if the buffer contains only allowed data (RAM page initialisation data, etc. e.g. 0x00, 0xff, 0x03, 0xcc)
1315 if(!CheckBufferContents(buffer, nFilePos))
1317 test.Printf(_L("\nCheckFileContents failed ! The file contains illegitimate information!\n"));
1318 nRes = KErrCorrupt; //-- indicate that the read buffer contains illegitimate information
1319 break; //-- comment this out if you need a full dump of the file
1322 nFilePos+=buffer.Length();
1329 //--------------------------------------------------------
1332 Check if the buffer contains illegitimate information i.e. something different from 0x00, 0xff, 0x03, 0xcc
1334 @param aBuffer buffer descriptor to check
1335 @param aPrintBaseAddr dump base address, used for dumping buffer only
1336 @return ETrue on success
1338 TBool CheckBufferContents(const TDesC8& aBuffer, TUint aPrintBaseAddr/*=0*/)
1342 //-- check if the buffer filled with allowable data (RAM page initialisation data or something similar)
1343 //-- but not something meaningful.
1344 //-- allowable bytes: 0x00, 0x03, 0xff, 0xcc
1345 for(TInt i=0; i<aBuffer.Size(); ++i)
1347 TUint8 byte = aBuffer[i];
1348 if(byte != 0x00 && byte != 0x03 && byte != 0xff && byte != 0xcc )
1355 //-- dump the buffer if it contains anything different than allowed data
1358 for (TInt n=0; n<aBuffer.Size(); )
1360 TBuf16<3> byteBuffer;
1361 TBuf16<256> lineBuffer;
1362 lineBuffer.Format(_L("%08X: "), aPrintBaseAddr+n);
1363 for (TInt m=0; m<16 && n<aBuffer.Size(); m++, n++)
1365 byteBuffer.Format(_L("%02X "), aBuffer[n]);
1366 lineBuffer.Append(byteBuffer);
1368 test.Printf(lineBuffer);
1376 GLDEF_C void CallTestsL()
1378 // Call tests that may leave
1397 TestGetMediaSerialNumber();