1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/filesystem/automounter/t_automounter.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1693 @@
1.4 +// Copyright (c) 1996-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of the License "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +// Testing "automounter" filesystem plugin functionality.
1.19 +//
1.20 +//
1.21 +
1.22 +/**
1.23 + @file
1.24 +*/
1.25 +
1.26 +#define __E32TEST_EXTENSION__
1.27 +
1.28 +#include <f32file.h>
1.29 +#include <e32test.h>
1.30 +#include <e32math.h>
1.31 +#include <e32property.h>
1.32 +#include <f32dbg.h>
1.33 +
1.34 +#include "filesystem_fat.h"
1.35 +#include "filesystem_automounter.h"
1.36 +
1.37 +
1.38 +#include "t_server.h"
1.39 +#include "fat_utils.h"
1.40 +
1.41 +using namespace Fat_Test_Utils;
1.42 +
1.43 +
1.44 +
1.45 +
1.46 +RTest test(_L("T_Automounter"));
1.47 +
1.48 +static TInt gDriveNum=-1; ///< drive number we are dealing with
1.49 +
1.50 +//-------------------------------------------------------------------
1.51 +//-- the debug test property string can be used to control automounter in debug mode.
1.52 +const TUid KThisTestSID={0x10210EB3}; ///< this EXE SID
1.53 +
1.54 +//-------------------------------------------------------------------
1.55 +//-- Actually, for testing autoounter, it is neccessary to have at least 3 filesystems:
1.56 +//-- automounter itself and any 2 dirrerent filesystems that can be used as child ones.
1.57 +//-- Let's use FAT as a 1st child, and exFAT as 2nd. All these 3 *.fsy shall be present.
1.58 +
1.59 +/** automounter filesystem name */
1.60 +#define KAutoMounterFSName KFileSystemName_AutoMounter
1.61 +_LIT(KAutoMounterFsy, "automounter.fsy"); ///< automounter *.fsy module name
1.62 +
1.63 +
1.64 +//-- FAT is used as a child filesystem #0
1.65 +
1.66 +/** filesystem #1 name */
1.67 +#define KFSName1 KFileSystemName_FAT
1.68 +
1.69 +#if defined(__WINS__) //-- FAT fsy name is a mess.
1.70 +_LIT(KFsy1, "efat32.fsy");
1.71 +#else
1.72 +_LIT(KFsy1, "elocal.fsy");
1.73 +#endif
1.74 +
1.75 +
1.76 +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1.77 +//-- exFAT is used as a child filesystem #1. The problem here: some poor guys might not have the exFAT at all including the header file
1.78 +//-- "filesystem_exfat.h" that defines exFAT volume formatting structure. Fortunately for them the exFAT formatting parameters like "sectors per cluster" and
1.79 +//-- "number of FATs" have the same layout in the data container as FAT ones. So FAT formatting structure can be used for formatting exFAT.
1.80 +//-- The macro defines if exFAT might not be available.
1.81 +#define EXFAT_MIGHT_NOT_BE_PRESENT
1.82 +
1.83 +/** filesystem #2 name */
1.84 +#ifdef EXFAT_MIGHT_NOT_BE_PRESENT
1.85 + _LIT(KFSName2, "exFAT");
1.86 +#else
1.87 + #define KFSName2 KFileSystemName_exFAT
1.88 + #include "filesystem_exfat.h"
1.89 + using namespace FileSystem_EXFAT;
1.90 +#endif
1.91 +
1.92 +
1.93 +
1.94 +
1.95 +_LIT(KFsy2, "exfat.fsy"); ///< filesystem #2 *.fsy module name
1.96 +
1.97 +TBool automounter_Loaded = EFalse; ///< ETrue if automounter.fsy is loaded; used for correct cleanup
1.98 +TBool childFs1_Loaded = EFalse; ///< ETrue if child #0 *.fsy is loaded; used for correct cleanup
1.99 +TBool childFs2_Loaded = EFalse; ///< ETrue if child #1 *.fsy is loaded; used for correct cleanup
1.100 +
1.101 +TFSDescriptor orgFsDescriptor; //-- keeps parameters of the original FS
1.102 +
1.103 +//-------------------------------------------------------------------
1.104 +
1.105 +/**
1.106 + perform some operations to see if the file system works at all
1.107 +*/
1.108 +void CheckFsOperations()
1.109 +{
1.110 + TInt nRes;
1.111 +
1.112 + TVolumeInfo v;
1.113 + nRes = TheFs.Volume(v);
1.114 + test_KErrNone(nRes);
1.115 +
1.116 + _LIT(KTestDir, "\\directory1\\DIR2\\another directory\\");
1.117 + MakeDir(KTestDir);
1.118 +
1.119 + _LIT(KTestFile, "\\this is a file to test.bin");
1.120 + nRes = CreateCheckableStuffedFile(TheFs, KTestFile, 20376);
1.121 + test_KErrNone(nRes);
1.122 +
1.123 + nRes = VerifyCheckableFile(TheFs, KTestFile);
1.124 + test_KErrNone(nRes);
1.125 +
1.126 + nRes = TheFs.Delete(KTestFile);
1.127 + test_KErrNone(nRes);
1.128 +
1.129 +}
1.130 +
1.131 +//-------------------------------------------------------------------
1.132 +
1.133 +/**
1.134 + Check that FileSystem1 subtype matches one of the expected
1.135 +*/
1.136 +void CheckSubtype_FS1(const TDesC& aFsSubtype)
1.137 +{
1.138 + _LIT(KFatSubType12, "fat12");
1.139 + _LIT(KFatSubType16, "fat16");
1.140 + _LIT(KFatSubType32, "fat32");
1.141 +
1.142 + test(aFsSubtype.CompareF(KFatSubType12) == 0 || aFsSubtype.CompareF(KFatSubType16) == 0 || aFsSubtype.CompareF(KFatSubType32) == 0 );
1.143 +}
1.144 +
1.145 +//-------------------------------------------------------------------
1.146 +
1.147 +/**
1.148 + Check that FileSystem2 subtype matches expected
1.149 +*/
1.150 +void CheckSubtype_FS2(const TDesC& aFsSubtype)
1.151 +{
1.152 + _LIT(KExFatSubType, "exFAT");
1.153 + test(aFsSubtype.CompareF(KExFatSubType) == 0);
1.154 +}
1.155 +
1.156 +
1.157 +//-------------------------------------------------------------------
1.158 +/**
1.159 + Dismounts Currently mounted file system.
1.160 +*/
1.161 +static TInt DoDismountFS()
1.162 +{
1.163 + TBuf<40> fsName(0);
1.164 + TInt nRes;
1.165 +
1.166 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.167 + if(nRes == KErrNone)
1.168 + {
1.169 + test.Printf(_L("--- Dismounting FS:%S\n"), &fsName);
1.170 + nRes = TheFs.DismountFileSystem(fsName, gDriveNum);
1.171 + return nRes;
1.172 + }
1.173 +
1.174 + return KErrNone; //-- no file system mounted
1.175 +}
1.176 +
1.177 +//-------------------------------------------------------------------
1.178 +/**
1.179 + Dismounts Currently mounted file system.
1.180 +*/
1.181 +static void DismountFS()
1.182 +{
1.183 + test(DoDismountFS() == KErrNone);
1.184 +}
1.185 +
1.186 +//-------------------------------------------------------------------
1.187 +/**
1.188 + Dismounts Currently mounted file system.
1.189 +*/
1.190 +static void ForceDismountFS()
1.191 +{
1.192 + test.Printf(_L("--- Force dismounting current FS\n"));
1.193 + TRequestStatus stat;
1.194 + TheFs.NotifyDismount(gDriveNum, stat, EFsDismountForceDismount);
1.195 + User::WaitForRequest(stat);
1.196 + test(stat.Int() == KErrNone);
1.197 +}
1.198 +
1.199 +
1.200 +
1.201 +//-------------------------------------------------------------------
1.202 +/**
1.203 + Mount the given file system. Mounting file system doesn't mean that it will be usable.
1.204 + For example, KErrCorrupt can be the result if FS doesn't recognise bootsectors etc.
1.205 +
1.206 + @param aFsName file system name
1.207 + @return error code
1.208 +*/
1.209 +static TInt DoMountFS(const TDesC& aFsName)
1.210 +{
1.211 + TInt nRes;
1.212 + test.Printf(_L("+++ Mounting FS:%S\n"), &aFsName);
1.213 +
1.214 + TFSDescriptor newFsDescriptor = orgFsDescriptor;
1.215 + newFsDescriptor.iFsName = aFsName;
1.216 + test(!newFsDescriptor.iDriveSynch); //-- mount the given FS as asynchronous one, the automounter can't be used on a synchronous drive anyway.
1.217 +
1.218 + nRes = MountFileSystem(TheFs, gDriveNum, newFsDescriptor);
1.219 +
1.220 + if(nRes != KErrNone)
1.221 + {
1.222 + test.Printf(_L("++> Error Mounting FS! code:%d\n"), nRes);
1.223 + }
1.224 + else
1.225 + {
1.226 + PrintDrvInfo(TheFs, gDriveNum);
1.227 + }
1.228 +
1.229 +
1.230 + return nRes;
1.231 +}
1.232 +
1.233 +
1.234 +//-------------------------------------------------------------------
1.235 +/**
1.236 + Explicitly mount the "automounter" FS
1.237 +*/
1.238 +static void Mount_AutomounterFS()
1.239 +{
1.240 + DismountFS();
1.241 + DoMountFS(KAutoMounterFSName);
1.242 +}
1.243 +
1.244 +//-------------------------------------------------------------------
1.245 +/**
1.246 + Explicitly mount the FileSystem1
1.247 +*/
1.248 +static void Mount_FileSystem1()
1.249 +{
1.250 + DismountFS();
1.251 + DoMountFS(KFSName1);
1.252 +
1.253 +}
1.254 +
1.255 +//-------------------------------------------------------------------
1.256 +/**
1.257 + Explicitly mount the FileSystem2
1.258 +*/
1.259 +static void Mount_FileSystem2()
1.260 +{
1.261 + DismountFS();
1.262 + DoMountFS(KFSName2);
1.263 +}
1.264 +
1.265 +//-------------------------------------------------------------------
1.266 +/**
1.267 + Just fill first 32 sectors with zeroes.
1.268 + The volume will require formatting after this.
1.269 +*/
1.270 +static void CorruptDrive()
1.271 +{
1.272 + TInt nRes;
1.273 + test.Printf(_L("!!! corrupting the drive...\n"));
1.274 +
1.275 + RRawDisk rawDisk;
1.276 + nRes = rawDisk.Open(TheFs, gDriveNum);
1.277 + test(nRes == KErrNone);
1.278 +
1.279 + TBuf8<512> sectorBuf(512);
1.280 +
1.281 + sectorBuf.FillZ();
1.282 +
1.283 + const TInt KSectors = 32;
1.284 + TInt64 mediaPos = 0;
1.285 +
1.286 + for(TInt i=0; i<KSectors; ++i)
1.287 + {
1.288 + nRes = rawDisk.Write(mediaPos, sectorBuf);
1.289 + test(nRes == KErrNone);
1.290 +
1.291 + mediaPos += sectorBuf.Size();
1.292 + }
1.293 +
1.294 + rawDisk.Close();
1.295 +}
1.296 +
1.297 +//-------------------------------------------------------------------
1.298 +
1.299 +
1.300 +/**
1.301 + quick format the volume using all parameter by default
1.302 +*/
1.303 +static void FormatVolume(TBool aQuickFormat = ETrue)
1.304 +{
1.305 + TInt nRes;
1.306 + nRes = FormatDrive(TheFs, CurrentDrive(), aQuickFormat);
1.307 + test_KErrNone(nRes);
1.308 +}
1.309 +
1.310 +
1.311 +//-------------------------------------------------------------------
1.312 +TInt DoFormatSteps(RFormat& aFormat, TInt& aFmtCnt)
1.313 +{
1.314 + TInt nRes = KErrNone;
1.315 +
1.316 + while(aFmtCnt)
1.317 + {
1.318 + nRes = aFormat.Next(aFmtCnt);
1.319 + if(nRes != KErrNone)
1.320 + {
1.321 + test.Printf(_L("RFormat::Next() failed! code:%d\n"), nRes);
1.322 + break;
1.323 + }
1.324 + }
1.325 +
1.326 + return nRes;
1.327 +}
1.328 +
1.329 +//-------------------------------------------------------------------
1.330 +
1.331 +/**
1.332 + initialise test global objects
1.333 + @return EFalse if something goes wrong
1.334 +*/
1.335 +TBool InitGlobals()
1.336 +{
1.337 +#ifndef _DEBUG
1.338 + test.Printf(_L("This test can't be performed in RELEASE mode! Skipping.\n"));
1.339 + test(0);
1.340 +#endif
1.341 +
1.342 + TInt nRes;
1.343 +
1.344 + //-- store original file system parameters
1.345 + nRes = GetFileSystemDescriptor(TheFs, gDriveNum, orgFsDescriptor);
1.346 + test_KErrNone(nRes);
1.347 +
1.348 +
1.349 + //=======================================
1.350 + //-- define a text propery that will override automounter config string in estart.txt
1.351 + //-- automounter must be able to parse this string.
1.352 + //-- The property key is a drive number being tested
1.353 + {
1.354 + const TUint KPropKey = 0; //-- property key
1.355 + _LIT_SECURITY_POLICY_PASS(KTestPropPolicy);
1.356 +
1.357 + nRes = RProperty::Define(KThisTestSID, KPropKey, RProperty::EText, KTestPropPolicy, KTestPropPolicy);
1.358 + test(nRes == KErrNone || nRes == KErrAlreadyExists);
1.359 +
1.360 + //-- set the propery, it will override automounter config from estart.txt.
1.361 + //-- the config string has following format: "<fs_name1>,<fsname2>"
1.362 +
1.363 + TBuf8<50> cfgBuf(0);
1.364 + cfgBuf.Append(KFSName1);
1.365 + cfgBuf.Append(_L(" , "));
1.366 + cfgBuf.Append(KFSName2);
1.367 +
1.368 +
1.369 + nRes = RProperty::Set(KThisTestSID, KPropKey, cfgBuf);
1.370 + test_KErrNone(nRes);
1.371 +
1.372 + }
1.373 +
1.374 + //=======================================
1.375 + //-- we must ensure that all 3 required *.fsy are present and load them.
1.376 + //-- the automounter must have child filesystems loaded before its initialisation.
1.377 + {
1.378 + _LIT(KFsyFailure, "can't load '%S', code:%d, the test can't be performed!\n");
1.379 +
1.380 + //-- child FS #0
1.381 + nRes = TheFs.AddFileSystem(KFsy1);
1.382 + if(nRes != KErrNone && nRes != KErrAlreadyExists)
1.383 + {
1.384 + test.Printf(KFsyFailure, &KFsy1, nRes);
1.385 + return EFalse;
1.386 + }
1.387 + childFs1_Loaded = ETrue;
1.388 +
1.389 +
1.390 + //-- child FS #1
1.391 + nRes = TheFs.AddFileSystem(KFsy2);
1.392 + if(nRes != KErrNone && nRes != KErrAlreadyExists)
1.393 + {
1.394 + test.Printf(KFsyFailure, &KFsy2, nRes);
1.395 + return EFalse;
1.396 + }
1.397 + childFs2_Loaded = ETrue;
1.398 +
1.399 + //-- automounter
1.400 + nRes = TheFs.AddFileSystem(KAutoMounterFsy);
1.401 + if(nRes != KErrNone && nRes != KErrAlreadyExists)
1.402 + {
1.403 + test.Printf(KFsyFailure, &KAutoMounterFsy, nRes);
1.404 + return EFalse;
1.405 + }
1.406 + automounter_Loaded = ETrue;
1.407 + }
1.408 +
1.409 +
1.410 + //=======================================
1.411 + //-- dismount original file system and optional primary extension. Secondary extensions are not supported.
1.412 +
1.413 + test.Printf(_L("Dismounting the original FS:%S, PExt:%S \n"), &orgFsDescriptor.iFsName, &orgFsDescriptor.iPExtName);
1.414 +
1.415 + nRes = TheFs.DismountFileSystem(orgFsDescriptor.iFsName, gDriveNum);
1.416 + test_KErrNone(nRes);
1.417 +
1.418 + return ETrue;
1.419 +}
1.420 +
1.421 +//-------------------------------------------------------------------
1.422 +/** destroy test global objects */
1.423 +void DestroyGlobals()
1.424 +{
1.425 + test.Printf(_L("Restoring the environment....\n"));
1.426 +
1.427 + TInt nRes;
1.428 +
1.429 + //=======================================
1.430 + //-- dismount current filesystem that was used for testing and mount the original filesystem
1.431 + if(orgFsDescriptor.iFsName.Length())
1.432 + {//-- the original file system had been dismounted during test initialisation; dismount whatever we have now
1.433 + test.Printf(_L("Mounting back the original FS:%S, PExt:%S \n"), &orgFsDescriptor.iFsName, &orgFsDescriptor.iPExtName);
1.434 +
1.435 + TBuf<40> fsName;
1.436 +
1.437 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.438 + if(nRes == KErrNone && fsName.CompareF(orgFsDescriptor.iFsName) != KErrNone)
1.439 + {
1.440 + nRes = TheFs.DismountFileSystem(fsName, gDriveNum);
1.441 + test_KErrNone(nRes);
1.442 +
1.443 +
1.444 + //-- mount original FS as asynchronous one, the automounter can't be used on a synchronous drive anyway.
1.445 + MountFileSystem(TheFs, gDriveNum, orgFsDescriptor);
1.446 +
1.447 + FormatVolume();
1.448 + }
1.449 + }
1.450 +
1.451 + //=======================================
1.452 + //-- delete test property
1.453 + RProperty::Delete(KThisTestSID, gDriveNum);
1.454 +
1.455 + //=======================================
1.456 + //-- if the original FS wasn't automounter, unload child file systems
1.457 + if(orgFsDescriptor.iFsName.CompareF(KFileSystemName_AutoMounter) != 0)
1.458 + {
1.459 +
1.460 + if(childFs1_Loaded)
1.461 + {
1.462 + nRes = TheFs.RemoveFileSystem(KFSName1);
1.463 + test(nRes == KErrNone || nRes == KErrInUse); //-- if the FS was used on some drive before test started, It will be KErrInUse
1.464 + childFs1_Loaded = EFalse;
1.465 + }
1.466 +
1.467 + if(childFs2_Loaded)
1.468 + {
1.469 + nRes = TheFs.RemoveFileSystem(KFSName2);
1.470 + test(nRes == KErrNone || nRes == KErrInUse); //-- if the FS was used on some drive before test started, It will be KErrInUse
1.471 + childFs2_Loaded = EFalse;
1.472 + }
1.473 +
1.474 +
1.475 + //-- unload test filesystem modules
1.476 + if(automounter_Loaded)
1.477 + {
1.478 + nRes = TheFs.RemoveFileSystem(KAutoMounterFSName); //-- if the FS was used on some drive before test started, It will be KErrInUse
1.479 + test(nRes == KErrNone || nRes == KErrInUse);
1.480 + automounter_Loaded = EFalse;
1.481 + }
1.482 + }
1.483 + else
1.484 + {
1.485 + nRes = RemountFS(TheFs, gDriveNum);
1.486 + test(nRes == KErrNone);
1.487 + }
1.488 +
1.489 + TVolumeInfo v;
1.490 + TheFs.Volume(v);
1.491 +}
1.492 +
1.493 +//-------------------------------------------------------------------
1.494 +
1.495 +/*
1.496 + Testing basic automounter functionality. Format media with different file systems FS1/FS2, mount automounter and
1.497 + ensure that it recognised and successfully mounts appropriate child file system.
1.498 +
1.499 +
1.500 + 1.1 mount "filesystem1" / format volume
1.501 + 1.2 check file system name / subtype / functionality
1.502 + 1.3 corrupt "filesystem1"
1.503 + 1.4 check file system name / subtype
1.504 +
1.505 +
1.506 + 2.1 mount "automounter"
1.507 + 2.2 check file system name / subtype / functionality (this must correspond to the filesystem1) The "filesystem1" must be recognised
1.508 +
1.509 + 3.1 mount "filesystem2" / format volume
1.510 + 3.2 check file system name / subtype / functionality
1.511 + 3.3 corrupt "filesystem2"
1.512 + 3.4 check file system name / subtype
1.513 + 3.5 format volume (it will be filesystem2)
1.514 +
1.515 + 4.1 mount "automounter"
1.516 + 4.2 check file system name / subtype / functionality (this must correspond to the filesystem2) The "filesystem2" must be recognised
1.517 +
1.518 +
1.519 + 5. check the list of supported file systems on the drive
1.520 +
1.521 + 6.1 corrupt the volume
1.522 + 6.2 check that automounter can't recognise it
1.523 +
1.524 + 7. restore "filesystem1" / format volume
1.525 +*/
1.526 +void TestAutomounterBasics()
1.527 +{
1.528 +
1.529 + test.Next(_L("Testing automounter basic functionality \n"));
1.530 +
1.531 + TVolumeInfo v;
1.532 + TBuf<40> fsName(0);
1.533 + TBuf<40> fsSubType(0);
1.534 + TInt nRes;
1.535 +
1.536 + //================================================================================
1.537 + //-- 1. mount "filesystem1" / format volume
1.538 + test.Printf(_L("Mounting FileSystem1...\n"));
1.539 + Mount_FileSystem1();
1.540 +
1.541 + FormatVolume();
1.542 +
1.543 + nRes = TheFs.Volume(v);
1.544 + test_KErrNone(nRes);
1.545 +
1.546 + //-- check file system name / subtype etc.
1.547 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.548 + test_KErrNone(nRes);
1.549 + test(fsName.CompareF(KFSName1) == 0);
1.550 +
1.551 +
1.552 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.553 + test_KErrNone(nRes);
1.554 + CheckSubtype_FS1(fsSubType);
1.555 +
1.556 + //-- check the list of supported file systems on this drive (there is only 1 FS supported).
1.557 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, -1);
1.558 + test(nRes == KErrArgument);
1.559 +
1.560 + fsName.SetLength(0);
1.561 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem
1.562 + test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0);
1.563 +
1.564 + fsName.SetLength(0);
1.565 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem
1.566 + test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0);
1.567 +
1.568 + fsName.SetLength(0);
1.569 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- there are no more supported FSs
1.570 + test(nRes == KErrNotFound);
1.571 +
1.572 + //-- perform some operation
1.573 + CheckFsOperations();
1.574 +
1.575 +
1.576 + //================================================================================
1.577 + //-- 2. Now we have volume formatted for "filesystem1"; Mount "automounter" and check that the
1.578 + //-- file system on the volume is recognised OK.
1.579 + test.Printf(_L("Mounting Automounter FS and checking its functionality ...\n"));
1.580 + Mount_AutomounterFS();
1.581 +
1.582 + nRes = TheFs.Volume(v);
1.583 + test_KErrNone(nRes);
1.584 +
1.585 + //-- check file system name / subtype etc.
1.586 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.587 + test_KErrNone(nRes);
1.588 +
1.589 + //-- the FS Subtype must be the subtype of the recognised child FS
1.590 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.591 + test_KErrNone(nRes);
1.592 +
1.593 + test.Printf(_L("FS name:'%S', FS Subtype:'%S'\n") ,&fsName, &fsSubType);
1.594 +
1.595 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.596 + CheckSubtype_FS1(fsSubType);
1.597 +
1.598 +
1.599 +
1.600 + //================================================================================
1.601 + //-- dismount current file system
1.602 + test.Printf(_L("Dismomounting FileSystem1...\n"));
1.603 + DismountFS();
1.604 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.605 + test(nRes == KErrNotFound);
1.606 +
1.607 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem
1.608 + test(nRes == KErrNotFound);
1.609 +
1.610 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem
1.611 + test(nRes == KErrNotFound);
1.612 +
1.613 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.614 + test(nRes == KErrNotReady);
1.615 +
1.616 +
1.617 + //================================================================================
1.618 + //-- 3. mount "filesystem2" / format volume
1.619 + test.Printf(_L("Mounting FileSystem2...\n"));
1.620 + Mount_FileSystem2();
1.621 +
1.622 + FormatVolume();
1.623 +
1.624 + nRes = TheFs.Volume(v);
1.625 + test_KErrNone(nRes);
1.626 +
1.627 + //-- check file system name / subtype etc.
1.628 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.629 + test_KErrNone(nRes);
1.630 + test(fsName.CompareF(KFSName2) == 0);
1.631 +
1.632 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.633 + test_KErrNone(nRes);
1.634 + CheckSubtype_FS2(fsSubType);
1.635 +
1.636 + //-- check the list of supported file systems on this drive (there is only 1 FS supported).
1.637 + fsName.SetLength(0);
1.638 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem
1.639 + test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0);
1.640 +
1.641 + fsName.SetLength(0);
1.642 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem
1.643 + test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0);
1.644 +
1.645 + fsName.SetLength(0);
1.646 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- there are no more supported FSs
1.647 + test(nRes == KErrNotFound);
1.648 +
1.649 + //-- perform some operation
1.650 + CheckFsOperations();
1.651 +
1.652 +
1.653 + //================================================================================
1.654 + //-- 4. Now we have volume formatted for "filesystem2"; Mount "automounter" and check that the
1.655 + //-- file system on the volume is recognised OK.
1.656 + test.Printf(_L("Mounting Automounter FS and checking its functionality ...\n"));
1.657 + Mount_AutomounterFS();
1.658 +
1.659 + nRes = TheFs.Volume(v);
1.660 + test_KErrNone(nRes);
1.661 +
1.662 + //-- check file system name / subtype etc.
1.663 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.664 + test_KErrNone(nRes);
1.665 +
1.666 + //-- the FS Subtype must be the subtype of the recognised child FS
1.667 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.668 + test_KErrNone(nRes);
1.669 +
1.670 + test.Printf(_L("FS name:'%S', FS Subtype:'%S'\n") ,&fsName, &fsSubType);
1.671 +
1.672 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.673 + CheckSubtype_FS2(fsSubType);
1.674 +
1.675 + //================================================================================
1.676 + //-- 5. check the list of supported file systems on this drive (there must be 2 child FS supported).
1.677 + test.Printf(_L("Getting list of supported by automounter file systems ...\n"));
1.678 +
1.679 + fsName.SetLength(0);
1.680 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, RFs::KRootFileSystem); //-- "root" filesystem
1.681 + test(nRes == KErrNone && fsName.CompareF(KAutoMounterFSName) == 0);
1.682 + test.Printf(_L("Root FS:'%S'\n"), &fsName);
1.683 +
1.684 +
1.685 + fsName.SetLength(0);
1.686 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 0); //-- 1st "child" filesystem
1.687 + test(nRes == KErrNone && fsName.CompareF(KFSName1) == 0);
1.688 +
1.689 + fsName.SetLength(0);
1.690 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 1); //-- 2nd "child" filesystem
1.691 + test(nRes == KErrNone && fsName.CompareF(KFSName2) == 0);
1.692 +
1.693 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, 2); //-- 3rd "child" filesystem
1.694 + test(nRes == KErrNotFound);
1.695 +
1.696 + //-- get and print out list of all child FS (enumeration example)
1.697 + TInt i;
1.698 + for(i=0; ;++i)
1.699 + {
1.700 + nRes = TheFs.SupportedFileSystemName(fsName, gDriveNum, i);
1.701 + if(nRes == KErrNone)
1.702 + {
1.703 + test.Printf(_L("child FS[%d]:'%S'\n"), i, &fsName);
1.704 + }
1.705 + else
1.706 + {
1.707 + test(nRes == KErrNotFound);
1.708 + break;
1.709 + }
1.710 +
1.711 + }
1.712 +
1.713 + //-- perform some operation. They will happen on currently active child FS
1.714 + CheckFsOperations();
1.715 +
1.716 + //================================================================================
1.717 + //-- 6. corrupt the media, mount automounter, check that FS is not recognised.
1.718 + test.Printf(_L("Test automounter handling corrupted media.\n"));
1.719 +
1.720 + CorruptDrive(); //-- the active child FS will do this and the root FS will be remounted on first access
1.721 +
1.722 + //-- check file system name / subtype etc.
1.723 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.724 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.725 + test_KErrNone(nRes);
1.726 +
1.727 + //-- the FS Subtype query requires mounted and recognised file system. this shall fail
1.728 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.729 + test(nRes == KErrCorrupt);
1.730 +
1.731 + nRes = TheFs.MkDir(_L("\\dir1\\"));
1.732 + test(nRes == KErrCorrupt);
1.733 +
1.734 +
1.735 + //================================================================================
1.736 + //-- 7. restore filesystem on the drive
1.737 + test.Printf(_L("Restoring FileSystem1.\n"));
1.738 + Mount_FileSystem1();
1.739 + FormatVolume();
1.740 +
1.741 + nRes = TheFs.Volume(v);
1.742 + test_KErrNone(nRes);
1.743 +
1.744 +}
1.745 +
1.746 +//-------------------------------------------------------------------
1.747 +/**
1.748 +
1.749 + 1.1 mount "filesystem1" / format volume
1.750 + 1.2 create and open a file on the volume.
1.751 + 1.3 dismount the file system with opened file on it.
1.752 +
1.753 + 2. mount "automounter" The "filesystem1" must be recognised
1.754 + 2.1 open previously created file (it is still opened by dismounted FS1)
1.755 +
1.756 + 3. forcedly dismount the current file system (automounter)
1.757 + 4. mount the automounter FS again. check file system name / subtype; The "filesystem1" must be recognised
1.758 + 5. try to read a file (see 2.1), using already dismounted mount; it shall result in KErrDismounted.
1.759 +*/
1.760 +void TestDismounting()
1.761 +{
1.762 + test.Next(_L("Testing media dismounting/remounting with automounter FS \n"));
1.763 +
1.764 + TInt nRes;
1.765 + TBuf<40> fsName(0);
1.766 + TBuf<40> fsSubType(0);
1.767 + TBuf8<40> buf;
1.768 +
1.769 + //================================================================================
1.770 + //-- 1. mount "filesystem1" / format volume
1.771 + test.Printf(_L("Mounting FileSystem1 and opening a file.\n"));
1.772 + Mount_FileSystem1();
1.773 + FormatVolume();
1.774 +
1.775 + //-- create a file, open it and try to dismount FS
1.776 + _LIT(KTestFile, "\\test_file");
1.777 + nRes = CreateEmptyFile(TheFs, KTestFile, 100);
1.778 + test(nRes == KErrNone);
1.779 +
1.780 + RFile file;
1.781 +
1.782 + nRes = file.Open(TheFs, KTestFile, 0);
1.783 + test(nRes == KErrNone);
1.784 +
1.785 + //TheFs.SetDebugRegister(KFSERV);
1.786 +
1.787 + test.Printf(_L("dismounting FileSystem1 with a file opened.\n"));
1.788 + nRes = DoDismountFS();
1.789 + test(nRes == KErrInUse);
1.790 +
1.791 + file.Close();
1.792 +
1.793 + //================================================================================
1.794 + //-- 2. mount "automounter", previous FS must be recognised and set as an active child
1.795 + Mount_AutomounterFS();
1.796 +
1.797 + //-- check file system name / subtype etc.
1.798 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.799 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.800 + test_KErrNone(nRes);
1.801 +
1.802 + //-- the FS Subtype must be the subtype of the recognised child FS
1.803 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.804 + test_KErrNone(nRes);
1.805 + CheckSubtype_FS1(fsSubType);
1.806 +
1.807 + //-- open the previously created file
1.808 + nRes = file.Open(TheFs, KTestFile, 0);
1.809 + test(nRes == KErrNone);
1.810 +
1.811 + //TheFs.SetDebugRegister(KFSERV);
1.812 +
1.813 + nRes = DoDismountFS();
1.814 + test(nRes == KErrInUse); //-- opened file belongs to the child FS, actually.
1.815 +
1.816 +
1.817 + //================================================================================
1.818 + //-- 3. force dismounting the file system, this will leave hanging dismounted mount associated with this drive.
1.819 + test.Printf(_L("Force dismounting the file system.\n"));
1.820 + ForceDismountFS();
1.821 +
1.822 + //TheFs.SetDebugRegister(KFSERV);
1.823 +
1.824 + //================================================================================
1.825 + //-- 4. mount "automounter" again, this will create another instance of mount corresponding to the filesystem1
1.826 + Mount_AutomounterFS();
1.827 +
1.828 + //-- check file system name / subtype etc.
1.829 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.830 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.831 + test_KErrNone(nRes);
1.832 +
1.833 + //-- the FS Subtype must be the subtype of the recognised child FS
1.834 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.835 + test_KErrNone(nRes);
1.836 + CheckSubtype_FS1(fsSubType);
1.837 +
1.838 + //================================================================================
1.839 + //-- 5. try to read a file using already dead mount
1.840 + nRes = file.Read(0, buf, 2);
1.841 + test(nRes == KErrDisMounted);
1.842 +
1.843 + //-- this will cause the forcedly dismounted hanging mount to self-destruct
1.844 + file.Close();
1.845 +
1.846 +
1.847 + //-- open the previously created file using current alive mount.
1.848 + nRes = file.Open(TheFs, KTestFile, 0);
1.849 + test(nRes == KErrNone);
1.850 + nRes = file.Read(0, buf, 2);
1.851 + test(nRes == KErrNone);
1.852 +
1.853 + file.Close();
1.854 +
1.855 +
1.856 + //TheFs.SetDebugRegister(0x00);
1.857 +}
1.858 +
1.859 +//-------------------------------------------------------------------
1.860 +/**
1.861 + Testing legacy RFormat API in the case when the volume has "automounter" file system bound.
1.862 + The formatting is performed without specifying any parameters, i.e. "all by default"
1.863 +
1.864 + If the automounter recognises file system on the volume and successfully mounts it, the
1.865 + default formatting must be transparent, i.e. the appropriate child FS will perform it.
1.866 +
1.867 + If the automounter can't recognise the filesystem on the volume because of volume corruption or if this FS is unknown to it,
1.868 + the "default" formatting will fail with "KErrNotFound"
1.869 +*/
1.870 +void TestAutomounterDefaultFormatting()
1.871 +{
1.872 + test.Next(_L("Testing media formatting with default parameters. Automounter FS\n"));
1.873 +
1.874 + TInt nRes;
1.875 + TBuf<40> fsName(0);
1.876 + TBuf<40> fsSubType(0);
1.877 +
1.878 +
1.879 + //================================================================================
1.880 + //-- 1. mount "filesystem1" / format volume
1.881 + Mount_FileSystem1();
1.882 + FormatVolume();
1.883 +
1.884 + //================================================================================
1.885 + //-- 2. mount "automounter", previous FS must be recognised and set as an active child
1.886 + Mount_AutomounterFS();
1.887 +
1.888 + //-- check file system name / subtype etc.
1.889 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.890 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.891 + test_KErrNone(nRes);
1.892 +
1.893 + //-- the FS Subtype must be the subtype of the recognised child FS
1.894 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.895 + test_KErrNone(nRes);
1.896 + CheckSubtype_FS1(fsSubType);
1.897 +
1.898 + //================================================================================
1.899 + //-- 3. format the drive with all default parameters; the current active child FS shall be used
1.900 + //-- check that we still have automounter as "root" FS and the same active child
1.901 + FormatVolume();
1.902 +
1.903 + //-- check file system name / subtype etc.
1.904 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.905 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.906 + test_KErrNone(nRes);
1.907 +
1.908 + //-- the FS Subtype must be the subtype of the recognised child FS
1.909 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.910 + test_KErrNone(nRes);
1.911 + CheckSubtype_FS1(fsSubType);
1.912 +
1.913 + //-- perform some operations
1.914 + CheckFsOperations();
1.915 + test.Printf(_L("default formatting for FS:'%S', subtype:'%S' OK!\n"), &fsName, &fsSubType);
1.916 +
1.917 + //================================================================================
1.918 + //-- 3. mount "filesystem2" / format volume
1.919 + Mount_FileSystem2();
1.920 + FormatVolume();
1.921 +
1.922 + //================================================================================
1.923 + //-- 4. mount "automounter", previous FS must be recognised and set as an active child
1.924 + Mount_AutomounterFS();
1.925 +
1.926 + //-- check file system name / subtype etc.
1.927 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.928 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.929 + test_KErrNone(nRes);
1.930 +
1.931 + //-- the FS Subtype must be the subtype of the recognised child FS
1.932 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.933 + test_KErrNone(nRes);
1.934 + CheckSubtype_FS2(fsSubType);
1.935 +
1.936 + //================================================================================
1.937 + //-- 5. format the drive with all default parameters; the current active child FS shall be used
1.938 + //-- check that we still have automounter as "root" FS and the same active child
1.939 + FormatVolume();
1.940 +
1.941 + //-- check file system name / subtype etc.
1.942 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.943 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.944 + test_KErrNone(nRes);
1.945 +
1.946 + //-- the FS Subtype must be the subtype of the recognised child FS
1.947 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.948 + test_KErrNone(nRes);
1.949 + CheckSubtype_FS2(fsSubType);
1.950 +
1.951 + //-- perform some operations
1.952 + CheckFsOperations();
1.953 + test.Printf(_L("default formatting for FS:'%S', subtype:'%S' OK!\n"), &fsName, &fsSubType);
1.954 +
1.955 + //================================================================================
1.956 + //-- 6. corrupt the media, mount automounter, check that FS is not recognised.
1.957 + //-- default formatting shall fail, because automounter can't chose appropriate child FS
1.958 +
1.959 + CorruptDrive(); //-- the active child FS will do this and the root FS will be remounted on first access
1.960 +
1.961 + //-- check file system name / subtype etc.
1.962 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.963 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.964 + test_KErrNone(nRes);
1.965 +
1.966 + //-- the FS Subtype query requires mounted and recognised file system. this shall fail
1.967 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.968 + test(nRes == KErrCorrupt);
1.969 +
1.970 + //-- try default formatting; this shall fail with a special error code
1.971 + nRes = FormatDrive(TheFs, CurrentDrive(), ETrue);
1.972 + test(nRes == KErrNotFound);
1.973 +
1.974 + //-- try special formatting without any parameters, it shall also fail.
1.975 + RFormat format;
1.976 + TUint fmtMode = EQuickFormat | ESpecialFormat;
1.977 + TInt fmtCnt;
1.978 + TBuf<10> drivePath;
1.979 + drivePath.Format(_L("%C:\\"), gDriveNum+'A');
1.980 +
1.981 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
1.982 + test(nRes==KErrNotFound);
1.983 + format.Close();
1.984 +
1.985 +
1.986 +
1.987 + //================================================================================
1.988 + //-- 7. restore filesystem on the drive, try formatting with specifying ESpecialFormat flag, but without any formatting parameters
1.989 + //-- just to check that it works (it will not work on SD cards that do not allow ESpecialFormat)
1.990 + test.Printf(_L("Restoring FileSystem1 and use special format without any parameters\n"));
1.991 +
1.992 + Mount_FileSystem1();
1.993 + //FormatVolume();
1.994 +
1.995 +
1.996 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
1.997 + test(nRes==KErrNone);
1.998 +
1.999 + nRes = DoFormatSteps(format, fmtCnt);
1.1000 + test(nRes==KErrNone);
1.1001 +
1.1002 + format.Close();
1.1003 +
1.1004 +
1.1005 +
1.1006 + //-- check file system name / subtype etc.
1.1007 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1008 + test_KErrNone(nRes);
1.1009 + test(fsName.CompareF(KFSName1) == 0);
1.1010 +
1.1011 +
1.1012 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.1013 + test_KErrNone(nRes);
1.1014 + CheckSubtype_FS1(fsSubType);
1.1015 +
1.1016 +
1.1017 +}
1.1018 +
1.1019 +
1.1020 +
1.1021 +//-------------------------------------------------------------------
1.1022 +/**
1.1023 + Testing the use case when there is "automounter" FS bound to the drive and RFormat API that allows specifying
1.1024 + the file system name that we want to put on the volume.
1.1025 +
1.1026 + It must be possible:
1.1027 + - format the volume without specifying FS name at all (the currently active child FS will be used)
1.1028 + - format the volume with specifying FS name that belongs to one of the supported child FS. The volume shall be formatted with this FS.
1.1029 + - format the volume with specifying incorrect FS name (not supported) the RFormat::Open() must fail with KErrNotSupported.
1.1030 +
1.1031 + - 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.
1.1032 + - 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.
1.1033 +*/
1.1034 +void TestAutomounterFormatting_FsNameSpecified()
1.1035 +{
1.1036 + test.Next(_L("Testing formatting API that allows specifying particular FS. Automounter FS.\n"));
1.1037 +
1.1038 +
1.1039 + TInt nRes;
1.1040 + TBuf<40> fsName(0);
1.1041 + TBuf<40> fsSubType(0);
1.1042 +
1.1043 + TBuf<10> drivePath;
1.1044 + drivePath.Format(_L("%C:\\"), gDriveNum+'A');
1.1045 +
1.1046 + RFormat format;
1.1047 + TUint fmtMode = EQuickFormat | ESpecialFormat;
1.1048 + TInt fmtCnt;
1.1049 +
1.1050 + TVolFormatParamBuf fmtParamBuf;
1.1051 + TVolFormatParam& fmtParam = fmtParamBuf();
1.1052 +
1.1053 + //_LIT(KTestFile, "\\this is a test file");
1.1054 +
1.1055 + //================================================================================
1.1056 + //-- 0. prepare the volume
1.1057 + Mount_FileSystem1();
1.1058 + FormatVolume(); //-- old API, formatting with all parameters by default
1.1059 +
1.1060 +
1.1061 + //================================================================================
1.1062 + //-- 0.1 mount "automounter", previous FS must be recognised and set as an active child
1.1063 + Mount_AutomounterFS();
1.1064 +
1.1065 + //-- check file system name / subtype etc.
1.1066 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1067 + test(fsName.CompareF(KAutoMounterFSName) == 0); //-- the file system name shall be "automounter" - it is a root FS
1.1068 + test_KErrNone(nRes);
1.1069 +
1.1070 + //-- the FS Subtype must be the subtype of the recognised child FS
1.1071 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.1072 + test_KErrNone(nRes);
1.1073 + CheckSubtype_FS1(fsSubType);
1.1074 +
1.1075 + //================================================================================
1.1076 +
1.1077 + //-- 1.1 format the volume without specifying any parameters at all, the currently active child FS shall be used
1.1078 + test.Printf(_L("format the volume without specifying any parameters at all\n"));
1.1079 +
1.1080 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
1.1081 + test(nRes==KErrNone);
1.1082 +
1.1083 + nRes = DoFormatSteps(format, fmtCnt);
1.1084 + test(nRes==KErrNone);
1.1085 +
1.1086 + format.Close();
1.1087 +
1.1088 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1089 + test(fsName.CompareF(KAutoMounterFSName) == 0);
1.1090 +
1.1091 + //-- the FS Subtype must be the subtype of the recognised child FS
1.1092 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.1093 + test_KErrNone(nRes);
1.1094 + CheckSubtype_FS1(fsSubType);
1.1095 +
1.1096 +
1.1097 + //-- 1.2 format the volume without specifying the FS name, the currently active child FS shall be used
1.1098 + test.Printf(_L("format the volume without specifying the FS name\n"));
1.1099 + fmtParam.Init(); //-- reset all data
1.1100 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1101 + test(nRes==KErrNone);
1.1102 +
1.1103 + nRes = DoFormatSteps(format, fmtCnt);
1.1104 + test(nRes==KErrNone);
1.1105 +
1.1106 + format.Close();
1.1107 +
1.1108 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1109 + test(fsName.CompareF(KAutoMounterFSName) == 0);
1.1110 +
1.1111 + //-- the FS Subtype must be the subtype of the recognised child FS
1.1112 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.1113 + test_KErrNone(nRes);
1.1114 + CheckSubtype_FS1(fsSubType);
1.1115 +
1.1116 +
1.1117 + CheckFsOperations();
1.1118 +
1.1119 + //================================================================================
1.1120 + //-- 2. format the volume specifying _second_ child FS name
1.1121 + test.Printf(_L("format the volume specifying second child FS name\n"));
1.1122 + fmtParam.Init(); //-- reset all data
1.1123 + fmtParam.SetFileSystemName(KFSName2);
1.1124 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1125 + test(nRes==KErrNone);
1.1126 +
1.1127 + nRes =DoFormatSteps(format, fmtCnt);
1.1128 + test(nRes==KErrNone);
1.1129 +
1.1130 + format.Close();
1.1131 +
1.1132 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1133 + test(fsName.CompareF(KAutoMounterFSName) == 0);
1.1134 +
1.1135 + //-- the FS Subtype must be the subtype of the recognised child FS
1.1136 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.1137 + test_KErrNone(nRes);
1.1138 + CheckSubtype_FS2(fsSubType);
1.1139 +
1.1140 + CheckFsOperations();
1.1141 +
1.1142 +
1.1143 + //================================================================================
1.1144 + //-- 3. format the volume specifying _first_ child FS name
1.1145 + fmtParam.Init(); //-- reset all data
1.1146 + fmtParam.SetFileSystemName(KFSName1);
1.1147 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1148 + test(nRes==KErrNone);
1.1149 +
1.1150 + nRes =DoFormatSteps(format, fmtCnt);
1.1151 + test(nRes==KErrNone);
1.1152 +
1.1153 + format.Close();
1.1154 +
1.1155 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1156 + test(fsName.CompareF(KAutoMounterFSName) == 0);
1.1157 +
1.1158 + //-- the FS Subtype must be the subtype of the recognised child FS
1.1159 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.1160 + test_KErrNone(nRes);
1.1161 + CheckSubtype_FS1(fsSubType);
1.1162 +
1.1163 + CheckFsOperations();
1.1164 +
1.1165 +
1.1166 + //================================================================================
1.1167 + //-- 4. try formatting the volume specifying wrond child FS name
1.1168 + fmtParam.Init(); //-- reset all data
1.1169 +
1.1170 + fmtParam.SetFileSystemName(KAutoMounterFSName); //-- it might have some strange consequences :)
1.1171 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1172 + test(nRes==KErrNotSupported);
1.1173 + format.Close();
1.1174 +
1.1175 + fmtParam.SetFileSystemName(_L("wrong FS"));
1.1176 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1177 + test(nRes==KErrNotSupported);
1.1178 + format.Close();
1.1179 +
1.1180 +
1.1181 + //================================================================================
1.1182 + //-- 5. corrupt the volume and try formatting without specyfying FS name
1.1183 + CorruptDrive();
1.1184 +
1.1185 + fmtParam.Init(); //-- reset all data
1.1186 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1187 + test(nRes==KErrNotFound); //-- the meaning: "can't find the appropriate file system to put onto the volume"
1.1188 + format.Close();
1.1189 +
1.1190 + //test.Printf(_L("#### T_a #1 res:%d\n"), nRes);
1.1191 +
1.1192 + fmtParam.SetFileSystemName(KAutoMounterFSName); //-- it might have some strange consequences :)
1.1193 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1194 + //test.Printf(_L("#### T_a #2 res:%d\n"), nRes);
1.1195 +
1.1196 + test(nRes == KErrNotSupported || nRes==KErrNotFound);
1.1197 +
1.1198 + format.Close();
1.1199 +
1.1200 + fmtParam.SetFileSystemName(_L("wrong FS"));
1.1201 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1202 + test(nRes==KErrNotSupported);
1.1203 + format.Close();
1.1204 +
1.1205 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
1.1206 + test(nRes==KErrNotFound); //-- the meaning: "can't find the appropriate file system to put onto the volume"
1.1207 + format.Close();
1.1208 +
1.1209 +
1.1210 + //--------------------------------------------------------------------------------
1.1211 + //-- 5.1 format the volume with specifying child FS2 explicitly
1.1212 + fmtParam.Init(); //-- reset all data
1.1213 + fmtParam.SetFileSystemName(KFSName2);
1.1214 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1215 + test(nRes==KErrNone);
1.1216 +
1.1217 + nRes =DoFormatSteps(format, fmtCnt);
1.1218 + test(nRes==KErrNone);
1.1219 +
1.1220 + format.Close();
1.1221 +
1.1222 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1223 + test(fsName.CompareF(KAutoMounterFSName) == 0);
1.1224 +
1.1225 + //-- the FS Subtype must be the subtype of the recognised child FS
1.1226 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.1227 + test_KErrNone(nRes);
1.1228 + CheckSubtype_FS2(fsSubType);
1.1229 +
1.1230 + CheckFsOperations();
1.1231 +
1.1232 + //--------------------------------------------------------------------------------
1.1233 + //-- 5.2 corrupt the volume and format with specifying child FS1 explicitly
1.1234 + CorruptDrive();
1.1235 +
1.1236 + fmtParam.Init(); //-- reset all data
1.1237 + fmtParam.SetFileSystemName(KFSName1);
1.1238 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1239 + test(nRes==KErrNone);
1.1240 +
1.1241 + nRes =DoFormatSteps(format, fmtCnt);
1.1242 + test(nRes==KErrNone);
1.1243 +
1.1244 + format.Close();
1.1245 +
1.1246 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1247 + test(fsName.CompareF(KAutoMounterFSName) == 0);
1.1248 +
1.1249 + //-- the FS Subtype must be the subtype of the recognised child FS
1.1250 + nRes = TheFs.FileSystemSubType(gDriveNum, fsSubType);
1.1251 + test_KErrNone(nRes);
1.1252 + CheckSubtype_FS1(fsSubType);
1.1253 +
1.1254 + CheckFsOperations();
1.1255 +}
1.1256 +
1.1257 +//-------------------------------------------------------------------
1.1258 +/**
1.1259 + Testing the use case when we have some rigidly bound FS to the drive (e.g "FAT")
1.1260 + and RFormat API that allows specifying the file system name that we want to put on the volume.
1.1261 +
1.1262 + It must be possible:
1.1263 + - format the volume without specifying FS name at all (the bound FS will be used)
1.1264 + - format the volume without specifying FS name at all when the volume is corrupted (the bound FS will be used)
1.1265 + - format the volume with specifying FS name that is the same as the bound FS has.
1.1266 +
1.1267 + If the specified file system name differs from the name that the bound FS has, the RFormat::Open() fails with KErrNotSupported.
1.1268 +
1.1269 +*/
1.1270 +void TestFixedFsFormatting_FsNameSpecified()
1.1271 +{
1.1272 + test.Next(_L("Testing RFormat API that allows specifying particular FS name for fixed FS.\n"));
1.1273 +
1.1274 + TInt nRes;
1.1275 + TBuf<40> fsName(0);
1.1276 +
1.1277 + TBuf<10> drivePath;
1.1278 + drivePath.Format(_L("%C:\\"), gDriveNum+'A');
1.1279 +
1.1280 + RFormat format;
1.1281 + TUint fmtMode = EQuickFormat | ESpecialFormat;
1.1282 + TInt fmtCnt;
1.1283 +
1.1284 + TVolFormatParamBuf fmtParamBuf;
1.1285 + TVolFormatParam& fmtParam = fmtParamBuf();
1.1286 +
1.1287 + _LIT(KTestFile, "\\this is a test file");
1.1288 +
1.1289 + //================================================================================
1.1290 + //-- 0. prepare the volume
1.1291 + test.Printf(_L("fmt: ESpecialFormat, no parameters specified\n"));
1.1292 + Mount_FileSystem1();
1.1293 +
1.1294 + //-- 0.1 format the volume with ESpecialFormat and without any parameters at all
1.1295 + test(fmtMode & ESpecialFormat);
1.1296 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt);
1.1297 + test(nRes==KErrNone);
1.1298 +
1.1299 + nRes = DoFormatSteps(format, fmtCnt);
1.1300 + test(nRes==KErrNone);
1.1301 +
1.1302 +
1.1303 + format.Close();
1.1304 +
1.1305 + //================================================================================
1.1306 + //-- 1. format the volume with default parameters without specifying file system name. The volume is already formatted with FS1
1.1307 + test.Printf(_L("fmt: ESpecialFormat, no FS name specified #1\n"));
1.1308 + fmtParam.Init(); //-- reset all data
1.1309 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1310 + test(nRes==KErrNone);
1.1311 +
1.1312 + nRes =DoFormatSteps(format, fmtCnt);
1.1313 + test(nRes==KErrNone);
1.1314 +
1.1315 + format.Close();
1.1316 +
1.1317 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1318 + test(fsName.CompareF(KFSName1) == 0);
1.1319 + CheckFsOperations();
1.1320 +
1.1321 + //-- 1.1 corrupt the media and check formatting without specifying FS name.
1.1322 + //-- The file system bount to this drive shall be used.
1.1323 + CorruptDrive();
1.1324 +
1.1325 + test.Printf(_L("fmt: ESpecialFormat, no FS name specified #2\n"));
1.1326 +
1.1327 + fmtParam.Init(); //-- reset all data
1.1328 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1329 + test(nRes==KErrNone);
1.1330 +
1.1331 + nRes =DoFormatSteps(format, fmtCnt);
1.1332 + test(nRes==KErrNone);
1.1333 +
1.1334 + format.Close();
1.1335 +
1.1336 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1337 + test(fsName.CompareF(KFSName1) == 0);
1.1338 + CheckFsOperations();
1.1339 +
1.1340 + //-- 1.2 the media is already formatted with FS1, try to specify other file system name for formatting.
1.1341 + //-- this shall fail with KErrNotSupported, the volume must not be affected
1.1342 + test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #1\n"));
1.1343 +
1.1344 + nRes = CreateCheckableStuffedFile(TheFs, KTestFile, 17384);
1.1345 + test(nRes==KErrNone);
1.1346 +
1.1347 + fmtParam.Init(); //-- reset all data
1.1348 + fmtParam.SetFileSystemName(_L("some filesystem name"));
1.1349 +
1.1350 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1351 + test(nRes==KErrNotSupported);
1.1352 + format.Close();
1.1353 +
1.1354 + test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #2\n"));
1.1355 + fmtParam.Init(); //-- reset all data
1.1356 + fmtParam.SetFileSystemName(KFSName2);
1.1357 +
1.1358 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1359 + test(nRes==KErrNotSupported);
1.1360 + format.Close();
1.1361 +
1.1362 +
1.1363 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1364 + test(fsName.CompareF(KFSName1) == 0);
1.1365 + CheckFsOperations();
1.1366 +
1.1367 + nRes = VerifyCheckableFile(TheFs, KTestFile);
1.1368 + test(nRes==KErrNone);
1.1369 +
1.1370 +
1.1371 + //-- 1.3 corrupt the media and check formatting with the FS Name that doesn't match the FS bound to this drive
1.1372 + //-- this shall fail
1.1373 + test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #3\n"));
1.1374 + CorruptDrive();
1.1375 +
1.1376 + fmtParam.Init(); //-- reset all data
1.1377 + fmtParam.SetFileSystemName(_L("some filesystem name"));
1.1378 +
1.1379 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1380 + test(nRes==KErrNotSupported);
1.1381 + format.Close();
1.1382 +
1.1383 + test.Printf(_L("fmt: ESpecialFormat, specifying wrong FS name #4\n"));
1.1384 + fmtParam.Init(); //-- reset all data
1.1385 + fmtParam.SetFileSystemName(KFSName2);
1.1386 +
1.1387 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1388 + test(nRes==KErrNotSupported);
1.1389 + format.Close();
1.1390 +
1.1391 + //-- 1.4 specify the correct file system name (bound to this drive) formatting must succeed
1.1392 + test.Printf(_L("fmt: ESpecialFormat, specifying correct FS name\n"));
1.1393 + fmtParam.Init(); //-- reset all data
1.1394 + fmtParam.SetFileSystemName(KFSName1);
1.1395 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1396 + test(nRes==KErrNone);
1.1397 +
1.1398 + nRes = DoFormatSteps(format, fmtCnt);
1.1399 + test(nRes==KErrNone);
1.1400 +
1.1401 + format.Close();
1.1402 +
1.1403 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1404 + test(fsName.CompareF(KFSName1) == 0);
1.1405 + CheckFsOperations();
1.1406 +
1.1407 +
1.1408 +}
1.1409 +
1.1410 +//-------------------------------------------------------------------
1.1411 +/**
1.1412 + Test formatting FAT file system with some specific parameters, like sector per cluster etc.
1.1413 + Note that some media types (like SD cards) do not support such type of formatting.
1.1414 +*/
1.1415 +void TestFormatting_FsName_Parameters_FAT()
1.1416 +{
1.1417 + using namespace FileSystem_FAT;
1.1418 +
1.1419 + test.Next(_L("Testing TVolFormatParam_FAT formatting API\n"));
1.1420 +
1.1421 + TInt nRes;
1.1422 + TBuf<40> fsName(0);
1.1423 +
1.1424 + TBuf<10> drivePath;
1.1425 + drivePath.Format(_L("%C:\\"), gDriveNum+'A');
1.1426 +
1.1427 + RFormat format;
1.1428 + TUint fmtMode = EQuickFormat | ESpecialFormat;
1.1429 + TInt fmtCnt;
1.1430 +
1.1431 + //================================================================================
1.1432 + //-- 0. prepare the volume
1.1433 + Mount_FileSystem1();
1.1434 + FormatVolume(); //-- old API, formatting with all parameters by default
1.1435 +
1.1436 + //================================================================================
1.1437 + //-- 1.0 simple unit test for TVolFormatParam_FAT
1.1438 + TVolFormatParam_FATBuf fmtParamBuf_FAT;
1.1439 + TVolFormatParam_FAT& fmtParam_FAT = fmtParamBuf_FAT();
1.1440 +
1.1441 + fmtParam_FAT.SetFatSubType(EFat32);
1.1442 + test(fmtParam_FAT.FatSubType() == EFat32);
1.1443 +
1.1444 + fmtParam_FAT.SetFatSubType(EFat12);
1.1445 + test(fmtParam_FAT.FatSubType() == EFat12);
1.1446 +
1.1447 + fmtParam_FAT.SetFatSubType(EFat16);
1.1448 + test(fmtParam_FAT.FatSubType() == EFat16);
1.1449 +
1.1450 + fmtParam_FAT.SetFatSubType(ENotSpecified);
1.1451 + test(fmtParam_FAT.FatSubType() == ENotSpecified);
1.1452 +
1.1453 + fmtParam_FAT.SetFatSubType(KFSSubType_FAT32);
1.1454 + test(fmtParam_FAT.FatSubType() == EFat32);
1.1455 +
1.1456 + fmtParam_FAT.SetFatSubType(KFSSubType_FAT12);
1.1457 + test(fmtParam_FAT.FatSubType() == EFat12);
1.1458 +
1.1459 + fmtParam_FAT.SetFatSubType(KFSSubType_FAT16);
1.1460 + test(fmtParam_FAT.FatSubType() == EFat16);
1.1461 +
1.1462 +
1.1463 + fmtParam_FAT.SetSectPerCluster(64);
1.1464 + test(fmtParam_FAT.SectPerCluster()==64);
1.1465 +
1.1466 + fmtParam_FAT.SetNumFATs(1);
1.1467 + test(fmtParam_FAT.NumFATs()==1);
1.1468 +
1.1469 + fmtParam_FAT.SetReservedSectors(13);
1.1470 + test(fmtParam_FAT.ReservedSectors()==13);
1.1471 +
1.1472 +
1.1473 + fmtParam_FAT.Init();
1.1474 + test(fmtParam_FAT.FatSubType() == ENotSpecified);
1.1475 + test(fmtParam_FAT.SectPerCluster() == 0);
1.1476 + test(fmtParam_FAT.NumFATs()==0);
1.1477 + test(fmtParam_FAT.ReservedSectors()==0);
1.1478 +
1.1479 +
1.1480 + //--- formatting FAT without specifying any parameters. This shall always succeed
1.1481 + test.Printf(_L("fmt: using TVolFormatParam_FAT, no parameters.\n"));
1.1482 +
1.1483 + fmtParam_FAT.Init();
1.1484 +
1.1485 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_FAT);
1.1486 + test(nRes==KErrNone);
1.1487 +
1.1488 + nRes = DoFormatSteps(format, fmtCnt);
1.1489 + test(nRes==KErrNone);
1.1490 +
1.1491 + format.Close();
1.1492 +
1.1493 + //-- formatting FAT with specifying some parameters. This may fail because the media doesn't support overriding FAT parameters
1.1494 + //-- or because this parameters combination isn't compatible with the volume geometry.
1.1495 +
1.1496 + test.Printf(_L("fmt: using TVolFormatParam_FAT, some FAT specific parameters.\n"));
1.1497 + fmtParam_FAT.SetFatSubType(EFat32);
1.1498 + fmtParam_FAT.SetSectPerCluster(1);
1.1499 + fmtParam_FAT.SetNumFATs(1);
1.1500 + fmtParam_FAT.SetReservedSectors(13);
1.1501 +
1.1502 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf_FAT);
1.1503 + test(nRes==KErrNone);
1.1504 +
1.1505 + nRes = DoFormatSteps(format, fmtCnt);
1.1506 + if(nRes != KErrNone)
1.1507 + {
1.1508 + test.Printf(_L("formatting failed. reason code:%d\n"), nRes);
1.1509 + }
1.1510 +
1.1511 + format.Close();
1.1512 +
1.1513 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1514 + test(fsName.CompareF(KFSName1) == 0);
1.1515 +
1.1516 + CheckFsOperations();
1.1517 +
1.1518 +}
1.1519 +
1.1520 +//-------------------------------------------------------------------
1.1521 +/**
1.1522 + Test formatting FAT file system with some specific parameters, like sector per cluster etc.
1.1523 + Note that some media types (like SD cards) do not support such type of formatting.
1.1524 +*/
1.1525 +
1.1526 +void TestFormatting_FsName_Parameters_exFAT()
1.1527 +{
1.1528 +
1.1529 +
1.1530 + test.Next(_L("Testing TVolFormatParam_exFAT formatting API\n"));
1.1531 +
1.1532 + TInt nRes;
1.1533 + TBuf<40> fsName(0);
1.1534 +
1.1535 + TBuf<10> drivePath;
1.1536 + drivePath.Format(_L("%C:\\"), gDriveNum+'A');
1.1537 +
1.1538 + RFormat format;
1.1539 + TUint fmtMode = EQuickFormat | ESpecialFormat;
1.1540 + TInt fmtCnt;
1.1541 +
1.1542 +
1.1543 + //================================================================================
1.1544 + //-- 0. prepare the volume
1.1545 + Mount_FileSystem2();
1.1546 + FormatVolume(); //-- old API, formatting with all parameters by default
1.1547 +
1.1548 + //================================================================================
1.1549 + //-- 1.0 simple unit test for TVolFormatParam_FAT
1.1550 +
1.1551 +#ifndef EXFAT_MIGHT_NOT_BE_PRESENT
1.1552 + TVolFormatParam_exFATBuf fmtParamBuf;
1.1553 + TVolFormatParam_exFAT& fmtParam = fmtParamBuf();
1.1554 +#else
1.1555 + //-- see the comments to "EXFAT_MIGHT_NOT_BE_PRESENT" macro definition
1.1556 + TVolFormatParam_FATBuf fmtParamBuf;
1.1557 + TVolFormatParam_FAT& fmtParam= fmtParamBuf();
1.1558 +#endif
1.1559 +
1.1560 +
1.1561 + fmtParam.SetSectPerCluster(64);
1.1562 + test(fmtParam.SectPerCluster()==64);
1.1563 +
1.1564 + fmtParam.SetSectPerCluster(14);
1.1565 + test(fmtParam.SectPerCluster()==14);
1.1566 +
1.1567 + fmtParam.SetNumFATs(1);
1.1568 + test(fmtParam.NumFATs()==1);
1.1569 +
1.1570 + fmtParam.SetNumFATs(2);
1.1571 + test(fmtParam.NumFATs()==2);
1.1572 +
1.1573 + fmtParam.Init();
1.1574 + test(fmtParam.SectPerCluster() == 0);
1.1575 + test(fmtParam.NumFATs()==0);
1.1576 +
1.1577 +
1.1578 + //--- formatting exFAT without specifying any parameters. This shall always succeed
1.1579 + test.Printf(_L("fmt: using TVolFormatParam_exFAT, no parameters.\n"));
1.1580 + fmtParam.Init();
1.1581 +
1.1582 +#ifdef EXFAT_MIGHT_NOT_BE_PRESENT
1.1583 + //-- need to forcedly set exFAT FS name, because fmtParam.Init(); set it to "FAT"
1.1584 + ((TVolFormatParam&)fmtParam).SetFileSystemName(KFSName2);
1.1585 +#endif
1.1586 +
1.1587 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1588 + test(nRes==KErrNone);
1.1589 +
1.1590 + nRes = DoFormatSteps(format, fmtCnt);
1.1591 + test(nRes==KErrNone);
1.1592 +
1.1593 + format.Close();
1.1594 +
1.1595 + //-- formatting exFAT with specifying some parameters. This may fail because the media doesn't support overriding FAT parameters
1.1596 + //-- or because this parameters combination isn't compatible with the volume geometry.
1.1597 +
1.1598 + test.Printf(_L("fmt: using TVolFormatParam_exFAT, some exFAT specific parameters.\n"));
1.1599 +
1.1600 + fmtParam.SetSectPerCluster(1);
1.1601 + fmtParam.SetNumFATs(2);
1.1602 +
1.1603 + nRes = format.Open(TheFs, drivePath, fmtMode, fmtCnt, fmtParamBuf);
1.1604 + test(nRes==KErrNone);
1.1605 +
1.1606 + nRes = DoFormatSteps(format, fmtCnt);
1.1607 + if(nRes != KErrNone)
1.1608 + {
1.1609 + test.Printf(_L("formatting failed. reason code:%d\n"), nRes);
1.1610 + }
1.1611 +
1.1612 + format.Close();
1.1613 +
1.1614 + nRes = TheFs.FileSystemName(fsName, gDriveNum);
1.1615 + test(fsName.CompareF(KFSName2) == 0);
1.1616 +
1.1617 + CheckFsOperations();
1.1618 +}
1.1619 +
1.1620 +//-------------------------------------------------------------------
1.1621 +
1.1622 +void CallTestsL()
1.1623 + {
1.1624 +
1.1625 +
1.1626 + //-- set up console output
1.1627 + Fat_Test_Utils::SetConsole(test.Console());
1.1628 +
1.1629 +#ifndef _DEBUG
1.1630 + //-- automounter has a special debug interface allowing to control child file ssytems mounting in _DEBUG mode only
1.1631 + test.Printf(_L("Skipping the test in the Release build! \n"));
1.1632 + return;
1.1633 +#else
1.1634 +
1.1635 + TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
1.1636 + test(nRes==KErrNone);
1.1637 +
1.1638 +
1.1639 + //-------------------------------------
1.1640 +
1.1641 + PrintDrvInfo(TheFs, gDriveNum);
1.1642 +
1.1643 + TVolumeInfo v;
1.1644 + nRes = TheFs.Volume(v);
1.1645 + test(nRes==KErrNone);
1.1646 + if(v.iDrive.iMediaAtt & KMediaAttVariableSize)
1.1647 + {
1.1648 + test.Printf(_L("Skipping. Internal ram drive not tested.\n"));
1.1649 + return;
1.1650 + }
1.1651 +
1.1652 + if(v.iDrive.iType != EMediaHardDisk || !(v.iDrive.iDriveAtt & KDriveAttRemovable))
1.1653 + {
1.1654 + test.Printf(_L("The drive shall be removable and the media type EMediaHardDisk. Skipping.\n"));
1.1655 + return;
1.1656 + }
1.1657 +
1.1658 +
1.1659 + //-------------------------------------
1.1660 +
1.1661 + if(InitGlobals())
1.1662 + {//-- do tests here
1.1663 +
1.1664 + TestAutomounterBasics();
1.1665 + TestDismounting();
1.1666 + TestFixedFsFormatting_FsNameSpecified();
1.1667 +
1.1668 + TestAutomounterDefaultFormatting();
1.1669 + TestAutomounterFormatting_FsNameSpecified();
1.1670 +
1.1671 + TestFormatting_FsName_Parameters_FAT();
1.1672 + TestFormatting_FsName_Parameters_exFAT();
1.1673 +
1.1674 + }
1.1675 + //-------------------------------------
1.1676 + DestroyGlobals();
1.1677 +#endif
1.1678 + }
1.1679 +
1.1680 +
1.1681 +
1.1682 +
1.1683 +
1.1684 +
1.1685 +
1.1686 +
1.1687 +
1.1688 +
1.1689 +
1.1690 +
1.1691 +
1.1692 +
1.1693 +
1.1694 +
1.1695 +
1.1696 +