kerneltest/f32test/server/t_fsys.cpp
branchRCL_3
changeset 110 c734af59ce98
parent 33 0173bcd7697c
child 256 c1f20ce4abcf
equal deleted inserted replaced
97:41f0cfe18c80 110:c734af59ce98
   931     RFile file;
   931     RFile file;
   932 
   932 
   933     //-- 2. open this file
   933     //-- 2. open this file
   934     nRes = file.Open(TheFs, KFile, EFileRead);
   934     nRes = file.Open(TheFs, KFile, EFileRead);
   935     test_KErrNone(nRes);
   935     test_KErrNone(nRes);
       
   936     
       
   937     const TInt drvNumber = CurrentDrive();
   936 
   938 
   937     //-- 2.1 try to dismount the FS, it must fail because of the opened object.
   939     //-- 2.1 try to dismount the FS, it must fail because of the opened object.
   938     TBuf<40> fsName;
   940     TBuf<40> fsName;
   939     nRes = TheFs.FileSystemName(fsName, CurrentDrive());
   941     nRes = TheFs.FileSystemName(fsName, drvNumber);
   940     test_KErrNone(nRes);
   942     test_KErrNone(nRes);
   941 
   943 
   942     nRes = TheFs.DismountFileSystem(fsName, CurrentDrive());
   944     nRes = TheFs.DismountFileSystem(fsName, drvNumber);
   943     test(nRes == KErrInUse);
   945     test_Value(nRes, nRes == KErrInUse);
   944 
   946 
   945 
   947     // Flag from locmedia.h to simulate ejecting and re-inserting the media.
       
   948     const TUint KMediaRemountForceMediaChange = 0x00000001;
       
   949     TRequestStatus changeStatus;
       
   950     TheFs.NotifyChange(ENotifyAll, changeStatus);
       
   951     TDriveInfo driveInfo;
       
   952     
   946     //-- 3. forcedly remount the drive
   953     //-- 3. forcedly remount the drive
   947     nRes = TheFs.RemountDrive(CurrentDrive());
   954     nRes = TheFs.RemountDrive(drvNumber, NULL, KMediaRemountForceMediaChange);
       
   955     
   948     if(nRes == KErrNotSupported)
   956     if(nRes == KErrNotSupported)
   949     {//-- this feature is not supported and the test is inconsistent.
   957     	{//-- this feature is not supported and the test is inconsistent.
   950         test.Printf(_L("RemountDrive() is not supported, the test is inconsistent!"));
   958         test.Printf(_L("RemountDrive() is not supported, the test is inconsistent!"));
   951         
   959         
   952         //-- remounting must work at least on MMC drives
   960         //-- remounting must work at least on MMC drives
   953         const TBool isFAT = Is_Fat(TheFs, CurrentDrive());
   961         const TBool isFAT = Is_Fat(TheFs, drvNumber);
   954 
   962 
   955         TDriveInfo  driveInfo;
   963         nRes = TheFs.Drive(driveInfo, drvNumber);
   956         nRes = TheFs.Drive(driveInfo, CurrentDrive());
       
   957         test_KErrNone(nRes);
   964         test_KErrNone(nRes);
   958 
   965 
   959         test(!isFAT || (!(driveInfo.iDriveAtt & KDriveAttRemovable)));
   966         test_Value(driveInfo.iDriveAtt, !isFAT || (!(driveInfo.iDriveAtt & KDriveAttRemovable)));
   960 
   967     	}
   961     }
       
   962     else
   968     else
   963     {
   969     	{
   964         test_KErrNone(nRes);
   970 		test_Value(nRes, nRes == KErrNotReady || nRes == KErrNone);
   965     }
   971 		
   966 
   972 		//-- 3.1 wait for media change to complete
   967     User::After(500*K1mSec);
   973 		do
       
   974 			{
       
   975 			// Waiting for media change...
       
   976 			User::WaitForRequest(changeStatus);
       
   977 			nRes = TheFs.Drive(driveInfo, drvNumber);
       
   978 			TheFs.NotifyChange(ENotifyAll, changeStatus);
       
   979 			}
       
   980 		while (nRes == KErrNotReady);
       
   981 		
       
   982 		test_KErrNone(nRes);
       
   983 		User::After(1000*K1mSec);	// Wait 1 sec (needed by certain platforms)
       
   984     	}
       
   985     
       
   986     TheFs.NotifyChangeCancel(changeStatus);
   968 
   987 
   969     //-- 4. read this file. The FS will be remounted and the read must be OK.
   988     //-- 4. read this file. The FS will be remounted and the read must be OK.
   970     TBuf8<40> buf;
   989     TBuf8<40> buf;
   971     nRes = file.Read(0, buf, 30);
   990     nRes = file.Read(0, buf, 30);
   972     test_KErrNone(nRes);
   991     test_KErrNone(nRes);