207 |
207 |
208 TInt r=TheFs.DismountFileSystem(_L("DELAYFS"),EDriveQ); |
208 TInt r=TheFs.DismountFileSystem(_L("DELAYFS"),EDriveQ); |
209 |
209 |
210 test.Printf(_L("Dismounting the Remote Drive returned %d\n"),r); |
210 test.Printf(_L("Dismounting the Remote Drive returned %d\n"),r); |
211 |
211 |
212 test(r==KErrNone ); |
212 test_Value(r, r == KErrNone ); |
213 } |
213 } |
214 |
214 |
215 |
215 |
216 LOCAL_C void CreateSubstDrive() |
216 LOCAL_C void CreateSubstDrive() |
217 { |
217 { |
218 test.Printf(_L("Create Substitute Drive \n")); |
218 test.Printf(_L("Create Substitute Drive \n")); |
219 |
219 |
220 TDriveList driveList; |
220 TDriveList driveList; |
221 TInt i ; |
221 |
222 |
222 TInt r=TheFs.SessionPath(gTestSessionPath); |
223 TInt r=TheFs.SessionPath(gTestSessionPath); |
223 test_KErrNone(r); |
224 test(r==KErrNone); |
|
225 |
224 |
226 r=TheFs.DriveList(driveList, KDriveAttExclude|KDriveAttLocal); |
225 r=TheFs.DriveList(driveList, KDriveAttExclude|KDriveAttLocal); |
227 test( r==KErrNone ); |
226 test_KErrNone(r); |
228 |
227 |
229 |
228 |
230 for ( i = EDriveO; i < KMaxDrives; i++) |
229 for (TInt i = EDriveO; i < KMaxDrives; i++) |
231 { |
230 { |
232 |
231 if (driveList[i] == 0) |
233 if ( driveList[i] == 0) |
232 { |
234 { |
233 if (i == EDriveQ) |
235 if (i == EDriveQ) continue; // Q reserved to mount a virtual Remote Drive, as part of the test. |
234 continue; // Q reserved to mount a virtual Remote Drive, as part of the test. |
236 substDrive = i; |
235 substDrive = i; |
237 break; |
236 break; |
238 } |
237 } |
239 } |
238 } |
240 |
239 |
241 |
|
242 if (substDrive) |
240 if (substDrive) |
243 { |
241 { |
244 TDriveInfo driveInfo; |
242 TDriveInfo driveInfo; |
245 r=TheFs.Drive(driveInfo,substDrive); |
243 r=TheFs.Drive(driveInfo,substDrive); |
246 test(r==KErrNone); |
244 test_KErrNone(r); |
247 |
245 |
248 if (driveInfo.iDriveAtt==KDriveAttLocal) |
246 if (driveInfo.iDriveAtt==KDriveAttLocal) |
249 { |
247 { |
250 return; // Subst local drives fails |
248 return; // Subst local drives fails |
251 } |
249 } |
252 |
250 |
253 TFileName n; |
251 TFileName n; |
254 r=TheFs.Subst(n,substDrive); |
252 r=TheFs.Subst(n,substDrive); |
255 test(r==KErrNone); |
253 test_KErrNone(r); |
256 test(n.Length()==0); |
254 test_Value(n.Length(), n.Length() == 0); |
257 r=TheFs.SetSubst(gTestSessionPath,substDrive); |
255 r=TheFs.SetSubst(gTestSessionPath,substDrive); |
258 test(r==KErrNone); |
256 test_KErrNone(r); |
259 r=TheFs.Subst(n,substDrive); |
257 r=TheFs.Subst(n,substDrive); |
260 test(r==KErrNone); |
258 test_KErrNone(r); |
261 test(n==gTestSessionPath); |
259 test(n==gTestSessionPath); |
262 } |
260 } |
263 |
|
264 |
|
265 } |
261 } |
266 |
262 |
267 |
263 |
268 LOCAL_C void RemoveSubstDrive() |
264 LOCAL_C void RemoveSubstDrive() |
269 { |
265 { |
270 if( substDrive) |
266 if( substDrive) |
271 { |
267 { |
272 test.Printf(_L("Removing Substitute Drive \n")); |
268 test.Printf(_L("Removing Substitute Drive \n")); |
273 TInt r =TheFs.SetSubst(_L(""),substDrive); |
269 TInt r =TheFs.SetSubst(_L(""),substDrive); |
274 test(r ==KErrNone); |
270 test_KErrNone(r); |
275 } |
271 } |
276 |
272 |
277 } |
273 } |
278 |
274 |
279 |
275 |
282 // |
278 // |
283 // Test the drive info is reasonable |
279 // Test the drive info is reasonable |
284 // |
280 // |
285 { |
281 { |
286 |
282 |
287 test(anInfo.iConnectionBusType==EConnectionBusInternal || anInfo.iConnectionBusType==EConnectionBusUsb); |
283 test_Value(anInfo.iConnectionBusType, anInfo.iConnectionBusType==EConnectionBusInternal || anInfo.iConnectionBusType==EConnectionBusUsb); |
288 |
284 |
289 if (aDrive==EDriveZ) |
285 if (aDrive==EDriveZ) |
290 { |
286 { |
291 if (anInfo.iType==EMediaNotPresent) |
287 if (anInfo.iType==EMediaNotPresent) |
292 return; |
288 return; |
293 |
289 |
294 test(anInfo.iMediaAtt==KMediaAttWriteProtected); |
290 test_Value(anInfo.iMediaAtt, anInfo.iMediaAtt==KMediaAttWriteProtected); |
295 test(anInfo.iDriveAtt==(KDriveAttRom|KDriveAttInternal)); |
291 test_Value(anInfo.iDriveAtt, anInfo.iDriveAtt==(KDriveAttRom|KDriveAttInternal)); |
296 test(anInfo.iType==EMediaRom); |
292 test_Value(anInfo.iType, anInfo.iType==EMediaRom); |
297 } |
293 } |
298 |
294 |
299 else if (GetDriveLFFS()==aDrive) |
295 else if (GetDriveLFFS()==aDrive) |
300 { |
296 { |
301 if (anInfo.iType==EMediaNotPresent) |
297 if (anInfo.iType==EMediaNotPresent) |
302 return; |
298 return; |
303 |
299 |
304 test(anInfo.iDriveAtt&(KDriveAttLocal|KDriveAttInternal)==KDriveAttLocal|KDriveAttInternal); // LFFS sets KDriveAttTransaction as well |
300 test_Value(anInfo.iDriveAtt, anInfo.iDriveAtt&(KDriveAttLocal|KDriveAttInternal)==KDriveAttLocal|KDriveAttInternal); // LFFS sets KDriveAttTransaction as well |
305 test(anInfo.iType==EMediaFlash); |
301 test_Value(anInfo.iType, anInfo.iType==EMediaFlash); |
306 test(anInfo.iMediaAtt==KMediaAttFormattable); |
302 test_Value(anInfo.iMediaAtt, anInfo.iMediaAtt==KMediaAttFormattable); |
307 } |
303 } |
308 /* |
304 /* |
309 Why assume certain drive letters can only refer to certain drive types? |
305 Why assume certain drive letters can only refer to certain drive types? |
310 else if (aDrive==EDriveC || aDrive==EDriveY) |
306 else if (aDrive==EDriveC || aDrive==EDriveY) |
311 { |
307 { |
460 |
456 |
461 printDriveAtt(i,info.iDriveAtt); |
457 printDriveAtt(i,info.iDriveAtt); |
462 } |
458 } |
463 } |
459 } |
464 |
460 |
465 test(allDrivecount == drivecount + hiddenOrRemoteDriveCount); |
|
466 test(hiddenOrRemoteDriveCount - hiddenDriveCount == 1); |
|
467 |
|
468 test.Printf(_L("Found %d substitute drives\n"), substDriveCount); |
461 test.Printf(_L("Found %d substitute drives\n"), substDriveCount); |
469 test.Printf(_L("Found %d exclusively substitute drives \n"),exclusiveSubstDriveCount); |
462 test.Printf(_L("Found %d exclusively substitute drives \n"),exclusiveSubstDriveCount); |
470 test.Printf(_L("Found %d hidden drives\n"), hiddenDriveCount); |
463 test.Printf(_L("Found %d hidden drives\n"), hiddenDriveCount); |
471 |
464 |
472 TInt nonRemovables = drivecount - removableDriveCount; |
465 TInt nonRemovables = drivecount - removableDriveCount; |
473 TInt physicallyRemovable = removableDriveCount - logicallyRemovableDriveCount; |
466 TInt physicallyRemovable = removableDriveCount - logicallyRemovableDriveCount; |
474 test.Printf(_L("Found %d non removables drives\n"), nonRemovables); |
467 test.Printf(_L("Found %d non removables drives\n"), nonRemovables); |
475 test.Printf(_L("Found %d physically removable drives \n"),physicallyRemovable); |
468 test.Printf(_L("Found %d physically removable drives \n"),physicallyRemovable); |
476 test.Printf(_L("Found %d logically removable drives \n"),logicallyRemovableDriveCount); |
469 test.Printf(_L("Found %d logically removable drives \n"),logicallyRemovableDriveCount); |
477 |
470 |
|
471 test(allDrivecount == drivecount + hiddenOrRemoteDriveCount); |
|
472 test(hiddenOrRemoteDriveCount - hiddenDriveCount == 1); |
|
473 |
478 |
474 |
479 //--------------------------------------------- |
475 //--------------------------------------------- |
480 //! @SYMTestCaseID PBASE-T_FSRV-0546 |
476 //! @SYMTestCaseID PBASE-T_FSRV-0546 |
481 //! @SYMTestType UT |
477 //! @SYMTestType UT |
482 //! @SYMREQ CR909 |
478 //! @SYMREQ CR909 |
685 |
681 |
686 drivecount = 0; |
682 drivecount = 0; |
687 flags = KDriveAttExclude | KDriveAttRemote | KDriveAttSubsted; |
683 flags = KDriveAttExclude | KDriveAttRemote | KDriveAttSubsted; |
688 err = TheFs.DriveList(driveList, flags); |
684 err = TheFs.DriveList(driveList, flags); |
689 |
685 |
690 test( err == KErrNone ); |
686 test_KErrNone(err); |
691 |
687 |
692 for ( i = 0; i < KMaxDrives; i++) |
688 for ( i = 0; i < KMaxDrives; i++) |
693 { |
689 { |
694 if (driveList[i]) |
690 if (driveList[i]) |
695 { |
691 { |
696 err = TheFs.Drive(info,i); |
692 err = TheFs.Drive(info,i); |
697 test( err == KErrNone ); |
693 test_KErrNone(err); |
698 test( (!(info.iDriveAtt & KDriveAttRemote ) && (!(info.iDriveAtt & KDriveAttSubsted )))); |
694 test_Value(info.iDriveAtt, (!(info.iDriveAtt & KDriveAttRemote ) && (!(info.iDriveAtt & KDriveAttSubsted )))); |
699 drivecount++; |
695 drivecount++; |
700 |
696 |
701 printDriveAtt(i,info.iDriveAtt); |
697 printDriveAtt(i,info.iDriveAtt); |
702 } |
698 } |
703 } |
699 } |
704 test(drivecount == (allDrivecount - substDriveCount- 1) ); |
700 test_Value(drivecount, drivecount == (allDrivecount - substDriveCount- 1) ); |
705 |
701 |
706 |
702 |
707 |
703 |
708 test.Printf(_L("Exclusively Exclude Substed drives\n")); |
704 test.Printf(_L("Exclusively Exclude Substed drives\n")); |
709 |
705 |
710 drivecount = 0; |
706 drivecount = 0; |
711 flags = KDriveAttExclusive | KDriveAttExclude | KDriveAttSubsted; |
707 flags = KDriveAttExclusive | KDriveAttExclude | KDriveAttSubsted; |
712 err = TheFs.DriveList(driveList, flags); |
708 err = TheFs.DriveList(driveList, flags); |
713 |
709 |
714 test( err == KErrNone ); |
710 test_KErrNone(err); |
715 |
711 |
716 for ( i = 0; i < KMaxDrives; i++) |
712 for ( i = 0; i < KMaxDrives; i++) |
717 { |
713 { |
718 if (driveList[i]) |
714 if (driveList[i]) |
719 { |
715 { |
720 err = TheFs.Drive(info,i); |
716 err = TheFs.Drive(info,i); |
721 test( err == KErrNone ); |
717 test_KErrNone(err); |
722 test( info.iDriveAtt != KDriveAttSubsted ); |
718 test_Value(info.iDriveAtt, info.iDriveAtt != KDriveAttSubsted); |
723 drivecount++; |
719 drivecount++; |
724 |
720 |
725 printDriveAtt(i,info.iDriveAtt); |
721 printDriveAtt(i,info.iDriveAtt); |
726 } |
722 } |
727 |
723 |
728 } |
724 } |
729 |
725 |
730 test(drivecount == (allDrivecount - exclusiveSubstDriveCount) ); |
726 test_Value(drivecount, drivecount == (allDrivecount - exclusiveSubstDriveCount) ); |
731 |
727 |
732 } |
728 } |
733 |
729 |
734 |
730 |
735 //--------------------------------------------- |
731 //--------------------------------------------- |
811 |
807 |
812 case KDriveAttAll: |
808 case KDriveAttAll: |
813 expectMatch = ETrue; |
809 expectMatch = ETrue; |
814 break; |
810 break; |
815 |
811 |
816 case KDriveAttExclude : |
812 case KDriveAttExclude: |
817 expectMatch = (fullDriveList[i] & testAtt) == 0; |
813 expectMatch = (fullDriveList[i] & testAtt) == 0; |
818 break; |
814 break; |
819 |
815 |
820 case KDriveAttExclusive : |
816 case KDriveAttExclusive: |
821 expectMatch = (fullDriveList[i] == testAtt); |
817 expectMatch = (fullDriveList[i] == testAtt); |
822 break; |
818 break; |
823 |
819 |
824 case KDriveAttExclude | KDriveAttExclusive: |
820 case KDriveAttExclude | KDriveAttExclusive: |
825 expectMatch = (fullDriveList[i] != testAtt); |
821 expectMatch = (fullDriveList[i] != testAtt); |
826 break; |
822 break; |
827 |
823 |
828 case KDriveAttAll | KDriveAttExclude : |
824 case KDriveAttAll | KDriveAttExclude: |
829 test(0); // Invalid - should never get here as this returns KErrArgument for all cases |
825 // Invalid - should never get here as this returns KErrArgument for all cases |
830 break; |
826 case KDriveAttAll | KDriveAttExclusive: |
831 |
827 // Invalid - should never get here as this returns KErrArgument for all cases |
832 case KDriveAttAll | KDriveAttExclusive : |
828 case KDriveAttAll | KDriveAttExclude | KDriveAttExclusive: |
833 test(0); // Invalid - should never get here as this returns KErrArgument for all cases |
829 // Invalid - should never get here as this returns KErrArgument for all cases |
834 break; |
|
835 |
|
836 case KDriveAttAll | KDriveAttExclude | KDriveAttExclusive : |
|
837 test(0); // Invalid - should never get here as this returns KErrArgument for all cases |
|
838 break; |
|
839 |
|
840 default: |
830 default: |
841 test.Printf(_L("Unexpected Match Mask %08x"), testCombinations[matchIdx].iMatchMask); |
831 test.Printf(_L("Unexpected or invalid Match Mask %08x"), testCombinations[matchIdx].iMatchMask); |
842 test(0); |
832 test(0); |
843 break; |
833 break; |
844 } |
834 } |
845 |
835 |
846 if(expectMatch) |
836 if(expectMatch) |
847 { |
837 { |
848 //test.Printf(_L(" %c MATCHED OK "), 'A' + i); |
838 //test.Printf(_L(" %c MATCHED OK "), 'A' + i); |
849 test(newDriveList[i] == fullDriveList[i]); |
839 test_Value(newDriveList[i], newDriveList[i] == fullDriveList[i]); |
850 } |
840 } |
851 else |
841 else |
852 { |
842 { |
853 /*if(fullDriveList[i] == 0) |
843 /*if(fullDriveList[i] == 0) |
854 { |
844 { |
1104 { |
1093 { |
1105 |
1094 |
1106 test.Printf(_L("Test subst")); |
1095 test.Printf(_L("Test subst")); |
1107 TVolumeInfo v; |
1096 TVolumeInfo v; |
1108 TInt r=TheFs.Volume(v); |
1097 TInt r=TheFs.Volume(v); |
1109 test(r==KErrNone); |
1098 test_KErrNone(r); |
1110 TDriveInfo origDI; |
1099 TDriveInfo origDI; |
1111 r=TheFs.Drive(origDI); |
1100 r=TheFs.Drive(origDI); |
1112 test(r==KErrNone); |
1101 test_KErrNone(r); |
1113 |
1102 |
1114 TDriveInfo driveInfo; |
1103 TDriveInfo driveInfo; |
1115 r=TheFs.Drive(driveInfo,EDriveO); |
1104 r=TheFs.Drive(driveInfo,EDriveO); |
1116 test(r==KErrNone); |
1105 test_KErrNone(r); |
1117 |
1106 |
1118 if (driveInfo.iDriveAtt==KDriveAttLocal) |
1107 if (driveInfo.iDriveAtt==KDriveAttLocal) |
1119 { |
1108 { |
1120 return; // Subst local drives fails |
1109 return; // Subst local drives fails |
1121 } |
1110 } |
1122 |
1111 |
1123 TFileName n; |
1112 TFileName n; |
1124 r=TheFs.Subst(n,EDriveO); |
1113 r=TheFs.Subst(n,EDriveO); |
1125 test(r==KErrNone); |
1114 test_KErrNone(r); |
1126 test(n.Length()==0); |
1115 test_Value(n.Length(), n.Length()==0); |
1127 r=TheFs.SetSubst(gSessionPath,EDriveO); |
1116 r=TheFs.SetSubst(gSessionPath,EDriveO); |
1128 test(r==KErrNone); |
1117 test_KErrNone(r); |
1129 r=TheFs.Subst(n,EDriveO); |
1118 r=TheFs.Subst(n,EDriveO); |
1130 test(r==KErrNone); |
1119 test_KErrNone(r); |
1131 test(n==gSessionPath); |
1120 test(n==gSessionPath); |
1132 TVolumeInfo w; |
1121 TVolumeInfo w; |
1133 r=TheFs.Volume(w,EDriveO); |
1122 r=TheFs.Volume(w,EDriveO); |
1134 test(r==KErrNone); |
1123 test_KErrNone(r); |
1135 test(w.iDrive.iType==v.iDrive.iType); |
1124 test_Value(w.iDrive.iType, w.iDrive.iType==v.iDrive.iType); |
1136 test(w.iDrive.iConnectionBusType==v.iDrive.iConnectionBusType); |
1125 test_Value(w.iDrive.iConnectionBusType, w.iDrive.iConnectionBusType==v.iDrive.iConnectionBusType); |
1137 test(w.iDrive.iDriveAtt==KDriveAttSubsted); |
1126 test_Value(w.iDrive.iDriveAtt, w.iDrive.iDriveAtt==KDriveAttSubsted); |
1138 test(w.iDrive.iMediaAtt==v.iDrive.iMediaAtt); |
1127 test_Value(w.iDrive.iMediaAtt, w.iDrive.iMediaAtt==v.iDrive.iMediaAtt); |
1139 test(w.iUniqueID==v.iUniqueID); |
1128 test(w.iUniqueID==v.iUniqueID); |
1140 test(w.iSize==v.iSize); |
1129 test(w.iSize==v.iSize); |
1141 test(w.iFree==v.iFree); |
1130 test(w.iFree==v.iFree); |
1142 test(w.iName==v.iName); |
1131 test(w.iName==v.iName); |
1143 TDriveList driveList; |
1132 TDriveList driveList; |
1144 r=TheFs.DriveList(driveList); |
1133 r=TheFs.DriveList(driveList); |
1145 test(r==KErrNone); |
1134 test_KErrNone(r); |
1146 test(driveList[EDriveO]==KDriveAttSubsted); |
1135 test(driveList[EDriveO]==KDriveAttSubsted); |
1147 TDriveInfo d; |
1136 TDriveInfo d; |
1148 r=TheFs.Drive(d,EDriveO); |
1137 r=TheFs.Drive(d,EDriveO); |
1149 test(r==KErrNone); |
1138 test_KErrNone(r); |
1150 test(d.iDriveAtt==KDriveAttSubsted); |
1139 test_Value(d.iDriveAtt, d.iDriveAtt==KDriveAttSubsted); |
1151 test(d.iMediaAtt==origDI.iMediaAtt); |
1140 test_Value(d.iMediaAtt, d.iMediaAtt==origDI.iMediaAtt); |
1152 test(d.iType==origDI.iType); |
1141 test_Value(d.iType, d.iType==origDI.iType); |
1153 test(d.iConnectionBusType==origDI.iConnectionBusType); |
1142 test_Value(d.iConnectionBusType, d.iConnectionBusType==origDI.iConnectionBusType); |
1154 |
1143 |
1155 |
1144 |
1156 test.Next(_L("Test real name")); |
1145 test.Next(_L("Test real name")); |
1157 r=TheFs.RealName(_L("O:\\FILE.XXX"),n); |
1146 r=TheFs.RealName(_L("O:\\FILE.XXX"),n); |
1158 test(r==KErrNone); |
1147 test_KErrNone(r); |
1159 TFileName substedPath=gSessionPath; |
1148 TFileName substedPath=gSessionPath; |
1160 substedPath.Append(_L("FILE.XXX")); |
1149 substedPath.Append(_L("FILE.XXX")); |
1161 test(n.CompareF(substedPath)==KErrNone); |
1150 test(n.CompareF(substedPath)==KErrNone); |
1162 // |
1151 // |
1163 test.Next(_L("Test MkDir, Rename and RmDir on Substed drive")); |
1152 test.Next(_L("Test MkDir, Rename and RmDir on Substed drive")); |
1164 _LIT(KTurgid,"turgid\\"); |
1153 _LIT(KTurgid,"turgid\\"); |
1165 TFileName dir=gSessionPath; |
1154 TFileName dir=gSessionPath; |
1166 dir+=KTurgid; |
1155 dir+=KTurgid; |
1167 r=TheFs.MkDirAll(dir); |
1156 r=TheFs.MkDirAll(dir); |
1168 test(r==KErrNone); |
1157 test_KErrNone(r); |
1169 dir+=_L("subdir\\"); |
1158 dir+=_L("subdir\\"); |
1170 r=TheFs.MkDir(dir); |
1159 r=TheFs.MkDir(dir); |
1171 test(r==KErrNone); |
1160 test_KErrNone(r); |
1172 r=TheFs.RmDir(_L("O:\\turgid\\subdir\\")); |
1161 r=TheFs.RmDir(_L("O:\\turgid\\subdir\\")); |
1173 test(r==KErrNone); |
1162 test_KErrNone(r); |
1174 r=TheFs.Rename(_L("O:\\turgid"), _L("O:\\facile")); |
1163 r=TheFs.Rename(_L("O:\\turgid"), _L("O:\\facile")); |
1175 test(r==KErrNone); |
1164 test_KErrNone(r); |
1176 r=TheFs.MkDir(_L("O:\\insipid\\")); |
1165 r=TheFs.MkDir(_L("O:\\insipid\\")); |
1177 test(r==KErrNone); |
1166 test_KErrNone(r); |
1178 r=TheFs.Rename(_L("O:\\insipid"), _L("O:\\glib")); |
1167 r=TheFs.Rename(_L("O:\\insipid"), _L("O:\\glib")); |
1179 test(r==KErrNone); |
1168 test_KErrNone(r); |
1180 r=TheFs.RmDir(_L("O:\\facile\\")); |
1169 r=TheFs.RmDir(_L("O:\\facile\\")); |
1181 test(r==KErrNone); |
1170 test_KErrNone(r); |
1182 _LIT(KGlib,"glib\\"); |
1171 _LIT(KGlib,"glib\\"); |
1183 dir=gSessionPath; |
1172 dir=gSessionPath; |
1184 dir+=KGlib; |
1173 dir+=KGlib; |
1185 r=TheFs.RmDir(dir); |
1174 r=TheFs.RmDir(dir); |
1186 test(r==KErrNone); |
1175 test_KErrNone(r); |
1187 // |
1176 // |
1188 test.Next(_L("Test file operations on Substed drive")); |
1177 test.Next(_L("Test file operations on Substed drive")); |
1189 _LIT(File1,"File1.txt"); |
1178 _LIT(File1,"File1.txt"); |
1190 _LIT(File2,"File2.txt"); |
1179 _LIT(File2,"File2.txt"); |
1191 _LIT(SubstRoot,"O:\\"); |
1180 _LIT(SubstRoot,"O:\\"); |
1193 TFileName name1,name2; |
1182 TFileName name1,name2; |
1194 name1=gSessionPath; |
1183 name1=gSessionPath; |
1195 name1+=File1; |
1184 name1+=File1; |
1196 RFile f1; |
1185 RFile f1; |
1197 r=f1.Replace(TheFs,name1,EFileShareExclusive|EFileWrite); |
1186 r=f1.Replace(TheFs,name1,EFileShareExclusive|EFileWrite); |
1198 test(r==KErrNone); |
1187 test_KErrNone(r); |
1199 name2=SubstRoot; |
1188 name2=SubstRoot; |
1200 name2+=File2; |
1189 name2+=File2; |
1201 TBool isValid=TheFs.IsValidName(name2); |
1190 TBool isValid=TheFs.IsValidName(name2); |
1202 test(isValid); |
1191 test(isValid); |
1203 r=f1.Rename(name2); |
1192 r=f1.Rename(name2); |
1204 test(r==KErrNone); |
1193 test_KErrNone(r); |
1205 f1.Close(); |
1194 f1.Close(); |
1206 r=f1.Create(TheFs,name1,EFileShareExclusive|EFileWrite); |
1195 r=f1.Create(TheFs,name1,EFileShareExclusive|EFileWrite); |
1207 test(r==KErrNone); |
1196 test_KErrNone(r); |
1208 f1.Close(); |
1197 f1.Close(); |
1209 r=TheFs.Replace(name2,name1); |
1198 r=TheFs.Replace(name2,name1); |
1210 test(r==KErrNone); |
1199 test_KErrNone(r); |
1211 r=TheFs.Delete(name1); |
1200 r=TheFs.Delete(name1); |
1212 test(r==KErrNone); |
1201 test_KErrNone(r); |
1213 test.Next(_L("Test notifications on Substed drive")); |
1202 test.Next(_L("Test notifications on Substed drive")); |
1214 name1=gSessionPath; |
1203 name1=gSessionPath; |
1215 name1+=Subdir; |
1204 name1+=Subdir; |
1216 name2=SubstRoot; |
1205 name2=SubstRoot; |
1217 name2+=Subdir; |
1206 name2+=Subdir; |
1218 // set up some extended notifications |
1207 // set up some extended notifications |
1219 TRequestStatus status1; |
1208 TRequestStatus status1; |
1220 TRequestStatus status2; |
1209 TRequestStatus status2; |
1221 TRequestStatus status3; |
1210 TRequestStatus status3; |
1222 TheFs.NotifyChange(ENotifyDir,status1,name1); |
1211 TheFs.NotifyChange(ENotifyDir,status1,name1); |
1223 test(status1==KRequestPending); |
1212 test_Value(status1.Int(), status1==KRequestPending); |
1224 TheFs.NotifyChange(ENotifyDir,status2,name2); |
1213 TheFs.NotifyChange(ENotifyDir,status2,name2); |
1225 test(status2==KRequestPending); |
1214 test_Value(status2.Int(), status2==KRequestPending); |
1226 r=TheFs.MkDirAll(name1); |
1215 r=TheFs.MkDirAll(name1); |
1227 test(r==KErrNone); |
1216 test_KErrNone(r); |
1228 User::WaitForRequest(status1); |
1217 User::WaitForRequest(status1); |
1229 User::WaitForRequest(status2); |
1218 User::WaitForRequest(status2); |
1230 test(status1==KErrNone && status2==KErrNone); |
1219 test_KErrNone(status1.Int()); |
|
1220 test_KErrNone(status2.Int()); |
1231 TheFs.NotifyChange(ENotifyDir,status1,name1); |
1221 TheFs.NotifyChange(ENotifyDir,status1,name1); |
1232 test(status1==KRequestPending); |
1222 test_Value(status1.Int(), status1==KRequestPending); |
1233 TheFs.NotifyChange(ENotifyDir,status2,name2); |
1223 TheFs.NotifyChange(ENotifyDir,status2,name2); |
1234 test(status2==KRequestPending); |
1224 test_Value(status2.Int(), status2==KRequestPending); |
1235 TheFs.NotifyChange(ENotifyAll,status3,name2); |
1225 TheFs.NotifyChange(ENotifyAll,status3,name2); |
1236 test(status3==KRequestPending); |
1226 test_Value(status3.Int(), status3==KRequestPending); |
1237 r=f1.Temp(TheFs,name2,n,EFileShareAny|EFileWrite); |
1227 r=f1.Temp(TheFs,name2,n,EFileShareAny|EFileWrite); |
1238 test(r==KErrNone); |
1228 test_KErrNone(r); |
1239 User::WaitForRequest(status3); |
1229 User::WaitForRequest(status3); |
1240 test(status3==KErrNone && status1==KRequestPending && status2==KRequestPending); |
1230 test_KErrNone(status3.Int()); |
|
1231 test_Value(status1.Int(), status1==KRequestPending); |
|
1232 test_Value(status2.Int(), status2==KRequestPending); |
1241 f1.Close(); |
1233 f1.Close(); |
1242 TheFs.NotifyChangeCancel(); |
1234 TheFs.NotifyChangeCancel(); |
1243 test(status1==KErrCancel && status2==KErrCancel); |
1235 test_Value(status1.Int(), status1==KErrCancel); |
|
1236 test_Value(status2.Int(), status2==KErrCancel); |
1244 r=TheFs.Delete(n); |
1237 r=TheFs.Delete(n); |
1245 test(r==KErrNone); |
1238 test_KErrNone(r); |
1246 r=TheFs.RmDir(name1); |
1239 r=TheFs.RmDir(name1); |
1247 test(r==KErrNone); |
1240 test_KErrNone(r); |
1248 // |
1241 // |
1249 test.Next(_L("Test file systems on Substed drive")); |
1242 test.Next(_L("Test file systems on Substed drive")); |
1250 // test cannot mount file system on substituted drive |
1243 // test cannot mount file system on substituted drive |
1251 TInt sessionDrv; |
1244 TInt sessionDrv; |
1252 r=TheFs.CharToDrive(gSessionPath[0],sessionDrv); |
1245 r=TheFs.CharToDrive(gSessionPath[0],sessionDrv); |
1253 test(r==KErrNone); |
1246 test_KErrNone(r); |
1254 r=TheFs.FileSystemName(n,sessionDrv); |
1247 r=TheFs.FileSystemName(n,sessionDrv); |
1255 test(r==KErrNone || r==KErrNotFound); |
1248 test_Value(r, r == KErrNone || r==KErrNotFound); |
1256 r=TheFs.MountFileSystem(n,EDriveO); |
1249 r=TheFs.MountFileSystem(n,EDriveO); |
1257 test(r==KErrAccessDenied); |
1250 test_Value(r, r == KErrAccessDenied); |
1258 // test file system name on substitued drive is null |
1251 // test file system name on substitued drive is null |
1259 r=TheFs.FileSystemName(n,EDriveO); |
1252 r=TheFs.FileSystemName(n,EDriveO); |
1260 test(r==KErrNotFound && n==KNullDesC); |
1253 test_Value(r, r == KErrNotFound && n==KNullDesC); |
1261 // test cannot format a substitued drive |
1254 // test cannot format a substitued drive |
1262 RFormat format; |
1255 RFormat format; |
1263 TInt count; |
1256 TInt count; |
1264 r=format.Open(TheFs,SubstRoot,EHighDensity,count); |
1257 r=format.Open(TheFs,SubstRoot,EHighDensity,count); |
1265 test(r==KErrAccessDenied); |
1258 test_Value(r, r == KErrAccessDenied); |
1266 |
1259 |
1267 r=TheFs.SetSubst(_L(""),EDriveO); |
1260 r=TheFs.SetSubst(_L(""),EDriveO); |
1268 test(r==KErrNone); |
1261 test_KErrNone(r); |
1269 r=TheFs.Subst(n,EDriveO); |
1262 r=TheFs.Subst(n,EDriveO); |
1270 test(r==KErrNone); |
1263 test_KErrNone(r); |
1271 test(n==_L("")); |
1264 test(n==_L("")); |
1272 r=TheFs.Drive(d,EDriveO); |
1265 r=TheFs.Drive(d,EDriveO); |
1273 test(r==KErrNone); |
1266 test_KErrNone(r); |
1274 test(d.iDriveAtt==0); |
1267 test_Value(d.iDriveAtt, d.iDriveAtt==0); |
1275 } |
1268 } |
1276 |
1269 |
1277 LOCAL_C void testSetVolume() |
1270 LOCAL_C void testSetVolume() |
1278 // |
1271 // |
1279 // Test setting the volume info. |
1272 // Test setting the volume info. |
1298 test.Printf(_L("Error %d: Set volume label not testing on WINS\n"),r); |
1291 test.Printf(_L("Error %d: Set volume label not testing on WINS\n"),r); |
1299 test.End(); |
1292 test.End(); |
1300 return; |
1293 return; |
1301 } |
1294 } |
1302 |
1295 |
1303 test(r==KErrNone); |
1296 test_KErrNone(r); |
1304 r=TheFs.Volume(v,driveNum); |
1297 r=TheFs.Volume(v,driveNum); |
1305 test(r==KErrNone ); |
1298 test_Value(r, r == KErrNone ); |
|
1299 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
1306 test(v.iName==_L("")); |
1300 test(v.iName==_L("")); |
1307 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1308 |
1301 |
1309 test.Next(_L("Set volume label to ABCDEFGHIJK")); |
1302 test.Next(_L("Set volume label to ABCDEFGHIJK")); |
1310 r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum); |
1303 r=TheFs.SetVolumeLabel(_L("ABCDEFGHIJK"),driveNum); |
1311 test(r==KErrNone); |
1304 test_KErrNone(r); |
1312 r=TheFs.Volume(v,driveNum); |
1305 r=TheFs.Volume(v,driveNum); |
1313 test(r==KErrNone); |
1306 test_KErrNone(r); |
|
1307 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
1314 test(v.iName==_L("ABCDEFGHIJK")); |
1308 test(v.iName==_L("ABCDEFGHIJK")); |
1315 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1316 |
1309 |
1317 test.Next(_L("Set volume label to ABCDE")); |
1310 test.Next(_L("Set volume label to ABCDE")); |
1318 r=TheFs.SetVolumeLabel(_L("ABCDE"),driveNum); |
1311 r=TheFs.SetVolumeLabel(_L("ABCDE"),driveNum); |
1319 test(r==KErrNone); |
1312 test_KErrNone(r); |
1320 r=TheFs.Volume(v,driveNum); |
1313 r=TheFs.Volume(v,driveNum); |
1321 test(r==KErrNone); |
1314 test_KErrNone(r); |
|
1315 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
1322 test(v.iName==_L("ABCDE")); |
1316 test(v.iName==_L("ABCDE")); |
1323 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1324 |
1317 |
1325 |
1318 |
1326 test.Next(_L("Test replacement of non-ascii chars")); |
1319 test.Next(_L("Test replacement of non-ascii chars")); |
1327 TBuf<KMaxVolumeName> uBuf(KMaxVolumeName); |
1320 TBuf<KMaxVolumeName> uBuf(KMaxVolumeName); |
1328 uBuf.FillZ(); |
1321 uBuf.FillZ(); |
1336 uBuf[7]=0x103; |
1329 uBuf[7]=0x103; |
1337 uBuf[8]='e'; |
1330 uBuf[8]='e'; |
1338 uBuf[9]=0x104; |
1331 uBuf[9]=0x104; |
1339 uBuf[10]='f'; |
1332 uBuf[10]='f'; |
1340 r=TheFs.SetVolumeLabel(uBuf,driveNum); |
1333 r=TheFs.SetVolumeLabel(uBuf,driveNum); |
1341 test(r==KErrNone); |
1334 test_KErrNone(r); |
1342 TFileName drive=_L("?:"); |
1335 TFileName drive=_L("?:"); |
1343 drive[0]=gSessionPath[0]; |
1336 drive[0]=gSessionPath[0]; |
1344 |
1337 |
1345 // ??? this needs to be replaced |
1338 // ??? this needs to be replaced |
1346 // UserSvr::ForceRemountMedia(ERemovableMedia0); |
1339 // UserSvr::ForceRemountMedia(ERemovableMedia0); |
1347 User::After(1000000); |
1340 User::After(1000000); |
1348 |
1341 |
1349 TFileName sess; |
1342 TFileName sess; |
1350 r=TheFs.SessionPath(sess); |
1343 r=TheFs.SessionPath(sess); |
1351 test(r==KErrNone); |
1344 test_KErrNone(r); |
1352 r=TheFs.Volume(v,driveNum); |
1345 r=TheFs.Volume(v,driveNum); |
1353 test(r==KErrNone); |
1346 test_KErrNone(r); |
1354 |
1347 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
1355 if(Is_Fat(TheFs, gDrive)) //-- FAT doesn't support normal UNICODE in volume labels |
1348 if(Is_Fat(TheFs, gDrive)) //-- FAT doesn't support normal UNICODE in volume labels |
1356 test(v.iName==_L("a_b_c_d_e_f")); |
1349 test(v.iName==_L("a_b_c_d_e_f")); |
1357 else |
1350 else |
1358 test(v.iName == uBuf); |
1351 test(v.iName == uBuf); |
1359 |
1352 |
1360 |
|
1361 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1362 |
|
1363 |
|
1364 test.Next(_L("Set volume label back to nothing")); |
1353 test.Next(_L("Set volume label back to nothing")); |
1365 r=TheFs.SetVolumeLabel(_L(""),driveNum); |
1354 r=TheFs.SetVolumeLabel(_L(""),driveNum); |
1366 test(r==KErrNone); |
1355 test_KErrNone(r); |
1367 r=TheFs.Volume(v,driveNum); |
1356 r=TheFs.Volume(v,driveNum); |
1368 test(r==KErrNone); |
1357 test_KErrNone(r); |
|
1358 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
1369 test(v.iName==_L("")); |
1359 test(v.iName==_L("")); |
1370 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1371 |
1360 |
1372 test.Next(_L("Attempt to set volume label containing illegal characters")); |
1361 test.Next(_L("Attempt to set volume label containing illegal characters")); |
1373 r=TheFs.SetVolumeLabel(_L("abc>def"),driveNum); |
1362 r=TheFs.SetVolumeLabel(_L("abc>def"),driveNum); |
1374 test(r==KErrBadName); |
1363 test_Value(r, r == KErrBadName); |
1375 r=TheFs.SetVolumeLabel(_L("ghi*jkl"),driveNum); |
1364 r=TheFs.SetVolumeLabel(_L("ghi*jkl"),driveNum); |
1376 test(r==KErrBadName); |
1365 test_Value(r, r == KErrBadName); |
1377 r=TheFs.SetVolumeLabel(_L("mno?pqr"),driveNum); |
1366 r=TheFs.SetVolumeLabel(_L("mno?pqr"),driveNum); |
1378 test(r==KErrBadName); |
1367 test_Value(r, r == KErrBadName); |
1379 r=TheFs.SetVolumeLabel(_L("stu|vwx"),driveNum); |
1368 r=TheFs.SetVolumeLabel(_L("stu|vwx"),driveNum); |
1380 test(r==KErrBadName); |
1369 test_Value(r, r == KErrBadName); |
1381 r=TheFs.SetVolumeLabel(_L("yz<abc"),driveNum); |
1370 r=TheFs.SetVolumeLabel(_L("yz<abc"),driveNum); |
1382 test(r==KErrBadName); |
1371 test_Value(r, r == KErrBadName); |
1383 r=TheFs.SetVolumeLabel(_L("def//ghi"),driveNum); |
1372 r=TheFs.SetVolumeLabel(_L("def//ghi"),driveNum); |
1384 test(r==KErrBadName); |
1373 test_Value(r, r == KErrBadName); |
1385 |
1374 |
1386 r=TheFs.Volume(v,driveNum); |
1375 r=TheFs.Volume(v,driveNum); |
1387 test(r==KErrNone); |
1376 test_KErrNone(r); |
|
1377 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
1388 test(v.iName==_L("")); |
1378 test(v.iName==_L("")); |
1389 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1390 |
1379 |
1391 // test volume label after remount (for removable media only) |
1380 // test volume label after remount (for removable media only) |
1392 test.Next(_L("Test volume label after remount")); |
1381 test.Next(_L("Test volume label after remount")); |
1393 |
1382 |
1394 TDriveInfo info; |
1383 TDriveInfo info; |
1395 test(TheFs.Drive(info, driveNum) == KErrNone); |
1384 r = TheFs.Drive(info, driveNum); |
|
1385 test_KErrNone(r); |
1396 |
1386 |
1397 if((info.iDriveAtt & KDriveAttRemovable) != 0) |
1387 if((info.iDriveAtt & KDriveAttRemovable) != 0) |
1398 { |
1388 { |
1399 // 1. set volume label |
1389 // 1. set volume label |
1400 test(TheFs.SetVolumeLabel(_L("XXX"), driveNum) == KErrNone); |
1390 r = TheFs.SetVolumeLabel(_L("XXX"), driveNum); |
|
1391 test_KErrNone(r); |
1401 |
1392 |
1402 // 2. change bootsector volume label |
1393 // 2. change bootsector volume label |
1403 const TInt offset = IsFileSystemFAT32(TheFs, driveNum)? |
1394 const TInt offset = IsFileSystemFAT32(TheFs, driveNum)? |
1404 71 /*KFat32VolumeLabelPos*/ |
1395 71 /*KFat32VolumeLabelPos*/ |
1405 : |
1396 : |
1406 43 /*KFat16VolumeLabelPos*/; // both from sfat32\inc\sl_bpb.h |
1397 43 /*KFat16VolumeLabelPos*/; // both from sfat32\inc\sl_bpb.h |
1407 |
1398 |
1408 RRawDisk rdisk; |
1399 RRawDisk rdisk; |
1409 TPtrC8 label(_S8("Z"), 1); |
1400 TPtrC8 label(_S8("Z"), 1); |
1410 |
1401 |
1411 test(rdisk.Open(TheFs, driveNum) == KErrNone); |
1402 r = rdisk.Open(TheFs, driveNum); |
1412 test(rdisk.Write(offset, label) == KErrNone); |
1403 test_KErrNone(r); |
|
1404 r = rdisk.Write(offset, label); |
|
1405 test_KErrNone(r); |
1413 rdisk.Close(); |
1406 rdisk.Close(); |
1414 |
1407 |
1415 // 3. remount the drive |
1408 // 3. remount the drive |
1416 test(TheFs.RemountDrive(driveNum) == KErrNone); |
1409 r = TheFs.RemountDrive(driveNum); |
|
1410 test_KErrNone(r); |
1417 |
1411 |
1418 // 4. check volume label |
1412 // 4. check volume label |
1419 test(TheFs.Volume(v, driveNum) == KErrNone); |
1413 r = TheFs.Volume(v, driveNum); |
|
1414 test_KErrNone(r); |
|
1415 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
1420 test(v.iName == _L("XXX")); |
1416 test(v.iName == _L("XXX")); |
1421 test.Printf(_L("- Passed.\n")); |
1417 test.Printf(_L("- Passed.\n")); |
1422 } |
1418 } |
1423 else |
1419 else |
1424 test.Printf(_L("- Skipped (drive is not removable).\n")); |
1420 test.Printf(_L("- Skipped (drive is not removable).\n")); |
1425 |
1421 |
1426 // clean up |
1422 // clean up |
1427 test.Next(_L("Set volume label to original")); |
1423 test.Next(_L("Set volume label to original")); |
1428 r=TheFs.SetVolumeLabel(n,driveNum); |
1424 r=TheFs.SetVolumeLabel(n,driveNum); |
1429 test(r==KErrNone); |
1425 test_KErrNone(r); |
1430 r=TheFs.Volume(v,driveNum); |
1426 r=TheFs.Volume(v,driveNum); |
1431 test(r==KErrNone); |
1427 test_KErrNone(r); |
|
1428 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
1432 test(v.iName==n); |
1429 test(v.iName==n); |
1433 test.Printf(_L("VOL=\"%S\"\n"),&v.iName); |
|
1434 |
1430 |
1435 test.End(); |
1431 test.End(); |
1436 } |
1432 } |
1437 |
1433 |
1438 LOCAL_C void testModified() |
1434 LOCAL_C void testModified() |
1442 { |
1438 { |
1443 |
1439 |
1444 test.Start(_L("Test modified/SetModified functions")); |
1440 test.Start(_L("Test modified/SetModified functions")); |
1445 TTime savedTime; |
1441 TTime savedTime; |
1446 TInt r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),savedTime); |
1442 TInt r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),savedTime); |
1447 test(r==KErrNone); |
1443 test_KErrNone(r); |
1448 TDateTime dateTime=savedTime.DateTime(); |
1444 TDateTime dateTime=savedTime.DateTime(); |
1449 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()); |
1445 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()); |
1450 test.Next(_L("Set modified")); |
1446 test.Next(_L("Set modified")); |
1451 dateTime.Set(1993,EAugust,23,1,13,54,123456); |
1447 dateTime.Set(1993,EAugust,23,1,13,54,123456); |
1452 TTime newTime(dateTime); |
1448 TTime newTime(dateTime); |
1453 r=TheFs.SetModified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),newTime); |
1449 r=TheFs.SetModified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),newTime); |
1454 test(r==KErrNone); |
1450 test_KErrNone(r); |
1455 TTime checkTime; |
1451 TTime checkTime; |
1456 r=TheFs.Modified(_L("\\XXXX\\YYYY\\ZZZZ.CPP"),checkTime); |
1452 r=TheFs.Modified(_L("\\XXXX\\YYYY\\ZZZZ.CPP"),checkTime); |
1457 test(r==KErrPathNotFound); |
1453 test_Value(r, r == KErrPathNotFound); |
1458 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
1454 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
1459 test(r==KErrNone); |
1455 test_KErrNone(r); |
1460 dateTime=checkTime.DateTime(); |
1456 dateTime=checkTime.DateTime(); |
|
1457 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()); |
1461 test(dateTime.Year()==1993); |
1458 test(dateTime.Year()==1993); |
1462 test(dateTime.Month()==EAugust); |
1459 test(dateTime.Month()==EAugust); |
1463 test(dateTime.Day()==23); |
1460 test(dateTime.Day()==23); |
1464 test(dateTime.Hour()==1); |
1461 test(dateTime.Hour()==1); |
1465 test(dateTime.Minute()==13); |
1462 test(dateTime.Minute()==13); |
1466 test(dateTime.Second()==54); |
1463 test(dateTime.Second()==54); |
1467 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()); |
|
1468 // test(dateTime.MicroSecond()==123456); // dos is not accurate enough |
1464 // test(dateTime.MicroSecond()==123456); // dos is not accurate enough |
1469 r=TheFs.SetModified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),savedTime); |
1465 r=TheFs.SetModified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),savedTime); |
1470 test(r==KErrNone); |
1466 test_KErrNone(r); |
1471 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
1467 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
1472 test(r==KErrNone); |
1468 test_KErrNone(r); |
1473 test(checkTime==savedTime); |
1469 test(checkTime==savedTime); |
1474 |
1470 |
1475 RFile f; |
1471 RFile f; |
1476 r=f.Open(TheFs,_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),EFileWrite); |
1472 r=f.Open(TheFs,_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),EFileWrite); |
1477 test(r==KErrNone); |
1473 test_KErrNone(r); |
1478 dateTime.Set(1997,EJanuary,1,2,55,51,999999); |
1474 dateTime.Set(1997,EJanuary,1,2,55,51,999999); |
1479 newTime=dateTime; |
1475 newTime=dateTime; |
1480 r=f.SetModified(newTime); |
1476 r=f.SetModified(newTime); |
1481 test(r==KErrNone); |
1477 test_KErrNone(r); |
1482 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
1478 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
1483 test(r==KErrNone); |
1479 test_KErrNone(r); |
1484 |
1480 |
1485 dateTime=checkTime.DateTime(); |
1481 dateTime=checkTime.DateTime(); |
|
1482 test.Printf(_L("T_FSRV.CPP last modified via RFs::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()); |
1486 test(dateTime.Year()==1997); |
1483 test(dateTime.Year()==1997); |
1487 test(dateTime.Month()==EJanuary); |
1484 test(dateTime.Month()==EJanuary); |
1488 test(dateTime.Day()==1); |
1485 test(dateTime.Day()==1); |
1489 test(dateTime.Hour()==2); |
1486 test(dateTime.Hour()==2); |
1490 test(dateTime.Minute()==55); |
1487 test(dateTime.Minute()==55); |
1491 test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 |
1488 test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 |
1492 |
1489 |
1493 r=f.Modified(checkTime); |
1490 r=f.Modified(checkTime); |
1494 test(r==KErrNone); |
1491 test_KErrNone(r); |
1495 |
1492 |
1496 dateTime=checkTime.DateTime(); |
1493 dateTime=checkTime.DateTime(); |
|
1494 test.Printf(_L("T_FSRV.CPP last modified via RFile::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()); |
1497 test(dateTime.Year()==1997); |
1495 test(dateTime.Year()==1997); |
1498 test(dateTime.Month()==EJanuary); |
1496 test(dateTime.Month()==EJanuary); |
1499 test(dateTime.Day()==1); |
1497 test(dateTime.Day()==1); |
1500 test(dateTime.Hour()==2); |
1498 test(dateTime.Hour()==2); |
1501 test(dateTime.Minute()==55); |
1499 test(dateTime.Minute()==55); |
1502 test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 |
1500 test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 |
1503 f.Close(); |
1501 f.Close(); |
1504 |
1502 |
1505 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
1503 r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); |
1506 test(r==KErrNone); |
1504 test_KErrNone(r); |
1507 |
1505 |
1508 dateTime=checkTime.DateTime(); |
1506 dateTime=checkTime.DateTime(); |
|
1507 test.Printf(_L("T_FSRV.CPP last modified via RFs::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()); |
1509 test(dateTime.Year()==1997); |
1508 test(dateTime.Year()==1997); |
1510 test(dateTime.Month()==EJanuary); |
1509 test(dateTime.Month()==EJanuary); |
1511 test(dateTime.Day()==1); |
1510 test(dateTime.Day()==1); |
1512 test(dateTime.Hour()==2); |
1511 test(dateTime.Hour()==2); |
1513 test(dateTime.Minute()==55); |
1512 test(dateTime.Minute()==55); |
1635 // |
1625 // |
1636 { |
1626 { |
1637 |
1627 |
1638 test.Start(_L("Create and delete large files")); |
1628 test.Start(_L("Create and delete large files")); |
1639 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\SMALLDIRECTORY\\")); |
1629 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\SMALLDIRECTORY\\")); |
1640 test(r==KErrNone || r==KErrAlreadyExists); |
1630 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
1641 TBuf<128> fileName=_L("\\F32-TST\\SMALLDIRECTORY\\FILE"); |
1631 TBuf<128> fileName=_L("\\F32-TST\\SMALLDIRECTORY\\FILE"); |
1642 r=CreateFileX(fileName,0); |
1632 r=CreateFileX(fileName,0); |
1643 test(r==KErrNone); |
1633 test_KErrNone(r); |
1644 r=CreateFileX(fileName,1); |
1634 r=CreateFileX(fileName,1); |
1645 test(r==KErrNone); |
1635 test_KErrNone(r); |
1646 r=DeleteFileX(fileName,0); |
1636 r=DeleteFileX(fileName,0); |
1647 test(r==KErrNone); |
1637 test_KErrNone(r); |
1648 r=CreateFileX(fileName,2); |
1638 r=CreateFileX(fileName,2); |
1649 test(r==KErrNone); |
1639 test_KErrNone(r); |
1650 r=CreateFileX(fileName,1); |
1640 r=CreateFileX(fileName,1); |
1651 test(r==KErrNone); |
1641 test_KErrNone(r); |
1652 r=CreateFileX(fileName,3); |
1642 r=CreateFileX(fileName,3); |
1653 test(r==KErrNone); |
1643 test_KErrNone(r); |
1654 r=DeleteFileX(fileName,1); |
1644 r=DeleteFileX(fileName,1); |
1655 test(r==KErrNone); |
1645 test_KErrNone(r); |
1656 r=CreateFileX(fileName,4); |
1646 r=CreateFileX(fileName,4); |
1657 test(r==KErrNone); |
1647 test_KErrNone(r); |
1658 r=DeleteFileX(fileName,2); |
1648 r=DeleteFileX(fileName,2); |
1659 test(r==KErrNone); |
1649 test_KErrNone(r); |
1660 r=DeleteFileX(fileName,3); |
1650 r=DeleteFileX(fileName,3); |
1661 test(r==KErrNone); |
1651 test_KErrNone(r); |
1662 r=DeleteFileX(fileName,4); |
1652 r=DeleteFileX(fileName,4); |
1663 test(r==KErrNone); |
1653 test_KErrNone(r); |
1664 r=CreateFileX(fileName,1); |
1654 r=CreateFileX(fileName,1); |
1665 test(r==KErrNone); |
1655 test_KErrNone(r); |
1666 r=DeleteFileX(fileName,1); |
1656 r=DeleteFileX(fileName,1); |
1667 test(r==KErrNone); |
1657 test_KErrNone(r); |
1668 |
1658 |
1669 r=TheFs.CheckDisk(fileName); |
1659 r=TheFs.CheckDisk(fileName); |
1670 if (r!=KErrNone && r!=KErrNotSupported) |
1660 test_Value(r, r == KErrNone || r == KErrNotSupported); |
1671 { |
|
1672 test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); |
|
1673 test(0); |
|
1674 //test.Getch(); |
|
1675 } |
|
1676 |
|
1677 test.End(); |
1661 test.End(); |
1678 } |
1662 } |
1679 |
1663 |
1680 LOCAL_C void FillUpDisk() |
1664 LOCAL_C void FillUpDisk() |
1681 // |
1665 // |
1683 // |
1667 // |
1684 { |
1668 { |
1685 |
1669 |
1686 test.Start(_L("Fill disk to capacity")); |
1670 test.Start(_L("Fill disk to capacity")); |
1687 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\BIGDIRECTORY\\")); |
1671 TInt r=TheFs.MkDirAll(_L("\\F32-TST\\BIGDIRECTORY\\")); |
1688 test(r==KErrNone || r==KErrAlreadyExists); |
1672 test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
1689 TInt count=0; |
1673 TInt count=0; |
1690 TFileName sessionPath; |
1674 TFileName sessionPath; |
1691 r=TheFs.SessionPath(sessionPath); |
1675 r=TheFs.SessionPath(sessionPath); |
1692 test(r==KErrNone); |
1676 test_KErrNone(r); |
1693 TBuf<128> fileName=_L("\\F32-TST\\BIGDIRECTORY\\FILE"); |
1677 TBuf<128> fileName=_L("\\F32-TST\\BIGDIRECTORY\\FILE"); |
1694 FOREVER |
1678 FOREVER |
1695 { |
1679 { |
1696 TInt r=CreateFileX(fileName,count); |
1680 TInt r=CreateFileX(fileName,count); |
1697 if (r==KErrDiskFull) |
1681 if (r==KErrDiskFull) |
1698 break; |
1682 break; |
1699 test(r==KErrNone); |
1683 test_KErrNone(r); |
1700 count++; |
1684 count++; |
1701 #if defined(__WINS__) |
1685 if (Is_SimulatedSystemDrive(TheFs,gDrive) && count==32) |
1702 if (count==32 && sessionPath[0]=='C') |
1686 break; // Limit on disk size for emulator/PlatSim |
1703 break; |
|
1704 #endif |
|
1705 } |
1687 } |
1706 |
1688 |
1707 r=TheFs.CheckDisk(fileName); |
1689 r=TheFs.CheckDisk(fileName); |
1708 if (r!=KErrNone && r!=KErrNotSupported) |
1690 test_Value(r, r == KErrNone || r == KErrNotSupported); |
1709 { |
|
1710 test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); |
|
1711 test(0); |
|
1712 //test.Getch(); |
|
1713 } |
|
1714 |
1691 |
1715 while(count--) |
1692 while(count--) |
1716 DeleteFileX(fileName,count); |
1693 DeleteFileX(fileName,count); |
1717 |
1694 |
1718 r=TheFs.CheckDisk(fileName); |
1695 r=TheFs.CheckDisk(fileName); |
1719 if (r!=KErrNone && r!=KErrNotSupported) |
1696 test_Value(r, r == KErrNone || r == KErrNotSupported); |
1720 { |
|
1721 test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); |
|
1722 test(0); |
|
1723 //test.Getch(); |
|
1724 } |
|
1725 |
1697 |
1726 test.End(); |
1698 test.End(); |
1727 } |
1699 } |
1728 |
1700 |
1729 LOCAL_C void CopyFileToTestDirectory() |
1701 LOCAL_C void CopyFileToTestDirectory() |
1734 |
1706 |
1735 TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
1707 TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP"); |
1736 fn[0] = gExeFileName[0]; |
1708 fn[0] = gExeFileName[0]; |
1737 TParse f; |
1709 TParse f; |
1738 TInt r=TheFs.Parse(fn,f); |
1710 TInt r=TheFs.Parse(fn,f); |
1739 test(r==KErrNone); |
1711 test_KErrNone(r); |
1740 test.Next(_L("Copying file to test directory")); |
1712 test.Next(_L("Copying file to test directory")); |
1741 TParse fCopy; |
1713 TParse fCopy; |
1742 r=TheFs.Parse(f.NameAndExt(),fCopy); |
1714 r=TheFs.Parse(f.NameAndExt(),fCopy); |
1743 test(r==KErrNone); |
1715 test_KErrNone(r); |
1744 |
1716 |
1745 RFile f1; |
1717 RFile f1; |
1746 r=f1.Open(TheFs,f.FullName(),EFileStreamText|EFileShareReadersOnly); |
1718 r=f1.Open(TheFs,f.FullName(),EFileStreamText|EFileShareReadersOnly); |
1747 test(r==KErrNone); |
1719 test_KErrNone(r); |
1748 RFile f2; |
1720 RFile f2; |
1749 r=f2.Replace(TheFs,fCopy.FullName(),EFileWrite); |
1721 r=f2.Replace(TheFs,fCopy.FullName(),EFileWrite); |
1750 test(r==KErrNone); |
1722 test_KErrNone(r); |
1751 TBuf8<512> copyBuf; |
1723 TBuf8<512> copyBuf; |
1752 TInt rem; |
1724 TInt rem; |
1753 r=f1.Size(rem); |
1725 r=f1.Size(rem); |
1754 test(r==KErrNone); |
1726 test_KErrNone(r); |
1755 TInt pos=0; |
1727 TInt pos=0; |
1756 while (rem) |
1728 while (rem) |
1757 { |
1729 { |
1758 TInt s=Min(rem,copyBuf.MaxSize()); |
1730 TInt s=Min(rem,copyBuf.MaxSize()); |
1759 r=f1.Read(pos,copyBuf,s); |
1731 r=f1.Read(pos,copyBuf,s); |
1760 test(r==KErrNone); |
1732 test_KErrNone(r); |
1761 test(copyBuf.Length()==s); |
1733 test_Value(copyBuf.Length(), copyBuf.Length() == s); |
1762 r=f2.Write(pos,copyBuf,s); |
1734 r=f2.Write(pos,copyBuf,s); |
1763 test(r==KErrNone); |
1735 test_KErrNone(r); |
1764 pos+=s; |
1736 pos+=s; |
1765 rem-=s; |
1737 rem-=s; |
1766 } |
1738 } |
1767 f1.Close(); |
1739 f1.Close(); |
1768 f2.Close(); |
1740 f2.Close(); |
1788 |
1760 |
1789 const TInt KMyError = -756; //-- specific error code we will simulate |
1761 const TInt KMyError = -756; //-- specific error code we will simulate |
1790 |
1762 |
1791 //========== just create a file |
1763 //========== just create a file |
1792 nRes = TheFs.SetErrorCondition(KMyError,0); //-- set up FS error simulation |
1764 nRes = TheFs.SetErrorCondition(KMyError,0); //-- set up FS error simulation |
1793 test(nRes == KErrNone); |
1765 test_KErrNone(nRes); |
1794 |
1766 |
1795 //-- this shall fail immediately |
1767 //-- this shall fail immediately |
1796 nRes = file.Replace(TheFs, KFileName, EFileWrite); |
1768 nRes = file.Replace(TheFs, KFileName, EFileWrite); |
1797 test(nRes == KMyError); |
1769 test_Value(nRes, nRes == KMyError); |
1798 |
1770 |
1799 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
1771 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
1800 file.Close(); |
1772 file.Close(); |
1801 |
1773 |
1802 //========== create file & duplicate a handle #1 |
1774 //========== create file & duplicate a handle #1 |
1803 nRes = TheFs.SetErrorCondition(KMyError,1); //-- set up FS error simulation |
1775 nRes = TheFs.SetErrorCondition(KMyError,1); //-- set up FS error simulation |
1804 test(nRes == KErrNone); |
1776 test_KErrNone(nRes); |
1805 |
1777 |
1806 //-- this shall succeed |
1778 //-- this shall succeed |
1807 nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 0 |
1779 nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 0 |
1808 test(nRes == KErrNone); |
1780 test_KErrNone(nRes); |
1809 |
1781 |
1810 //-- this shall fail inside RFile::Duplicate() half way through in the RFile::DuplicateHandle() |
1782 //-- this shall fail inside RFile::Duplicate() half way through in the RFile::DuplicateHandle() |
1811 nRes = file1.Duplicate(file); |
1783 nRes = file1.Duplicate(file); |
1812 test(nRes == KMyError); |
1784 test_Value(nRes, nRes == KMyError); |
1813 file1.Close(); |
1785 file1.Close(); |
1814 |
1786 |
1815 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
1787 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
1816 file.Close(); |
1788 file.Close(); |
1817 |
1789 |
1818 //-- check that the file isn't locked |
1790 //-- check that the file isn't locked |
1819 nRes = TheFs.Delete(KFileName); |
1791 nRes = TheFs.Delete(KFileName); |
1820 test(nRes == KErrNone); |
1792 test_KErrNone(nRes); |
1821 |
1793 |
1822 //========== create file & duplicate a handle #2 |
1794 //========== create file & duplicate a handle #2 |
1823 nRes = TheFs.SetErrorCondition(KMyError,2); //-- set up FS error simulation |
1795 nRes = TheFs.SetErrorCondition(KMyError,2); //-- set up FS error simulation |
1824 test(nRes == KErrNone); |
1796 test_KErrNone(nRes); |
1825 |
1797 |
1826 //-- this shall succeed |
1798 //-- this shall succeed |
1827 nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 1 |
1799 nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 1 |
1828 test(nRes == KErrNone); |
1800 test_KErrNone(nRes); |
1829 |
1801 |
1830 //-- this must not fail, because EFsFileAdopt is excluded from the erros simulation |
1802 //-- this must not fail, because EFsFileAdopt is excluded from the erros simulation |
1831 nRes = file1.Duplicate(file); |
1803 nRes = file1.Duplicate(file); |
1832 test(nRes == KErrNone); |
1804 test_KErrNone(nRes); |
1833 file1.Close(); |
1805 file1.Close(); |
1834 |
1806 |
1835 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
1807 nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation |
1836 file.Close(); |
1808 file.Close(); |
1837 |
1809 |
1838 //-- check that the file isn't locked |
1810 //-- check that the file isn't locked |
1839 nRes = TheFs.Delete(KFileName); |
1811 nRes = TheFs.Delete(KFileName); |
1840 test(nRes == KErrNone); |
1812 test_KErrNone(nRes); |
1841 |
1813 |
1842 //========== crazy loop, for DEF103757 |
1814 //========== crazy loop, for DEF103757 |
1843 |
1815 |
1844 for(TInt i=0; i<6; ++i) |
1816 for(TInt i=0; i<6; ++i) |
1845 { |
1817 { |