sl@0: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of the License "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // f32test\bench\t_fsrdel.cpp sl@0: // sl@0: // sl@0: sl@0: sl@0: #include sl@0: #include sl@0: #include "t_benchmain.h" sl@0: sl@0: GLDEF_D RTest test(_L("File Server Benchmarks, deletion of a massive amount of files")); sl@0: sl@0: //---------------------------------------------------------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRDEL-0272 sl@0: //! @SYMTestType CIT sl@0: //! @SYMPREQ PREQ000 sl@0: //! @SYMTestCaseDesc This test case is measuring performance of the FAT implementation. sl@0: //! @SYMTestActions 0. Expects the files to exist in order to successful execution sl@0: //! 1. Time the deletion of a file from each directory with RFs::Delete sl@0: //! 2. Time the deletion of a file from each directory with CFileMan::Delete sl@0: //! 3. Time the deletion of all the files from each directory sl@0: //! with RFs::Delete sl@0: //! 4. Time the deletion of all the files from each directory with sl@0: //! CFileMan::Delete (wildcard F*.*) sl@0: //! 5. Time the deletion of a file from each directory with RFs::Delete sl@0: //! with two clients accessing the directory sl@0: //! 6. Time the deletion of a file from each directory with CFileMan::Delete sl@0: //! with two clients accessing the directory sl@0: //! 7. Time the deletion of all the files from each directory with RFs::Delete sl@0: //! with two clients accessing the directory sl@0: //! 8. Time the deletion of all the files from each directory with sl@0: //! CFileMan::Delete with two clients accessing the directory (wildcard F*.*) sl@0: //! 9. Time the deletion of a file from each directory with RFs::Delete sl@0: //! with two clients accessing different directories sl@0: //! 10. Time the deletion of a file from each directory with CFileMan::Delete sl@0: //! with two clients accessing different directories sl@0: //! 11. Time the deletion of all the files from each directory with RFs::Delete sl@0: //! with two clients accessing different directories sl@0: //! 12. Time the deletion of all the files from each directory with sl@0: //! CFileMan::Delete with two clients accessing different directories (wildcard F*.*) sl@0: //! @SYMTestExpectedResults Finishes if the system behaves as expected, panics otherwise sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //---------------------------------------------------------------------------------------------- sl@0: sl@0: LOCAL_D RSemaphore client,write_screen; sl@0: LOCAL_D const TInt KHeapSize=0x4000; sl@0: LOCAL_D TBuf8<4096> buf; sl@0: LOCAL_D TDriveList gDriveList; sl@0: sl@0: // Concurrent thread varibles sl@0: RThread gSpeedy; sl@0: RThread gSpeedyII; sl@0: TInt gT1; sl@0: TInt gT2; sl@0: LOCAL_D TFileName gDelEntryDir; sl@0: LOCAL_D TFileName gDelEntryDir2; sl@0: LOCAL_D TInt ThreadCount=0; sl@0: TBool gWriting = EFalse; sl@0: sl@0: TBool gKillMe=EFalse; sl@0: sl@0: _LIT(KDeleteMe,"delete%d.me"); sl@0: _LIT(KDeleteMe2,"blabla%d.rhd"); sl@0: sl@0: sl@0: /** Send content through the RDebug for trgtest sl@0: not to hung, when the test is not writing sl@0: sl@0: */ sl@0: LOCAL_C TInt noise(TAny* ) sl@0: { sl@0: FOREVER sl@0: { sl@0: User::After(2147483647); // max value, 35 minutes, 47 seconds sl@0: if(!gWriting) sl@0: RDebug::Print(_L(".")); sl@0: } sl@0: } sl@0: sl@0: /** Create background noise by deleting/creating file in gDelEntryDir2 directory sl@0: sl@0: */ sl@0: LOCAL_C TInt DeleteEntryAccess2(TAny* ) sl@0: { sl@0: RFs fs; sl@0: TInt r = 0; sl@0: TBuf<100> dirfile; sl@0: TBuf<50> filename; sl@0: RFile file; sl@0: RTest test(_L("test 2")); sl@0: sl@0: // Not checking error state until main thread has been signalled, to avoid deadlock sl@0: fs.Connect(); sl@0: r = fs.SetSessionPath(gSessionPath); sl@0: sl@0: filename.Format(KDeleteMe2,gT2); sl@0: sl@0: dirfile = gDelEntryDir2; sl@0: dirfile.Append(filename); sl@0: sl@0: client.Signal(); sl@0: FailIfError(r); sl@0: sl@0: FOREVER sl@0: { sl@0: if(!gKillMe) sl@0: { sl@0: r = file.Create(fs, dirfile, EFileShareAny|EFileWrite); sl@0: if(r == KErrAlreadyExists) sl@0: r = file.Open(fs, dirfile, EFileShareAny|EFileWrite); sl@0: file.Close(); sl@0: FailIfError(r); sl@0: sl@0: r = fs.Delete(dirfile); sl@0: if((r != KErrNone) && (r != KErrInUse)) sl@0: FailIfError(r); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** Create background noise by deleting/creating file in gDelEntryDir directory sl@0: sl@0: */ sl@0: LOCAL_C TInt DeleteEntryAccess(TAny*) sl@0: { sl@0: RFs fs2; sl@0: TInt r = 0; sl@0: TBuf<100> dirfile; sl@0: TBuf<50> filename; sl@0: RFile file2; sl@0: RTest test(_L("test 2")); sl@0: sl@0: // Not checking error state until main thread has been signalled, to avoid deadlock sl@0: fs2.Connect(); sl@0: r = fs2.SetSessionPath(gSessionPath); sl@0: sl@0: filename.Format(KDeleteMe,gT1); sl@0: sl@0: dirfile = gDelEntryDir; sl@0: dirfile.Append(filename); sl@0: sl@0: client.Signal(); sl@0: FailIfError(r); sl@0: sl@0: FOREVER sl@0: { sl@0: if(!gKillMe) sl@0: { sl@0: r = file2.Create(fs2, dirfile, EFileShareAny|EFileWrite); sl@0: if(r == KErrAlreadyExists) sl@0: r = file2.Open(fs2, dirfile, EFileShareAny|EFileWrite); sl@0: file2.Close(); sl@0: FailIfError(r); sl@0: r = fs2.Delete(dirfile); sl@0: if((r != KErrNone) && (r != KErrInUse)) sl@0: FailIfError(r); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** Starts a concurrent client session in different directories sl@0: sl@0: */ sl@0: LOCAL_C void DoTest(TThreadFunction aFunction) sl@0: { sl@0: gKillMe = EFalse; sl@0: sl@0: TBuf<20> buffer = _L("Speedy"); sl@0: buffer.AppendNum(ThreadCount++); sl@0: gT1 = ThreadCount; sl@0: TInt r = gSpeedy.Create(buffer, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL); sl@0: FailIfError(r); sl@0: sl@0: buffer = _L("Speedy"); sl@0: buffer.AppendNum(ThreadCount++); sl@0: gT2=ThreadCount; sl@0: r = gSpeedyII.Create(buffer, DeleteEntryAccess2, KDefaultStackSize, KHeapSize, KHeapSize, NULL); sl@0: FailIfError(r); sl@0: sl@0: gSpeedy.SetPriority(EPriorityLess); sl@0: gSpeedyII.SetPriority(EPriorityLess); sl@0: sl@0: gSpeedy.Resume(); sl@0: gSpeedyII.Resume(); sl@0: sl@0: client.Wait(); sl@0: client.Wait(); sl@0: } sl@0: sl@0: /** Kills the concurrent sessions sl@0: sl@0: */ sl@0: LOCAL_C void DoTestKill() sl@0: { sl@0: gKillMe = ETrue; sl@0: User::After(10000000); sl@0: sl@0: gSpeedy.Kill(KErrNone); sl@0: gSpeedy.Close(); sl@0: sl@0: gSpeedyII.Kill(KErrNone); sl@0: gSpeedyII.Close(); sl@0: } sl@0: sl@0: /** Creates again the last.txt file in each directory that is being used sl@0: sl@0: */ sl@0: LOCAL_C void ReCreateLast() sl@0: { sl@0: TInt i = 1, r = 0; sl@0: RFile file; sl@0: TBuf16<50> dirtemp; sl@0: sl@0: TBuf16<50> path; sl@0: TBuf8<1024> dummy(1024); sl@0: sl@0: sl@0: while(i <= gTypes) sl@0: { sl@0: path = gSessionPath; sl@0: dirtemp.Format(KDirMultipleName, i, 100); sl@0: path.Append(dirtemp); sl@0: path.Append(KCommonFile); sl@0: r = file.Create(TheFs, path, EFileShareAny|EFileWrite); sl@0: if(r == KErrAlreadyExists) sl@0: { sl@0: r = file.Open(TheFs, path, EFileShareAny|EFileWrite); sl@0: FailIfError(r); sl@0: } sl@0: r = file.Write(dummy); sl@0: FailIfError(r); sl@0: file.Close(); sl@0: i++; sl@0: } sl@0: sl@0: if(gFilesLimit >= 1000) sl@0: { sl@0: i = 1; sl@0: while(i <= gTypes) sl@0: { sl@0: path = gSessionPath; sl@0: dirtemp.Format(KDirMultipleName, i, 1000); sl@0: path.Append(dirtemp); sl@0: path.Append(KCommonFile); sl@0: r = file.Create(TheFs, path, EFileShareAny|EFileWrite); sl@0: if(r == KErrAlreadyExists) sl@0: { sl@0: r = file.Open(TheFs, path, EFileShareAny|EFileWrite); sl@0: FailIfError(r); sl@0: } sl@0: r = file.Write(dummy); sl@0: FailIfError(r); sl@0: file.Close(); sl@0: i++; sl@0: } sl@0: } sl@0: sl@0: if(gFilesLimit >= 5000) sl@0: { sl@0: i = 1; sl@0: while(i <= gTypes) sl@0: { sl@0: path = gSessionPath; sl@0: dirtemp.Format(KDirMultipleName, i, 5000); sl@0: path.Append(dirtemp); sl@0: path.Append(KCommonFile); sl@0: r = file.Create(TheFs, path, EFileShareAny|EFileWrite); sl@0: if(r == KErrAlreadyExists) sl@0: { sl@0: r = file.Open(TheFs, path, EFileShareAny|EFileWrite); sl@0: FailIfError(r); sl@0: } sl@0: r = file.Write(dummy); sl@0: FailIfError(r); sl@0: file.Close(); sl@0: i++; sl@0: } sl@0: } sl@0: if(gFilesLimit >= 10000) sl@0: { sl@0: i = 1; sl@0: while(i <= gTypes) sl@0: { sl@0: path = gSessionPath; sl@0: dirtemp.Format(KDirMultipleName, i, 10000); sl@0: path.Append(dirtemp); sl@0: path.Append(KCommonFile); sl@0: r = file.Create(TheFs, path, EFileShareAny|EFileWrite); sl@0: if(r ==KErrAlreadyExists) sl@0: { sl@0: r = file.Open(TheFs, path, EFileShareAny|EFileWrite); sl@0: FailIfError(r); sl@0: } sl@0: r = file.Write(dummy); sl@0: FailIfError(r); sl@0: file.Close(); sl@0: i++; sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** Deletes all files in a given directory one by one sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C TInt DelAllFiles1(TInt aN, TInt aStep) sl@0: { sl@0: TInt i = 0, r = 0; sl@0: TBuf16<50> directory; sl@0: TBuf16<50> dirtemp; sl@0: sl@0: TBuf16<50> path; sl@0: TBuf16<50> buffer(50); sl@0: sl@0: _LIT(KMsg, "This file caused a problem: %S\n"); sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: // all 8.3 sl@0: directory = gSessionPath; sl@0: dirtemp.Format(KDirMultipleName, 1, aN); sl@0: directory.Append(dirtemp); sl@0: sl@0: i = 0; sl@0: startTime.HomeTime(); sl@0: while(i < aN) sl@0: { sl@0: FileNamesGeneration(buffer, 8, i, i%3+1) ; sl@0: path = directory; sl@0: path.Append(buffer); sl@0: r = TheFs.Delete(path); sl@0: if(r != KErrNone) sl@0: { sl@0: TBuf16<250> msg; sl@0: msg.Format(KMsg, &path); sl@0: test.Printf(msg); sl@0: FailIfError(r); sl@0: } sl@0: i++; sl@0: } sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: // all 20.3 chars sl@0: dirtemp.Format(KDirMultipleName, 2, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: i = 0; sl@0: startTime.HomeTime(); sl@0: while(i < aN) sl@0: { sl@0: FileNamesGeneration(buffer, 20, i, i%3+1) ; sl@0: path = directory; sl@0: path.Append(buffer); sl@0: r = TheFs.Delete(path); sl@0: if(r != KErrNone) sl@0: { sl@0: TBuf16<250> msg; sl@0: msg.Format(KMsg, &path); sl@0: test.Printf(msg); sl@0: FailIfError(r); sl@0: } sl@0: i++; sl@0: } sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 3) sl@0: { sl@0: // 50/50 sl@0: dirtemp.Format(KDirMultipleName, 3, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: i = 0; sl@0: startTime.HomeTime(); sl@0: while(i < aN) sl@0: { sl@0: if(1 == (i % 2)) FileNamesGeneration(buffer, 8, i, i%3+1) ; sl@0: else FileNamesGeneration(buffer, 20, i, i%3+1) ; sl@0: sl@0: path = directory; sl@0: path.Append(buffer); sl@0: r = TheFs.Delete(path); sl@0: if(r != KErrNone) sl@0: { sl@0: TBuf16<250> msg; sl@0: msg.Format(KMsg, &path); sl@0: test.Printf(msg); sl@0: FailIfError(r); sl@0: } sl@0: i++; sl@0: } sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit); sl@0: } sl@0: } sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: /** Deletes all files in a given directory using wildcards sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C TInt DelAllFiles2(TInt aN, TInt aStep) sl@0: { sl@0: TInt r = 0; sl@0: sl@0: TBuf16<50> directory; sl@0: TBuf16<50> dirtemp; sl@0: sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: // all 8.3 sl@0: dirtemp.Format(KDirMultipleName, 1, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: if(gTypes >= 2) sl@0: { sl@0: // all 20.3 chars sl@0: dirtemp.Format(KDirMultipleName, 2, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 3) sl@0: { sl@0: // 50/50 sl@0: dirtemp.Format(KDirMultipleName,3, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: } sl@0: delete fMan; sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: /** Delete last.txt with two threads accessing the current directory and sl@0: creating/deleting a file with RFs::Delete sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelFileM1(TInt aN, TInt aStep) sl@0: { sl@0: TBuf16<100> dir1; sl@0: TBuf16<100> dir2; sl@0: TBuf16<100> dir3; sl@0: TBuf16<100> dir4; sl@0: sl@0: TInt r = 0; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: dir1 = gSessionPath; sl@0: dir2 = gSessionPath; sl@0: dir3 = gSessionPath; sl@0: sl@0: dir4.Format(KDirMultipleName, 1, aN); sl@0: dir1.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 2, aN); sl@0: dir2.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 3, aN); sl@0: dir3.Append(dir4); sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: gDelEntryDir = dir1; sl@0: gDelEntryDir2 = dir1; sl@0: dir1.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir1); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: sl@0: DoTestKill(); sl@0: sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: gDelEntryDir = dir2; sl@0: gDelEntryDir2 = dir2; sl@0: sl@0: dir2.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir2); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: sl@0: DoTestKill(); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 3) sl@0: { sl@0: gDelEntryDir = dir3; sl@0: gDelEntryDir2 = dir3; sl@0: sl@0: dir3.Append(KCommonFile); sl@0: sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir3); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: } sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: } sl@0: sl@0: /** Delete last.txt by opening it and with two threads accessing the current sl@0: directory and creating/deleting a file with CFileMan::Delete sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelFileM2(TInt aN, TInt aStep) sl@0: { sl@0: TBuf16<100> dir1; sl@0: TBuf16<100> dir2; sl@0: TBuf16<100> dir3; sl@0: TBuf16<100> dir4; sl@0: sl@0: TInt r = 0; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: CFileMan* fMan = CFileMan::NewL(TheFs); sl@0: sl@0: dir1 = gSessionPath; sl@0: dir2 = gSessionPath; sl@0: dir3 = gSessionPath; sl@0: sl@0: dir4.Format(KDirMultipleName, 1, aN); sl@0: dir1.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 2, aN); sl@0: dir2.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 3, aN); sl@0: dir3.Append(dir4); sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: gDelEntryDir = dir1; sl@0: gDelEntryDir2 = dir1; sl@0: sl@0: dir1.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir1); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: gDelEntryDir = dir2; sl@0: gDelEntryDir2 = dir2; sl@0: sl@0: dir2.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir2); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: DoTestKill(); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 3) sl@0: { sl@0: gDelEntryDir = dir3; sl@0: gDelEntryDir2 = dir3; sl@0: dir3.Append(KCommonFile); sl@0: sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir3); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: } sl@0: delete fMan; sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: sl@0: } sl@0: sl@0: /** Delete all files with two threads accessing the current directory and creating/deleting a file sl@0: with RFs::Delete sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelAllM1(TInt aN, TInt aStep) sl@0: { sl@0: TInt i = 0, r = 0; sl@0: sl@0: TBuf16<50> directory; sl@0: TBuf16<50> dirtemp; sl@0: sl@0: TBuf16<50> path; sl@0: TBuf16<50> buffer(50); sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: // Start the noise in the background sl@0: gDelEntryDir = directory; sl@0: gDelEntryDir2 = directory; sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: if(gTypes >= 1) sl@0: { sl@0: // all 8.3 sl@0: dirtemp.Format(KDirMultipleName, 1, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: i = 0; sl@0: sl@0: startTime.HomeTime(); sl@0: while(i < aN) sl@0: { sl@0: FileNamesGeneration(buffer, 8, i, i%3+1) ; sl@0: path = directory; sl@0: path.Append(buffer); sl@0: r = TheFs.Delete(path); sl@0: FailIfError(r); sl@0: i++; sl@0: } sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: // all 20.3 chars sl@0: dirtemp.Format(KDirMultipleName, 2, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: i = 0; sl@0: startTime.HomeTime(); sl@0: while(i < aN) sl@0: { sl@0: FileNamesGeneration(buffer, 20, i, i%3+1) ; sl@0: path = directory; sl@0: path.Append(buffer); sl@0: r = TheFs.Delete(path); sl@0: FailIfError(r); sl@0: i++; sl@0: } sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 3) sl@0: { sl@0: // 50/50 sl@0: dirtemp.Format(KDirMultipleName,3, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: i = 0; sl@0: startTime.HomeTime(); sl@0: while(i < aN) sl@0: { sl@0: if(1 == (i % 2)) FileNamesGeneration(buffer, 8, i, i%3+1) ; sl@0: else FileNamesGeneration(buffer, 20, i, i%3+1) ; sl@0: sl@0: path = directory; sl@0: path.Append(buffer); sl@0: r = TheFs.Delete(path); sl@0: FailIfError(r); sl@0: i++; sl@0: } sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: // Stop the noise in the background sl@0: DoTestKill(); sl@0: } sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: } sl@0: sl@0: /** Delete all files with two threads accessing the same directory and creating/deleting a file sl@0: with CFileMan::Delete sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelAllM2(TInt aN, TInt aStep) sl@0: { sl@0: TInt r = 0; sl@0: TBuf16<50> directory; sl@0: TBuf16<50> dirtemp; sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: CFileMan* fMan = CFileMan::NewL(TheFs); sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: // Start the noise in the background sl@0: gDelEntryDir = directory; sl@0: gDelEntryDir2 = directory; sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: if(gTypes >= 1) sl@0: { sl@0: // all 8.3 sl@0: dirtemp.Format(KDirMultipleName, 1, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: // all 20.3 chars sl@0: dirtemp.Format(KDirMultipleName, 2, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: sl@0: } sl@0: if(gTypes >= 3) sl@0: { sl@0: // 50/50 sl@0: dirtemp.Format(KDirMultipleName, 3, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: // Stop the noise in the background sl@0: DoTestKill(); sl@0: } sl@0: sl@0: delete fMan; sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: } sl@0: sl@0: sl@0: /** Delete last.txt file with two threads accessing different directories and sl@0: creating/deleting a file in them sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelFileMD1(TInt aN, TInt aStep) sl@0: { sl@0: TBuf16<100> dir1; sl@0: TBuf16<100> dir2; sl@0: TBuf16<100> dir3; sl@0: TBuf16<100> dir4; sl@0: TBuf16<100> temp; sl@0: sl@0: TInt r = 0; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: sl@0: dir1 = gSessionPath; sl@0: dir2 = gSessionPath; sl@0: dir3 = gSessionPath; sl@0: sl@0: dir4.Format(KDirMultipleName, 1, aN); sl@0: dir1.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 2, aN); sl@0: dir2.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 3, aN); sl@0: dir3.Append(dir4); sl@0: sl@0: sl@0: temp = gSessionPath; sl@0: dir4.Format(KDirMultipleName, 3 ,300); sl@0: temp.Append(dir4); sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: gDelEntryDir = dir1; sl@0: gDelEntryDir2=temp; sl@0: dir1.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir1); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: gDelEntryDir = dir2; sl@0: sl@0: dir2.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir2); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: DoTestKill(); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 3) sl@0: { sl@0: gDelEntryDir = dir3; sl@0: sl@0: dir3.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir3); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: } sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: } sl@0: sl@0: /** Delete last.txt file with two threads accessing different directories and sl@0: creating/deleting a file in them sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelFileMD2(TInt aN, TInt aStep) sl@0: { sl@0: TBuf16<100> dir1; sl@0: TBuf16<100> dir2; sl@0: TBuf16<100> dir3; sl@0: TBuf16<100> dir4; sl@0: TBuf16<100> temp; sl@0: sl@0: TInt r = 0; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: sl@0: dir1 = gSessionPath; sl@0: dir2 = gSessionPath; sl@0: dir3 = gSessionPath; sl@0: sl@0: dir4.Format(KDirMultipleName, 1, aN); sl@0: dir1.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 2, aN); sl@0: dir2.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 3, aN); sl@0: dir3.Append(dir4); sl@0: sl@0: sl@0: temp=gSessionPath; sl@0: dir4.Format(KDirMultipleName, 3, 300); sl@0: temp.Append(dir4); sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: gDelEntryDir = dir1; sl@0: gDelEntryDir2=temp; sl@0: sl@0: dir1.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir1); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: dir4=dir2; sl@0: gDelEntryDir = dir4; sl@0: sl@0: dir2.Append(KCommonFile); sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir2); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: DoTestKill(); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: if(gTypes >= 3) sl@0: { sl@0: dir4=dir3; sl@0: gDelEntryDir = dir4; sl@0: sl@0: dir3.Append(KCommonFile); sl@0: sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir3); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: } sl@0: sl@0: delete fMan; sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: } sl@0: sl@0: /** Delete all files with two threads accessing different directories and sl@0: creating/deleting a file in them using RFs::Delete sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelAllMD1(TInt aN, TInt aStep) sl@0: { sl@0: TInt i = 0,r = 0; sl@0: sl@0: TBuf16<50> directory; sl@0: TBuf16<50> dirtemp; sl@0: TBuf16<50> temp; sl@0: TBuf16<50> dir4; sl@0: sl@0: sl@0: TBuf16<50> path; sl@0: TBuf16<50> buffer(50); sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: sl@0: temp=gSessionPath; sl@0: dir4.Format(KDirMultipleName, 3, 300); sl@0: temp.Append(dir4); sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: // all 8.3 sl@0: dirtemp.Format(KDirMultipleName,1, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: gDelEntryDir = directory; sl@0: gDelEntryDir2 = temp; sl@0: sl@0: i = 0; sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: while(i < aN) sl@0: { sl@0: FileNamesGeneration(buffer, 8, i, i%3+1) ; sl@0: path = directory; sl@0: path.Append(buffer); sl@0: r = TheFs.Delete(path); sl@0: FailIfError(r); sl@0: i++; sl@0: } sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: // all 20.3 chars sl@0: dirtemp.Format(KDirMultipleName,2, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: gDelEntryDir = directory; sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: i = 0; sl@0: startTime.HomeTime(); sl@0: while(i= 3) sl@0: { sl@0: // 50/50 sl@0: dirtemp.Format(KDirMultipleName,3, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: gDelEntryDir = directory; sl@0: DoTest(DeleteEntryAccess); sl@0: i = 0; sl@0: startTime.HomeTime(); sl@0: while(i directory; sl@0: TBuf16<50> dirtemp; sl@0: TBuf16<50> dir4; sl@0: TBuf16<50> temp; sl@0: sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: CFileMan* fMan=CFileMan::NewL(TheFs); sl@0: sl@0: sl@0: // Creating directory for being accessed by other thread sl@0: temp=gSessionPath; sl@0: dir4.Format(KDirMultipleName, 3, 300); sl@0: temp.Append(dir4); sl@0: gDelEntryDir2=temp; sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: // all 8.3 sl@0: dirtemp.Format(KDirMultipleName,1, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: gDelEntryDir = directory; sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: DoTestKill(); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: // all 20.3 chars sl@0: dirtemp.Format(KDirMultipleName,2, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: gDelEntryDir = directory; sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: if(gTypes >= 3) sl@0: { sl@0: // 50/50 sl@0: dirtemp.Format(KDirMultipleName,3, aN); sl@0: directory = gSessionPath; sl@0: directory.Append(dirtemp); sl@0: gDelEntryDir = directory; sl@0: sl@0: DoTest(DeleteEntryAccess); sl@0: sl@0: startTime.HomeTime(); sl@0: directory.Append(_L("F*.*")); sl@0: r = fMan->Delete(directory); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: DoTestKill(); sl@0: sl@0: timeTaken=endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: } sl@0: sl@0: delete fMan; sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: } sl@0: sl@0: sl@0: /** Delete last.txt with RFs::Delete sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelFile1(TInt aN, TInt aStep) sl@0: { sl@0: TBuf16<100> dir1; sl@0: TBuf16<100> dir2; sl@0: TBuf16<100> dir3; sl@0: TBuf16<100> dir4; sl@0: sl@0: TInt r = 0; sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: dir1 = gSessionPath; sl@0: dir2 = gSessionPath; sl@0: dir3 = gSessionPath; sl@0: sl@0: dir4.Format(KDirMultipleName, 1, aN); sl@0: dir1.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 2, aN); sl@0: dir2.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 3, aN); sl@0: dir3.Append(dir4); sl@0: sl@0: dir1.Append(KCommonFile); sl@0: dir2.Append(KCommonFile); sl@0: dir3.Append(KCommonFile); sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: if(gTypes >= 1) sl@0: { sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir1); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: if(gTypes >= 2) sl@0: { sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir2); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: if(gTypes >= 3) sl@0: { sl@0: startTime.HomeTime(); sl@0: sl@0: r = TheFs.Delete(dir3); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: } sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: } sl@0: sl@0: /** Delete last.txt with CFileMan::Delete sl@0: sl@0: @param aN Number of files in the directory sl@0: @param aStep Test step sl@0: */ sl@0: LOCAL_C void DelFile2(TInt aN, TInt aStep) sl@0: { sl@0: TBuf16<100> dir1; sl@0: TBuf16<100> dir2; sl@0: TBuf16<100> dir3; sl@0: TBuf16<100> dir4; sl@0: sl@0: TInt r = 0; sl@0: sl@0: TTime startTime; sl@0: TTime endTime; sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; sl@0: sl@0: if(aN <= gFilesLimit) sl@0: { sl@0: CFileMan* fMan = CFileMan::NewL(TheFs); sl@0: sl@0: dir1 = gSessionPath; sl@0: dir2 = gSessionPath; sl@0: dir3 = gSessionPath; sl@0: sl@0: dir4.Format(KDirMultipleName, 1, aN); sl@0: dir1.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 2, aN); sl@0: dir2.Append(dir4); sl@0: dir4.Format(KDirMultipleName, 3, aN); sl@0: dir3.Append(dir4); sl@0: sl@0: dir1.Append(KCommonFile); sl@0: dir2.Append(KCommonFile); sl@0: dir3.Append(KCommonFile); sl@0: sl@0: if(gTypes >= 1) sl@0: { sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir1); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 2) sl@0: { sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir2); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit ); sl@0: } sl@0: sl@0: if(gTypes >= 3) sl@0: { sl@0: startTime.HomeTime(); sl@0: sl@0: r = fMan->Delete(dir3); sl@0: FailIfError(r); sl@0: sl@0: endTime.HomeTime(); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit); sl@0: } sl@0: sl@0: delete fMan; sl@0: } sl@0: sl@0: gWriting = ETrue; User::After(1000000); sl@0: PrintResult(aStep, 1, aN); sl@0: PrintResultTime(aStep, 2, timeTaken1); sl@0: PrintResultTime(aStep, 3, timeTaken2); sl@0: PrintResultTime(aStep, 4, timeTaken3); sl@0: gWriting = EFalse; sl@0: } sl@0: sl@0: /** Tests the deletion of one file with both API: RFs::Delete and CFileMan::Delete sl@0: sl@0: @param aSelector Configuration in case of manual execution sl@0: */ sl@0: LOCAL_C TInt TestDelEntry(TAny* aSelector) sl@0: { sl@0: // Precondition: the drive already filled with the right files sl@0: sl@0: TInt i = 100; sl@0: TInt testStep = 1; sl@0: sl@0: Validate(aSelector); sl@0: sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt, RFs::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelFile1(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: ReCreateLast(); sl@0: gTestCase++; sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt, CFileMan::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelFile2(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: gTestCase++; sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: /** Tests the deletion of all the files in a directory with both API: sl@0: RFs::Delete and CFileMan::Delete sl@0: sl@0: @param aSelector Configuration in case of manual execution sl@0: */ sl@0: LOCAL_C TInt TestDelAllFiles(TAny* aSelector) sl@0: { sl@0: // Precondition: drive already filled with the right files sl@0: sl@0: TInt i = 100; sl@0: TInt testStep = 1; sl@0: sl@0: Validate(aSelector); sl@0: sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete all, RFs::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelAllFiles1(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: TestFileCreate(aSelector); sl@0: gTestCase++; sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete all, CFileMan::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelAllFiles2(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: gTestCase++; sl@0: return(KErrNone); sl@0: } sl@0: sl@0: /** Tests the deletion of last.txt in a directory with both API: sl@0: RFs::Delete and CFileMan::Delete while 2 other threads accessing the directory sl@0: sl@0: @param aSelector Configuration in case of manual execution sl@0: */ sl@0: LOCAL_C TInt TestDelMultSame(TAny* aSelector) sl@0: { sl@0: TInt i = 100; sl@0: TInt testStep = 1; sl@0: sl@0: sl@0: Validate(aSelector); sl@0: sl@0: TestFileCreate(aSelector); sl@0: sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt mult. clients del in same dir, RFs::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelFileM1(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: ReCreateLast(); sl@0: gTestCase++; sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt mult. clients del in same dir, CFileMan::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: { sl@0: DelFileM2(i, testStep); sl@0: testStep++; sl@0: } sl@0: i += 100; sl@0: } sl@0: sl@0: ReCreateLast(); sl@0: gTestCase++; sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete all mult. clients del in same dir, RFs::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelAllM1(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: TestFileCreate(aSelector); sl@0: gTestCase++; sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete all mult. clients del in same dir, CFileMan::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelAllM2(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: gTestCase++; sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: sl@0: /** Tests the deletion of last.txt in a directory with both API: sl@0: RFs::Delete and CFileMan::Delete while 2 threads accessing different directories sl@0: (the current and one with 300 files) sl@0: sl@0: @param aSelector Configuration in case of manual execution sl@0: */ sl@0: LOCAL_C TInt TestDelMultDif(TAny* aSelector) sl@0: { sl@0: TInt i = 100; sl@0: TInt testStep = 1; sl@0: sl@0: Validate(aSelector); sl@0: sl@0: TestFileCreate(aSelector); sl@0: CreateDirWithNFiles(300, 3); sl@0: sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt mult. clients del in dif dirs, RFs::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelFileMD1(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: ReCreateLast(); sl@0: gTestCase++; sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete last.txt mult. clients del in dif dirs, CFileMan::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelFileMD2(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: ReCreateLast(); sl@0: gTestCase++; sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete all mult. clients del in dif dirs, RFs::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelAllMD1(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: TestFileCreate(aSelector); sl@0: gTestCase++; sl@0: test.Printf(_L("#~TS_Title_%d,%d: Delete all mult. clients del in dif dirs, CFileMan::Delete\n"), gTestHarness, gTestCase); sl@0: sl@0: sl@0: i = 100; sl@0: testStep = 1; sl@0: while(i <= KMaxFiles) sl@0: { sl@0: if(i == 100 || i == 1000 || i == 5000 || i == 10000) sl@0: DelAllMD2(i, testStep++); sl@0: i += 100; sl@0: } sl@0: sl@0: gTestCase++; sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: /** Goes automatically through all the options sl@0: sl@0: @param aSelector Configuration in case of manual execution sl@0: */ sl@0: LOCAL_C TInt TestAll(TAny* aSelector) sl@0: { sl@0: Validate(aSelector); sl@0: sl@0: gFormat=ETrue; // The card will be formatted after this test execution sl@0: sl@0: TestDelEntry(aSelector); sl@0: TestDelAllFiles(aSelector); sl@0: TestDelMultSame(aSelector); sl@0: TestDelMultDif(aSelector); sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** Call all tests sl@0: sl@0: */ sl@0: GLDEF_C void CallTestsL() sl@0: { sl@0: sl@0: TInt r = client.CreateLocal(0); sl@0: FailIfError(r); sl@0: sl@0: // Each test case of the suite has an identifyer for parsing purposes of the results sl@0: gTestHarness = 1; sl@0: gTestCase = 1; sl@0: sl@0: PrintHeaders(1, _L("t_fsrdel. Deletion")); sl@0: sl@0: RThread noisy; sl@0: TBuf<20> buf = _L("Noisy"); sl@0: r = noisy.Create(buf, noise, KDefaultStackSize, KHeapSize, KHeapSize, NULL); sl@0: FailIfError(r); sl@0: sl@0: noisy.Resume(); sl@0: sl@0: CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console()); sl@0: sl@0: if(gMode == 0) sl@0: { // Manual sl@0: gSessionPath=_L("?:\\"); sl@0: TCallBack createFiles(TestFileCreate,TheSelector); sl@0: TCallBack delFile(TestDelEntry,TheSelector); sl@0: TCallBack delAllFiles(TestDelAllFiles,TheSelector); sl@0: TCallBack delMultSame(TestDelMultSame,TheSelector); sl@0: TCallBack delMultDif(TestDelMultDif,TheSelector); sl@0: TCallBack delAll(TestAll,TheSelector); sl@0: TheSelector->AddDriveSelectorL(TheFs); sl@0: TheSelector->AddLineL(_L("Create all files"),createFiles); sl@0: TheSelector->AddLineL(_L("Delete one file from each dir"),delFile); sl@0: TheSelector->AddLineL(_L("Delete all files"),delAllFiles); sl@0: TheSelector->AddLineL(_L("Delete mult clients same dir"),delMultSame); sl@0: TheSelector->AddLineL(_L("Delete mult clients dif dir"),delMultDif); sl@0: TheSelector->AddLineL(_L("Execute all options"),delAll); sl@0: TheSelector->Run(); sl@0: } sl@0: else sl@0: { // Automatic sl@0: TestAll(TheSelector); sl@0: } sl@0: sl@0: client.Close(); sl@0: delete TheSelector; sl@0: sl@0: noisy.Kill(KErrNone); sl@0: noisy.Close(); sl@0: sl@0: test.Printf(_L("#~TestEnd_%d\n"), gTestHarness); sl@0: }