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_fsys.cpp
18 #define __E32TEST_EXTENSION__
21 #include <f32file_private.h>
24 #include "fat_utils.h"
25 #include "filesystem_fat.h"
27 using namespace Fat_Test_Utils;
29 RTest test(_L("T_FSYS"));
31 static void TestFileSystemNames()
33 test.Next(_L("Read file system names for all drives"));
36 for(TInt i=EDriveA;i<KMaxDrives;++i)
38 r=TheFs.FileSystemName(name,i);
39 test(r==KErrNone || r==KErrNotFound);
41 r=RFs::DriveToChar(i,c);
44 test.Printf(_L("File System Name on drive %c is %S\n"),(char)c,&name);
46 test.Printf(_L("No file system on drive %c\n"),(char)c);
50 static void CheckDismount(TDesC& aFs,TInt aDrive)
53 if (aDrive==EDriveC) // ??? Can't test on C: - see below
56 TFullName oldSess, newSess;
57 r=TheFs.SessionPath(oldSess);
60 r=TheFs.DriveToChar(aDrive,c);
68 r=TheFs.Drive(di,aDrive);
70 b.Format(_L("Test dismounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
73 // Test cannot dismount on rom drive
74 test.Next(_L("Test cannot dismount on Rom drive"));
76 r=TheFs.FileSystemName(zName,EDriveZ);
78 r=TheFs.DismountFileSystem(zName,EDriveZ);
79 test.Printf(_L("r=%d"),r);
80 // NB if paging is enabled on a ROFS partition which is part of the composite file system then the
81 // likelihood is that there will be a at least one file clamped: in this case there error will be KErrInUse
82 test(r==KErrAccessDenied || r==KErrInUse);
84 // Test cannot dismount on wrong drive
85 test.Next(_L("Test cannot dismount on wrong drive"));
86 r=TheFs.DismountFileSystem(aFs,EDriveA);
87 test(r==KErrNotReady);
89 // Test cannot dismount with wrong name
90 test.Next(_L("Test cannot dismount with wrong file system name"));
91 r=TheFs.DismountFileSystem(_L("abc"),aDrive);
92 test(r==KErrNotFound);
94 // Test cannot dismount with a file open
95 test.Next(_L("Test cannot dismount with a file open"));
96 r=TheFs.SetSessionPath(newSess);
98 r=file.Replace(TheFs,_L("abc"),EFileShareAny);
100 r=TheFs.SessionPath(newSess);
102 r=TheFs.IsFileOpen(_L("abc"),open);
105 r=TheFs.DismountFileSystem(aFs,aDrive);
109 // Now test dismount works
110 test.Next(_L("Test dismounts OK"));
111 r=TheFs.DismountFileSystem(aFs,aDrive);
114 test.Printf(_L("Error = %d"),r);
118 r=TheFs.FileSystemName(n,aDrive);
119 test(r==KErrNone || r==KErrNotFound);
121 r=file.Replace(TheFs,_L("abc"),EFileShareAny);
122 test(r==KErrNotReady);
125 r=TheFs.MountFileSystem(aFs,aDrive);
128 test.Printf(_L("error = %d\n"),r);
131 r=TheFs.FileSystemName(n,aDrive);
133 test(n.Compare(aFs)==0);
134 r=file.Replace(TheFs,_L("abc"),EFileShareAny); // ??? bang
137 r=TheFs.SetSessionPath(oldSess);
141 static void TestDismountFileSystem(TInt aDrive)
146 r=TheFs.FileSystemName(name,aDrive);
147 test(r==KErrNone || r==KErrNotFound);
149 CheckDismount(name,aDrive);
152 #if defined(__EPOC32__)
153 static void TestFileSystem(TInt aDrive)
155 // Mount a new CTestFileSystem on the drive under test
160 TInt r=TheFs.DriveToChar(aDrive,c);
163 r=TheFs.Drive(di,aDrive);
165 b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
168 test.Next(_L("Test mounting of test file system"));
169 r=TheFs.AddFileSystem(_L("T_TFSYS"));
170 if(r!=KErrNone && r!=KErrAlreadyExists)
172 test.Printf(_L("error=%d"),r);
177 r=TheFs.FileSystemName(oldFs,aDrive);
179 // r=TheFs.FileSystemName(oldFs,aDrive);
181 r=TheFs.DismountFileSystem(oldFs,aDrive);
184 test.Printf(_L("Error = %d"),r);
187 r=TheFs.MountFileSystem(_L("Test"),aDrive);
191 r=TheFs.FileSystemName(newFs,aDrive);
193 test(newFs.Compare(_L("Test"))==0);
197 r=TheFs.Drive(info,aDrive);
200 test.Printf(_L("iType=%d,iConnectionBusType=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
201 (TUint)info.iConnectionBusType,info.iDriveAtt,info.iMediaAtt);
203 //Try to remove filesystem without dismounting.
204 r=TheFs.RemoveFileSystem(_L("Test"));
207 test.Printf(_L("error=%d"),r);
210 r=TheFs.FileSystemName(newFs,aDrive);
212 test(newFs.Compare(_L("Test"))==0);
214 r=TheFs.DismountFileSystem(newFs,aDrive);
217 r=TheFs.MountFileSystem(oldFs,aDrive);
222 static void TestMountInvalidDrive()
224 // Attempt to mount FAT on non-local drive
226 test.Start(_L("TestMountInvalidDrive"));
230 test.Next(_L("Adding EFAT"));
232 _LIT(KFsNm, "EFAT32");
234 _LIT(KFsNm, "ELOCAL");
237 r = TheFs.AddFileSystem(KFsNm);
238 test.Printf(_L("afs: r = %d\n"), r);
239 test(r == KErrNone || r == KErrAlreadyExists);
240 test.Next(_L("mounting FAT on drive R"));
241 r = TheFs.MountFileSystem(KFileSystemName_FAT, EDriveR);
242 test(r == KErrArgument);
247 // Additional step for INC083446: Corrupted miniSD not detected as corrupted by phone
248 static void TestMountingBrokenMedia(TInt aDrive)
250 // Mount a new CTestFileSystem on the drive under test
253 if (aDrive==EDriveC) // ??? Can't test on C:
258 TInt r=TheFs.DriveToChar(aDrive,c);
261 r=TheFs.Drive(di,aDrive);
263 b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
266 test.Next(_L("Test mounting of test file system"));
267 r=TheFs.AddFileSystem(_L("T_TFSYS2"));
268 if(r!=KErrNone && r!=KErrAlreadyExists)
270 test.Printf(_L("error=%d"),r);
275 r=TheFs.FileSystemName(oldFs,aDrive);
277 r=TheFs.DismountFileSystem(oldFs,aDrive);
280 test.Printf(_L("Error = %d"),r);
283 r=TheFs.MountFileSystem(_L("Test2"),aDrive);
284 test(r == KErrCorrupt);
287 r=TheFs.FileSystemName(newFs,aDrive);
289 test(newFs.Compare(_L("Test2"))==0);
291 // Get the number of remounts by checking the volume attributes -
292 // T_TFSYS2 hijacks the iBattery member to report back the number of times MountL() has been called
295 r=TheFs.Drive(info,aDrive);
297 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
298 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
299 remounts = (TInt) info.iBattery;
300 test.Printf(_L("Initial remounts = %d"), remounts);
302 // Make the file server attempt to remount the drive by looking for a non-existant DLL
303 // The file server should setop trying to remount the driver after KMaxMountFailures attempts
304 const TInt KMaxMountFailures = 3; // copied from sf_drv.cpp
305 const TInt KEntryAttempts = 10;
307 for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++)
310 _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL");
311 r = TheFs.Entry(KNonExistantFilename, entry);
312 test(r == KErrCorrupt);
314 r=TheFs.Drive(info,aDrive);
316 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
317 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
318 remounts = (TInt) info.iBattery;
319 test.Printf(_L("Remounts = %d"), remounts);
320 test(remounts == KMaxMountFailures);
322 // simulate a media change to reset failure count
323 r = TheFs.RemountDrive(aDrive, NULL, 0);
325 // now try mounting again & verify the the file server attempts to mount the drive again
326 for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++)
329 _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL");
330 r = TheFs.Entry(KNonExistantFilename, entry);
331 test(r == KErrCorrupt);
333 r=TheFs.Drive(info,aDrive);
335 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
336 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
337 remounts = (TInt) info.iBattery;
338 test.Printf(_L("Remounts = %d"), remounts);
339 test(remounts == KMaxMountFailures * 2);
343 r=TheFs.DismountFileSystem(newFs,aDrive);
345 r=TheFs.MountFileSystem(oldFs,aDrive);
348 r=TheFs.RemoveFileSystem(_L("Test2"));
351 test.Printf(_L("error=%d"),r);
358 Testing obtaining media serial number for the substituted drives
360 static void TestSubstDriveMediaSerialNumber()
362 test.Next(_L("Test obtaining media serial number for the substituted drives"));
365 const TInt currDrvNum=CurrentDrive();
368 nRes=TheFs.Drive(drvInfo, currDrvNum);
369 test(nRes==KErrNone);
371 if(drvInfo.iDriveAtt & (KDriveAttRom | KDriveAttRedirected | KDriveAttSubsted))
373 test.Printf(_L("Can't test on this drive!\n"));
377 TMediaSerialNumber serNum;
379 //-- test Media Serial Number on unexisting drive
381 for(TInt drvNum=EDriveA; drvNum<=EDriveZ; ++drvNum)
384 if(KErrNone==TheFs.Drive(drvInfo, drvNum) && drvInfo.iType==EMediaNotPresent)
386 // found a non-extant drive, test it...
387 nRes = TheFs.GetMediaSerialNumber(serNum, drvNum);
388 test(nRes == KErrNotReady);
394 nRes = TheFs.GetMediaSerialNumber(serNum, currDrvNum);
397 test.Printf(_L("Test is inconsintent on this drive!\n"));
401 TFileName substPath; //-- path to the directory to substitute
402 const TInt KSubstDrv = EDriveO; //-- drive to be substituted
404 //-- make directory, which will be substituted ad a drive
405 substPath.Format(_L("%c:\\SubstDrv1\\"), (TUint8)'A'+currDrvNum);
408 nRes = TheFs.SetSubst(substPath, KSubstDrv);
409 test(nRes == KErrNone);
411 //-- an attempt to obtain Media Serial Number on a substed drive shall result in KErrNotSupported
412 nRes = TheFs.GetMediaSerialNumber(serNum, KSubstDrv);
413 test(nRes == KErrNotSupported);
415 //-- delete substed drive
416 nRes = TheFs.SetSubst(_L(""), KSubstDrv);
417 test(nRes == KErrNone);
421 //----------------------------------------------------------------------------------------------
422 //! @SYMTestCaseID PBASE-t_fsys-0317
425 //! @SYMTestCaseDesc This test case is testing querying file system sub type name using
426 //! RFs::QueryVolumeInfoExt() API.
427 //! @SYMTestActions 1 querys sub type of file system on volumes mounted with 'Fat' file system
428 //! 2 querys sub type of file system on volumes mounted with 'Lffs' file system
429 //! 3 querys sub type of file system on volumes mounted with 'rofs' file system
430 //! 4 querys sub type of file system on volumes mounted with other file systems
431 //! @SYMTestExpectedResults
432 //! 1 returned error code should be KErrNone, descriptor should match 'FAT12' or 'FAT16' or 'FAT32'
433 //! 2 returned error code should be KErrNotSupported, descriptor should match 'Lffs'
434 //! 3 returned error code should be KErrNotSupported, descriptor should match 'rofs'
435 //! 4 returned error code should be KErrNotSupported, descriptor length should not be zero
436 //! @SYMTestPriority High
437 //! @SYMTestStatus Implemented
438 //----------------------------------------------------------------------------------------------
439 static void TestFileSystemSubTypeQuery()
441 test.Next(_L("Test querying sub type of the mounted file system"));
443 TPckgBuf<TFSName> subName;
445 TDriveInfo driveInfo;
446 TPckgBuf<TBool> fDrvSyncBuf;
449 for(i = EDriveA; i <= EDriveZ; ++i, subName.Zero())
451 r = TheFs.FileSystemName(fsName, i);
454 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
455 r=TheFs.Drive(driveInfo, i);
458 if (driveInfo.iType==EMediaNotPresent)
460 test.Printf(_L("The media is not present.\n"));
461 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
462 test(r == KErrNone || r == KErrNotReady);
464 else if (driveInfo.iType==EMediaCdRom)
466 test.Printf(_L("CD ROM with no media will report not ready!\n"));
467 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
468 test(r == KErrNotReady);
472 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
475 //-- test EIsDriveSync command
476 r = TheFs.QueryVolumeInfoExt(i, EIsDriveSync, fDrvSyncBuf);
479 test.Printf(_L("The drive is Synchronous.\n"));
481 test.Printf(_L("The drive is Asynchronous.\n"));
485 // if Fat, testing returning sub type name
486 if (fsName.CompareF(KFileSystemName_FAT)==0)
489 test(subName().CompareF(KFSSubType_FAT12)==0 ||
490 subName().CompareF(KFSSubType_FAT16)==0 ||
491 subName().CompareF(KFSSubType_FAT32)==0);
495 // if Lffs, testing returning file system name
496 if (fsName.CompareF(_L("Lffs"))==0)
499 test(subName().CompareF(_L("Lffs"))==0);
502 // if rofs, testing returning file system name
503 if (fsName.CompareF(_L("rofs"))==0)
506 test(subName().CompareF(_L("rofs"))==0);
509 // if Composite, testing returning file system name
510 if (fsName.CompareF(_L("Composite"))==0)
513 test(subName().CompareF(_L("Composite"))==0);
519 test(subName().Length()!=0);
526 //----------------------------------------------------------------------------------------------
527 //! @SYMTestCaseID PBASE-t_fsys-0318
530 //! @SYMTestCaseDesc This test case is testing querying file system's cluster size using
531 //! RFs::QueryVolumeInfoExt() API.
532 //! @SYMTestActions 1 querys cluster size of file system on volumes mounted with 'Fat' file system
533 //! 2 querys cluster size of file system on volumes mounted with 'Lffs' file system
534 //! 3 querys cluster size of file system on volumes mounted with other file systems
535 //! @SYMTestExpectedResults
536 //! 1 returned error code should be KErrNone, cluster size should be non-zero
537 //! 2 returned error code should be KErrNone, cluster size should be 512
538 //! 3 returned error code should be KErrNone, cluster size should be KErrNotSupported
539 //! @SYMTestPriority High
540 //! @SYMTestStatus Implemented
541 //----------------------------------------------------------------------------------------------
542 static void TestFileSystemClusterSizeQuery()
544 test.Next(_L("Test querying cluster size information of the mounted file system"));
546 TPckgBuf<TVolumeIOParamInfo> ioInfo;
548 TDriveInfo driveInfo;
549 for(i = EDriveA; i <= EDriveZ; ++i)
551 r = TheFs.FileSystemName(fsName, i);
554 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
556 r=TheFs.Drive(driveInfo, i);
558 // if no media present
559 if (driveInfo.iType==EMediaNotPresent)
561 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
562 test(r == KErrNone || r == KErrNotReady);
564 else if (driveInfo.iType==EMediaCdRom)
566 test.Printf(_L("CD ROM with no media!\n"));
567 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
568 test(r == KErrNone || r == KErrNotReady);
572 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
575 if (fsName.CompareF(KFileSystemName_FAT)==0)
577 test(ioInfo().iClusterSize != 0);
581 if (fsName.CompareF(_L("Lffs"))==0)
583 TBusLocalDrive drive;
584 TBool changeFlag = EFalse;
586 TLocalDriveCaps DriveCaps;
587 TLocalDriveCapsV7 DriveCapsV7;
588 for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++)
590 r = drive.Connect(locDriveNumber,changeFlag);
594 TPckg<TLocalDriveCaps> capsPckg(DriveCaps);
595 r=drive.Caps(capsPckg);
596 if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS))
603 TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7);
604 r=drive.Caps(capsPckg);
607 if(DriveCapsV7.iObjectModeSize == 0)
609 test(ioInfo().iClusterSize == 512);
614 test((TUint32)(ioInfo().iClusterSize) == DriveCapsV7.iObjectModeSize);
619 //-- we can not suggest anything about unknown filesystem, thus do not check the result.
620 //test(ioInfo().iClusterSize == KErrNotSupported);
627 //----------------------------------------------------------------------------------------------
628 //! @SYMTestCaseID PBASE-t_fsys-0319
631 //! @SYMTestCaseDesc This test case is testing querying block size of underlying media using
632 //! RFs::QueryVolumeInfoExt() API.
633 //! @SYMTestActions 1 querys block size on volumes mounted with MMC card type of media
634 //! 2 querys block size on volumes mounted with RAM type of media
635 //! 3 querys block size on volumes mounted with NOR flash type of media
636 //! 4 querys block size on volumes mounted with Nand flash (code) type of media
637 //! 5 querys block size on volumes mounted with Nand flash (data) type of media
638 //! @SYMTestExpectedResults
639 //! 1 returned error code should be KErrNone, block size should be 512
640 //! 2 returned error code should be KErrNone, block size should be KDefaultVolumeBlockSize
641 //! 3 returned error code should be KErrNone, block size should be KDefaultVolumeBlockSize
642 //! 4 returned error code should be KErrNone, block size should be 512
643 //! 5 returned error code should be KErrNone, block size should be 512
644 //! @SYMTestPriority High
645 //! @SYMTestStatus Implemented
646 //----------------------------------------------------------------------------------------------
647 static void TestMediaBlockSizeQuery()
649 test.Next(_L("Test querying block size information of the underlying media"));
650 #if defined(__WINS__)
651 test.Printf(_L("This test case runs on hardware only"));
654 #else // test runs on hardware only.
656 TPckgBuf<TVolumeIOParamInfo> ioInfo;
658 TDriveInfo driveInfo;
659 for(i = EDriveA; i <= EDriveZ; ++i)
661 r = TheFs.FileSystemName(fsName, i);
664 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
665 r=TheFs.Drive(driveInfo, i);
667 // if no media present
668 if (driveInfo.iType==EMediaNotPresent)
670 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
671 test(r == KErrNone || r == KErrNotReady);
673 else if (driveInfo.iType==EMediaCdRom)
675 test.Printf(_L("CD ROM with no media will report not ready!\n"));
676 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
677 test(r == KErrNotReady);
681 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
683 // if MMC, test block size >= 512;
684 // (Version 4.3 MMC cards introduce the concept of a "Super Page" which should be used as
685 // guide when calculating the cluster size. For these cards the reported block size may be
686 // any multiple of 512).
687 if ((driveInfo.iType == EMediaHardDisk) &&
688 (driveInfo.iDriveAtt & KDriveAttRemovable) &&
689 (driveInfo.iDriveAtt & KDriveAttLocal))
691 test(ioInfo().iBlockSize >= 512);
694 // if RAM, test block size == 1;
695 if ((driveInfo.iType == EMediaRam) &&
696 (driveInfo.iDriveAtt & KDriveAttLocal) &&
697 (driveInfo.iDriveAtt & KDriveAttInternal))
699 test(ioInfo().iBlockSize == 1);
702 // if NOR flash, test block size == 512 (default block size);
703 if ((driveInfo.iType == EMediaFlash) &&
704 (driveInfo.iDriveAtt & KDriveAttLocal) &&
705 (driveInfo.iDriveAtt & KDriveAttInternal))
707 TBusLocalDrive drive;
708 TBool changeFlag = EFalse;
710 TLocalDriveCaps DriveCaps;
711 TLocalDriveCapsV7 DriveCapsV7;
712 for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++)
714 r = drive.Connect(locDriveNumber,changeFlag);
717 TPckg<TLocalDriveCaps> capsPckg(DriveCaps);
718 r=drive.Caps(capsPckg);
719 if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS))
726 TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7);
727 r=drive.Caps(capsPckg);
729 if ((fsName.CompareF(_L("Lffs"))==0) && (DriveCapsV7.iObjectModeSize != 0))
731 test(ioInfo().iBlockSize == (TInt) DriveCapsV7.iObjectModeSize);
736 test(ioInfo().iBlockSize == (TInt) KDefaultVolumeBlockSize);
740 // if Nand flash (with Fat file system), test block size == 512 (small-block) or 2048 (large-block)
741 if ((driveInfo.iType == EMediaNANDFlash) &&
742 (driveInfo.iDriveAtt & KDriveAttLocal) &&
743 (driveInfo.iDriveAtt & KDriveAttInternal))
745 test(ioInfo().iBlockSize == 512 || ioInfo().iBlockSize == 2048);
754 //----------------------------------------------------------------------------------------------
755 //! @SYMTestCaseID PBASE-t_fsys-0320
758 //! @SYMTestCaseDesc This test case is testing wrapper API RFs::FileSystemSubType() has the same
759 //! behaviours as RFs::QueryVolumeInfoExt()
760 //! @SYMTestActions 1 querys file system sub type name by both APIs
761 //! @SYMTestExpectedResults
762 //! 1 returned error codes and descriptors of both API should be identical
763 //! @SYMTestPriority High
764 //! @SYMTestStatus Implemented
765 //----------------------------------------------------------------------------------------------
766 static void TestFileSystemSubType()
768 test.Next(_L("Test wrapper API RFs::FileSystemSubType()'s behaviour"));
770 TPckgBuf<TFSName> subName;
775 for(TInt i = EDriveA; i <= EDriveZ; ++i)
777 r = TheFs.FileSystemName(fsName, i);
780 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
781 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
782 r1 = TheFs.FileSystemSubType(i, subName1);
784 if (subName().Length())
786 test(subName().CompareF(subName1)==0);
790 test(subName1.Length()==0);
796 //----------------------------------------------------------------------------------------------
797 //! @SYMTestCaseID PBASE-t_fsys-0321
800 //! @SYMTestCaseDesc This test case is testing wrapper API RFs::VolumeIOParam() has the same
801 //! behaviours as RFs::QueryVolumeInfoExt()
802 //! @SYMTestActions 1 querys volume IO params by both APIs
803 //! @SYMTestExpectedResults
804 //! 1 returned error codes and IO param values of both API should be identical
805 //! @SYMTestPriority High
806 //! @SYMTestStatus Implemented
807 //----------------------------------------------------------------------------------------------
808 static void TestVolumeIOParam()
810 test.Next(_L("Test wrapper API RFs::VolumeIOParam()'s behaviour"));
812 TPckgBuf<TVolumeIOParamInfo> ioInfo;
814 TVolumeIOParamInfo ioInfo1;
817 for(TInt i = EDriveA; i <= EDriveZ; ++i)
819 r = TheFs.FileSystemName(fsName, i);
822 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
823 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
824 r1 = TheFs.VolumeIOParam(i, ioInfo1);
826 test(ioInfo().iBlockSize == ioInfo1.iBlockSize);
827 test(ioInfo().iClusterSize == ioInfo1.iClusterSize);
828 test(ioInfo().iRecReadBufSize == ioInfo1.iRecReadBufSize);
829 test(ioInfo().iRecWriteBufSize == ioInfo1.iRecWriteBufSize);
835 //----------------------------------------------------------------------------------------------
836 //! @SYMTestCaseID PBASE-t_fsys-0322
839 //! @SYMTestCaseDesc This test case is testing RFs::QueryVolumeInfoExt() API on a testing file system
840 //! @SYMTestActions 0 mounts testing file system on a certain drive
841 //! 1 querys file system's sub type name on the drive under testing
842 //! 2 querys file system's cluster size on the drive under testing
843 //! @SYMTestExpectedResults
844 //! 1 returned error code should be KErrNone, sub type name should match 'Test3SubType'
845 //! 2 returned error code should be KErrNone, cluster size should equal 1024
846 //! @SYMTestPriority High
847 //! @SYMTestStatus Implemented
848 //----------------------------------------------------------------------------------------------
849 static void TestQueryVolumeInfoExtOnTestFS(TInt aDrive)
851 if (aDrive==EDriveC) // Can't test on C:
856 test.Printf(_L("Tested on drive: %c.\n"), (char)(aDrive+'A'));
858 // Mount a new CTestFileSystem on the drive under test
859 test.Next(_L("Test RFs::QueryVolumeInfoExt() on Testing File System"));
860 r = TheFs.AddFileSystem(_L("T_TFSYS3"));
861 if (r != KErrNone && r != KErrAlreadyExists)
863 test.Printf(_L("error=%d"),r);
867 r = TheFs.FileSystemName(oldFs,aDrive);
869 r = TheFs.DismountFileSystem(oldFs,aDrive);
872 test.Printf(_L("Error = %d"),r);
875 r = TheFs.MountFileSystem(_L("Test3"),aDrive);
878 r = TheFs.FileSystemName(newFs,aDrive);
880 test(newFs.Compare(_L("Test3"))==0);
882 // Sub type name query:
883 TPckgBuf<TFSName> subNameP;
884 r = TheFs.QueryVolumeInfoExt(aDrive, EFileSystemSubType, subNameP);
886 test(subNameP() == _L("Test3SubType"));
888 // Cluster size querys:
889 TPckgBuf<TVolumeIOParamInfo> ioInfoP;
890 r = TheFs.QueryVolumeInfoExt(aDrive, EIOParamInfo, ioInfoP);
892 test(ioInfoP().iClusterSize==1024);
894 // Mount the original file system back
895 r=TheFs.DismountFileSystem(newFs,aDrive);
897 r=TheFs.MountFileSystem(oldFs,aDrive);
900 r=TheFs.RemoveFileSystem(_L("Test3"));
903 test.Printf(_L("error=%d"),r);
909 //----------------------------------------------------------------------------------------------
911 Test remounting the file system with objects opened.
915 3. forcedly remount the file system
916 4. read this file (this will imply remounting the filesystem)
918 static void TestRemountFSWithOpenedObjects()
920 test.Next(_L("Testing forcedly remounting FS with objects opened.\n"));
924 //-- 1. create a file
925 _LIT(KFile, "\\test_file.file");
926 const TUint KFileSz = 5000;
928 nRes = CreateCheckableStuffedFile(TheFs, KFile, KFileSz);
933 //-- 2. open this file
934 nRes = file.Open(TheFs, KFile, EFileRead);
937 //-- 2.1 try to dismount the FS, it must fail because of the opened object.
939 nRes = TheFs.FileSystemName(fsName, CurrentDrive());
942 nRes = TheFs.DismountFileSystem(fsName, CurrentDrive());
943 test(nRes == KErrInUse);
946 //-- 3. forcedly remount the drive
947 nRes = TheFs.RemountDrive(CurrentDrive());
948 if(nRes == KErrNotSupported)
949 {//-- this feature is not supported and the test is inconsistent.
950 test.Printf(_L("RemountDrive() is not supported, the test is inconsistent!"));
952 //-- remounting must work at least on MMC drives
953 const TBool isFAT = Is_Fat(TheFs, CurrentDrive());
955 TDriveInfo driveInfo;
956 nRes = TheFs.Drive(driveInfo, CurrentDrive());
959 test(!isFAT || (!(driveInfo.iDriveAtt & KDriveAttRemovable)));
967 User::After(500*K1mSec);
969 //-- 4. read this file. The FS will be remounted and the read must be OK.
971 nRes = file.Read(0, buf, 30);
976 //-- 5. verify the file, just in case.
977 nRes = VerifyCheckableFile(TheFs, KFile);
980 //-- 6. delete the file
984 //----------------------------------------------------------------------------------------------
985 static void TestFileSystem_MaxSupportedFileSizeQuery()
987 test.Next(_L("Test querying max. supported file size on this file system"));
989 TPckgBuf<TVolumeIOParamInfo> ioInfo;
990 TVolumeIOParamInfo& volInfo = ioInfo();
992 const TInt drvNo=CurrentDrive();
996 nRes = TheFs.FileSystemName(fsName, drvNo);
999 nRes = TheFs.QueryVolumeInfoExt(drvNo, EIOParamInfo, ioInfo);
1000 test_KErrNone(nRes);
1002 test.Printf(_L("FS:'%S' Max File Size:0x%LX\n"), &fsName, volInfo.iMaxSupportedFileSize);
1003 if(volInfo.iMaxSupportedFileSize == KMaxTUint64)
1005 test.Printf(_L("Max File Size query isn't supported by this FS\n"));
1009 //-- check the value for FAT FS only.
1010 if(Is_Fat(TheFs, drvNo))
1012 test(volInfo.iMaxSupportedFileSize == KMaxSupportedFatFileSize);
1017 //----------------------------------------------------------------------------------------------
1018 GLDEF_C void CallTestsL()
1024 //-- set up console output
1025 Fat_Test_Utils::SetConsole(test.Console());
1027 TInt drive=CurrentDrive();
1029 PrintDrvInfo(TheFs, drive);
1031 //Do not run this test on the NAND drive, as
1032 //this has the FTL mounted as a primary extension
1033 //which causes the test to fail
1034 #if defined(__WINS__)
1038 TDriveInfo driveInfo;
1039 TheFs.Drive(driveInfo,drive);
1040 if (driveInfo.iType == EMediaNANDFlash)
1046 //---------------------------------------
1048 TestFileSystemNames();
1049 TestDismountFileSystem(CurrentDrive());
1050 #if defined(__EPOC32__)
1051 TestFileSystem(CurrentDrive());
1054 TestMountInvalidDrive();
1056 TestMountingBrokenMedia(CurrentDrive());
1057 TestSubstDriveMediaSerialNumber();
1059 TestFileSystemSubTypeQuery();
1060 TestFileSystemClusterSizeQuery();
1061 TestMediaBlockSizeQuery();
1062 TestFileSystemSubType();
1063 TestVolumeIOParam();
1064 TestQueryVolumeInfoExtOnTestFS(CurrentDrive());
1066 TestFileSystem_MaxSupportedFileSizeQuery();
1068 TestRemountFSWithOpenedObjects();