kerneltest/f32test/server/t_ext1.cpp
branchRCL_3
changeset 256 c1f20ce4abcf
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
249:a179b74831c9 256:c1f20ce4abcf
    13 // Description:
    13 // Description:
    14 // f32test\ext\t_ext1.cpp
    14 // f32test\ext\t_ext1.cpp
    15 // 
    15 // 
    16 //
    16 //
    17 
    17 
       
    18 #define __E32TEST_EXTENSION__
    18 #include <f32file.h>
    19 #include <f32file.h>
    19 #include <e32test.h>
    20 #include <e32test.h>
    20 #include <e32svr.h>
    21 #include <e32svr.h>
    21 #include "t_server.h"
    22 #include "t_server.h"
    22 #include "f32_test_utils.h"
    23 #include "f32_test_utils.h"
    44 //
    45 //
    45 	{
    46 	{
    46 	test.Next(_L("TestSecondaryExtensions()"));
    47 	test.Next(_L("TestSecondaryExtensions()"));
    47 	TInt drive;
    48 	TInt drive;
    48 	TInt err=RFs::CharToDrive(gDriveToTest,drive);
    49 	TInt err=RFs::CharToDrive(gDriveToTest,drive);
    49 	test(err==KErrNone);
    50 	test_KErrNone(err);
    50 	
    51 	
    51 	TPckgBuf<TBool> drvSyncBuf;
    52 	TPckgBuf<TBool> drvSyncBuf;
    52 	err = TheFs.QueryVolumeInfoExt(drive, EIsDriveSync, drvSyncBuf);
    53 	err = TheFs.QueryVolumeInfoExt(drive, EIsDriveSync, drvSyncBuf);
    53 	test(err==KErrNone);
    54 	test_KErrNone(err);
    54 	const TBool bDrvSync = drvSyncBuf();
    55 	const TBool bDrvSync = drvSyncBuf();
    55 			
    56 			
    56 
    57 
    57 	TFullName fsName;
    58 	TFullName fsName;
    58 	TInt r=TheFs.FileSystemName(fsName,drive);
    59 	TInt r=TheFs.FileSystemName(fsName,drive);
    59 	test(r==KErrNone);
    60 	test_KErrNone(r);
    60 	test.Printf(_L("fsName=%S\n"),&fsName);
    61 	test.Printf(_L("fsName=%S\n"),&fsName);
    61 
    62 
    62 #if defined(__WINS__)
    63 	if (Is_SimulatedSystemDrive(TheFs, drive))
    63 	if(drive==EDriveC)
       
    64 		{
    64 		{
    65 		// check that the extension cannot be mounted since not supported by the file system
    65 		// check that the extension cannot be mounted since it is not supported by the file system
       
    66 		test.Printf(_L("Test extension cannot be mounted"));
    66 		r=TheFs.AddExtension(KExtensionLog);
    67 		r=TheFs.AddExtension(KExtensionLog);
    67 		test(r==KErrNone);
    68 		test_KErrNone(r);
    68 		r=TheFs.MountExtension(KExtensionLogName,drive);
    69 		r=TheFs.MountExtension(KExtensionLogName,drive);
    69 		test(r==KErrNotSupported);
    70 		test_Value(r, r == KErrNotSupported);
    70 		r=TheFs.RemoveExtension(KExtensionLogName);
    71 		r=TheFs.RemoveExtension(KExtensionLogName);
    71 		test(r==KErrNone);
    72 		test_KErrNone(r);
    72 		return;
    73 		return;
    73 		}
    74 		}
    74 #endif
       
    75 
    75 
    76 	test.Next(_L("RFs::AddExtension()"));
    76 	test.Next(_L("RFs::AddExtension()"));
    77 	r=TheFs.AddExtension(KExtensionLog);
    77 	r=TheFs.AddExtension(KExtensionLog);
    78 	RDebug::Print(_L("addext=%d"),r);
    78 	RDebug::Print(_L("addext=%d"),r);
    79 	test(r==KErrNone);
    79 	test_KErrNone(r);
    80 	r=TheFs.AddExtension(KExtensionLog);
    80 	r=TheFs.AddExtension(KExtensionLog);
    81 	test(r==KErrAlreadyExists);
    81 	test_Value(r, r == KErrAlreadyExists);
    82 	r=TheFs.AddExtension(KExtensionRubbish);
    82 	r=TheFs.AddExtension(KExtensionRubbish);
    83 	test(r==KErrNotFound);
    83 	test_Value(r, r == KErrNotFound);
    84 	r=TheFs.AddExtension(KExtensionEmpty);
    84 	r=TheFs.AddExtension(KExtensionEmpty);
    85 	test(r==KErrNone);
    85 	test_KErrNone(r);
    86 
    86 
    87 	test.Next(_L("RFs::MountExtension()"));
    87 	test.Next(_L("RFs::MountExtension()"));
    88 #if !defined(__WINS__)
    88 #if !defined(__WINS__)
    89 	// check that the extension cannot be mounted on file system that does not support extensions
    89 	// check that the extension cannot be mounted on file system that does not support extensions
    90 	r=TheFs.MountExtension(KExtensionLogName,EDriveZ);
    90 	r=TheFs.MountExtension(KExtensionLogName,EDriveZ);
    91 	test(r==KErrNotSupported);
    91 	test_Value(r, r == KErrNotSupported);
    92 #endif
    92 #endif
    93 	// test mounting on drive with no file system
    93 	// test mounting on drive with no file system
    94 	r=TheFs.DismountFileSystem(fsName,drive);
    94 	r=TheFs.DismountFileSystem(fsName,drive);
    95 	test(r==KErrNone);
    95 	test_KErrNone(r);
    96 	r=TheFs.MountExtension(KExtensionLogName,drive);
    96 	r=TheFs.MountExtension(KExtensionLogName,drive);
    97 	test(r==KErrNotReady);
    97 	test_Value(r, r == KErrNotReady);
    98 	r=TheFs.MountFileSystem(fsName,drive,bDrvSync);
    98 	r=TheFs.MountFileSystem(fsName,drive,bDrvSync);
    99 	test(r==KErrNone);
    99 	test_KErrNone(r);
   100 	// test with a resource open
   100 	// test with a resource open
   101 	_LIT(KFileName,"testing.doc");
   101 	_LIT(KFileName,"testing.doc");
   102 	RFile file;
   102 	RFile file;
   103 	r=file.Replace(TheFs,KFileName,EFileShareExclusive);
   103 	r=file.Replace(TheFs,KFileName,EFileShareExclusive);
   104 	test(r==KErrNone);
   104 	test_KErrNone(r);
   105 	r=TheFs.MountExtension(KExtensionLogName,drive);
   105 	r=TheFs.MountExtension(KExtensionLogName,drive);
   106 	test(r==KErrInUse);
   106 	test_Value(r, r == KErrInUse);
   107 	file.Close();
   107 	file.Close();
   108 	r=TheFs.Delete(KFileName);
   108 	r=TheFs.Delete(KFileName);
   109 	test(r==KErrNone);
   109 	test_KErrNone(r);
   110 	// test with a format open
   110 	// test with a format open
   111 	TBuf<4> driveBuf=_L("?:\\");
   111 	TBuf<4> driveBuf=_L("?:\\");
   112 	driveBuf[0]=(TText)(drive+'A');
   112 	driveBuf[0]=(TText)(drive+'A');
   113 	RFormat format;
   113 	RFormat format;
   114 	TInt count;
   114 	TInt count;
   115 	r=format.Open(TheFs,driveBuf,EHighDensity,count);
   115 	r=format.Open(TheFs,driveBuf,EHighDensity,count);
   116 	test(r==KErrNone);
   116 	test_KErrNone(r);
   117 	r=TheFs.MountExtension(KExtensionLogName,drive);
   117 	r=TheFs.MountExtension(KExtensionLogName,drive);
   118 	test(r==KErrInUse);
   118 	test_Value(r, r == KErrInUse);
   119 	format.Close();
   119 	format.Close();
   120 	// get the extension name
   120 	// get the extension name
   121 	TFullName extName;
   121 	TFullName extName;
   122 	r=TheFs.ExtensionName(extName,drive,0);
   122 	r=TheFs.ExtensionName(extName,drive,0);
   123 	test(r==KErrNotFound);
   123 	test_Value(r, r == KErrNotFound);
   124 	// now load the extension
   124 	// now load the extension
   125 	r=TheFs.MountExtension(KExtensionLogName,drive);
   125 	r=TheFs.MountExtension(KExtensionLogName,drive);
   126 	test(r==KErrNone);
   126 	test_KErrNone(r);
   127 	r=TheFs.ExtensionName(extName,drive,0);
   127 	r=TheFs.ExtensionName(extName,drive,0);
   128 	test(r==KErrNone && extName==KExtensionLogName);
   128 	test_Value(r, r == KErrNone && extName==KExtensionLogName);
   129 	r=TheFs.ExtensionName(extName,drive,1);
   129 	r=TheFs.ExtensionName(extName,drive,1);
   130 	test(r==KErrNotFound);
   130 	test_Value(r, r == KErrNotFound);
   131 	// try remounting the same extension
   131 	// try remounting the same extension
   132 	r=TheFs.MountExtension(KExtensionLogName,drive);
   132 	r=TheFs.MountExtension(KExtensionLogName,drive);
   133 	test(r==KErrAlreadyExists);
   133 	test_Value(r, r == KErrAlreadyExists);
   134 	// mount a second extension
   134 	// mount a second extension
   135 	r=TheFs.MountExtension(KExtensionEmptyName,drive);
   135 	r=TheFs.MountExtension(KExtensionEmptyName,drive);
   136 	test(r==KErrNone);
   136 	test_KErrNone(r);
   137 	r=TheFs.ExtensionName(extName,drive,0);
   137 	r=TheFs.ExtensionName(extName,drive,0);
   138 	test(r==KErrNone && extName==KExtensionLogName);
   138 	test_Value(r, r == KErrNone && extName==KExtensionLogName);
   139 	r=TheFs.ExtensionName(extName,drive,1);
   139 	r=TheFs.ExtensionName(extName,drive,1);
   140 	test(r==KErrNone && extName==KExtensionEmptyName);
   140 	test_Value(r, r == KErrNone && extName==KExtensionEmptyName);
   141 	
   141 	
   142     // force a remount on a removable media and check that extensions both exist
   142     // force a remount on a removable media and check that extensions both exist
   143     test.Printf(_L("Test forcing remount\n"));
   143     test.Printf(_L("Test forcing remount\n"));
   144     TDriveInfo info;
   144     TDriveInfo info;
   145 	r=TheFs.Drive(info,drive);
   145 	r=TheFs.Drive(info,drive);
   151         TRequestStatus changeStatus;
   151         TRequestStatus changeStatus;
   152         TheFs.NotifyChange(ENotifyAll, changeStatus);
   152         TheFs.NotifyChange(ENotifyAll, changeStatus);
   153 
   153 
   154         test.Printf(_L("Remounting the drive\n"), r);
   154         test.Printf(_L("Remounting the drive\n"), r);
   155         r = TheFs.RemountDrive(drive, NULL, (TUint) KMediaRemountForceMediaChange);
   155         r = TheFs.RemountDrive(drive, NULL, (TUint) KMediaRemountForceMediaChange);
   156         test(r == KErrNotReady || r == KErrNone);
   156         test_Value(r, r == KErrNotReady || r == KErrNone);
   157         
   157         
   158         do
   158         do
   159         {
   159         {
   160         test.Printf(_L("Waiting for media change...\n"));
   160         test.Printf(_L("Waiting for media change...\n"));
   161         User::WaitForRequest(changeStatus);
   161         User::WaitForRequest(changeStatus);
   179 
   179 
   180         test.Printf(_L("Force media change\n"));
   180         test.Printf(_L("Force media change\n"));
   181     	RLocalDrive d;
   181     	RLocalDrive d;
   182 		TBool flag=EFalse;
   182 		TBool flag=EFalse;
   183 		r=d.Connect(1,flag);
   183 		r=d.Connect(1,flag);
   184 		test(r==KErrNone);
   184 		test_KErrNone(r);
   185 		d.ForceMediaChange();
   185 		d.ForceMediaChange();
   186 		d.Close();
   186 		d.Close();
   187 //#if defined(__WINS__)
   187 //#if defined(__WINS__)
   188 		// ??? seems to work, find out why
   188 		// ??? seems to work, find out why
   189 		//User::After(500000);
   189 		//User::After(500000);
   193 		}
   193 		}
   194 
   194 
   195 
   195 
   196 
   196 
   197 	r=TheFs.ExtensionName(extName,drive,0);
   197 	r=TheFs.ExtensionName(extName,drive,0);
   198 	test(r==KErrNone && extName==KExtensionLogName);
   198 	test_Value(r, r == KErrNone && extName==KExtensionLogName);
   199 	r=TheFs.ExtensionName(extName,drive,1);
   199 	r=TheFs.ExtensionName(extName,drive,1);
   200 	test(r==KErrNone && extName==KExtensionEmptyName);
   200 	test_Value(r, r == KErrNone && extName==KExtensionEmptyName);
   201 
   201 
   202     test.Printf(_L("Accessing media...\n"));
   202     test.Printf(_L("Accessing media...\n"));
   203 	// and now do some file system operations
   203 	// and now do some file system operations
   204 	TBuf8<16> readBuf;
   204 	TBuf8<16> readBuf;
   205 	r=TheFs.MkDir(dir1);
   205 	r=TheFs.MkDir(dir1);
   206     
   206     
   207     test.Printf(_L("res=%d\n"), r);
   207     test.Printf(_L("res=%d\n"), r);
   208 
   208 
   209 
   209 
   210 	test(r==KErrNone||r==KErrAlreadyExists);
   210 	test_Value(r, r == KErrNone||r==KErrAlreadyExists);
   211 	RFile file1;
   211 	RFile file1;
   212 	r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
   212 	r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
   213 	test(r==KErrNone);
   213 	test_KErrNone(r);
   214 	r=file1.Write(toWrite);
   214 	r=file1.Write(toWrite);
   215 	test(r==KErrNone);
   215 	test_KErrNone(r);
   216 	r=file1.Read(0,readBuf);
   216 	r=file1.Read(0,readBuf);
   217 	test(readBuf==toWrite);
   217 	test(readBuf==toWrite);
   218 	r=file1.SetSize(0);
   218 	r=file1.SetSize(0);
   219 	test(r==KErrNone);
   219 	test_KErrNone(r);
   220 	file1.Close();
   220 	file1.Close();
   221 	r=TheFs.Delete(file1Name);
   221 	r=TheFs.Delete(file1Name);
   222 	test(r==KErrNone);
   222 	test_KErrNone(r);
   223 	r=TheFs.RmDir(dir1);
   223 	r=TheFs.RmDir(dir1);
   224 	test(r==KErrNone);
   224 	test_KErrNone(r);
   225 
   225 
   226 	test.Next(_L("RFs::DismountExtension()"));
   226 	test.Next(_L("RFs::DismountExtension()"));
   227 	// test with a resource open
   227 	// test with a resource open
   228 	r=file.Replace(TheFs,KFileName,EFileShareExclusive);
   228 	r=file.Replace(TheFs,KFileName,EFileShareExclusive);
   229 	test(r==KErrNone);
   229 	test_KErrNone(r);
   230 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   230 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   231 	test(r==KErrInUse);
   231 	test_Value(r, r == KErrInUse);
   232 	file.Close();
   232 	file.Close();
   233 	r=TheFs.Delete(KFileName);
   233 	r=TheFs.Delete(KFileName);
   234 	test(r==KErrNone);
   234 	test_KErrNone(r);
   235 	// test with a format open
   235 	// test with a format open
   236 	r=format.Open(TheFs,driveBuf,EHighDensity,count);
   236 	r=format.Open(TheFs,driveBuf,EHighDensity,count);
   237 	test(r==KErrNone);
   237 	test_KErrNone(r);
   238 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   238 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   239 	test(r==KErrInUse);
   239 	test_Value(r, r == KErrInUse);
   240 	format.Close();
   240 	format.Close();
   241 	// now dismount an extension
   241 	// now dismount an extension
   242 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   242 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   243 	test(r==KErrNone);
   243 	test_KErrNone(r);
   244 	r=TheFs.ExtensionName(extName,drive,0);
   244 	r=TheFs.ExtensionName(extName,drive,0);
   245 	test(r==KErrNone && extName==KExtensionEmptyName);
   245 	test_Value(r, r == KErrNone && extName==KExtensionEmptyName);
   246 	r=TheFs.ExtensionName(extName,drive,1);
   246 	r=TheFs.ExtensionName(extName,drive,1);
   247 	test(r==KErrNotFound);
   247 	test_Value(r, r == KErrNotFound);
   248 	// try to dismount an extension that is not mounted
   248 	// try to dismount an extension that is not mounted
   249 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   249 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   250 	test(r==KErrNotFound);
   250 	test_Value(r, r == KErrNotFound);
   251 	r=TheFs.ExtensionName(extName,drive,0);
   251 	r=TheFs.ExtensionName(extName,drive,0);
   252 	test(r==KErrNone && extName==KExtensionEmptyName);
   252 	test_Value(r, r == KErrNone && extName==KExtensionEmptyName);
   253 	r=TheFs.ExtensionName(extName,drive,1);
   253 	r=TheFs.ExtensionName(extName,drive,1);
   254 	test(r==KErrNotFound);
   254 	test_Value(r, r == KErrNotFound);
   255 	// dismount the remaining extension
   255 	// dismount the remaining extension
   256 	r=TheFs.DismountExtension(KExtensionEmptyName,drive);
   256 	r=TheFs.DismountExtension(KExtensionEmptyName,drive);
   257 	test(r==KErrNone);
   257 	test_KErrNone(r);
   258 	r=TheFs.ExtensionName(extName,drive,0);
   258 	r=TheFs.ExtensionName(extName,drive,0);
   259 	test(r==KErrNotFound);
   259 	test_Value(r, r == KErrNotFound);
   260 	r=TheFs.ExtensionName(extName,drive,1);
   260 	r=TheFs.ExtensionName(extName,drive,1);
   261 	test(r==KErrNotFound);
   261 	test_Value(r, r == KErrNotFound);
   262 
   262 
   263 	test.Next(_L("RFs::RemoveExtension()"));
   263 	test.Next(_L("RFs::RemoveExtension()"));
   264 	r=TheFs.RemoveExtension(KExtensionLogName);
   264 	r=TheFs.RemoveExtension(KExtensionLogName);
   265 	test(r==KErrNone);
   265 	test_KErrNone(r);
   266 	r=TheFs.RemoveExtension(KExtensionEmptyName);
   266 	r=TheFs.RemoveExtension(KExtensionEmptyName);
   267 	test(r==KErrNone);
   267 	test_KErrNone(r);
   268 	}
   268 	}
   269 
   269 
   270 void TestPrimaryExtensions()
   270 void TestPrimaryExtensions()
   271 //
   271 //
   272 // a primary extension is one that is added to a drive before a file system is mounted
   272 // a primary extension is one that is added to a drive before a file system is mounted
   274 //
   274 //
   275 	{
   275 	{
   276 	test.Next(_L("TestPrimaryExtensions()"));
   276 	test.Next(_L("TestPrimaryExtensions()"));
   277 	TInt drive;
   277 	TInt drive;
   278 	TInt err=RFs::CharToDrive(gDriveToTest,drive);
   278 	TInt err=RFs::CharToDrive(gDriveToTest,drive);
   279 	test(err==KErrNone);
   279 	test_KErrNone(err);
   280 
   280 
   281 #if defined(__WINS__)
   281 	if(Is_SimulatedSystemDrive(TheFs, drive))
   282 	if(drive==EDriveC)
   282 	    {
       
   283 		test.Printf(_L("Skipping TestPrimaryExtensions on PlatSim/Emulator drive %C:\n"), gSessionPath[0]);
   283 		return;
   284 		return;
   284 #endif
   285 	    }
   285 
   286 
   286 	TPckgBuf<TBool> drvSyncBuf;
   287 	TPckgBuf<TBool> drvSyncBuf;
   287 	err = TheFs.QueryVolumeInfoExt(drive, EIsDriveSync, drvSyncBuf);
   288 	err = TheFs.QueryVolumeInfoExt(drive, EIsDriveSync, drvSyncBuf);
   288 	test(err==KErrNone);
   289 	test_KErrNone(err);
   289     const TBool bDrvSync = drvSyncBuf();
   290     const TBool bDrvSync = drvSyncBuf();
   290 
   291 
   291 	// don't test on ram drive since accesses memory directly
   292 	// don't test on ram drive since accesses memory directly
   292 	TDriveInfo info;
   293 	TDriveInfo info;
   293 	TInt r=TheFs.Drive(info,drive);
   294 	TInt r=TheFs.Drive(info,drive);
   294 	if(info.iMediaAtt&KMediaAttVariableSize)
   295 	if(info.iMediaAtt&KMediaAttVariableSize)
   295 		return;
   296 		return;
   296 
   297 
   297 	TFullName fsName;
   298 	TFullName fsName;
   298 	r=TheFs.FileSystemName(fsName,drive);
   299 	r=TheFs.FileSystemName(fsName,drive);
   299 	test(r==KErrNone);
   300 	test_KErrNone(r);
   300 	test.Printf(_L("fsName=%S\n"),&fsName);
   301 	test.Printf(_L("fsName=%S\n"),&fsName);
   301 
   302 
   302 	test.Next(_L("RFs::AddExtension()"));
   303 	test.Next(_L("RFs::AddExtension()"));
   303 	r=TheFs.AddExtension(KExtensionLog);
   304 	r=TheFs.AddExtension(KExtensionLog);
   304 	test(r==KErrNone);
   305 	test_KErrNone(r);
   305 	r=TheFs.AddExtension(KExtensionEmpty);
   306 	r=TheFs.AddExtension(KExtensionEmpty);
   306 	test(r==KErrNone);
   307 	test_KErrNone(r);
   307 	r=TheFs.AddExtension(KExtensionBit);
   308 	r=TheFs.AddExtension(KExtensionBit);
   308 	test(r==KErrNone);
   309 	test_KErrNone(r);
   309 
   310 
   310 	test.Next(_L("RFs::MountFileSystem()"));
   311 	test.Next(_L("RFs::MountFileSystem()"));
   311 	// test with file system that already exists
   312 	// test with file system that already exists
   312 	r=TheFs.MountFileSystem(fsName,KExtensionBitName,drive,bDrvSync);
   313 	r=TheFs.MountFileSystem(fsName,KExtensionBitName,drive,bDrvSync);
   313 	test(r==KErrAccessDenied);
   314 	test_Value(r, r == KErrAccessDenied);
   314 	// unmount drive and mount primary extension along with file system
   315 	// unmount drive and mount primary extension along with file system
   315 	r=TheFs.DismountFileSystem(fsName,drive);
   316 	r=TheFs.DismountFileSystem(fsName,drive);
   316 	test(r==KErrNone);
   317 	test_KErrNone(r);
   317 
   318 
   318     //-- !! N.B this extension mangles data read/written ftom/to the media, for some file systems it is OK and mounting succeeds
   319     //-- !! N.B this extension mangles data read/written ftom/to the media, for some file systems it is OK and mounting succeeds
   319     //-- for others - this will result in KErrCorrupt
   320     //-- for others - this will result in KErrCorrupt
   320 	r=TheFs.MountFileSystem(fsName,KExtensionBitName,drive,bDrvSync);
   321 	r=TheFs.MountFileSystem(fsName,KExtensionBitName,drive,bDrvSync);
   321 	test(r==KErrNone||r==KErrCorrupt);
   322 	test_Value(r, r == KErrNone||r==KErrCorrupt);
   322 	
   323 	
   323     // and now format
   324     // and now format
   324 	Format(drive);
   325 	Format(drive);
   325 	TFullName extName;
   326 	TFullName extName;
   326 	r=TheFs.ExtensionName(extName,drive,0);
   327 	r=TheFs.ExtensionName(extName,drive,0);
   327 	test(r==KErrNone && extName==KExtensionBitName);
   328 	test_Value(r, r == KErrNone && extName==KExtensionBitName);
   328 	r=TheFs.ExtensionName(extName,drive,1);
   329 	r=TheFs.ExtensionName(extName,drive,1);
   329 	test(r==KErrNotFound);
   330 	test_Value(r, r == KErrNotFound);
   330 	
   331 	
   331 	// and now do some file system operations
   332 	// and now do some file system operations
   332 	TBuf8<16> readBuf;
   333 	TBuf8<16> readBuf;
   333 	r=TheFs.MkDir(dir1);
   334 	r=TheFs.MkDir(dir1);
   334 	test(r==KErrNone||r==KErrAlreadyExists);
   335 	test_Value(r, r == KErrNone||r==KErrAlreadyExists);
   335 	RFile file1;
   336 	RFile file1;
   336 	r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
   337 	r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
   337 	test(r==KErrNone);
   338 	test_KErrNone(r);
   338 	r=file1.Write(toWrite);
   339 	r=file1.Write(toWrite);
   339 	test(r==KErrNone);
   340 	test_KErrNone(r);
   340 	r=file1.Read(0,readBuf);
   341 	r=file1.Read(0,readBuf);
   341 	test(readBuf==toWrite);
   342 	test(readBuf==toWrite);
   342 	r=file1.SetSize(0);
   343 	r=file1.SetSize(0);
   343 	test(r==KErrNone);
   344 	test_KErrNone(r);
   344 	file1.Close();
   345 	file1.Close();
   345 	r=TheFs.Delete(file1Name);
   346 	r=TheFs.Delete(file1Name);
   346 	test(r==KErrNone);
   347 	test_KErrNone(r);
   347 	r=TheFs.RmDir(dir1);
   348 	r=TheFs.RmDir(dir1);
   348 	test(r==KErrNone);
   349 	test_KErrNone(r);
   349 
   350 
   350 	// add a secondary extension
   351 	// add a secondary extension
   351 	test.Printf(_L("RFs::MountExtension()"));
   352 	test.Printf(_L("RFs::MountExtension()"));
   352 	r=TheFs.MountExtension(KExtensionLogName,drive);
   353 	r=TheFs.MountExtension(KExtensionLogName,drive);
   353 	test(r==KErrNone);
   354 	test_KErrNone(r);
   354 	r=TheFs.ExtensionName(extName,drive,0);
   355 	r=TheFs.ExtensionName(extName,drive,0);
   355 	test(r==KErrNone && extName==KExtensionBitName);
   356 	test_Value(r, r == KErrNone && extName==KExtensionBitName);
   356 	r=TheFs.ExtensionName(extName,drive,1);
   357 	r=TheFs.ExtensionName(extName,drive,1);
   357 	test(r==KErrNone && extName==KExtensionLogName);
   358 	test_Value(r, r == KErrNone && extName==KExtensionLogName);
   358 	// try to add the same extension
   359 	// try to add the same extension
   359 	r=TheFs.MountExtension(KExtensionBitName,drive);
   360 	r=TheFs.MountExtension(KExtensionBitName,drive);
   360 	test(r==KErrAlreadyExists);
   361 	test_Value(r, r == KErrAlreadyExists);
   361 	r=TheFs.ExtensionName(extName,drive,0);
   362 	r=TheFs.ExtensionName(extName,drive,0);
   362 	test(r==KErrNone && extName==KExtensionBitName);
   363 	test_Value(r, r == KErrNone && extName==KExtensionBitName);
   363 	r=TheFs.ExtensionName(extName,drive,1);
   364 	r=TheFs.ExtensionName(extName,drive,1);
   364 	test(r==KErrNone && extName==KExtensionLogName);
   365 	test_Value(r, r == KErrNone && extName==KExtensionLogName);
   365 	// try to add a third extension
   366 	// try to add a third extension
   366 	r=TheFs.MountExtension(KExtensionEmptyName,drive);
   367 	r=TheFs.MountExtension(KExtensionEmptyName,drive);
   367 	test(r==KErrAccessDenied);
   368 	test_Value(r, r == KErrAccessDenied);
   368 	r=TheFs.ExtensionName(extName,drive,0);
   369 	r=TheFs.ExtensionName(extName,drive,0);
   369 	test(r==KErrNone && extName==KExtensionBitName);
   370 	test_Value(r, r == KErrNone && extName==KExtensionBitName);
   370 	r=TheFs.ExtensionName(extName,drive,1);
   371 	r=TheFs.ExtensionName(extName,drive,1);
   371 	test(r==KErrNone && extName==KExtensionLogName);
   372 	test_Value(r, r == KErrNone && extName==KExtensionLogName);
   372 
   373 
   373 	// and now do some file system operations
   374 	// and now do some file system operations
   374 	r=TheFs.MkDir(dir1);
   375 	r=TheFs.MkDir(dir1);
   375 	test(r==KErrNone||r==KErrAlreadyExists);
   376 	test_Value(r, r == KErrNone||r==KErrAlreadyExists);
   376 	r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
   377 	r=file1.Replace(TheFs,file1Name,EFileShareExclusive);
   377 	test(r==KErrNone);
   378 	test_KErrNone(r);
   378 	r=file1.Write(toWrite);
   379 	r=file1.Write(toWrite);
   379 	test(r==KErrNone);
   380 	test_KErrNone(r);
   380 	r=file1.Read(0,readBuf);
   381 	r=file1.Read(0,readBuf);
   381 	test(readBuf==toWrite);
   382 	test(readBuf==toWrite);
   382 	r=file1.SetSize(0);
   383 	r=file1.SetSize(0);
   383 	test(r==KErrNone);
   384 	test_KErrNone(r);
   384 	file1.Close();
   385 	file1.Close();
   385 	r=TheFs.Delete(file1Name);
   386 	r=TheFs.Delete(file1Name);
   386 	test(r==KErrNone);
   387 	test_KErrNone(r);
   387 	r=TheFs.RmDir(dir1);
   388 	r=TheFs.RmDir(dir1);
   388 	test(r==KErrNone);
   389 	test_KErrNone(r);
   389 
   390 
   390 	test.Printf(_L("RFs::DismountExtension()"));
   391 	test.Printf(_L("RFs::DismountExtension()"));
   391 	// test that can't dismount a primary extension via this method
   392 	// test that can't dismount a primary extension via this method
   392 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   393 	r=TheFs.DismountExtension(KExtensionLogName,drive);
   393 	test(r==KErrNone);
   394 	test_KErrNone(r);
   394 	r=TheFs.ExtensionName(extName,drive,0);
   395 	r=TheFs.ExtensionName(extName,drive,0);
   395 	test(r==KErrNone && extName==KExtensionBitName);
   396 	test_Value(r, r == KErrNone && extName==KExtensionBitName);
   396 	r=TheFs.ExtensionName(extName,drive,1);
   397 	r=TheFs.ExtensionName(extName,drive,1);
   397 	test(r==KErrNotFound);
   398 	test_Value(r, r == KErrNotFound);
   398 	r=TheFs.DismountExtension(KExtensionBitName,drive);
   399 	r=TheFs.DismountExtension(KExtensionBitName,drive);
   399 	test(r==KErrAccessDenied);
   400 	test_Value(r, r == KErrAccessDenied);
   400 	r=TheFs.ExtensionName(extName,drive,0);
   401 	r=TheFs.ExtensionName(extName,drive,0);
   401 	test(r==KErrNone && extName==KExtensionBitName);
   402 	test_Value(r, r == KErrNone && extName==KExtensionBitName);
   402 	r=TheFs.ExtensionName(extName,drive,1);
   403 	r=TheFs.ExtensionName(extName,drive,1);
   403 	test(r==KErrNotFound);
   404 	test_Value(r, r == KErrNotFound);
   404 	
   405 	
   405 	test.Printf(_L("RFs::DismountFileSystem()"));
   406 	test.Printf(_L("RFs::DismountFileSystem()"));
   406 	r=TheFs.MountExtension(KExtensionLogName,drive);
   407 	r=TheFs.MountExtension(KExtensionLogName,drive);
   407 	test(r==KErrNone);
   408 	test_KErrNone(r);
   408 	r=TheFs.ExtensionName(extName,drive,0);
   409 	r=TheFs.ExtensionName(extName,drive,0);
   409 	test(r==KErrNone && extName==KExtensionBitName);
   410 	test_Value(r, r == KErrNone && extName==KExtensionBitName);
   410 	r=TheFs.ExtensionName(extName,drive,1);
   411 	r=TheFs.ExtensionName(extName,drive,1);
   411 	test(r==KErrNone && extName==KExtensionLogName);
   412 	test_Value(r, r == KErrNone && extName==KExtensionLogName);
   412 	// and now dismount
   413 	// and now dismount
   413 	r=TheFs.DismountFileSystem(fsName,drive);
   414 	r=TheFs.DismountFileSystem(fsName,drive);
   414 	test(r==KErrNone);
   415 	test_KErrNone(r);
   415 	r=TheFs.ExtensionName(extName,drive,0);
   416 	r=TheFs.ExtensionName(extName,drive,0);
   416 	test(r==KErrNotReady);
   417 	test_Value(r, r == KErrNotReady);
   417 	r=TheFs.ExtensionName(extName,drive,1);
   418 	r=TheFs.ExtensionName(extName,drive,1);
   418 	test(r==KErrNotReady);
   419 	test_Value(r, r == KErrNotReady);
   419 	// remount the file system
   420 	// remount the file system
   420 	r=TheFs.MountFileSystem(fsName,drive,bDrvSync);
   421 	r=TheFs.MountFileSystem(fsName,drive,bDrvSync);
   421 	test(r==KErrNone||r==KErrCorrupt);
   422 	test_Value(r, r == KErrNone||r==KErrCorrupt);
   422 	r=TheFs.ExtensionName(extName,drive,0);
   423 	r=TheFs.ExtensionName(extName,drive,0);
   423 	test(r==KErrNotFound);
   424 	test_Value(r, r == KErrNotFound);
   424 	r=TheFs.ExtensionName(extName,drive,1);
   425 	r=TheFs.ExtensionName(extName,drive,1);
   425 	test(r==KErrNotFound);
   426 	test_Value(r, r == KErrNotFound);
   426 	Format(drive);
   427 	Format(drive);
   427 
   428 
   428 	test.Next(_L("RFs::RemoveExtension()"));
   429 	test.Next(_L("RFs::RemoveExtension()"));
   429 	r=TheFs.RemoveExtension(KExtensionLogName);
   430 	r=TheFs.RemoveExtension(KExtensionLogName);
   430 	test(r==KErrNone);
   431 	test_KErrNone(r);
   431 	r=TheFs.RemoveExtension(KExtensionEmptyName);
   432 	r=TheFs.RemoveExtension(KExtensionEmptyName);
   432 	test(r==KErrNone);
   433 	test_KErrNone(r);
   433 	r=TheFs.RemoveExtension(KExtensionBitName);
   434 	r=TheFs.RemoveExtension(KExtensionBitName);
   434 	test(r==KErrNone);
   435 	test_KErrNone(r);
   435 	}
   436 	}
   436 
   437 
   437 
   438 
   438 GLDEF_C void CallTestsL()
   439 GLDEF_C void CallTestsL()
   439 //
   440 //
   444     F32_Test_Utils::SetConsole(test.Console()); 
   445     F32_Test_Utils::SetConsole(test.Console()); 
   445 	
   446 	
   446     TInt drive;
   447     TInt drive;
   447 	TInt err=RFs::CharToDrive(gDriveToTest,drive);
   448 	TInt err=RFs::CharToDrive(gDriveToTest,drive);
   448 	test.Start(_L("Starting Test - T_EXT1"));
   449 	test.Start(_L("Starting Test - T_EXT1"));
   449 	test(err==KErrNone);
   450 	test_KErrNone(err);
   450 
   451 
       
   452 	// Check that the drive supports extensions.
       
   453 	TBool extensionsSupported = EFalse;
       
   454 	TPckg<TBool> dataBuf(extensionsSupported);
       
   455 	err = TheFs.QueryVolumeInfoExt(drive,EFSysExtensionsSupported,dataBuf);
       
   456 	test_KErrNone(err);
       
   457 	if(!extensionsSupported)
       
   458 	    {
       
   459         test.Printf(_L("Drive %C: does not support file sys extensions. Skipping T_EXT1."), gSessionPath[0]);
       
   460         test.End();
       
   461         test.Close();
       
   462         return;
       
   463 	    }
       
   464 	
   451     PrintDrvInfo(TheFs, drive);
   465     PrintDrvInfo(TheFs, drive);
   452 
   466 
   453 //Do not run this test on the NAND drive, as
   467 //Do not run this test on the NAND drive, as
   454 //this has the FTL mounted as a primary extension
   468 //this has the FTL mounted as a primary extension
   455 //which causes the test to fail
   469 //which causes the test to fail
   459 #else
   473 #else
   460 	TDriveInfo driveInfo;
   474 	TDriveInfo driveInfo;
   461 	TheFs.Drive(driveInfo,drive);
   475 	TheFs.Drive(driveInfo,drive);
   462 	if (driveInfo.iType == EMediaNANDFlash)
   476 	if (driveInfo.iType == EMediaNANDFlash)
   463 		{
   477 		{
       
   478 		test.Printf(_L("Skipping T_EXT1 as drive %C: is NAND\n"), gSessionPath[0]);
   464 		return;
   479 		return;
   465 		}
   480 		}
   466 #endif
   481 #endif
   467 	TestSecondaryExtensions();
   482 	TestSecondaryExtensions();
   468 
   483