First public contribution.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\bench\t_fsrdel.cpp
21 #include "t_benchmain.h"
23 GLDEF_D RTest test(_L("File Server Benchmarks, deletion of a massive amount of files"));
25 //----------------------------------------------------------------------------------------------
26 //! @SYMTestCaseID PBASE-T_FSRDEL-0272
29 //! @SYMTestCaseDesc This test case is measuring performance of the FAT implementation.
30 //! @SYMTestActions 0. Expects the files to exist in order to successful execution
31 //! 1. Time the deletion of a file from each directory with RFs::Delete
32 //! 2. Time the deletion of a file from each directory with CFileMan::Delete
33 //! 3. Time the deletion of all the files from each directory
35 //! 4. Time the deletion of all the files from each directory with
36 //! CFileMan::Delete (wildcard F*.*)
37 //! 5. Time the deletion of a file from each directory with RFs::Delete
38 //! with two clients accessing the directory
39 //! 6. Time the deletion of a file from each directory with CFileMan::Delete
40 //! with two clients accessing the directory
41 //! 7. Time the deletion of all the files from each directory with RFs::Delete
42 //! with two clients accessing the directory
43 //! 8. Time the deletion of all the files from each directory with
44 //! CFileMan::Delete with two clients accessing the directory (wildcard F*.*)
45 //! 9. Time the deletion of a file from each directory with RFs::Delete
46 //! with two clients accessing different directories
47 //! 10. Time the deletion of a file from each directory with CFileMan::Delete
48 //! with two clients accessing different directories
49 //! 11. Time the deletion of all the files from each directory with RFs::Delete
50 //! with two clients accessing different directories
51 //! 12. Time the deletion of all the files from each directory with
52 //! CFileMan::Delete with two clients accessing different directories (wildcard F*.*)
53 //! @SYMTestExpectedResults Finishes if the system behaves as expected, panics otherwise
54 //! @SYMTestPriority High
55 //! @SYMTestStatus Implemented
56 //----------------------------------------------------------------------------------------------
58 LOCAL_D RSemaphore client,write_screen;
59 LOCAL_D const TInt KHeapSize=0x4000;
60 LOCAL_D TBuf8<4096> buf;
61 LOCAL_D TDriveList gDriveList;
63 // Concurrent thread varibles
68 LOCAL_D TFileName gDelEntryDir;
69 LOCAL_D TFileName gDelEntryDir2;
70 LOCAL_D TInt ThreadCount=0;
71 TBool gWriting = EFalse;
75 _LIT(KDeleteMe,"delete%d.me");
76 _LIT(KDeleteMe2,"blabla%d.rhd");
79 /** Send content through the RDebug for trgtest
80 not to hung, when the test is not writing
83 LOCAL_C TInt noise(TAny* )
87 User::After(2147483647); // max value, 35 minutes, 47 seconds
89 RDebug::Print(_L("."));
93 /** Create background noise by deleting/creating file in gDelEntryDir2 directory
96 LOCAL_C TInt DeleteEntryAccess2(TAny* )
103 RTest test(_L("test 2"));
105 // Not checking error state until main thread has been signalled, to avoid deadlock
107 r = fs.SetSessionPath(gSessionPath);
109 filename.Format(KDeleteMe2,gT2);
111 dirfile = gDelEntryDir2;
112 dirfile.Append(filename);
121 r = file.Create(fs, dirfile, EFileShareAny|EFileWrite);
122 if(r == KErrAlreadyExists)
123 r = file.Open(fs, dirfile, EFileShareAny|EFileWrite);
127 r = fs.Delete(dirfile);
128 if((r != KErrNone) && (r != KErrInUse))
134 /** Create background noise by deleting/creating file in gDelEntryDir directory
137 LOCAL_C TInt DeleteEntryAccess(TAny*)
144 RTest test(_L("test 2"));
146 // Not checking error state until main thread has been signalled, to avoid deadlock
148 r = fs2.SetSessionPath(gSessionPath);
150 filename.Format(KDeleteMe,gT1);
152 dirfile = gDelEntryDir;
153 dirfile.Append(filename);
162 r = file2.Create(fs2, dirfile, EFileShareAny|EFileWrite);
163 if(r == KErrAlreadyExists)
164 r = file2.Open(fs2, dirfile, EFileShareAny|EFileWrite);
167 r = fs2.Delete(dirfile);
168 if((r != KErrNone) && (r != KErrInUse))
174 /** Starts a concurrent client session in different directories
177 LOCAL_C void DoTest(TThreadFunction aFunction)
181 TBuf<20> buffer = _L("Speedy");
182 buffer.AppendNum(ThreadCount++);
184 TInt r = gSpeedy.Create(buffer, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
187 buffer = _L("Speedy");
188 buffer.AppendNum(ThreadCount++);
190 r = gSpeedyII.Create(buffer, DeleteEntryAccess2, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
193 gSpeedy.SetPriority(EPriorityLess);
194 gSpeedyII.SetPriority(EPriorityLess);
203 /** Kills the concurrent sessions
206 LOCAL_C void DoTestKill()
209 User::After(10000000);
211 gSpeedy.Kill(KErrNone);
214 gSpeedyII.Kill(KErrNone);
218 /** Creates again the last.txt file in each directory that is being used
221 LOCAL_C void ReCreateLast()
228 TBuf8<1024> dummy(1024);
234 dirtemp.Format(KDirMultipleName, i, 100);
235 path.Append(dirtemp);
236 path.Append(KCommonFile);
237 r = file.Create(TheFs, path, EFileShareAny|EFileWrite);
238 if(r == KErrAlreadyExists)
240 r = file.Open(TheFs, path, EFileShareAny|EFileWrite);
243 r = file.Write(dummy);
249 if(gFilesLimit >= 1000)
255 dirtemp.Format(KDirMultipleName, i, 1000);
256 path.Append(dirtemp);
257 path.Append(KCommonFile);
258 r = file.Create(TheFs, path, EFileShareAny|EFileWrite);
259 if(r == KErrAlreadyExists)
261 r = file.Open(TheFs, path, EFileShareAny|EFileWrite);
264 r = file.Write(dummy);
271 if(gFilesLimit >= 5000)
277 dirtemp.Format(KDirMultipleName, i, 5000);
278 path.Append(dirtemp);
279 path.Append(KCommonFile);
280 r = file.Create(TheFs, path, EFileShareAny|EFileWrite);
281 if(r == KErrAlreadyExists)
283 r = file.Open(TheFs, path, EFileShareAny|EFileWrite);
286 r = file.Write(dummy);
292 if(gFilesLimit >= 10000)
298 dirtemp.Format(KDirMultipleName, i, 10000);
299 path.Append(dirtemp);
300 path.Append(KCommonFile);
301 r = file.Create(TheFs, path, EFileShareAny|EFileWrite);
302 if(r ==KErrAlreadyExists)
304 r = file.Open(TheFs, path, EFileShareAny|EFileWrite);
307 r = file.Write(dummy);
315 /** Deletes all files in a given directory one by one
317 @param aN Number of files in the directory
318 @param aStep Test step
320 LOCAL_C TInt DelAllFiles1(TInt aN, TInt aStep)
323 TBuf16<50> directory;
327 TBuf16<50> buffer(50);
329 _LIT(KMsg, "This file caused a problem: %S\n");
333 TTimeIntervalMicroSeconds timeTaken(0);
334 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
336 if(aN <= gFilesLimit)
341 directory = gSessionPath;
342 dirtemp.Format(KDirMultipleName, 1, aN);
343 directory.Append(dirtemp);
346 startTime.HomeTime();
349 FileNamesGeneration(buffer, 8, i, i%3+1) ;
352 r = TheFs.Delete(path);
356 msg.Format(KMsg, &path);
363 timeTaken = endTime.MicroSecondsFrom(startTime);
364 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
370 dirtemp.Format(KDirMultipleName, 2, aN);
371 directory = gSessionPath;
372 directory.Append(dirtemp);
375 startTime.HomeTime();
378 FileNamesGeneration(buffer, 20, i, i%3+1) ;
381 r = TheFs.Delete(path);
385 msg.Format(KMsg, &path);
392 timeTaken = endTime.MicroSecondsFrom(startTime);
393 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
399 dirtemp.Format(KDirMultipleName, 3, aN);
400 directory = gSessionPath;
401 directory.Append(dirtemp);
403 startTime.HomeTime();
406 if(1 == (i % 2)) FileNamesGeneration(buffer, 8, i, i%3+1) ;
407 else FileNamesGeneration(buffer, 20, i, i%3+1) ;
411 r = TheFs.Delete(path);
415 msg.Format(KMsg, &path);
422 timeTaken = endTime.MicroSecondsFrom(startTime);
423 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
427 gWriting = ETrue; User::After(1000000);
428 PrintResult(aStep, 1, aN);
429 PrintResultTime(aStep, 2, timeTaken1);
430 PrintResultTime(aStep, 3, timeTaken2);
431 PrintResultTime(aStep, 4, timeTaken3);
437 /** Deletes all files in a given directory using wildcards
439 @param aN Number of files in the directory
440 @param aStep Test step
442 LOCAL_C TInt DelAllFiles2(TInt aN, TInt aStep)
446 TBuf16<50> directory;
449 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
452 TTimeIntervalMicroSeconds timeTaken(0);
453 CFileMan* fMan=CFileMan::NewL(TheFs);
456 if(aN <= gFilesLimit)
461 dirtemp.Format(KDirMultipleName, 1, aN);
462 directory = gSessionPath;
463 directory.Append(dirtemp);
465 startTime.HomeTime();
466 directory.Append(_L("F*.*"));
468 r = fMan->Delete(directory);
472 timeTaken = endTime.MicroSecondsFrom(startTime);
473 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
478 dirtemp.Format(KDirMultipleName, 2, aN);
479 directory = gSessionPath;
480 directory.Append(dirtemp);
482 startTime.HomeTime();
483 directory.Append(_L("F*.*"));
484 r = fMan->Delete(directory);
489 timeTaken = endTime.MicroSecondsFrom(startTime);
490 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
496 dirtemp.Format(KDirMultipleName,3, aN);
497 directory = gSessionPath;
498 directory.Append(dirtemp);
500 startTime.HomeTime();
501 directory.Append(_L("F*.*"));
502 r = fMan->Delete(directory);
507 timeTaken = endTime.MicroSecondsFrom(startTime);
508 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
513 gWriting = ETrue; User::After(1000000);
514 PrintResult(aStep, 1, aN);
515 PrintResultTime(aStep, 2, timeTaken1);
516 PrintResultTime(aStep, 3, timeTaken2);
517 PrintResultTime(aStep, 4, timeTaken3);
523 /** Delete last.txt with two threads accessing the current directory and
524 creating/deleting a file with RFs::Delete
526 @param aN Number of files in the directory
527 @param aStep Test step
529 LOCAL_C void DelFileM1(TInt aN, TInt aStep)
539 TTimeIntervalMicroSeconds timeTaken(0);
540 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
546 dir4.Format(KDirMultipleName, 1, aN);
548 dir4.Format(KDirMultipleName, 2, aN);
550 dir4.Format(KDirMultipleName, 3, aN);
553 if(aN <= gFilesLimit)
558 gDelEntryDir2 = dir1;
559 dir1.Append(KCommonFile);
561 DoTest(DeleteEntryAccess);
563 startTime.HomeTime();
565 r = TheFs.Delete(dir1);
572 timeTaken=endTime.MicroSecondsFrom(startTime);
573 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
579 gDelEntryDir2 = dir2;
581 dir2.Append(KCommonFile);
583 DoTest(DeleteEntryAccess);
585 startTime.HomeTime();
587 r = TheFs.Delete(dir2);
591 timeTaken=endTime.MicroSecondsFrom(startTime);
594 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
600 gDelEntryDir2 = dir3;
602 dir3.Append(KCommonFile);
605 DoTest(DeleteEntryAccess);
607 startTime.HomeTime();
609 r = TheFs.Delete(dir3);
615 timeTaken = endTime.MicroSecondsFrom(startTime);
616 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
620 gWriting = ETrue; User::After(1000000);
621 PrintResult(aStep, 1, aN);
622 PrintResultTime(aStep, 2, timeTaken1);
623 PrintResultTime(aStep, 3, timeTaken2);
624 PrintResultTime(aStep, 4, timeTaken3);
628 /** Delete last.txt by opening it and with two threads accessing the current
629 directory and creating/deleting a file with CFileMan::Delete
631 @param aN Number of files in the directory
632 @param aStep Test step
634 LOCAL_C void DelFileM2(TInt aN, TInt aStep)
644 TTimeIntervalMicroSeconds timeTaken(0);
645 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
647 CFileMan* fMan = CFileMan::NewL(TheFs);
653 dir4.Format(KDirMultipleName, 1, aN);
655 dir4.Format(KDirMultipleName, 2, aN);
657 dir4.Format(KDirMultipleName, 3, aN);
660 if(aN <= gFilesLimit)
665 gDelEntryDir2 = dir1;
667 dir1.Append(KCommonFile);
669 DoTest(DeleteEntryAccess);
671 startTime.HomeTime();
673 r = fMan->Delete(dir1);
679 timeTaken = endTime.MicroSecondsFrom(startTime);
680 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
686 gDelEntryDir2 = dir2;
688 dir2.Append(KCommonFile);
690 DoTest(DeleteEntryAccess);
692 startTime.HomeTime();
694 r = fMan->Delete(dir2);
698 timeTaken = endTime.MicroSecondsFrom(startTime);
700 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
706 gDelEntryDir2 = dir3;
707 dir3.Append(KCommonFile);
710 DoTest(DeleteEntryAccess);
712 startTime.HomeTime();
714 r = fMan->Delete(dir3);
720 timeTaken = endTime.MicroSecondsFrom(startTime);
721 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
726 gWriting = ETrue; User::After(1000000);
727 PrintResult(aStep, 1, aN);
728 PrintResultTime(aStep, 2, timeTaken1);
729 PrintResultTime(aStep, 3, timeTaken2);
730 PrintResultTime(aStep, 4, timeTaken3);
735 /** Delete all files with two threads accessing the current directory and creating/deleting a file
738 @param aN Number of files in the directory
739 @param aStep Test step
741 LOCAL_C void DelAllM1(TInt aN, TInt aStep)
745 TBuf16<50> directory;
749 TBuf16<50> buffer(50);
753 TTimeIntervalMicroSeconds timeTaken(0);
754 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
756 if(aN <= gFilesLimit)
758 // Start the noise in the background
759 gDelEntryDir = directory;
760 gDelEntryDir2 = directory;
761 DoTest(DeleteEntryAccess);
766 dirtemp.Format(KDirMultipleName, 1, aN);
767 directory = gSessionPath;
768 directory.Append(dirtemp);
772 startTime.HomeTime();
775 FileNamesGeneration(buffer, 8, i, i%3+1) ;
778 r = TheFs.Delete(path);
784 timeTaken = endTime.MicroSecondsFrom(startTime);
785 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
791 dirtemp.Format(KDirMultipleName, 2, aN);
792 directory = gSessionPath;
793 directory.Append(dirtemp);
796 startTime.HomeTime();
799 FileNamesGeneration(buffer, 20, i, i%3+1) ;
802 r = TheFs.Delete(path);
808 timeTaken = endTime.MicroSecondsFrom(startTime);
809 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
815 dirtemp.Format(KDirMultipleName,3, aN);
816 directory = gSessionPath;
817 directory.Append(dirtemp);
820 startTime.HomeTime();
823 if(1 == (i % 2)) FileNamesGeneration(buffer, 8, i, i%3+1) ;
824 else FileNamesGeneration(buffer, 20, i, i%3+1) ;
828 r = TheFs.Delete(path);
834 timeTaken = endTime.MicroSecondsFrom(startTime);
835 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
837 // Stop the noise in the background
841 gWriting = ETrue; User::After(1000000);
842 PrintResult(aStep, 1, aN);
843 PrintResultTime(aStep, 2, timeTaken1);
844 PrintResultTime(aStep, 3, timeTaken2);
845 PrintResultTime(aStep, 4, timeTaken3);
849 /** Delete all files with two threads accessing the same directory and creating/deleting a file
850 with CFileMan::Delete
852 @param aN Number of files in the directory
853 @param aStep Test step
855 LOCAL_C void DelAllM2(TInt aN, TInt aStep)
858 TBuf16<50> directory;
863 TTimeIntervalMicroSeconds timeTaken(0);
864 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
866 CFileMan* fMan = CFileMan::NewL(TheFs);
868 if(aN <= gFilesLimit)
870 // Start the noise in the background
871 gDelEntryDir = directory;
872 gDelEntryDir2 = directory;
873 DoTest(DeleteEntryAccess);
878 dirtemp.Format(KDirMultipleName, 1, aN);
879 directory = gSessionPath;
880 directory.Append(dirtemp);
882 startTime.HomeTime();
883 directory.Append(_L("F*.*"));
884 r = fMan->Delete(directory);
888 timeTaken = endTime.MicroSecondsFrom(startTime);
889 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
895 dirtemp.Format(KDirMultipleName, 2, aN);
896 directory = gSessionPath;
897 directory.Append(dirtemp);
899 startTime.HomeTime();
900 directory.Append(_L("F*.*"));
901 r = fMan->Delete(directory);
905 timeTaken = endTime.MicroSecondsFrom(startTime);
906 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
912 dirtemp.Format(KDirMultipleName, 3, aN);
913 directory = gSessionPath;
914 directory.Append(dirtemp);
916 startTime.HomeTime();
917 directory.Append(_L("F*.*"));
918 r = fMan->Delete(directory);
922 timeTaken = endTime.MicroSecondsFrom(startTime);
923 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
926 // Stop the noise in the background
932 gWriting = ETrue; User::After(1000000);
933 PrintResult(aStep, 1, aN);
934 PrintResultTime(aStep, 2, timeTaken1);
935 PrintResultTime(aStep, 3, timeTaken2);
936 PrintResultTime(aStep, 4, timeTaken3);
941 /** Delete last.txt file with two threads accessing different directories and
942 creating/deleting a file in them
944 @param aN Number of files in the directory
945 @param aStep Test step
947 LOCAL_C void DelFileMD1(TInt aN, TInt aStep)
958 TTimeIntervalMicroSeconds timeTaken(0);
959 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
966 dir4.Format(KDirMultipleName, 1, aN);
968 dir4.Format(KDirMultipleName, 2, aN);
970 dir4.Format(KDirMultipleName, 3, aN);
975 dir4.Format(KDirMultipleName, 3 ,300);
978 if(aN <= gFilesLimit)
984 dir1.Append(KCommonFile);
986 DoTest(DeleteEntryAccess);
988 startTime.HomeTime();
990 r = TheFs.Delete(dir1);
996 timeTaken=endTime.MicroSecondsFrom(startTime);
997 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
1002 gDelEntryDir = dir2;
1004 dir2.Append(KCommonFile);
1006 DoTest(DeleteEntryAccess);
1008 startTime.HomeTime();
1010 r = TheFs.Delete(dir2);
1014 timeTaken = endTime.MicroSecondsFrom(startTime);
1016 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
1021 gDelEntryDir = dir3;
1023 dir3.Append(KCommonFile);
1025 DoTest(DeleteEntryAccess);
1027 startTime.HomeTime();
1029 r = TheFs.Delete(dir3);
1035 timeTaken=endTime.MicroSecondsFrom(startTime);
1036 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
1040 gWriting = ETrue; User::After(1000000);
1041 PrintResult(aStep, 1, aN);
1042 PrintResultTime(aStep, 2, timeTaken1);
1043 PrintResultTime(aStep, 3, timeTaken2);
1044 PrintResultTime(aStep, 4, timeTaken3);
1048 /** Delete last.txt file with two threads accessing different directories and
1049 creating/deleting a file in them
1051 @param aN Number of files in the directory
1052 @param aStep Test step
1054 LOCAL_C void DelFileMD2(TInt aN, TInt aStep)
1065 TTimeIntervalMicroSeconds timeTaken(0);
1066 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
1068 CFileMan* fMan=CFileMan::NewL(TheFs);
1070 dir1 = gSessionPath;
1071 dir2 = gSessionPath;
1072 dir3 = gSessionPath;
1074 dir4.Format(KDirMultipleName, 1, aN);
1076 dir4.Format(KDirMultipleName, 2, aN);
1078 dir4.Format(KDirMultipleName, 3, aN);
1083 dir4.Format(KDirMultipleName, 3, 300);
1086 if(aN <= gFilesLimit)
1090 gDelEntryDir = dir1;
1093 dir1.Append(KCommonFile);
1095 DoTest(DeleteEntryAccess);
1097 startTime.HomeTime();
1099 r = fMan->Delete(dir1);
1105 timeTaken=endTime.MicroSecondsFrom(startTime);
1106 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
1112 gDelEntryDir = dir4;
1114 dir2.Append(KCommonFile);
1116 DoTest(DeleteEntryAccess);
1118 startTime.HomeTime();
1120 r = fMan->Delete(dir2);
1124 timeTaken=endTime.MicroSecondsFrom(startTime);
1126 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
1131 gDelEntryDir = dir4;
1133 dir3.Append(KCommonFile);
1136 DoTest(DeleteEntryAccess);
1138 startTime.HomeTime();
1140 r = fMan->Delete(dir3);
1146 timeTaken=endTime.MicroSecondsFrom(startTime);
1147 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
1153 gWriting = ETrue; User::After(1000000);
1154 PrintResult(aStep, 1, aN);
1155 PrintResultTime(aStep, 2, timeTaken1);
1156 PrintResultTime(aStep, 3, timeTaken2);
1157 PrintResultTime(aStep, 4, timeTaken3);
1161 /** Delete all files with two threads accessing different directories and
1162 creating/deleting a file in them using RFs::Delete
1164 @param aN Number of files in the directory
1165 @param aStep Test step
1167 LOCAL_C void DelAllMD1(TInt aN, TInt aStep)
1171 TBuf16<50> directory;
1178 TBuf16<50> buffer(50);
1182 TTimeIntervalMicroSeconds timeTaken(0);
1183 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
1187 dir4.Format(KDirMultipleName, 3, 300);
1190 if(aN <= gFilesLimit)
1195 dirtemp.Format(KDirMultipleName,1, aN);
1196 directory = gSessionPath;
1197 directory.Append(dirtemp);
1199 gDelEntryDir = directory;
1200 gDelEntryDir2 = temp;
1204 DoTest(DeleteEntryAccess);
1206 startTime.HomeTime();
1209 FileNamesGeneration(buffer, 8, i, i%3+1) ;
1211 path.Append(buffer);
1212 r = TheFs.Delete(path);
1219 timeTaken=endTime.MicroSecondsFrom(startTime);
1220 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
1226 dirtemp.Format(KDirMultipleName,2, aN);
1227 directory = gSessionPath;
1228 directory.Append(dirtemp);
1229 gDelEntryDir = directory;
1230 DoTest(DeleteEntryAccess);
1233 startTime.HomeTime();
1236 FileNamesGeneration(buffer, 20, i, i%3+1) ;
1238 path.Append(buffer);
1239 r = TheFs.Delete(path);
1246 timeTaken=endTime.MicroSecondsFrom(startTime);
1247 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
1253 dirtemp.Format(KDirMultipleName,3, aN);
1254 directory = gSessionPath;
1255 directory.Append(dirtemp);
1257 gDelEntryDir = directory;
1258 DoTest(DeleteEntryAccess);
1260 startTime.HomeTime();
1263 if(1==(i%2)) FileNamesGeneration(buffer, 8, i, i%3+1) ;
1264 else FileNamesGeneration(buffer, 20, i, i%3+1) ;
1267 path.Append(buffer);
1268 r = TheFs.Delete(path);
1275 timeTaken=endTime.MicroSecondsFrom(startTime);
1276 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
1280 gWriting = ETrue; User::After(1000000);
1281 PrintResult(aStep, 1, aN);
1282 PrintResultTime(aStep, 2, timeTaken1);
1283 PrintResultTime(aStep, 3, timeTaken2);
1284 PrintResultTime(aStep, 4, timeTaken3);
1288 /** Delete all files with two threads accessing different directories and
1289 creating/deleting a file in them using CFileMan::Delete
1291 @param aN Number of files in the directory
1292 @param aStep Test step
1294 LOCAL_C void DelAllMD2(TInt aN, TInt aStep)
1297 TBuf16<50> directory;
1305 TTimeIntervalMicroSeconds timeTaken(0);
1306 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
1307 CFileMan* fMan=CFileMan::NewL(TheFs);
1310 // Creating directory for being accessed by other thread
1312 dir4.Format(KDirMultipleName, 3, 300);
1316 if(aN <= gFilesLimit)
1321 dirtemp.Format(KDirMultipleName,1, aN);
1322 directory = gSessionPath;
1323 directory.Append(dirtemp);
1325 gDelEntryDir = directory;
1327 DoTest(DeleteEntryAccess);
1329 startTime.HomeTime();
1330 directory.Append(_L("F*.*"));
1331 r = fMan->Delete(directory);
1335 timeTaken=endTime.MicroSecondsFrom(startTime);
1336 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
1343 dirtemp.Format(KDirMultipleName,2, aN);
1344 directory = gSessionPath;
1345 directory.Append(dirtemp);
1346 gDelEntryDir = directory;
1348 DoTest(DeleteEntryAccess);
1350 startTime.HomeTime();
1351 directory.Append(_L("F*.*"));
1352 r = fMan->Delete(directory);
1358 timeTaken=endTime.MicroSecondsFrom(startTime);
1359 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
1364 dirtemp.Format(KDirMultipleName,3, aN);
1365 directory = gSessionPath;
1366 directory.Append(dirtemp);
1367 gDelEntryDir = directory;
1369 DoTest(DeleteEntryAccess);
1371 startTime.HomeTime();
1372 directory.Append(_L("F*.*"));
1373 r = fMan->Delete(directory);
1379 timeTaken=endTime.MicroSecondsFrom(startTime);
1380 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
1386 gWriting = ETrue; User::After(1000000);
1387 PrintResult(aStep, 1, aN);
1388 PrintResultTime(aStep, 2, timeTaken1);
1389 PrintResultTime(aStep, 3, timeTaken2);
1390 PrintResultTime(aStep, 4, timeTaken3);
1395 /** Delete last.txt with RFs::Delete
1397 @param aN Number of files in the directory
1398 @param aStep Test step
1400 LOCAL_C void DelFile1(TInt aN, TInt aStep)
1410 TTimeIntervalMicroSeconds timeTaken(0);
1411 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
1413 dir1 = gSessionPath;
1414 dir2 = gSessionPath;
1415 dir3 = gSessionPath;
1417 dir4.Format(KDirMultipleName, 1, aN);
1419 dir4.Format(KDirMultipleName, 2, aN);
1421 dir4.Format(KDirMultipleName, 3, aN);
1424 dir1.Append(KCommonFile);
1425 dir2.Append(KCommonFile);
1426 dir3.Append(KCommonFile);
1428 if(aN <= gFilesLimit)
1432 startTime.HomeTime();
1434 r = TheFs.Delete(dir1);
1439 timeTaken = endTime.MicroSecondsFrom(startTime);
1440 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
1444 startTime.HomeTime();
1446 r = TheFs.Delete(dir2);
1450 timeTaken = endTime.MicroSecondsFrom(startTime);
1452 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
1456 startTime.HomeTime();
1458 r = TheFs.Delete(dir3);
1462 timeTaken = endTime.MicroSecondsFrom(startTime);
1463 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit );
1467 gWriting = ETrue; User::After(1000000);
1468 PrintResult(aStep, 1, aN);
1469 PrintResultTime(aStep, 2, timeTaken1);
1470 PrintResultTime(aStep, 3, timeTaken2);
1471 PrintResultTime(aStep, 4, timeTaken3);
1475 /** Delete last.txt with CFileMan::Delete
1477 @param aN Number of files in the directory
1478 @param aStep Test step
1480 LOCAL_C void DelFile2(TInt aN, TInt aStep)
1491 TTimeIntervalMicroSeconds timeTaken(0);
1492 TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
1494 if(aN <= gFilesLimit)
1496 CFileMan* fMan = CFileMan::NewL(TheFs);
1498 dir1 = gSessionPath;
1499 dir2 = gSessionPath;
1500 dir3 = gSessionPath;
1502 dir4.Format(KDirMultipleName, 1, aN);
1504 dir4.Format(KDirMultipleName, 2, aN);
1506 dir4.Format(KDirMultipleName, 3, aN);
1509 dir1.Append(KCommonFile);
1510 dir2.Append(KCommonFile);
1511 dir3.Append(KCommonFile);
1515 startTime.HomeTime();
1517 r = fMan->Delete(dir1);
1522 timeTaken = endTime.MicroSecondsFrom(startTime);
1523 timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit );
1528 startTime.HomeTime();
1530 r = fMan->Delete(dir2);
1534 timeTaken = endTime.MicroSecondsFrom(startTime);
1535 timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit );
1540 startTime.HomeTime();
1542 r = fMan->Delete(dir3);
1546 timeTaken = endTime.MicroSecondsFrom(startTime);
1547 timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
1553 gWriting = ETrue; User::After(1000000);
1554 PrintResult(aStep, 1, aN);
1555 PrintResultTime(aStep, 2, timeTaken1);
1556 PrintResultTime(aStep, 3, timeTaken2);
1557 PrintResultTime(aStep, 4, timeTaken3);
1561 /** Tests the deletion of one file with both API: RFs::Delete and CFileMan::Delete
1563 @param aSelector Configuration in case of manual execution
1565 LOCAL_C TInt TestDelEntry(TAny* aSelector)
1567 // Precondition: the drive already filled with the right files
1572 Validate(aSelector);
1574 test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt, RFs::Delete\n"), gTestHarness, gTestCase);
1578 while(i <= KMaxFiles)
1580 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1581 DelFile1(i, testStep++);
1587 test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt, CFileMan::Delete\n"), gTestHarness, gTestCase);
1591 while(i <= KMaxFiles)
1593 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1594 DelFile2(i, testStep++);
1603 /** Tests the deletion of all the files in a directory with both API:
1604 RFs::Delete and CFileMan::Delete
1606 @param aSelector Configuration in case of manual execution
1608 LOCAL_C TInt TestDelAllFiles(TAny* aSelector)
1610 // Precondition: drive already filled with the right files
1615 Validate(aSelector);
1617 test.Printf(_L("#~TS_Title_%d,%d: Delete all, RFs::Delete\n"), gTestHarness, gTestCase);
1620 while(i <= KMaxFiles)
1622 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1623 DelAllFiles1(i, testStep++);
1627 TestFileCreate(aSelector);
1629 test.Printf(_L("#~TS_Title_%d,%d: Delete all, CFileMan::Delete\n"), gTestHarness, gTestCase);
1634 while(i <= KMaxFiles)
1636 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1637 DelAllFiles2(i, testStep++);
1645 /** Tests the deletion of last.txt in a directory with both API:
1646 RFs::Delete and CFileMan::Delete while 2 other threads accessing the directory
1648 @param aSelector Configuration in case of manual execution
1650 LOCAL_C TInt TestDelMultSame(TAny* aSelector)
1656 Validate(aSelector);
1658 TestFileCreate(aSelector);
1660 test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt mult. clients del in same dir, RFs::Delete\n"), gTestHarness, gTestCase);
1663 while(i <= KMaxFiles)
1665 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1666 DelFileM1(i, testStep++);
1672 test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt mult. clients del in same dir, CFileMan::Delete\n"), gTestHarness, gTestCase);
1676 while(i <= KMaxFiles)
1678 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1680 DelFileM2(i, testStep);
1688 test.Printf(_L("#~TS_Title_%d,%d: Delete all mult. clients del in same dir, RFs::Delete\n"), gTestHarness, gTestCase);
1692 while(i <= KMaxFiles)
1694 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1695 DelAllM1(i, testStep++);
1699 TestFileCreate(aSelector);
1701 test.Printf(_L("#~TS_Title_%d,%d: Delete all mult. clients del in same dir, CFileMan::Delete\n"), gTestHarness, gTestCase);
1705 while(i <= KMaxFiles)
1707 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1708 DelAllM2(i, testStep++);
1718 /** Tests the deletion of last.txt in a directory with both API:
1719 RFs::Delete and CFileMan::Delete while 2 threads accessing different directories
1720 (the current and one with 300 files)
1722 @param aSelector Configuration in case of manual execution
1724 LOCAL_C TInt TestDelMultDif(TAny* aSelector)
1729 Validate(aSelector);
1731 TestFileCreate(aSelector);
1732 CreateDirWithNFiles(300, 3);
1734 test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt mult. clients del in dif dirs, RFs::Delete\n"), gTestHarness, gTestCase);
1737 while(i <= KMaxFiles)
1739 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1740 DelFileMD1(i, testStep++);
1746 test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt mult. clients del in dif dirs, CFileMan::Delete\n"), gTestHarness, gTestCase);
1750 while(i <= KMaxFiles)
1752 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1753 DelFileMD2(i, testStep++);
1759 test.Printf(_L("#~TS_Title_%d,%d: Delete all mult. clients del in dif dirs, RFs::Delete\n"), gTestHarness, gTestCase);
1763 while(i <= KMaxFiles)
1765 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1766 DelAllMD1(i, testStep++);
1770 TestFileCreate(aSelector);
1772 test.Printf(_L("#~TS_Title_%d,%d: Delete all mult. clients del in dif dirs, CFileMan::Delete\n"), gTestHarness, gTestCase);
1777 while(i <= KMaxFiles)
1779 if(i == 100 || i == 1000 || i == 5000 || i == 10000)
1780 DelAllMD2(i, testStep++);
1789 /** Goes automatically through all the options
1791 @param aSelector Configuration in case of manual execution
1793 LOCAL_C TInt TestAll(TAny* aSelector)
1795 Validate(aSelector);
1797 gFormat=ETrue; // The card will be formatted after this test execution
1799 TestDelEntry(aSelector);
1800 TestDelAllFiles(aSelector);
1801 TestDelMultSame(aSelector);
1802 TestDelMultDif(aSelector);
1810 GLDEF_C void CallTestsL()
1813 TInt r = client.CreateLocal(0);
1816 // Each test case of the suite has an identifyer for parsing purposes of the results
1820 PrintHeaders(1, _L("t_fsrdel. Deletion"));
1823 TBuf<20> buf = _L("Noisy");
1824 r = noisy.Create(buf, noise, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
1829 CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console());
1833 gSessionPath=_L("?:\\");
1834 TCallBack createFiles(TestFileCreate,TheSelector);
1835 TCallBack delFile(TestDelEntry,TheSelector);
1836 TCallBack delAllFiles(TestDelAllFiles,TheSelector);
1837 TCallBack delMultSame(TestDelMultSame,TheSelector);
1838 TCallBack delMultDif(TestDelMultDif,TheSelector);
1839 TCallBack delAll(TestAll,TheSelector);
1840 TheSelector->AddDriveSelectorL(TheFs);
1841 TheSelector->AddLineL(_L("Create all files"),createFiles);
1842 TheSelector->AddLineL(_L("Delete one file from each dir"),delFile);
1843 TheSelector->AddLineL(_L("Delete all files"),delAllFiles);
1844 TheSelector->AddLineL(_L("Delete mult clients same dir"),delMultSame);
1845 TheSelector->AddLineL(_L("Delete mult clients dif dir"),delMultDif);
1846 TheSelector->AddLineL(_L("Execute all options"),delAll);
1851 TestAll(TheSelector);
1857 noisy.Kill(KErrNone);
1860 test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);