|
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // f32test\server\t_fsrv.cpp |
|
15 // |
|
16 // |
|
17 #define __E32TEST_EXTENSION__ |
|
18 #include <f32file.h> |
|
19 #include <e32test.h> |
|
20 #include "t_server.h" |
|
21 #include "t_chlffs.h" |
|
22 |
|
23 #include "f32_test_utils.h" |
|
24 |
|
25 using namespace F32_Test_Utils; |
|
26 |
|
27 |
|
28 RTest test(_L("T_FSRV")); |
|
29 |
|
30 |
|
31 |
|
32 const TInt KMaxParses=7; |
|
33 const TInt KHeapSize=0x2000; |
|
34 TFileName tPath; |
|
35 TBool gFirstTime=ETrue; |
|
36 const TInt KMaxVolumeName=11; |
|
37 |
|
38 TInt substDrive=0; |
|
39 |
|
40 TFileName gTestSessionPath; |
|
41 |
|
42 TInt LargeFileSize; |
|
43 TInt gDrive=-1; |
|
44 |
|
45 struct SParse |
|
46 { |
|
47 const TText* src; |
|
48 const TText* rel; |
|
49 const TText* def; |
|
50 const TText* fullName; |
|
51 const TText* drive; |
|
52 const TText* path; |
|
53 const TText* name; |
|
54 const TText* ext; |
|
55 }; |
|
56 |
|
57 struct SParseServer |
|
58 { |
|
59 const TText* src; |
|
60 const TText* rel; |
|
61 const TText* fullName; |
|
62 const TText* drive; |
|
63 const TText* path; |
|
64 const TText* name; |
|
65 const TText* ext; |
|
66 }; |
|
67 |
|
68 LOCAL_D SParse parse[KMaxParses] = |
|
69 { |
|
70 {_S("A:\\PATH\\NAME.EXT"),NULL,NULL,_S("A:\\PATH\\NAME.EXT"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".EXT")}, |
|
71 {_S("A:\\PATH\\NAME"),NULL,NULL,_S("A:\\PATH\\NAME"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S("")}, |
|
72 {_S("A:\\PATH\\"),NULL,NULL,_S("A:\\PATH\\"),_S("A:"),_S("\\PATH\\"),_S(""),_S("")}, |
|
73 {_S("A:"),NULL,NULL,_S("A:"),_S("A:"),_S(""),_S(""),_S("")}, |
|
74 {_S(""),NULL,NULL,_S(""),_S(""),_S(""),_S(""),_S("")}, |
|
75 {_S("A:\\PATH\\NAME"),_S("A:\\ZZZZ\\YYYY.XXX"),NULL,_S("A:\\PATH\\NAME.XXX"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".XXX")}, |
|
76 {_S("NAME"),_S(".YYY"),_S("A:\\PATH\\"),_S("A:\\PATH\\NAME.YYY"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".YYY")} |
|
77 }; |
|
78 |
|
79 LOCAL_D SParseServer parseServer[KMaxParses] = |
|
80 { |
|
81 {_S("A:\\PATH\\NAME.EXT"),NULL,_S("A:\\PATH\\NAME.EXT"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".EXT")}, |
|
82 {_S("A:\\PATH\\NAME"),NULL,_S("A:\\PATH\\NAME"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S("")}, |
|
83 {_S("A:\\PATH\\"),NULL,_S("A:\\PATH\\"),_S("A:"),_S("\\PATH\\"),_S(""),_S("")}, |
|
84 {_S("A:"),NULL,_S("A:\\ABCDEF\\"),_S("A:"),_S("\\ABCDEF\\"),_S(""),_S("")}, |
|
85 {_S(""),NULL,_S("C:\\ABCDEF\\"),_S("C:"),_S("\\ABCDEF\\"),_S(""),_S("")}, |
|
86 {_S("A:\\PATH\\NAME"),_S("A:\\ZZZZ\\YYYY.XXX"),_S("A:\\PATH\\NAME.XXX"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".XXX")}, |
|
87 {_S("NAME"),_S(".YYY"),_S("C:\\ABCDEF\\NAME.YYY"),_S("C:"),_S("\\ABCDEF\\"),_S("NAME"),_S(".YYY")} |
|
88 }; |
|
89 |
|
90 LOCAL_C TInt pathTestThread(TAny*) |
|
91 // |
|
92 // The entry point for the producer thread. |
|
93 // |
|
94 { |
|
95 |
|
96 RTest test(_L("Second thread path handling")); |
|
97 test.Title(); |
|
98 |
|
99 test.Start(_L("Path test thread")); |
|
100 RFs f; |
|
101 TInt r=f.Connect(); |
|
102 test(r==KErrNone); |
|
103 r=f.SessionPath(tPath); |
|
104 test(r==KErrNone); |
|
105 f.Close(); |
|
106 |
|
107 return(KErrNone); |
|
108 } |
|
109 |
|
110 LOCAL_C void printDriveAtt(TInt aDrive,TUint anAtt) |
|
111 // |
|
112 // Print a drive attribute. |
|
113 // |
|
114 { |
|
115 |
|
116 test.Printf(_L("%c: "),aDrive+'A'); |
|
117 if (anAtt&KDriveAttLocal) |
|
118 test.Printf(_L("LOCAL ")); |
|
119 if (anAtt&KDriveAttRom) |
|
120 test.Printf(_L("ROM ")); |
|
121 if (anAtt&KDriveAttRedirected) |
|
122 test.Printf(_L("REDIR ")); |
|
123 if (anAtt&KDriveAttSubsted) |
|
124 test.Printf(_L("SUBST ")); |
|
125 if (anAtt&KDriveAttInternal) |
|
126 test.Printf(_L("INTERNAL ")); |
|
127 if (anAtt&KDriveAttHidden) |
|
128 test.Printf(_L("HIDDEN ")); |
|
129 if ((anAtt&KDriveAttRemovable) && !(anAtt&KDriveAttLogicallyRemovable)) |
|
130 test.Printf(_L("PHYSICALLYREMOVABLE ")); |
|
131 if ((anAtt&KDriveAttRemovable) && (anAtt&KDriveAttLogicallyRemovable)) |
|
132 test.Printf(_L("LOGICALLYREMOVABLE ")); |
|
133 |
|
134 test.Printf(_L("\n")); |
|
135 } |
|
136 |
|
137 LOCAL_C void printDriveInfo(TInt aDrive,TDriveInfo& anInfo) |
|
138 // |
|
139 // Print a drive info. |
|
140 // |
|
141 { |
|
142 |
|
143 printDriveAtt(aDrive,anInfo.iDriveAtt); |
|
144 test.Printf(_L(" MEDIA-ATT=")); |
|
145 if (anInfo.iMediaAtt==0) |
|
146 test.Printf(_L("<none>")); |
|
147 if (anInfo.iMediaAtt&KMediaAttVariableSize) |
|
148 test.Printf(_L("VariableSize ")); |
|
149 if (anInfo.iMediaAtt&KMediaAttDualDensity) |
|
150 test.Printf(_L("DualDensity ")); |
|
151 if (anInfo.iMediaAtt&KMediaAttFormattable) |
|
152 test.Printf(_L("Formattable ")); |
|
153 if (anInfo.iMediaAtt&KMediaAttWriteProtected) |
|
154 test.Printf(_L("WProtected ")); |
|
155 test.Printf(_L("\n BATTERY=")); |
|
156 switch(anInfo.iBattery) |
|
157 { |
|
158 case EBatNotSupported: test.Printf(_L("Not supported\n")); break; |
|
159 case EBatGood: test.Printf(_L("Good\n")); break; |
|
160 case EBatLow: test.Printf(_L("Low\n")); break; |
|
161 default: |
|
162 test.Printf(_L("Unknown value\n")); |
|
163 } |
|
164 test.Printf(_L(" MEDIA=")); |
|
165 switch(anInfo.iType) |
|
166 { |
|
167 case EMediaNotPresent: test.Printf(_L("Not present\n")); break; |
|
168 case EMediaUnknown: test.Printf(_L("Unknown\n")); break; |
|
169 case EMediaFloppy: test.Printf(_L("Floppy\n")); break; |
|
170 case EMediaHardDisk: test.Printf(_L("Hard disk\n")); break; |
|
171 case EMediaCdRom: test.Printf(_L("CD Rom\n")); break; |
|
172 case EMediaRam: test.Printf(_L("Ram\n")); break; |
|
173 case EMediaFlash: test.Printf(_L("Flash\n")); break; |
|
174 case EMediaRom: test.Printf(_L("Rom\n")); break; |
|
175 case EMediaRemote: test.Printf(_L("Remote\n")); break; |
|
176 case EMediaNANDFlash: test.Printf(_L("NANDFlash\n")); break; |
|
177 default: |
|
178 test.Printf(_L("Unknown value\n")); |
|
179 } |
|
180 } |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 LOCAL_C void MountRemoteFilesystem() |
|
186 { |
|
187 test.Next(_L("Mount Remote Drive simulator on Q:")); |
|
188 |
|
189 TInt r=TheFs.AddFileSystem(_L("CFAFSDLY")); |
|
190 test.Printf(_L("Add remote file system")); |
|
191 test.Printf(_L("AddFileSystem returned %d\n"),r); |
|
192 test_Value(r, r==KErrNone || r==KErrAlreadyExists); |
|
193 |
|
194 r=TheFs.MountFileSystem(_L("DELAYFS"),EDriveQ); |
|
195 |
|
196 |
|
197 test.Printf(_L("Mount remote file system")); |
|
198 test.Printf(_L("MountFileSystem returned %d\n"),r); |
|
199 test_Value(r, r==KErrNone || r==KErrCorrupt || r==KErrNotReady || r==KErrAlreadyExists); |
|
200 |
|
201 } |
|
202 |
|
203 |
|
204 LOCAL_C void DisMountRemoteFilesystem() |
|
205 { |
|
206 |
|
207 test.Printf(_L("Dismounting the remote Drives \n")); |
|
208 |
|
209 TInt r=TheFs.DismountFileSystem(_L("DELAYFS"),EDriveQ); |
|
210 |
|
211 test.Printf(_L("Dismounting the Remote Drive returned %d\n"),r); |
|
212 |
|
213 test(r==KErrNone ); |
|
214 } |
|
215 |
|
216 |
|
217 LOCAL_C void CreateSubstDrive() |
|
218 { |
|
219 test.Printf(_L("Create Substitute Drive \n")); |
|
220 |
|
221 TDriveList driveList; |
|
222 TInt i ; |
|
223 |
|
224 TInt r=TheFs.SessionPath(gTestSessionPath); |
|
225 test(r==KErrNone); |
|
226 |
|
227 r=TheFs.DriveList(driveList, KDriveAttExclude|KDriveAttLocal); |
|
228 test( r==KErrNone ); |
|
229 |
|
230 |
|
231 for ( i = EDriveO; i < KMaxDrives; i++) |
|
232 { |
|
233 |
|
234 if ( driveList[i] == 0) |
|
235 { |
|
236 if (i == EDriveQ) continue; // Q reserved to mount a virtual Remote Drive, as part of the test. |
|
237 substDrive = i; |
|
238 break; |
|
239 } |
|
240 } |
|
241 |
|
242 |
|
243 if (substDrive) |
|
244 { |
|
245 TDriveInfo driveInfo; |
|
246 r=TheFs.Drive(driveInfo,substDrive); |
|
247 test(r==KErrNone); |
|
248 |
|
249 if (driveInfo.iDriveAtt==KDriveAttLocal) |
|
250 { |
|
251 return; // Subst local drives fails |
|
252 } |
|
253 |
|
254 TFileName n; |
|
255 r=TheFs.Subst(n,substDrive); |
|
256 test(r==KErrNone); |
|
257 test(n.Length()==0); |
|
258 r=TheFs.SetSubst(gTestSessionPath,substDrive); |
|
259 test(r==KErrNone); |
|
260 r=TheFs.Subst(n,substDrive); |
|
261 test(r==KErrNone); |
|
262 test(n==gTestSessionPath); |
|
263 } |
|
264 |
|
265 |
|
266 } |
|
267 |
|
268 |
|
269 LOCAL_C void RemoveSubstDrive() |
|
270 { |
|
271 if( substDrive) |
|
272 { |
|
273 test.Printf(_L("Removing Substitute Drive \n")); |
|
274 TInt r =TheFs.SetSubst(_L(""),substDrive); |
|
275 test(r ==KErrNone); |
|
276 } |
|
277 |
|
278 } |
|
279 |
|
280 |
|
281 |
|
282 LOCAL_C void testDriveInfo(TInt aDrive,TDriveInfo& anInfo) |
|
283 // |
|
284 // Test the drive info is reasonable |
|
285 // |
|
286 { |
|
287 |
|
288 test(anInfo.iBattery==EBatLow || anInfo.iBattery==EBatGood || anInfo.iBattery==EBatNotSupported); |
|
289 |
|
290 if (aDrive==EDriveZ) |
|
291 { |
|
292 if (anInfo.iType==EMediaNotPresent) |
|
293 return; |
|
294 |
|
295 test(anInfo.iMediaAtt==KMediaAttWriteProtected); |
|
296 test(anInfo.iDriveAtt==(KDriveAttRom|KDriveAttInternal)); |
|
297 test(anInfo.iType==EMediaRom); |
|
298 } |
|
299 |
|
300 else if (GetDriveLFFS()==aDrive) |
|
301 { |
|
302 if (anInfo.iType==EMediaNotPresent) |
|
303 return; |
|
304 |
|
305 test(anInfo.iDriveAtt&(KDriveAttLocal|KDriveAttInternal)==KDriveAttLocal|KDriveAttInternal); // LFFS sets KDriveAttTransaction as well |
|
306 test(anInfo.iType==EMediaFlash); |
|
307 test(anInfo.iMediaAtt==KMediaAttFormattable); |
|
308 } |
|
309 /* |
|
310 Why assume certain drive letters can only refer to certain drive types? |
|
311 else if (aDrive==EDriveC || aDrive==EDriveY) |
|
312 { |
|
313 if (anInfo.iType==EMediaNotPresent) |
|
314 return; |
|
315 |
|
316 // test(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttInternal)); |
|
317 |
|
318 test(anInfo.iDriveAtt&(KDriveAttLocal|KDriveAttInternal)==KDriveAttLocal|KDriveAttInternal); // LFFS sets KDriveAttTransaction as well |
|
319 test(anInfo.iType==EMediaRam || anInfo.iType==EMediaFlash); |
|
320 if(anInfo.iType==EMediaRam) test(anInfo.iMediaAtt==(KMediaAttVariableSize|KMediaAttFormattable)); |
|
321 else if(anInfo.iType==EMediaFlash) test(anInfo.iMediaAtt==KMediaAttFormattable); |
|
322 } |
|
323 |
|
324 else if (aDrive==EDriveD || aDrive==EDriveX) |
|
325 { |
|
326 if (anInfo.iType==EMediaNotPresent) |
|
327 return; |
|
328 |
|
329 test(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttRemovable)); |
|
330 test(anInfo.iType==EMediaHardDisk); |
|
331 test(anInfo.iMediaAtt & KMediaAttFormattable); |
|
332 } |
|
333 */ |
|
334 } |
|
335 |
|
336 |
|
337 /* |
|
338 * The following test has the requirement that the only remote drive is the one we mount |
|
339 * during the test and which doesn't have any other attributes set. If this is not the |
|
340 * case then the test conditions must be changed, in order for the test to stop failing. |
|
341 */ |
|
342 |
|
343 |
|
344 LOCAL_C void testDriveList() |
|
345 // |
|
346 // Test the drive list. |
|
347 // |
|
348 { |
|
349 |
|
350 test.Start(_L("The drive list\n")); |
|
351 |
|
352 |
|
353 TInt err; |
|
354 TInt drivecount = 0; |
|
355 TDriveList driveList; |
|
356 TDriveInfo info; |
|
357 TUint flags; |
|
358 TInt removableDriveCount =0; |
|
359 TInt nonHiddenRemovableDriveCount =0; |
|
360 TInt logicallyRemovableDriveCount =0; |
|
361 TInt substDriveCount =0; |
|
362 TInt exclusiveSubstDriveCount =0; |
|
363 TInt hiddenDriveCount = 0; |
|
364 TInt hiddenOrRemoteDriveCount = 0; |
|
365 |
|
366 TInt i ; |
|
367 |
|
368 |
|
369 //--------------------------------------------- |
|
370 //! @SYMTestCaseID PBASE-T_FSRV-0544 |
|
371 //! @SYMTestType UT |
|
372 //! @SYMREQ CR909, CR1086 |
|
373 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList) does not return remote or hidden drives. |
|
374 //! @SYMTestActions Call DriveList to get the drive list. |
|
375 //! @SYMTestExpectedResults Check that no remote or hidden drive was returned. Count the number of drives we got |
|
376 //! and seperately the number of none hidden removable ones. |
|
377 //! @SYMTestPriority High |
|
378 //! @SYMTestStatus Implemented |
|
379 //--------------------------------------------- |
|
380 |
|
381 |
|
382 test.Printf(_L("Test existing DriveList \n")); |
|
383 |
|
384 err = TheFs.DriveList(driveList); |
|
385 test( err == KErrNone ); |
|
386 |
|
387 for ( i = 0; i < KMaxDrives; i++) |
|
388 { |
|
389 if (driveList[i]) |
|
390 { |
|
391 err = TheFs.Drive(info, i); |
|
392 test( err == KErrNone ); |
|
393 test( info.iType != EMediaRemote ); |
|
394 test( !(info.iDriveAtt & KDriveAttRemote ) ); |
|
395 test( !(info.iDriveAtt & KDriveAttHidden ) ); |
|
396 drivecount++; |
|
397 |
|
398 if( info.iDriveAtt & KDriveAttRemovable) |
|
399 nonHiddenRemovableDriveCount++; |
|
400 |
|
401 printDriveAtt(i,info.iDriveAtt); |
|
402 |
|
403 } |
|
404 |
|
405 } |
|
406 |
|
407 |
|
408 TInt nonHiddenNonRemovables = drivecount - nonHiddenRemovableDriveCount; |
|
409 test.Printf(_L("Found %d non hidden non removable drives\n"), nonHiddenNonRemovables); |
|
410 test.Printf(_L("Found %d non hidden removable drives \n"),nonHiddenRemovableDriveCount); |
|
411 |
|
412 |
|
413 |
|
414 //--------------------------------------------- |
|
415 //! @SYMTestCaseID PBASE-T_FSRV-0545 |
|
416 //! @SYMTestType UT |
|
417 //! @SYMREQ CR909, CR1086 |
|
418 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to return all |
|
419 //! available drives, including the remote and the hidden ones. |
|
420 //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttAll. |
|
421 //! @SYMTestExpectedResults Check that the number of drives is increased by the number of hidden and remote drives and also that the number of remote drives is one (one remote drive we mounted). |
|
422 //! Also count the number of substitute, exclusively substitute, removable, physically removable and logically removable drives. |
|
423 //! @SYMTestPriority High |
|
424 //! @SYMTestStatus Implemented |
|
425 //--------------------------------------------- |
|
426 |
|
427 |
|
428 test.Printf(_L("Return all available drives\n")); |
|
429 |
|
430 TInt allDrivecount = 0; |
|
431 flags = KDriveAttAll; |
|
432 err = TheFs.DriveList(driveList, flags); |
|
433 |
|
434 test( err == KErrNone ); |
|
435 for ( i = 0; i < KMaxDrives; i++) |
|
436 { |
|
437 if (driveList[i]) |
|
438 { |
|
439 err = TheFs.Drive(info,i); |
|
440 test( err == KErrNone ); |
|
441 allDrivecount++; |
|
442 |
|
443 if( info.iDriveAtt & KDriveAttSubsted ) |
|
444 substDriveCount++; |
|
445 |
|
446 if( info.iDriveAtt == KDriveAttSubsted) |
|
447 exclusiveSubstDriveCount++; |
|
448 |
|
449 if( info.iDriveAtt & KDriveAttHidden) |
|
450 hiddenDriveCount++; |
|
451 |
|
452 if( info.iDriveAtt & (KDriveAttHidden|KDriveAttRemote)) |
|
453 hiddenOrRemoteDriveCount++; |
|
454 |
|
455 if( info.iDriveAtt & KDriveAttRemovable) |
|
456 removableDriveCount++; |
|
457 |
|
458 if( info.iDriveAtt & KDriveAttLogicallyRemovable) |
|
459 logicallyRemovableDriveCount++; |
|
460 |
|
461 |
|
462 printDriveAtt(i,info.iDriveAtt); |
|
463 } |
|
464 } |
|
465 |
|
466 test(allDrivecount == drivecount + hiddenOrRemoteDriveCount); |
|
467 test(hiddenOrRemoteDriveCount - hiddenDriveCount == 1); |
|
468 |
|
469 test.Printf(_L("Found %d substitute drives\n"), substDriveCount); |
|
470 test.Printf(_L("Found %d exclusively substitute drives \n"),exclusiveSubstDriveCount); |
|
471 test.Printf(_L("Found %d hidden drives\n"), hiddenDriveCount); |
|
472 |
|
473 TInt nonRemovables = drivecount - removableDriveCount; |
|
474 TInt physicallyRemovable = removableDriveCount - logicallyRemovableDriveCount; |
|
475 test.Printf(_L("Found %d non removables drives\n"), nonRemovables); |
|
476 test.Printf(_L("Found %d physically removable drives \n"),physicallyRemovable); |
|
477 test.Printf(_L("Found %d logically removable drives \n"),logicallyRemovableDriveCount); |
|
478 |
|
479 |
|
480 //--------------------------------------------- |
|
481 //! @SYMTestCaseID PBASE-T_FSRV-0546 |
|
482 //! @SYMTestType UT |
|
483 //! @SYMREQ CR909 |
|
484 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to specify |
|
485 //! certain attributes that drives to be returned should have. |
|
486 //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttRemovable. |
|
487 //! @SYMTestExpectedResults Check that the number of drives returned is the same, since no removable drive was added. |
|
488 //! @SYMTestPriority High |
|
489 //! @SYMTestStatus Implemented |
|
490 //--------------------------------------------- |
|
491 |
|
492 |
|
493 test.Printf(_L("Return only Removable \n")); |
|
494 |
|
495 drivecount = 0; |
|
496 |
|
497 flags = KDriveAttRemovable; |
|
498 err = TheFs.DriveList(driveList, flags); |
|
499 test( err == KErrNone ); |
|
500 for ( i = 0; i < KMaxDrives; i++) |
|
501 { |
|
502 if (driveList[i]) |
|
503 { |
|
504 err = TheFs.Drive(info, i); |
|
505 test( err == KErrNone ); |
|
506 test( info.iDriveAtt & KDriveAttRemovable ); |
|
507 drivecount++; |
|
508 |
|
509 printDriveAtt(i,info.iDriveAtt); |
|
510 } |
|
511 |
|
512 } |
|
513 |
|
514 test( drivecount == removableDriveCount ); // no removable drive was added |
|
515 |
|
516 |
|
517 //--------------------------------------------- |
|
518 //! @SYMTestCaseID PBASE-T_FSRV-0547 |
|
519 //! @SYMTestType UT |
|
520 //! @SYMREQ CR909 |
|
521 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to specify |
|
522 //! certain attributes(as a combination)that drives to be returned should have. |
|
523 //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttRemovable | KDriveAttRemote |
|
524 //! @SYMTestExpectedResults Check that the number of drives is increased by one, since we also allow remote drives. |
|
525 //! @SYMTestPriority High |
|
526 //! @SYMTestStatus Implemented |
|
527 //--------------------------------------------- |
|
528 |
|
529 |
|
530 test.Printf(_L("Return only Removable and Remote \n")); |
|
531 |
|
532 drivecount = 0; |
|
533 flags = KDriveAttRemovable | KDriveAttRemote; |
|
534 err = TheFs.DriveList(driveList, flags); |
|
535 test( err == KErrNone ); |
|
536 for ( i = 0; i < KMaxDrives; i++) |
|
537 { |
|
538 if (driveList[i]) |
|
539 { |
|
540 err = TheFs.Drive(info, i); |
|
541 test( err == KErrNone ); |
|
542 test( (info.iDriveAtt & KDriveAttRemovable ) || (info.iDriveAtt & KDriveAttRemote)); |
|
543 drivecount++; |
|
544 |
|
545 printDriveAtt(i,info.iDriveAtt); |
|
546 |
|
547 } |
|
548 |
|
549 } |
|
550 test( drivecount == removableDriveCount + 1 ); //contains the remote drive we mounted |
|
551 |
|
552 |
|
553 //--------------------------------------------- |
|
554 //! @SYMTestCaseID PBASE-T_FSRV-0548 |
|
555 //! @SYMTestType UT |
|
556 //! @SYMREQ CR909 |
|
557 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclusively |
|
558 //! return drives with certain attributes. |
|
559 //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttExclusive | KDriveAttRemote. |
|
560 //! @SYMTestExpectedResults Check that only the remote drive that was mounted is returned. |
|
561 //! @SYMTestPriority High |
|
562 //! @SYMTestStatus Implemented |
|
563 //--------------------------------------------- |
|
564 |
|
565 |
|
566 test.Printf(_L("Return Exclusively Remote drives \n")); |
|
567 |
|
568 drivecount = 0; |
|
569 flags = KDriveAttExclusive | KDriveAttRemote; |
|
570 TUint match = KDriveAttRemote; |
|
571 err = TheFs.DriveList(driveList, flags); |
|
572 test( err == KErrNone ); |
|
573 for ( i = 0; i < KMaxDrives; i++) |
|
574 { |
|
575 if (driveList[i]) |
|
576 { |
|
577 err = TheFs.Drive(info, i); |
|
578 test( err == KErrNone ); |
|
579 test( (info.iDriveAtt == match)); |
|
580 drivecount++; |
|
581 |
|
582 printDriveAtt(i,info.iDriveAtt); |
|
583 } |
|
584 |
|
585 } |
|
586 test( drivecount == 1 ); //The remote drive we mounted. |
|
587 |
|
588 |
|
589 //--------------------------------------------- |
|
590 //! @SYMTestCaseID PBASE-T_FSRV-0549 |
|
591 //! @SYMTestType UT |
|
592 //! @SYMREQ CR909 |
|
593 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclude drives |
|
594 //! to be returned with certain attributes. |
|
595 //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttExclude | KDriveAttRemovable. |
|
596 //! @SYMTestExpectedResults Check that the remote drive we mounted is included as a non removable one. |
|
597 //! @SYMTestPriority High |
|
598 //! @SYMTestStatus Implemented |
|
599 //--------------------------------------------- |
|
600 |
|
601 |
|
602 test.Printf(_L("Exclude Removable\n")); |
|
603 |
|
604 drivecount = 0; |
|
605 flags = KDriveAttExclude | KDriveAttRemovable; |
|
606 err = TheFs.DriveList(driveList, flags); |
|
607 test( err == KErrNone ); |
|
608 for (i = 0; i < KMaxDrives; i++) |
|
609 { |
|
610 if (driveList[i]) |
|
611 { |
|
612 err = TheFs.Drive(info, i); |
|
613 test( err == KErrNone ); |
|
614 test( (!(info.iDriveAtt & KDriveAttRemovable ) )); |
|
615 drivecount++; |
|
616 |
|
617 printDriveAtt(i,info.iDriveAtt); |
|
618 } |
|
619 |
|
620 } |
|
621 test ( drivecount == allDrivecount - removableDriveCount); |
|
622 test ( drivecount == nonRemovables + hiddenDriveCount + 1) ; //The remote drive we added is non removable |
|
623 |
|
624 |
|
625 |
|
626 //--------------------------------------------- |
|
627 //! @SYMTestCaseID PBASE-T_FSRV-0550 |
|
628 //! @SYMTestType UT |
|
629 //! @SYMREQ CR909 |
|
630 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclude |
|
631 //! drives to be returned with certain attributes(as a combination). |
|
632 //! @SYMTestActions Call DriveList by passing to aFlags a value of |
|
633 //! KDriveAttExclude | KDriveAttRemovable | KDriveAttRemote. |
|
634 //! @SYMTestExpectedResults Test that only the remote drive that was mounted is returned. |
|
635 //! @SYMTestPriority High |
|
636 //! @SYMTestStatus Implemented |
|
637 //--------------------------------------------- |
|
638 |
|
639 |
|
640 |
|
641 test.Printf(_L("Exclude Removable and Remote\n")); |
|
642 |
|
643 drivecount = 0; |
|
644 flags = KDriveAttExclude | KDriveAttRemovable | KDriveAttRemote; |
|
645 err = TheFs.DriveList(driveList, flags); |
|
646 |
|
647 test( err == KErrNone ); |
|
648 |
|
649 for ( i = 0; i < KMaxDrives; i++) |
|
650 { |
|
651 if (driveList[i]) |
|
652 { |
|
653 err = TheFs.Drive(info,i); |
|
654 test( err == KErrNone ); |
|
655 test( (!(info.iDriveAtt & KDriveAttRemovable ) && (!(info.iDriveAtt & KDriveAttRemote )))); |
|
656 drivecount++; |
|
657 |
|
658 printDriveAtt(i,info.iDriveAtt); |
|
659 } |
|
660 } |
|
661 test(drivecount == (allDrivecount - removableDriveCount - 1) ); // also excluding the removables and the remote drive |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 |
|
667 //--------------------------------------------- |
|
668 //! @SYMTestCaseID PBASE-T_FSRV-0551 |
|
669 //! @SYMTestType UT |
|
670 //! @SYMREQ CR909 |
|
671 //! @SYMTestCaseDesc Test RFs::DriveList(TDriveList& aList, TUint aFlags) with substitute drives. |
|
672 //! @SYMTestActions Call DriveList by passing to aFlags combinations of attributes that exclude, exclusive or |
|
673 //! not substitute drives. |
|
674 //! @SYMTestExpectedResults Test that only the appropriate drives are returned. |
|
675 //! @SYMTestPriority High |
|
676 //! @SYMTestStatus Implemented |
|
677 //--------------------------------------------- |
|
678 |
|
679 |
|
680 |
|
681 if (substDrive) |
|
682 { |
|
683 |
|
684 |
|
685 test.Printf(_L("Exclude Remote and Substed\n")); |
|
686 |
|
687 drivecount = 0; |
|
688 flags = KDriveAttExclude | KDriveAttRemote | KDriveAttSubsted; |
|
689 err = TheFs.DriveList(driveList, flags); |
|
690 |
|
691 test( err == KErrNone ); |
|
692 |
|
693 for ( i = 0; i < KMaxDrives; i++) |
|
694 { |
|
695 if (driveList[i]) |
|
696 { |
|
697 err = TheFs.Drive(info,i); |
|
698 test( err == KErrNone ); |
|
699 test( (!(info.iDriveAtt & KDriveAttRemote ) && (!(info.iDriveAtt & KDriveAttSubsted )))); |
|
700 drivecount++; |
|
701 |
|
702 printDriveAtt(i,info.iDriveAtt); |
|
703 } |
|
704 } |
|
705 test(drivecount == (allDrivecount - substDriveCount- 1) ); |
|
706 |
|
707 |
|
708 |
|
709 test.Printf(_L("Exclusively Exclude Substed drives\n")); |
|
710 |
|
711 drivecount = 0; |
|
712 flags = KDriveAttExclusive | KDriveAttExclude | KDriveAttSubsted; |
|
713 err = TheFs.DriveList(driveList, flags); |
|
714 |
|
715 test( err == KErrNone ); |
|
716 |
|
717 for ( i = 0; i < KMaxDrives; i++) |
|
718 { |
|
719 if (driveList[i]) |
|
720 { |
|
721 err = TheFs.Drive(info,i); |
|
722 test( err == KErrNone ); |
|
723 test( info.iDriveAtt != KDriveAttSubsted ); |
|
724 drivecount++; |
|
725 |
|
726 printDriveAtt(i,info.iDriveAtt); |
|
727 } |
|
728 |
|
729 } |
|
730 |
|
731 test(drivecount == (allDrivecount - exclusiveSubstDriveCount) ); |
|
732 |
|
733 } |
|
734 |
|
735 |
|
736 //--------------------------------------------- |
|
737 //! @SYMTestCaseID PBASE-T_FSRV-0552 |
|
738 //! @SYMTestType UT |
|
739 //! @SYMREQ CR909 |
|
740 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) returns the correct value for every |
|
741 //! combination of matching mask. |
|
742 //! @SYMTestActions Call DriveList for every combination of mask and check that the correct value is returned. |
|
743 //! A structure is used to store the expected value for each combination. |
|
744 //! @SYMTestExpectedResults Test for every combination that only drives with the correct attributes are retruned. |
|
745 //! @SYMTestPriority High |
|
746 //! @SYMTestStatus Implemented |
|
747 //--------------------------------------------- |
|
748 |
|
749 |
|
750 test.Printf(_L("Test All Combinations \n")); |
|
751 |
|
752 struct TCombinations |
|
753 { |
|
754 TUint iMatchMask; // The Match Mask to be combined with drive attributes |
|
755 TInt iExpectedResultNoAtts; // Expected result when flag used on it's own |
|
756 TInt iExpectedResultWithAtts; // Expected result when flag used in combination with drive flags |
|
757 }; |
|
758 |
|
759 TCombinations testCombinations[] = { |
|
760 { 0, KErrNone, KErrNone}, |
|
761 { KDriveAttAll, KErrNone, KErrArgument }, |
|
762 { KDriveAttExclude, KErrArgument, KErrNone }, |
|
763 { KDriveAttExclusive, KErrArgument, KErrNone }, |
|
764 { KDriveAttExclude | KDriveAttExclusive, KErrArgument, KErrNone }, |
|
765 { KDriveAttAll | KDriveAttExclude, KErrArgument, KErrArgument }, |
|
766 { KDriveAttAll | KDriveAttExclusive, KErrArgument, KErrArgument}, |
|
767 { KDriveAttAll | KDriveAttExclude | KDriveAttExclusive, KErrArgument, KErrArgument}}; |
|
768 |
|
769 TDriveList fullDriveList; |
|
770 err = TheFs.DriveList(fullDriveList, KDriveAttAll); |
|
771 test( err == KErrNone ); |
|
772 |
|
773 for ( i = 0; i < KMaxDrives; i++) |
|
774 { |
|
775 if (driveList[i]) |
|
776 { |
|
777 err = TheFs.Drive(info,i); |
|
778 test( err == KErrNone ); |
|
779 printDriveAtt(i,info.iDriveAtt); |
|
780 } |
|
781 } |
|
782 |
|
783 for(TUint matchIdx = 0; matchIdx < sizeof(testCombinations) / sizeof(TCombinations); matchIdx++) |
|
784 { |
|
785 test.Printf(_L("\nMatch Flags: KDriveAttAll[%c] KDriveAttExclude[%c] KDriveAttExclusive[%c]\n"), testCombinations[matchIdx].iMatchMask & KDriveAttAll ? 'X' : ' ', |
|
786 testCombinations[matchIdx].iMatchMask & KDriveAttExclude ? 'X' : ' ', |
|
787 testCombinations[matchIdx].iMatchMask & KDriveAttExclusive ? 'X' : ' '); |
|
788 |
|
789 for(TUint testAtt = 0; testAtt <= KMaxTUint8; testAtt++) |
|
790 { |
|
791 TDriveList newDriveList; |
|
792 err = TheFs.DriveList(newDriveList, testCombinations[matchIdx].iMatchMask | testAtt); |
|
793 |
|
794 //test.Printf(_L(" ATT : 0x%08x \n"), testAtt); |
|
795 //test.Printf(_L("Expected Result : %d \n"), testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts); |
|
796 //test.Printf(_L(" Actual Result : 0x%08x \n"), err); |
|
797 |
|
798 test( err == (testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts) ); |
|
799 |
|
800 if(err == KErrNone) |
|
801 { |
|
802 //printDriveAtt(0, testAtt); //Prints attributes |
|
803 for ( i = 0; i < KMaxDrives; i++) |
|
804 { |
|
805 TBool expectMatch = EFalse; |
|
806 |
|
807 switch(testCombinations[matchIdx].iMatchMask) |
|
808 { |
|
809 case 0: |
|
810 expectMatch = (fullDriveList[i] & testAtt) != 0; |
|
811 break; |
|
812 |
|
813 case KDriveAttAll: |
|
814 expectMatch = ETrue; |
|
815 break; |
|
816 |
|
817 case KDriveAttExclude : |
|
818 expectMatch = (fullDriveList[i] & testAtt) == 0; |
|
819 break; |
|
820 |
|
821 case KDriveAttExclusive : |
|
822 expectMatch = (fullDriveList[i] == testAtt); |
|
823 break; |
|
824 |
|
825 case KDriveAttExclude | KDriveAttExclusive: |
|
826 expectMatch = (fullDriveList[i] != testAtt); |
|
827 break; |
|
828 |
|
829 case KDriveAttAll | KDriveAttExclude : |
|
830 test(0); // Invalid - should never get here as this returns KErrArgument for all cases |
|
831 break; |
|
832 |
|
833 case KDriveAttAll | KDriveAttExclusive : |
|
834 test(0); // Invalid - should never get here as this returns KErrArgument for all cases |
|
835 break; |
|
836 |
|
837 case KDriveAttAll | KDriveAttExclude | KDriveAttExclusive : |
|
838 test(0); // Invalid - should never get here as this returns KErrArgument for all cases |
|
839 break; |
|
840 |
|
841 default: |
|
842 test.Printf(_L("Unexpected Match Mask %08x"), testCombinations[matchIdx].iMatchMask); |
|
843 test(0); |
|
844 break; |
|
845 } |
|
846 |
|
847 if(expectMatch) |
|
848 { |
|
849 //test.Printf(_L(" %c MATCHED OK "), 'A' + i); |
|
850 test(newDriveList[i] == fullDriveList[i]); |
|
851 } |
|
852 else |
|
853 { |
|
854 /*if(fullDriveList[i] == 0) |
|
855 { |
|
856 test.Printf(_L(" %c NOT PRESENT "), 'A' + i); |
|
857 } |
|
858 else |
|
859 { |
|
860 test.Printf(_L(" %c NOT MATCHED "), 'A' + i); |
|
861 } |
|
862 */ |
|
863 test(newDriveList[i] == 0); |
|
864 } |
|
865 } |
|
866 } |
|
867 } |
|
868 } |
|
869 |
|
870 |
|
871 |
|
872 //--------------------------------------------- |
|
873 //! @SYMTestCaseID PBASE-T_FSRV-0605 |
|
874 //! @SYMTestType UT |
|
875 //! @SYMREQ CR1086 |
|
876 //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can identify the |
|
877 //! logically removable drives. |
|
878 //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttLogicallyRemovable. |
|
879 //! @SYMTestExpectedResults Check that only the logically removable drives specified in estart.txt are returned. |
|
880 //! @SYMTestPriority High |
|
881 //! @SYMTestStatus Implemented |
|
882 //--------------------------------------------- |
|
883 |
|
884 test.Printf(_L("Return only Logically Removable drives \n")); |
|
885 |
|
886 drivecount = 0; |
|
887 flags = KDriveAttLogicallyRemovable; |
|
888 err = TheFs.DriveList(driveList, flags); |
|
889 test( err == KErrNone ); |
|
890 for ( i = 0; i < KMaxDrives; i++) |
|
891 { |
|
892 if (driveList[i]) |
|
893 { |
|
894 err = TheFs.Drive(info, i); |
|
895 test( err == KErrNone ); |
|
896 test( info.iDriveAtt & KDriveAttLogicallyRemovable ); |
|
897 drivecount++; |
|
898 |
|
899 printDriveAtt(i,info.iDriveAtt); |
|
900 } |
|
901 |
|
902 } |
|
903 |
|
904 test( drivecount == logicallyRemovableDriveCount ); // no logically removable drive was added |
|
905 |
|
906 |
|
907 test.End(); |
|
908 } |
|
909 |
|
910 |
|
911 |
|
912 |
|
913 |
|
914 |
|
915 |
|
916 LOCAL_C void testDriveInfo() |
|
917 // |
|
918 // Test the drive info. |
|
919 // |
|
920 { |
|
921 |
|
922 test.Start(_L("The drive info")); |
|
923 TDriveList list; |
|
924 TInt r=TheFs.DriveList(list); |
|
925 test(r==KErrNone); |
|
926 for (TInt i=0;i<KMaxDrives;i++) |
|
927 { |
|
928 TInt att=list[i]; |
|
929 if (att) |
|
930 { |
|
931 TDriveInfo d; |
|
932 r=TheFs.Drive(d,i); |
|
933 test(r==KErrNone); |
|
934 printDriveInfo(i,d); |
|
935 test.Printf(_L("\n")); |
|
936 testDriveInfo(i,d); |
|
937 } |
|
938 } |
|
939 |
|
940 test.End(); |
|
941 } |
|
942 |
|
943 LOCAL_C void testVolumeInfo() |
|
944 // |
|
945 // Test volume info. |
|
946 // |
|
947 { |
|
948 |
|
949 test.Start(_L("The volume info")); |
|
950 TDriveList list; |
|
951 TInt r=TheFs.DriveList(list); |
|
952 test(r==KErrNone); |
|
953 for (TInt i=0;i<KMaxDrives;i++) |
|
954 { |
|
955 TVolumeInfo v; |
|
956 TDriveInfo d; |
|
957 switch (r=TheFs.Volume(v,i)) |
|
958 { |
|
959 case KErrNone: |
|
960 printDriveInfo(i,v.iDrive); |
|
961 test.Printf(_L(" VOL=\"%S\" ID=%08x\n"),&v.iName,v.iUniqueID); |
|
962 test.Printf(_L(" SIZE=%ldK FREE=%ldK\n"),v.iSize/1024,v.iFree/1024); |
|
963 break; |
|
964 case KErrNotReady: |
|
965 r=TheFs.Drive(d, i); |
|
966 test_KErrNone(r); |
|
967 if (d.iType == EMediaNotPresent) |
|
968 test.Printf(_L("%c: Medium not present - cannot perform test.\n"), i + 'A'); |
|
969 else |
|
970 test.Printf(_L("medium found (type %d) but drive %c: not ready\nPrevious test may have hung; else, check hardware.\n"), (TInt)d.iType, i + 'A'); |
|
971 break; |
|
972 case KErrPathNotFound: |
|
973 test.Printf(_L("%c: Not Found\n"), i + 'A'); |
|
974 break; |
|
975 case KErrCorrupt: |
|
976 test.Printf(_L("%c: Media corruption; previous test may have aborted; else, check hardware\n"), i + 'A'); |
|
977 default: |
|
978 test_KErrNone(r); |
|
979 } |
|
980 test.Printf(_L("\n")); |
|
981 } |
|
982 |
|
983 test.End(); |
|
984 } |
|
985 |
|
986 LOCAL_C void testClientParse() |
|
987 // |
|
988 // Test the client side parse. |
|
989 // |
|
990 { |
|
991 |
|
992 test.Start(_L("Test client side parsing")); |
|
993 |
|
994 for (TInt i=0;i<KMaxParses;i++) |
|
995 { |
|
996 TInt r; |
|
997 TParse f; |
|
998 SParse& p=parse[i]; |
|
999 TPtrC name(p.src); |
|
1000 if (p.rel) |
|
1001 { |
|
1002 if (p.def) |
|
1003 { |
|
1004 TPtrC rel(p.rel); |
|
1005 TPtrC def(p.def); |
|
1006 r=f.Set(name,&rel,&def); |
|
1007 } |
|
1008 else |
|
1009 { |
|
1010 TPtrC rel(p.rel); |
|
1011 r=f.Set(name,&rel,NULL); |
|
1012 } |
|
1013 } |
|
1014 else |
|
1015 r=f.Set(name,NULL,NULL); |
|
1016 test(r==KErrNone); |
|
1017 test(TPtrC(p.fullName)==f.FullName()); |
|
1018 test(TPtrC(p.drive)==f.Drive()); |
|
1019 test(TPtrC(p.path)==f.Path()); |
|
1020 test(TPtrC(p.name)==f.Name()); |
|
1021 test(TPtrC(p.ext)==f.Ext()); |
|
1022 } |
|
1023 |
|
1024 test.End(); |
|
1025 } |
|
1026 |
|
1027 LOCAL_C void testPath() |
|
1028 // |
|
1029 // Test the path handling. |
|
1030 // |
|
1031 { |
|
1032 |
|
1033 test.Start(_L("Test path handling")); |
|
1034 TFileName p; |
|
1035 TInt r=TheFs.SessionPath(p); |
|
1036 test(r==KErrNone); |
|
1037 test.Printf(_L("SESSION=\"%S\"\n"),&p); |
|
1038 r=TheFs.SetSessionPath(_L("A:\\TEST\\")); |
|
1039 test(r==KErrNone); |
|
1040 r=TheFs.SessionPath(p); |
|
1041 test(r==KErrNone); |
|
1042 test(p==_L("A:\\TEST\\")); |
|
1043 r=TheFs.SetSessionPath(gSessionPath); |
|
1044 test(r==KErrNone); |
|
1045 |
|
1046 |
|
1047 TheFs.SetAllocFailure(gAllocFailOff); |
|
1048 |
|
1049 RThread t; |
|
1050 r=t.Create(_L("PathTest"),pathTestThread,KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
1051 test(r==KErrNone); |
|
1052 TRequestStatus tStat; |
|
1053 t.Logon(tStat); |
|
1054 t.Resume(); |
|
1055 User::WaitForRequest(tStat); |
|
1056 test(tStat==KErrNone); |
|
1057 test(r==KErrNone); |
|
1058 t.Close(); |
|
1059 |
|
1060 TheFs.SetAllocFailure(gAllocFailOn); |
|
1061 |
|
1062 test.End(); |
|
1063 } |
|
1064 |
|
1065 LOCAL_C void testServerParse() |
|
1066 // |
|
1067 // Test the client side parse. |
|
1068 // |
|
1069 { |
|
1070 |
|
1071 test.Start(_L("Test server side parsing")); |
|
1072 |
|
1073 TFileName old; |
|
1074 TInt r=TheFs.SessionPath(old); |
|
1075 test(r==KErrNone); |
|
1076 r=TheFs.SetSessionPath(_L("C:\\ABCDEF\\")); |
|
1077 test(r==KErrNone); |
|
1078 for (TInt i=0;i<KMaxParses;i++) |
|
1079 { |
|
1080 TInt r; |
|
1081 TParse f; |
|
1082 SParseServer& p=parseServer[i]; |
|
1083 TPtrC name(p.src); |
|
1084 if (p.rel) |
|
1085 r=TheFs.Parse(name,TPtrC(p.rel),f); |
|
1086 else |
|
1087 r=TheFs.Parse(name,f); |
|
1088 test(r==KErrNone); |
|
1089 test(TPtrC(p.fullName)==f.FullName()); |
|
1090 test(TPtrC(p.drive)==f.Drive()); |
|
1091 test(TPtrC(p.path)==f.Path()); |
|
1092 test(TPtrC(p.name)==f.Name()); |
|
1093 test(TPtrC(p.ext)==f.Ext()); |
|
1094 } |
|
1095 r=TheFs.SetSessionPath(old); |
|
1096 test(r==KErrNone); |
|
1097 |
|
1098 test.End(); |
|
1099 } |
|
1100 |
|
1101 LOCAL_C void testSubst() |
|
1102 // |
|
1103 // Test the substitute functions. |
|
1104 // |
|
1105 { |
|
1106 |
|
1107 test.Printf(_L("Test subst")); |
|
1108 TVolumeInfo v; |
|
1109 TInt r=TheFs.Volume(v); |
|
1110 test(r==KErrNone); |
|
1111 TDriveInfo origDI; |
|
1112 r=TheFs.Drive(origDI); |
|
1113 test(r==KErrNone); |
|
1114 |
|
1115 TDriveInfo driveInfo; |
|
1116 r=TheFs.Drive(driveInfo,EDriveO); |
|
1117 test(r==KErrNone); |
|
1118 |
|
1119 if (driveInfo.iDriveAtt==KDriveAttLocal) |
|
1120 { |
|
1121 return; // Subst local drives fails |
|
1122 } |
|
1123 |
|
1124 TFileName n; |
|
1125 r=TheFs.Subst(n,EDriveO); |
|
1126 test(r==KErrNone); |
|
1127 test(n.Length()==0); |
|
1128 r=TheFs.SetSubst(gSessionPath,EDriveO); |
|
1129 test(r==KErrNone); |
|
1130 r=TheFs.Subst(n,EDriveO); |
|
1131 test(r==KErrNone); |
|
1132 test(n==gSessionPath); |
|
1133 TVolumeInfo w; |
|
1134 r=TheFs.Volume(w,EDriveO); |
|
1135 test(r==KErrNone); |
|
1136 test(w.iDrive.iType==v.iDrive.iType); |
|
1137 test(w.iDrive.iBattery==v.iDrive.iBattery); |
|
1138 test(w.iDrive.iDriveAtt==KDriveAttSubsted); |
|
1139 test(w.iDrive.iMediaAtt==v.iDrive.iMediaAtt); |
|
1140 test(w.iUniqueID==v.iUniqueID); |
|
1141 test(w.iSize==v.iSize); |
|
1142 test(w.iFree==v.iFree); |
|
1143 test(w.iName==v.iName); |
|
1144 TDriveList driveList; |
|
1145 r=TheFs.DriveList(driveList); |
|
1146 test(r==KErrNone); |
|
1147 test(driveList[EDriveO]==KDriveAttSubsted); |
|
1148 TDriveInfo d; |
|
1149 r=TheFs.Drive(d,EDriveO); |
|
1150 test(r==KErrNone); |
|
1151 test(d.iDriveAtt==KDriveAttSubsted); |
|
1152 test(d.iMediaAtt==origDI.iMediaAtt); |
|
1153 test(d.iType==origDI.iType); |
|
1154 test(d.iBattery==origDI.iBattery); |
|
1155 |
|
1156 |
|
1157 test.Next(_L("Test real name")); |
|
1158 r=TheFs.RealName(_L("O:\\FILE.XXX"),n); |
|
1159 test(r==KErrNone); |
|
1160 TFileName substedPath=gSessionPath; |
|
1161 substedPath.Append(_L("FILE.XXX")); |
|
1162 test(n.CompareF(substedPath)==KErrNone); |
|
1163 // |
|
1164 test.Next(_L("Test MkDir, Rename and RmDir on Substed drive")); |
|
1165 _LIT(KTurgid,"turgid\\"); |
|
1166 TFileName dir=gSessionPath; |
|
1167 dir+=KTurgid; |
|
1168 r=TheFs.MkDirAll(dir); |
|
1169 test(r==KErrNone); |
|
1170 dir+=_L("subdir\\"); |
|
1171 r=TheFs.MkDir(dir); |
|
1172 test(r==KErrNone); |
|
1173 r=TheFs.RmDir(_L("O:\\turgid\\subdir\\")); |
|
1174 test(r==KErrNone); |
|
1175 r=TheFs.Rename(_L("O:\\turgid"), _L("O:\\facile")); |
|
1176 test(r==KErrNone); |
|
1177 r=TheFs.MkDir(_L("O:\\insipid\\")); |
|
1178 test(r==KErrNone); |
|
1179 r=TheFs.Rename(_L("O:\\insipid"), _L("O:\\glib")); |
|
1180 test(r==KErrNone); |
|
1181 r=TheFs.RmDir(_L("O:\\facile\\")); |
|
1182 test(r==KErrNone); |
|
1183 _LIT(KGlib,"glib\\"); |
|
1184 dir=gSessionPath; |
|
1185 dir+=KGlib; |
|
1186 r=TheFs.RmDir(dir); |
|
1187 test(r==KErrNone); |
|
1188 // |
|
1189 test.Next(_L("Test file operations on Substed drive")); |
|
1190 _LIT(File1,"File1.txt"); |
|
1191 _LIT(File2,"File2.txt"); |
|
1192 _LIT(SubstRoot,"O:\\"); |
|
1193 _LIT(Subdir,"subdir\\"); |
|
1194 TFileName name1,name2; |
|
1195 name1=gSessionPath; |
|
1196 name1+=File1; |
|
1197 RFile f1; |
|
1198 r=f1.Replace(TheFs,name1,EFileShareExclusive|EFileWrite); |
|
1199 test(r==KErrNone); |
|
1200 name2=SubstRoot; |
|
1201 name2+=File2; |
|
1202 TBool isValid=TheFs.IsValidName(name2); |
|
1203 test(isValid); |
|
1204 r=f1.Rename(name2); |
|
1205 test(r==KErrNone); |
|
1206 f1.Close(); |
|
1207 r=f1.Create(TheFs,name1,EFileShareExclusive|EFileWrite); |
|
1208 test(r==KErrNone); |
|
1209 f1.Close(); |
|
1210 r=TheFs.Replace(name2,name1); |
|
1211 test(r==KErrNone); |
|
1212 r=TheFs.Delete(name1); |
|
1213 test(r==KErrNone); |
|
1214 test.Next(_L("Test notifications on Substed drive")); |
|
1215 name1=gSessionPath; |
|
1216 name1+=Subdir; |
|
1217 name2=SubstRoot; |
|
1218 name2+=Subdir; |
|
1219 // set up some extended notifications |
|
1220 TRequestStatus status1; |
|
1221 TRequestStatus status2; |
|
1222 TRequestStatus status3; |
|
1223 TheFs.NotifyChange(ENotifyDir,status1,name1); |
|
1224 test(status1==KRequestPending); |
|
1225 TheFs.NotifyChange(ENotifyDir,status2,name2); |
|
1226 test(status2==KRequestPending); |
|
1227 r=TheFs.MkDirAll(name1); |
|
1228 test(r==KErrNone); |
|
1229 User::WaitForRequest(status1); |
|
1230 User::WaitForRequest(status2); |
|
1231 test(status1==KErrNone && status2==KErrNone); |
|
1232 TheFs.NotifyChange(ENotifyDir,status1,name1); |
|
1233 test(status1==KRequestPending); |
|
1234 TheFs.NotifyChange(ENotifyDir,status2,name2); |
|
1235 test(status2==KRequestPending); |
|
1236 TheFs.NotifyChange(ENotifyAll,status3,name2); |
|
1237 test(status3==KRequestPending); |
|
1238 r=f1.Temp(TheFs,name2,n,EFileShareAny|EFileWrite); |
|
1239 test(r==KErrNone); |
|
1240 User::WaitForRequest(status3); |
|
1241 test(status3==KErrNone && status1==KRequestPending && status2==KRequestPending); |
|
1242 f1.Close(); |
|
1243 TheFs.NotifyChangeCancel(); |
|
1244 test(status1==KErrCancel && status2==KErrCancel); |
|
1245 r=TheFs.Delete(n); |
|
1246 test(r==KErrNone); |
|
1247 r=TheFs.RmDir(name1); |
|
1248 test(r==KErrNone); |
|
1249 // |
|
1250 test.Next(_L("Test file systems on Substed drive")); |
|
1251 // test cannot mount file system on substituted drive |
|
1252 TInt sessionDrv; |
|
1253 r=TheFs.CharToDrive(gSessionPath[0],sessionDrv); |
|
1254 test(r==KErrNone); |
|
1255 r=TheFs.FileSystemName(n,sessionDrv); |
|
1256 test(r==KErrNone || r==KErrNotFound); |
|
1257 r=TheFs.MountFileSystem(n,EDriveO); |
|
1258 test(r==KErrAccessDenied); |
|
1259 // test file system name on substitued drive is null |
|
1260 r=TheFs.FileSystemName(n,EDriveO); |
|
1261 test(r==KErrNotFound && n==KNullDesC); |
|
1262 // test cannot format a substitued drive |
|
1263 RFormat format; |
|
1264 TInt count; |
|
1265 r=format.Open(TheFs,SubstRoot,EHighDensity,count); |
|
1266 test(r==KErrAccessDenied); |
|
1267 |
|
1268 r=TheFs.SetSubst(_L(""),EDriveO); |
|
1269 test(r==KErrNone); |
|
1270 r=TheFs.Subst(n,EDriveO); |
|
1271 test(r==KErrNone); |
|
1272 test(n==_L("")); |
|
1273 r=TheFs.Drive(d,EDriveO); |
|
1274 test(r==KErrNone); |
|
1275 test(d.iDriveAtt==0); |
|
1276 } |
|
1277 |
|
1278 LOCAL_C void testSetVolume() |
|
1279 // |
|
1280 // Test setting the volume info. |
|
1281 // |
|
1282 { |
|
1283 |
|
1284 test.Start(_L("Test setting the volume label")); |
|
1285 |
|
1286 const TInt driveNum=CurrentDrive(); |
|
1287 |
|
1288 TVolumeInfo v; |
|
1289 TInt r=TheFs.Volume(v,driveNum); |
|
1290 test(r==KErrNone); |
|
1291 TFileName n=v.iName; |
|
1292 test.Printf(_L("VOL=\"%S\"\n"),&n); |
|
1293 |
|
1294 test.Next(_L("Set volume label to nothing")); |
|
1295 r=TheFs.SetVolumeLabel(_L(""),driveNum); |
|
1296 |
|
1297 if(Is_Win32(TheFs, gDrive) && (r==KErrGeneral || r==KErrAccessDenied || r==KErrNotSupported)) |
|
1298 { |
|
1299 test.Printf(_L("Error %d: Set volume label not testing on WINS\n"),r); |
|
1300 test.End(); |
|
1301 return; |
|
1302 } |
|
1303 |
|
1304 test(r==KErrNone); |
|
1305 r=TheFs.Volume(v,driveNum); |
|
1306 test(r==KErrNone ); |
|
1307 test(v.iName==_L("")); |
|
1308 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1309 |
|
1310 test.Next(_L("Set volume label to ABCDEFGHIJK")); |
|
1311 r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum); |
|
1312 test(r==KErrNone); |
|
1313 r=TheFs.Volume(v,driveNum); |
|
1314 test(r==KErrNone); |
|
1315 test(v.iName==_L("ABCDEFGHIJK")); |
|
1316 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1317 |
|
1318 test.Next(_L("Set volume label to ABCDE")); |
|
1319 r=TheFs.SetVolumeLabel(_L("ABCDE"),driveNum); |
|
1320 test(r==KErrNone); |
|
1321 r=TheFs.Volume(v,driveNum); |
|
1322 test(r==KErrNone); |
|
1323 test(v.iName==_L("ABCDE")); |
|
1324 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1325 |
|
1326 |
|
1327 test.Next(_L("Test replacement of non-ascii chars")); |
|
1328 TBuf<KMaxVolumeName> uBuf(KMaxVolumeName); |
|
1329 uBuf.FillZ(); |
|
1330 uBuf[0]='a'; |
|
1331 uBuf[1]=0x100; |
|
1332 uBuf[2]='b'; |
|
1333 uBuf[3]=0x101; |
|
1334 uBuf[4]='c'; |
|
1335 uBuf[5]=0x102; |
|
1336 uBuf[6]='d'; |
|
1337 uBuf[7]=0x103; |
|
1338 uBuf[8]='e'; |
|
1339 uBuf[9]=0x104; |
|
1340 uBuf[10]='f'; |
|
1341 r=TheFs.SetVolumeLabel(uBuf,driveNum); |
|
1342 test(r==KErrNone); |
|
1343 TFileName drive=_L("?:"); |
|
1344 drive[0]=gSessionPath[0]; |
|
1345 |
|
1346 // ??? this needs to be replaced |
|
1347 // UserSvr::ForceRemountMedia(ERemovableMedia0); |
|
1348 User::After(1000000); |
|
1349 |
|
1350 TFileName sess; |
|
1351 r=TheFs.SessionPath(sess); |
|
1352 test(r==KErrNone); |
|
1353 r=TheFs.Volume(v,driveNum); |
|
1354 test(r==KErrNone); |
|
1355 |
|
1356 if(Is_Fat(TheFs, gDrive)) //-- FAT doesn't support normal UNICODE in volume labels |
|
1357 test(v.iName==_L("a_b_c_d_e_f")); |
|
1358 else |
|
1359 test(v.iName == uBuf); |
|
1360 |
|
1361 |
|
1362 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1363 |
|
1364 |
|
1365 test.Next(_L("Set volume label back to nothing")); |
|
1366 r=TheFs.SetVolumeLabel(_L(""),driveNum); |
|
1367 test(r==KErrNone); |
|
1368 r=TheFs.Volume(v,driveNum); |
|
1369 test(r==KErrNone); |
|
1370 test(v.iName==_L("")); |
|
1371 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1372 |
|
1373 test.Next(_L("Attempt to set volume label containing illegal characters")); |
|
1374 r=TheFs.SetVolumeLabel(_L("abc>def"),driveNum); |
|
1375 test(r==KErrBadName); |
|
1376 r=TheFs.SetVolumeLabel(_L("ghi*jkl"),driveNum); |
|
1377 test(r==KErrBadName); |
|
1378 r=TheFs.SetVolumeLabel(_L("mno?pqr"),driveNum); |
|
1379 test(r==KErrBadName); |
|
1380 r=TheFs.SetVolumeLabel(_L("stu|vwx"),driveNum); |
|
1381 test(r==KErrBadName); |
|
1382 r=TheFs.SetVolumeLabel(_L("yz<abc"),driveNum); |
|
1383 test(r==KErrBadName); |
|
1384 r=TheFs.SetVolumeLabel(_L("def//ghi"),driveNum); |
|
1385 test(r==KErrBadName); |
|
1386 |
|
1387 r=TheFs.Volume(v,driveNum); |
|
1388 test(r==KErrNone); |
|
1389 test(v.iName==_L("")); |
|
1390 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1391 |
|
1392 // test volume label after remount (for removable media only) |
|
1393 test.Next(_L("Test volume label after remount")); |
|
1394 |
|
1395 TDriveInfo info; |
|
1396 test(TheFs.Drive(info, driveNum) == KErrNone); |
|
1397 |
|
1398 if((info.iDriveAtt & KDriveAttRemovable) != 0) |
|
1399 { |
|
1400 // 1. set volume label |
|
1401 test(TheFs.SetVolumeLabel(_L("XXX"), driveNum) == KErrNone); |
|
1402 |
|
1403 // 2. change bootsector volume label |
|
1404 const TInt offset = IsFileSystemFAT32(TheFs, driveNum)? |
|
1405 71 /*KFat32VolumeLabelPos*/ |
|
1406 : |
|
1407 43 /*KFat16VolumeLabelPos*/; // both from sfat32\inc\sl_bpb.h |
|
1408 |
|
1409 RRawDisk rdisk; |
|
1410 TPtrC8 label(_S8("Z"), 1); |
|
1411 |
|
1412 test(rdisk.Open(TheFs, driveNum) == KErrNone); |
|
1413 test(rdisk.Write(offset, label) == KErrNone); |
|
1414 rdisk.Close(); |
|
1415 |
|
1416 // 3. remount the drive |
|
1417 test(TheFs.RemountDrive(driveNum) == KErrNone); |
|
1418 |
|
1419 // 4. check volume label |
|
1420 test(TheFs.Volume(v, driveNum) == KErrNone); |
|
1421 test(v.iName == _L("XXX")); |
|
1422 test.Printf(_L("- Passed.\n")); |
|
1423 } |
|
1424 else |
|
1425 test.Printf(_L("- Skipped (drive is not removable).\n")); |
|
1426 |
|
1427 // clean up |
|
1428 test.Next(_L("Set volume label to original")); |
|
1429 r=TheFs.SetVolumeLabel(n,driveNum); |
|
1430 test(r==KErrNone); |
|
1431 r=TheFs.Volume(v,driveNum); |
|
1432 test(r==KErrNone); |
|
1433 test(v.iName==n); |
|
1434 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1435 |
|
1436 test.End(); |
|
1437 } |
|
1438 |
|
1439 LOCAL_C void testModified() |
|
1440 // |
|
1441 // Test the Modified/SetModified functions. |
|
1442 // |
|
1443 { |
|
1444 |
|
1445 test.Start(_L("Test modified/SetModified functions")); |
|
1446 TTime savedTime; |
|
1447 TInt r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),savedTime); |
|
1448 test(r==KErrNone); |
|
1449 TDateTime dateTime=savedTime.DateTime(); |
|
1450 test.Printf(_L("T_FSRV.CPP last modified %d/%d/%d %d:%d:%d.%-06d\n"),dateTime.Day()+1,dateTime.Month()+1,dateTime.Year(),dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond()); |
|
1451 test.Next(_L("Set modified")); |
|
1452 dateTime.Set(1993,EAugust,23,1,13,54,123456); |
|
1453 TTime newTime(dateTime); |
|
1454 r=TheFs.SetModified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),newTime); |
|
1455 test(r==KErrNone); |
|
1456 TTime checkTime; |
|
1457 r=TheFs.Modified(_L("\\XXXX\\YYYY\\ZZZZ.CPP"),checkTime); |
|
1458 test(r==KErrPathNotFound); |
|
1459 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
|
1460 test(r==KErrNone); |
|
1461 dateTime=checkTime.DateTime(); |
|
1462 test(dateTime.Year()==1993); |
|
1463 test(dateTime.Month()==EAugust); |
|
1464 test(dateTime.Day()==23); |
|
1465 test(dateTime.Hour()==1); |
|
1466 test(dateTime.Minute()==13); |
|
1467 test(dateTime.Second()==54); |
|
1468 test.Printf(_L("T_FSRV.CPP last modified %d/%d/%d %d:%d:%d.%-06d\n"),dateTime.Day()+1,dateTime.Month()+1,dateTime.Year(),dateTime.Hour(),dateTime.Minute(),dateTime.Second(),dateTime.MicroSecond()); |
|
1469 // test(dateTime.MicroSecond()==123456); // dos is not accurate enough |
|
1470 r=TheFs.SetModified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),savedTime); |
|
1471 test(r==KErrNone); |
|
1472 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
|
1473 test(r==KErrNone); |
|
1474 test(checkTime==savedTime); |
|
1475 |
|
1476 RFile f; |
|
1477 r=f.Open(TheFs,_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),EFileWrite); |
|
1478 test(r==KErrNone); |
|
1479 dateTime.Set(1997,EJanuary,1,2,55,51,999999); |
|
1480 newTime=dateTime; |
|
1481 r=f.SetModified(newTime); |
|
1482 test(r==KErrNone); |
|
1483 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
|
1484 test(r==KErrNone); |
|
1485 |
|
1486 dateTime=checkTime.DateTime(); |
|
1487 test(dateTime.Year()==1997); |
|
1488 test(dateTime.Month()==EJanuary); |
|
1489 test(dateTime.Day()==1); |
|
1490 test(dateTime.Hour()==2); |
|
1491 test(dateTime.Minute()==55); |
|
1492 test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 |
|
1493 |
|
1494 r=f.Modified(checkTime); |
|
1495 test(r==KErrNone); |
|
1496 |
|
1497 dateTime=checkTime.DateTime(); |
|
1498 test(dateTime.Year()==1997); |
|
1499 test(dateTime.Month()==EJanuary); |
|
1500 test(dateTime.Day()==1); |
|
1501 test(dateTime.Hour()==2); |
|
1502 test(dateTime.Minute()==55); |
|
1503 test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 |
|
1504 f.Close(); |
|
1505 |
|
1506 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
|
1507 test(r==KErrNone); |
|
1508 |
|
1509 dateTime=checkTime.DateTime(); |
|
1510 test(dateTime.Year()==1997); |
|
1511 test(dateTime.Month()==EJanuary); |
|
1512 test(dateTime.Day()==1); |
|
1513 test(dateTime.Hour()==2); |
|
1514 test(dateTime.Minute()==55); |
|
1515 test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 |
|
1516 test.End(); |
|
1517 } |
|
1518 |
|
1519 LOCAL_C void testName() |
|
1520 // |
|
1521 // Test the Modified/SetModified functions. |
|
1522 // |
|
1523 { |
|
1524 test.Start(_L("Test file name functions")); |
|
1525 |
|
1526 |
|
1527 _LIT(KFileNameAndPath, "\\F32-TST\\TFSRV\\T_FSRV.CPP"); |
|
1528 _LIT(KFileName, "T_FSRV.CPP"); |
|
1529 |
|
1530 RFile file; |
|
1531 |
|
1532 TInt r=file.Open(TheFs, KFileName, 0 ); |
|
1533 if (r!=KErrNone) |
|
1534 { |
|
1535 test.Printf(_L("Error %d opening file %S\n"), r, &KFileName); |
|
1536 test(0); |
|
1537 } |
|
1538 |
|
1539 TFileName fileName; |
|
1540 |
|
1541 // Check RFile::Name just retuns the file name, without path and drive |
|
1542 r=file.Name(fileName); |
|
1543 test(r==KErrNone); |
|
1544 test(fileName==KFileName()); |
|
1545 |
|
1546 // Check RFile::FullName returns the complete file name and path |
|
1547 r=file.FullName(fileName); |
|
1548 test(r==KErrNone); |
|
1549 test(fileName.Mid(2)==KFileNameAndPath); // chop off drive letter + ':' |
|
1550 |
|
1551 file.Close(); |
|
1552 |
|
1553 test.End(); |
|
1554 } |
|
1555 |
|
1556 LOCAL_C TInt CreateFileX(const TDesC& aBaseName,TInt aX) |
|
1557 // |
|
1558 // Create a large file. Return KErrEof or KErrNone |
|
1559 // |
|
1560 { |
|
1561 |
|
1562 TBuf<128> fileName=aBaseName; |
|
1563 fileName.AppendNum(aX); |
|
1564 RFile file; |
|
1565 |
|
1566 TInt r=file.Replace(TheFs,fileName,EFileWrite); |
|
1567 if (r==KErrDiskFull) |
|
1568 return(r); |
|
1569 if (r!=KErrNone) |
|
1570 { |
|
1571 test.Printf(_L("ERROR:: Replace returned %d\n"),r); |
|
1572 test(0); |
|
1573 //test.Getch(); |
|
1574 return(KErrDiskFull); |
|
1575 } |
|
1576 |
|
1577 if (!IsTestingLFFS()) |
|
1578 r=file.SetSize(LargeFileSize); |
|
1579 else |
|
1580 { // ??? Whats wrong with setsize |
|
1581 TBuf8<1024> testdata(1024); |
|
1582 TInt count=(LargeFileSize/testdata.Length()); |
|
1583 r=KErrNone; |
|
1584 while (count-- && r==KErrNone) |
|
1585 r=file.Write(testdata); |
|
1586 } |
|
1587 if (r==KErrDiskFull) |
|
1588 { |
|
1589 file.Close(); |
|
1590 return(r); |
|
1591 } |
|
1592 if (r!=KErrNone) |
|
1593 { |
|
1594 test.Printf(_L("ERROR:: SetSize/Write returned %d\n"),r); |
|
1595 test(0); |
|
1596 //test.Getch(); |
|
1597 file.Close(); |
|
1598 return(KErrDiskFull); |
|
1599 } |
|
1600 |
|
1601 file.Close(); |
|
1602 // r=TheFs.CheckDisk(fileName); |
|
1603 // if (r!=KErrNone && r!=KErrNotSupported) |
|
1604 // { |
|
1605 // test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); |
|
1606 // test.Getch(); |
|
1607 // return(KErrDiskFull); |
|
1608 // } |
|
1609 test.Printf(_L("Created file %d size %d\n"),aX,LargeFileSize); |
|
1610 return(KErrNone); |
|
1611 } |
|
1612 |
|
1613 LOCAL_C TInt DeleteFileX(TBuf<128>& aBaseName,TInt aX) |
|
1614 // |
|
1615 // Delete a file. |
|
1616 // |
|
1617 { |
|
1618 |
|
1619 TBuf<128> fileName=aBaseName; |
|
1620 fileName.AppendNum(aX); |
|
1621 TInt r=TheFs.Delete(fileName); |
|
1622 test(r==KErrNone); |
|
1623 // r=TheFs.CheckDisk(fileName); |
|
1624 // if (r!=KErrNone && r!=KErrNotSupported) |
|
1625 // { |
|
1626 // test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); |
|
1627 // test(r==KErrNone); |
|
1628 // } |
|
1629 test.Printf(_L("Deleted File %d\n"),aX); |
|
1630 return(KErrNone); |
|
1631 } |
|
1632 |
|
1633 LOCAL_C void MakeAndDeleteFiles() |
|
1634 // |
|
1635 // Create and delete large files in a randomish order |
|
1636 // |
|
1637 { |
|
1638 |
|
1639 test.Start(_L("Create and delete large files")); |
|
1640 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\SMALLDIRECTORY\\")); |
|
1641 test(r==KErrNone || r==KErrAlreadyExists); |
|
1642 TBuf<128> fileName=_L("\\F32-TST\\SMALLDIRECTORY\\FILE"); |
|
1643 r=CreateFileX(fileName,0); |
|
1644 test(r==KErrNone); |
|
1645 r=CreateFileX(fileName,1); |
|
1646 test(r==KErrNone); |
|
1647 r=DeleteFileX(fileName,0); |
|
1648 test(r==KErrNone); |
|
1649 r=CreateFileX(fileName,2); |
|
1650 test(r==KErrNone); |
|
1651 r=CreateFileX(fileName,1); |
|
1652 test(r==KErrNone); |
|
1653 r=CreateFileX(fileName,3); |
|
1654 test(r==KErrNone); |
|
1655 r=DeleteFileX(fileName,1); |
|
1656 test(r==KErrNone); |
|
1657 r=CreateFileX(fileName,4); |
|
1658 test(r==KErrNone); |
|
1659 r=DeleteFileX(fileName,2); |
|
1660 test(r==KErrNone); |
|
1661 r=DeleteFileX(fileName,3); |
|
1662 test(r==KErrNone); |
|
1663 r=DeleteFileX(fileName,4); |
|
1664 test(r==KErrNone); |
|
1665 r=CreateFileX(fileName,1); |
|
1666 test(r==KErrNone); |
|
1667 r=DeleteFileX(fileName,1); |
|
1668 test(r==KErrNone); |
|
1669 |
|
1670 r=TheFs.CheckDisk(fileName); |
|
1671 if (r!=KErrNone && r!=KErrNotSupported) |
|
1672 { |
|
1673 test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); |
|
1674 test(0); |
|
1675 //test.Getch(); |
|
1676 } |
|
1677 |
|
1678 test.End(); |
|
1679 } |
|
1680 |
|
1681 LOCAL_C void FillUpDisk() |
|
1682 // |
|
1683 // Test that a full disk is ok |
|
1684 // |
|
1685 { |
|
1686 |
|
1687 test.Start(_L("Fill disk to capacity")); |
|
1688 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\BIGDIRECTORY\\")); |
|
1689 test(r==KErrNone || r==KErrAlreadyExists); |
|
1690 TInt count=0; |
|
1691 TFileName sessionPath; |
|
1692 r=TheFs.SessionPath(sessionPath); |
|
1693 test(r==KErrNone); |
|
1694 TBuf<128> fileName=_L("\\F32-TST\\BIGDIRECTORY\\FILE"); |
|
1695 FOREVER |
|
1696 { |
|
1697 TInt r=CreateFileX(fileName,count); |
|
1698 if (r==KErrDiskFull) |
|
1699 break; |
|
1700 test(r==KErrNone); |
|
1701 count++; |
|
1702 #if defined(__WINS__) |
|
1703 if (count==32 && sessionPath[0]=='C') |
|
1704 break; |
|
1705 #endif |
|
1706 } |
|
1707 |
|
1708 r=TheFs.CheckDisk(fileName); |
|
1709 if (r!=KErrNone && r!=KErrNotSupported) |
|
1710 { |
|
1711 test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); |
|
1712 test(0); |
|
1713 //test.Getch(); |
|
1714 } |
|
1715 |
|
1716 while(count--) |
|
1717 DeleteFileX(fileName,count); |
|
1718 |
|
1719 r=TheFs.CheckDisk(fileName); |
|
1720 if (r!=KErrNone && r!=KErrNotSupported) |
|
1721 { |
|
1722 test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); |
|
1723 test(0); |
|
1724 //test.Getch(); |
|
1725 } |
|
1726 |
|
1727 test.End(); |
|
1728 } |
|
1729 |
|
1730 LOCAL_C void CopyFileToTestDirectory() |
|
1731 // |
|
1732 // Make a copy of the file in ram |
|
1733 // |
|
1734 { |
|
1735 |
|
1736 TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
|
1737 fn[0] = gExeFileName[0]; |
|
1738 TParse f; |
|
1739 TInt r=TheFs.Parse(fn,f); |
|
1740 test(r==KErrNone); |
|
1741 test.Next(_L("Copying file to test directory")); |
|
1742 TParse fCopy; |
|
1743 r=TheFs.Parse(f.NameAndExt(),fCopy); |
|
1744 test(r==KErrNone); |
|
1745 |
|
1746 RFile f1; |
|
1747 r=f1.Open(TheFs,f.FullName(),EFileStreamText|EFileShareReadersOnly); |
|
1748 test(r==KErrNone); |
|
1749 RFile f2; |
|
1750 r=f2.Replace(TheFs,fCopy.FullName(),EFileWrite); |
|
1751 test(r==KErrNone); |
|
1752 TBuf8<512> copyBuf; |
|
1753 TInt rem; |
|
1754 r=f1.Size(rem); |
|
1755 test(r==KErrNone); |
|
1756 TInt pos=0; |
|
1757 while (rem) |
|
1758 { |
|
1759 TInt s=Min(rem,copyBuf.MaxSize()); |
|
1760 r=f1.Read(pos,copyBuf,s); |
|
1761 test(r==KErrNone); |
|
1762 test(copyBuf.Length()==s); |
|
1763 r=f2.Write(pos,copyBuf,s); |
|
1764 test(r==KErrNone); |
|
1765 pos+=s; |
|
1766 rem-=s; |
|
1767 } |
|
1768 f1.Close(); |
|
1769 f2.Close(); |
|
1770 } |
|
1771 |
|
1772 |
|
1773 //--------------------------------------------------------------------------- |
|
1774 |
|
1775 /** |
|
1776 test RFs::SetErrorCondition() aspects |
|
1777 */ |
|
1778 void TestSetErrorCondition() |
|
1779 { |
|
1780 #ifdef _DEBUG |
|
1781 |
|
1782 test.Next(_L("TestSetErrorCondition\n")); |
|
1783 |
|
1784 _LIT(KFileName, "\\A.swf"); |
|
1785 |
|
1786 TInt nRes; |
|
1787 RFile file; |
|
1788 RFile file1; |
|
1789 |
|
1790 const TInt KMyError = -756; //-- specific error code we will simulate |
|
1791 |
|
1792 //========== just create a file |
|
1793 nRes = TheFs.SetErrorCondition(KMyError,0); //-- set up FS error simulation |
|
1794 test(nRes == KErrNone); |
|
1795 |
|
1796 //-- this shall fail immediately |
|
1797 nRes = file.Replace(TheFs, KFileName, EFileWrite); |
|
1798 test(nRes == KMyError); |
|
1799 |
|
1800 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
|
1801 file.Close(); |
|
1802 |
|
1803 //========== create file & duplicate a handle #1 |
|
1804 nRes = TheFs.SetErrorCondition(KMyError,1); //-- set up FS error simulation |
|
1805 test(nRes == KErrNone); |
|
1806 |
|
1807 //-- this shall succeed |
|
1808 nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 0 |
|
1809 test(nRes == KErrNone); |
|
1810 |
|
1811 //-- this shall fail inside RFile::Duplicate() half way through in the RFile::DuplicateHandle() |
|
1812 nRes = file1.Duplicate(file); |
|
1813 test(nRes == KMyError); |
|
1814 file1.Close(); |
|
1815 |
|
1816 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
|
1817 file.Close(); |
|
1818 |
|
1819 //-- check that the file isn't locked |
|
1820 nRes = TheFs.Delete(KFileName); |
|
1821 test(nRes == KErrNone); |
|
1822 |
|
1823 //========== create file & duplicate a handle #2 |
|
1824 nRes = TheFs.SetErrorCondition(KMyError,2); //-- set up FS error simulation |
|
1825 test(nRes == KErrNone); |
|
1826 |
|
1827 //-- this shall succeed |
|
1828 nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 1 |
|
1829 test(nRes == KErrNone); |
|
1830 |
|
1831 //-- this must not fail, because EFsFileAdopt is excluded from the erros simulation |
|
1832 nRes = file1.Duplicate(file); |
|
1833 test(nRes == KErrNone); |
|
1834 file1.Close(); |
|
1835 |
|
1836 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
|
1837 file.Close(); |
|
1838 |
|
1839 //-- check that the file isn't locked |
|
1840 nRes = TheFs.Delete(KFileName); |
|
1841 test(nRes == KErrNone); |
|
1842 |
|
1843 //========== crazy loop, for DEF103757 |
|
1844 |
|
1845 for(TInt i=0; i<6; ++i) |
|
1846 { |
|
1847 nRes = TheFs.SetErrorCondition(KMyError,i); //-- set up FS error simulation |
|
1848 |
|
1849 nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 1 |
|
1850 if(nRes != KErrNone) |
|
1851 continue; |
|
1852 |
|
1853 nRes = file1.Duplicate(file); |
|
1854 |
|
1855 file1.Close(); |
|
1856 file.Close(); |
|
1857 |
|
1858 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
|
1859 } |
|
1860 |
|
1861 //-- check that the file isn't locked |
|
1862 nRes = TheFs.Delete(KFileName); |
|
1863 test(nRes == KErrNone); |
|
1864 |
|
1865 |
|
1866 #endif |
|
1867 } |
|
1868 |
|
1869 //--------------------------------------------------------------------------- |
|
1870 |
|
1871 GLDEF_C void CallTestsL() |
|
1872 // |
|
1873 // Test the file server. |
|
1874 // |
|
1875 { |
|
1876 |
|
1877 //-- set up console output |
|
1878 F32_Test_Utils::SetConsole(test.Console()); |
|
1879 |
|
1880 TInt nRes=TheFs.CharToDrive(gDriveToTest, gDrive); |
|
1881 test(nRes==KErrNone); |
|
1882 |
|
1883 PrintDrvInfo(TheFs, gDrive); |
|
1884 |
|
1885 |
|
1886 TVolumeInfo v; |
|
1887 TInt r=TheFs.Volume(v, CurrentDrive()); |
|
1888 test(r==KErrNone); |
|
1889 LargeFileSize=Max((TUint32)I64LOW(v.iFree >> 7), (TUint32)65536u); |
|
1890 |
|
1891 if (gFirstTime) |
|
1892 { |
|
1893 MountRemoteFilesystem(); |
|
1894 CreateSubstDrive(); |
|
1895 |
|
1896 testDriveList(); |
|
1897 |
|
1898 DisMountRemoteFilesystem(); |
|
1899 RemoveSubstDrive(); |
|
1900 |
|
1901 testDriveInfo(); |
|
1902 testVolumeInfo(); |
|
1903 testClientParse(); |
|
1904 testPath(); |
|
1905 testServerParse(); |
|
1906 gFirstTime=EFalse; |
|
1907 } |
|
1908 |
|
1909 CreateTestDirectory(_L("\\F32-TST\\TFSRV\\")); |
|
1910 testSubst(); |
|
1911 testSetVolume(); |
|
1912 CopyFileToTestDirectory(); |
|
1913 testModified(); |
|
1914 testName(); |
|
1915 MakeAndDeleteFiles(); |
|
1916 FillUpDisk(); |
|
1917 DeleteTestDirectory(); |
|
1918 |
|
1919 TestSetErrorCondition(); |
|
1920 |
|
1921 } |
|
1922 |