27 using namespace Fat_Test_Utils; |
27 using namespace Fat_Test_Utils; |
28 |
28 |
29 RTest test(_L("T_FSYS")); |
29 RTest test(_L("T_FSYS")); |
30 |
30 |
31 static void TestFileSystemNames() |
31 static void TestFileSystemNames() |
32 { |
32 { |
33 test.Next(_L("Read file system names for all drives")); |
33 test.Next(_L("Read file system names for all drives")); |
34 TFullName name; |
34 TFullName name; |
35 TInt r; |
35 TInt r; |
36 for(TInt i=EDriveA;i<KMaxDrives;++i) |
36 for(TInt i=EDriveA;i<KMaxDrives;++i) |
37 { |
37 { |
38 r=TheFs.FileSystemName(name,i); |
38 r=TheFs.FileSystemName(name,i); |
39 test(r==KErrNone || r==KErrNotFound); |
39 test(r==KErrNone || r==KErrNotFound); |
40 TChar c; |
40 TChar c; |
41 r=RFs::DriveToChar(i,c); |
41 r=RFs::DriveToChar(i,c); |
42 test(r==KErrNone); |
42 test(r==KErrNone); |
43 if(name.Length()) |
43 if(name.Length()) |
44 test.Printf(_L("File System Name on drive %c is %S\n"),(char)c,&name); |
44 test.Printf(_L("File System Name on drive %c is %S\n"),(char)c,&name); |
45 else |
45 else |
46 test.Printf(_L("No file system on drive %c\n"),(char)c); |
46 test.Printf(_L("No file system on drive %c\n"),(char)c); |
47 } |
47 } |
48 } |
48 } |
49 |
49 |
50 static void CheckDismount(TDesC& aFs,TInt aDrive) |
50 static void CheckDismount(TDesC& aFs,TInt aDrive) |
51 { |
51 { |
52 |
52 |
53 if (aDrive==EDriveC) // ??? Can't test on C: - see below |
53 if (aDrive==EDriveC) // ??? Can't test on C: - see below |
54 return; |
54 return; |
55 TInt r; |
55 TInt r; |
56 TFullName oldSess, newSess; |
56 TFullName oldSess, newSess; |
57 r=TheFs.SessionPath(oldSess); |
57 r=TheFs.SessionPath(oldSess); |
58 test(r==KErrNone); |
58 test(r==KErrNone); |
59 TChar c; |
59 TChar c; |
60 r=TheFs.DriveToChar(aDrive,c); |
60 r=TheFs.DriveToChar(aDrive,c); |
61 test(r==KErrNone); |
61 test(r==KErrNone); |
62 newSess.Append(c); |
62 newSess.Append(c); |
63 newSess.Append(':'); |
63 newSess.Append(':'); |
64 newSess.Append('\\'); |
64 newSess.Append('\\'); |
65 |
65 |
66 TBuf<128> b; |
66 TBuf<128> b; |
67 TDriveInfo di; |
67 TDriveInfo di; |
68 r=TheFs.Drive(di,aDrive); |
68 r=TheFs.Drive(di,aDrive); |
69 test(r==KErrNone); |
69 test(r==KErrNone); |
70 b.Format(_L("Test dismounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(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); |
71 test.Next(b); |
71 test.Next(b); |
72 |
72 |
73 // Test cannot dismount on rom drive |
73 // Test cannot dismount on rom drive |
74 test.Next(_L("Test cannot dismount on Rom drive")); |
74 test.Next(_L("Test cannot dismount on Rom drive")); |
75 TFullName zName; |
75 TFullName zName; |
76 r=TheFs.FileSystemName(zName,EDriveZ); |
76 r=TheFs.FileSystemName(zName,EDriveZ); |
77 test(r==KErrNone); |
77 test(r==KErrNone); |
78 r=TheFs.DismountFileSystem(zName,EDriveZ); |
78 r=TheFs.DismountFileSystem(zName,EDriveZ); |
79 test.Printf(_L("r=%d"),r); |
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 |
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 |
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); |
82 test(r==KErrAccessDenied || r==KErrInUse); |
83 |
83 |
84 // Test cannot dismount on wrong drive |
84 // Test cannot dismount on wrong drive |
85 test.Next(_L("Test cannot dismount on wrong drive")); |
85 test.Next(_L("Test cannot dismount on wrong drive")); |
86 r=TheFs.DismountFileSystem(aFs,EDriveA); |
86 r=TheFs.DismountFileSystem(aFs,EDriveA); |
87 test(r==KErrNotReady); |
87 test(r==KErrNotReady); |
88 |
88 |
89 // Test cannot dismount with wrong name |
89 // Test cannot dismount with wrong name |
90 test.Next(_L("Test cannot dismount with wrong file system name")); |
90 test.Next(_L("Test cannot dismount with wrong file system name")); |
91 r=TheFs.DismountFileSystem(_L("abc"),aDrive); |
91 r=TheFs.DismountFileSystem(_L("abc"),aDrive); |
92 test(r==KErrNotFound); |
92 test(r==KErrNotFound); |
93 |
93 |
94 // Test cannot dismount with a file open |
94 // Test cannot dismount with a file open |
95 test.Next(_L("Test cannot dismount with a file open")); |
95 test.Next(_L("Test cannot dismount with a file open")); |
96 r=TheFs.SetSessionPath(newSess); |
96 r=TheFs.SetSessionPath(newSess); |
97 RFile file; |
97 RFile file; |
98 r=file.Replace(TheFs,_L("abc"),EFileShareAny); |
98 r=file.Replace(TheFs,_L("abc"),EFileShareAny); |
99 test(r==KErrNone); |
99 test(r==KErrNone); |
100 r=TheFs.SessionPath(newSess); |
100 r=TheFs.SessionPath(newSess); |
101 TBool open; |
101 TBool open; |
102 r=TheFs.IsFileOpen(_L("abc"),open); |
102 r=TheFs.IsFileOpen(_L("abc"),open); |
103 test(r==KErrNone); |
103 test(r==KErrNone); |
104 test(open); |
104 test(open); |
105 r=TheFs.DismountFileSystem(aFs,aDrive); |
105 r=TheFs.DismountFileSystem(aFs,aDrive); |
106 test(r==KErrInUse); |
106 test(r==KErrInUse); |
107 file.Close(); |
107 file.Close(); |
108 |
108 |
109 // Now test dismount works |
109 // Now test dismount works |
110 test.Next(_L("Test dismounts OK")); |
110 test.Next(_L("Test dismounts OK")); |
111 r=TheFs.DismountFileSystem(aFs,aDrive); |
111 r=TheFs.DismountFileSystem(aFs,aDrive); |
112 if(r!=KErrNone) |
112 if(r!=KErrNone) |
113 { |
113 { |
114 test.Printf(_L("Error = %d"),r); |
114 test.Printf(_L("Error = %d"),r); |
115 test(EFalse); |
115 test(EFalse); |
116 } |
116 } |
117 TFullName n; |
117 TFullName n; |
118 r=TheFs.FileSystemName(n,aDrive); |
118 r=TheFs.FileSystemName(n,aDrive); |
119 test(r==KErrNone || r==KErrNotFound); |
119 test(r==KErrNone || r==KErrNotFound); |
120 test(!n.Length()); |
120 test(!n.Length()); |
121 r=file.Replace(TheFs,_L("abc"),EFileShareAny); |
121 r=file.Replace(TheFs,_L("abc"),EFileShareAny); |
122 test(r==KErrNotReady); |
122 test(r==KErrNotReady); |
123 file.Close(); |
123 file.Close(); |
124 |
124 |
125 r=TheFs.MountFileSystem(aFs,aDrive); |
125 r=TheFs.MountFileSystem(aFs,aDrive); |
126 if(r!=KErrNone) |
126 if(r!=KErrNone) |
127 { |
127 { |
128 test.Printf(_L("error = %d\n"),r); |
128 test.Printf(_L("error = %d\n"),r); |
129 test(EFalse); |
129 test(EFalse); |
130 } |
130 } |
131 r=TheFs.FileSystemName(n,aDrive); |
131 r=TheFs.FileSystemName(n,aDrive); |
132 test(r==KErrNone); |
132 test(r==KErrNone); |
133 test(n.Compare(aFs)==0); |
133 test(n.Compare(aFs)==0); |
134 r=file.Replace(TheFs,_L("abc"),EFileShareAny); // ??? bang |
134 r=file.Replace(TheFs,_L("abc"),EFileShareAny); // ??? bang |
135 test(r==KErrNone); |
135 test(r==KErrNone); |
136 file.Close(); |
136 file.Close(); |
137 r=TheFs.SetSessionPath(oldSess); |
137 r=TheFs.SetSessionPath(oldSess); |
138 test(r==KErrNone); |
138 test(r==KErrNone); |
139 } |
139 } |
140 |
140 |
141 static void TestDismountFileSystem(TInt aDrive) |
141 static void TestDismountFileSystem(TInt aDrive) |
142 { |
142 { |
143 |
143 |
144 TInt r; |
144 TInt r; |
145 TFullName name; |
145 TFullName name; |
146 r=TheFs.FileSystemName(name,aDrive); |
146 r=TheFs.FileSystemName(name,aDrive); |
147 test(r==KErrNone || r==KErrNotFound); |
147 test(r==KErrNone || r==KErrNotFound); |
148 if(name.Length()) |
148 if(name.Length()) |
149 CheckDismount(name,aDrive); |
149 CheckDismount(name,aDrive); |
150 } |
150 } |
151 |
151 |
152 #if defined(__EPOC32__) |
152 #if defined(__EPOC32__) |
153 static void TestFileSystem(TInt aDrive) |
153 static void TestFileSystem(TInt aDrive) |
154 // |
154 // |
155 // Mount a new CTestFileSystem on the drive under test |
155 // Mount a new CTestFileSystem on the drive under test |
156 // |
156 // |
157 { |
157 { |
158 TBuf<64> b; |
158 TBuf<64> b; |
159 TChar c; |
159 TChar c; |
160 TInt r=TheFs.DriveToChar(aDrive,c); |
160 TInt r=TheFs.DriveToChar(aDrive,c); |
161 test(r==KErrNone); |
161 test(r==KErrNone); |
162 TDriveInfo di; |
162 TDriveInfo di; |
163 r=TheFs.Drive(di,aDrive); |
163 r=TheFs.Drive(di,aDrive); |
164 test(r==KErrNone); |
164 test(r==KErrNone); |
165 b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(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); |
166 test.Next(b); |
166 test.Next(b); |
167 |
167 |
168 test.Next(_L("Test mounting of test file system")); |
168 test.Next(_L("Test mounting of test file system")); |
169 r=TheFs.AddFileSystem(_L("T_TFSYS")); |
169 r=TheFs.AddFileSystem(_L("T_TFSYS")); |
170 if(r!=KErrNone && r!=KErrAlreadyExists) |
170 if(r!=KErrNone && r!=KErrAlreadyExists) |
171 { |
171 { |
172 test.Printf(_L("error=%d"),r); |
172 test.Printf(_L("error=%d"),r); |
173 test(EFalse); |
173 test(EFalse); |
174 } |
174 } |
175 |
175 |
176 TFullName oldFs; |
176 TFullName oldFs; |
177 r=TheFs.FileSystemName(oldFs,aDrive); |
177 r=TheFs.FileSystemName(oldFs,aDrive); |
178 // TFileName oldFs; |
178 // TFileName oldFs; |
179 // r=TheFs.FileSystemName(oldFs,aDrive); |
179 // r=TheFs.FileSystemName(oldFs,aDrive); |
180 test(r==KErrNone); |
180 test(r==KErrNone); |
181 r=TheFs.DismountFileSystem(oldFs,aDrive); |
181 r=TheFs.DismountFileSystem(oldFs,aDrive); |
182 if(r!=KErrNone) |
182 if(r!=KErrNone) |
183 { |
183 { |
184 test.Printf(_L("Error = %d"),r); |
184 test.Printf(_L("Error = %d"),r); |
185 test(EFalse); |
185 test(EFalse); |
186 } |
186 } |
187 r=TheFs.MountFileSystem(_L("Test"),aDrive); |
187 r=TheFs.MountFileSystem(_L("Test"),aDrive); |
188 test(r==KErrNone); |
188 test(r==KErrNone); |
189 |
189 |
190 TFileName newFs; |
190 TFileName newFs; |
191 r=TheFs.FileSystemName(newFs,aDrive); |
191 r=TheFs.FileSystemName(newFs,aDrive); |
192 test(r==KErrNone); |
192 test(r==KErrNone); |
193 test(newFs.Compare(_L("Test"))==0); |
193 test(newFs.Compare(_L("Test"))==0); |
194 |
194 |
195 // Check attributes |
195 // Check attributes |
196 TDriveInfo info; |
196 TDriveInfo info; |
197 r=TheFs.Drive(info,aDrive); |
197 r=TheFs.Drive(info,aDrive); |
198 test(r==KErrNone); |
198 test(r==KErrNone); |
199 |
199 |
200 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
200 test.Printf(_L("iType=%d,iConnectionBusType=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
201 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
201 (TUint)info.iConnectionBusType,info.iDriveAtt,info.iMediaAtt); |
202 |
202 |
203 //Try to remove filesystem without dismounting. |
203 //Try to remove filesystem without dismounting. |
204 r=TheFs.RemoveFileSystem(_L("Test")); |
204 r=TheFs.RemoveFileSystem(_L("Test")); |
205 if(r!=KErrInUse) |
205 if(r!=KErrInUse) |
206 { |
206 { |
207 test.Printf(_L("error=%d"),r); |
207 test.Printf(_L("error=%d"),r); |
208 test(EFalse); |
208 test(EFalse); |
209 } |
209 } |
210 r=TheFs.FileSystemName(newFs,aDrive); |
210 r=TheFs.FileSystemName(newFs,aDrive); |
211 test(r==KErrNone); |
211 test(r==KErrNone); |
212 test(newFs.Compare(_L("Test"))==0); |
212 test(newFs.Compare(_L("Test"))==0); |
213 |
213 |
214 r=TheFs.DismountFileSystem(newFs,aDrive); |
214 r=TheFs.DismountFileSystem(newFs,aDrive); |
215 test(r==KErrNone); |
215 test(r==KErrNone); |
216 |
216 |
217 r=TheFs.MountFileSystem(oldFs,aDrive); |
217 r=TheFs.MountFileSystem(oldFs,aDrive); |
218 test(r==KErrNone); |
218 test(r==KErrNone); |
219 } |
219 } |
220 #endif |
220 #endif |
221 |
221 |
222 static void TestMountInvalidDrive() |
222 static void TestMountInvalidDrive() |
223 // |
223 // |
224 // Attempt to mount FAT on non-local drive |
224 // Attempt to mount FAT on non-local drive |
225 { |
225 { |
226 test.Start(_L("TestMountInvalidDrive")); |
226 test.Start(_L("TestMountInvalidDrive")); |
227 |
227 |
228 TInt r; |
228 TInt r; |
229 |
229 |
230 test.Next(_L("Adding EFAT")); |
230 test.Next(_L("Adding EFAT")); |
231 #ifdef __WINS__ |
231 #ifdef __WINS__ |
232 _LIT(KFsNm, "EFAT"); |
232 _LIT(KFsNm, "EFAT32"); |
233 #else |
233 #else |
234 _LIT(KFsNm, "ELOCAL"); |
234 _LIT(KFsNm, "ELOCAL"); |
235 #endif |
235 #endif |
236 |
236 |
237 r = TheFs.AddFileSystem(KFsNm); |
237 r = TheFs.AddFileSystem(KFsNm); |
238 test.Printf(_L("afs: r = %d\n"), r); |
238 test.Printf(_L("afs: r = %d\n"), r); |
239 test(r == KErrNone || r == KErrAlreadyExists); |
239 test(r == KErrNone || r == KErrAlreadyExists); |
240 test.Next(_L("mounting FAT on drive R")); |
240 test.Next(_L("mounting FAT on drive R")); |
241 r = TheFs.MountFileSystem(KFileSystemName_FAT, EDriveR); |
241 r = TheFs.MountFileSystem(KFileSystemName_FAT, EDriveR); |
242 test(r == KErrArgument); |
242 test(r == KErrArgument); |
243 |
243 |
244 test.End(); |
244 test.End(); |
245 } |
245 } |
246 |
246 |
247 // 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 |
248 static void TestMountingBrokenMedia(TInt aDrive) |
248 static void TestMountingBrokenMedia(TInt aDrive) |
249 // |
249 // |
250 // Mount a new CTestFileSystem on the drive under test |
250 // Mount a new CTestFileSystem on the drive under test |
251 // |
251 // |
252 { |
252 { |
253 if (aDrive==EDriveC) // ??? Can't test on C: |
253 if (aDrive==EDriveC) // ??? Can't test on C: |
254 return; |
254 return; |
255 |
255 |
256 TBuf<64> b; |
256 TBuf<64> b; |
257 TChar c; |
257 TChar c; |
258 TInt r=TheFs.DriveToChar(aDrive,c); |
258 TInt r=TheFs.DriveToChar(aDrive,c); |
259 test(r==KErrNone); |
259 test(r==KErrNone); |
260 TDriveInfo di; |
260 TDriveInfo di; |
261 r=TheFs.Drive(di,aDrive); |
261 r=TheFs.Drive(di,aDrive); |
262 test(r==KErrNone); |
262 test(r==KErrNone); |
263 b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(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); |
264 test.Next(b); |
264 test.Next(b); |
265 |
265 |
266 test.Next(_L("Test mounting of test file system")); |
266 test.Next(_L("Test mounting of test file system")); |
267 r=TheFs.AddFileSystem(_L("T_TFSYS2")); |
267 r=TheFs.AddFileSystem(_L("T_TFSYS2")); |
268 if(r!=KErrNone && r!=KErrAlreadyExists) |
268 if(r!=KErrNone && r!=KErrAlreadyExists) |
269 { |
269 { |
270 test.Printf(_L("error=%d"),r); |
270 test.Printf(_L("error=%d"),r); |
271 test(EFalse); |
271 test(EFalse); |
272 } |
272 } |
273 |
273 |
274 TFullName oldFs; |
274 TFullName oldFs; |
275 r=TheFs.FileSystemName(oldFs,aDrive); |
275 r=TheFs.FileSystemName(oldFs,aDrive); |
276 test(r==KErrNone); |
276 test(r==KErrNone); |
277 r=TheFs.DismountFileSystem(oldFs,aDrive); |
277 r=TheFs.DismountFileSystem(oldFs,aDrive); |
278 if(r!=KErrNone) |
278 if(r!=KErrNone) |
279 { |
279 { |
280 test.Printf(_L("Error = %d"),r); |
280 test.Printf(_L("Error = %d"),r); |
281 test(EFalse); |
281 test(EFalse); |
282 } |
282 } |
283 r=TheFs.MountFileSystem(_L("Test2"),aDrive); |
283 r=TheFs.MountFileSystem(_L("Test2"),aDrive); |
284 test(r == KErrCorrupt); |
284 test(r == KErrCorrupt); |
285 |
285 |
286 TFileName newFs; |
286 TFileName newFs; |
287 r=TheFs.FileSystemName(newFs,aDrive); |
287 r=TheFs.FileSystemName(newFs,aDrive); |
288 test(r==KErrNone); |
288 test(r==KErrNone); |
289 test(newFs.Compare(_L("Test2"))==0); |
289 test(newFs.Compare(_L("Test2"))==0); |
290 |
290 |
291 // Get the number of remounts by checking the volume attributes - |
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 |
292 // T_TFSYS2 hijacks the iBattery member to report back the number of times MountL() has been called |
293 TDriveInfo info; |
293 TDriveInfo info; |
294 TInt remounts; |
294 TInt remounts; |
295 r=TheFs.Drive(info,aDrive); |
295 r=TheFs.Drive(info,aDrive); |
296 test(r==KErrNone); |
296 test(r==KErrNone); |
297 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,\ |
298 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
298 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
299 remounts = (TInt) info.iBattery; |
299 remounts = (TInt) info.iBattery; |
300 test.Printf(_L("Initial remounts = %d"), remounts); |
300 test.Printf(_L("Initial remounts = %d"), remounts); |
301 |
301 |
302 // 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 |
303 // 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 |
304 const TInt KMaxMountFailures = 3; // copied from sf_drv.cpp |
304 const TInt KMaxMountFailures = 3; // copied from sf_drv.cpp |
305 const TInt KEntryAttempts = 10; |
305 const TInt KEntryAttempts = 10; |
306 TInt entryAttempts; |
306 TInt entryAttempts; |
307 for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++) |
307 for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++) |
308 { |
308 { |
309 TEntry entry; |
309 TEntry entry; |
310 _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL"); |
310 _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL"); |
311 r = TheFs.Entry(KNonExistantFilename, entry); |
311 r = TheFs.Entry(KNonExistantFilename, entry); |
312 test(r == KErrCorrupt); |
312 test(r == KErrCorrupt); |
313 } |
313 } |
314 r=TheFs.Drive(info,aDrive); |
314 r=TheFs.Drive(info,aDrive); |
315 test(r==KErrNone); |
315 test(r==KErrNone); |
316 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
316 test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\ |
317 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
317 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
318 remounts = (TInt) info.iBattery; |
318 remounts = (TInt) info.iBattery; |
319 test.Printf(_L("Remounts = %d"), remounts); |
319 test.Printf(_L("Remounts = %d"), remounts); |
320 test(remounts == KMaxMountFailures); |
320 test(remounts == KMaxMountFailures); |
321 |
321 |
322 // simulate a media change to reset failure count |
322 // simulate a media change to reset failure count |
323 r = TheFs.RemountDrive(aDrive, NULL, 0); |
323 r = TheFs.RemountDrive(aDrive, NULL, 0); |
324 |
324 |
325 // now try mounting again & verify the the file server attempts to mount the drive again |
325 // now try mounting again & verify the the file server attempts to mount the drive again |
326 for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++) |
326 for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++) |
327 { |
327 { |
328 TEntry entry; |
328 TEntry entry; |
329 _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL"); |
329 _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL"); |
330 r = TheFs.Entry(KNonExistantFilename, entry); |
330 r = TheFs.Entry(KNonExistantFilename, entry); |
331 test(r == KErrCorrupt); |
331 test(r == KErrCorrupt); |
332 } |
332 } |
333 r=TheFs.Drive(info,aDrive); |
333 r=TheFs.Drive(info,aDrive); |
334 test(r==KErrNone); |
334 test(r==KErrNone); |
335 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,\ |
336 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
336 (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt); |
337 remounts = (TInt) info.iBattery; |
337 remounts = (TInt) info.iBattery; |
338 test.Printf(_L("Remounts = %d"), remounts); |
338 test.Printf(_L("Remounts = %d"), remounts); |
339 test(remounts == KMaxMountFailures * 2); |
339 test(remounts == KMaxMountFailures * 2); |
340 |
340 |
341 |
341 |
342 |
342 |
343 r=TheFs.DismountFileSystem(newFs,aDrive); |
343 r=TheFs.DismountFileSystem(newFs,aDrive); |
344 test(r==KErrNone); |
344 test(r==KErrNone); |
345 r=TheFs.MountFileSystem(oldFs,aDrive); |
345 r=TheFs.MountFileSystem(oldFs,aDrive); |
346 test(r==KErrNone); |
346 test(r==KErrNone); |
347 |
347 |
348 r=TheFs.RemoveFileSystem(_L("Test2")); |
348 r=TheFs.RemoveFileSystem(_L("Test2")); |
349 if(r!=KErrNone) |
349 if(r!=KErrNone) |
350 { |
350 { |
351 test.Printf(_L("error=%d"),r); |
351 test.Printf(_L("error=%d"),r); |
352 test(EFalse); |
352 test(EFalse); |
353 } |
353 } |
354 } |
354 } |
355 |
355 |
356 |
356 |
357 /** |
357 /** |
358 Testing obtaining media serial number for the substituted drives |
358 Testing obtaining media serial number for the substituted drives |
359 */ |
359 */ |
421 //---------------------------------------------------------------------------------------------- |
421 //---------------------------------------------------------------------------------------------- |
422 //! @SYMTestCaseID PBASE-t_fsys-0317 |
422 //! @SYMTestCaseID PBASE-t_fsys-0317 |
423 //! @SYMTestType CIT |
423 //! @SYMTestType CIT |
424 //! @SYMPREQ CR0882 |
424 //! @SYMPREQ CR0882 |
425 //! @SYMTestCaseDesc This test case is testing querying file system sub type name using |
425 //! @SYMTestCaseDesc This test case is testing querying file system sub type name using |
426 //! RFs::QueryVolumeInfoExt() API. |
426 //! RFs::QueryVolumeInfoExt() API. |
427 //! @SYMTestActions 1 querys sub type of file system on volumes mounted with 'Fat' file system |
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 |
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 |
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 |
430 //! 4 querys sub type of file system on volumes mounted with other file systems |
431 //! @SYMTestExpectedResults |
431 //! @SYMTestExpectedResults |
432 //! 1 returned error code should be KErrNone, descriptor should match 'FAT12' or 'FAT16' or 'FAT32' |
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' |
433 //! 2 returned error code should be KErrNotSupported, descriptor should match 'Lffs' |
434 //! 3 returned error code should be KErrNotSupported, descriptor should match 'rofs' |
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 |
435 //! 4 returned error code should be KErrNotSupported, descriptor length should not be zero |
436 //! @SYMTestPriority High |
436 //! @SYMTestPriority High |
437 //! @SYMTestStatus Implemented |
437 //! @SYMTestStatus Implemented |
438 //---------------------------------------------------------------------------------------------- |
438 //---------------------------------------------------------------------------------------------- |
439 static void TestFileSystemSubTypeQuery() |
439 static void TestFileSystemSubTypeQuery() |
440 { |
440 { |
441 test.Next(_L("Test querying sub type of the mounted file system")); |
441 test.Next(_L("Test querying sub type of the mounted file system")); |
442 TFSName fsName; |
442 TFSName fsName; |
443 TPckgBuf<TFSName> subName; |
443 TPckgBuf<TFSName> subName; |
444 TInt i, r; |
444 TInt i, r; |
445 TDriveInfo driveInfo; |
445 TDriveInfo driveInfo; |
446 TPckgBuf<TBool> fDrvSyncBuf; |
446 TPckgBuf<TBool> fDrvSyncBuf; |
447 |
447 |
448 |
448 |
449 for(i = EDriveA; i <= EDriveZ; ++i, subName.Zero()) |
449 for(i = EDriveA; i <= EDriveZ; ++i, subName.Zero()) |
450 { |
450 { |
451 r = TheFs.FileSystemName(fsName, i); |
451 r = TheFs.FileSystemName(fsName, i); |
452 if (r == KErrNone) |
452 if (r == KErrNone) |
453 { |
453 { |
454 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
454 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
455 r=TheFs.Drive(driveInfo, i); |
455 r=TheFs.Drive(driveInfo, i); |
456 test(r==KErrNone); |
456 test(r==KErrNone); |
457 |
457 |
458 if (driveInfo.iType==EMediaNotPresent) |
458 if (driveInfo.iType==EMediaNotPresent) |
459 { |
459 { |
460 test.Printf(_L("The media is not present.\n")); |
460 test.Printf(_L("The media is not present.\n")); |
461 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
461 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
462 test(r == KErrNone || r == KErrNotReady); |
462 test(r == KErrNone || r == KErrNotReady); |
463 } |
463 } |
464 else if (driveInfo.iType==EMediaCdRom) |
464 else if (driveInfo.iType==EMediaCdRom) |
465 { |
465 { |
466 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")); |
467 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
467 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
468 test(r == KErrNotReady); |
468 test(r == KErrNotReady); |
469 } |
469 } |
470 else |
470 else |
471 { |
471 { |
472 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
472 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
473 test_KErrNone(r); |
473 test_KErrNone(r); |
474 |
474 |
475 //-- test EIsDriveSync command |
475 //-- test EIsDriveSync command |
476 r = TheFs.QueryVolumeInfoExt(i, EIsDriveSync, fDrvSyncBuf); |
476 r = TheFs.QueryVolumeInfoExt(i, EIsDriveSync, fDrvSyncBuf); |
477 test(r == KErrNone); |
477 test(r == KErrNone); |
478 if(fDrvSyncBuf()) |
478 if(fDrvSyncBuf()) |
479 test.Printf(_L("The drive is Synchronous.\n")); |
479 test.Printf(_L("The drive is Synchronous.\n")); |
480 else |
480 else |
481 test.Printf(_L("The drive is Asynchronous.\n")); |
481 test.Printf(_L("The drive is Asynchronous.\n")); |
482 |
482 |
483 //----------------- |
483 //----------------- |
484 |
484 |
485 // if Fat, testing returning sub type name |
485 // if Fat, testing returning sub type name |
486 if (fsName.CompareF(KFileSystemName_FAT)==0) |
486 if (fsName.CompareF(KFileSystemName_FAT)==0) |
487 { |
487 { |
488 test(r == KErrNone); |
488 test(r == KErrNone); |
489 test(subName().CompareF(KFSSubType_FAT12)==0 || |
489 test(subName().CompareF(KFSSubType_FAT12)==0 || |
490 subName().CompareF(KFSSubType_FAT16)==0 || |
490 subName().CompareF(KFSSubType_FAT16)==0 || |
491 subName().CompareF(KFSSubType_FAT32)==0); |
491 subName().CompareF(KFSSubType_FAT32)==0); |
492 continue; |
492 continue; |
493 } |
493 } |
494 |
494 |
495 // if Lffs, testing returning file system name |
495 // if Lffs, testing returning file system name |
496 if (fsName.CompareF(_L("Lffs"))==0) |
496 if (fsName.CompareF(_L("Lffs"))==0) |
497 { |
497 { |
498 test(r == KErrNone); |
498 test(r == KErrNone); |
499 test(subName().CompareF(_L("Lffs"))==0); |
499 test(subName().CompareF(_L("Lffs"))==0); |
500 continue; |
500 continue; |
501 } |
501 } |
502 // if rofs, testing returning file system name |
502 // if rofs, testing returning file system name |
503 if (fsName.CompareF(_L("rofs"))==0) |
503 if (fsName.CompareF(_L("rofs"))==0) |
504 { |
504 { |
505 test(r == KErrNone); |
505 test(r == KErrNone); |
506 test(subName().CompareF(_L("rofs"))==0); |
506 test(subName().CompareF(_L("rofs"))==0); |
507 continue; |
507 continue; |
508 } |
508 } |
509 // if Composite, testing returning file system name |
509 // if Composite, testing returning file system name |
510 if (fsName.CompareF(_L("Composite"))==0) |
510 if (fsName.CompareF(_L("Composite"))==0) |
511 { |
511 { |
512 test(r == KErrNone); |
512 test(r == KErrNone); |
513 test(subName().CompareF(_L("Composite"))==0); |
513 test(subName().CompareF(_L("Composite"))==0); |
514 continue; |
514 continue; |
515 } |
515 } |
516 |
516 |
517 // else |
517 // else |
518 test(r == KErrNone); |
518 test(r == KErrNone); |
519 test(subName().Length()!=0); |
519 test(subName().Length()!=0); |
520 |
520 |
521 } |
521 } |
522 } |
522 } |
523 } |
523 } |
524 } |
524 } |
525 |
525 |
526 //---------------------------------------------------------------------------------------------- |
526 //---------------------------------------------------------------------------------------------- |
527 //! @SYMTestCaseID PBASE-t_fsys-0318 |
527 //! @SYMTestCaseID PBASE-t_fsys-0318 |
528 //! @SYMTestType CIT |
528 //! @SYMTestType CIT |
529 //! @SYMPREQ CR0882 |
529 //! @SYMPREQ CR0882 |
530 //! @SYMTestCaseDesc This test case is testing querying file system's cluster size using |
530 //! @SYMTestCaseDesc This test case is testing querying file system's cluster size using |
531 //! RFs::QueryVolumeInfoExt() API. |
531 //! RFs::QueryVolumeInfoExt() API. |
532 //! @SYMTestActions 1 querys cluster size of file system on volumes mounted with 'Fat' file system |
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 |
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 |
534 //! 3 querys cluster size of file system on volumes mounted with other file systems |
535 //! @SYMTestExpectedResults |
535 //! @SYMTestExpectedResults |
536 //! 1 returned error code should be KErrNone, cluster size should be non-zero |
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 |
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 |
538 //! 3 returned error code should be KErrNone, cluster size should be KErrNotSupported |
539 //! @SYMTestPriority High |
539 //! @SYMTestPriority High |
540 //! @SYMTestStatus Implemented |
540 //! @SYMTestStatus Implemented |
541 //---------------------------------------------------------------------------------------------- |
541 //---------------------------------------------------------------------------------------------- |
542 static void TestFileSystemClusterSizeQuery() |
542 static void TestFileSystemClusterSizeQuery() |
543 { |
543 { |
544 test.Next(_L("Test querying cluster size information of the mounted file system")); |
544 test.Next(_L("Test querying cluster size information of the mounted file system")); |
545 TFullName fsName; |
545 TFullName fsName; |
546 TPckgBuf<TVolumeIOParamInfo> ioInfo; |
546 TPckgBuf<TVolumeIOParamInfo> ioInfo; |
547 TInt i, r; |
547 TInt i, r; |
548 TDriveInfo driveInfo; |
548 TDriveInfo driveInfo; |
549 for(i = EDriveA; i <= EDriveZ; ++i) |
549 for(i = EDriveA; i <= EDriveZ; ++i) |
550 { |
550 { |
551 r = TheFs.FileSystemName(fsName, i); |
551 r = TheFs.FileSystemName(fsName, i); |
552 if (r == KErrNone) |
552 if (r == KErrNone) |
553 { |
553 { |
554 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
554 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
555 |
555 |
556 r=TheFs.Drive(driveInfo, i); |
556 r=TheFs.Drive(driveInfo, i); |
557 test(r==KErrNone); |
557 test(r==KErrNone); |
558 // if no media present |
558 // if no media present |
559 if (driveInfo.iType==EMediaNotPresent) |
559 if (driveInfo.iType==EMediaNotPresent) |
560 { |
560 { |
561 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
|
562 test(r == KErrNone || r == KErrNotReady); |
|
563 } |
|
564 else if (driveInfo.iType==EMediaCdRom) |
|
565 { |
|
566 test.Printf(_L("CD ROM with no media!\n")); |
|
567 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
561 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
568 test(r == KErrNone || r == KErrNotReady); |
562 test(r == KErrNone || r == KErrNotReady); |
569 } |
563 } |
570 else |
564 else if (driveInfo.iType==EMediaCdRom) |
571 { |
565 { |
572 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
566 test.Printf(_L("CD ROM with no media!\n")); |
573 test(KErrNone == r); |
567 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
574 // if Fat |
568 test(r == KErrNone || r == KErrNotReady); |
575 if (fsName.CompareF(KFileSystemName_FAT)==0) |
569 } |
576 { |
570 else |
577 test(ioInfo().iClusterSize != 0); |
571 { |
578 continue; |
572 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
579 } |
573 test(KErrNone == r); |
580 // else if Lffs |
574 // if Fat |
581 if (fsName.CompareF(_L("Lffs"))==0) |
575 if (fsName.CompareF(KFileSystemName_FAT)==0) |
582 { |
576 { |
583 TBusLocalDrive drive; |
577 test(ioInfo().iClusterSize != 0); |
584 TBool changeFlag = EFalse; |
578 continue; |
585 TInt locDriveNumber; |
579 } |
586 TLocalDriveCaps DriveCaps; |
580 // else if Lffs |
587 TLocalDriveCapsV7 DriveCapsV7; |
581 if (fsName.CompareF(_L("Lffs"))==0) |
588 for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++) |
582 { |
589 { |
583 TBusLocalDrive drive; |
590 r = drive.Connect(locDriveNumber,changeFlag); |
584 TBool changeFlag = EFalse; |
591 if(r==KErrNone) |
585 TInt locDriveNumber; |
592 { |
586 TLocalDriveCaps DriveCaps; |
593 |
587 TLocalDriveCapsV7 DriveCapsV7; |
594 TPckg<TLocalDriveCaps> capsPckg(DriveCaps); |
588 for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++) |
595 r=drive.Caps(capsPckg); |
589 { |
596 if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS)) |
590 r = drive.Connect(locDriveNumber,changeFlag); |
597 { |
591 if(r==KErrNone) |
598 break; |
592 { |
599 } |
593 |
600 drive.Disconnect(); |
594 TPckg<TLocalDriveCaps> capsPckg(DriveCaps); |
601 } |
595 r=drive.Caps(capsPckg); |
602 } |
596 if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS)) |
603 TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7); |
597 { |
604 r=drive.Caps(capsPckg); |
598 break; |
605 test(r==KErrNone); |
599 } |
606 drive.Disconnect(); |
600 drive.Disconnect(); |
607 if(DriveCapsV7.iObjectModeSize == 0) |
601 } |
608 { |
602 } |
609 test(ioInfo().iClusterSize == 512); |
603 TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7); |
610 continue; |
604 r=drive.Caps(capsPckg); |
611 } |
605 test(r==KErrNone); |
612 else |
606 drive.Disconnect(); |
613 { |
607 if(DriveCapsV7.iObjectModeSize == 0) |
614 test((TUint32)(ioInfo().iClusterSize) == DriveCapsV7.iObjectModeSize); |
608 { |
615 continue; |
609 test(ioInfo().iClusterSize == 512); |
616 } |
610 continue; |
617 } |
611 } |
618 // else |
612 else |
619 //-- we can not suggest anything about unknown filesystem, thus do not check the result. |
613 { |
|
614 test((TUint32)(ioInfo().iClusterSize) == DriveCapsV7.iObjectModeSize); |
|
615 continue; |
|
616 } |
|
617 } |
|
618 // else |
|
619 //-- we can not suggest anything about unknown filesystem, thus do not check the result. |
620 //test(ioInfo().iClusterSize == KErrNotSupported); |
620 //test(ioInfo().iClusterSize == KErrNotSupported); |
621 |
621 |
622 } |
622 } |
623 } |
623 } |
624 } |
624 } |
625 } |
625 } |
626 |
626 |
627 //---------------------------------------------------------------------------------------------- |
627 //---------------------------------------------------------------------------------------------- |
628 //! @SYMTestCaseID PBASE-t_fsys-0319 |
628 //! @SYMTestCaseID PBASE-t_fsys-0319 |
629 //! @SYMTestType CIT |
629 //! @SYMTestType CIT |
630 //! @SYMPREQ CR0882 |
630 //! @SYMPREQ CR0882 |
631 //! @SYMTestCaseDesc This test case is testing querying block size of underlying media using |
631 //! @SYMTestCaseDesc This test case is testing querying block size of underlying media using |
632 //! RFs::QueryVolumeInfoExt() API. |
632 //! RFs::QueryVolumeInfoExt() API. |
633 //! @SYMTestActions 1 querys block size on volumes mounted with MMC card type of media |
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 |
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 |
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 |
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 |
637 //! 5 querys block size on volumes mounted with Nand flash (data) type of media |
638 //! @SYMTestExpectedResults |
638 //! @SYMTestExpectedResults |
639 //! 1 returned error code should be KErrNone, block size should be 512 |
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 |
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 |
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 |
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 |
643 //! 5 returned error code should be KErrNone, block size should be 512 |
644 //! @SYMTestPriority High |
644 //! @SYMTestPriority High |
645 //! @SYMTestStatus Implemented |
645 //! @SYMTestStatus Implemented |
646 //---------------------------------------------------------------------------------------------- |
646 //---------------------------------------------------------------------------------------------- |
647 static void TestMediaBlockSizeQuery() |
647 static void TestMediaBlockSizeQuery() |
648 { |
648 { |
649 test.Next(_L("Test querying block size information of the underlying media")); |
649 test.Next(_L("Test querying block size information of the underlying media")); |
650 #if defined(__WINS__) |
650 #if defined(__WINS__) |
651 test.Printf(_L("This test case runs on hardware only")); |
651 test.Printf(_L("This test case runs on hardware only")); |
652 return; |
652 return; |
653 |
653 |
654 #else // test runs on hardware only. |
654 #else // test runs on hardware only. |
655 TFSName fsName; |
655 TFSName fsName; |
656 TPckgBuf<TVolumeIOParamInfo> ioInfo; |
656 TPckgBuf<TVolumeIOParamInfo> ioInfo; |
657 TInt i, r; |
657 TInt i, r; |
658 TDriveInfo driveInfo; |
658 TDriveInfo driveInfo; |
659 for(i = EDriveA; i <= EDriveZ; ++i) |
659 for(i = EDriveA; i <= EDriveZ; ++i) |
660 { |
660 { |
661 r = TheFs.FileSystemName(fsName, i); |
661 r = TheFs.FileSystemName(fsName, i); |
662 if (r == KErrNone) |
662 if (r == KErrNone) |
663 { |
663 { |
664 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
664 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
665 r=TheFs.Drive(driveInfo, i); |
665 r=TheFs.Drive(driveInfo, i); |
666 test(r==KErrNone); |
666 test(r==KErrNone); |
667 // if no media present |
667 // if no media present |
668 if (driveInfo.iType==EMediaNotPresent) |
668 if (driveInfo.iType==EMediaNotPresent) |
669 { |
669 { |
670 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
|
671 test(r == KErrNone || r == KErrNotReady); |
|
672 } |
|
673 else if (driveInfo.iType==EMediaCdRom) |
|
674 { |
|
675 test.Printf(_L("CD ROM with no media will report not ready!\n")); |
|
676 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
670 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
677 test(r == KErrNotReady); |
671 test(r == KErrNone || r == KErrNotReady); |
678 } |
672 } |
679 else |
673 else if (driveInfo.iType==EMediaCdRom) |
680 { |
674 { |
681 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
675 test.Printf(_L("CD ROM with no media will report not ready!\n")); |
682 test(KErrNone == r); |
676 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
683 // if MMC, test block size >= 512; |
677 test(r == KErrNotReady); |
684 // (Version 4.3 MMC cards introduce the concept of a "Super Page" which should be used as |
678 } |
685 // guide when calculating the cluster size. For these cards the reported block size may be |
679 else |
686 // any multiple of 512). |
680 { |
687 if ((driveInfo.iType == EMediaHardDisk) && |
681 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
688 (driveInfo.iDriveAtt & KDriveAttRemovable) && |
682 test(KErrNone == r); |
689 (driveInfo.iDriveAtt & KDriveAttLocal)) |
683 // if MMC, test block size >= 512; |
690 { |
684 // (Version 4.3 MMC cards introduce the concept of a "Super Page" which should be used as |
691 test(ioInfo().iBlockSize >= 512); |
685 // guide when calculating the cluster size. For these cards the reported block size may be |
692 continue; |
686 // any multiple of 512). |
693 } |
687 if ((driveInfo.iType == EMediaHardDisk) && |
694 // if RAM, test block size == 1; |
688 (driveInfo.iDriveAtt & KDriveAttRemovable) && |
695 if ((driveInfo.iType == EMediaRam) && |
689 (driveInfo.iDriveAtt & KDriveAttLocal)) |
696 (driveInfo.iDriveAtt & KDriveAttLocal) && |
690 { |
697 (driveInfo.iDriveAtt & KDriveAttInternal)) |
691 test(ioInfo().iBlockSize >= 512); |
698 { |
692 continue; |
699 test(ioInfo().iBlockSize == 1); |
693 } |
700 continue; |
694 // if RAM, test block size == 1; |
701 } |
695 if ((driveInfo.iType == EMediaRam) && |
702 // if NOR flash, test block size == 512 (default block size); |
696 (driveInfo.iDriveAtt & KDriveAttLocal) && |
703 if ((driveInfo.iType == EMediaFlash) && |
697 (driveInfo.iDriveAtt & KDriveAttInternal)) |
704 (driveInfo.iDriveAtt & KDriveAttLocal) && |
698 { |
705 (driveInfo.iDriveAtt & KDriveAttInternal)) |
699 test(ioInfo().iBlockSize == 1); |
706 { |
700 continue; |
707 TBusLocalDrive drive; |
701 } |
708 TBool changeFlag = EFalse; |
702 // if NOR flash, test block size == 512 (default block size); |
709 TInt locDriveNumber; |
703 if ((driveInfo.iType == EMediaFlash) && |
710 TLocalDriveCaps DriveCaps; |
704 (driveInfo.iDriveAtt & KDriveAttLocal) && |
711 TLocalDriveCapsV7 DriveCapsV7; |
705 (driveInfo.iDriveAtt & KDriveAttInternal)) |
712 for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++) |
706 { |
713 { |
707 TBusLocalDrive drive; |
714 r = drive.Connect(locDriveNumber,changeFlag); |
708 TBool changeFlag = EFalse; |
715 if(r==KErrNone) |
709 TInt locDriveNumber; |
716 { |
710 TLocalDriveCaps DriveCaps; |
717 TPckg<TLocalDriveCaps> capsPckg(DriveCaps); |
711 TLocalDriveCapsV7 DriveCapsV7; |
718 r=drive.Caps(capsPckg); |
712 for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++) |
719 if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS)) |
713 { |
720 { |
714 r = drive.Connect(locDriveNumber,changeFlag); |
721 break; |
715 if(r==KErrNone) |
722 } |
716 { |
723 drive.Disconnect(); |
717 TPckg<TLocalDriveCaps> capsPckg(DriveCaps); |
724 } |
718 r=drive.Caps(capsPckg); |
725 } |
719 if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS)) |
726 TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7); |
720 { |
727 r=drive.Caps(capsPckg); |
721 break; |
728 test(r==KErrNone); |
722 } |
729 if ((fsName.CompareF(_L("Lffs"))==0) && (DriveCapsV7.iObjectModeSize != 0)) |
723 drive.Disconnect(); |
730 { |
724 } |
731 test(ioInfo().iBlockSize == (TInt) DriveCapsV7.iObjectModeSize); |
725 } |
732 continue; |
726 TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7); |
733 } |
727 r=drive.Caps(capsPckg); |
734 else |
728 test(r==KErrNone); |
735 { |
729 if ((fsName.CompareF(_L("Lffs"))==0) && (DriveCapsV7.iObjectModeSize != 0)) |
736 test(ioInfo().iBlockSize == (TInt) KDefaultVolumeBlockSize); |
730 { |
737 continue; |
731 test(ioInfo().iBlockSize == (TInt) DriveCapsV7.iObjectModeSize); |
738 } |
732 continue; |
739 } |
733 } |
740 // if Nand flash (with Fat file system), test block size == 512 (small-block) or 2048 (large-block) |
734 else |
741 if ((driveInfo.iType == EMediaNANDFlash) && |
735 { |
742 (driveInfo.iDriveAtt & KDriveAttLocal) && |
736 test(ioInfo().iBlockSize == (TInt) KDefaultVolumeBlockSize); |
743 (driveInfo.iDriveAtt & KDriveAttInternal)) |
737 continue; |
744 { |
738 } |
745 test(ioInfo().iBlockSize == 512 || ioInfo().iBlockSize == 2048); |
739 } |
746 continue; |
740 // if Nand flash (with Fat file system), test block size == 512 (small-block) or 2048 (large-block) |
747 } |
741 if ((driveInfo.iType == EMediaNANDFlash) && |
748 } |
742 (driveInfo.iDriveAtt & KDriveAttLocal) && |
749 } |
743 (driveInfo.iDriveAtt & KDriveAttInternal)) |
750 } |
744 { |
751 #endif // __WINS__ |
745 test(ioInfo().iBlockSize == 512 || ioInfo().iBlockSize == 2048); |
752 } |
746 continue; |
|
747 } |
|
748 } |
|
749 } |
|
750 } |
|
751 #endif // __WINS__ |
|
752 } |
753 |
753 |
754 //---------------------------------------------------------------------------------------------- |
754 //---------------------------------------------------------------------------------------------- |
755 //! @SYMTestCaseID PBASE-t_fsys-0320 |
755 //! @SYMTestCaseID PBASE-t_fsys-0320 |
756 //! @SYMTestType CIT |
756 //! @SYMTestType CIT |
757 //! @SYMPREQ CR0882 |
757 //! @SYMPREQ CR0882 |
758 //! @SYMTestCaseDesc This test case is testing wrapper API RFs::FileSystemSubType() has the same |
758 //! @SYMTestCaseDesc This test case is testing wrapper API RFs::FileSystemSubType() has the same |
759 //! behaviours as RFs::QueryVolumeInfoExt() |
759 //! behaviours as RFs::QueryVolumeInfoExt() |
760 //! @SYMTestActions 1 querys file system sub type name by both APIs |
760 //! @SYMTestActions 1 querys file system sub type name by both APIs |
761 //! @SYMTestExpectedResults |
761 //! @SYMTestExpectedResults |
762 //! 1 returned error codes and descriptors of both API should be identical |
762 //! 1 returned error codes and descriptors of both API should be identical |
763 //! @SYMTestPriority High |
763 //! @SYMTestPriority High |
764 //! @SYMTestStatus Implemented |
764 //! @SYMTestStatus Implemented |
765 //---------------------------------------------------------------------------------------------- |
765 //---------------------------------------------------------------------------------------------- |
766 static void TestFileSystemSubType() |
766 static void TestFileSystemSubType() |
767 { |
767 { |
768 test.Next(_L("Test wrapper API RFs::FileSystemSubType()'s behaviour")); |
768 test.Next(_L("Test wrapper API RFs::FileSystemSubType()'s behaviour")); |
769 TFSName fsName; |
769 TFSName fsName; |
770 TPckgBuf<TFSName> subName; |
770 TPckgBuf<TFSName> subName; |
771 TInt r; |
771 TInt r; |
772 TFSName subName1; |
772 TFSName subName1; |
773 TInt r1; |
773 TInt r1; |
774 |
774 |
775 for(TInt i = EDriveA; i <= EDriveZ; ++i) |
775 for(TInt i = EDriveA; i <= EDriveZ; ++i) |
776 { |
776 { |
777 r = TheFs.FileSystemName(fsName, i); |
777 r = TheFs.FileSystemName(fsName, i); |
778 if (r == KErrNone) |
778 if (r == KErrNone) |
779 { |
779 { |
780 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
780 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
781 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
781 r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName); |
782 r1 = TheFs.FileSystemSubType(i, subName1); |
782 r1 = TheFs.FileSystemSubType(i, subName1); |
783 test(r==r1); |
783 test(r==r1); |
784 if (subName().Length()) |
784 if (subName().Length()) |
785 { |
785 { |
786 test(subName().CompareF(subName1)==0); |
786 test(subName().CompareF(subName1)==0); |
787 } |
787 } |
788 else |
788 else |
789 { |
789 { |
790 test(subName1.Length()==0); |
790 test(subName1.Length()==0); |
791 } |
791 } |
792 } |
792 } |
793 } |
793 } |
794 } |
794 } |
795 |
795 |
796 //---------------------------------------------------------------------------------------------- |
796 //---------------------------------------------------------------------------------------------- |
797 //! @SYMTestCaseID PBASE-t_fsys-0321 |
797 //! @SYMTestCaseID PBASE-t_fsys-0321 |
798 //! @SYMTestType CIT |
798 //! @SYMTestType CIT |
799 //! @SYMPREQ CR0882 |
799 //! @SYMPREQ CR0882 |
800 //! @SYMTestCaseDesc This test case is testing wrapper API RFs::VolumeIOParam() has the same |
800 //! @SYMTestCaseDesc This test case is testing wrapper API RFs::VolumeIOParam() has the same |
801 //! behaviours as RFs::QueryVolumeInfoExt() |
801 //! behaviours as RFs::QueryVolumeInfoExt() |
802 //! @SYMTestActions 1 querys volume IO params by both APIs |
802 //! @SYMTestActions 1 querys volume IO params by both APIs |
803 //! @SYMTestExpectedResults |
803 //! @SYMTestExpectedResults |
804 //! 1 returned error codes and IO param values of both API should be identical |
804 //! 1 returned error codes and IO param values of both API should be identical |
805 //! @SYMTestPriority High |
805 //! @SYMTestPriority High |
806 //! @SYMTestStatus Implemented |
806 //! @SYMTestStatus Implemented |
807 //---------------------------------------------------------------------------------------------- |
807 //---------------------------------------------------------------------------------------------- |
808 static void TestVolumeIOParam() |
808 static void TestVolumeIOParam() |
809 { |
809 { |
810 test.Next(_L("Test wrapper API RFs::VolumeIOParam()'s behaviour")); |
810 test.Next(_L("Test wrapper API RFs::VolumeIOParam()'s behaviour")); |
811 TFSName fsName; |
811 TFSName fsName; |
812 TPckgBuf<TVolumeIOParamInfo> ioInfo; |
812 TPckgBuf<TVolumeIOParamInfo> ioInfo; |
813 TInt r; |
813 TInt r; |
814 TVolumeIOParamInfo ioInfo1; |
814 TVolumeIOParamInfo ioInfo1; |
815 TInt r1; |
815 TInt r1; |
816 |
816 |
817 for(TInt i = EDriveA; i <= EDriveZ; ++i) |
817 for(TInt i = EDriveA; i <= EDriveZ; ++i) |
818 { |
818 { |
819 r = TheFs.FileSystemName(fsName, i); |
819 r = TheFs.FileSystemName(fsName, i); |
820 if (r == KErrNone) |
820 if (r == KErrNone) |
821 { |
821 { |
822 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
822 test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A')); |
823 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
823 r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo); |
824 r1 = TheFs.VolumeIOParam(i, ioInfo1); |
824 r1 = TheFs.VolumeIOParam(i, ioInfo1); |
825 test(r==r1); |
825 test(r==r1); |
826 test(ioInfo().iBlockSize == ioInfo1.iBlockSize); |
826 test(ioInfo().iBlockSize == ioInfo1.iBlockSize); |
827 test(ioInfo().iClusterSize == ioInfo1.iClusterSize); |
827 test(ioInfo().iClusterSize == ioInfo1.iClusterSize); |
828 test(ioInfo().iRecReadBufSize == ioInfo1.iRecReadBufSize); |
828 test(ioInfo().iRecReadBufSize == ioInfo1.iRecReadBufSize); |
829 test(ioInfo().iRecWriteBufSize == ioInfo1.iRecWriteBufSize); |
829 test(ioInfo().iRecWriteBufSize == ioInfo1.iRecWriteBufSize); |
830 } |
830 } |
831 } |
831 } |
832 } |
832 } |
833 |
833 |
834 |
834 |
835 //---------------------------------------------------------------------------------------------- |
835 //---------------------------------------------------------------------------------------------- |
836 //! @SYMTestCaseID PBASE-t_fsys-0322 |
836 //! @SYMTestCaseID PBASE-t_fsys-0322 |
837 //! @SYMTestType CIT |
837 //! @SYMTestType CIT |
838 //! @SYMPREQ CR0882 |
838 //! @SYMPREQ CR0882 |
839 //! @SYMTestCaseDesc This test case is testing RFs::QueryVolumeInfoExt() API on a testing file system |
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 |
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 |
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 |
842 //! 2 querys file system's cluster size on the drive under testing |
843 //! @SYMTestExpectedResults |
843 //! @SYMTestExpectedResults |
844 //! 1 returned error code should be KErrNone, sub type name should match 'Test3SubType' |
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 |
845 //! 2 returned error code should be KErrNone, cluster size should equal 1024 |
846 //! @SYMTestPriority High |
846 //! @SYMTestPriority High |
847 //! @SYMTestStatus Implemented |
847 //! @SYMTestStatus Implemented |
848 //---------------------------------------------------------------------------------------------- |
848 //---------------------------------------------------------------------------------------------- |
849 static void TestQueryVolumeInfoExtOnTestFS(TInt aDrive) |
849 static void TestQueryVolumeInfoExtOnTestFS(TInt aDrive) |
850 { |
850 { |
851 if (aDrive==EDriveC) // Can't test on C: |
851 if (aDrive==EDriveC) // Can't test on C: |
852 return; |
852 return; |
853 |
853 |
854 TInt r; |
854 TInt r; |
855 |
855 |
856 test.Printf(_L("Tested on drive: %c.\n"), (char)(aDrive+'A')); |
856 test.Printf(_L("Tested on drive: %c.\n"), (char)(aDrive+'A')); |
857 |
857 |
858 // Mount a new CTestFileSystem on the drive under test |
858 // Mount a new CTestFileSystem on the drive under test |
859 test.Next(_L("Test RFs::QueryVolumeInfoExt() on Testing File System")); |
859 test.Next(_L("Test RFs::QueryVolumeInfoExt() on Testing File System")); |
860 r = TheFs.AddFileSystem(_L("T_TFSYS3")); |
860 r = TheFs.AddFileSystem(_L("T_TFSYS3")); |
861 if (r != KErrNone && r != KErrAlreadyExists) |
861 if (r != KErrNone && r != KErrAlreadyExists) |
862 { |
862 { |
863 test.Printf(_L("error=%d"),r); |
863 test.Printf(_L("error=%d"),r); |
864 test(EFalse); |
864 test(EFalse); |
865 } |
865 } |
866 TFSName oldFs; |
866 TFSName oldFs; |
867 r = TheFs.FileSystemName(oldFs,aDrive); |
867 r = TheFs.FileSystemName(oldFs,aDrive); |
868 test(r==KErrNone); |
868 test(r==KErrNone); |
869 r = TheFs.DismountFileSystem(oldFs,aDrive); |
869 r = TheFs.DismountFileSystem(oldFs,aDrive); |
870 if (r != KErrNone) |
870 if (r != KErrNone) |
871 { |
871 { |
872 test.Printf(_L("Error = %d"),r); |
872 test.Printf(_L("Error = %d"),r); |
873 test(EFalse); |
873 test(EFalse); |
874 } |
874 } |
875 r = TheFs.MountFileSystem(_L("Test3"),aDrive); |
875 r = TheFs.MountFileSystem(_L("Test3"),aDrive); |
876 test(r==KErrNone); |
876 test(r==KErrNone); |
877 TFSName newFs; |
877 TFSName newFs; |
878 r = TheFs.FileSystemName(newFs,aDrive); |
878 r = TheFs.FileSystemName(newFs,aDrive); |
879 test(r==KErrNone); |
879 test(r==KErrNone); |
880 test(newFs.Compare(_L("Test3"))==0); |
880 test(newFs.Compare(_L("Test3"))==0); |
881 |
881 |
882 // Sub type name query: |
882 // Sub type name query: |
883 TPckgBuf<TFSName> subNameP; |
883 TPckgBuf<TFSName> subNameP; |
884 r = TheFs.QueryVolumeInfoExt(aDrive, EFileSystemSubType, subNameP); |
884 r = TheFs.QueryVolumeInfoExt(aDrive, EFileSystemSubType, subNameP); |
885 test(r==KErrNone); |
885 test(r==KErrNone); |
886 test(subNameP() == _L("Test3SubType")); |
886 test(subNameP() == _L("Test3SubType")); |
887 |
887 |
888 // Cluster size querys: |
888 // Cluster size querys: |
889 TPckgBuf<TVolumeIOParamInfo> ioInfoP; |
889 TPckgBuf<TVolumeIOParamInfo> ioInfoP; |
890 r = TheFs.QueryVolumeInfoExt(aDrive, EIOParamInfo, ioInfoP); |
890 r = TheFs.QueryVolumeInfoExt(aDrive, EIOParamInfo, ioInfoP); |
891 test(r==KErrNone); |
891 test(r==KErrNone); |
892 test(ioInfoP().iClusterSize==1024); |
892 test(ioInfoP().iClusterSize==1024); |
893 |
893 |
894 // Mount the original file system back |
894 // Mount the original file system back |
895 r=TheFs.DismountFileSystem(newFs,aDrive); |
895 r=TheFs.DismountFileSystem(newFs,aDrive); |
896 test(r==KErrNone); |
896 test(r==KErrNone); |
897 r=TheFs.MountFileSystem(oldFs,aDrive); |
897 r=TheFs.MountFileSystem(oldFs,aDrive); |
898 test(r==KErrNone); |
898 test(r==KErrNone); |
899 |
899 |
900 r=TheFs.RemoveFileSystem(_L("Test3")); |
900 r=TheFs.RemoveFileSystem(_L("Test3")); |
901 if(r!=KErrNone) |
901 if(r!=KErrNone) |
902 { |
902 { |
903 test.Printf(_L("error=%d"),r); |
903 test.Printf(_L("error=%d"),r); |
904 test(EFalse); |
904 test(EFalse); |
905 } |
905 } |
906 } |
906 } |
907 |
907 |
908 |
908 |
909 //---------------------------------------------------------------------------------------------- |
909 //---------------------------------------------------------------------------------------------- |
910 /** |
910 /** |
911 Test remounting the file system with objects opened. |
911 Test remounting the file system with objects opened. |