18 #define __E32TEST_EXTENSION__ |
18 #define __E32TEST_EXTENSION__ |
19 |
19 |
20 #include <f32file.h> |
20 #include <f32file.h> |
21 #include <f32file_private.h> |
21 #include <f32file_private.h> |
22 #include <e32test.h> |
22 #include <e32test.h> |
23 #include <e32math.h> |
|
24 #include "t_server.h" |
23 #include "t_server.h" |
25 #include "fat_utils.h" |
24 #include "fat_utils.h" |
26 #include "filesystem_fat.h" |
25 #include "filesystem_fat.h" |
27 |
26 |
28 using namespace Fat_Test_Utils; |
27 using namespace Fat_Test_Utils; |
29 |
28 |
30 RTest test(_L("T_FSYS")); |
29 RTest test(_L("T_FSYS")); |
31 static TInt64 gRndSeed; |
30 |
32 |
|
33 _LIT(KTestFsy, "T_TFSYS"); |
|
34 _LIT(KTestFsy2, "T_TFSYS2"); |
|
35 _LIT(KTestFsy3, "T_TFSYS3"); |
|
36 |
|
37 _LIT(KTestFsName, "Test"); |
|
38 _LIT(KTestFsName2, "Test2"); |
|
39 _LIT(KTestFsName3, "Test3"); |
|
40 |
|
41 |
|
42 |
|
43 //--------------------------------------------------- |
|
44 |
|
45 |
|
46 void InitGlobals() |
|
47 { |
|
48 //-- initialise random generator |
|
49 gRndSeed = 0xf73c1ab; |
|
50 Math::Rand(gRndSeed); |
|
51 } |
|
52 |
|
53 //--------------------------------------------------- |
|
54 void DestroyGlobals() |
|
55 { |
|
56 } |
|
57 |
|
58 //--------------------------------------------------- |
|
59 static void TestFileSystemNames() |
31 static void TestFileSystemNames() |
60 { |
32 { |
61 test.Next(_L("TestFileSystemNames(). Read file system names for all drives\n")); |
33 test.Next(_L("Read file system names for all drives")); |
62 TFullName name; |
34 TFullName name; |
63 TBuf<60> buf; |
35 TInt r; |
64 TInt nRes; |
36 for(TInt i=EDriveA;i<KMaxDrives;++i) |
65 |
37 { |
66 TDriveList drvList; |
38 r=TheFs.FileSystemName(name,i); |
67 nRes = TheFs.DriveList(drvList); |
39 test(r==KErrNone || r==KErrNotFound); |
68 test_KErrNone(nRes); |
40 TChar c; |
69 |
41 r=RFs::DriveToChar(i,c); |
70 for(TInt i=0; i<KMaxDrives; ++i) |
42 test(r==KErrNone); |
71 { |
43 if(name.Length()) |
72 buf.Format(_L("drv %C: att:0x%02x"), 'A'+i, drvList[i]); |
44 test.Printf(_L("File System Name on drive %c is %S\n"),(char)c,&name); |
73 |
|
74 nRes = TheFs.FileSystemName(name, i); |
|
75 test_Value(nRes, nRes == KErrNone || nRes==KErrNotFound); |
|
76 |
|
77 if(nRes == KErrNone) |
|
78 { |
|
79 buf.AppendFormat(_L(" Mounted FS:%S"), &name); |
|
80 } |
|
81 else |
45 else |
82 { |
46 test.Printf(_L("No file system on drive %c\n"),(char)c); |
83 buf.Append(_L(" Mounted FS:")); |
47 } |
84 } |
48 } |
85 |
49 |
86 buf.Append(_L("\n")); |
|
87 test.Printf(buf); |
|
88 } |
|
89 |
|
90 } |
|
91 |
|
92 //--------------------------------------------------- |
|
93 static void CheckDismount(TDesC& aFs,TInt aDrive) |
50 static void CheckDismount(TDesC& aFs,TInt aDrive) |
94 { |
51 { |
95 |
52 |
96 if (aDrive==EDriveC) // ??? Can't test on C: - see below |
53 if (aDrive==EDriveC) // ??? Can't test on C: - see below |
97 return; |
54 return; |
98 TInt r; |
55 TInt r; |
99 TFullName oldSess, newSess; |
56 TFullName oldSess, newSess; |
100 r=TheFs.SessionPath(oldSess); |
57 r=TheFs.SessionPath(oldSess); |
101 test_KErrNone(r); |
58 test(r==KErrNone); |
102 TChar c; |
59 TChar c; |
103 r=TheFs.DriveToChar(aDrive,c); |
60 r=TheFs.DriveToChar(aDrive,c); |
104 test_KErrNone(r); |
61 test(r==KErrNone); |
105 newSess.Append(c); |
62 newSess.Append(c); |
106 newSess.Append(':'); |
63 newSess.Append(':'); |
107 newSess.Append('\\'); |
64 newSess.Append('\\'); |
108 |
65 |
109 TBuf<128> b; |
66 TBuf<128> b; |
110 TDriveInfo di; |
67 TDriveInfo di; |
111 r=TheFs.Drive(di,aDrive); |
68 r=TheFs.Drive(di,aDrive); |
112 test_KErrNone(r); |
69 test(r==KErrNone); |
113 b.Format(_L("Test dismounting of test file system on %c: (DrvAtt:%x MedAtt:%x)\n"),(TUint)c,di.iDriveAtt,di.iMediaAtt); |
70 b.Format(_L("Test dismounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt); |
114 test.Next(b); |
71 test.Next(b); |
115 |
72 |
116 // Test cannot dismount on rom drive |
73 // Test cannot dismount on rom drive |
117 test.Next(_L("Test cannot dismount on Rom drive\n")); |
74 test.Next(_L("Test cannot dismount on Rom drive")); |
118 TFullName zName; |
75 TFullName zName; |
119 r=TheFs.FileSystemName(zName,EDriveZ); |
76 r=TheFs.FileSystemName(zName,EDriveZ); |
120 test_KErrNone(r); |
77 test(r==KErrNone); |
121 r=TheFs.DismountFileSystem(zName,EDriveZ); |
78 r=TheFs.DismountFileSystem(zName,EDriveZ); |
122 test.Printf(_L("r=%d\n"),r); |
79 test.Printf(_L("r=%d"),r); |
123 // NB if paging is enabled on a ROFS partition which is part of the composite file system then the |
80 // NB if paging is enabled on a ROFS partition which is part of the composite file system then the |
124 // likelihood is that there will be a at least one file clamped: in this case there error will be KErrInUse |
81 // likelihood is that there will be a at least one file clamped: in this case there error will be KErrInUse |
125 test_Value(r, r == KErrAccessDenied || r==KErrInUse); |
82 test(r==KErrAccessDenied || r==KErrInUse); |
126 |
83 |
127 // Test cannot dismount on wrong drive |
84 // Test cannot dismount on wrong drive |
128 test.Next(_L("Test cannot dismount on wrong drive\n")); |
85 test.Next(_L("Test cannot dismount on wrong drive")); |
129 r=TheFs.DismountFileSystem(aFs,EDriveA); |
86 r=TheFs.DismountFileSystem(aFs,EDriveA); |
130 test_Value(r, r == KErrNotReady); |
87 test(r==KErrNotReady); |
131 |
88 |
132 // Test cannot dismount with wrong name |
89 // Test cannot dismount with wrong name |
133 test.Next(_L("Test cannot dismount with wrong file system name\n")); |
90 test.Next(_L("Test cannot dismount with wrong file system name")); |
134 r=TheFs.DismountFileSystem(_L("abc"),aDrive); |
91 r=TheFs.DismountFileSystem(_L("abc"),aDrive); |
135 test_Value(r, r == KErrNotFound); |
92 test(r==KErrNotFound); |
136 |
93 |
137 // Test cannot dismount with a file open |
94 // Test cannot dismount with a file open |
138 test.Next(_L("Test cannot dismount with a file open\n")); |
95 test.Next(_L("Test cannot dismount with a file open")); |
139 r=TheFs.SetSessionPath(newSess); |
96 r=TheFs.SetSessionPath(newSess); |
140 RFile file; |
97 RFile file; |
141 r=file.Replace(TheFs,_L("abc"),EFileShareAny); |
98 r=file.Replace(TheFs,_L("abc"),EFileShareAny); |
142 test_KErrNone(r); |
99 test(r==KErrNone); |
143 r=TheFs.SessionPath(newSess); |
100 r=TheFs.SessionPath(newSess); |
144 TBool open; |
101 TBool open; |
145 r=TheFs.IsFileOpen(_L("abc"),open); |
102 r=TheFs.IsFileOpen(_L("abc"),open); |
146 test_KErrNone(r); |
103 test(r==KErrNone); |
147 test(open); |
104 test(open); |
148 r=TheFs.DismountFileSystem(aFs,aDrive); |
105 r=TheFs.DismountFileSystem(aFs,aDrive); |
149 test_Value(r, r == KErrInUse); |
106 test(r==KErrInUse); |
150 file.Close(); |
107 file.Close(); |
151 |
108 |
152 // Now test dismount works |
109 // Now test dismount works |
153 test.Next(_L("Test dismounts OK\n")); |
110 test.Next(_L("Test dismounts OK")); |
154 r=TheFs.DismountFileSystem(aFs,aDrive); |
111 r=TheFs.DismountFileSystem(aFs,aDrive); |
155 if(r!=KErrNone) |
112 if(r!=KErrNone) |
156 { |
113 { |
157 test.Printf(_L("Error = %d\n"),r); |
114 test.Printf(_L("Error = %d"),r); |
158 test(EFalse); |
115 test(EFalse); |
159 } |
116 } |
160 TFullName n; |
117 TFullName n; |
161 r=TheFs.FileSystemName(n,aDrive); |
118 r=TheFs.FileSystemName(n,aDrive); |
162 test_Value(r, r == KErrNone || r==KErrNotFound); |
119 test(r==KErrNone || r==KErrNotFound); |
163 test(!n.Length()); |
120 test(!n.Length()); |
164 r=file.Replace(TheFs,_L("abc"),EFileShareAny); |
121 r=file.Replace(TheFs,_L("abc"),EFileShareAny); |
165 test_Value(r, r == KErrNotReady); |
122 test(r==KErrNotReady); |
166 file.Close(); |
123 file.Close(); |
167 |
124 |
168 r=TheFs.MountFileSystem(aFs,aDrive); |
125 r=TheFs.MountFileSystem(aFs,aDrive); |
169 if(r!=KErrNone) |
126 if(r!=KErrNone) |
170 { |
127 { |
171 test.Printf(_L("error = %d\n"),r); |
128 test.Printf(_L("error = %d\n"),r); |
172 test(EFalse); |
129 test(EFalse); |
173 } |
130 } |
174 r=TheFs.FileSystemName(n,aDrive); |
131 r=TheFs.FileSystemName(n,aDrive); |
175 test_KErrNone(r); |
132 test(r==KErrNone); |
176 test(n.Compare(aFs)==0); |
133 test(n.Compare(aFs)==0); |
177 r=file.Replace(TheFs,_L("abc"),EFileShareAny); // ??? bang |
134 r=file.Replace(TheFs,_L("abc"),EFileShareAny); // ??? bang |
178 test_KErrNone(r); |
135 test(r==KErrNone); |
179 file.Close(); |
136 file.Close(); |
180 r=TheFs.SetSessionPath(oldSess); |
137 r=TheFs.SetSessionPath(oldSess); |
181 test_KErrNone(r); |
138 test(r==KErrNone); |
182 } |
139 } |
183 |
140 |
184 static void TestDismountFileSystem(TInt aDrive) |
141 static void TestDismountFileSystem(TInt aDrive) |
185 { |
142 { |
186 test.Next(_L("TestDismountFileSystem()\n")); |
143 |
187 TInt r; |
144 TInt r; |
188 TFullName name; |
145 TFullName name; |
189 r=TheFs.FileSystemName(name,aDrive); |
146 r=TheFs.FileSystemName(name,aDrive); |
190 test_Value(r, r == KErrNone || r==KErrNotFound); |
147 test(r==KErrNone || r==KErrNotFound); |
191 if(name.Length()) |
148 if(name.Length()) |
192 CheckDismount(name,aDrive); |
149 CheckDismount(name,aDrive); |
193 } |
150 } |
194 |
151 |
195 //--------------------------------------------------- |
152 #if defined(__EPOC32__) |
|
153 static void TestFileSystem(TInt aDrive) |
196 // |
154 // |
197 // Mount a new CTestFileSystem on the drive under test |
155 // Mount a new CTestFileSystem on the drive under test |
198 // |
156 // |
199 static void TestFileSystem(TInt aDrive) |
157 { |
200 { |
|
201 test.Next(_L("TestFileSystem()\n")); |
|
202 |
|
203 if(Is_Win32(TheFs, aDrive)) |
|
204 { |
|
205 test.Printf(_L("Can't test on a simulated drive, skipping!\n")); |
|
206 return; |
|
207 } |
|
208 |
|
209 TBuf<64> b; |
158 TBuf<64> b; |
210 TChar c; |
159 TChar c; |
211 TInt r=TheFs.DriveToChar(aDrive,c); |
160 TInt r=TheFs.DriveToChar(aDrive,c); |
212 test_KErrNone(r); |
161 test(r==KErrNone); |
213 TDriveInfo di; |
162 TDriveInfo di; |
214 r=TheFs.Drive(di,aDrive); |
163 r=TheFs.Drive(di,aDrive); |
215 test_KErrNone(r); |
164 test(r==KErrNone); |
216 b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)\n"),(TUint)c,di.iDriveAtt,di.iMediaAtt); |
165 b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt); |
217 test.Next(b); |
166 test.Next(b); |
218 |
167 |
219 test.Next(_L("Test mounting of test file system\n")); |
168 test.Next(_L("Test mounting of test file system")); |
220 r=TheFs.AddFileSystem(KTestFsy); |
169 r=TheFs.AddFileSystem(_L("T_TFSYS")); |
221 if(r!=KErrNone && r!=KErrAlreadyExists) |
170 if(r!=KErrNone && r!=KErrAlreadyExists) |
222 { |
171 { |
223 test.Printf(_L("error=%d\n"),r); |
172 test.Printf(_L("error=%d"),r); |
224 test(EFalse); |
173 test(EFalse); |
225 } |
174 } |
226 |
175 |
227 TFullName oldFs; |
176 TFullName oldFs; |
228 r=TheFs.FileSystemName(oldFs,aDrive); |
177 r=TheFs.FileSystemName(oldFs,aDrive); |
229 // TFileName oldFs; |
178 // TFileName oldFs; |
230 // r=TheFs.FileSystemName(oldFs,aDrive); |
179 // r=TheFs.FileSystemName(oldFs,aDrive); |
231 test_KErrNone(r); |
180 test(r==KErrNone); |
232 r=TheFs.DismountFileSystem(oldFs,aDrive); |
181 r=TheFs.DismountFileSystem(oldFs,aDrive); |
233 if(r!=KErrNone) |
182 if(r!=KErrNone) |
234 { |
183 { |
235 test.Printf(_L("Error = %d\n"),r); |
184 test.Printf(_L("Error = %d"),r); |
236 test(EFalse); |
185 test(EFalse); |
237 } |
186 } |
238 r=TheFs.MountFileSystem(KTestFsName,aDrive); |
187 r=TheFs.MountFileSystem(_L("Test"),aDrive); |
239 test_KErrNone(r); |
188 test(r==KErrNone); |
240 |
189 |
241 TFileName newFs; |
190 TFileName newFs; |
242 r=TheFs.FileSystemName(newFs,aDrive); |
191 r=TheFs.FileSystemName(newFs,aDrive); |
243 test_KErrNone(r); |
192 test(r==KErrNone); |
244 test(newFs.Compare(KTestFsName)==0); |
193 test(newFs.Compare(_L("Test"))==0); |
245 |
194 |
246 // Check attributes |
195 // Check attributes |
247 TDriveInfo info; |
196 TDriveInfo info; |
248 r=TheFs.Drive(info,aDrive); |
197 r=TheFs.Drive(info,aDrive); |
249 test_KErrNone(r); |
198 test(r==KErrNone); |
250 |
199 |
251 test.Printf(_L("iType=%d,iConnectionBusType=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType, (TUint)info.iConnectionBusType,info.iDriveAtt,info.iMediaAtt); |
200 test.Printf(_L("iType=%d,iConnectionBusType=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
|
201 (TUint)info.iConnectionBusType,info.iDriveAtt,info.iMediaAtt); |
252 |
202 |
253 //Try to remove filesystem without dismounting. |
203 //Try to remove filesystem without dismounting. |
254 r=TheFs.RemoveFileSystem(KTestFsName); |
204 r=TheFs.RemoveFileSystem(_L("Test")); |
255 if(r!=KErrInUse) |
205 if(r!=KErrInUse) |
256 { |
206 { |
257 test.Printf(_L("error=%d\n"),r); |
207 test.Printf(_L("error=%d"),r); |
258 test(EFalse); |
208 test(EFalse); |
259 } |
209 } |
260 r=TheFs.FileSystemName(newFs,aDrive); |
210 r=TheFs.FileSystemName(newFs,aDrive); |
261 test_KErrNone(r); |
211 test(r==KErrNone); |
262 test(newFs.Compare(KTestFsName)==0); |
212 test(newFs.Compare(_L("Test"))==0); |
263 |
213 |
264 r=TheFs.DismountFileSystem(newFs,aDrive); |
214 r=TheFs.DismountFileSystem(newFs,aDrive); |
265 test_KErrNone(r); |
215 test(r==KErrNone); |
266 |
216 |
267 r=TheFs.MountFileSystem(oldFs,aDrive); |
217 r=TheFs.MountFileSystem(oldFs,aDrive); |
268 test_KErrNone(r); |
218 test(r==KErrNone); |
269 } |
219 } |
270 |
220 #endif |
271 //--------------------------------------------------- |
221 |
272 static void TestMountInvalidDrive() |
222 static void TestMountInvalidDrive() |
273 { |
223 // |
274 test.Next(_L("TestMountInvalidDrive(). Try mounting FS on an invalid drive\n")); |
224 // Attempt to mount FAT on non-local drive |
275 |
225 { |
276 //-- 1. find an invalid drive |
226 test.Start(_L("TestMountInvalidDrive")); |
277 TInt drv = 0; |
227 |
278 TDriveList drvList; |
228 TInt r; |
279 |
229 |
280 TInt nRes = TheFs.DriveList(drvList); |
230 test.Next(_L("Adding EFAT")); |
281 test_KErrNone(nRes); |
231 #ifdef __WINS__ |
282 |
232 _LIT(KFsNm, "EFAT32"); |
283 for(drv =0; drv<KMaxDrives; ++drv) |
233 #else |
284 { |
234 _LIT(KFsNm, "ELOCAL"); |
285 if(!drvList[drv]) |
235 #endif |
286 break; |
236 |
287 } |
237 r = TheFs.AddFileSystem(KFsNm); |
288 |
238 test.Printf(_L("afs: r = %d\n"), r); |
289 test.Printf(_L("Try mounting a test FS onto drive:%C:\n"), 'A'+drv); |
239 test(r == KErrNone || r == KErrAlreadyExists); |
290 |
240 test.Next(_L("mounting FAT on drive R")); |
291 nRes = TheFs.AddFileSystem(KTestFsy); |
241 r = TheFs.MountFileSystem(KFileSystemName_FAT, EDriveR); |
292 test_Value(nRes, nRes == KErrNone || nRes == KErrAlreadyExists); |
242 test(r == KErrArgument); |
293 |
243 |
294 nRes = TheFs.MountFileSystem(KTestFsName, drv); |
244 test.End(); |
295 test_Value(nRes, nRes == KErrArgument); |
|
296 |
|
297 } |
245 } |
298 |
246 |
299 // Additional step for INC083446: Corrupted miniSD not detected as corrupted by phone |
247 // Additional step for INC083446: Corrupted miniSD not detected as corrupted by phone |
300 static void TestMountingBrokenMedia(TInt aDrive) |
248 static void TestMountingBrokenMedia(TInt aDrive) |
301 // |
249 // |
306 return; |
254 return; |
307 |
255 |
308 TBuf<64> b; |
256 TBuf<64> b; |
309 TChar c; |
257 TChar c; |
310 TInt r=TheFs.DriveToChar(aDrive,c); |
258 TInt r=TheFs.DriveToChar(aDrive,c); |
311 test_KErrNone(r); |
259 test(r==KErrNone); |
312 TDriveInfo di; |
260 TDriveInfo di; |
313 r=TheFs.Drive(di,aDrive); |
261 r=TheFs.Drive(di,aDrive); |
314 test_KErrNone(r); |
262 test(r==KErrNone); |
315 b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)\n"),(TUint)c,di.iDriveAtt,di.iMediaAtt); |
263 b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt); |
316 test.Next(b); |
264 test.Next(b); |
317 |
265 |
318 test.Next(_L("Test mounting of test file system\n")); |
266 test.Next(_L("Test mounting of test file system")); |
319 r=TheFs.AddFileSystem(KTestFsy2); |
267 r=TheFs.AddFileSystem(_L("T_TFSYS2")); |
320 if(r!=KErrNone && r!=KErrAlreadyExists) |
268 if(r!=KErrNone && r!=KErrAlreadyExists) |
321 { |
269 { |
322 test.Printf(_L("error=%d\n"),r); |
270 test.Printf(_L("error=%d"),r); |
323 test(EFalse); |
271 test(EFalse); |
324 } |
272 } |
325 |
273 |
326 TFullName oldFs; |
274 TFullName oldFs; |
327 r=TheFs.FileSystemName(oldFs,aDrive); |
275 r=TheFs.FileSystemName(oldFs,aDrive); |
328 test_KErrNone(r); |
276 test(r==KErrNone); |
329 r=TheFs.DismountFileSystem(oldFs,aDrive); |
277 r=TheFs.DismountFileSystem(oldFs,aDrive); |
330 if(r!=KErrNone) |
278 if(r!=KErrNone) |
331 { |
279 { |
332 test.Printf(_L("Error = %d\n"),r); |
280 test.Printf(_L("Error = %d"),r); |
333 test(EFalse); |
281 test(EFalse); |
334 } |
282 } |
335 r=TheFs.MountFileSystem(KTestFsName2 ,aDrive); |
283 r=TheFs.MountFileSystem(_L("Test2"),aDrive); |
336 test_Value(r, r == KErrCorrupt); |
284 test(r == KErrCorrupt); |
337 |
285 |
338 TFileName newFs; |
286 TFileName newFs; |
339 r=TheFs.FileSystemName(newFs,aDrive); |
287 r=TheFs.FileSystemName(newFs,aDrive); |
340 test_KErrNone(r); |
288 test(r==KErrNone); |
341 test(newFs.Compare(KTestFsName2)==0); |
289 test(newFs.Compare(_L("Test2"))==0); |
342 |
290 |
343 // Get the number of remounts by checking the volume attributes - |
291 // Get the number of remounts by checking the volume attributes - |
344 // T_TFSYS2 hijacks the iBattery member to report back the number of times MountL() has been called |
292 // T_TFSYS2 hijacks the iBattery member to report back the number of times MountL() has been called |
345 TDriveInfo info; |
293 TDriveInfo info; |
346 TInt remounts; |
294 TInt remounts; |
347 r=TheFs.Drive(info,aDrive); |
295 r=TheFs.Drive(info,aDrive); |
348 test_KErrNone(r); |
296 test(r==KErrNone); |
349 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
297 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
350 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
298 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
351 remounts = (TInt) info.iBattery; |
299 remounts = (TInt) info.iBattery; |
352 test.Printf(_L("Initial remounts = %d\n"), remounts); |
300 test.Printf(_L("Initial remounts = %d"), remounts); |
353 |
301 |
354 // Make the file server attempt to remount the drive by looking for a non-existant DLL |
302 // Make the file server attempt to remount the drive by looking for a non-existant DLL |
355 // The file server should setop trying to remount the driver after KMaxMountFailures attempts |
303 // The file server should setop trying to remount the driver after KMaxMountFailures attempts |
356 const TInt KMaxMountFailures = 3; // copied from sf_drv.cpp |
304 const TInt KMaxMountFailures = 3; // copied from sf_drv.cpp |
357 const TInt KEntryAttempts = 10; |
305 const TInt KEntryAttempts = 10; |
378 for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++) |
326 for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++) |
379 { |
327 { |
380 TEntry entry; |
328 TEntry entry; |
381 _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL"); |
329 _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL"); |
382 r = TheFs.Entry(KNonExistantFilename, entry); |
330 r = TheFs.Entry(KNonExistantFilename, entry); |
383 test_Value(r, r == KErrCorrupt); |
331 test(r == KErrCorrupt); |
384 } |
332 } |
385 r=TheFs.Drive(info,aDrive); |
333 r=TheFs.Drive(info,aDrive); |
386 test_KErrNone(r); |
334 test(r==KErrNone); |
387 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
335 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
388 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
336 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
389 remounts = (TInt) info.iBattery; |
337 remounts = (TInt) info.iBattery; |
390 test.Printf(_L("Remounts = %d\n"), remounts); |
338 test.Printf(_L("Remounts = %d"), remounts); |
391 test(remounts == KMaxMountFailures * 2); |
339 test(remounts == KMaxMountFailures * 2); |
392 |
340 |
393 |
341 |
394 |
342 |
395 r=TheFs.DismountFileSystem(newFs,aDrive); |
343 r=TheFs.DismountFileSystem(newFs,aDrive); |
396 test_KErrNone(r); |
344 test(r==KErrNone); |
397 r=TheFs.MountFileSystem(oldFs,aDrive); |
345 r=TheFs.MountFileSystem(oldFs,aDrive); |
398 test_KErrNone(r); |
346 test(r==KErrNone); |
399 |
347 |
400 r=TheFs.RemoveFileSystem(KTestFsName2); |
348 r=TheFs.RemoveFileSystem(_L("Test2")); |
401 if(r!=KErrNone) |
349 if(r!=KErrNone) |
402 { |
350 { |
403 test.Printf(_L("error=%d\n"),r); |
351 test.Printf(_L("error=%d"),r); |
404 test(EFalse); |
352 test(EFalse); |
405 } |
353 } |
406 } |
354 } |
407 |
355 |
408 |
356 |
409 /** |
357 /** |
410 Testing obtaining media serial number for the substituted drives |
358 Testing obtaining media serial number for the substituted drives |
411 */ |
359 */ |
412 static void TestSubstDriveMediaSerialNumber() |
360 static void TestSubstDriveMediaSerialNumber() |
413 { |
361 { |
414 test.Next(_L("Test obtaining media serial number for the substituted drives\n")); |
362 test.Next(_L("Test obtaining media serial number for the substituted drives")); |
415 |
363 |
416 TInt nRes; |
364 TInt nRes; |
417 const TInt currDrvNum=CurrentDrive(); |
365 const TInt currDrvNum=CurrentDrive(); |
418 |
366 |
419 TDriveInfo drvInfo; |
367 TDriveInfo drvInfo; |
420 nRes=TheFs.Drive(drvInfo, currDrvNum); |
368 nRes=TheFs.Drive(drvInfo, currDrvNum); |
421 test_KErrNone(nRes); |
369 test(nRes==KErrNone); |
422 |
370 |
423 if(drvInfo.iDriveAtt & (KDriveAttRom | KDriveAttRedirected | KDriveAttSubsted)) |
371 if(drvInfo.iDriveAtt & (KDriveAttRom | KDriveAttRedirected | KDriveAttSubsted)) |
424 { |
372 { |
425 test.Printf(_L("Can't test on this drive!\n")); |
373 test.Printf(_L("Can't test on this drive!\n")); |
426 return; |
374 return; |
503 r = TheFs.FileSystemName(fsName, i); |
451 r = TheFs.FileSystemName(fsName, i); |
504 if (r == KErrNone) |
452 if (r == KErrNone) |
505 { |
453 { |
506 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
454 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
507 r=TheFs.Drive(driveInfo, i); |
455 r=TheFs.Drive(driveInfo, i); |
508 test_KErrNone(r); |
456 test(r==KErrNone); |
509 |
457 |
510 if (driveInfo.iType==EMediaNotPresent) |
458 if (driveInfo.iType==EMediaNotPresent) |
511 { |
459 { |
512 test.Printf(_L("The media is not present.\n")); |
460 test.Printf(_L("The media is not present.\n")); |
513 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
461 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
514 test_Value(r, r == KErrNone || r == KErrNotReady); |
462 test(r == KErrNone || r == KErrNotReady); |
515 } |
463 } |
516 else if (driveInfo.iType==EMediaCdRom) |
464 else if (driveInfo.iType==EMediaCdRom) |
517 { |
465 { |
518 test.Printf(_L("CD ROM with no media will report not ready!\n")); |
466 test.Printf(_L("CD ROM with no media will report not ready!\n")); |
519 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
467 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
520 test_Value(r, r == KErrNotReady); |
468 test(r == KErrNotReady); |
521 } |
469 } |
522 else |
470 else |
523 { |
471 { |
524 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
472 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
525 test_KErrNone(r); |
473 test_KErrNone(r); |
526 |
474 |
527 //-- test EIsDriveSync command |
475 //-- test EIsDriveSync command |
528 r = TheFs.QueryVolumeInfoExt(i, EIsDriveSync, fDrvSyncBuf); |
476 r = TheFs.QueryVolumeInfoExt(i, EIsDriveSync, fDrvSyncBuf); |
529 test_KErrNone(r); |
477 test(r == KErrNone); |
530 if(fDrvSyncBuf()) |
478 if(fDrvSyncBuf()) |
531 test.Printf(_L("The drive is Synchronous.\n")); |
479 test.Printf(_L("The drive is Synchronous.\n")); |
532 else |
480 else |
533 test.Printf(_L("The drive is Asynchronous.\n")); |
481 test.Printf(_L("The drive is Asynchronous.\n")); |
534 |
482 |
535 //----------------- |
483 //----------------- |
536 |
484 |
537 // if Fat, testing returning sub type name |
485 // if Fat, testing returning sub type name |
538 if (fsName.CompareF(KFileSystemName_FAT)==0) |
486 if (fsName.CompareF(KFileSystemName_FAT)==0) |
539 { |
487 { |
540 test_KErrNone(r); |
488 test(r == KErrNone); |
541 test(subName().CompareF(KFSSubType_FAT12)==0 || |
489 test(subName().CompareF(KFSSubType_FAT12)==0 || |
542 subName().CompareF(KFSSubType_FAT16)==0 || |
490 subName().CompareF(KFSSubType_FAT16)==0 || |
543 subName().CompareF(KFSSubType_FAT32)==0); |
491 subName().CompareF(KFSSubType_FAT32)==0); |
544 continue; |
492 continue; |
545 } |
493 } |
546 |
494 |
547 // if Lffs, testing returning file system name |
495 // if Lffs, testing returning file system name |
548 if (fsName.CompareF(_L("Lffs"))==0) |
496 if (fsName.CompareF(_L("Lffs"))==0) |
549 { |
497 { |
550 test_KErrNone(r); |
498 test(r == KErrNone); |
551 test(subName().CompareF(_L("Lffs"))==0); |
499 test(subName().CompareF(_L("Lffs"))==0); |
552 continue; |
500 continue; |
553 } |
501 } |
554 // if rofs, testing returning file system name |
502 // if rofs, testing returning file system name |
555 if (fsName.CompareF(_L("rofs"))==0) |
503 if (fsName.CompareF(_L("rofs"))==0) |
556 { |
504 { |
557 test_KErrNone(r); |
505 test(r == KErrNone); |
558 test(subName().CompareF(_L("rofs"))==0); |
506 test(subName().CompareF(_L("rofs"))==0); |
559 continue; |
507 continue; |
560 } |
508 } |
561 // if Composite, testing returning file system name |
509 // if Composite, testing returning file system name |
562 if (fsName.CompareF(_L("Composite"))==0) |
510 if (fsName.CompareF(_L("Composite"))==0) |
563 { |
511 { |
564 test_KErrNone(r); |
512 test(r == KErrNone); |
565 test(subName().CompareF(_L("Composite"))==0); |
513 test(subName().CompareF(_L("Composite"))==0); |
566 continue; |
514 continue; |
567 } |
515 } |
568 |
516 |
569 // else |
517 // else |
570 test_KErrNone(r); |
518 test(r == KErrNone); |
571 test(subName().Length()!=0); |
519 test(subName().Length()!=0); |
572 |
520 |
573 } |
521 } |
574 } |
522 } |
575 } |
523 } |
906 TInt r; |
854 TInt r; |
907 |
855 |
908 test.Printf(_L("Tested on drive: %c.\n"), (char)(aDrive+'A')); |
856 test.Printf(_L("Tested on drive: %c.\n"), (char)(aDrive+'A')); |
909 |
857 |
910 // Mount a new CTestFileSystem on the drive under test |
858 // Mount a new CTestFileSystem on the drive under test |
911 test.Next(_L("Test RFs::QueryVolumeInfoExt() on Testing File System\n")); |
859 test.Next(_L("Test RFs::QueryVolumeInfoExt() on Testing File System")); |
912 r = TheFs.AddFileSystem(KTestFsy3); |
860 r = TheFs.AddFileSystem(_L("T_TFSYS3")); |
913 if (r != KErrNone && r != KErrAlreadyExists) |
861 if (r != KErrNone && r != KErrAlreadyExists) |
914 { |
862 { |
915 test.Printf(_L("error=%d\n"),r); |
863 test.Printf(_L("error=%d"),r); |
916 test(EFalse); |
864 test(EFalse); |
917 } |
865 } |
918 TFSName oldFs; |
866 TFSName oldFs; |
919 r = TheFs.FileSystemName(oldFs,aDrive); |
867 r = TheFs.FileSystemName(oldFs,aDrive); |
920 test_KErrNone(r); |
868 test(r==KErrNone); |
921 r = TheFs.DismountFileSystem(oldFs,aDrive); |
869 r = TheFs.DismountFileSystem(oldFs,aDrive); |
922 if (r != KErrNone) |
870 if (r != KErrNone) |
923 { |
871 { |
924 test.Printf(_L("Error = %d\n"),r); |
872 test.Printf(_L("Error = %d"),r); |
925 test(EFalse); |
873 test(EFalse); |
926 } |
874 } |
927 r = TheFs.MountFileSystem(KTestFsName3, aDrive); |
875 r = TheFs.MountFileSystem(_L("Test3"),aDrive); |
928 test_KErrNone(r); |
876 test(r==KErrNone); |
929 TFSName newFs; |
877 TFSName newFs; |
930 r = TheFs.FileSystemName(newFs,aDrive); |
878 r = TheFs.FileSystemName(newFs,aDrive); |
931 test_KErrNone(r); |
879 test(r==KErrNone); |
932 test(newFs.Compare(KTestFsName3)==0); |
880 test(newFs.Compare(_L("Test3"))==0); |
933 |
881 |
934 // Sub type name query: |
882 // Sub type name query: |
935 TPckgBuf<TFSName> subNameP; |
883 TPckgBuf<TFSName> subNameP; |
936 r = TheFs.QueryVolumeInfoExt(aDrive, EFileSystemSubType, subNameP); |
884 r = TheFs.QueryVolumeInfoExt(aDrive, EFileSystemSubType, subNameP); |
937 test_KErrNone(r); |
885 test(r==KErrNone); |
938 test(subNameP() == _L("Test3SubType")); |
886 test(subNameP() == _L("Test3SubType")); |
939 |
887 |
940 // Cluster size querys: |
888 // Cluster size querys: |
941 TPckgBuf<TVolumeIOParamInfo> ioInfoP; |
889 TPckgBuf<TVolumeIOParamInfo> ioInfoP; |
942 r = TheFs.QueryVolumeInfoExt(aDrive, EIOParamInfo, ioInfoP); |
890 r = TheFs.QueryVolumeInfoExt(aDrive, EIOParamInfo, ioInfoP); |
943 test_KErrNone(r); |
891 test(r==KErrNone); |
944 test(ioInfoP().iClusterSize==1024); |
892 test(ioInfoP().iClusterSize==1024); |
945 |
893 |
946 // Mount the original file system back |
894 // Mount the original file system back |
947 r=TheFs.DismountFileSystem(newFs,aDrive); |
895 r=TheFs.DismountFileSystem(newFs,aDrive); |
948 test_KErrNone(r); |
896 test(r==KErrNone); |
949 r=TheFs.MountFileSystem(oldFs,aDrive); |
897 r=TheFs.MountFileSystem(oldFs,aDrive); |
950 test_KErrNone(r); |
898 test(r==KErrNone); |
951 |
899 |
952 r=TheFs.RemoveFileSystem(KTestFsName3); |
900 r=TheFs.RemoveFileSystem(_L("Test3")); |
953 if(r!=KErrNone) |
901 if(r!=KErrNone) |
954 { |
902 { |
955 test.Printf(_L("error=%d\n"),r); |
903 test.Printf(_L("error=%d"),r); |
956 test(EFalse); |
904 test(EFalse); |
957 } |
905 } |
958 } |
906 } |
959 |
907 |
960 |
908 |