sl@0: // Copyright (c) 1995-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_fsrv.cpp sl@0: // sl@0: // sl@0: #define __E32TEST_EXTENSION__ sl@0: #include sl@0: #include sl@0: #include "t_server.h" sl@0: #include "t_chlffs.h" sl@0: sl@0: #include "f32_test_utils.h" sl@0: sl@0: using namespace F32_Test_Utils; sl@0: sl@0: sl@0: RTest test(_L("T_FSRV")); sl@0: sl@0: sl@0: sl@0: const TInt KMaxParses=7; sl@0: const TInt KHeapSize=0x2000; sl@0: TFileName tPath; sl@0: TBool gFirstTime=ETrue; sl@0: const TInt KMaxVolumeName=11; sl@0: sl@0: TInt substDrive=0; sl@0: sl@0: TFileName gTestSessionPath; sl@0: sl@0: TInt LargeFileSize; sl@0: TInt gDrive=-1; sl@0: sl@0: struct SParse sl@0: { sl@0: const TText* src; sl@0: const TText* rel; sl@0: const TText* def; sl@0: const TText* fullName; sl@0: const TText* drive; sl@0: const TText* path; sl@0: const TText* name; sl@0: const TText* ext; sl@0: }; sl@0: sl@0: struct SParseServer sl@0: { sl@0: const TText* src; sl@0: const TText* rel; sl@0: const TText* fullName; sl@0: const TText* drive; sl@0: const TText* path; sl@0: const TText* name; sl@0: const TText* ext; sl@0: }; sl@0: sl@0: LOCAL_D SParse parse[KMaxParses] = sl@0: { sl@0: {_S("A:\\PATH\\NAME.EXT"),NULL,NULL,_S("A:\\PATH\\NAME.EXT"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".EXT")}, sl@0: {_S("A:\\PATH\\NAME"),NULL,NULL,_S("A:\\PATH\\NAME"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S("")}, sl@0: {_S("A:\\PATH\\"),NULL,NULL,_S("A:\\PATH\\"),_S("A:"),_S("\\PATH\\"),_S(""),_S("")}, sl@0: {_S("A:"),NULL,NULL,_S("A:"),_S("A:"),_S(""),_S(""),_S("")}, sl@0: {_S(""),NULL,NULL,_S(""),_S(""),_S(""),_S(""),_S("")}, sl@0: {_S("A:\\PATH\\NAME"),_S("A:\\ZZZZ\\YYYY.XXX"),NULL,_S("A:\\PATH\\NAME.XXX"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".XXX")}, sl@0: {_S("NAME"),_S(".YYY"),_S("A:\\PATH\\"),_S("A:\\PATH\\NAME.YYY"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".YYY")} sl@0: }; sl@0: sl@0: LOCAL_D SParseServer parseServer[KMaxParses] = sl@0: { sl@0: {_S("A:\\PATH\\NAME.EXT"),NULL,_S("A:\\PATH\\NAME.EXT"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".EXT")}, sl@0: {_S("A:\\PATH\\NAME"),NULL,_S("A:\\PATH\\NAME"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S("")}, sl@0: {_S("A:\\PATH\\"),NULL,_S("A:\\PATH\\"),_S("A:"),_S("\\PATH\\"),_S(""),_S("")}, sl@0: {_S("A:"),NULL,_S("A:\\ABCDEF\\"),_S("A:"),_S("\\ABCDEF\\"),_S(""),_S("")}, sl@0: {_S(""),NULL,_S("C:\\ABCDEF\\"),_S("C:"),_S("\\ABCDEF\\"),_S(""),_S("")}, sl@0: {_S("A:\\PATH\\NAME"),_S("A:\\ZZZZ\\YYYY.XXX"),_S("A:\\PATH\\NAME.XXX"),_S("A:"),_S("\\PATH\\"),_S("NAME"),_S(".XXX")}, sl@0: {_S("NAME"),_S(".YYY"),_S("C:\\ABCDEF\\NAME.YYY"),_S("C:"),_S("\\ABCDEF\\"),_S("NAME"),_S(".YYY")} sl@0: }; sl@0: sl@0: LOCAL_C TInt pathTestThread(TAny*) sl@0: // sl@0: // The entry point for the producer thread. sl@0: // sl@0: { sl@0: sl@0: RTest test(_L("Second thread path handling")); sl@0: test.Title(); sl@0: sl@0: test.Start(_L("Path test thread")); sl@0: RFs f; sl@0: TInt r=f.Connect(); sl@0: test(r==KErrNone); sl@0: r=f.SessionPath(tPath); sl@0: test(r==KErrNone); sl@0: f.Close(); sl@0: sl@0: return(KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void printDriveAtt(TInt aDrive,TUint anAtt) sl@0: // sl@0: // Print a drive attribute. sl@0: // sl@0: { sl@0: sl@0: test.Printf(_L("%c: "),aDrive+'A'); sl@0: if (anAtt&KDriveAttLocal) sl@0: test.Printf(_L("LOCAL ")); sl@0: if (anAtt&KDriveAttRom) sl@0: test.Printf(_L("ROM ")); sl@0: if (anAtt&KDriveAttRedirected) sl@0: test.Printf(_L("REDIR ")); sl@0: if (anAtt&KDriveAttSubsted) sl@0: test.Printf(_L("SUBST ")); sl@0: if (anAtt&KDriveAttInternal) sl@0: test.Printf(_L("INTERNAL ")); sl@0: if (anAtt&KDriveAttHidden) sl@0: test.Printf(_L("HIDDEN ")); sl@0: if ((anAtt&KDriveAttRemovable) && !(anAtt&KDriveAttLogicallyRemovable)) sl@0: test.Printf(_L("PHYSICALLYREMOVABLE ")); sl@0: if ((anAtt&KDriveAttRemovable) && (anAtt&KDriveAttLogicallyRemovable)) sl@0: test.Printf(_L("LOGICALLYREMOVABLE ")); sl@0: sl@0: test.Printf(_L("\n")); sl@0: } sl@0: sl@0: LOCAL_C void printDriveInfo(TInt aDrive,TDriveInfo& anInfo) sl@0: // sl@0: // Print a drive info. sl@0: // sl@0: { sl@0: sl@0: printDriveAtt(aDrive,anInfo.iDriveAtt); sl@0: test.Printf(_L(" MEDIA-ATT=")); sl@0: if (anInfo.iMediaAtt==0) sl@0: test.Printf(_L("")); sl@0: if (anInfo.iMediaAtt&KMediaAttVariableSize) sl@0: test.Printf(_L("VariableSize ")); sl@0: if (anInfo.iMediaAtt&KMediaAttDualDensity) sl@0: test.Printf(_L("DualDensity ")); sl@0: if (anInfo.iMediaAtt&KMediaAttFormattable) sl@0: test.Printf(_L("Formattable ")); sl@0: if (anInfo.iMediaAtt&KMediaAttWriteProtected) sl@0: test.Printf(_L("WProtected ")); sl@0: test.Printf(_L("\n CONNECTION BUS=")); sl@0: switch(anInfo.iConnectionBusType) sl@0: { sl@0: case EConnectionBusInternal: test.Printf(_L("Internal\n")); break; sl@0: case EConnectionBusUsb: test.Printf(_L("USB\n")); break; sl@0: default: sl@0: test.Printf(_L("Unknown value\n")); sl@0: } sl@0: test.Printf(_L(" MEDIA=")); sl@0: switch(anInfo.iType) sl@0: { sl@0: case EMediaNotPresent: test.Printf(_L("Not present\n")); break; sl@0: case EMediaUnknown: test.Printf(_L("Unknown\n")); break; sl@0: case EMediaFloppy: test.Printf(_L("Floppy\n")); break; sl@0: case EMediaHardDisk: test.Printf(_L("Hard disk\n")); break; sl@0: case EMediaCdRom: test.Printf(_L("CD Rom\n")); break; sl@0: case EMediaRam: test.Printf(_L("Ram\n")); break; sl@0: case EMediaFlash: test.Printf(_L("Flash\n")); break; sl@0: case EMediaRom: test.Printf(_L("Rom\n")); break; sl@0: case EMediaRemote: test.Printf(_L("Remote\n")); break; sl@0: case EMediaNANDFlash: test.Printf(_L("NANDFlash\n")); break; sl@0: default: sl@0: test.Printf(_L("Unknown value\n")); sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: LOCAL_C void MountRemoteFilesystem() sl@0: { sl@0: test.Next(_L("Mount Remote Drive simulator on Q:")); sl@0: sl@0: TInt r=TheFs.AddFileSystem(_L("CFAFSDLY")); sl@0: test.Printf(_L("Add remote file system")); sl@0: test.Printf(_L("AddFileSystem returned %d\n"),r); sl@0: test_Value(r, r==KErrNone || r==KErrAlreadyExists); sl@0: sl@0: r=TheFs.MountFileSystem(_L("DELAYFS"),EDriveQ); sl@0: sl@0: sl@0: test.Printf(_L("Mount remote file system")); sl@0: test.Printf(_L("MountFileSystem returned %d\n"),r); sl@0: test_Value(r, r==KErrNone || r==KErrCorrupt || r==KErrNotReady || r==KErrAlreadyExists); sl@0: sl@0: } sl@0: sl@0: sl@0: LOCAL_C void DisMountRemoteFilesystem() sl@0: { sl@0: sl@0: test.Printf(_L("Dismounting the remote Drives \n")); sl@0: sl@0: TInt r=TheFs.DismountFileSystem(_L("DELAYFS"),EDriveQ); sl@0: sl@0: test.Printf(_L("Dismounting the Remote Drive returned %d\n"),r); sl@0: sl@0: test(r==KErrNone ); sl@0: } sl@0: sl@0: sl@0: LOCAL_C void CreateSubstDrive() sl@0: { sl@0: test.Printf(_L("Create Substitute Drive \n")); sl@0: sl@0: TDriveList driveList; sl@0: TInt i ; sl@0: sl@0: TInt r=TheFs.SessionPath(gTestSessionPath); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.DriveList(driveList, KDriveAttExclude|KDriveAttLocal); sl@0: test( r==KErrNone ); sl@0: sl@0: sl@0: for ( i = EDriveO; i < KMaxDrives; i++) sl@0: { sl@0: sl@0: if ( driveList[i] == 0) sl@0: { sl@0: if (i == EDriveQ) continue; // Q reserved to mount a virtual Remote Drive, as part of the test. sl@0: substDrive = i; sl@0: break; sl@0: } sl@0: } sl@0: sl@0: sl@0: if (substDrive) sl@0: { sl@0: TDriveInfo driveInfo; sl@0: r=TheFs.Drive(driveInfo,substDrive); sl@0: test(r==KErrNone); sl@0: sl@0: if (driveInfo.iDriveAtt==KDriveAttLocal) sl@0: { sl@0: return; // Subst local drives fails sl@0: } sl@0: sl@0: TFileName n; sl@0: r=TheFs.Subst(n,substDrive); sl@0: test(r==KErrNone); sl@0: test(n.Length()==0); sl@0: r=TheFs.SetSubst(gTestSessionPath,substDrive); sl@0: test(r==KErrNone); sl@0: r=TheFs.Subst(n,substDrive); sl@0: test(r==KErrNone); sl@0: test(n==gTestSessionPath); sl@0: } sl@0: sl@0: sl@0: } sl@0: sl@0: sl@0: LOCAL_C void RemoveSubstDrive() sl@0: { sl@0: if( substDrive) sl@0: { sl@0: test.Printf(_L("Removing Substitute Drive \n")); sl@0: TInt r =TheFs.SetSubst(_L(""),substDrive); sl@0: test(r ==KErrNone); sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: sl@0: LOCAL_C void testDriveInfo(TInt aDrive,TDriveInfo& anInfo) sl@0: // sl@0: // Test the drive info is reasonable sl@0: // sl@0: { sl@0: sl@0: test(anInfo.iConnectionBusType==EConnectionBusInternal || anInfo.iConnectionBusType==EConnectionBusUsb); sl@0: sl@0: if (aDrive==EDriveZ) sl@0: { sl@0: if (anInfo.iType==EMediaNotPresent) sl@0: return; sl@0: sl@0: test(anInfo.iMediaAtt==KMediaAttWriteProtected); sl@0: test(anInfo.iDriveAtt==(KDriveAttRom|KDriveAttInternal)); sl@0: test(anInfo.iType==EMediaRom); sl@0: } sl@0: sl@0: else if (GetDriveLFFS()==aDrive) sl@0: { sl@0: if (anInfo.iType==EMediaNotPresent) sl@0: return; sl@0: sl@0: test(anInfo.iDriveAtt&(KDriveAttLocal|KDriveAttInternal)==KDriveAttLocal|KDriveAttInternal); // LFFS sets KDriveAttTransaction as well sl@0: test(anInfo.iType==EMediaFlash); sl@0: test(anInfo.iMediaAtt==KMediaAttFormattable); sl@0: } sl@0: /* sl@0: Why assume certain drive letters can only refer to certain drive types? sl@0: else if (aDrive==EDriveC || aDrive==EDriveY) sl@0: { sl@0: if (anInfo.iType==EMediaNotPresent) sl@0: return; sl@0: sl@0: // test(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttInternal)); sl@0: sl@0: test(anInfo.iDriveAtt&(KDriveAttLocal|KDriveAttInternal)==KDriveAttLocal|KDriveAttInternal); // LFFS sets KDriveAttTransaction as well sl@0: test(anInfo.iType==EMediaRam || anInfo.iType==EMediaFlash); sl@0: if(anInfo.iType==EMediaRam) test(anInfo.iMediaAtt==(KMediaAttVariableSize|KMediaAttFormattable)); sl@0: else if(anInfo.iType==EMediaFlash) test(anInfo.iMediaAtt==KMediaAttFormattable); sl@0: } sl@0: sl@0: else if (aDrive==EDriveD || aDrive==EDriveX) sl@0: { sl@0: if (anInfo.iType==EMediaNotPresent) sl@0: return; sl@0: sl@0: test(anInfo.iDriveAtt==(KDriveAttLocal|KDriveAttRemovable)); sl@0: test(anInfo.iType==EMediaHardDisk); sl@0: test(anInfo.iMediaAtt & KMediaAttFormattable); sl@0: } sl@0: */ sl@0: } sl@0: sl@0: sl@0: /* sl@0: * The following test has the requirement that the only remote drive is the one we mount sl@0: * during the test and which doesn't have any other attributes set. If this is not the sl@0: * case then the test conditions must be changed, in order for the test to stop failing. sl@0: */ sl@0: sl@0: sl@0: LOCAL_C void testDriveList() sl@0: // sl@0: // Test the drive list. sl@0: // sl@0: { sl@0: sl@0: test.Start(_L("The drive list\n")); sl@0: sl@0: sl@0: TInt err; sl@0: TInt drivecount = 0; sl@0: TDriveList driveList; sl@0: TDriveInfo info; sl@0: TUint flags; sl@0: TInt removableDriveCount =0; sl@0: TInt nonHiddenRemovableDriveCount =0; sl@0: TInt logicallyRemovableDriveCount =0; sl@0: TInt substDriveCount =0; sl@0: TInt exclusiveSubstDriveCount =0; sl@0: TInt hiddenDriveCount = 0; sl@0: TInt hiddenOrRemoteDriveCount = 0; sl@0: sl@0: TInt i ; sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0544 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909, CR1086 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList) does not return remote or hidden drives. sl@0: //! @SYMTestActions Call DriveList to get the drive list. sl@0: //! @SYMTestExpectedResults Check that no remote or hidden drive was returned. Count the number of drives we got sl@0: //! and seperately the number of none hidden removable ones. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: test.Printf(_L("Test existing DriveList \n")); sl@0: sl@0: err = TheFs.DriveList(driveList); sl@0: test( err == KErrNone ); sl@0: sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info, i); sl@0: test( err == KErrNone ); sl@0: test( info.iType != EMediaRemote ); sl@0: test( !(info.iDriveAtt & KDriveAttRemote ) ); sl@0: test( !(info.iDriveAtt & KDriveAttHidden ) ); sl@0: drivecount++; sl@0: sl@0: if( info.iDriveAtt & KDriveAttRemovable) sl@0: nonHiddenRemovableDriveCount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: sl@0: } sl@0: sl@0: } sl@0: sl@0: sl@0: TInt nonHiddenNonRemovables = drivecount - nonHiddenRemovableDriveCount; sl@0: test.Printf(_L("Found %d non hidden non removable drives\n"), nonHiddenNonRemovables); sl@0: test.Printf(_L("Found %d non hidden removable drives \n"),nonHiddenRemovableDriveCount); sl@0: sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0545 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909, CR1086 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to return all sl@0: //! available drives, including the remote and the hidden ones. sl@0: //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttAll. sl@0: //! @SYMTestExpectedResults Check that the number of drives is increased by the number of hidden and remote drives and also that the number of remote drives is one (one remote drive we mounted). sl@0: //! Also count the number of substitute, exclusively substitute, removable, physically removable and logically removable drives. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: test.Printf(_L("Return all available drives\n")); sl@0: sl@0: TInt allDrivecount = 0; sl@0: flags = KDriveAttAll; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: sl@0: test( err == KErrNone ); sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info,i); sl@0: test( err == KErrNone ); sl@0: allDrivecount++; sl@0: sl@0: if( info.iDriveAtt & KDriveAttSubsted ) sl@0: substDriveCount++; sl@0: sl@0: if( info.iDriveAtt == KDriveAttSubsted) sl@0: exclusiveSubstDriveCount++; sl@0: sl@0: if( info.iDriveAtt & KDriveAttHidden) sl@0: hiddenDriveCount++; sl@0: sl@0: if( info.iDriveAtt & (KDriveAttHidden|KDriveAttRemote)) sl@0: hiddenOrRemoteDriveCount++; sl@0: sl@0: if( info.iDriveAtt & KDriveAttRemovable) sl@0: removableDriveCount++; sl@0: sl@0: if( info.iDriveAtt & KDriveAttLogicallyRemovable) sl@0: logicallyRemovableDriveCount++; sl@0: sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: } sl@0: sl@0: test(allDrivecount == drivecount + hiddenOrRemoteDriveCount); sl@0: test(hiddenOrRemoteDriveCount - hiddenDriveCount == 1); sl@0: sl@0: test.Printf(_L("Found %d substitute drives\n"), substDriveCount); sl@0: test.Printf(_L("Found %d exclusively substitute drives \n"),exclusiveSubstDriveCount); sl@0: test.Printf(_L("Found %d hidden drives\n"), hiddenDriveCount); sl@0: sl@0: TInt nonRemovables = drivecount - removableDriveCount; sl@0: TInt physicallyRemovable = removableDriveCount - logicallyRemovableDriveCount; sl@0: test.Printf(_L("Found %d non removables drives\n"), nonRemovables); sl@0: test.Printf(_L("Found %d physically removable drives \n"),physicallyRemovable); sl@0: test.Printf(_L("Found %d logically removable drives \n"),logicallyRemovableDriveCount); sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0546 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to specify sl@0: //! certain attributes that drives to be returned should have. sl@0: //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttRemovable. sl@0: //! @SYMTestExpectedResults Check that the number of drives returned is the same, since no removable drive was added. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: test.Printf(_L("Return only Removable \n")); sl@0: sl@0: drivecount = 0; sl@0: sl@0: flags = KDriveAttRemovable; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: test( err == KErrNone ); sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info, i); sl@0: test( err == KErrNone ); sl@0: test( info.iDriveAtt & KDriveAttRemovable ); sl@0: drivecount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: sl@0: } sl@0: sl@0: test( drivecount == removableDriveCount ); // no removable drive was added sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0547 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to specify sl@0: //! certain attributes(as a combination)that drives to be returned should have. sl@0: //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttRemovable | KDriveAttRemote sl@0: //! @SYMTestExpectedResults Check that the number of drives is increased by one, since we also allow remote drives. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: test.Printf(_L("Return only Removable and Remote \n")); sl@0: sl@0: drivecount = 0; sl@0: flags = KDriveAttRemovable | KDriveAttRemote; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: test( err == KErrNone ); sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info, i); sl@0: test( err == KErrNone ); sl@0: test( (info.iDriveAtt & KDriveAttRemovable ) || (info.iDriveAtt & KDriveAttRemote)); sl@0: drivecount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: sl@0: } sl@0: sl@0: } sl@0: test( drivecount == removableDriveCount + 1 ); //contains the remote drive we mounted sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0548 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclusively sl@0: //! return drives with certain attributes. sl@0: //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttExclusive | KDriveAttRemote. sl@0: //! @SYMTestExpectedResults Check that only the remote drive that was mounted is returned. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: test.Printf(_L("Return Exclusively Remote drives \n")); sl@0: sl@0: drivecount = 0; sl@0: flags = KDriveAttExclusive | KDriveAttRemote; sl@0: TUint match = KDriveAttRemote; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: test( err == KErrNone ); sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info, i); sl@0: test( err == KErrNone ); sl@0: test( (info.iDriveAtt == match)); sl@0: drivecount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: sl@0: } sl@0: test( drivecount == 1 ); //The remote drive we mounted. sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0549 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclude drives sl@0: //! to be returned with certain attributes. sl@0: //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttExclude | KDriveAttRemovable. sl@0: //! @SYMTestExpectedResults Check that the remote drive we mounted is included as a non removable one. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: test.Printf(_L("Exclude Removable\n")); sl@0: sl@0: drivecount = 0; sl@0: flags = KDriveAttExclude | KDriveAttRemovable; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: test( err == KErrNone ); sl@0: for (i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info, i); sl@0: test( err == KErrNone ); sl@0: test( (!(info.iDriveAtt & KDriveAttRemovable ) )); sl@0: drivecount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: sl@0: } sl@0: test ( drivecount == allDrivecount - removableDriveCount); sl@0: test ( drivecount == nonRemovables + hiddenDriveCount + 1) ; //The remote drive we added is non removable sl@0: sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0550 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can be used to exclude sl@0: //! drives to be returned with certain attributes(as a combination). sl@0: //! @SYMTestActions Call DriveList by passing to aFlags a value of sl@0: //! KDriveAttExclude | KDriveAttRemovable | KDriveAttRemote. sl@0: //! @SYMTestExpectedResults Test that only the remote drive that was mounted is returned. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: sl@0: test.Printf(_L("Exclude Removable and Remote\n")); sl@0: sl@0: drivecount = 0; sl@0: flags = KDriveAttExclude | KDriveAttRemovable | KDriveAttRemote; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: sl@0: test( err == KErrNone ); sl@0: sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info,i); sl@0: test( err == KErrNone ); sl@0: test( (!(info.iDriveAtt & KDriveAttRemovable ) && (!(info.iDriveAtt & KDriveAttRemote )))); sl@0: drivecount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: } sl@0: test(drivecount == (allDrivecount - removableDriveCount - 1) ); // also excluding the removables and the remote drive sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0551 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909 sl@0: //! @SYMTestCaseDesc Test RFs::DriveList(TDriveList& aList, TUint aFlags) with substitute drives. sl@0: //! @SYMTestActions Call DriveList by passing to aFlags combinations of attributes that exclude, exclusive or sl@0: //! not substitute drives. sl@0: //! @SYMTestExpectedResults Test that only the appropriate drives are returned. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: sl@0: if (substDrive) sl@0: { sl@0: sl@0: sl@0: test.Printf(_L("Exclude Remote and Substed\n")); sl@0: sl@0: drivecount = 0; sl@0: flags = KDriveAttExclude | KDriveAttRemote | KDriveAttSubsted; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: sl@0: test( err == KErrNone ); sl@0: sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info,i); sl@0: test( err == KErrNone ); sl@0: test( (!(info.iDriveAtt & KDriveAttRemote ) && (!(info.iDriveAtt & KDriveAttSubsted )))); sl@0: drivecount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: } sl@0: test(drivecount == (allDrivecount - substDriveCount- 1) ); sl@0: sl@0: sl@0: sl@0: test.Printf(_L("Exclusively Exclude Substed drives\n")); sl@0: sl@0: drivecount = 0; sl@0: flags = KDriveAttExclusive | KDriveAttExclude | KDriveAttSubsted; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: sl@0: test( err == KErrNone ); sl@0: sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info,i); sl@0: test( err == KErrNone ); sl@0: test( info.iDriveAtt != KDriveAttSubsted ); sl@0: drivecount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: sl@0: } sl@0: sl@0: test(drivecount == (allDrivecount - exclusiveSubstDriveCount) ); sl@0: sl@0: } sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0552 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR909 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) returns the correct value for every sl@0: //! combination of matching mask. sl@0: //! @SYMTestActions Call DriveList for every combination of mask and check that the correct value is returned. sl@0: //! A structure is used to store the expected value for each combination. sl@0: //! @SYMTestExpectedResults Test for every combination that only drives with the correct attributes are retruned. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: sl@0: test.Printf(_L("Test All Combinations \n")); sl@0: sl@0: struct TCombinations sl@0: { sl@0: TUint iMatchMask; // The Match Mask to be combined with drive attributes sl@0: TInt iExpectedResultNoAtts; // Expected result when flag used on it's own sl@0: TInt iExpectedResultWithAtts; // Expected result when flag used in combination with drive flags sl@0: }; sl@0: sl@0: TCombinations testCombinations[] = { sl@0: { 0, KErrNone, KErrNone}, sl@0: { KDriveAttAll, KErrNone, KErrArgument }, sl@0: { KDriveAttExclude, KErrArgument, KErrNone }, sl@0: { KDriveAttExclusive, KErrArgument, KErrNone }, sl@0: { KDriveAttExclude | KDriveAttExclusive, KErrArgument, KErrNone }, sl@0: { KDriveAttAll | KDriveAttExclude, KErrArgument, KErrArgument }, sl@0: { KDriveAttAll | KDriveAttExclusive, KErrArgument, KErrArgument}, sl@0: { KDriveAttAll | KDriveAttExclude | KDriveAttExclusive, KErrArgument, KErrArgument}}; sl@0: sl@0: TDriveList fullDriveList; sl@0: err = TheFs.DriveList(fullDriveList, KDriveAttAll); sl@0: test( err == KErrNone ); sl@0: sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info,i); sl@0: test( err == KErrNone ); sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: } sl@0: sl@0: for(TUint matchIdx = 0; matchIdx < sizeof(testCombinations) / sizeof(TCombinations); matchIdx++) sl@0: { sl@0: test.Printf(_L("\nMatch Flags: KDriveAttAll[%c] KDriveAttExclude[%c] KDriveAttExclusive[%c]\n"), testCombinations[matchIdx].iMatchMask & KDriveAttAll ? 'X' : ' ', sl@0: testCombinations[matchIdx].iMatchMask & KDriveAttExclude ? 'X' : ' ', sl@0: testCombinations[matchIdx].iMatchMask & KDriveAttExclusive ? 'X' : ' '); sl@0: sl@0: for(TUint testAtt = 0; testAtt <= KMaxTUint8; testAtt++) sl@0: { sl@0: TDriveList newDriveList; sl@0: err = TheFs.DriveList(newDriveList, testCombinations[matchIdx].iMatchMask | testAtt); sl@0: sl@0: //test.Printf(_L(" ATT : 0x%08x \n"), testAtt); sl@0: //test.Printf(_L("Expected Result : %d \n"), testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts); sl@0: //test.Printf(_L(" Actual Result : 0x%08x \n"), err); sl@0: sl@0: test( err == (testAtt == 0 ? testCombinations[matchIdx].iExpectedResultNoAtts : testCombinations[matchIdx].iExpectedResultWithAtts) ); sl@0: sl@0: if(err == KErrNone) sl@0: { sl@0: //printDriveAtt(0, testAtt); //Prints attributes sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: TBool expectMatch = EFalse; sl@0: sl@0: switch(testCombinations[matchIdx].iMatchMask) sl@0: { sl@0: case 0: sl@0: expectMatch = (fullDriveList[i] & testAtt) != 0; sl@0: break; sl@0: sl@0: case KDriveAttAll: sl@0: expectMatch = ETrue; sl@0: break; sl@0: sl@0: case KDriveAttExclude : sl@0: expectMatch = (fullDriveList[i] & testAtt) == 0; sl@0: break; sl@0: sl@0: case KDriveAttExclusive : sl@0: expectMatch = (fullDriveList[i] == testAtt); sl@0: break; sl@0: sl@0: case KDriveAttExclude | KDriveAttExclusive: sl@0: expectMatch = (fullDriveList[i] != testAtt); sl@0: break; sl@0: sl@0: case KDriveAttAll | KDriveAttExclude : sl@0: test(0); // Invalid - should never get here as this returns KErrArgument for all cases sl@0: break; sl@0: sl@0: case KDriveAttAll | KDriveAttExclusive : sl@0: test(0); // Invalid - should never get here as this returns KErrArgument for all cases sl@0: break; sl@0: sl@0: case KDriveAttAll | KDriveAttExclude | KDriveAttExclusive : sl@0: test(0); // Invalid - should never get here as this returns KErrArgument for all cases sl@0: break; sl@0: sl@0: default: sl@0: test.Printf(_L("Unexpected Match Mask %08x"), testCombinations[matchIdx].iMatchMask); sl@0: test(0); sl@0: break; sl@0: } sl@0: sl@0: if(expectMatch) sl@0: { sl@0: //test.Printf(_L(" %c MATCHED OK "), 'A' + i); sl@0: test(newDriveList[i] == fullDriveList[i]); sl@0: } sl@0: else sl@0: { sl@0: /*if(fullDriveList[i] == 0) sl@0: { sl@0: test.Printf(_L(" %c NOT PRESENT "), 'A' + i); sl@0: } sl@0: else sl@0: { sl@0: test.Printf(_L(" %c NOT MATCHED "), 'A' + i); sl@0: } sl@0: */ sl@0: test(newDriveList[i] == 0); sl@0: } sl@0: } sl@0: } sl@0: } sl@0: } sl@0: sl@0: sl@0: sl@0: //--------------------------------------------- sl@0: //! @SYMTestCaseID PBASE-T_FSRV-0605 sl@0: //! @SYMTestType UT sl@0: //! @SYMREQ CR1086 sl@0: //! @SYMTestCaseDesc Test that RFs::DriveList(TDriveList& aList, TUint aFlags) can identify the sl@0: //! logically removable drives. sl@0: //! @SYMTestActions Call DriveList by passing to aFlags a value of KDriveAttLogicallyRemovable. sl@0: //! @SYMTestExpectedResults Check that only the logically removable drives specified in estart.txt are returned. sl@0: //! @SYMTestPriority High sl@0: //! @SYMTestStatus Implemented sl@0: //--------------------------------------------- sl@0: sl@0: test.Printf(_L("Return only Logically Removable drives \n")); sl@0: sl@0: drivecount = 0; sl@0: flags = KDriveAttLogicallyRemovable; sl@0: err = TheFs.DriveList(driveList, flags); sl@0: test( err == KErrNone ); sl@0: for ( i = 0; i < KMaxDrives; i++) sl@0: { sl@0: if (driveList[i]) sl@0: { sl@0: err = TheFs.Drive(info, i); sl@0: test( err == KErrNone ); sl@0: test( info.iDriveAtt & KDriveAttLogicallyRemovable ); sl@0: drivecount++; sl@0: sl@0: printDriveAtt(i,info.iDriveAtt); sl@0: } sl@0: sl@0: } sl@0: sl@0: test( drivecount == logicallyRemovableDriveCount ); // no logically removable drive was added sl@0: sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: sl@0: LOCAL_C void testDriveInfo() sl@0: // sl@0: // Test the drive info. sl@0: // sl@0: { sl@0: sl@0: test.Start(_L("The drive info")); sl@0: TDriveList list; sl@0: TInt r=TheFs.DriveList(list); sl@0: test(r==KErrNone); sl@0: for (TInt i=0;i uBuf(KMaxVolumeName); sl@0: uBuf.FillZ(); sl@0: uBuf[0]='a'; sl@0: uBuf[1]=0x100; sl@0: uBuf[2]='b'; sl@0: uBuf[3]=0x101; sl@0: uBuf[4]='c'; sl@0: uBuf[5]=0x102; sl@0: uBuf[6]='d'; sl@0: uBuf[7]=0x103; sl@0: uBuf[8]='e'; sl@0: uBuf[9]=0x104; sl@0: uBuf[10]='f'; sl@0: r=TheFs.SetVolumeLabel(uBuf,driveNum); sl@0: test(r==KErrNone); sl@0: TFileName drive=_L("?:"); sl@0: drive[0]=gSessionPath[0]; sl@0: sl@0: // ??? this needs to be replaced sl@0: // UserSvr::ForceRemountMedia(ERemovableMedia0); sl@0: User::After(1000000); sl@0: sl@0: TFileName sess; sl@0: r=TheFs.SessionPath(sess); sl@0: test(r==KErrNone); sl@0: r=TheFs.Volume(v,driveNum); sl@0: test(r==KErrNone); sl@0: sl@0: if(Is_Fat(TheFs, gDrive)) //-- FAT doesn't support normal UNICODE in volume labels sl@0: test(v.iName==_L("a_b_c_d_e_f")); sl@0: else sl@0: test(v.iName == uBuf); sl@0: sl@0: sl@0: test.Printf(_L("VOL=\"%S\"\n"),&v.iName); sl@0: sl@0: sl@0: test.Next(_L("Set volume label back to nothing")); sl@0: r=TheFs.SetVolumeLabel(_L(""),driveNum); sl@0: test(r==KErrNone); sl@0: r=TheFs.Volume(v,driveNum); sl@0: test(r==KErrNone); sl@0: test(v.iName==_L("")); sl@0: test.Printf(_L("VOL=\"%S\"\n"),&v.iName); sl@0: sl@0: test.Next(_L("Attempt to set volume label containing illegal characters")); sl@0: r=TheFs.SetVolumeLabel(_L("abc>def"),driveNum); sl@0: test(r==KErrBadName); sl@0: r=TheFs.SetVolumeLabel(_L("ghi*jkl"),driveNum); sl@0: test(r==KErrBadName); sl@0: r=TheFs.SetVolumeLabel(_L("mno?pqr"),driveNum); sl@0: test(r==KErrBadName); sl@0: r=TheFs.SetVolumeLabel(_L("stu|vwx"),driveNum); sl@0: test(r==KErrBadName); sl@0: r=TheFs.SetVolumeLabel(_L("yz=50 && dateTime.Second()<=51); // Dos stores seconds %2 sl@0: sl@0: r=f.Modified(checkTime); sl@0: test(r==KErrNone); sl@0: sl@0: dateTime=checkTime.DateTime(); sl@0: test(dateTime.Year()==1997); sl@0: test(dateTime.Month()==EJanuary); sl@0: test(dateTime.Day()==1); sl@0: test(dateTime.Hour()==2); sl@0: test(dateTime.Minute()==55); sl@0: test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 sl@0: f.Close(); sl@0: sl@0: r=TheFs.Modified(_L("\\F32-TST\\TFSRV\\T_FSRV.CPP"),checkTime); sl@0: test(r==KErrNone); sl@0: sl@0: dateTime=checkTime.DateTime(); sl@0: test(dateTime.Year()==1997); sl@0: test(dateTime.Month()==EJanuary); sl@0: test(dateTime.Day()==1); sl@0: test(dateTime.Hour()==2); sl@0: test(dateTime.Minute()==55); sl@0: test(dateTime.Second()>=50 && dateTime.Second()<=51); // Dos stores seconds %2 sl@0: test.End(); sl@0: } sl@0: sl@0: LOCAL_C void testName() sl@0: // sl@0: // Test the Modified/SetModified functions. sl@0: // sl@0: { sl@0: test.Start(_L("Test file name functions")); sl@0: sl@0: sl@0: _LIT(KFileNameAndPath, "\\F32-TST\\TFSRV\\T_FSRV.CPP"); sl@0: _LIT(KFileName, "T_FSRV.CPP"); sl@0: sl@0: RFile file; sl@0: sl@0: TInt r=file.Open(TheFs, KFileName, 0 ); sl@0: if (r!=KErrNone) sl@0: { sl@0: test.Printf(_L("Error %d opening file %S\n"), r, &KFileName); sl@0: test(0); sl@0: } sl@0: sl@0: TFileName fileName; sl@0: sl@0: // Check RFile::Name just retuns the file name, without path and drive sl@0: r=file.Name(fileName); sl@0: test(r==KErrNone); sl@0: test(fileName==KFileName()); sl@0: sl@0: // Check RFile::FullName returns the complete file name and path sl@0: r=file.FullName(fileName); sl@0: test(r==KErrNone); sl@0: test(fileName.Mid(2)==KFileNameAndPath); // chop off drive letter + ':' sl@0: sl@0: file.Close(); sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: LOCAL_C TInt CreateFileX(const TDesC& aBaseName,TInt aX) sl@0: // sl@0: // Create a large file. Return KErrEof or KErrNone sl@0: // sl@0: { sl@0: sl@0: TBuf<128> fileName=aBaseName; sl@0: fileName.AppendNum(aX); sl@0: RFile file; sl@0: sl@0: TInt r=file.Replace(TheFs,fileName,EFileWrite); sl@0: if (r==KErrDiskFull) sl@0: return(r); sl@0: if (r!=KErrNone) sl@0: { sl@0: test.Printf(_L("ERROR:: Replace returned %d\n"),r); sl@0: test(0); sl@0: //test.Getch(); sl@0: return(KErrDiskFull); sl@0: } sl@0: sl@0: if (!IsTestingLFFS()) sl@0: r=file.SetSize(LargeFileSize); sl@0: else sl@0: { // ??? Whats wrong with setsize sl@0: TBuf8<1024> testdata(1024); sl@0: TInt count=(LargeFileSize/testdata.Length()); sl@0: r=KErrNone; sl@0: while (count-- && r==KErrNone) sl@0: r=file.Write(testdata); sl@0: } sl@0: if (r==KErrDiskFull) sl@0: { sl@0: file.Close(); sl@0: return(r); sl@0: } sl@0: if (r!=KErrNone) sl@0: { sl@0: test.Printf(_L("ERROR:: SetSize/Write returned %d\n"),r); sl@0: test(0); sl@0: //test.Getch(); sl@0: file.Close(); sl@0: return(KErrDiskFull); sl@0: } sl@0: sl@0: file.Close(); sl@0: // r=TheFs.CheckDisk(fileName); sl@0: // if (r!=KErrNone && r!=KErrNotSupported) sl@0: // { sl@0: // test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); sl@0: // test.Getch(); sl@0: // return(KErrDiskFull); sl@0: // } sl@0: test.Printf(_L("Created file %d size %d\n"),aX,LargeFileSize); sl@0: return(KErrNone); sl@0: } sl@0: sl@0: LOCAL_C TInt DeleteFileX(TBuf<128>& aBaseName,TInt aX) sl@0: // sl@0: // Delete a file. sl@0: // sl@0: { sl@0: sl@0: TBuf<128> fileName=aBaseName; sl@0: fileName.AppendNum(aX); sl@0: TInt r=TheFs.Delete(fileName); sl@0: test(r==KErrNone); sl@0: // r=TheFs.CheckDisk(fileName); sl@0: // if (r!=KErrNone && r!=KErrNotSupported) sl@0: // { sl@0: // test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); sl@0: // test(r==KErrNone); sl@0: // } sl@0: test.Printf(_L("Deleted File %d\n"),aX); sl@0: return(KErrNone); sl@0: } sl@0: sl@0: LOCAL_C void MakeAndDeleteFiles() sl@0: // sl@0: // Create and delete large files in a randomish order sl@0: // sl@0: { sl@0: sl@0: test.Start(_L("Create and delete large files")); sl@0: TInt r=TheFs.MkDirAll(_L("\\F32-TST\\SMALLDIRECTORY\\")); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: TBuf<128> fileName=_L("\\F32-TST\\SMALLDIRECTORY\\FILE"); sl@0: r=CreateFileX(fileName,0); sl@0: test(r==KErrNone); sl@0: r=CreateFileX(fileName,1); sl@0: test(r==KErrNone); sl@0: r=DeleteFileX(fileName,0); sl@0: test(r==KErrNone); sl@0: r=CreateFileX(fileName,2); sl@0: test(r==KErrNone); sl@0: r=CreateFileX(fileName,1); sl@0: test(r==KErrNone); sl@0: r=CreateFileX(fileName,3); sl@0: test(r==KErrNone); sl@0: r=DeleteFileX(fileName,1); sl@0: test(r==KErrNone); sl@0: r=CreateFileX(fileName,4); sl@0: test(r==KErrNone); sl@0: r=DeleteFileX(fileName,2); sl@0: test(r==KErrNone); sl@0: r=DeleteFileX(fileName,3); sl@0: test(r==KErrNone); sl@0: r=DeleteFileX(fileName,4); sl@0: test(r==KErrNone); sl@0: r=CreateFileX(fileName,1); sl@0: test(r==KErrNone); sl@0: r=DeleteFileX(fileName,1); sl@0: test(r==KErrNone); sl@0: sl@0: r=TheFs.CheckDisk(fileName); sl@0: if (r!=KErrNone && r!=KErrNotSupported) sl@0: { sl@0: test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); sl@0: test(0); sl@0: //test.Getch(); sl@0: } sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: LOCAL_C void FillUpDisk() sl@0: // sl@0: // Test that a full disk is ok sl@0: // sl@0: { sl@0: sl@0: test.Start(_L("Fill disk to capacity")); sl@0: TInt r=TheFs.MkDirAll(_L("\\F32-TST\\BIGDIRECTORY\\")); sl@0: test(r==KErrNone || r==KErrAlreadyExists); sl@0: TInt count=0; sl@0: TFileName sessionPath; sl@0: r=TheFs.SessionPath(sessionPath); sl@0: test(r==KErrNone); sl@0: TBuf<128> fileName=_L("\\F32-TST\\BIGDIRECTORY\\FILE"); sl@0: FOREVER sl@0: { sl@0: TInt r=CreateFileX(fileName,count); sl@0: if (r==KErrDiskFull) sl@0: break; sl@0: test(r==KErrNone); sl@0: count++; sl@0: #if defined(__WINS__) sl@0: if (count==32 && sessionPath[0]=='C') sl@0: break; sl@0: #endif sl@0: } sl@0: sl@0: r=TheFs.CheckDisk(fileName); sl@0: if (r!=KErrNone && r!=KErrNotSupported) sl@0: { sl@0: test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); sl@0: test(0); sl@0: //test.Getch(); sl@0: } sl@0: sl@0: while(count--) sl@0: DeleteFileX(fileName,count); sl@0: sl@0: r=TheFs.CheckDisk(fileName); sl@0: if (r!=KErrNone && r!=KErrNotSupported) sl@0: { sl@0: test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r); sl@0: test(0); sl@0: //test.Getch(); sl@0: } sl@0: sl@0: test.End(); sl@0: } sl@0: sl@0: LOCAL_C void CopyFileToTestDirectory() sl@0: // sl@0: // Make a copy of the file in ram sl@0: // sl@0: { sl@0: sl@0: TFileName fn = _L("Z:\\TEST\\T_FSRV.CPP"); sl@0: fn[0] = gExeFileName[0]; sl@0: TParse f; sl@0: TInt r=TheFs.Parse(fn,f); sl@0: test(r==KErrNone); sl@0: test.Next(_L("Copying file to test directory")); sl@0: TParse fCopy; sl@0: r=TheFs.Parse(f.NameAndExt(),fCopy); sl@0: test(r==KErrNone); sl@0: sl@0: RFile f1; sl@0: r=f1.Open(TheFs,f.FullName(),EFileStreamText|EFileShareReadersOnly); sl@0: test(r==KErrNone); sl@0: RFile f2; sl@0: r=f2.Replace(TheFs,fCopy.FullName(),EFileWrite); sl@0: test(r==KErrNone); sl@0: TBuf8<512> copyBuf; sl@0: TInt rem; sl@0: r=f1.Size(rem); sl@0: test(r==KErrNone); sl@0: TInt pos=0; sl@0: while (rem) sl@0: { sl@0: TInt s=Min(rem,copyBuf.MaxSize()); sl@0: r=f1.Read(pos,copyBuf,s); sl@0: test(r==KErrNone); sl@0: test(copyBuf.Length()==s); sl@0: r=f2.Write(pos,copyBuf,s); sl@0: test(r==KErrNone); sl@0: pos+=s; sl@0: rem-=s; sl@0: } sl@0: f1.Close(); sl@0: f2.Close(); sl@0: } sl@0: sl@0: sl@0: //--------------------------------------------------------------------------- sl@0: sl@0: /** sl@0: test RFs::SetErrorCondition() aspects sl@0: */ sl@0: void TestSetErrorCondition() sl@0: { sl@0: #ifdef _DEBUG sl@0: sl@0: test.Next(_L("TestSetErrorCondition\n")); sl@0: sl@0: _LIT(KFileName, "\\A.swf"); sl@0: sl@0: TInt nRes; sl@0: RFile file; sl@0: RFile file1; sl@0: sl@0: const TInt KMyError = -756; //-- specific error code we will simulate sl@0: sl@0: //========== just create a file sl@0: nRes = TheFs.SetErrorCondition(KMyError,0); //-- set up FS error simulation sl@0: test(nRes == KErrNone); sl@0: sl@0: //-- this shall fail immediately sl@0: nRes = file.Replace(TheFs, KFileName, EFileWrite); sl@0: test(nRes == KMyError); sl@0: sl@0: nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation sl@0: file.Close(); sl@0: sl@0: //========== create file & duplicate a handle #1 sl@0: nRes = TheFs.SetErrorCondition(KMyError,1); //-- set up FS error simulation sl@0: test(nRes == KErrNone); sl@0: sl@0: //-- this shall succeed sl@0: nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 0 sl@0: test(nRes == KErrNone); sl@0: sl@0: //-- this shall fail inside RFile::Duplicate() half way through in the RFile::DuplicateHandle() sl@0: nRes = file1.Duplicate(file); sl@0: test(nRes == KMyError); sl@0: file1.Close(); sl@0: sl@0: nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation sl@0: file.Close(); sl@0: sl@0: //-- check that the file isn't locked sl@0: nRes = TheFs.Delete(KFileName); sl@0: test(nRes == KErrNone); sl@0: sl@0: //========== create file & duplicate a handle #2 sl@0: nRes = TheFs.SetErrorCondition(KMyError,2); //-- set up FS error simulation sl@0: test(nRes == KErrNone); sl@0: sl@0: //-- this shall succeed sl@0: nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 1 sl@0: test(nRes == KErrNone); sl@0: sl@0: //-- this must not fail, because EFsFileAdopt is excluded from the erros simulation sl@0: nRes = file1.Duplicate(file); sl@0: test(nRes == KErrNone); sl@0: file1.Close(); sl@0: sl@0: nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation sl@0: file.Close(); sl@0: sl@0: //-- check that the file isn't locked sl@0: nRes = TheFs.Delete(KFileName); sl@0: test(nRes == KErrNone); sl@0: sl@0: //========== crazy loop, for DEF103757 sl@0: sl@0: for(TInt i=0; i<6; ++i) sl@0: { sl@0: nRes = TheFs.SetErrorCondition(KMyError,i); //-- set up FS error simulation sl@0: sl@0: nRes = file.Replace(TheFs, KFileName, EFileWrite); //-- err cnt -> 1 sl@0: if(nRes != KErrNone) sl@0: continue; sl@0: sl@0: nRes = file1.Duplicate(file); sl@0: sl@0: file1.Close(); sl@0: file.Close(); sl@0: sl@0: nRes = TheFs.SetErrorCondition(KErrNone); //-- disable FS error simulation sl@0: } sl@0: sl@0: //-- check that the file isn't locked sl@0: nRes = TheFs.Delete(KFileName); sl@0: test(nRes == KErrNone); sl@0: sl@0: sl@0: #endif sl@0: } sl@0: sl@0: //--------------------------------------------------------------------------- sl@0: sl@0: GLDEF_C void CallTestsL() sl@0: // sl@0: // Test the file server. sl@0: // sl@0: { sl@0: sl@0: //-- set up console output sl@0: F32_Test_Utils::SetConsole(test.Console()); sl@0: sl@0: TInt nRes=TheFs.CharToDrive(gDriveToTest, gDrive); sl@0: test(nRes==KErrNone); sl@0: sl@0: PrintDrvInfo(TheFs, gDrive); sl@0: sl@0: sl@0: TVolumeInfo v; sl@0: TInt r=TheFs.Volume(v, CurrentDrive()); sl@0: test(r==KErrNone); sl@0: LargeFileSize=Max((TUint32)I64LOW(v.iFree >> 7), (TUint32)65536u); sl@0: sl@0: if (gFirstTime) sl@0: { sl@0: MountRemoteFilesystem(); sl@0: CreateSubstDrive(); sl@0: sl@0: testDriveList(); sl@0: sl@0: DisMountRemoteFilesystem(); sl@0: RemoveSubstDrive(); sl@0: sl@0: testDriveInfo(); sl@0: testVolumeInfo(); sl@0: testClientParse(); sl@0: testPath(); sl@0: testServerParse(); sl@0: gFirstTime=EFalse; sl@0: } sl@0: sl@0: CreateTestDirectory(_L("\\F32-TST\\TFSRV\\")); sl@0: testSubst(); sl@0: testSetVolume(); sl@0: CopyFileToTestDirectory(); sl@0: testModified(); sl@0: testName(); sl@0: MakeAndDeleteFiles(); sl@0: FillUpDisk(); sl@0: DeleteTestDirectory(); sl@0: sl@0: TestSetErrorCondition(); sl@0: sl@0: } sl@0: