93 { |
94 { |
94 TInt r; |
95 TInt r; |
95 TBuf<64> b; |
96 TBuf<64> b; |
96 TChar c; |
97 TChar c; |
97 r=TheFs.DriveToChar(aDrive,c); |
98 r=TheFs.DriveToChar(aDrive,c); |
98 test(r==KErrNone); |
99 test_KErrNone(r); |
99 b.Format(_L("Mount test file system on %c:"),(TUint)c); |
100 b.Format(_L("Mount test file system on %c:"),(TUint)c); |
100 test.Next(b); |
101 test.Next(b); |
101 |
102 |
102 r=TheFs.AddFileSystem(KFsFile); |
103 r=TheFs.AddFileSystem(KFsFile); |
103 test(r==KErrNone || r==KErrAlreadyExists); |
104 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
104 |
105 |
105 r=TheFs.FileSystemName(gOldFsName,aDrive); |
106 r=TheFs.FileSystemName(gOldFsName,aDrive); |
106 test(r==KErrNone || r==KErrNotFound); |
107 test_Value(r, r == KErrNone || r==KErrNotFound); |
107 |
108 |
108 TDriveInfo drv; |
109 TDriveInfo drv; |
109 r = TheFs.Drive(drv, aDrive); |
110 r = TheFs.Drive(drv, aDrive); |
110 test(r == KErrNone); |
111 test_KErrNone(r); |
111 |
112 |
112 gNoMedia = (drv.iType == EMediaUnknown || drv.iType == EMediaNotPresent); |
113 gNoMedia = (drv.iType == EMediaUnknown || drv.iType == EMediaNotPresent); |
113 |
114 |
114 if (gOldFsName.Length() > 0) |
115 if (gOldFsName.Length() > 0) |
115 { |
116 { |
116 TTest::Printf(_L("Dismount %C: %S"), (TUint)c, &gOldFsName); |
117 TTest::Printf(_L("Dismount %C: %S"), (TUint)c, &gOldFsName); |
117 r=TheFs.DismountFileSystem(gOldFsName,aDrive); |
118 r=TheFs.DismountFileSystem(gOldFsName,aDrive); |
118 test(r==KErrNone); |
119 test_KErrNone(r); |
119 } |
120 } |
120 |
121 |
121 r=TheFs.MountFileSystem(KFsName,aDrive); |
122 r=TheFs.MountFileSystem(KFsName,aDrive); |
122 test(r==KErrNone); |
123 test_KErrNone(r); |
123 |
124 |
124 r=TheFs.FileSystemName(gNewFsName,aDrive); |
125 r=TheFs.FileSystemName(gNewFsName,aDrive); |
125 test(r==KErrNone); |
126 test_KErrNone(r); |
126 test(gNewFsName.CompareF(KFsName)==0); |
127 test(gNewFsName.CompareF(KFsName)==0); |
127 return c; |
128 return c; |
128 } |
129 } |
129 |
130 |
130 LOCAL_C void UnmountFileSystem(TInt aDrive) |
131 LOCAL_C void UnmountFileSystem(TInt aDrive) |
131 /// Unmount a test filesystem and mount the old one. |
132 /// Unmount a test filesystem and mount the old one. |
132 { |
133 { |
133 TChar c; |
134 TChar c; |
134 TInt r=TheFs.DriveToChar(aDrive,c); |
135 TInt r=TheFs.DriveToChar(aDrive,c); |
135 test(r==KErrNone); |
136 test_KErrNone(r); |
136 r=TheFs.DismountFileSystem(gNewFsName,aDrive); |
137 r=TheFs.DismountFileSystem(gNewFsName,aDrive); |
137 test(r==KErrNone); |
138 test_KErrNone(r); |
138 // if there's no media present, don't try to mount it |
139 // if there's no media present, don't try to mount it |
139 if (gNoMedia) |
140 if (gNoMedia) |
140 { |
141 { |
141 test.Printf(_L("No media on %C: so don't remount it"), (TUint)c); |
142 test.Printf(_L("No media on %C: so don't remount it"), (TUint)c); |
142 } |
143 } |
143 else if (gOldFsName.Length() > 0) |
144 else if (gOldFsName.Length() > 0) |
144 { |
145 { |
145 test.Printf(_L("Mount %C: %S"), (TUint)c, &gOldFsName); |
146 test.Printf(_L("Mount %C: %S"), (TUint)c, &gOldFsName); |
146 r=TheFs.MountFileSystem(gOldFsName,aDrive); |
147 r=TheFs.MountFileSystem(gOldFsName,aDrive); |
147 test(r==KErrNone); |
148 test_KErrNone(r); |
148 } |
149 } |
149 if (r != KErrNone) |
150 if (r != KErrNone) |
150 test.Printf(_L("Error %d remounting %S on %C\n"), r, &gOldFsName, (TUint)c); |
151 test.Printf(_L("Error %d remounting %S on %C\n"), r, &gOldFsName, (TUint)c); |
151 } |
152 } |
152 |
153 |
157 /// @param aSync Mount synchronous if true, asynchronous if not. |
158 /// @param aSync Mount synchronous if true, asynchronous if not. |
158 { |
159 { |
159 TChar c; |
160 TChar c; |
160 TInt r=TheFs.DriveToChar(aDrive,c); |
161 TInt r=TheFs.DriveToChar(aDrive,c); |
161 r=TheFs.FileSystemName(gFsName, aDrive); |
162 r=TheFs.FileSystemName(gFsName, aDrive); |
162 test(r==KErrNone || r==KErrNotFound); |
163 test_Value(r, r == KErrNone || r==KErrNotFound); |
163 |
164 |
164 if (gFsName.Length() > 0) |
165 if (gFsName.Length() > 0) |
165 { |
166 { |
166 r=TheFs.DismountFileSystem(gFsName, aDrive); |
167 r=TheFs.DismountFileSystem(gFsName, aDrive); |
167 if(r!=KErrNone) |
168 if(r!=KErrNone) |
650 |
648 |
651 timer.CreateLocal(); |
649 timer.CreateLocal(); |
652 |
650 |
653 |
651 |
654 r = TheFs.DriveToChar(aDrive1, dc1); |
652 r = TheFs.DriveToChar(aDrive1, dc1); |
655 test(r == KErrNone); |
653 test_KErrNone(r); |
656 r = TheFs.DriveToChar(aDrive2, dc2); |
654 r = TheFs.DriveToChar(aDrive2, dc2); |
657 test(r == KErrNone); |
655 test_KErrNone(r); |
658 |
656 |
659 // allocate buffers |
657 // allocate buffers |
660 r = f1.Init(dc1, aBufSize1); |
658 r = f1.Init(dc1, aBufSize1); |
661 test(r == KErrNone); |
659 test_KErrNone(r); |
662 r = f2.Init(dc2, aBufSize2); |
660 r = f2.Init(dc2, aBufSize2); |
663 test(r == KErrNone); |
661 test_KErrNone(r); |
664 |
662 |
665 |
663 |
666 _LIT(KSync, " sync"); |
664 _LIT(KSync, " sync"); |
667 _LIT(KAsync, "async"); |
665 _LIT(KAsync, "async"); |
668 if (gVerbose) |
666 if (gVerbose) |
684 //******************************************************************** |
682 //******************************************************************** |
685 |
683 |
686 if (aBufSize1 > 0) |
684 if (aBufSize1 > 0) |
687 { |
685 { |
688 r = f1.CreateReadFile(); |
686 r = f1.CreateReadFile(); |
689 test(r == KErrNone); |
687 test_KErrNone(r); |
690 } |
688 } |
691 if (aBufSize2 > 0) |
689 if (aBufSize2 > 0) |
692 { |
690 { |
693 r = f2.CreateReadFile(); |
691 r = f2.CreateReadFile(); |
694 test(r == KErrNone); |
692 test_KErrNone(r); |
695 } |
693 } |
696 |
694 |
697 if (aBufSize1 > 0) |
695 if (aBufSize1 > 0) |
698 r = f1.Open(RFileOps::ERead); |
696 r = f1.Open(RFileOps::ERead); |
699 test(r == KErrNone); |
697 test_KErrNone(r); |
700 |
698 |
701 if (aBufSize2 > 0) |
699 if (aBufSize2 > 0) |
702 r = f2.Open(RFileOps::ERead); |
700 r = f2.Open(RFileOps::ERead); |
703 test(r == KErrNone); |
701 test_KErrNone(r); |
704 |
702 |
705 |
703 |
706 timer.After(tstat, KTimeBM * KSecond); |
704 timer.After(tstat, KTimeBM * KSecond); |
707 |
705 |
708 startTime.HomeTime(); |
706 startTime.HomeTime(); |
961 { |
959 { |
962 User::Panic(_L("USER ABORT"), 0); |
960 User::Panic(_L("USER ABORT"), 0); |
963 } |
961 } |
964 |
962 |
965 r = TheFs.CharToDrive(drvch1, drive1); |
963 r = TheFs.CharToDrive(drvch1, drive1); |
966 test(r == KErrNone); |
964 test_KErrNone(r); |
967 r = TheFs.CharToDrive(drvch2, drive2); |
965 r = TheFs.CharToDrive(drvch2, drive2); |
968 test(r == KErrNone); |
966 test_KErrNone(r); |
969 |
967 |
970 r = TheFs.FileSystemName(gFsName1, drive1); |
968 r = TheFs.FileSystemName(gFsName1, drive1); |
971 test(r == KErrNone || r == KErrNotFound); |
969 test_Value(r, r == KErrNone || r == KErrNotFound); |
972 r = TheFs.FileSystemName(gFsName2, drive2); |
970 r = TheFs.FileSystemName(gFsName2, drive2); |
973 test(r == KErrNone || r == KErrNotFound); |
971 test_Value(r, r == KErrNone || r == KErrNotFound); |
974 |
972 |
975 if (testFs) |
973 if (testFs) |
976 { |
974 { |
977 MountTestFileSystem(drive1); |
975 MountTestFileSystem(drive1); |
978 MountTestFileSystem(drive2); |
976 MountTestFileSystem(drive2); |