kerneltest/f32test/filesystem/automounter/t_automounter.cpp
changeset 0 a41df078684a
child 36 538db54a451d
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // 
       
    15 // Testing "automounter" filesystem plugin functionality. 
       
    16 //
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21 */
       
    22 
       
    23 #define __E32TEST_EXTENSION__
       
    24 
       
    25 #include <f32file.h>
       
    26 #include <e32test.h>
       
    27 #include <e32math.h>
       
    28 #include <e32property.h>
       
    29 #include <f32dbg.h>
       
    30 
       
    31 #include "filesystem_fat.h"
       
    32 #include "filesystem_exfat.h" 
       
    33 #include "filesystem_automounter.h" 
       
    34 
       
    35 
       
    36 #include "t_server.h"
       
    37 #include "fat_utils.h"
       
    38 
       
    39 using namespace Fat_Test_Utils;
       
    40 
       
    41 
       
    42 
       
    43 
       
    44 RTest test(_L("T_Automounter"));
       
    45 
       
    46 static TInt     gDriveNum=-1; ///< drive number we are dealing with
       
    47 
       
    48 //-------------------------------------------------------------------
       
    49 //-- the debug test property string can be used to control automounter in debug mode.
       
    50 const TUid KThisTestSID={0x10210EB3}; ///< this EXE SID
       
    51 
       
    52 //-------------------------------------------------------------------
       
    53 //-- Actually, for testing autoounter, it is neccessary to have at least 3 filesystems:
       
    54 //-- automounter itself and any 2 dirrerent filesystems that can be used as child ones. 
       
    55 //-- Let's use FAT as a 1st child, and exFAT as 2nd. All these 3  *.fsy shall be present.
       
    56 
       
    57 /** automounter filesystem name */
       
    58 #define KAutoMounterFSName KFileSystemName_AutoMounter
       
    59 _LIT(KAutoMounterFsy,    "automounter.fsy");    ///< automounter *.fsy module name
       
    60 
       
    61 
       
    62 //-- FAT is used as a child filesystem #0
       
    63 
       
    64 /**  filesystem #1 name */
       
    65 #define KFSName1 KFileSystemName_FAT
       
    66 
       
    67 #if defined(__WINS__) //-- FAT fsy name is a mess.
       
    68 _LIT(KFsy1, "efat32.fsy");
       
    69 #else
       
    70 _LIT(KFsy1, "elocal.fsy");
       
    71 #endif    
       
    72     
       
    73 //-- exFAT is used as a child filesystem #1
       
    74 //_LIT(KFSName2, "exfat");  ///< filesystem #2 name
       
    75 
       
    76 /** filesystem #2 name */
       
    77 #define KFSName2 KFileSystemName_exFAT
       
    78 _LIT(KFsy2, "exfat.fsy"); ///< filesystem #2 *.fsy module name
       
    79 
       
    80 TBool automounter_Loaded  = EFalse; ///< ETrue if automounter.fsy is loaded; used for correct cleanup
       
    81 TBool childFs1_Loaded     = EFalse; ///< ETrue if child #0 *.fsy is loaded; used for correct cleanup
       
    82 TBool childFs2_Loaded     = EFalse; ///< ETrue if child #1 *.fsy is loaded; used for correct cleanup
       
    83 
       
    84 TFSDescriptor   orgFsDescriptor; //-- keeps parameters of the original FS
       
    85 
       
    86 //-------------------------------------------------------------------
       
    87 
       
    88 /**
       
    89     perform some operations to see if the file system works at all
       
    90 */
       
    91 void CheckFsOperations()
       
    92 {
       
    93     TInt nRes;
       
    94 
       
    95     TVolumeInfo v;
       
    96     nRes = TheFs.Volume(v);
       
    97     test_KErrNone(nRes);
       
    98 
       
    99     _LIT(KTestDir, "\\directory1\\DIR2\\another directory\\");
       
   100     MakeDir(KTestDir);
       
   101 
       
   102     _LIT(KTestFile, "\\this is a file to test.bin");
       
   103     nRes = CreateCheckableStuffedFile(TheFs, KTestFile, 20376);
       
   104     test_KErrNone(nRes);
       
   105 
       
   106     nRes = VerifyCheckableFile(TheFs, KTestFile);
       
   107     test_KErrNone(nRes);
       
   108 
       
   109     nRes = TheFs.Delete(KTestFile);
       
   110     test_KErrNone(nRes);
       
   111 
       
   112 }
       
   113 
       
   114 //-------------------------------------------------------------------
       
   115 
       
   116 /**
       
   117     Check that FileSystem1 subtype matches one of the expected
       
   118 */
       
   119 void CheckSubtype_FS1(const TDesC& aFsSubtype)
       
   120 {
       
   121     _LIT(KFatSubType12, "fat12");
       
   122     _LIT(KFatSubType16, "fat16");
       
   123     _LIT(KFatSubType32, "fat32");
       
   124 
       
   125     test(aFsSubtype.CompareF(KFatSubType12) == 0 || aFsSubtype.CompareF(KFatSubType16) == 0 || aFsSubtype.CompareF(KFatSubType32) == 0 );
       
   126 }
       
   127 
       
   128 //-------------------------------------------------------------------
       
   129 
       
   130 /**
       
   131     Check that FileSystem2 subtype matches expected
       
   132 */
       
   133 void CheckSubtype_FS2(const TDesC& aFsSubtype)
       
   134 {
       
   135     _LIT(KExFatSubType, "exFAT");
       
   136     test(aFsSubtype.CompareF(KExFatSubType) == 0);
       
   137 }
       
   138 
       
   139 
       
   140 //-------------------------------------------------------------------
       
   141 /**
       
   142     Dismounts Currently mounted file system.
       
   143 */
       
   144 static TInt DoDismountFS()
       
   145 {
       
   146     TBuf<40> fsName(0);
       
   147     TInt nRes;
       
   148    
       
   149     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   150     if(nRes == KErrNone)
       
   151     {
       
   152         test.Printf(_L("--- Dismounting FS:%S\n"), &fsName);
       
   153         nRes = TheFs.DismountFileSystem(fsName, gDriveNum);
       
   154         return nRes;
       
   155     }
       
   156 
       
   157     return KErrNone; //-- no file system mounted
       
   158 }
       
   159 
       
   160 //-------------------------------------------------------------------
       
   161 /**
       
   162     Dismounts Currently mounted file system.
       
   163 */
       
   164 static void DismountFS()
       
   165 {
       
   166     test(DoDismountFS() == KErrNone);
       
   167 }
       
   168 
       
   169 //-------------------------------------------------------------------
       
   170 /**
       
   171     Dismounts Currently mounted file system.
       
   172 */
       
   173 static void ForceDismountFS()
       
   174 {
       
   175     test.Printf(_L("--- Force dismounting current FS\n"));
       
   176     TRequestStatus stat;
       
   177     TheFs.NotifyDismount(gDriveNum, stat, EFsDismountForceDismount); 
       
   178     User::WaitForRequest(stat);         
       
   179     test(stat.Int() == KErrNone);
       
   180 }
       
   181 
       
   182 
       
   183 
       
   184 //-------------------------------------------------------------------
       
   185 /**
       
   186     Mount the given file system. Mounting file system doesn't mean that it will be usable.
       
   187     For example, KErrCorrupt can be the result if FS doesn't recognise bootsectors etc. 
       
   188 
       
   189     @param  aFsName file system name
       
   190     @return error code
       
   191 */
       
   192 static TInt DoMountFS(const TDesC& aFsName)
       
   193 {
       
   194     TInt nRes;
       
   195     test.Printf(_L("+++ Mounting FS:%S\n"), &aFsName);
       
   196 
       
   197     TFSDescriptor   newFsDescriptor = orgFsDescriptor;
       
   198     newFsDescriptor.iFsName = aFsName;
       
   199     test(!newFsDescriptor.iDriveSynch); //-- mount the given FS as asynchronous one, the automounter can't be used on a synchronous drive anyway.
       
   200 
       
   201     nRes = MountFileSystem(TheFs, gDriveNum, newFsDescriptor);
       
   202     
       
   203     if(nRes != KErrNone)
       
   204     {
       
   205         test.Printf(_L("++> Error Mounting FS! code:%d\n"), nRes);
       
   206     }
       
   207     else
       
   208     {
       
   209         PrintDrvInfo(TheFs, gDriveNum);
       
   210     }
       
   211 
       
   212 
       
   213     return nRes;
       
   214 }
       
   215 
       
   216 
       
   217 //-------------------------------------------------------------------
       
   218 /**
       
   219     Explicitly mount the "automounter" FS
       
   220 */
       
   221 static void Mount_AutomounterFS()
       
   222 {
       
   223     DismountFS();
       
   224     DoMountFS(KAutoMounterFSName);
       
   225 }
       
   226 
       
   227 //-------------------------------------------------------------------
       
   228 /**
       
   229     Explicitly mount the FileSystem1
       
   230 */
       
   231 static void Mount_FileSystem1()
       
   232 {
       
   233     DismountFS();
       
   234     DoMountFS(KFSName1);
       
   235 
       
   236 }
       
   237 
       
   238 //-------------------------------------------------------------------
       
   239 /**
       
   240     Explicitly mount the FileSystem2
       
   241 */
       
   242 static void Mount_FileSystem2()
       
   243 {
       
   244     DismountFS();
       
   245     DoMountFS(KFSName2);
       
   246 }
       
   247 
       
   248 //-------------------------------------------------------------------
       
   249 /**
       
   250     Just fill first 32 sectors with zeroes.
       
   251     The volume will require formatting after this.
       
   252 */
       
   253 static void CorruptDrive()
       
   254 {
       
   255     TInt nRes;
       
   256     test.Printf(_L("!!! corrupting the drive...\n"));
       
   257 
       
   258     RRawDisk  rawDisk;
       
   259     nRes = rawDisk.Open(TheFs, gDriveNum);
       
   260     test(nRes == KErrNone);
       
   261 
       
   262     TBuf8<512>  sectorBuf(512);
       
   263 
       
   264     sectorBuf.FillZ();
       
   265 
       
   266     const TInt  KSectors = 32;
       
   267     TInt64      mediaPos = 0;
       
   268 
       
   269     for(TInt i=0; i<KSectors; ++i)
       
   270     {
       
   271         nRes = rawDisk.Write(mediaPos, sectorBuf);
       
   272         test(nRes == KErrNone);
       
   273         
       
   274         mediaPos += sectorBuf.Size();
       
   275     }
       
   276 
       
   277     rawDisk.Close();
       
   278 }
       
   279 
       
   280 //-------------------------------------------------------------------
       
   281 
       
   282 
       
   283 /**
       
   284     quick format the volume using all parameter by default
       
   285 */
       
   286 static void FormatVolume(TBool aQuickFormat = ETrue)
       
   287 {
       
   288     TInt nRes;
       
   289     nRes = FormatDrive(TheFs, CurrentDrive(), aQuickFormat);
       
   290     test_KErrNone(nRes);
       
   291 }
       
   292 
       
   293 
       
   294 //-------------------------------------------------------------------
       
   295 TInt DoFormatSteps(RFormat& aFormat, TInt& aFmtCnt)
       
   296 {
       
   297     TInt nRes = KErrNone;
       
   298 
       
   299     while(aFmtCnt)
       
   300     {
       
   301         nRes = aFormat.Next(aFmtCnt);
       
   302         if(nRes != KErrNone)
       
   303         {
       
   304             test.Printf(_L("RFormat::Next() failed! code:%d\n"), nRes);
       
   305             break;
       
   306         }
       
   307     }
       
   308 
       
   309     return nRes;
       
   310 }
       
   311 
       
   312 //-------------------------------------------------------------------
       
   313 
       
   314 /** 
       
   315     initialise test global objects 
       
   316     @return EFalse if something goes wrong
       
   317 */
       
   318 TBool InitGlobals()
       
   319 {
       
   320 #ifndef _DEBUG
       
   321     test.Printf(_L("This test can't be performed in RELEASE mode! Skipping.\n"));
       
   322     test(0);
       
   323 #endif
       
   324     
       
   325     TInt nRes;
       
   326 
       
   327     //-- store original file system parameters
       
   328     nRes = GetFileSystemDescriptor(TheFs, gDriveNum, orgFsDescriptor);
       
   329     test_KErrNone(nRes);
       
   330 
       
   331 
       
   332     //=======================================
       
   333     //-- define a text propery that will override automounter config string in estart.txt
       
   334     //-- automounter must be able to parse this string.
       
   335     //-- The property key is a drive number being tested
       
   336     {
       
   337         const TUint KPropKey = 0; //-- property key
       
   338         _LIT_SECURITY_POLICY_PASS(KTestPropPolicy);
       
   339         
       
   340         nRes = RProperty::Define(KThisTestSID, KPropKey, RProperty::EText, KTestPropPolicy, KTestPropPolicy);
       
   341         test(nRes == KErrNone || nRes == KErrAlreadyExists);
       
   342 
       
   343         //-- set the propery, it will override automounter config from estart.txt. 
       
   344         //-- the config string has following format: "<fs_name1>,<fsname2>"
       
   345     
       
   346         TBuf8<50> cfgBuf(0);
       
   347         cfgBuf.Append(KFSName1);
       
   348         cfgBuf.Append(_L(" , "));
       
   349         cfgBuf.Append(KFSName2);
       
   350   
       
   351     
       
   352         nRes = RProperty::Set(KThisTestSID, KPropKey, cfgBuf);
       
   353         test_KErrNone(nRes);
       
   354 
       
   355     }
       
   356     
       
   357     //=======================================
       
   358     //-- we must ensure that all 3 required *.fsy are present and load them.
       
   359     //-- the automounter must have child filesystems loaded before its initialisation. 
       
   360     {
       
   361         _LIT(KFsyFailure, "can't load '%S', code:%d, the test can't be performed!\n");
       
   362         
       
   363         //-- child FS #0
       
   364         nRes = TheFs.AddFileSystem(KFsy1);
       
   365         if(nRes != KErrNone && nRes != KErrAlreadyExists)
       
   366         {
       
   367             test.Printf(KFsyFailure, &KFsy1, nRes);    
       
   368             return EFalse;
       
   369         }
       
   370         childFs1_Loaded = ETrue;
       
   371 
       
   372 
       
   373         //-- child FS #1
       
   374         nRes = TheFs.AddFileSystem(KFsy2);
       
   375         if(nRes != KErrNone && nRes != KErrAlreadyExists)
       
   376         {
       
   377             test.Printf(KFsyFailure, &KFsy2, nRes);    
       
   378             return EFalse;
       
   379         }
       
   380         childFs2_Loaded = ETrue;
       
   381 
       
   382         //-- automounter
       
   383         nRes = TheFs.AddFileSystem(KAutoMounterFsy);
       
   384         if(nRes != KErrNone && nRes != KErrAlreadyExists)
       
   385         {
       
   386             test.Printf(KFsyFailure, &KAutoMounterFsy, nRes);    
       
   387             return EFalse;
       
   388         }
       
   389         automounter_Loaded = ETrue;
       
   390     }
       
   391 
       
   392 
       
   393     //=======================================
       
   394     //-- dismount original file system and optional primary extension. Secondary extensions are not supported.
       
   395 
       
   396     test.Printf(_L("Dismounting the original FS:%S, PExt:%S \n"), &orgFsDescriptor.iFsName, &orgFsDescriptor.iPExtName);
       
   397 
       
   398     nRes = TheFs.DismountFileSystem(orgFsDescriptor.iFsName, gDriveNum);
       
   399     test_KErrNone(nRes);
       
   400 
       
   401     return ETrue;
       
   402 }
       
   403 
       
   404 //-------------------------------------------------------------------
       
   405 /** destroy test global objects */
       
   406 void DestroyGlobals()
       
   407 {
       
   408     test.Printf(_L("Restoring the environment....\n"));
       
   409 
       
   410     TInt nRes;
       
   411 
       
   412     //=======================================
       
   413     //-- dismount current filesystem that was used for testing and mount the original filesystem
       
   414     if(orgFsDescriptor.iFsName.Length())
       
   415     {//-- the original file system had been dismounted during test initialisation; dismount whatever we have now
       
   416         test.Printf(_L("Mounting back the original FS:%S, PExt:%S \n"), &orgFsDescriptor.iFsName, &orgFsDescriptor.iPExtName);
       
   417         
       
   418         TBuf<40> fsName;
       
   419 
       
   420         nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   421         if(nRes == KErrNone && fsName.CompareF(orgFsDescriptor.iFsName) != KErrNone)
       
   422         {
       
   423             nRes = TheFs.DismountFileSystem(fsName, gDriveNum);
       
   424             test_KErrNone(nRes);
       
   425         
       
   426 
       
   427             //-- mount original FS as asynchronous one, the automounter can't be used on a synchronous drive anyway.
       
   428             MountFileSystem(TheFs, gDriveNum, orgFsDescriptor);
       
   429        
       
   430             FormatVolume();
       
   431         }
       
   432     }
       
   433 
       
   434     //=======================================
       
   435     //-- delete test property
       
   436     RProperty::Delete(KThisTestSID, gDriveNum);
       
   437 
       
   438     //=======================================
       
   439     //-- if the original FS wasn't automounter, unload child file systems
       
   440     if(orgFsDescriptor.iFsName.CompareF(KFileSystemName_AutoMounter) != 0)
       
   441     { 
       
   442 
       
   443         if(childFs1_Loaded)
       
   444         {
       
   445             nRes = TheFs.RemoveFileSystem(KFSName1);
       
   446             test(nRes == KErrNone ||  nRes == KErrInUse); //-- if the FS was used on some drive before test started, It will be KErrInUse
       
   447             childFs1_Loaded = EFalse;
       
   448         }
       
   449 
       
   450         if(childFs2_Loaded)
       
   451         {
       
   452             nRes = TheFs.RemoveFileSystem(KFSName2);
       
   453             test(nRes == KErrNone ||  nRes == KErrInUse); //-- if the FS was used on some drive before test started, It will be KErrInUse
       
   454             childFs2_Loaded = EFalse;
       
   455         }
       
   456     
       
   457 
       
   458         //-- unload test filesystem modules
       
   459         if(automounter_Loaded)
       
   460         {
       
   461             nRes = TheFs.RemoveFileSystem(KAutoMounterFSName); //-- if the FS was used on some drive before test started, It will be KErrInUse
       
   462             test(nRes == KErrNone ||  nRes == KErrInUse);
       
   463             automounter_Loaded = EFalse;
       
   464         }
       
   465      }
       
   466      else
       
   467      {
       
   468         nRes = RemountFS(TheFs, gDriveNum);
       
   469         test(nRes == KErrNone);
       
   470      }
       
   471 
       
   472     TVolumeInfo v;
       
   473     TheFs.Volume(v);
       
   474 }
       
   475 
       
   476 //-------------------------------------------------------------------
       
   477 
       
   478 /*
       
   479     Testing basic automounter functionality. Format media with different file systems FS1/FS2, mount automounter and 
       
   480     ensure that it recognised and successfully mounts appropriate child file system.
       
   481 
       
   482     
       
   483     1.1 mount "filesystem1" / format volume 
       
   484     1.2 check file system name / subtype / functionality
       
   485     1.3 corrupt "filesystem1"
       
   486     1.4 check  file system name / subtype
       
   487 
       
   488 
       
   489     2.1 mount "automounter"
       
   490     2.2 check file system name / subtype / functionality (this must correspond to the filesystem1) The "filesystem1" must be recognised
       
   491 
       
   492     3.1 mount "filesystem2" / format volume
       
   493     3.2 check file system name / subtype / functionality
       
   494     3.3 corrupt "filesystem2"
       
   495     3.4 check  file system name / subtype
       
   496     3.5 format volume (it will be filesystem2)
       
   497 
       
   498     4.1 mount "automounter"
       
   499     4.2 check file system name / subtype / functionality (this must correspond to the filesystem2) The "filesystem2" must be recognised
       
   500     
       
   501     
       
   502     5.  check the list of supported file systems on the drive
       
   503 
       
   504     6.1 corrupt the volume 
       
   505     6.2 check that automounter can't recognise it
       
   506 
       
   507     7.  restore "filesystem1" / format volume 
       
   508 */
       
   509 void TestAutomounterBasics()
       
   510 {
       
   511     
       
   512     test.Next(_L("Testing automounter basic functionality \n"));
       
   513 
       
   514     TVolumeInfo v;
       
   515     TBuf<40> fsName(0);
       
   516     TBuf<40> fsSubType(0);
       
   517     TInt nRes;
       
   518    
       
   519     //================================================================================
       
   520     //-- 1. mount "filesystem1" / format volume
       
   521     test.Printf(_L("Mounting FileSystem1...\n"));
       
   522     Mount_FileSystem1();
       
   523     
       
   524     FormatVolume();
       
   525 
       
   526     nRes = TheFs.Volume(v);
       
   527     test_KErrNone(nRes);
       
   528     
       
   529     //-- check file system name / subtype etc.
       
   530     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   531     test_KErrNone(nRes);
       
   532     test(fsName.CompareF(KFSName1) == 0);
       
   533 
       
   534 
       
   535     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
       
   536     test_KErrNone(nRes);
       
   537     CheckSubtype_FS1(fsSubType);
       
   538 
       
   539     //-- check the list of supported file systems on this drive (there is only 1 FS supported).
       
   540     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, -1);
       
   541     test(nRes == KErrArgument);
       
   542     
       
   543     fsName.SetLength(0);
       
   544     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem
       
   545     test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0);
       
   546 
       
   547     fsName.SetLength(0);
       
   548     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem
       
   549     test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0);
       
   550 
       
   551     fsName.SetLength(0);
       
   552     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- there are no more supported FSs
       
   553     test(nRes == KErrNotFound);
       
   554 
       
   555     //-- perform some operation
       
   556     CheckFsOperations();
       
   557     
       
   558 
       
   559     //================================================================================
       
   560     //-- 2. Now we have volume formatted for "filesystem1"; Mount "automounter" and check that the 
       
   561     //-- file system on the volume is recognised OK.
       
   562     test.Printf(_L("Mounting Automounter FS and checking its functionality ...\n"));
       
   563     Mount_AutomounterFS();
       
   564 
       
   565     nRes = TheFs.Volume(v);
       
   566     test_KErrNone(nRes);
       
   567 
       
   568     //-- check file system name / subtype etc.
       
   569     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   570     test_KErrNone(nRes);
       
   571 
       
   572     //-- the FS Subtype must be the subtype of the recognised child FS
       
   573     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   574     test_KErrNone(nRes);
       
   575     
       
   576     test.Printf(_L("FS name:'%S', FS Subtype:'%S'\n") ,&fsName, &fsSubType);
       
   577 
       
   578     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   579     CheckSubtype_FS1(fsSubType);
       
   580 
       
   581 
       
   582 
       
   583     //================================================================================
       
   584     //-- dismount current file system
       
   585     test.Printf(_L("Dismomounting FileSystem1...\n"));
       
   586     DismountFS();
       
   587     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   588     test(nRes == KErrNotFound);
       
   589 
       
   590     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem
       
   591     test(nRes == KErrNotFound);
       
   592 
       
   593     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem
       
   594     test(nRes == KErrNotFound);
       
   595 
       
   596     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
       
   597     test(nRes == KErrNotReady);
       
   598 
       
   599     
       
   600     //================================================================================
       
   601     //-- 3. mount "filesystem2" / format volume
       
   602     test.Printf(_L("Mounting FileSystem2...\n"));
       
   603     Mount_FileSystem2();
       
   604     
       
   605     FormatVolume();
       
   606 
       
   607     nRes = TheFs.Volume(v);
       
   608     test_KErrNone(nRes);
       
   609     
       
   610     //-- check file system name / subtype etc.
       
   611     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   612     test_KErrNone(nRes);
       
   613     test(fsName.CompareF(KFSName2) == 0);
       
   614 
       
   615     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
       
   616     test_KErrNone(nRes);
       
   617     CheckSubtype_FS2(fsSubType);
       
   618 
       
   619     //-- check the list of supported file systems on this drive (there is only 1 FS supported).
       
   620     fsName.SetLength(0);
       
   621     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem
       
   622     test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0);
       
   623 
       
   624     fsName.SetLength(0);
       
   625     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem
       
   626     test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0);
       
   627 
       
   628     fsName.SetLength(0);
       
   629     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- there are no more supported FSs
       
   630     test(nRes == KErrNotFound);
       
   631 
       
   632     //-- perform some operation
       
   633     CheckFsOperations();
       
   634 
       
   635 
       
   636     //================================================================================
       
   637     //-- 4. Now we have volume formatted for "filesystem2"; Mount "automounter" and check that the 
       
   638     //-- file system on the volume is recognised OK.
       
   639     test.Printf(_L("Mounting Automounter FS and checking its functionality ...\n"));
       
   640     Mount_AutomounterFS();
       
   641 
       
   642     nRes = TheFs.Volume(v);
       
   643     test_KErrNone(nRes);
       
   644 
       
   645     //-- check file system name / subtype etc.
       
   646     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   647     test_KErrNone(nRes);
       
   648 
       
   649     //-- the FS Subtype must be the subtype of the recognised child FS
       
   650     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   651     test_KErrNone(nRes);
       
   652     
       
   653     test.Printf(_L("FS name:'%S', FS Subtype:'%S'\n") ,&fsName, &fsSubType);
       
   654 
       
   655     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   656     CheckSubtype_FS2(fsSubType);
       
   657 
       
   658     //================================================================================
       
   659     //-- 5. check the list of supported file systems on this drive (there must be 2 child FS supported).
       
   660     test.Printf(_L("Getting list of supported by automounter file systems ...\n"));
       
   661     
       
   662     fsName.SetLength(0);
       
   663     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem
       
   664     test(nRes == KErrNone && fsName.CompareF(KAutoMounterFSName) == 0);
       
   665     test.Printf(_L("Root FS:'%S'\n"), &fsName);
       
   666 
       
   667 
       
   668     fsName.SetLength(0);
       
   669     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem
       
   670     test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0);
       
   671 
       
   672     fsName.SetLength(0);
       
   673     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- 2nd "child" filesystem
       
   674     test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0);
       
   675 
       
   676     nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 2); //-- 3rd "child" filesystem
       
   677     test(nRes == KErrNotFound);
       
   678 
       
   679     //-- get and print out list of all child FS (enumeration example)
       
   680     TInt i;
       
   681     for(i=0; ;++i)
       
   682     {
       
   683         nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, i); 
       
   684         if(nRes == KErrNone)
       
   685         {
       
   686             test.Printf(_L("child FS[%d]:'%S'\n"), i, &fsName);
       
   687         }
       
   688         else
       
   689         {
       
   690         test(nRes == KErrNotFound);
       
   691         break;    
       
   692         }
       
   693         
       
   694     }
       
   695 
       
   696     //-- perform some operation. They will happen on currently active child FS
       
   697     CheckFsOperations();
       
   698 
       
   699     //================================================================================
       
   700     //-- 6. corrupt the media, mount automounter, check that FS is not recognised.
       
   701     test.Printf(_L("Test automounter handling corrupted media.\n"));
       
   702     
       
   703     CorruptDrive(); //-- the active child FS will do this and the root FS will be remounted on first access
       
   704 
       
   705     //-- check file system name / subtype etc.
       
   706     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   707     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   708     test_KErrNone(nRes);
       
   709 
       
   710     //-- the FS Subtype query requires mounted and recognised file system. this shall fail
       
   711     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   712     test(nRes == KErrCorrupt);
       
   713 
       
   714     nRes = TheFs.MkDir(_L("\\dir1\\"));
       
   715     test(nRes == KErrCorrupt);
       
   716 
       
   717 
       
   718     //================================================================================
       
   719     //-- 7. restore filesystem on the drive 
       
   720     test.Printf(_L("Restoring FileSystem1.\n"));
       
   721     Mount_FileSystem1();
       
   722     FormatVolume();
       
   723     
       
   724     nRes = TheFs.Volume(v);
       
   725     test_KErrNone(nRes);
       
   726 
       
   727 }
       
   728 
       
   729 //-------------------------------------------------------------------
       
   730 /**
       
   731     
       
   732     1.1 mount "filesystem1" / format volume 
       
   733     1.2 create and open a file on the volume.
       
   734     1.3 dismount the file system with opened file on it.
       
   735 
       
   736     2.  mount "automounter" The "filesystem1" must be recognised
       
   737     2.1 open previously created file (it is still opened by dismounted FS1)
       
   738 
       
   739     3.  forcedly dismount the current file system (automounter)
       
   740     4.  mount the automounter FS again. check file system name / subtype; The "filesystem1" must be recognised
       
   741     5.  try to read a file (see 2.1), using already dismounted mount; it shall result in KErrDismounted.
       
   742 */
       
   743 void TestDismounting()
       
   744 {
       
   745     test.Next(_L("Testing media dismounting/remounting with automounter FS \n"));
       
   746 
       
   747     TInt nRes;
       
   748     TBuf<40>    fsName(0);
       
   749     TBuf<40>    fsSubType(0);
       
   750     TBuf8<40>   buf;
       
   751 
       
   752     //================================================================================
       
   753     //-- 1. mount "filesystem1" / format volume
       
   754     test.Printf(_L("Mounting FileSystem1 and opening a file.\n"));
       
   755     Mount_FileSystem1();
       
   756     FormatVolume();
       
   757 
       
   758     //-- create a file, open it and try to dismount FS
       
   759     _LIT(KTestFile, "\\test_file");
       
   760     nRes = CreateEmptyFile(TheFs, KTestFile, 100);
       
   761     test(nRes == KErrNone);
       
   762     
       
   763     RFile file;
       
   764 
       
   765     nRes = file.Open(TheFs, KTestFile, 0);
       
   766     test(nRes == KErrNone);
       
   767 
       
   768         //TheFs.SetDebugRegister(KFSERV);
       
   769 
       
   770     test.Printf(_L("dismounting FileSystem1 with a file opened.\n"));
       
   771     nRes = DoDismountFS();
       
   772     test(nRes == KErrInUse);
       
   773 
       
   774     file.Close();
       
   775 
       
   776     //================================================================================
       
   777     //-- 2. mount "automounter", previous FS must be recognised and set as an active child
       
   778     Mount_AutomounterFS();
       
   779    
       
   780     //-- check file system name / subtype etc.
       
   781     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   782     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   783     test_KErrNone(nRes);
       
   784 
       
   785     //-- the FS Subtype must be the subtype of the recognised child FS
       
   786     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   787     test_KErrNone(nRes);
       
   788     CheckSubtype_FS1(fsSubType);
       
   789 
       
   790     //-- open the previously created file
       
   791     nRes = file.Open(TheFs, KTestFile, 0);
       
   792     test(nRes == KErrNone);
       
   793 
       
   794         //TheFs.SetDebugRegister(KFSERV);
       
   795 
       
   796     nRes = DoDismountFS();
       
   797     test(nRes == KErrInUse); //-- opened file belongs to the child FS, actually.
       
   798 
       
   799 
       
   800     //================================================================================
       
   801     //-- 3. force dismounting the file system, this will leave hanging dismounted mount associated with this drive.
       
   802     test.Printf(_L("Force dismounting the file system.\n"));
       
   803     ForceDismountFS();
       
   804 
       
   805         //TheFs.SetDebugRegister(KFSERV);
       
   806 
       
   807     //================================================================================
       
   808     //-- 4. mount "automounter" again, this will create another instance of mount corresponding to the filesystem1
       
   809     Mount_AutomounterFS();
       
   810    
       
   811     //-- check file system name / subtype etc.
       
   812     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   813     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   814     test_KErrNone(nRes);
       
   815 
       
   816     //-- the FS Subtype must be the subtype of the recognised child FS
       
   817     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   818     test_KErrNone(nRes);
       
   819     CheckSubtype_FS1(fsSubType);
       
   820 
       
   821     //================================================================================
       
   822     //-- 5. try to read a file using already dead mount
       
   823     nRes = file.Read(0, buf, 2);
       
   824     test(nRes == KErrDisMounted);
       
   825 
       
   826     //-- this will cause the forcedly dismounted hanging mount to self-destruct
       
   827     file.Close();   
       
   828 
       
   829 
       
   830     //-- open the previously created file using current alive mount.
       
   831     nRes = file.Open(TheFs, KTestFile, 0);
       
   832     test(nRes == KErrNone);
       
   833     nRes = file.Read(0, buf, 2);
       
   834     test(nRes == KErrNone);
       
   835 
       
   836     file.Close();
       
   837 
       
   838     
       
   839     //TheFs.SetDebugRegister(0x00);
       
   840 }
       
   841 
       
   842 //-------------------------------------------------------------------
       
   843 /**
       
   844     Testing legacy RFormat API in the case when the volume has "automounter" file system bound.
       
   845     The formatting is performed without specifying any parameters, i.e. "all by default"
       
   846 
       
   847     If the automounter recognises file system on the volume and successfully mounts it, the 
       
   848     default formatting must be transparent, i.e. the appropriate child FS will perform it.
       
   849 
       
   850     If the automounter can't recognise the filesystem on the volume because of volume corruption or if this FS is unknown to it,
       
   851     the "default" formatting will fail with "KErrNotFound"
       
   852 */
       
   853 void TestAutomounterDefaultFormatting()
       
   854 {
       
   855     test.Next(_L("Testing media formatting with default parameters. Automounter FS\n"));
       
   856 
       
   857     TInt nRes;
       
   858     TBuf<40>    fsName(0);
       
   859     TBuf<40>    fsSubType(0);
       
   860 
       
   861 
       
   862     //================================================================================
       
   863     //-- 1. mount "filesystem1" / format volume
       
   864     Mount_FileSystem1();
       
   865     FormatVolume();
       
   866 
       
   867     //================================================================================
       
   868     //-- 2. mount "automounter", previous FS must be recognised and set as an active child
       
   869     Mount_AutomounterFS();
       
   870    
       
   871     //-- check file system name / subtype etc.
       
   872     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   873     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   874     test_KErrNone(nRes);
       
   875 
       
   876     //-- the FS Subtype must be the subtype of the recognised child FS
       
   877     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   878     test_KErrNone(nRes);
       
   879     CheckSubtype_FS1(fsSubType);
       
   880 
       
   881     //================================================================================
       
   882     //-- 3. format the drive with all default parameters; the current active child FS shall be used
       
   883     //-- check that we still have automounter as "root" FS and the same active child
       
   884     FormatVolume();
       
   885 
       
   886     //-- check file system name / subtype etc.
       
   887     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   888     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   889     test_KErrNone(nRes);
       
   890 
       
   891     //-- the FS Subtype must be the subtype of the recognised child FS
       
   892     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   893     test_KErrNone(nRes);
       
   894     CheckSubtype_FS1(fsSubType);
       
   895 
       
   896     //-- perform some operations
       
   897     CheckFsOperations();
       
   898     test.Printf(_L("default formatting for FS:'%S', subtype:'%S' OK!\n"), &fsName, &fsSubType);
       
   899 
       
   900     //================================================================================
       
   901     //-- 3. mount "filesystem2" / format volume
       
   902     Mount_FileSystem2();
       
   903     FormatVolume();
       
   904 
       
   905     //================================================================================
       
   906     //-- 4. mount "automounter", previous FS must be recognised and set as an active child
       
   907     Mount_AutomounterFS();
       
   908    
       
   909     //-- check file system name / subtype etc.
       
   910     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   911     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   912     test_KErrNone(nRes);
       
   913 
       
   914     //-- the FS Subtype must be the subtype of the recognised child FS
       
   915     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   916     test_KErrNone(nRes);
       
   917     CheckSubtype_FS2(fsSubType);
       
   918 
       
   919     //================================================================================
       
   920     //-- 5. format the drive with all default parameters; the current active child FS shall be used
       
   921     //-- check that we still have automounter as "root" FS and the same active child
       
   922     FormatVolume();
       
   923 
       
   924     //-- check file system name / subtype etc.
       
   925     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   926     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   927     test_KErrNone(nRes);
       
   928 
       
   929     //-- the FS Subtype must be the subtype of the recognised child FS
       
   930     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   931     test_KErrNone(nRes);
       
   932     CheckSubtype_FS2(fsSubType);
       
   933 
       
   934     //-- perform some operations
       
   935     CheckFsOperations();
       
   936     test.Printf(_L("default formatting for FS:'%S', subtype:'%S' OK!\n"), &fsName, &fsSubType);
       
   937 
       
   938     //================================================================================
       
   939     //-- 6. corrupt the media, mount automounter, check that FS is not recognised.
       
   940     //-- default formatting shall fail, because automounter can't chose appropriate child FS
       
   941     
       
   942     CorruptDrive(); //-- the active child FS will do this and the root FS will be remounted on first access
       
   943 
       
   944     //-- check file system name / subtype etc.
       
   945     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   946     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
   947     test_KErrNone(nRes);
       
   948 
       
   949     //-- the FS Subtype query requires mounted and recognised file system. this shall fail
       
   950     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
   951     test(nRes == KErrCorrupt);
       
   952 
       
   953     //-- try default formatting; this shall fail with a special error code
       
   954     nRes = FormatDrive(TheFs, CurrentDrive(), ETrue);
       
   955     test(nRes == KErrNotFound);
       
   956 
       
   957     //-- try special formatting without any parameters, it shall also fail.
       
   958     RFormat     format;
       
   959     TUint       fmtMode = EQuickFormat | ESpecialFormat;
       
   960     TInt        fmtCnt;
       
   961     TBuf<10>    drivePath;
       
   962     drivePath.Format(_L("%C:\\"), gDriveNum+'A');
       
   963 
       
   964     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
       
   965     test(nRes==KErrNotFound);
       
   966     format.Close();
       
   967 
       
   968 
       
   969 
       
   970     //================================================================================
       
   971     //-- 7. restore filesystem on the drive, try formatting with specifying ESpecialFormat flag, but without any formatting parameters
       
   972     //-- just to check that it works (it will not work on SD cards that do not allow ESpecialFormat)
       
   973     test.Printf(_L("Restoring FileSystem1 and use special format without any parameters\n"));
       
   974 
       
   975     Mount_FileSystem1();
       
   976     //FormatVolume();
       
   977     
       
   978 
       
   979     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
       
   980     test(nRes==KErrNone);
       
   981 
       
   982     nRes = DoFormatSteps(format, fmtCnt);
       
   983     test(nRes==KErrNone);
       
   984 
       
   985     format.Close();
       
   986 
       
   987 
       
   988     
       
   989     //-- check file system name / subtype etc.
       
   990     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
   991     test_KErrNone(nRes);
       
   992     test(fsName.CompareF(KFSName1) == 0);
       
   993 
       
   994 
       
   995     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
       
   996     test_KErrNone(nRes);
       
   997     CheckSubtype_FS1(fsSubType);
       
   998 
       
   999 
       
  1000 }
       
  1001 
       
  1002 
       
  1003 
       
  1004 //-------------------------------------------------------------------
       
  1005 /**
       
  1006     Testing the use case when there is "automounter" FS bound to the drive and RFormat API that allows specifying
       
  1007     the file system name that we want to put on the volume.
       
  1008     
       
  1009     It must be possible:
       
  1010         - format the volume without specifying FS name at all (the currently active child FS will be used)
       
  1011         - format the volume with specifying FS name that belongs to one of the supported child FS. The volume shall be formatted with this FS.
       
  1012         - format the volume with specifying incorrect FS name (not supported) the RFormat::Open() must fail with KErrNotSupported.
       
  1013 
       
  1014         - If the file system on the volume is damaged or not recognisable, the RFormat::Open() shall with KErrNotFound if the concrete file system name is not specified.
       
  1015         - If the file system on the volume is damaged or not recognisable, if shall be possible to format such a volume by specifying the child FS name.
       
  1016 */
       
  1017 void TestAutomounterFormatting_FsNameSpecified()
       
  1018 {
       
  1019     test.Next(_L("Testing formatting API that allows specifying particular FS. Automounter FS.\n"));
       
  1020 
       
  1021 
       
  1022     TInt nRes;
       
  1023     TBuf<40>    fsName(0);
       
  1024     TBuf<40>    fsSubType(0);
       
  1025     
       
  1026     TBuf<10>    drivePath;
       
  1027     drivePath.Format(_L("%C:\\"), gDriveNum+'A');
       
  1028 
       
  1029     RFormat     format;
       
  1030     TUint       fmtMode = EQuickFormat | ESpecialFormat;
       
  1031     TInt        fmtCnt;
       
  1032 
       
  1033     TVolFormatParamBuf  fmtParamBuf;
       
  1034     TVolFormatParam& fmtParam = fmtParamBuf();
       
  1035 
       
  1036     //_LIT(KTestFile, "\\this is a test file");
       
  1037 
       
  1038     //================================================================================
       
  1039     //-- 0. prepare the volume
       
  1040     Mount_FileSystem1();    
       
  1041     FormatVolume(); //-- old API, formatting with all parameters by default
       
  1042 
       
  1043 
       
  1044     //================================================================================
       
  1045     //-- 0.1 mount "automounter", previous FS must be recognised and set as an active child
       
  1046     Mount_AutomounterFS();
       
  1047    
       
  1048     //-- check file system name / subtype etc.
       
  1049     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1050     test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
       
  1051     test_KErrNone(nRes);
       
  1052 
       
  1053     //-- the FS Subtype must be the subtype of the recognised child FS
       
  1054     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
  1055     test_KErrNone(nRes);
       
  1056     CheckSubtype_FS1(fsSubType);
       
  1057 
       
  1058     //================================================================================
       
  1059     
       
  1060     //-- 1.1 format the volume without specifying any parameters at all, the currently active child FS shall be used
       
  1061     test.Printf(_L("format the volume without specifying any parameters at all\n"));
       
  1062 
       
  1063     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
       
  1064     test(nRes==KErrNone);
       
  1065     
       
  1066     nRes = DoFormatSteps(format, fmtCnt);
       
  1067     test(nRes==KErrNone);
       
  1068 
       
  1069     format.Close();
       
  1070 
       
  1071     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1072     test(fsName.CompareF(KAutoMounterFSName) == 0); 
       
  1073 
       
  1074     //-- the FS Subtype must be the subtype of the recognised child FS
       
  1075     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
  1076     test_KErrNone(nRes);
       
  1077     CheckSubtype_FS1(fsSubType);
       
  1078 
       
  1079     
       
  1080     //-- 1.2 format the volume without specifying the FS name, the currently active child FS shall be used
       
  1081     test.Printf(_L("format the volume without specifying the FS name\n"));
       
  1082     fmtParam.Init(); //-- reset all data
       
  1083     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1084     test(nRes==KErrNone);
       
  1085     
       
  1086     nRes = DoFormatSteps(format, fmtCnt);
       
  1087     test(nRes==KErrNone);
       
  1088 
       
  1089     format.Close();
       
  1090 
       
  1091     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1092     test(fsName.CompareF(KAutoMounterFSName) == 0); 
       
  1093 
       
  1094     //-- the FS Subtype must be the subtype of the recognised child FS
       
  1095     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
  1096     test_KErrNone(nRes);
       
  1097     CheckSubtype_FS1(fsSubType);
       
  1098 
       
  1099 
       
  1100     CheckFsOperations();
       
  1101 
       
  1102     //================================================================================
       
  1103     //-- 2. format the volume specifying _second_ child FS name
       
  1104     test.Printf(_L("format the volume specifying second child FS name\n"));
       
  1105     fmtParam.Init(); //-- reset all data
       
  1106     fmtParam.SetFileSystemName(KFSName2);
       
  1107     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1108     test(nRes==KErrNone);
       
  1109     
       
  1110     nRes =DoFormatSteps(format, fmtCnt);
       
  1111     test(nRes==KErrNone);
       
  1112 
       
  1113     format.Close();
       
  1114 
       
  1115     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1116     test(fsName.CompareF(KAutoMounterFSName) == 0); 
       
  1117 
       
  1118     //-- the FS Subtype must be the subtype of the recognised child FS
       
  1119     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
  1120     test_KErrNone(nRes);
       
  1121     CheckSubtype_FS2(fsSubType);
       
  1122     
       
  1123     CheckFsOperations();
       
  1124 
       
  1125 
       
  1126     //================================================================================
       
  1127     //-- 3. format the volume specifying _first_ child FS name
       
  1128     fmtParam.Init(); //-- reset all data
       
  1129     fmtParam.SetFileSystemName(KFSName1);
       
  1130     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1131     test(nRes==KErrNone);
       
  1132     
       
  1133     nRes =DoFormatSteps(format, fmtCnt);
       
  1134     test(nRes==KErrNone);
       
  1135 
       
  1136     format.Close();
       
  1137 
       
  1138     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1139     test(fsName.CompareF(KAutoMounterFSName) == 0); 
       
  1140 
       
  1141     //-- the FS Subtype must be the subtype of the recognised child FS
       
  1142     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
  1143     test_KErrNone(nRes);
       
  1144     CheckSubtype_FS1(fsSubType);
       
  1145     
       
  1146     CheckFsOperations();
       
  1147 
       
  1148 
       
  1149     //================================================================================
       
  1150     //-- 4. try formatting the volume specifying wrond child FS name
       
  1151     fmtParam.Init(); //-- reset all data
       
  1152     
       
  1153     fmtParam.SetFileSystemName(KAutoMounterFSName); //-- it might have some strange consequences :)
       
  1154     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1155     test(nRes==KErrNotSupported);
       
  1156     format.Close();
       
  1157 
       
  1158     fmtParam.SetFileSystemName(_L("wrong FS")); 
       
  1159     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1160     test(nRes==KErrNotSupported);
       
  1161     format.Close();
       
  1162 
       
  1163 
       
  1164     //================================================================================
       
  1165     //-- 5. corrupt the volume and try formatting without specyfying FS name
       
  1166     CorruptDrive();
       
  1167 
       
  1168     fmtParam.Init(); //-- reset all data
       
  1169     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1170     test(nRes==KErrNotFound); //-- the meaning: "can't find the appropriate file system to put onto the volume"
       
  1171     format.Close();
       
  1172 
       
  1173     //test.Printf(_L("#### T_a #1 res:%d\n"), nRes);
       
  1174 
       
  1175     fmtParam.SetFileSystemName(KAutoMounterFSName); //-- it might have some strange consequences :)
       
  1176     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1177     //test.Printf(_L("#### T_a #2 res:%d\n"), nRes);
       
  1178     
       
  1179     test(nRes == KErrNotSupported || nRes==KErrNotFound);
       
  1180 
       
  1181     format.Close();
       
  1182 
       
  1183     fmtParam.SetFileSystemName(_L("wrong FS")); 
       
  1184     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1185     test(nRes==KErrNotSupported);
       
  1186     format.Close();
       
  1187 
       
  1188     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
       
  1189     test(nRes==KErrNotFound); //-- the meaning: "can't find the appropriate file system to put onto the volume"
       
  1190     format.Close();
       
  1191 
       
  1192 
       
  1193     //--------------------------------------------------------------------------------
       
  1194     //-- 5.1 format the volume with specifying child FS2 explicitly
       
  1195     fmtParam.Init(); //-- reset all data
       
  1196     fmtParam.SetFileSystemName(KFSName2);
       
  1197     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1198     test(nRes==KErrNone);
       
  1199     
       
  1200     nRes =DoFormatSteps(format, fmtCnt);
       
  1201     test(nRes==KErrNone);
       
  1202 
       
  1203     format.Close();
       
  1204 
       
  1205     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1206     test(fsName.CompareF(KAutoMounterFSName) == 0); 
       
  1207 
       
  1208     //-- the FS Subtype must be the subtype of the recognised child FS
       
  1209     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
  1210     test_KErrNone(nRes);
       
  1211     CheckSubtype_FS2(fsSubType);
       
  1212     
       
  1213     CheckFsOperations();
       
  1214 
       
  1215     //--------------------------------------------------------------------------------
       
  1216     //-- 5.2 corrupt the volume and format with specifying child FS1 explicitly
       
  1217     CorruptDrive();
       
  1218 
       
  1219     fmtParam.Init(); //-- reset all data
       
  1220     fmtParam.SetFileSystemName(KFSName1);
       
  1221     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1222     test(nRes==KErrNone);
       
  1223     
       
  1224     nRes =DoFormatSteps(format, fmtCnt);
       
  1225     test(nRes==KErrNone);
       
  1226 
       
  1227     format.Close();
       
  1228 
       
  1229     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1230     test(fsName.CompareF(KAutoMounterFSName) == 0); 
       
  1231 
       
  1232     //-- the FS Subtype must be the subtype of the recognised child FS
       
  1233     nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);   
       
  1234     test_KErrNone(nRes);
       
  1235     CheckSubtype_FS1(fsSubType);
       
  1236     
       
  1237     CheckFsOperations();
       
  1238 }
       
  1239 
       
  1240 //-------------------------------------------------------------------
       
  1241 /**
       
  1242     Testing the use case when we have some rigidly bound FS to the drive (e.g "FAT")
       
  1243     and RFormat API that allows specifying the file system name that we want to put on the volume.
       
  1244     
       
  1245     It must be possible:
       
  1246         - format the volume without specifying FS name at all (the bound FS will be used)
       
  1247         - format the volume without specifying FS name at all when the volume is corrupted (the bound FS will be used)    
       
  1248         - format the volume with specifying FS name that is the same as the bound FS has.
       
  1249 
       
  1250     If the specified file system name differs from the name that the bound FS has, the RFormat::Open() fails with KErrNotSupported.
       
  1251 
       
  1252 */
       
  1253 void TestFixedFsFormatting_FsNameSpecified()
       
  1254 {
       
  1255     test.Next(_L("Testing RFormat API that allows specifying particular FS name for fixed FS.\n"));
       
  1256 
       
  1257     TInt nRes;
       
  1258     TBuf<40>    fsName(0);
       
  1259    
       
  1260     TBuf<10>    drivePath;
       
  1261     drivePath.Format(_L("%C:\\"), gDriveNum+'A');
       
  1262 
       
  1263     RFormat     format;
       
  1264     TUint       fmtMode = EQuickFormat | ESpecialFormat;
       
  1265     TInt        fmtCnt;
       
  1266 
       
  1267     TVolFormatParamBuf  fmtParamBuf;
       
  1268     TVolFormatParam& fmtParam = fmtParamBuf();
       
  1269 
       
  1270     _LIT(KTestFile, "\\this is a test file");
       
  1271 
       
  1272     //================================================================================
       
  1273     //-- 0. prepare the volume
       
  1274     test.Printf(_L("fmt: ESpecialFormat, no parameters specified\n"));
       
  1275     Mount_FileSystem1();    
       
  1276     
       
  1277     //-- 0.1 format the volume with ESpecialFormat and without any parameters at all
       
  1278     test(fmtMode & ESpecialFormat);
       
  1279     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
       
  1280     test(nRes==KErrNone);
       
  1281     
       
  1282     nRes = DoFormatSteps(format, fmtCnt);
       
  1283     test(nRes==KErrNone);
       
  1284 
       
  1285 
       
  1286     format.Close();
       
  1287 
       
  1288     //================================================================================
       
  1289     //-- 1. format the volume with default parameters without specifying file system name. The volume is already formatted with FS1
       
  1290     test.Printf(_L("fmt: ESpecialFormat, no FS name specified #1\n"));
       
  1291     fmtParam.Init(); //-- reset all data
       
  1292     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1293     test(nRes==KErrNone);
       
  1294     
       
  1295     nRes =DoFormatSteps(format, fmtCnt);
       
  1296     test(nRes==KErrNone);
       
  1297 
       
  1298     format.Close();
       
  1299 
       
  1300     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1301     test(fsName.CompareF(KFSName1) == 0); 
       
  1302     CheckFsOperations();
       
  1303 
       
  1304     //-- 1.1 corrupt the media and check formatting without specifying FS name. 
       
  1305     //-- The file system bount to this drive shall be used.
       
  1306     CorruptDrive();
       
  1307     
       
  1308     test.Printf(_L("fmt: ESpecialFormat, no FS name specified #2\n"));
       
  1309 
       
  1310     fmtParam.Init(); //-- reset all data
       
  1311     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1312     test(nRes==KErrNone);
       
  1313     
       
  1314     nRes =DoFormatSteps(format, fmtCnt);
       
  1315     test(nRes==KErrNone);
       
  1316 
       
  1317     format.Close();
       
  1318 
       
  1319     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1320     test(fsName.CompareF(KFSName1) == 0); 
       
  1321     CheckFsOperations();
       
  1322 
       
  1323     //-- 1.2 the media is already formatted with FS1, try to specify other file system name for formatting.
       
  1324     //-- this shall fail with KErrNotSupported, the volume must not be affected
       
  1325     test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #1\n"));
       
  1326 
       
  1327     nRes = CreateCheckableStuffedFile(TheFs, KTestFile, 17384);
       
  1328     test(nRes==KErrNone);
       
  1329 
       
  1330     fmtParam.Init(); //-- reset all data
       
  1331     fmtParam.SetFileSystemName(_L("some filesystem name"));
       
  1332 
       
  1333     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1334     test(nRes==KErrNotSupported);
       
  1335     format.Close();
       
  1336 
       
  1337     test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #2\n"));
       
  1338     fmtParam.Init(); //-- reset all data
       
  1339     fmtParam.SetFileSystemName(KFSName2);
       
  1340 
       
  1341     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1342     test(nRes==KErrNotSupported);
       
  1343     format.Close();
       
  1344     
       
  1345     
       
  1346     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1347     test(fsName.CompareF(KFSName1) == 0); 
       
  1348     CheckFsOperations();
       
  1349 
       
  1350     nRes = VerifyCheckableFile(TheFs, KTestFile);
       
  1351     test(nRes==KErrNone);
       
  1352 
       
  1353 
       
  1354     //-- 1.3 corrupt the media and check formatting with the FS Name that doesn't match the FS bound to this drive
       
  1355     //-- this shall fail
       
  1356     test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #3\n"));
       
  1357     CorruptDrive();
       
  1358 
       
  1359     fmtParam.Init(); //-- reset all data
       
  1360     fmtParam.SetFileSystemName(_L("some filesystem name"));
       
  1361 
       
  1362     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1363     test(nRes==KErrNotSupported);
       
  1364     format.Close();
       
  1365 
       
  1366     test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #4\n"));
       
  1367     fmtParam.Init(); //-- reset all data
       
  1368     fmtParam.SetFileSystemName(KFSName2);
       
  1369 
       
  1370     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1371     test(nRes==KErrNotSupported);
       
  1372     format.Close();
       
  1373 
       
  1374     //-- 1.4 specify the correct file system name (bound to this drive) formatting must succeed 
       
  1375     test.Printf(_L("fmt: ESpecialFormat, specifying correct FS name\n"));
       
  1376     fmtParam.Init(); //-- reset all data
       
  1377     fmtParam.SetFileSystemName(KFSName1);
       
  1378     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
       
  1379     test(nRes==KErrNone);
       
  1380     
       
  1381     nRes = DoFormatSteps(format, fmtCnt);
       
  1382     test(nRes==KErrNone);
       
  1383 
       
  1384     format.Close();
       
  1385 
       
  1386     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1387     test(fsName.CompareF(KFSName1) == 0); 
       
  1388     CheckFsOperations();
       
  1389 
       
  1390 
       
  1391 }
       
  1392 
       
  1393 //-------------------------------------------------------------------
       
  1394 /**
       
  1395     Test formatting FAT file system with some specific parameters, like sector per cluster etc.
       
  1396     Note that some media types (like SD cards) do not support such type of formatting. 
       
  1397 */
       
  1398 void TestFormatting_FsName_Parameters_FAT()
       
  1399 {
       
  1400     using namespace FileSystem_FAT;
       
  1401 
       
  1402     test.Next(_L("Testing TVolFormatParam_FAT formatting API\n"));
       
  1403 
       
  1404     TInt nRes;
       
  1405     TBuf<40>    fsName(0);
       
  1406    
       
  1407     TBuf<10>    drivePath;
       
  1408     drivePath.Format(_L("%C:\\"), gDriveNum+'A');
       
  1409 
       
  1410     RFormat     format;
       
  1411     TUint       fmtMode = EQuickFormat | ESpecialFormat;
       
  1412     TInt        fmtCnt;
       
  1413 
       
  1414     //================================================================================
       
  1415     //-- 0. prepare the volume
       
  1416     Mount_FileSystem1();    
       
  1417     FormatVolume(); //-- old API, formatting with all parameters by default
       
  1418 
       
  1419     //================================================================================
       
  1420     //-- 1.0  simple unit test for TVolFormatParam_FAT
       
  1421     TVolFormatParam_FATBuf  fmtParamBuf_FAT;
       
  1422     TVolFormatParam_FAT&    fmtParam_FAT = fmtParamBuf_FAT();
       
  1423 
       
  1424     fmtParam_FAT.SetFatSubType(EFat32);
       
  1425     test(fmtParam_FAT.FatSubType() == EFat32);
       
  1426     
       
  1427     fmtParam_FAT.SetFatSubType(EFat12);
       
  1428     test(fmtParam_FAT.FatSubType() == EFat12);
       
  1429      
       
  1430     fmtParam_FAT.SetFatSubType(EFat16);
       
  1431     test(fmtParam_FAT.FatSubType() == EFat16);
       
  1432 
       
  1433     fmtParam_FAT.SetFatSubType(ENotSpecified);
       
  1434     test(fmtParam_FAT.FatSubType() == ENotSpecified);
       
  1435 
       
  1436     fmtParam_FAT.SetFatSubType(KFSSubType_FAT32);
       
  1437     test(fmtParam_FAT.FatSubType() == EFat32);
       
  1438     
       
  1439     fmtParam_FAT.SetFatSubType(KFSSubType_FAT12);
       
  1440     test(fmtParam_FAT.FatSubType() == EFat12);
       
  1441      
       
  1442     fmtParam_FAT.SetFatSubType(KFSSubType_FAT16);
       
  1443     test(fmtParam_FAT.FatSubType() == EFat16);
       
  1444 
       
  1445     
       
  1446     fmtParam_FAT.SetSectPerCluster(64);
       
  1447     test(fmtParam_FAT.SectPerCluster()==64);
       
  1448 
       
  1449     fmtParam_FAT.SetNumFATs(1);
       
  1450     test(fmtParam_FAT.NumFATs()==1);
       
  1451 
       
  1452     fmtParam_FAT.SetReservedSectors(13);
       
  1453     test(fmtParam_FAT.ReservedSectors()==13);
       
  1454 
       
  1455     
       
  1456     fmtParam_FAT.Init();
       
  1457     test(fmtParam_FAT.FatSubType() == ENotSpecified);
       
  1458     test(fmtParam_FAT.SectPerCluster() == 0);
       
  1459     test(fmtParam_FAT.NumFATs()==0);
       
  1460     test(fmtParam_FAT.ReservedSectors()==0);
       
  1461 
       
  1462     
       
  1463     //--- formatting FAT without specifying any parameters. This shall always succeed
       
  1464     test.Printf(_L("fmt: using TVolFormatParam_FAT, no parameters.\n"));
       
  1465 
       
  1466     fmtParam_FAT.Init();
       
  1467 
       
  1468     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_FAT);
       
  1469     test(nRes==KErrNone);
       
  1470     
       
  1471     nRes = DoFormatSteps(format, fmtCnt);
       
  1472     test(nRes==KErrNone);
       
  1473 
       
  1474     format.Close();
       
  1475 
       
  1476     //-- formatting FAT with specifying some parameters. This may fail because the media doesn't support overriding FAT parameters
       
  1477     //-- or because this parameters combination isn't compatible with the volume geometry.
       
  1478 
       
  1479     test.Printf(_L("fmt: using TVolFormatParam_FAT, some FAT specific parameters.\n"));
       
  1480     fmtParam_FAT.SetFatSubType(EFat32);
       
  1481     fmtParam_FAT.SetSectPerCluster(1);
       
  1482     fmtParam_FAT.SetNumFATs(1);
       
  1483     fmtParam_FAT.SetReservedSectors(13);
       
  1484 
       
  1485     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_FAT);
       
  1486     test(nRes==KErrNone);
       
  1487     
       
  1488     nRes = DoFormatSteps(format, fmtCnt);
       
  1489     if(nRes != KErrNone)
       
  1490     {
       
  1491         test.Printf(_L("formatting failed. reason code:%d\n"), nRes);        
       
  1492     }
       
  1493 
       
  1494     format.Close();
       
  1495 
       
  1496     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1497     test(fsName.CompareF(KFSName1) == 0); 
       
  1498 
       
  1499     CheckFsOperations();
       
  1500 
       
  1501 }
       
  1502 
       
  1503 //-------------------------------------------------------------------
       
  1504 /**
       
  1505     Test formatting FAT file system with some specific parameters, like sector per cluster etc.
       
  1506     Note that some media types (like SD cards) do not support such type of formatting. 
       
  1507 */
       
  1508 
       
  1509 void TestFormatting_FsName_Parameters_exFAT()
       
  1510 {
       
  1511     using namespace FileSystem_EXFAT;
       
  1512 
       
  1513     test.Next(_L("Testing TVolFormatParam_exFAT formatting API\n"));
       
  1514 
       
  1515     TInt nRes;
       
  1516     TBuf<40>    fsName(0);
       
  1517    
       
  1518     TBuf<10>    drivePath;
       
  1519     drivePath.Format(_L("%C:\\"), gDriveNum+'A');
       
  1520 
       
  1521     RFormat     format;
       
  1522     TUint       fmtMode = EQuickFormat | ESpecialFormat;
       
  1523     TInt        fmtCnt;
       
  1524 
       
  1525 
       
  1526     //================================================================================
       
  1527     //-- 0. prepare the volume
       
  1528     Mount_FileSystem2();    
       
  1529     FormatVolume(); //-- old API, formatting with all parameters by default
       
  1530 
       
  1531     //================================================================================
       
  1532     //-- 1.0  simple unit test for TVolFormatParam_FAT
       
  1533 
       
  1534     TVolFormatParam_exFATBuf    fmtParamBuf_exFAT;
       
  1535     TVolFormatParam_exFAT&      fmtParam = fmtParamBuf_exFAT();
       
  1536 
       
  1537     fmtParam.SetSectPerCluster(64);
       
  1538     test(fmtParam.SectPerCluster()==64);
       
  1539 
       
  1540     fmtParam.SetSectPerCluster(14);
       
  1541     test(fmtParam.SectPerCluster()==14);
       
  1542 
       
  1543     fmtParam.SetNumFATs(1);
       
  1544     test(fmtParam.NumFATs()==1);
       
  1545 
       
  1546     fmtParam.SetNumFATs(2);
       
  1547     test(fmtParam.NumFATs()==2);
       
  1548 
       
  1549     fmtParam.Init();
       
  1550     test(fmtParam.SectPerCluster() == 0);
       
  1551     test(fmtParam.NumFATs()==0);
       
  1552 
       
  1553 
       
  1554     //--- formatting exFAT without specifying any parameters. This shall always succeed
       
  1555     test.Printf(_L("fmt: using TVolFormatParam_exFAT, no parameters.\n"));
       
  1556     fmtParam.Init();
       
  1557     
       
  1558     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_exFAT);
       
  1559     test(nRes==KErrNone);
       
  1560     
       
  1561     nRes = DoFormatSteps(format, fmtCnt);
       
  1562     test(nRes==KErrNone);
       
  1563 
       
  1564     format.Close();
       
  1565 
       
  1566     //-- formatting exFAT with specifying some parameters. This may fail because the media doesn't support overriding FAT parameters
       
  1567     //-- or because this parameters combination isn't compatible with the volume geometry.
       
  1568 
       
  1569     test.Printf(_L("fmt: using TVolFormatParam_exFAT, some exFAT specific parameters.\n"));
       
  1570 
       
  1571     fmtParam.SetSectPerCluster(1);
       
  1572     fmtParam.SetNumFATs(2);
       
  1573 
       
  1574     nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_exFAT);
       
  1575     test(nRes==KErrNone);
       
  1576     
       
  1577     nRes = DoFormatSteps(format, fmtCnt);
       
  1578     if(nRes != KErrNone)
       
  1579     {
       
  1580         test.Printf(_L("formatting failed. reason code:%d\n"), nRes);        
       
  1581     }
       
  1582 
       
  1583     format.Close();
       
  1584 
       
  1585     nRes = TheFs.FileSystemName(fsName, gDriveNum);
       
  1586     test(fsName.CompareF(KFSName2) == 0); 
       
  1587 
       
  1588     CheckFsOperations();
       
  1589 }
       
  1590 
       
  1591 //-------------------------------------------------------------------
       
  1592 
       
  1593 void CallTestsL()
       
  1594     {
       
  1595 
       
  1596     
       
  1597     //-- set up console output
       
  1598     Fat_Test_Utils::SetConsole(test.Console());
       
  1599 
       
  1600 #ifndef _DEBUG
       
  1601     //-- automounter has a special debug interface allowing to control child file ssytems mounting in _DEBUG mode only
       
  1602     test.Printf(_L("Skipping the test in the Release build! \n"));
       
  1603     return;
       
  1604 #else
       
  1605 
       
  1606     TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
       
  1607     test(nRes==KErrNone);
       
  1608 
       
  1609 
       
  1610     //-------------------------------------
       
  1611 
       
  1612     PrintDrvInfo(TheFs, gDriveNum);
       
  1613 
       
  1614     TVolumeInfo v;
       
  1615     nRes = TheFs.Volume(v);
       
  1616     test(nRes==KErrNone);
       
  1617     if(v.iDrive.iMediaAtt & KMediaAttVariableSize)
       
  1618         {
       
  1619         test.Printf(_L("Skipping. Internal ram drive not tested.\n"));
       
  1620         return;
       
  1621         }
       
  1622 
       
  1623     if(v.iDrive.iType != EMediaHardDisk || !(v.iDrive.iDriveAtt & KDriveAttRemovable)) 
       
  1624         {
       
  1625         test.Printf(_L("The drive shall be removable and the media type EMediaHardDisk. Skipping.\n"));
       
  1626         return;
       
  1627         }
       
  1628 
       
  1629     
       
  1630     //-------------------------------------
       
  1631 
       
  1632     if(InitGlobals())
       
  1633         {//-- do tests here
       
  1634     
       
  1635           TestAutomounterBasics();
       
  1636           TestDismounting(); 
       
  1637           TestFixedFsFormatting_FsNameSpecified();  
       
  1638 
       
  1639           TestAutomounterDefaultFormatting();
       
  1640           TestAutomounterFormatting_FsNameSpecified();
       
  1641 
       
  1642           TestFormatting_FsName_Parameters_FAT();
       
  1643           TestFormatting_FsName_Parameters_exFAT();
       
  1644         
       
  1645         }
       
  1646     //-------------------------------------
       
  1647     DestroyGlobals();
       
  1648 #endif
       
  1649     }
       
  1650 
       
  1651 
       
  1652 
       
  1653 
       
  1654 
       
  1655 
       
  1656 
       
  1657 
       
  1658 
       
  1659 
       
  1660 
       
  1661 
       
  1662 
       
  1663 
       
  1664 
       
  1665 
       
  1666 
       
  1667