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_Main.cpp sl@0: // sl@0: // sl@0: sl@0: #define __E32TEST_EXTENSION__ sl@0: sl@0: #include sl@0: #include sl@0: //#include sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: #include "t_chlffs.h" sl@0: #include "fat_utils.h" sl@0: #include "T_Fatcharsetconv_Cases.h" sl@0: sl@0: sl@0: RTest test(_L("T_FatCharSetConv")); sl@0: sl@0: using namespace Fat_Test_Utils; sl@0: sl@0: #if defined(_DEBUG) || defined(_DEBUG_RELEASE) sl@0: sl@0: template 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: TInt r = fs.ControlIo(drv, fkn, ptrC); sl@0: return r; sl@0: } sl@0: sl@0: /* sl@0: * Presetting module, presets initial source, target and comparing direcotries. sl@0: * @param aParam test param that contains all information about a test case sl@0: */ sl@0: void DataGenerationL(const TTestParamAll& aParam) sl@0: { sl@0: // Setup source files sl@0: RBuf path; sl@0: path.CreateL(aParam.iSrcPrsPath); sl@0: sl@0: path[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: if(path[0] == (TUint8)gDriveToTest) sl@0: { sl@0: SetupDirFiles(path, aParam.iSrcPrsFiles); sl@0: } sl@0: sl@0: if (aParam.iAPI == EGetShortName || aParam.iAPI == EGetShortNameWithDLL || aParam.iAPI == EGetShortNameWithoutDLL || aParam.iAPI == ERFsReplace || aParam.iAPI == ERFsRename ||aParam.iAPI == ERenameFile ) sl@0: { sl@0: path[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: path.Close(); sl@0: CheckDisk(); sl@0: } sl@0: sl@0: /* sl@0: * Test execution module sl@0: * @param aParam test param that contains all information about a test case sl@0: * @panic USER:84 if return codes do not match the expected values. sl@0: */ sl@0: void DataExecutionL(const TTestParamAll& aParam, const TTCType aTCType) sl@0: { sl@0: RBuf srcCmdFile; sl@0: srcCmdFile.CreateL(aParam.iSrcCmdPath); sl@0: RBuf trgCmdFile; sl@0: trgCmdFile.CreateL(aParam.iTrgCmdPath); sl@0: RBuf srcCmd; sl@0: srcCmd.CreateL(aParam.iSrcPrsPath); sl@0: sl@0: if (srcCmdFile.Length() > 0) sl@0: { sl@0: srcCmdFile[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: } sl@0: else sl@0: { sl@0: // srcCmdFile= gSessionPath; sl@0: srcCmdFile[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: } sl@0: if (srcCmd.Length() > 0) sl@0: { sl@0: srcCmd[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: } sl@0: else sl@0: { sl@0: // srcCmd= gSessionPath; sl@0: srcCmd[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: } sl@0: sl@0: // logging for failure sl@0: gTCType = aTCType; sl@0: RBuf failedOnBuf; sl@0: failedOnBuf.CreateL(KExecution()); sl@0: gTCId = aParam.iTestCaseID; sl@0: RBuf tcUniquePath; sl@0: tcUniquePath.CreateL(aParam.iSrcPrsPath); sl@0: sl@0: TInt r = KErrNone; sl@0: sl@0: switch(aParam.iAPI) sl@0: { sl@0: case EGetShortName: sl@0: case EGetShortNameWithDLL: sl@0: case EGetShortNameWithoutDLL: sl@0: { sl@0: __UHEAP_MARK; sl@0: if(aParam.iAPI == EGetShortName ) sl@0: gLogFailureData.iAPIName = KGetShortName; sl@0: else if(aParam.iAPI == EGetShortNameWithDLL ) sl@0: gLogFailureData.iAPIName = KGetShortNameWithDLL; sl@0: else if(aParam.iAPI == EGetShortNameWithoutDLL ) sl@0: gLogFailureData.iAPIName = KGetShortNameWithoutDLL; sl@0: sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: sl@0: TBuf<0x10> shortName; sl@0: r=TheFs.GetShortName(srcCmdFile,shortName); sl@0: testAndLog(r==KErrNone); sl@0: srcCmd.ReAllocL(srcCmd.Length() + shortName.Length()); sl@0: srcCmd+= shortName; sl@0: testAndLog(srcCmd==trgCmdFile); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ELongShortConversion: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KLongShortConversion; sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: sl@0: RBuf lgnFullPath; sl@0: RBuf shnFullPath; sl@0: TFileName longName; sl@0: TBuf<0x10> shortName; sl@0: sl@0: r = TheFs.GetShortName(srcCmdFile, shortName); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: shnFullPath.CreateL(srcCmd); sl@0: shnFullPath.ReAllocL(srcCmd.Length() + shortName.Length()); sl@0: shnFullPath.Append(shortName); sl@0: r = shnFullPath.Compare(trgCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: r = TheFs.GetLongName(shnFullPath, longName); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: lgnFullPath.CreateL(srcCmd); sl@0: lgnFullPath.ReAllocL(srcCmd.Length() + longName.Length()); sl@0: lgnFullPath.Append(longName); sl@0: r = lgnFullPath.Compare(srcCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: lgnFullPath.Close(); sl@0: shnFullPath.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ECreateFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KCreateFile; sl@0: r = TheFile.Create(TheFs,srcCmdFile,EFileWrite); sl@0: testAndLog(r==KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EIsValidName: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KIsValidName; sl@0: TText badChar; sl@0: r=TheFs.IsValidName(srcCmdFile,badChar); sl@0: testAndLog(r==(TInt)ETrue); sl@0: r=TheFs.IsValidName(srcCmdFile); sl@0: testAndLog(r==(TInt)ETrue); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EMkDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KMkDir; sl@0: r=TheFs.MkDir(srcCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EMkDirAll: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KMkDirAll; sl@0: r=TheFs.MkDirAll(srcCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERenameFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRenameFile; sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: r=TheFile.Rename(trgCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EReadFileSection: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KReadFileSection; sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: sl@0: TInt numWrite = 15; sl@0: TBuf8<50> writeBuf = _L8("I am going to write some junk for testing purpose"); sl@0: TheFile.Write(writeBuf, numWrite); sl@0: r=TheFile.Flush(); sl@0: testAndLog(r==KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EDeleteFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KDeleteFile; sl@0: r=TheFs.Delete(srcCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EOpenDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KOpenDir; sl@0: r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported); sl@0: testAndLog(r==KErrNone); sl@0: TheDir.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EReadDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KReadDir; sl@0: r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported); sl@0: testAndLog(r==KErrNone); sl@0: TheDir.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERemoveDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRemoveDir; sl@0: r=TheFs.RmDir(srcCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EIsFileInRom: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KIsFileInRom; sl@0: // The tested files are created on non-rom drives, which should not be found sl@0: // on rom drives sl@0: TUint8* ptr=TheFs.IsFileInRom(srcCmdFile); sl@0: testAndLog(ptr==NULL); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EReplaceFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KReplaceFile; sl@0: r=TheFile.Replace(TheFs, srcCmdFile ,EFileWrite); sl@0: testAndLog(r==KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EOperateOnFileNames: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KOperateOnFileNames; sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead); sl@0: testAndLog(r == KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EFileModify: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KFileModify; sl@0: TTime time; sl@0: r=TheFs.Modified(srcCmdFile,time); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EFileAttributes: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KFileAttributes; sl@0: TUint att; sl@0: r=TheFs.Att(srcCmdFile,att); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERFsEntry: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRFsEntry; sl@0: TEntry entryDetail; sl@0: r=TheFs.Entry(srcCmdFile, entryDetail); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERFsReplace: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRFsReplace; sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: r=TheFs.Replace(srcCmdFile,trgCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERFsRename: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRFsRename; sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: r=TheFs.Rename(srcCmdFile,trgCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EGetDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KGetDir; sl@0: CDir *anEntryList; sl@0: r=TheFs.GetDir(srcCmdFile,KEntryAttNormal,ESortByName,anEntryList); sl@0: testAndLog(r==KErrNone); sl@0: delete anEntryList; sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EFileTemp: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KFileTemp; sl@0: TFileName tempFileName; sl@0: r=TheFile.Temp(TheFs,srcCmdFile,tempFileName,EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EReadFromFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KReadFromFile; sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: sl@0: TBuf8<200> writeBuf = _L8("I am going to write something to the file and then read from the specified position to test an overload of RFIle::Read"); sl@0: TInt numWrite = 50; sl@0: TheFile.Write(writeBuf, numWrite); sl@0: testAndLog(r==KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EWriteToFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KWriteToFile; sl@0: sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: sl@0: TBuf8<200> writeBuf = _L8("I am going to write something to the file and then read from the specified position to test an overload of RFIle::Read"); sl@0: TInt numWrite = 50; sl@0: TheFile.Write(writeBuf, numWrite); sl@0: testAndLog(r==KErrNone); sl@0: r=TheFile.Flush(); sl@0: testAndLog(r==KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: sl@0: break; sl@0: default: sl@0: break; sl@0: sl@0: } sl@0: // test.Printf(_L("DataExecution::\tTest case %d passed\n"),aParam.iTestCaseID); sl@0: sl@0: failedOnBuf.Close(); sl@0: tcUniquePath.Close(); sl@0: sl@0: srcCmdFile.Close(); sl@0: trgCmdFile.Close(); sl@0: srcCmd.Close(); sl@0: CheckDisk(); sl@0: } sl@0: sl@0: void DataVerificationL(const TTestParamAll& aParam, const TTCType aTCType) sl@0: { sl@0: RBuf srcCmdFile; sl@0: srcCmdFile.CreateL(aParam.iSrcCmdPath); sl@0: RBuf trgCmdFile; sl@0: trgCmdFile.CreateL(aParam.iTrgCmdPath); sl@0: RBuf srcCmd; sl@0: srcCmd.CreateL(aParam.iSrcPrsPath); sl@0: sl@0: if (srcCmdFile.Length() > 0) sl@0: { sl@0: srcCmdFile[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //srcCmdFile= gSessionPath; sl@0: srcCmdFile[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: } sl@0: sl@0: if (srcCmd.Length() > 0) sl@0: { sl@0: srcCmd[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //srcCmd= gSessionPath; sl@0: srcCmd[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: } sl@0: sl@0: // logging for failure sl@0: gTCType = aTCType; sl@0: RBuf failedOnBuf; sl@0: failedOnBuf.CreateL(KVerification()); sl@0: gTCId = aParam.iTestCaseID; sl@0: RBuf tcUniquePath; sl@0: tcUniquePath.CreateL(aParam.iSrcPrsPath); sl@0: sl@0: TInt r = KErrNone; sl@0: switch(aParam.iAPI) sl@0: { sl@0: case EGetShortName: sl@0: case EGetShortNameWithDLL: sl@0: case EGetShortNameWithoutDLL: sl@0: { sl@0: __UHEAP_MARK; sl@0: if(aParam.iAPI == EGetShortName ) sl@0: gLogFailureData.iAPIName = KGetShortName; sl@0: else if(aParam.iAPI == EGetShortNameWithDLL ) sl@0: gLogFailureData.iAPIName = KGetShortNameWithDLL; sl@0: else if(aParam.iAPI == EGetShortNameWithoutDLL ) sl@0: gLogFailureData.iAPIName = KGetShortNameWithoutDLL; sl@0: sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: sl@0: TBuf<0x10> shortName; sl@0: r=TheFs.GetShortName(srcCmdFile,shortName); sl@0: testAndLog(r==KErrNone); sl@0: if(r==KErrNone) sl@0: { sl@0: srcCmd.ReAllocL(srcCmd.Length() + shortName.Length()); sl@0: srcCmd+= shortName; sl@0: testAndLog(srcCmd==trgCmdFile); sl@0: } sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ELongShortConversion: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KLongShortConversion; sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: sl@0: RBuf lgnFullPath; sl@0: RBuf shnFullPath; sl@0: TFileName longName; sl@0: TBuf<0x10> shortName; sl@0: sl@0: r = TheFs.GetShortName(srcCmdFile, shortName); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: if(r==KErrNone) sl@0: { sl@0: shnFullPath.CreateL(srcCmd); sl@0: shnFullPath.ReAllocL(srcCmd.Length() + shortName.Length()); sl@0: shnFullPath.Append(shortName); sl@0: r = shnFullPath.Compare(trgCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: r = TheFs.GetLongName(shnFullPath, longName); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: lgnFullPath.CreateL(srcCmd); sl@0: lgnFullPath.ReAllocL(srcCmd.Length() + longName.Length()); sl@0: lgnFullPath.Append(longName); sl@0: r = lgnFullPath.Compare(srcCmdFile); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: lgnFullPath.Close(); sl@0: shnFullPath.Close(); sl@0: } sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ECreateFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KCreateFile; sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EIsValidName: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KIsValidName; sl@0: TText badChar; sl@0: r=TheFs.IsValidName(srcCmdFile,badChar); sl@0: testAndLog(r); sl@0: r=TheFs.IsValidName(srcCmdFile); sl@0: testAndLog(r); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EMkDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KMkDir; sl@0: r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported); sl@0: testAndLog(r==KErrNone); sl@0: TheDir.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EMkDirAll: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KMkDirAll; sl@0: r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported); sl@0: testAndLog(r==KErrNone); sl@0: TheDir.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERenameFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRenameFile; sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNotFound); sl@0: // r = TheFile.Open(TheFs, trgCmdFile, EFileRead|EFileWrite); sl@0: // testAndLog(r == KErrNone); sl@0: // TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EReadFileSection: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KReadFileSection; sl@0: TBool isFileOpen = EFalse; sl@0: r=TheFs.IsFileOpen(srcCmdFile,isFileOpen); sl@0: testAndLog(r==KErrNone); sl@0: if(isFileOpen) sl@0: { sl@0: TheFile.Close(); sl@0: } sl@0: else sl@0: { sl@0: TInt numRead = 15; sl@0: TBuf8<50> readBuf; sl@0: r=TheFs.ReadFileSection(srcCmdFile, 0, readBuf, numRead); sl@0: testAndLog(r==KErrNone); sl@0: } sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EDeleteFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KDeleteFile; sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNotFound); sl@0: // TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EOpenDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KOpenDir; sl@0: r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported); sl@0: testAndLog(r==KErrNone); sl@0: TheDir.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EReadDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KReadDir; sl@0: TEntry entry; sl@0: TInt dirEntryCount = 0; sl@0: r=TheDir.Open(TheFs,srcCmdFile,KEntryAttMaskSupported); sl@0: testAndLog(r==KErrNone); sl@0: FOREVER sl@0: { sl@0: r = TheDir.Read(entry); sl@0: if(r == KErrEof) sl@0: { sl@0: break; sl@0: } sl@0: dirEntryCount++; sl@0: } sl@0: TheDir.Close(); sl@0: testAndLog(dirEntryCount == 4); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERemoveDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRemoveDir; sl@0: r = TheDir.Open(TheFs, srcCmdFile, KEntryAttMaskSupported); sl@0: testAndLog(r == KErrPathNotFound); sl@0: // TheDir.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EIsFileInRom: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KIsFileInRom; sl@0: TUint8* ptr=TheFs.IsFileInRom(srcCmdFile); sl@0: // file should not be in ROM sl@0: testAndLog(ptr==NULL) sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EReplaceFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KReplaceFile; sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EOperateOnFileNames: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KOperateOnFileNames; sl@0: sl@0: TFileName realFileNameInFS; sl@0: TFileName fullFileName; sl@0: TFileName fileName; sl@0: sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead); sl@0: testAndLog(r == KErrNone); sl@0: sl@0: if(r==KErrNone) sl@0: { sl@0: r=TheFile.FullName(fullFileName); sl@0: testAndLog(r==KErrNone); sl@0: testAndLog(fullFileName==srcCmdFile); sl@0: sl@0: TInt length = srcCmdFile.Length()-srcCmd.Length(); sl@0: sl@0: r=TheFile.Name(fileName); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: TBuf<50> tempFileName; sl@0: tempFileName = srcCmdFile.Right(length); sl@0: testAndLog(fileName==tempFileName); sl@0: testAndLog(length==fileName.Length()); sl@0: sl@0: r=TheFs.RealName(srcCmdFile,realFileNameInFS); sl@0: testAndLog(r==KErrNone); sl@0: testAndLog(realFileNameInFS==srcCmdFile); sl@0: TheFile.Close(); sl@0: } sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EFileModify: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KFileModify; sl@0: TTime tempTime; sl@0: r=TheFs.Modified(srcCmdFile,tempTime); sl@0: testAndLog(r==KErrNone); sl@0: tempTime.HomeTime(); sl@0: r=TheFs.SetModified(srcCmdFile,tempTime); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EFileAttributes: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KFileAttributes; sl@0: TUint att; sl@0: r=TheFs.Att(srcCmdFile,att); sl@0: testAndLog(r==KErrNone); sl@0: r=TheFs.SetAtt(srcCmdFile,KEntryAttHidden,0); sl@0: testAndLog(r==KErrNone); sl@0: r=TheFs.Att(srcCmdFile,att); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERFsEntry: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRFsEntry; sl@0: TEntry entryDetail; sl@0: r=TheFs.Entry(srcCmdFile,entryDetail); sl@0: testAndLog(r==KErrNone); sl@0: TTime time; sl@0: time.HomeTime(); sl@0: r=TheFs.SetEntry(srcCmdFile, time, KEntryAttHidden, KEntryAttNormal); sl@0: testAndLog(r==KErrNone); sl@0: r=TheFs.Entry(srcCmdFile, entryDetail); sl@0: testAndLog(r==KErrNone); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERFsReplace: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRFsReplace; sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNotFound); sl@0: // r = TheFile.Open(TheFs, trgCmdFile, EFileRead|EFileWrite); sl@0: // testAndLog(r == KErrNone); sl@0: // TheFile.Close(); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case ERFsRename: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KRFsRename; sl@0: if (trgCmdFile.Length() > 0) sl@0: { sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: else sl@0: { sl@0: //trgCmdFile= gSessionPath; sl@0: trgCmdFile[0] = (TUint16)*aParam.iTrgDrvChar; sl@0: } sl@0: TInt len=srcCmdFile.Length(); sl@0: if(srcCmdFile[--len]=='\\') sl@0: { sl@0: r = TheDir.Open(TheFs, srcCmdFile, KEntryAttMaskSupported); sl@0: testAndLog(r == KErrPathNotFound); sl@0: // r = TheDir.Open(TheFs, trgCmdFile, KEntryAttMaskSupported); sl@0: // testAndLog(r == KErrNone); sl@0: // TheDir.Close(); sl@0: } sl@0: else sl@0: { sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNotFound); sl@0: // r = TheFile.Open(TheFs, trgCmdFile, EFileRead|EFileWrite); sl@0: // testAndLog(r == KErrNone); sl@0: // TheFile.Close(); sl@0: } sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EGetDir: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KGetDir; sl@0: CDir *anEntryList; sl@0: r=TheFs.GetDir(srcCmdFile,KEntryAttNormal,ESortByName,anEntryList); sl@0: testAndLog(r==KErrNone); sl@0: delete anEntryList; sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EFileTemp: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KFileTemp; sl@0: TFileName tempFileName; sl@0: r=TheFile.Temp(TheFs,srcCmdFile,tempFileName,EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: TheFile.Close(); sl@0: r = TheFile.Create(TheFs, tempFileName, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrAlreadyExists); sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EReadFromFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KReadFromFile; sl@0: sl@0: TInt start=0, readLen=15, readPos=10; sl@0: TBuf8<200> readBuf; sl@0: TInt numWritten = 50; sl@0: sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: sl@0: if(r==KErrNone) sl@0: { sl@0: r=TheFile.Seek(ESeekStart,start); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: readBuf.SetLength(0); sl@0: r=TheFile.Read(readBuf); sl@0: testAndLog(r == KErrNone); sl@0: testAndLog(numWritten == readBuf.Length()); sl@0: sl@0: //An overload of RFile::Read(), read specified no.of bytes. sl@0: r=TheFile.Seek(ESeekStart,start); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: readBuf.SetLength(0); sl@0: TheFile.Read(readBuf,readLen); sl@0: testAndLog(r == KErrNone); sl@0: testAndLog(readLen == readBuf.Length()); sl@0: sl@0: //An overload of RFile::Read(), read from the specified position. sl@0: readBuf.SetLength(0); sl@0: r=TheFile.Read(readPos,readBuf); sl@0: testAndLog(r == KErrNone); sl@0: testAndLog(numWritten-readPos == readBuf.Length()); sl@0: TheFile.Close(); sl@0: } sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: case EWriteToFile: sl@0: { sl@0: __UHEAP_MARK; sl@0: gLogFailureData.iAPIName = KWriteToFile; sl@0: sl@0: r = TheFile.Open(TheFs, srcCmdFile, EFileRead|EFileWrite); sl@0: testAndLog(r == KErrNone); sl@0: sl@0: if(r==KErrNone) sl@0: { sl@0: TInt writeLen=20, writePos=10, start=0, readLen=0; sl@0: TBuf8<200> writeBuf = _L8("I am going to write something to the file and then read from the specified position to test an overload of RFIle::Read"); sl@0: TInt numWritten = writeBuf.Length(); sl@0: TBuf8<200> readBuf; sl@0: sl@0: TheFile.Write(writeBuf); sl@0: r=TheFile.Flush(); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: r=TheFile.Seek(ESeekStart,start); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: readBuf.SetLength(0); sl@0: r=TheFile.Read(readBuf); sl@0: testAndLog(r==KErrNone); sl@0: readLen = readBuf.Length(); sl@0: testAndLog(numWritten == readLen); sl@0: sl@0: r=TheFile.SetSize(0); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: //An overload of RFile::Write(), write specified no.of bytes. sl@0: TheFile.Write(writeBuf,writeLen); sl@0: r=TheFile.Flush(); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: r=TheFile.Seek(ESeekStart,start); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: readBuf.SetLength(0); sl@0: r=TheFile.Read(readBuf); sl@0: testAndLog(r==KErrNone); sl@0: readLen = readBuf.Length(); sl@0: testAndLog(writeLen==readLen); sl@0: sl@0: r=TheFile.SetSize(0); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: //An overload of RFile::Write(), write to a particular position. sl@0: TBuf8<50> testBuf = _L8("Testing different variants of RFile::Write APIs"); sl@0: TheFile.Write(testBuf); sl@0: r=TheFile.Flush(); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: TheFile.Write(writePos,writeBuf); sl@0: r=TheFile.Flush(); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: r=TheFile.Seek(ESeekStart,start); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: readBuf.SetLength(0); sl@0: r=TheFile.Read(readBuf); sl@0: testAndLog(r==KErrNone); sl@0: readLen = readBuf.Length(); sl@0: testAndLog(numWritten + writePos == readLen); sl@0: sl@0: r=TheFile.SetSize(0); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: //An overload of RFile::Write(), write to a particular position and specified no. of bytes. sl@0: TInt size; sl@0: TheFile.Write(testBuf); sl@0: r=TheFile.Flush(); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: TheFile.Write(writePos,writeBuf,writeLen); sl@0: r=TheFile.Flush(); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: r=TheFile.Seek(ESeekStart,start); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: readBuf.SetLength(0); sl@0: r=TheFile.Read(readBuf); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: TInt newSize = testBuf.Length()-(writePos+writeLen); sl@0: if(newSize < testBuf.Length()) sl@0: { sl@0: size = testBuf.Length(); sl@0: } sl@0: else sl@0: size = newSize; sl@0: readLen = readBuf.Length(); sl@0: testAndLog(readLen==size); sl@0: sl@0: r=TheFile.SetSize(0); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: TheFile.Close(); sl@0: } sl@0: __UHEAP_MARKEND; sl@0: } sl@0: break; sl@0: default: sl@0: break; sl@0: } sl@0: // test.Printf(_L("DataVerification::\tTest case %d passed\n"),aParam.iTestCaseID); sl@0: sl@0: failedOnBuf.Close(); sl@0: tcUniquePath.Close(); sl@0: sl@0: srcCmdFile.Close(); sl@0: trgCmdFile.Close(); sl@0: srcCmd.Close(); sl@0: CheckDisk(); sl@0: } sl@0: sl@0: void DeletePathAfterTest(const TTestParamAll& aParam) sl@0: { sl@0: TFileName path = aParam.iSrcPrsPath; 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: path[0] = (TUint16)*aParam.iSrcDrvChar; sl@0: TInt idx = path.Find(_L("Src\\")); sl@0: path.Delete(idx,path.Length()-idx); sl@0: RmDir(path); sl@0: } sl@0: sl@0: sl@0: /* sl@0: * Do all basic binary test cases defined in gBasicUnitaryTestCases[] sl@0: */ sl@0: void DoAllBasicUnitaryTestsL(const TTestCaseUnitaryBasic aBasicUnitaryTestCaseGroup[], sl@0: TTestSwitches& aSwitches, TBool aIsWithDLL) sl@0: { sl@0: TTestParamAll* nextTestCase = new(ELeave) TTestParamAll(); sl@0: sl@0: TInt i = 0; sl@0: sl@0: // Reset the Test Log Data sl@0: ClearTCLogData(); sl@0: sl@0: while(SearchTestCaseByArrayIdx(i, aBasicUnitaryTestCaseGroup, sl@0: *nextTestCase, aIsWithDLL) == KErrNone) sl@0: { sl@0: TTime startTime; sl@0: TTime endTime; sl@0: startTime.HomeTime(); sl@0: if(aSwitches.iExeOnSymbian || aSwitches.iExeOnWindows) sl@0: { sl@0: DataGenerationL(*nextTestCase); sl@0: DataExecutionL(*nextTestCase, EUnitaryTest); sl@0: } sl@0: if(aSwitches.iVerOnSymbian || aSwitches.iVerOnWindows) sl@0: { sl@0: DataVerificationL(*nextTestCase, EUnitaryTest); sl@0: DeletePathAfterTest(*nextTestCase); sl@0: } sl@0: sl@0: CheckDisk(); sl@0: endTime.HomeTime(); sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: // test.Printf(_L("Test Case Id : %d\n"),(*nextTestCase).iTestCaseID); sl@0: // TInt time=0; sl@0: // time=I64LOW(timeTaken.Int64()/1000); sl@0: // test.Printf(_L("Time Taken by test case %d = %d mS \n"),nextTestCase.iTestCaseID,time); sl@0: ++i; sl@0: } sl@0: delete nextTestCase; sl@0: } sl@0: sl@0: /* sl@0: * Do all basic binary test cases defined in gBasicBinaryTestCases[] sl@0: */ sl@0: void DoAllBasicBinaryTestsL(const TTestCaseBinaryBasic aBasicBinaryTestCaseGroup[], sl@0: TTestSwitches& aSwitches, TBool aIsWithDLL) sl@0: { sl@0: TTestParamAll* nextTestCase = new(ELeave) TTestParamAll(); sl@0: sl@0: TInt i = 0; sl@0: sl@0: // Reset the Test Log Data sl@0: ClearTCLogData(); sl@0: sl@0: while (SearchTestCaseByArrayIdx(i, aBasicBinaryTestCaseGroup, sl@0: *nextTestCase, aIsWithDLL) == KErrNone) sl@0: { sl@0: if (aIsWithDLL) sl@0: { sl@0: if(((aBasicBinaryTestCaseGroup[i].iBasic.iAPI==EGetShortNameWithoutDLL))) sl@0: { sl@0: ++i; sl@0: continue; sl@0: } sl@0: } sl@0: else sl@0: { sl@0: if(((aBasicBinaryTestCaseGroup[i].iBasic.iAPI== EGetShortNameWithDLL) || (aBasicBinaryTestCaseGroup[i].iBasic.iAPI==ELongShortConversion)) ) sl@0: { sl@0: ++i; sl@0: continue; sl@0: } sl@0: } sl@0: TTime startTime; sl@0: TTime endTime; sl@0: startTime.HomeTime(); sl@0: sl@0: if(aSwitches.iExeOnSymbian || aSwitches.iExeOnWindows) sl@0: { sl@0: DataGenerationL(*nextTestCase); sl@0: DataExecutionL(*nextTestCase, EBinaryTest); sl@0: } sl@0: if(aSwitches.iVerOnSymbian || aSwitches.iVerOnWindows) sl@0: { sl@0: DataVerificationL(*nextTestCase, EBinaryTest); sl@0: DeletePathAfterTest(*nextTestCase); sl@0: } sl@0: sl@0: endTime.HomeTime(); sl@0: TTimeIntervalMicroSeconds timeTaken(0); sl@0: timeTaken = endTime.MicroSecondsFrom(startTime); sl@0: sl@0: // test.Printf(_L("Test Case Id : %d\n"),(*nextTestCase).iTestCaseID); sl@0: // TInt time2=0; sl@0: // time2=I64LOW(timeTaken.Int64()/1000); sl@0: // test.Printf(_L("Time Taken by test id %d = %d mS \n"),nextTestCase.iTestCaseID,time2); sl@0: ++i; sl@0: } sl@0: sl@0: delete nextTestCase; sl@0: } sl@0: sl@0: /* sl@0: * Main testing control unit sl@0: */ sl@0: void TestMainWithDLLL(TTestSwitches& aSwitches) sl@0: { sl@0: // Enables codepage dll implementation of LocaleUtils functions for this test only sl@0: TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions); sl@0: test(r == KErrNone); sl@0: sl@0: test.Printf(_L("Load the Code Page DLL")); sl@0: r = UserSvr::ChangeLocale(KTestLocale); sl@0: test(r == KErrNone); sl@0: sl@0: test.Next(_L("Test Unitary APIs with only Sync Variant with DLL")); sl@0: gLogFailureData.iFuncName = KDoAllBasicUnitaryTestsL; sl@0: DoAllBasicUnitaryTestsL(gBasicUnitaryTestCases, aSwitches, ETrue); sl@0: sl@0: test.Next(_L("Test Binary Tests with DLL")); sl@0: gLogFailureData.iFuncName = KDoAllBasicBinaryTestsL; sl@0: DoAllBasicBinaryTestsL(gBasicBinaryTestCases, aSwitches, ETrue); sl@0: sl@0: // Disables codepage dll implementation of LocaleUtils functions for other base tests sl@0: r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions); sl@0: test(r == KErrNone); sl@0: } sl@0: sl@0: void TestMainWithoutDLLL(TTestSwitches& aSwitches) sl@0: { sl@0: test.Next(_L("Test Unitary APIs with only Sync Variant without DLL")); sl@0: sl@0: // Disables codepage dll implementation of LocaleUtils functions sl@0: TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions); sl@0: test(r == KErrNone); sl@0: sl@0: gLogFailureData.iFuncName = KDoAllBasicUnitaryTestsL; sl@0: DoAllBasicUnitaryTestsL(gBasicUnitaryTestCases, aSwitches, EFalse); sl@0: sl@0: test.Next(_L("Test Binary Tests without DLL")); sl@0: gLogFailureData.iFuncName = KDoAllBasicBinaryTestsL; sl@0: DoAllBasicBinaryTestsL(gBasicBinaryTestCases, aSwitches, EFalse); sl@0: } sl@0: sl@0: void TestCompatibility(const TTestSwitches& aSwitches) sl@0: { sl@0: test.Next(_L("test compatibility")); sl@0: sl@0: // logging for failure sl@0: gTCType = ESymbianFATSpecific; sl@0: RBuf failedOnBuf; sl@0: failedOnBuf.CreateL(gLogFailureData.iFuncName); sl@0: gTCId = 0; sl@0: RBuf tcUniquePath; sl@0: tcUniquePath.CreateL(KNone()); sl@0: sl@0: // original file name in DBCS sl@0: TFileName fn1 = _L("\\\x798F\x5C71\x96C5\x6CBB"); sl@0: if (aSwitches.iExeOnSymbian) sl@0: { sl@0: GetBootInfo(); sl@0: RFile file; sl@0: TFileName fn = _L("\\ABCD"); sl@0: sl@0: TInt r=file.Create(TheFs,fn,EFileRead); sl@0: testAndLog(r==KErrNone); sl@0: file.Close(); sl@0: sl@0: // Assume this file is the first entry in the root directory sl@0: r=TheDisk.Open(TheFs,CurrentDrive()); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: //-- read the 1st dir entry, it should be a DOS entry sl@0: const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position sl@0: sl@0: TFatDirEntry fatEntry1; sl@0: TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry)); sl@0: testAndLog(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone); sl@0: testAndLog(!fatEntry1.IsVFatEntry()); sl@0: sl@0: // Manually modify the short name into unicode characters sl@0: // Unicode: 0x(798F 5C71 96C5 6CBB) sl@0: // Shift-JIS: 0x(959F 8E52 89EB 8EA1) sl@0: sl@0: TBuf8<8> unicodeSN = _L8("ABCD1234"); sl@0: unicodeSN[0] = 0x95; sl@0: unicodeSN[1] = 0x9F; sl@0: unicodeSN[2] = 0x8E; sl@0: unicodeSN[3] = 0x52; sl@0: unicodeSN[4] = 0x89; sl@0: unicodeSN[5] = 0xEB; sl@0: unicodeSN[6] = 0x8E; sl@0: unicodeSN[7] = 0xA1; sl@0: sl@0: fatEntry1.SetName(unicodeSN); sl@0: testAndLog(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone); sl@0: TheDisk.Close(); sl@0: } sl@0: if (aSwitches.iVerOnSymbian) sl@0: { sl@0: // Access the file without the DLL loaded. sl@0: TInt r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: TEntry entry; sl@0: r = TheFs.Entry(fn1, entry); sl@0: testAndLog(r==KErrNotFound); sl@0: sl@0: // Access the file with the DLL loaded. sl@0: r = TheFs.ControlIo(CurrentDrive(), KControlIoEnableFatUtilityFunctions); sl@0: testAndLog(r==KErrNone); sl@0: r = UserSvr::ChangeLocale(KTestLocale); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: r = TheFs.Entry(fn1, entry); sl@0: testAndLog(r==KErrNone); sl@0: sl@0: r = TheFs.ControlIo(CurrentDrive(), KControlIoDisableFatUtilityFunctions); sl@0: testAndLog(r==KErrNone); sl@0: } sl@0: failedOnBuf.Close(); sl@0: tcUniquePath.Close(); sl@0: } sl@0: sl@0: #endif //defined(_DEBUG) || defined(_DEBUG_RELEASE) sl@0: sl@0: /* sl@0: * Initialise test sl@0: */ sl@0: void CallTestsL(TTestSwitches& aSwitches) sl@0: { sl@0: test.Title(); sl@0: test.Start(_L("Starting T_FATCHARSETCONV tests")); sl@0: (void) aSwitches; sl@0: #ifdef LOG_FAILURE_DATA sl@0: test.Printf(_L("LOG_FAILURE_DATA: ON\n")); sl@0: #else sl@0: test.Printf(_L("LOG_FAILURE_DATA: OFF\n")); sl@0: #endif sl@0: sl@0: #if defined(_DEBUG) || defined(_DEBUG_RELEASE) sl@0: // Test only runs on Fat file systems sl@0: TheFs.SessionPath(gSessionPath); sl@0: TInt r = TheFs.FileSystemName(aSwitches.iMountedFSName, CurrentDrive()); sl@0: if (KErrNone == r) sl@0: { sl@0: // For automated testing this test should run on FAT file systems only. sl@0: // For inter-operability testing on FAT and Win32 file systems. sl@0: // if ((AUTO && FAT) || (IOT && (FAT || Win32)) sl@0: test.Printf(_L("Current File System: \"%S\"\n"), &aSwitches.iMountedFSName); sl@0: if( (gAutoTest && isFAT(aSwitches.iMountedFSName)) || sl@0: (gIOTesting && (isFAT(aSwitches.iMountedFSName) || isWin32(aSwitches.iMountedFSName)))) sl@0: { sl@0: // Log File System Name sl@0: gLogFailureData.iFSName = aSwitches.iMountedFSName; sl@0: sl@0: // Store current file name sl@0: TFileName fileName; sl@0: TInt i=0; sl@0: while(__FILE__[i]!='\0') sl@0: { sl@0: fileName.SetLength(i+1); sl@0: fileName[i] = __FILE__[i++]; sl@0: } sl@0: gFileName.Append(fileName); sl@0: sl@0: InitialiseL(); sl@0: // Special Cases - Non-Symbian sl@0: // Note: this case MUST be run as the first case as it performs formatting!! sl@0: TestCompatibility(aSwitches); sl@0: CreateTestDirectory(_L("\\F32-TST\\T_FATCHARSETCONV\\")); sl@0: //Special Cases - Only Symbian Specific sl@0: if(!gIOTesting && aSwitches.iMountedFSName.Compare(KFAT) == 0) sl@0: { sl@0: DoSymbianSpecificCases(); sl@0: } sl@0: sl@0: test.Next(_L("Test without DLL loaded")); sl@0: if(gAutoTest) sl@0: { sl@0: QuickFormat(); sl@0: } sl@0: TestMainWithoutDLLL(aSwitches); sl@0: sl@0: test.Next(_L("Test with DLL loaded")); sl@0: if(gAutoTest) sl@0: { sl@0: QuickFormat(); sl@0: } sl@0: TestMainWithDLLL(aSwitches); sl@0: Cleanup(); sl@0: } sl@0: else sl@0: { sl@0: if(gAutoTest) sl@0: test.Printf(_L("Test only runs on \"FAT\" File Systems !!!\n")); sl@0: if(gIOTesting) sl@0: test.Printf(_L("Test only runs on \"FAT\" and \"Win32\" File Systems !!!\n")); sl@0: } sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L("Drive %C: is not ready!\n"), 'A'+CurrentDrive()); sl@0: test(EFalse); sl@0: } sl@0: #else sl@0: test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details.\n")); sl@0: #endif // _DEBUG) || _DEBUG_RELEASE sl@0: test.End(); sl@0: } sl@0: sl@0: LOCAL_C void PushLotsL() sl@0: // sl@0: // Expand the cleanup stack sl@0: // sl@0: { sl@0: TInt i; sl@0: for(i=0;i<1000;i++) sl@0: CleanupStack::PushL((CBase*)NULL); sl@0: CleanupStack::Pop(1000); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void DoTests(TInt aDrive, TTestSwitches& aSwitches) sl@0: // sl@0: // Do testing on aDrive sl@0: // sl@0: { sl@0: gSessionPath=_L("?:\\F32-TST\\"); sl@0: TChar driveLetter; sl@0: TInt r=TheFs.DriveToChar(aDrive,driveLetter); sl@0: test(r==KErrNone); sl@0: gSessionPath[0]=(TText)driveLetter; sl@0: r=TheFs.SetSessionPath(gSessionPath); sl@0: test(r==KErrNone); sl@0: test.Printf(_L("gSessionPath = \"%S\"\n"), &gSessionPath); sl@0: sl@0: // !!! Disable platform security tests until we get the new APIs sl@0: // if(User::Capability() & KCapabilityRoot) sl@0: CheckMountLFFS(TheFs,driveLetter); sl@0: sl@0: User::After(1000000); sl@0: sl@0: // Format(CurrentDrive()); sl@0: sl@0: r=TheFs.MkDirAll(gSessionPath); sl@0: if(r == KErrCorrupt) sl@0: { sl@0: Format(aDrive); sl@0: r=TheFs.MkDirAll(gSessionPath); sl@0: test(r==KErrNone); sl@0: } 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(aSwitches)); 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: TestingLFFS(EFalse); sl@0: } sl@0: sl@0: sl@0: GLDEF_C TInt E32Main() sl@0: // sl@0: // Test with drive nearly full sl@0: // 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 tests...")); sl@0: sl@0: gSessionPath=_L("?:\\F32-TST\\"); sl@0: TTestSwitches testSwitches; sl@0: ParseCommandArguments(testSwitches); sl@0: sl@0: r=TheFs.Connect(); sl@0: test(r==KErrNone); sl@0: TheFs.SetAllocFailure(gAllocFailOn); sl@0: sl@0: TTime timerC; sl@0: timerC.HomeTime(); sl@0: sl@0: TInt theDrive; sl@0: r=TheFs.CharToDrive(gDriveToTest,theDrive); sl@0: test(r==KErrNone); 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: test(r==KErrNone); sl@0: sl@0: test.Printf(_L("\n")); sl@0: test.Printf(_L("Requests on close queue at start=%d\n"),orgValues.iCloseCount); sl@0: test.Printf(_L("Requests on free queue at start=%d\n"),orgValues.iFreeCount); sl@0: test.Printf(_L("Requests dynamically allocated at start=%d\n"),orgValues.iAllocated); sl@0: test.Printf(_L("Requests in total at start=%d\n"),orgValues.iTotalCount); sl@0: #endif sl@0: sl@0: DoTests(theDrive, testSwitches); sl@0: sl@0: TTime endTimeC; sl@0: endTimeC.HomeTime(); sl@0: TTimeIntervalSeconds timeTakenC; sl@0: r=endTimeC.SecondsFrom(timerC,timeTakenC); sl@0: test(r==KErrNone); sl@0: sl@0: test.Printf(_L("Time taken for test = %d seconds\n"),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("Requests on close queue at end=%d\n"),values.iCloseCount); sl@0: test.Printf(_L("Requests on free queue at end=%d\n"),values.iFreeCount); sl@0: test.Printf(_L("Requests dynamically allocated at end=%d\n"),values.iAllocated); sl@0: test.Printf(_L("Requests in total at end=%d\n"),values.iTotalCount); 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: }