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_benchmain.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include "t_benchmain.h" sl@0: #include "t_chlffs.h" sl@0: sl@0: RFs TheFs; sl@0: TFileName gSessionPath; sl@0: TFileName gExeFileName(RProcess().FileName()); sl@0: TInt gAllocFailOff=KAllocFailureOff; sl@0: TInt gAllocFailOn=KAllocFailureOff; sl@0: TInt64 gSeed = 51703; sl@0: TInt gFilesLimit; sl@0: TInt gTypes; sl@0: TInt gMode; sl@0: TInt gFormat = EFalse; sl@0: TInt gMinutes; sl@0: TInt gFileSize = 0; // In Kbytes sl@0: sl@0: TInt gTestHarness = 0; sl@0: TInt gTestCase = 1; sl@0: TInt gTimeUnit = 1000; // values: 1 - us, 1000 - ms, 1000000 - s sl@0: sl@0: sl@0: TChar gDriveToTest = ' '; sl@0: sl@0: sl@0: //////////////////////////////////////////////////////////// sl@0: // Template functions encapsulating ControlIo magic sl@0: // sl@0: template sl@0: sl@0: TInt controlIo(RFs &fs, TInt drv, TInt fkn, C &c) sl@0: { sl@0: TPtr8 ptrC((TUint8 *)&c, sizeof(C), sizeof(C)); sl@0: sl@0: TInt r = fs.ControlIo(drv, fkn, ptrC); sl@0: sl@0: return r; sl@0: } sl@0: sl@0: /** Prints headers of FAT32 and File Cache benchmarking sl@0: sl@0: @param aType type of test (FAT32 = 1/2 or File Cache = 3/4/5) sl@0: @param sl@0: */ sl@0: void PrintHeaders(TInt aType, TPtrC16 aTitle ) sl@0: { sl@0: TBuf16<250> title = _L("#~TestTitle_%d: "); sl@0: sl@0: title.Append(aTitle); sl@0: title.Append(_L("\n")); sl@0: sl@0: test.Printf(_L("#~TestId=%d\n"), gTestHarness); sl@0: test.Printf(title, gTestHarness); sl@0: test.Printf(_L("#~Report Variant: \n")); sl@0: test.Printf(_L("#~Report Description: \n")); sl@0: sl@0: _LIT(KSeconds,"seconds"); sl@0: _LIT(KMilliSecs,"milliseconds"); sl@0: _LIT(KMicroSecs,"microseconds"); sl@0: sl@0: TPtrC16 timeUnit; sl@0: if (gTimeUnit == 1) sl@0: timeUnit.Set(KMicroSecs); sl@0: else if (gTimeUnit == 1000) sl@0: timeUnit.Set(KMilliSecs); sl@0: else if (gTimeUnit == 1000000) sl@0: timeUnit.Set(KSeconds); sl@0: else sl@0: { sl@0: test.Printf(_L("Please, check gTimeUnit value\n")); sl@0: test(EFalse); sl@0: } sl@0: sl@0: sl@0: if(aType == 1) sl@0: { // All FAT32 tests but t_fsrrepeat sl@0: test.Printf(_L("#~TestParam_%d: MaxFiles=%d, type=%d, mode=%d, timeUnit=%S\n"), gTestHarness, gFilesLimit, gTypes, gMode, &timeUnit); sl@0: sl@0: test.Printf(_L("#~TestRows_%d: 4\n"), gTestHarness); sl@0: test.Printf(_L("#~TestColumns_%d: 4, NFiles, 8_3, 20_chars, 50_50\n"), gTestHarness); sl@0: } sl@0: else if(aType == 2) sl@0: { // t_fsrrepeat sl@0: test.Printf(_L("#~TestParam_%d: MaxFiles=%d, type=%d, mode=%d, timeUnit=%S\n"), gTestHarness, gFilesLimit, gTypes, gMode, &timeUnit); sl@0: sl@0: test.Printf(_L("#~TestRows_%d: 12\n"), gTestHarness); sl@0: test.Printf(_L("#~TestColumns_%d: 4, DirName, 1st, 2nd, 3rd\n"), gTestHarness); sl@0: } sl@0: else if(aType == 3) sl@0: { // Large sequential reads/writes sl@0: test.Printf(_L("#~TestParam_%d: mode=%d, timeUnit=%S\n"), gTestHarness, gMode, &timeUnit); sl@0: sl@0: test.Printf(_L("#~TestRows_%d: 8\n"), gTestHarness); sl@0: test.Printf(_L("#~TestColumns_%d: 4, bsize, 100KB, 1MB, 10MB\n"), gTestHarness); sl@0: } sl@0: else if(aType == 4) sl@0: { // Small random reads/writes sl@0: test.Printf(_L("#~TestParam_%d: mode=%d, timeUnit=%S\n"), gTestHarness, gMode, &timeUnit); sl@0: sl@0: test.Printf(_L("#~TestRows_%d: 11\n"), gTestHarness); sl@0: test.Printf(_L("#~TestColumns_%d: 8, bsize, 1KB, 2KB, 4KB, 8KB, 16KB, 32KB, 64KB\n"), gTestHarness); sl@0: } sl@0: else if(aType == 5) sl@0: { // Streaming sl@0: test.Printf(_L("#~TestParam_%d: mode=%d, timeUnit=%S\n"), gTestHarness, gMode, &timeUnit); sl@0: sl@0: test.Printf(_L("#~TestRows_%d: 6\n"), gTestHarness); sl@0: test.Printf(_L("#~TestColumns_%d: 4, bsize, 5m_w, 15s_w_r, 15s_w_r \n"), gTestHarness); sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("Check the function PrintHeaders() in t_benchmain.cpp, which wasn't called with the right parameters\n")); sl@0: test(EFalse); sl@0: } sl@0: sl@0: } sl@0: sl@0: /** Prints a line of results sl@0: sl@0: @param aPosX Row of the table sl@0: @param aPosY Column of the table sl@0: @param aValue Value figure for that position sl@0: */ sl@0: void PrintResultTime( TInt aPosX, TInt aPosY, TInt aValue) sl@0: { sl@0: test.Printf(_L("#~TS_Res_%d,%d,[%d,%d]=%d\n "), gTestHarness, gTestCase, aPosX, aPosY, aValue ); sl@0: } sl@0: sl@0: sl@0: /** Prints any other type of data sl@0: sl@0: @param aPosX Row of the table sl@0: @param aPosY Column of the table sl@0: @param aValue Value figure for that position sl@0: */ sl@0: void PrintResult( TInt aPosX, TInt aPosY, TInt aValue) sl@0: { sl@0: test.Printf(_L("#~TS_Res_%d,%d,[%d,%d]=%d\n "), gTestHarness, gTestCase, aPosX, aPosY, aValue); sl@0: } sl@0: sl@0: /** Prints string sl@0: sl@0: @param aPosX Row of the table sl@0: @param aPosY Column of the table sl@0: @param aValue Value figure for that position sl@0: */ sl@0: void PrintResultS( TInt aPosX, TInt aPosY, TDes16& aValue) sl@0: { sl@0: TBuf16<250> buffer = _L("#~TS_Res_%d,%d,[%d,%d]="); sl@0: sl@0: buffer.Append(aValue); sl@0: buffer.Append(_L("\n")); sl@0: test.Printf(buffer, gTestHarness, gTestCase, aPosX, aPosY); sl@0: } sl@0: sl@0: /** Call all RFormat methods sl@0: sl@0: @param aDrive Drive to be formatted sl@0: */ sl@0: void FormatFat(TDriveUnit aDrive) sl@0: { sl@0: RFormat format; sl@0: TPckgBuf count; sl@0: TInt r = format.Open(TheFs, aDrive.Name(), EQuickFormat, count()); sl@0: FailIfError(r); sl@0: sl@0: test(count() == 100); sl@0: TRequestStatus status; sl@0: while (count()) sl@0: { sl@0: format.Next(count, status); sl@0: User::WaitForRequest(status); sl@0: test(status == KErrNone || status == KErrNotSupported); sl@0: } sl@0: sl@0: format.Close(); sl@0: test.Printf(_L("Drive formatted\n")); sl@0: } sl@0: sl@0: /** Validates the drive selection sl@0: sl@0: @param aDrive Drive to be validated sl@0: @param aTest Type of test sl@0: */ sl@0: TInt ValidateDriveSelection(TDriveUnit aDrive,TSelectedTest aTest) sl@0: { sl@0: if ((aDrive == EDriveZ) || ((aDrive == EDriveC) && (aTest == ELocalDriveTest))) sl@0: { sl@0: test.Printf(_L("Test not available for this drive\n")); sl@0: test.Printf(_L("Press any key to continue...\n")); sl@0: return (KErrNotSupported); sl@0: } sl@0: else sl@0: return (KErrNone); sl@0: } sl@0: sl@0: /** Validates the selection for this tests and update appropriate variables sl@0: sl@0: @param aSelector This object is meant to give information about what needs sl@0: to be tests in manual mode sl@0: */ sl@0: TInt Validate(TAny* aSelector) sl@0: { sl@0: if(gMode == 0) sl@0: { sl@0: if (((CSelectionBox*)aSelector)->CurrentKeyPress() != EKeyEnter) sl@0: return(KErrNone); sl@0: sl@0: TInt r = ValidateDriveSelection(((CSelectionBox*)aSelector)->CurrentDrive(),EFileSeekTest); sl@0: if (r == KErrNotSupported) sl@0: return (r); sl@0: sl@0: TDriveUnit drive = ((CSelectionBox*)aSelector)->CurrentDrive(); sl@0: gSessionPath[0] = TUint8('A' + drive); sl@0: r = TheFs.SetSessionPath(gSessionPath); sl@0: FailIfError(r); sl@0: } sl@0: sl@0: return KErrNone; sl@0: } sl@0: sl@0: /** Prints current volume information sl@0: sl@0: */ sl@0: void PrintVolInfo() sl@0: { sl@0: TVolumeInfo volInfo; sl@0: TInt r; sl@0: sl@0: r = TheFs.Volume(volInfo); sl@0: FailIfError(r); sl@0: sl@0: test.Printf(_L("DriveAtt:0x%X, MediaAtt:0x%X, Free:%d KBytes\n"), volInfo.iDrive.iDriveAtt, volInfo.iDrive.iMediaAtt, (TUint32)(volInfo.iFree / 1024)); sl@0: } sl@0: sl@0: /** Create directory with a number of files, with specified file name type sl@0: sl@0: @param aN number of files to create sl@0: @param aType file names type : 1 - 8.3, 2 - 20 characters, 3 - 50/50 sl@0: */ sl@0: TInt CreateDirWithNFiles(TInt aN, TInt aType) sl@0: { sl@0: TInt i,r=0; sl@0: sl@0: RFile file; 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: dirtemp.Format(KDirMultipleName,aType, aN); sl@0: directory=gSessionPath; sl@0: directory.Append(dirtemp); sl@0: sl@0: r = TheFs.MkDir(directory); sl@0: test(r == KErrNone || r == KErrAlreadyExists); sl@0: sl@0: const TUint KNumFilesPrintTreshold = 100; sl@0: const TInt KFileSize = gFileSize * 1024; sl@0: sl@0: PrintVolInfo(); sl@0: sl@0: i = 0; sl@0: while( i < aN ) sl@0: { sl@0: // generate file name depending on type required sl@0: switch(aType) sl@0: { sl@0: case 1: // 8.3 filemnames sl@0: FileNamesGeneration(buffer, 8, i, i%3+1); sl@0: break; sl@0: sl@0: case 2: // 20 characrer filenames sl@0: FileNamesGeneration(buffer, 20, i, i%3+1); sl@0: break; sl@0: sl@0: case 3: // 50/50 mix sl@0: if(i%2) sl@0: FileNamesGeneration(buffer, 8, i, i%3+1) ; sl@0: else sl@0: FileNamesGeneration(buffer, 20, i, i%3+1) ; sl@0: break; sl@0: default: sl@0: test(0); sl@0: break; sl@0: }; sl@0: path = directory; sl@0: path.Append(buffer); sl@0: sl@0: // create or replace a file sl@0: r = file.Replace(TheFs, path, EFileShareAny|EFileWrite); sl@0: if(r != KErrNone) sl@0: { sl@0: PrintVolInfo(); sl@0: test.Printf(_L("Error creating file: %S, %d\n"), &path, r); sl@0: test(0); sl@0: } sl@0: sl@0: // set file size if required, file contents doesn't matter sl@0: if(gFileSize > 0) sl@0: { sl@0: r = file.SetSize(KFileSize); sl@0: if(r != KErrNone) sl@0: { sl@0: PrintVolInfo(); sl@0: test.Printf(_L("Error setting file size: %S, %d, err:%d\n"), &path, KFileSize, r); sl@0: test(0); sl@0: } sl@0: } sl@0: sl@0: file.Close(); sl@0: sl@0: if(i > 0 && ((i+1)%KNumFilesPrintTreshold) == 0) sl@0: { sl@0: test.Printf(_L("created %d files, type:%d\n"), i + 1, aType); sl@0: } sl@0: sl@0: i++; sl@0: }//while sl@0: sl@0: sl@0: // write "last.txt" file to the end of directory sl@0: path = directory; sl@0: path.Append(KCommonFile); sl@0: r = file.Replace(TheFs,path,EFileShareAny|EFileWrite); sl@0: if(r != KErrNone) sl@0: { sl@0: PrintVolInfo(); sl@0: test.Printf(_L("Error creating file: %S, %d\n"), &path, r); sl@0: test(0); sl@0: } sl@0: sl@0: // put random content to the "last.txt" file if specified length of files > 0 sl@0: if(gFileSize > 0) sl@0: { sl@0: r = file.SetSize(gFileSize * 1024); // gFileSize is in KBytes sl@0: if(r != KErrNone) sl@0: { sl@0: PrintVolInfo(); sl@0: test.Printf(_L("Error setting file size: %S, %d\n"), &path, r); sl@0: test(0); sl@0: } sl@0: } sl@0: sl@0: file.Close(); sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: sl@0: /** sl@0: Creates 12 directories with different sort of files and namefiles sl@0: 100 files with 8.3, 20 chars and 50/50 sl@0: 1000 files with 8.3, 20 chars and 50/50 sl@0: 5000 files with 8.3, 20 chars and 50/50 sl@0: 10000 files with 8.3, 20 chars and 50/50 sl@0: */ sl@0: TInt TestFileCreate(TAny* aSelector) sl@0: { sl@0: TInt i = 100, j = 1; sl@0: sl@0: Validate(aSelector); sl@0: sl@0: while(i <= gFilesLimit) sl@0: { sl@0: if(i == 100) sl@0: { sl@0: j = 1; sl@0: while(j <= gTypes) sl@0: CreateDirWithNFiles(100, j++); sl@0: } sl@0: if(i == 1000) sl@0: { sl@0: j=1; sl@0: while(j <= gTypes) sl@0: CreateDirWithNFiles(1000, j++); sl@0: } sl@0: if(i == 5000) sl@0: { sl@0: j = 1; sl@0: while(j <= gTypes) sl@0: CreateDirWithNFiles(5000, j++); sl@0: } sl@0: if(i == 10000) sl@0: { sl@0: j = 1; sl@0: while(j <= gTypes) sl@0: CreateDirWithNFiles(10000, j++); sl@0: } sl@0: i += 100; sl@0: } sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: /** Generate a filename according to the parameters configuration sl@0: sl@0: @param aBuffer Buffer where the name of the file will be returned sl@0: @param aLong Length of the name of the file sl@0: @param aPos Number to be attached to the name of the file sl@0: @param ext Type of extension (1/2/3) sl@0: */ sl@0: void FileNamesGeneration(TDes16& aBuffer, TInt aLong, TInt aPos,TInt ext) sl@0: { sl@0: TInt padding; sl@0: TInt i=0; sl@0: TBuf16<10> tempbuf; sl@0: sl@0: _LIT(KNumber,"%d"); sl@0: tempbuf.Format(KNumber, aPos); sl@0: padding = aLong - tempbuf.Size() / 2; sl@0: aBuffer = _L(""); sl@0: while(i < padding) sl@0: { sl@0: aBuffer.Append('F'); sl@0: i++; sl@0: } sl@0: sl@0: _LIT(KExtension1, ".TXT"); sl@0: _LIT(KExtension2, ".HTM"); sl@0: _LIT(KExtension3, ".LOG"); sl@0: sl@0: aBuffer.Append(tempbuf); sl@0: switch(ext) sl@0: { sl@0: case 1: aBuffer.Append(KExtension1);break; sl@0: case 2: aBuffer.Append(KExtension2);break; sl@0: case 3: aBuffer.Append(KExtension3);break; sl@0: default: aBuffer.Append(KExtension1);break; sl@0: } sl@0: } sl@0: sl@0: /** Do a checkdisk and report failure sl@0: sl@0: */ sl@0: void CheckDisk() sl@0: { sl@0: test.Next(_L("Check Disk")); sl@0: TInt r = TheFs.CheckDisk(gSessionPath); sl@0: if (r != KErrNone && r != KErrNotSupported && r != KErrPermissionDenied) sl@0: ReportCheckDiskFailure(r); sl@0: } sl@0: sl@0: /** Report a disk failure sl@0: sl@0: @param aRet The error will be returned in this variable sl@0: */ sl@0: void ReportCheckDiskFailure(TInt aRet) sl@0: { sl@0: test.Printf(_L("CHECKDISK FAILED: ")); sl@0: switch(aRet) sl@0: { sl@0: case 1: test.Printf(_L("File cluster chain contains a bad value (<2 or >maxCluster)\n")); break; sl@0: case 2: test.Printf(_L("Two files are linked to the same cluster\n")); break; sl@0: case 3: test.Printf(_L("Unallocated cluster contains a value != 0\n")); break; sl@0: case 4: test.Printf(_L("Size of file != number of clusters in chain\n")); break; sl@0: default: test.Printf(_L("Undefined Error value %d\n"),aRet); sl@0: } sl@0: } sl@0: sl@0: sl@0: /** Expand the cleanup stack sl@0: sl@0: */ sl@0: void PushLotsL() sl@0: { sl@0: TInt i; sl@0: sl@0: for(i=0;i<1000;i++) sl@0: CleanupStack::PushL((CBase*)NULL); sl@0: sl@0: CleanupStack::Pop(1000); sl@0: } sl@0: sl@0: /** Do testing on aDrive sl@0: sl@0: @param aDrive Drive for the testing sl@0: */ sl@0: void DoTests(TInt aDrive) sl@0: { sl@0: sl@0: gSessionPath=_L("?:\\"); sl@0: TChar driveLetter; sl@0: TInt r = TheFs.DriveToChar(aDrive, driveLetter); sl@0: FailIfError(r); sl@0: gSessionPath[0] = (TText)driveLetter; sl@0: r = TheFs.SetSessionPath(gSessionPath); sl@0: FailIfError(r); sl@0: sl@0: test.Printf(_L("DoTests() Session Path: %S\n"),&gSessionPath); sl@0: sl@0: CheckMountLFFS(TheFs,driveLetter); sl@0: sl@0: User::After(1000000); sl@0: sl@0: r = TheFs.MkDirAll(gSessionPath); sl@0: if (r != KErrNone && r != KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("MkDirAll() r %d\n"),r); sl@0: test(EFalse); sl@0: } sl@0: TheFs.ResourceCountMarkStart(); sl@0: TRAP(r,CallTestsL()); sl@0: if (r == KErrNone) sl@0: TheFs.ResourceCountMarkEnd(); sl@0: else sl@0: { sl@0: test.Printf(_L("Error: Leave %d\n"),r); sl@0: test(EFalse); sl@0: } sl@0: sl@0: CheckDisk(); sl@0: } sl@0: sl@0: /** Syntax of the test sl@0: sl@0: @param aOption option 1 is related to FAT32 testing/option 2 relates to the file caching sl@0: */ sl@0: void syntax (TInt aOption) sl@0: { sl@0: _LIT(KBad, "Wrong argument"); sl@0: sl@0: if(aOption == 1) sl@0: { sl@0: test.Printf(_L("Usage: \n testname <100/1000/5000/10000 number of files> <1/2/3 type of files> \n ")); sl@0: } sl@0: else if (aOption == 2) sl@0: { sl@0: test.Printf(_L("Usage: \n t_fcachebm \n ")); sl@0: } sl@0: sl@0: User::Panic(KBad,KErrArgument); sl@0: } sl@0: sl@0: /** sl@0: Parse commands : sl@0: sl@0: 1) t_name drive maxfiles filetypes manual/automatic sl@0: maxfiles can be: 100, 1000, 5000 or 10000 sl@0: filetypes can be 1 for 8.3, 2 for 20 chars as well and 3 for all sl@0: manual 0 and automatic 1 sl@0: 2) t_fcachebm drive manua/automatic sl@0: 3) t_fsrcreatefiles sl@0: */ sl@0: void ParseCommandArguments() sl@0: { sl@0: TBuf<0x100> cmd; sl@0: User::CommandLine(cmd); sl@0: sl@0: test.Printf(_L("Command line:\n")); sl@0: test.Printf(cmd); sl@0: test.Printf(_L("\n")); sl@0: sl@0: TLex lex(cmd); sl@0: lex.SkipSpace(); sl@0: sl@0: TPtrC token; sl@0: TFileName thisfile=RProcess().FileName(); sl@0: sl@0: TInt i = 0; sl@0: TInt testcase = 0; sl@0: TBool finish = EFalse; sl@0: _LIT(KCacheBM, "Z:\\sys\\bin\\t_fcachebm.exe"); sl@0: _LIT(KCreate, "Z:\\sys\\bin\\t_fsrcreatefiles.exe"); sl@0: sl@0: test.Printf(KCacheBM); sl@0: test.Printf(thisfile); sl@0: while((!finish) && (i <= 5)) sl@0: { sl@0: switch(i) sl@0: { sl@0: case 0: sl@0: if((thisfile != KCacheBM) && (thisfile != KCreate)) // FAT32 tests sl@0: testcase = 1; sl@0: else if(thisfile == KCreate) // FAT32 test files creation sl@0: testcase = 3; sl@0: else // File Cache (PREQ914) performance tests sl@0: testcase = 2; sl@0: break; sl@0: case 1: sl@0: test.Printf(_L("\nCLP=%S\n"), &token); sl@0: if(token.Length() != 0) sl@0: { sl@0: gDriveToTest = token[0]; sl@0: gDriveToTest.UpperCase(); sl@0: if(gMode==1) sl@0: gSessionPath[0] = (TText)gDriveToTest; sl@0: } sl@0: else sl@0: { sl@0: gDriveToTest = 'C'; sl@0: } sl@0: break; sl@0: case 2: sl@0: if((testcase == 1) || (testcase == 3)) // testcase == 1 || testcase == 3 sl@0: { sl@0: if(token.Length() != 0) sl@0: { sl@0: test.Printf(_L("Number of files=%S\n"),&token); sl@0: if(token[0]=='5') sl@0: { sl@0: gFilesLimit = 5000; sl@0: } sl@0: else sl@0: if(token[0] == '1' && token.Length() == 3) gFilesLimit = 100; sl@0: else if(token[0] == '1' && token.Length() == 4) gFilesLimit = 1000; sl@0: else if(token[0] == '1' && token.Length() == 5) gFilesLimit = 10000; sl@0: else syntax(testcase); sl@0: } sl@0: else sl@0: gFilesLimit = 10000 ; sl@0: sl@0: } sl@0: else // (testcase == 2) sl@0: { sl@0: if(token.Length() == 1) sl@0: { sl@0: TChar c = token[0]; sl@0: test.Printf(_L("0 manual/1 automatic ? %S\n"),&token); sl@0: if(c.IsDigit() && ((c == '0') || (c == '1'))) sl@0: gMode = c.GetNumericValue(); sl@0: else syntax(testcase); sl@0: } sl@0: else sl@0: syntax(testcase); sl@0: } sl@0: break; sl@0: case 3: sl@0: if((testcase == 1) || (testcase == 3)) sl@0: { sl@0: if(token.Length() == 1) sl@0: { sl@0: TChar c = token[0]; sl@0: test.Printf(_L("File type=%S\n"), &token); sl@0: if(c.IsDigit() &&((c == '1') || (c == '2') || (c == '3'))) sl@0: gTypes = c.GetNumericValue(); sl@0: else syntax(testcase); sl@0: } sl@0: else // Default value sl@0: gTypes = 3; sl@0: } sl@0: break; sl@0: case 4: sl@0: if((testcase == 1) || (testcase == 3)) sl@0: { sl@0: TChar c = token[0]; sl@0: if(token.Length() == 1) sl@0: { sl@0: test.Printf(_L("0 manual/1 automatic ? %S\n"),&token); sl@0: if(c.IsDigit() && ((c == '0') || (c == '1'))) sl@0: gMode = c.GetNumericValue(); sl@0: else syntax(1); sl@0: } sl@0: else sl@0: gMode = 0; sl@0: } sl@0: break; sl@0: case 5: sl@0: if(testcase == 3) sl@0: { sl@0: TChar c = token[0]; sl@0: if(c.IsDigit()) sl@0: gFileSize = c.GetNumericValue(); sl@0: else syntax(1); sl@0: } sl@0: break; sl@0: sl@0: default: sl@0: syntax(testcase); sl@0: } sl@0: finish = lex.Eos(); sl@0: token.Set(lex.NextToken()); sl@0: i++; sl@0: } sl@0: } sl@0: sl@0: /** Main function sl@0: sl@0: @return KErrNone if everything was ok, panics otherwise sl@0: */ sl@0: TInt E32Main() sl@0: { sl@0: CTrapCleanup* cleanup; sl@0: cleanup = CTrapCleanup::New(); sl@0: TRAPD(r,PushLotsL()); sl@0: __UHEAP_MARK; sl@0: sl@0: test.Title(); sl@0: test.Start(_L("Starting benchmarking tests...")); sl@0: sl@0: ParseCommandArguments(); //need this for drive letter to test and all the parameters sl@0: sl@0: r = TheFs.Connect(); sl@0: FailIfError(r); sl@0: TheFs.SetAllocFailure(gAllocFailOn); sl@0: TTime timerC; sl@0: timerC.HomeTime(); sl@0: TFileName sessionp; sl@0: TheFs.SessionPath(sessionp); sl@0: sl@0: TInt theDrive; sl@0: sl@0: r = TheFs.CharToDrive(gDriveToTest,theDrive); sl@0: FailIfError(r); sl@0: sl@0: PrintDrvInfo(TheFs, theDrive); sl@0: sl@0: #if defined(_DEBUG) || defined(_DEBUG_RELEASE) sl@0: TPckgBuf pkgOrgValues; sl@0: TIOCacheValues& orgValues=pkgOrgValues(); sl@0: r = controlIo(TheFs,theDrive, KControlIoCacheCount, orgValues); sl@0: FailIfError(r); sl@0: sl@0: test.Printf(_L("\nNumber of items on close list at beginning=%d\n"), orgValues.iCloseCount); sl@0: test.Printf(_L("Number of items on free list at beginning=%d\n"), orgValues.iFreeCount); sl@0: test.Printf(_L("Number of items allocated at beginning=%d\n"), orgValues.iAllocated); sl@0: #endif sl@0: sl@0: DoTests(theDrive); sl@0: sl@0: TTime endTimeC; sl@0: endTimeC.HomeTime(); sl@0: TTimeIntervalSeconds timeTakenC; sl@0: r = endTimeC.SecondsFrom(timerC,timeTakenC); sl@0: FailIfError(r); sl@0: sl@0: if(gFormat) sl@0: { sl@0: FormatFat(gSessionPath[0]-'A'); sl@0: } sl@0: sl@0: test.Printf(_L("#~T_Timing_%d: %d S\n"), gTestHarness, timeTakenC.Int()); sl@0: TheFs.SetAllocFailure(gAllocFailOff); sl@0: sl@0: #if defined(_DEBUG) || defined(_DEBUG_RELEASE) sl@0: TPckgBuf pkgValues; sl@0: TIOCacheValues& values=pkgValues(); sl@0: r = controlIo(TheFs,theDrive, KControlIoCacheCount, values); sl@0: test(r==KErrNone); sl@0: sl@0: test.Printf(_L("\nNumber of items on close list at end=%d\n"),values.iCloseCount); sl@0: test.Printf(_L("Number of items on free list at end=%d\n"),values.iFreeCount); sl@0: test.Printf(_L("Number of items allocated at the end=%d\n"),values.iAllocated); sl@0: sl@0: test(orgValues.iCloseCount==values.iCloseCount); sl@0: test(orgValues.iAllocated == values.iAllocated); sl@0: #endif sl@0: sl@0: TheFs.Close(); sl@0: test.End(); sl@0: test.Close(); sl@0: __UHEAP_MARKEND; sl@0: delete cleanup; sl@0: return(KErrNone); sl@0: }