sl@0: // Copyright (c) 2008-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\server\T_Fatcharsetconv_Aux.cpp sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "T_fatcharsetconv_Aux.h" sl@0: sl@0: CFileMan* gFileMan = NULL; sl@0: RPointerArray* gFileHandles = NULL; sl@0: TTestLogFailureData gLogFailureData; sl@0: RRawDisk TheDisk; sl@0: TFatBootSector gBootSector; sl@0: TBool gIOTesting; sl@0: TBool gAutoTest; // is BTB test sl@0: sl@0: RFs TheFs; sl@0: RFile TheFile; sl@0: RDir TheDir; sl@0: sl@0: TFileName gSessionPath; sl@0: TInt gAllocFailOff=KAllocFailureOff; sl@0: TInt gAllocFailOn=KAllocFailureOff; sl@0: TChar gDriveToTest; sl@0: TFileName gFileName; sl@0: sl@0: TTCType gTCType; sl@0: TUint gTCId; sl@0: sl@0: GLDEF_C void Format(TInt aDrive) sl@0: // sl@0: // Format current drive sl@0: // sl@0: { sl@0: test.Next(_L("Format")); sl@0: TBuf<4> driveBuf=_L("?:\\"); sl@0: driveBuf[0]=(TText)(aDrive+'A'); sl@0: RFormat format; sl@0: TInt count; sl@0: TInt r=format.Open(TheFs,driveBuf,EQuickFormat,count); sl@0: test(r==KErrNone); sl@0: while(count) sl@0: { sl@0: TInt r=format.Next(count); sl@0: test(r==KErrNone); sl@0: } sl@0: format.Close(); sl@0: } sl@0: sl@0: void MakeDir(const TDesC& aDirName) sl@0: // sl@0: // Make a directory sl@0: // sl@0: { sl@0: TInt r=TheFs.MkDirAll(aDirName); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: } sl@0: sl@0: sl@0: void ReportCheckDiskFailure(TInt aRet) sl@0: // sl@0: // Report the failure of checkdisk sl@0: // 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: test(EFalse); sl@0: } sl@0: sl@0: void CreateTestDirectory(const TDesC& aSessionPath) sl@0: // sl@0: // Create directory for test sl@0: // sl@0: { sl@0: TParsePtrC path(aSessionPath); sl@0: test(path.DrivePresent()==EFalse); sl@0: TInt r=TheFs.SetSessionPath(aSessionPath); sl@0: test(r==KErrNone); sl@0: r=TheFs.SessionPath(gSessionPath); sl@0: test(r==KErrNone); sl@0: r=TheFs.MkDirAll(gSessionPath); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: } sl@0: sl@0: TInt CurrentDrive(TChar aDriveChar) sl@0: // sl@0: // Return the current drive number sl@0: // sl@0: { sl@0: TInt driveNum; sl@0: TInt r = TheFs.CharToDrive(aDriveChar,driveNum); sl@0: test(r==KErrNone); sl@0: gDriveToTest = gSessionPath[0] = (TText)aDriveChar; sl@0: return(driveNum); sl@0: } sl@0: sl@0: TInt CurrentDrive() sl@0: // sl@0: // Return the current drive number sl@0: // sl@0: { sl@0: TInt driveNum; sl@0: TInt r = TheFs.CharToDrive(gSessionPath[0],driveNum); sl@0: test(r==KErrNone); sl@0: return(driveNum); sl@0: } sl@0: sl@0: void MakeFile(const TDesC& aFileName,const TUidType& aUidType,const TDesC8& aFileContents) sl@0: // sl@0: // Make a file and write uid and data sl@0: // sl@0: { sl@0: RFile file; sl@0: TInt r=file.Replace(TheFs,aFileName,0); sl@0: test(r==KErrNone || r==KErrPathNotFound); sl@0: if (r==KErrPathNotFound) sl@0: { sl@0: r=TheFs.MkDirAll(aFileName); sl@0: test(r==KErrNone); sl@0: r=file.Replace(TheFs,aFileName,0); sl@0: test(r==KErrNone); sl@0: } sl@0: TCheckedUid checkedUid(aUidType); sl@0: TPtrC8 uidData((TUint8*)&checkedUid,sizeof(TCheckedUid)); sl@0: r=file.Write(uidData); sl@0: test(r==KErrNone); sl@0: r=file.Write(aFileContents); sl@0: test(r==KErrNone); sl@0: file.Close(); sl@0: } sl@0: sl@0: void MakeFile(const TDesC& aFileName,const TDesC8& aFileContents) sl@0: // sl@0: // Make a file and write something in it sl@0: // sl@0: { sl@0: RFile file; sl@0: TInt r=file.Replace(TheFs,aFileName,0); sl@0: if(r!=KErrNone && r!=KErrPathNotFound) sl@0: { sl@0: test.Printf(_L("ERROR: r=%d"),r); sl@0: test(EFalse); sl@0: } sl@0: test(r==KErrNone || r==KErrPathNotFound); sl@0: if (r==KErrPathNotFound) sl@0: { sl@0: r=TheFs.MkDirAll(aFileName); sl@0: test(r==KErrNone); sl@0: r=file.Replace(TheFs,aFileName,0); sl@0: test(r==KErrNone); sl@0: } sl@0: r=file.Write(aFileContents); sl@0: test(r==KErrNone); sl@0: file.Close(); sl@0: } sl@0: sl@0: void MakeFile(const TDesC& aFileName,TInt anAttributes) sl@0: // sl@0: // Make a file and write something in it sl@0: // sl@0: { sl@0: RFile file; sl@0: TInt r=file.Replace(TheFs,aFileName,0); sl@0: test(r==KErrNone || r==KErrPathNotFound); sl@0: if (r==KErrPathNotFound) sl@0: { sl@0: r=TheFs.MkDirAll(aFileName); sl@0: test(r==KErrNone); sl@0: r=file.Replace(TheFs,aFileName,0); sl@0: test(r==KErrNone); sl@0: } sl@0: file.Close(); sl@0: r=TheFs.SetAtt(aFileName,anAttributes,0); sl@0: test(r==KErrNone); sl@0: } sl@0: sl@0: void MakeFile(const TDesC& aFileName) sl@0: // sl@0: // Make a file sl@0: // sl@0: { sl@0: MakeFile(aFileName,_L8("")); sl@0: } sl@0: sl@0: #if defined(_DEBUG) || defined(_DEBUG_RELEASE) sl@0: void QuickFormat() sl@0: { sl@0: FormatFatDrive(TheFs, CurrentDrive(), ETrue); sl@0: } sl@0: sl@0: void ReadBootSector(TFatBootSector& aBootSector) sl@0: { sl@0: TInt r = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum< tempName = _L("_"); sl@0: if(aTestCaseFound.iIsWithDLL) sl@0: tempName.Append(_L("DLL")); sl@0: else sl@0: tempName.Append(_L("NDLL")); sl@0: sl@0: TInt idx = aTestCaseFound.iSrcCmdPath.Find(_L("\\Src\\")); sl@0: aTestCaseFound.iSrcCmdPath.Insert(idx, tempName); sl@0: aTestCaseFound.iSrcPrsPath.Insert(idx, tempName); sl@0: } sl@0: else sl@0: return KErrNotFound; sl@0: sl@0: return KErrNone; sl@0: } sl@0: /* sl@0: * Search test cases by the index of the array of test case group, overloaded version for basic binary cases. sl@0: * @param aIdx the test case index in search sl@0: * @param aBasicUnitaryTestCaseGroup the input test group, should always be gBasicBinaryTestCases[] sl@0: * @param aTestCaseFound contains params of the test case found by the test case Id. sl@0: * @return KErrNone if only one test case on the id is found sl@0: * KErrNotFound if no test case is found sl@0: */ sl@0: TInt SearchTestCaseByArrayIdx(TUint aIdx, const TTestCaseBinaryBasic aBasicBinaryTestCaseGroup[], sl@0: TTestParamAll& aTestCaseFound, TBool aIsWithDLL=EFalse) sl@0: { sl@0: if (aBasicBinaryTestCaseGroup[aIdx].iBasic.iTestCaseID != 0) sl@0: { sl@0: aTestCaseFound.iTestCaseID = aBasicBinaryTestCaseGroup[aIdx].iBasic.iTestCaseID; sl@0: aTestCaseFound.iAPI = aBasicBinaryTestCaseGroup[aIdx].iBasic.iAPI; sl@0: sl@0: aTestCaseFound.iSrcDrvChar = aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iDrvChar; sl@0: aTestCaseFound.iSrcCmdPath.Copy(aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iCmdPath); sl@0: aTestCaseFound.iSrcPrsPath.Copy(aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iPrsPath); sl@0: aTestCaseFound.iSrcPrsFiles = aBasicBinaryTestCaseGroup[aIdx].iSrcPrsBasic.iPrsFiles; sl@0: sl@0: aTestCaseFound.iTrgDrvChar = aBasicBinaryTestCaseGroup[aIdx].iTrgPrsBasic.iDrvChar; sl@0: aTestCaseFound.iTrgCmdPath.Copy(aBasicBinaryTestCaseGroup[aIdx].iTrgPrsBasic.iCmdPath); sl@0: sl@0: aTestCaseFound.iIsWithDLL = aIsWithDLL; sl@0: // To make every test case uniquely indentified for interOP sl@0: // update the test case id and its path correspondingly sl@0: TBuf<15> tempBuf; sl@0: TInt idx = aTestCaseFound.iSrcCmdPath.Find(_L("\\T_FCSC\\")) + 8 /* Len of \\T_FCSC\\ */; sl@0: TInt i = 0; sl@0: while(aTestCaseFound.iSrcCmdPath[idx] != '\\') sl@0: { sl@0: tempBuf.SetLength(i+1); sl@0: tempBuf[i++] = aTestCaseFound.iSrcCmdPath[idx++]; sl@0: } sl@0: tempBuf.Append(_L("_")); sl@0: if(aTestCaseFound.iIsWithDLL) sl@0: tempBuf.Append(_L("DLL")); sl@0: else sl@0: tempBuf.Append(_L("NDLL")); sl@0: sl@0: TInt len = 0; sl@0: idx = aTestCaseFound.iSrcCmdPath.Find(_L("\\T_FCSC\\")) + 8; sl@0: while(aTestCaseFound.iSrcCmdPath[idx] != '\\') sl@0: { sl@0: len++; sl@0: aTestCaseFound.iSrcCmdPath[idx++]; sl@0: } sl@0: aTestCaseFound.iSrcCmdPath.Replace(idx-len, len, tempBuf); sl@0: sl@0: len =0; sl@0: idx = aTestCaseFound.iSrcPrsPath.Find(_L("\\T_FCSC\\")) + 8; sl@0: while(aTestCaseFound.iSrcPrsPath[idx] != '\\') sl@0: { sl@0: len++; sl@0: aTestCaseFound.iSrcCmdPath[idx++]; sl@0: } sl@0: aTestCaseFound.iSrcPrsPath.Replace(idx-len, len, tempBuf); sl@0: sl@0: len =0; sl@0: idx = aTestCaseFound.iTrgCmdPath.Find(_L("\\T_FCSC\\")) + 8; sl@0: while(aTestCaseFound.iTrgCmdPath[idx] != '\\') sl@0: { sl@0: len++; sl@0: aTestCaseFound.iTrgCmdPath[idx++]; sl@0: } sl@0: aTestCaseFound.iTrgCmdPath.Replace(idx-len, len, tempBuf); sl@0: } sl@0: else sl@0: { sl@0: return KErrNotFound; sl@0: } sl@0: return KErrNone; sl@0: } sl@0: sl@0: void Help() sl@0: { sl@0: RDebug::Print(_L("t_fatcharsetconv [-x {s,w}] [-d {dt}][-v {sw}]")); sl@0: RDebug::Print(_L("\t-x : for executing tests")); sl@0: RDebug::Print(_L("\t\t s or S for execution on Symbian")); sl@0: RDebug::Print(_L("\t\t w or W for execution on Windows")); sl@0: RDebug::Print(_L("\t-d: drive to test for execution/verification")); sl@0: RDebug::Print(_L("\t\t This test runs on FAT or Win32 file systems only")); sl@0: RDebug::Print(_L("\t\t d or D for test drive on Symbian (FAT file system)")); sl@0: RDebug::Print(_L("\t\t Any FAT/Win32 file system drive on emulator i.e. T, X etc")); sl@0: RDebug::Print(_L("\t-v : for validating tests")); sl@0: RDebug::Print(_L("\t\t s or S for verification on symbian")); sl@0: RDebug::Print(_L("\t\t w or W for verification on Windows")); sl@0: } sl@0: sl@0: void ClearSwitches(TTestSwitches& aSwitches) sl@0: { sl@0: // clear the switches sl@0: aSwitches.iExeOnSymbian = EFalse; sl@0: aSwitches.iVerOnSymbian = EFalse; sl@0: aSwitches.iExeOnWindows = EFalse; sl@0: aSwitches.iVerOnWindows = EFalse; sl@0: aSwitches.iExeDriveChar =' '; sl@0: aSwitches.iVerDriveChar =' '; sl@0: aSwitches.iExeDriveNum =0; sl@0: aSwitches.iVerDriveNum =0; sl@0: aSwitches.iMountedFSName.SetLength(0); sl@0: } sl@0: sl@0: sl@0: void ParseCommandArguments(TTestSwitches& aSwitches) sl@0: { sl@0: TBuf<256> cmd; sl@0: User::CommandLine(cmd); sl@0: RDebug::Print(_L("Command Line : %S"), &cmd); sl@0: TChar testDrive = 'C'; sl@0: sl@0: InitLogData(); sl@0: ClearSwitches(aSwitches); sl@0: sl@0: TFileName currentFile=RProcess().FileName(); sl@0: TLex lex(cmd); sl@0: TPtrC token=lex.NextToken(); sl@0: if (token.MatchF(currentFile)==0) sl@0: { sl@0: token.Set(lex.NextToken()); sl@0: } sl@0: if (token.Length()==0) sl@0: { sl@0: testDrive = 'C'; // default drives sl@0: gAutoTest = ETrue; sl@0: } sl@0: else if((token[0] >='A' && token[0]<='Z') || (token[0] >='a' && token[0]<='z')) sl@0: { sl@0: testDrive = token[0]; sl@0: gAutoTest = ETrue; sl@0: } sl@0: else sl@0: { sl@0: while (!lex.Eos()) sl@0: { sl@0: if (token.Length()==0) sl@0: { sl@0: continue; // ignore trailing whitespace sl@0: } sl@0: if (token==_L("-x") || token==_L("-X")) sl@0: { sl@0: token.Set(lex.NextToken()); sl@0: if((token==_L("s")) || (token==_L("S"))) sl@0: { sl@0: aSwitches.iExeOnSymbian = ETrue; sl@0: gLogFailureData.iExeOsName = KSymbian; sl@0: } sl@0: else if((token==_L("w")) || (token==_L("W"))) sl@0: { sl@0: aSwitches.iExeOnWindows = ETrue; sl@0: gLogFailureData.iExeOsName = KWindows; sl@0: } sl@0: token.Set(lex.NextToken()); sl@0: continue; sl@0: } sl@0: if (token==_L("-d") || token==_L("-D")) sl@0: { sl@0: token.Set(lex.NextToken()); sl@0: testDrive = token[0]; sl@0: token.Set(lex.NextToken()); sl@0: continue; sl@0: } sl@0: if (token==_L("-v") || token==_L("-V")) sl@0: { sl@0: token.Set(lex.NextToken()); sl@0: if((token==_L("s")) || (token==_L("S"))) sl@0: { sl@0: aSwitches.iVerOnSymbian = ETrue; sl@0: gLogFailureData.iVerOsName = KSymbian; sl@0: } sl@0: else if((token==_L("w")) || (token==_L("W"))) sl@0: { sl@0: aSwitches.iVerOnWindows = ETrue; sl@0: gLogFailureData.iVerOsName = KWindows; sl@0: } sl@0: token.Set(lex.NextToken()); sl@0: continue; sl@0: } sl@0: RDebug::Print(_L("Unknown option %S"), &token); sl@0: Help(); sl@0: return; sl@0: } sl@0: } sl@0: sl@0: CheckIfIOTesting(aSwitches); sl@0: sl@0: if(gIOTesting) sl@0: { sl@0: gAutoTest = EFalse; sl@0: } sl@0: else sl@0: { sl@0: gAutoTest = ETrue; sl@0: } sl@0: sl@0: testDrive.UpperCase(); sl@0: if (gAutoTest) sl@0: { sl@0: #if defined (__WINS__) sl@0: //execution phase sl@0: aSwitches.iExeOnWindows = ETrue; sl@0: aSwitches.iExeDriveChar = testDrive; sl@0: aSwitches.iExeDriveNum = CurrentDrive(aSwitches.iExeDriveChar); sl@0: gLogFailureData.iExeDrive = aSwitches.iExeDriveChar; sl@0: gLogFailureData.iExeOsName = KWindows; sl@0: //verification phase sl@0: aSwitches.iVerOnWindows = ETrue; sl@0: aSwitches.iVerDriveChar = testDrive; sl@0: aSwitches.iVerDriveNum = CurrentDrive(aSwitches.iVerDriveChar); sl@0: gLogFailureData.iVerDrive = aSwitches.iVerDriveChar; sl@0: gLogFailureData.iVerOsName = KWindows; sl@0: #else sl@0: //execution phase sl@0: aSwitches.iExeOnSymbian = ETrue; sl@0: aSwitches.iExeDriveChar = testDrive; sl@0: aSwitches.iExeDriveNum = CurrentDrive(aSwitches.iExeDriveChar); sl@0: gLogFailureData.iExeDrive = aSwitches.iExeDriveChar; sl@0: gLogFailureData.iExeOsName = KSymbian; sl@0: //verification phase sl@0: aSwitches.iVerOnSymbian = ETrue; sl@0: aSwitches.iVerDriveChar = testDrive; sl@0: aSwitches.iVerDriveNum = CurrentDrive(aSwitches.iVerDriveChar); sl@0: gLogFailureData.iVerDrive = aSwitches.iVerDriveChar; sl@0: gLogFailureData.iVerOsName = KSymbian; sl@0: #endif sl@0: } sl@0: sl@0: if(aSwitches.iExeOnWindows || aSwitches.iExeOnSymbian) sl@0: { sl@0: aSwitches.iExeDriveChar = testDrive; sl@0: aSwitches.iExeDriveNum = CurrentDrive(aSwitches.iExeDriveChar); sl@0: gLogFailureData.iExeDrive = aSwitches.iExeDriveChar; sl@0: } sl@0: if(aSwitches.iVerOnWindows || aSwitches.iVerOnSymbian) sl@0: { sl@0: aSwitches.iVerDriveChar = testDrive; sl@0: aSwitches.iVerDriveNum = CurrentDrive(aSwitches.iVerDriveChar); sl@0: gLogFailureData.iVerDrive = aSwitches.iVerDriveChar; sl@0: } sl@0: } sl@0: sl@0: void InitialiseL() sl@0: { sl@0: gFileMan=CFileMan::NewL(TheFs); sl@0: } sl@0: sl@0: void RmDir(const TDesC& aDirName) sl@0: { sl@0: TFileName filename_dir = aDirName; sl@0: TInt r = 0; sl@0: r = TheFs.SetAtt(filename_dir, 0, KEntryAttReadOnly); sl@0: test(r==KErrNone); sl@0: r=gFileMan->RmDir(filename_dir); sl@0: test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound || r==KErrInUse); sl@0: } sl@0: sl@0: // Cleanup test variables sl@0: void Cleanup() sl@0: { sl@0: delete gFileMan; sl@0: } sl@0: sl@0: /** sl@0: Parsing Dir Data Block sl@0: @param aDataBlock data block in TInt[] for parsing sl@0: @param aDirDataArray returning dir data array after parsing sl@0: sl@0: @panic if data setup error sl@0: */ sl@0: void ParsingDirDataBlock(const TInt aDataBlock[], RArray& aDirDataArray) sl@0: { sl@0: TInt err = KErrNone; sl@0: aDirDataArray.Reset(); sl@0: sl@0: if (aDataBlock[0] == EOB) sl@0: { sl@0: return; sl@0: } sl@0: sl@0: TInt i = 1; sl@0: FOREVER sl@0: { sl@0: TInt lastItem = aDataBlock[i-1]; sl@0: TInt currentItem = aDataBlock[i]; sl@0: sl@0: // check currentItem sl@0: if (currentItem == EOB) sl@0: { sl@0: if (lastItem == CON || lastItem > LAST) sl@0: //check last sl@0: { sl@0: test.Printf(_L("ERROR: wrong dir data setup! err=%d\n"), err); sl@0: test(EFalse); sl@0: } sl@0: else sl@0: // passed, insert last, break sl@0: { sl@0: err = aDirDataArray.InsertInOrder(lastItem); sl@0: if (err != KErrNone && err != KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("ERROR: wrong dir data setup! err=%d\n"), err); sl@0: test(EFalse); sl@0: } sl@0: break; sl@0: } sl@0: } sl@0: else if (currentItem == CON) sl@0: // if current == CON sl@0: { sl@0: if (lastItem == CON || lastItem >= LAST) sl@0: // check last item sl@0: { sl@0: test.Printf(_L("ERROR: wrong dir data setup! err=%d\n"), err); sl@0: test(EFalse); sl@0: } sl@0: else // last < LAST, last != CON sl@0: { sl@0: // check next item sl@0: TInt nextItem = aDataBlock[i+1]; sl@0: if (nextItem <= 0 || nextItem > LAST || lastItem >= nextItem) sl@0: { sl@0: test.Printf(_L("ERROR: wrong dir data setup! err=%d\n"), err); sl@0: test(EFalse); sl@0: } sl@0: else sl@0: { sl@0: // all valid sl@0: for (TInt j = lastItem; j < nextItem; j++) sl@0: { sl@0: err = aDirDataArray.InsertInOrder(j); sl@0: if (err != KErrNone && err != KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("ERROR: wrong dir data setup! err=%d\n"), err); sl@0: test(EFalse); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: i++; sl@0: } sl@0: else if (0 <= currentItem && currentItem <= LAST) sl@0: // if current == normal item sl@0: { sl@0: if (lastItem == CON) sl@0: { sl@0: i++; sl@0: continue; sl@0: } sl@0: else if (lastItem >= LAST) sl@0: // check last item sl@0: { sl@0: test.Printf(_L("ERROR: wrong dir data setup! err=%d\n"), err); sl@0: test(EFalse); sl@0: } sl@0: else sl@0: // passed, insert last sl@0: { sl@0: err = aDirDataArray.InsertInOrder(lastItem); sl@0: if (err != KErrNone && err != KErrAlreadyExists) sl@0: { sl@0: test.Printf(_L("ERROR: wrong dir data setup! err=%d\n"), err); sl@0: test(EFalse); sl@0: } sl@0: } sl@0: i++; sl@0: } sl@0: else // invalid input sl@0: { sl@0: test.Printf(_L("ERROR: wrong dir data setup! err=%d\n"), err); sl@0: test(EFalse); sl@0: } sl@0: } sl@0: } sl@0: sl@0: /** sl@0: Setup dir structure for testing and verifying functional results sl@0: @param datastr data structure to setup directory sl@0: @param iOperation Operation to be performed sl@0: @param SrcDrive Source drive sl@0: @param Targetdrive Target drive input sl@0: @panic if data structure definition is incorrect sl@0: */ sl@0: void SetupDirFiles(const TDesC& aPath, const TDirSetupFiles& aDirFiles) sl@0: { sl@0: TFileName path = aPath; sl@0: if (path.Length() == 0) sl@0: { sl@0: test.Printf(_L("ERROR: Zero length src path!\n")); sl@0: test(EFalse); sl@0: } sl@0: sl@0: MakeDir(path); sl@0: sl@0: RArray addBlockDataArray; sl@0: RArray deductBlockDataArray; sl@0: sl@0: ParsingDirDataBlock(aDirFiles.iAddingBlock, addBlockDataArray); sl@0: ParsingDirDataBlock(aDirFiles.iDeductBlock, deductBlockDataArray); sl@0: sl@0: if (addBlockDataArray.Count() == 0) sl@0: // empty dir setup sl@0: { sl@0: return; sl@0: } sl@0: for (TInt i = 0; i < deductBlockDataArray.Count(); ++i) sl@0: { sl@0: TInt idxToDelete = addBlockDataArray.FindInOrder(deductBlockDataArray[i]); sl@0: if (idxToDelete >= 0) sl@0: { sl@0: addBlockDataArray.Remove(idxToDelete); sl@0: } sl@0: else if (idxToDelete == KErrNotFound) sl@0: { sl@0: continue; sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("ERROR<>: wrong dir data setup! err=%d\n"), idxToDelete); sl@0: test(EFalse); sl@0: } sl@0: } sl@0: if (addBlockDataArray.Count() > 0) sl@0: { sl@0: for (TInt i = 0; i < addBlockDataArray.Count(); ++i) sl@0: { sl@0: TInt idx = addBlockDataArray[i]; sl@0: path = aPath; sl@0: path += gDirPatterns[idx]; sl@0: if (path[path.Length() - 1] == '\\') sl@0: { sl@0: MakeDir(path); sl@0: } sl@0: else sl@0: { sl@0: MakeFile(path, _L8("blahblah")); sl@0: } sl@0: } sl@0: } sl@0: sl@0: addBlockDataArray.Reset(); sl@0: deductBlockDataArray.Reset(); sl@0: } sl@0: sl@0: void LogTestFailureData(TTCType tcType, TFileName failedOn, sl@0: TUint tcId, TFileName tcUniquePath, TInt line) sl@0: { sl@0: if(tcType == EUnitaryTest) sl@0: gLogFailureData.iTCTypeName = KUnitary; sl@0: else if(tcType == EBinaryTest) sl@0: gLogFailureData.iTCTypeName = KBinary; sl@0: gLogFailureData.iTCFailureOn = failedOn; sl@0: gLogFailureData.iTCId = tcId; sl@0: gLogFailureData.iTCUniquePath.Copy(tcUniquePath); sl@0: gLogFailureData.iLineNum = line; sl@0: gLogFailureData.iFileName.Copy(gFileName); sl@0: sl@0: RFile file; sl@0: TBuf8<256> tempBuf; sl@0: sl@0: TFileName logFileName; sl@0: if(gIOTesting) sl@0: { sl@0: if(failedOn == KExecution) sl@0: { sl@0: logFileName.Append(KExeLogFileName); sl@0: } sl@0: else sl@0: { sl@0: logFileName.Append(KVerLogFileName); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: logFileName.Append(KLogFileName); sl@0: } sl@0: sl@0: logFileName.Append(KUnderScore); sl@0: logFileName.Append(gDriveToTest); sl@0: logFileName.Append(KExtension); sl@0: sl@0: TInt r = file.Create(TheFs, logFileName, EFileRead|EFileWrite); sl@0: test(r == KErrNone || r == KErrAlreadyExists); sl@0: sl@0: if (r == KErrNone) sl@0: { sl@0: tempBuf.Append(KLogFileHeader); sl@0: file.Write(tempBuf); sl@0: } sl@0: sl@0: if (r == KErrAlreadyExists) sl@0: { sl@0: r = file.Open(TheFs, logFileName, EFileRead|EFileWrite); sl@0: test(r == KErrNone); sl@0: TInt start = 0; sl@0: r=file.Seek(ESeekEnd,start); sl@0: test(r == KErrNone); sl@0: } sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(KNewLine); sl@0: if(gIOTesting) sl@0: tempBuf.Append(KYes); sl@0: else sl@0: tempBuf.Append(KNo); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iTCTypeName); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iTCFailureOn); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.AppendNum(gLogFailureData.iTCId); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iTCUniquePath); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iFSName); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iExeOsName); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iExeDrive); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iVerOsName); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iVerDrive); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iAPIName); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.AppendNum(gLogFailureData.iLineNum); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iFuncName); sl@0: tempBuf.Append(KComma); sl@0: file.Write(tempBuf); sl@0: sl@0: tempBuf.SetLength(0); sl@0: tempBuf.Append(gLogFailureData.iFileName); sl@0: file.Write(tempBuf); sl@0: sl@0: file.Close(); sl@0: }