os/kernelhwsrv/kerneltest/f32test/server/t_fsys.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/t_fsys.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,1071 @@
     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 +// f32test\server\t_fsys.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#define __E32TEST_EXTENSION__
    1.22 +
    1.23 +#include <f32file.h>
    1.24 +#include <f32file_private.h>
    1.25 +#include <e32test.h>
    1.26 +#include "t_server.h"
    1.27 +#include "fat_utils.h"
    1.28 +#include "filesystem_fat.h"
    1.29 +
    1.30 +using namespace Fat_Test_Utils;
    1.31 +
    1.32 +RTest test(_L("T_FSYS"));
    1.33 +
    1.34 +static void TestFileSystemNames()
    1.35 +    {
    1.36 +    test.Next(_L("Read file system names for all drives"));
    1.37 +    TFullName name;
    1.38 +    TInt r;
    1.39 +    for(TInt i=EDriveA;i<KMaxDrives;++i)
    1.40 +        {
    1.41 +        r=TheFs.FileSystemName(name,i);
    1.42 +        test(r==KErrNone || r==KErrNotFound);
    1.43 +        TChar c;
    1.44 +        r=RFs::DriveToChar(i,c);
    1.45 +        test(r==KErrNone);
    1.46 +        if(name.Length())       
    1.47 +            test.Printf(_L("File System Name on drive %c is %S\n"),(char)c,&name);
    1.48 +        else
    1.49 +            test.Printf(_L("No file system on drive %c\n"),(char)c);
    1.50 +        }
    1.51 +    }
    1.52 +
    1.53 +static void CheckDismount(TDesC& aFs,TInt aDrive)
    1.54 +    {
    1.55 +
    1.56 +    if (aDrive==EDriveC) // ??? Can't test on C: - see below
    1.57 +        return;
    1.58 +    TInt r;
    1.59 +    TFullName oldSess, newSess;
    1.60 +    r=TheFs.SessionPath(oldSess);
    1.61 +    test(r==KErrNone);
    1.62 +    TChar c;
    1.63 +    r=TheFs.DriveToChar(aDrive,c);
    1.64 +    test(r==KErrNone);
    1.65 +    newSess.Append(c);
    1.66 +    newSess.Append(':');
    1.67 +    newSess.Append('\\');
    1.68 +
    1.69 +    TBuf<128> b;
    1.70 +    TDriveInfo di;
    1.71 +    r=TheFs.Drive(di,aDrive);
    1.72 +    test(r==KErrNone);
    1.73 +    b.Format(_L("Test dismounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
    1.74 +    test.Next(b);
    1.75 +    
    1.76 +    // Test cannot dismount on rom drive
    1.77 +    test.Next(_L("Test cannot dismount on Rom drive"));
    1.78 +    TFullName zName;
    1.79 +    r=TheFs.FileSystemName(zName,EDriveZ);
    1.80 +    test(r==KErrNone);
    1.81 +    r=TheFs.DismountFileSystem(zName,EDriveZ);
    1.82 +    test.Printf(_L("r=%d"),r);
    1.83 +    // NB if paging is enabled on a ROFS partition which is part of the composite file system then the 
    1.84 +    // likelihood is that there will be a at least one file clamped: in this case there error will be KErrInUse
    1.85 +    test(r==KErrAccessDenied || r==KErrInUse);
    1.86 +
    1.87 +    // Test cannot dismount on wrong drive
    1.88 +    test.Next(_L("Test cannot dismount on wrong drive"));
    1.89 +    r=TheFs.DismountFileSystem(aFs,EDriveA);
    1.90 +    test(r==KErrNotReady);
    1.91 +
    1.92 +    // Test cannot dismount with wrong name
    1.93 +    test.Next(_L("Test cannot dismount with wrong file system name"));
    1.94 +    r=TheFs.DismountFileSystem(_L("abc"),aDrive);
    1.95 +    test(r==KErrNotFound);
    1.96 + 
    1.97 +    // Test cannot dismount with a file open
    1.98 +    test.Next(_L("Test cannot dismount with a file open"));
    1.99 +    r=TheFs.SetSessionPath(newSess);
   1.100 +    RFile file;
   1.101 +    r=file.Replace(TheFs,_L("abc"),EFileShareAny);
   1.102 +    test(r==KErrNone);
   1.103 +    r=TheFs.SessionPath(newSess);
   1.104 +    TBool open;
   1.105 +    r=TheFs.IsFileOpen(_L("abc"),open);
   1.106 +    test(r==KErrNone);
   1.107 +    test(open);
   1.108 +    r=TheFs.DismountFileSystem(aFs,aDrive);
   1.109 +    test(r==KErrInUse);
   1.110 +    file.Close();
   1.111 +
   1.112 +    // Now test dismount works
   1.113 +    test.Next(_L("Test dismounts OK"));
   1.114 +    r=TheFs.DismountFileSystem(aFs,aDrive);
   1.115 +    if(r!=KErrNone)
   1.116 +        {
   1.117 +        test.Printf(_L("Error = %d"),r);    
   1.118 +        test(EFalse);
   1.119 +        }
   1.120 +    TFullName n;
   1.121 +    r=TheFs.FileSystemName(n,aDrive);
   1.122 +    test(r==KErrNone || r==KErrNotFound);
   1.123 +    test(!n.Length());
   1.124 +    r=file.Replace(TheFs,_L("abc"),EFileShareAny);
   1.125 +    test(r==KErrNotReady);
   1.126 +    file.Close();
   1.127 +
   1.128 +    r=TheFs.MountFileSystem(aFs,aDrive);
   1.129 +    if(r!=KErrNone) 
   1.130 +        {
   1.131 +        test.Printf(_L("error = %d\n"),r);
   1.132 +        test(EFalse);
   1.133 +        }
   1.134 +    r=TheFs.FileSystemName(n,aDrive);
   1.135 +    test(r==KErrNone);
   1.136 +    test(n.Compare(aFs)==0);
   1.137 +    r=file.Replace(TheFs,_L("abc"),EFileShareAny); // ??? bang
   1.138 +    test(r==KErrNone);
   1.139 +    file.Close();
   1.140 +    r=TheFs.SetSessionPath(oldSess);
   1.141 +    test(r==KErrNone);
   1.142 +    }
   1.143 +
   1.144 +static void TestDismountFileSystem(TInt aDrive)
   1.145 +    {
   1.146 +
   1.147 +    TInt r;
   1.148 +    TFullName name;
   1.149 +    r=TheFs.FileSystemName(name,aDrive);
   1.150 +    test(r==KErrNone || r==KErrNotFound);
   1.151 +    if(name.Length())
   1.152 +        CheckDismount(name,aDrive);
   1.153 +    }
   1.154 +
   1.155 +#if defined(__EPOC32__)
   1.156 +static void TestFileSystem(TInt aDrive)
   1.157 +//
   1.158 +// Mount a new CTestFileSystem on the drive under test
   1.159 +//
   1.160 +    {
   1.161 +    TBuf<64> b;
   1.162 +    TChar c;
   1.163 +    TInt r=TheFs.DriveToChar(aDrive,c);
   1.164 +    test(r==KErrNone);
   1.165 +    TDriveInfo di;
   1.166 +    r=TheFs.Drive(di,aDrive);
   1.167 +    test(r==KErrNone);
   1.168 +    b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
   1.169 +    test.Next(b);
   1.170 +
   1.171 +    test.Next(_L("Test mounting of test file system"));
   1.172 +    r=TheFs.AddFileSystem(_L("T_TFSYS"));
   1.173 +    if(r!=KErrNone && r!=KErrAlreadyExists)
   1.174 +        {
   1.175 +        test.Printf(_L("error=%d"),r);
   1.176 +        test(EFalse);
   1.177 +        }
   1.178 +
   1.179 +    TFullName oldFs;
   1.180 +    r=TheFs.FileSystemName(oldFs,aDrive);
   1.181 +//  TFileName oldFs;
   1.182 +//  r=TheFs.FileSystemName(oldFs,aDrive);
   1.183 +    test(r==KErrNone);
   1.184 +    r=TheFs.DismountFileSystem(oldFs,aDrive);
   1.185 +    if(r!=KErrNone)
   1.186 +        {
   1.187 +        test.Printf(_L("Error = %d"),r);    
   1.188 +        test(EFalse);
   1.189 +        }
   1.190 +    r=TheFs.MountFileSystem(_L("Test"),aDrive);
   1.191 +    test(r==KErrNone);
   1.192 +
   1.193 +    TFileName newFs;
   1.194 +    r=TheFs.FileSystemName(newFs,aDrive);
   1.195 +    test(r==KErrNone);
   1.196 +    test(newFs.Compare(_L("Test"))==0);
   1.197 +
   1.198 +    // Check attributes
   1.199 +    TDriveInfo info;
   1.200 +    r=TheFs.Drive(info,aDrive);
   1.201 +    test(r==KErrNone);
   1.202 + 
   1.203 +    test.Printf(_L("iType=%d,iConnectionBusType=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
   1.204 +        (TUint)info.iConnectionBusType,info.iDriveAtt,info.iMediaAtt);
   1.205 +
   1.206 +    //Try to remove filesystem without dismounting.
   1.207 +    r=TheFs.RemoveFileSystem(_L("Test"));
   1.208 +    if(r!=KErrInUse)
   1.209 +        {
   1.210 +        test.Printf(_L("error=%d"),r);
   1.211 +        test(EFalse);
   1.212 +        }
   1.213 +    r=TheFs.FileSystemName(newFs,aDrive);
   1.214 +    test(r==KErrNone);
   1.215 +    test(newFs.Compare(_L("Test"))==0);
   1.216 +
   1.217 +    r=TheFs.DismountFileSystem(newFs,aDrive);
   1.218 +    test(r==KErrNone);
   1.219 +
   1.220 +    r=TheFs.MountFileSystem(oldFs,aDrive);
   1.221 +    test(r==KErrNone);
   1.222 +    }
   1.223 +#endif
   1.224 +
   1.225 +static void TestMountInvalidDrive()
   1.226 +//
   1.227 +// Attempt to mount FAT on non-local drive
   1.228 +    {
   1.229 +    test.Start(_L("TestMountInvalidDrive"));
   1.230 +
   1.231 +    TInt r;
   1.232 +
   1.233 +    test.Next(_L("Adding EFAT"));
   1.234 +#ifdef __WINS__
   1.235 +    _LIT(KFsNm, "EFAT32");
   1.236 +#else
   1.237 +    _LIT(KFsNm, "ELOCAL");
   1.238 +#endif
   1.239 +
   1.240 +    r = TheFs.AddFileSystem(KFsNm);
   1.241 +    test.Printf(_L("afs: r = %d\n"), r);
   1.242 +    test(r == KErrNone || r == KErrAlreadyExists);
   1.243 +    test.Next(_L("mounting FAT on drive R"));
   1.244 +    r = TheFs.MountFileSystem(KFileSystemName_FAT, EDriveR);
   1.245 +    test(r == KErrArgument);
   1.246 +    
   1.247 +    test.End();
   1.248 +    }
   1.249 +
   1.250 +// Additional step for INC083446: Corrupted miniSD not detected as corrupted by phone 
   1.251 +static void TestMountingBrokenMedia(TInt aDrive)
   1.252 +//
   1.253 +// Mount a new CTestFileSystem on the drive under test
   1.254 +//
   1.255 +    {
   1.256 +    if (aDrive==EDriveC) // ??? Can't test on C:
   1.257 +        return;
   1.258 +
   1.259 +    TBuf<64> b;
   1.260 +    TChar c;
   1.261 +    TInt r=TheFs.DriveToChar(aDrive,c);
   1.262 +    test(r==KErrNone);
   1.263 +    TDriveInfo di;
   1.264 +    r=TheFs.Drive(di,aDrive);
   1.265 +    test(r==KErrNone);
   1.266 +    b.Format(_L("Test mounting of test file system on %c: (DrvAtt:%x MedAtt:%x)"),(TUint)c,di.iDriveAtt,di.iMediaAtt);
   1.267 +    test.Next(b);
   1.268 +
   1.269 +    test.Next(_L("Test mounting of test file system"));
   1.270 +    r=TheFs.AddFileSystem(_L("T_TFSYS2"));
   1.271 +    if(r!=KErrNone && r!=KErrAlreadyExists)
   1.272 +        {
   1.273 +        test.Printf(_L("error=%d"),r);
   1.274 +        test(EFalse);
   1.275 +        }
   1.276 +
   1.277 +    TFullName oldFs;
   1.278 +    r=TheFs.FileSystemName(oldFs,aDrive);
   1.279 +    test(r==KErrNone);
   1.280 +    r=TheFs.DismountFileSystem(oldFs,aDrive);
   1.281 +    if(r!=KErrNone)
   1.282 +        {
   1.283 +        test.Printf(_L("Error = %d"),r);    
   1.284 +        test(EFalse);
   1.285 +        }
   1.286 +    r=TheFs.MountFileSystem(_L("Test2"),aDrive);
   1.287 +    test(r == KErrCorrupt);
   1.288 +
   1.289 +    TFileName newFs;
   1.290 +    r=TheFs.FileSystemName(newFs,aDrive);
   1.291 +    test(r==KErrNone);
   1.292 +    test(newFs.Compare(_L("Test2"))==0);
   1.293 +
   1.294 +    // Get the number of remounts by checking the volume attributes -
   1.295 +    // T_TFSYS2 hijacks the iBattery member to report back the number of times MountL() has been called
   1.296 +    TDriveInfo info;
   1.297 +    TInt remounts;
   1.298 +    r=TheFs.Drive(info,aDrive);
   1.299 +    test(r==KErrNone);
   1.300 +    test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
   1.301 +        (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
   1.302 +    remounts = (TInt) info.iBattery;
   1.303 +    test.Printf(_L("Initial remounts = %d"), remounts);
   1.304 +
   1.305 +    // Make the file server attempt to remount the drive by looking for a non-existant DLL
   1.306 +    // The file server should setop trying to remount the driver after KMaxMountFailures attempts
   1.307 +    const TInt KMaxMountFailures = 3;   // copied from sf_drv.cpp
   1.308 +    const TInt KEntryAttempts = 10;
   1.309 +    TInt entryAttempts;
   1.310 +    for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++)
   1.311 +        {
   1.312 +        TEntry entry;
   1.313 +        _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL");
   1.314 +        r = TheFs.Entry(KNonExistantFilename, entry);
   1.315 +        test(r == KErrCorrupt);
   1.316 +        }
   1.317 +    r=TheFs.Drive(info,aDrive);
   1.318 +    test(r==KErrNone);
   1.319 +    test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
   1.320 +        (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
   1.321 +    remounts = (TInt) info.iBattery;
   1.322 +    test.Printf(_L("Remounts = %d"), remounts);
   1.323 +    test(remounts ==  KMaxMountFailures);
   1.324 +    
   1.325 +    // simulate a media change to reset failure count
   1.326 +    r = TheFs.RemountDrive(aDrive, NULL, 0);
   1.327 +
   1.328 +    // now try mounting again & verify the the file server attempts to mount the drive again
   1.329 +    for (entryAttempts=0; entryAttempts < KEntryAttempts; entryAttempts++)
   1.330 +        {
   1.331 +        TEntry entry;
   1.332 +        _LIT(KNonExistantFilename, "NONEXISTANT_FILENAME.DLL");
   1.333 +        r = TheFs.Entry(KNonExistantFilename, entry);
   1.334 +        test(r == KErrCorrupt);
   1.335 +        }
   1.336 +    r=TheFs.Drive(info,aDrive);
   1.337 +    test(r==KErrNone);
   1.338 +    test.Printf(_L("iType=%d,iBattery=%d,iDriveAtt=%x,iMediaAtt=%x\n"),(TUint)info.iType,\
   1.339 +        (TUint)info.iBattery,info.iDriveAtt,info.iMediaAtt);
   1.340 +    remounts = (TInt) info.iBattery;
   1.341 +    test.Printf(_L("Remounts = %d"), remounts);
   1.342 +    test(remounts ==  KMaxMountFailures * 2);
   1.343 +    
   1.344 +
   1.345 +
   1.346 +    r=TheFs.DismountFileSystem(newFs,aDrive);
   1.347 +    test(r==KErrNone);
   1.348 +    r=TheFs.MountFileSystem(oldFs,aDrive);
   1.349 +    test(r==KErrNone);
   1.350 +    
   1.351 +    r=TheFs.RemoveFileSystem(_L("Test2"));
   1.352 +    if(r!=KErrNone)
   1.353 +        {
   1.354 +        test.Printf(_L("error=%d"),r);
   1.355 +        test(EFalse);
   1.356 +        }
   1.357 +    }
   1.358 +
   1.359 +
   1.360 +/**
   1.361 +    Testing obtaining media serial number for the substituted drives
   1.362 +*/
   1.363 +static void TestSubstDriveMediaSerialNumber()
   1.364 +{
   1.365 +    test.Next(_L("Test obtaining media serial number for the substituted drives"));
   1.366 +
   1.367 +    TInt  nRes;
   1.368 +    const TInt currDrvNum=CurrentDrive();
   1.369 +    
   1.370 +    TDriveInfo drvInfo;
   1.371 +    nRes=TheFs.Drive(drvInfo, currDrvNum);
   1.372 +    test(nRes==KErrNone);
   1.373 +
   1.374 +    if(drvInfo.iDriveAtt & (KDriveAttRom | KDriveAttRedirected | KDriveAttSubsted))
   1.375 +    {
   1.376 +        test.Printf(_L("Can't test on this drive!\n"));
   1.377 +        return;
   1.378 +    }
   1.379 +
   1.380 +    TMediaSerialNumber serNum;
   1.381 +
   1.382 +    //-- test Media Serial Number on unexisting drive
   1.383 +    {
   1.384 +    for(TInt drvNum=EDriveA; drvNum<=EDriveZ; ++drvNum)
   1.385 +        {
   1.386 +        TDriveInfo drvInfo;
   1.387 +        if(KErrNone==TheFs.Drive(drvInfo, drvNum) && drvInfo.iType==EMediaNotPresent)
   1.388 +            {
   1.389 +            // found a non-extant drive, test it...
   1.390 +            nRes = TheFs.GetMediaSerialNumber(serNum, drvNum);
   1.391 +            test(nRes == KErrNotReady);
   1.392 +            break;
   1.393 +            }
   1.394 +        }
   1.395 +    }
   1.396 +    
   1.397 +    nRes = TheFs.GetMediaSerialNumber(serNum, currDrvNum);
   1.398 +    if(nRes != KErrNone)
   1.399 +    {
   1.400 +        test.Printf(_L("Test is inconsintent on this drive!\n"));
   1.401 +        return;
   1.402 +    }
   1.403 +
   1.404 +    TFileName substPath;                //-- path to the directory to substitute
   1.405 +    const TInt KSubstDrv = EDriveO;     //-- drive to be substituted
   1.406 +
   1.407 +    //-- make directory, which will be substituted ad a drive
   1.408 +    substPath.Format(_L("%c:\\SubstDrv1\\"), (TUint8)'A'+currDrvNum);
   1.409 +    MakeDir(substPath);
   1.410 +  
   1.411 +    nRes = TheFs.SetSubst(substPath, KSubstDrv);
   1.412 +    test(nRes == KErrNone);
   1.413 +
   1.414 +    //-- an attempt to obtain Media Serial Number on a substed drive shall result in KErrNotSupported
   1.415 +    nRes = TheFs.GetMediaSerialNumber(serNum, KSubstDrv);
   1.416 +    test(nRes == KErrNotSupported);
   1.417 +
   1.418 +    //-- delete substed drive
   1.419 +    nRes = TheFs.SetSubst(_L(""), KSubstDrv);
   1.420 +    test(nRes == KErrNone);
   1.421 +}
   1.422 +
   1.423 +
   1.424 +//----------------------------------------------------------------------------------------------
   1.425 +//! @SYMTestCaseID      PBASE-t_fsys-0317
   1.426 +//! @SYMTestType        CIT
   1.427 +//! @SYMPREQ            CR0882
   1.428 +//! @SYMTestCaseDesc    This test case is testing querying file system sub type name using 
   1.429 +//!                     RFs::QueryVolumeInfoExt() API.
   1.430 +//! @SYMTestActions     1   querys sub type of file system on volumes mounted with 'Fat' file system
   1.431 +//!                     2   querys sub type of file system on volumes mounted with 'Lffs' file system
   1.432 +//!                     3   querys sub type of file system on volumes mounted with 'rofs' file system
   1.433 +//!                     4   querys sub type of file system on volumes mounted with other file systems
   1.434 +//! @SYMTestExpectedResults 
   1.435 +//!                     1   returned error code should be KErrNone, descriptor should match 'FAT12' or 'FAT16' or 'FAT32'
   1.436 +//!                     2   returned error code should be KErrNotSupported, descriptor should match 'Lffs'
   1.437 +//!                     3   returned error code should be KErrNotSupported, descriptor should match 'rofs'
   1.438 +//!                     4   returned error code should be KErrNotSupported, descriptor length should not be zero
   1.439 +//! @SYMTestPriority        High
   1.440 +//! @SYMTestStatus          Implemented
   1.441 +//----------------------------------------------------------------------------------------------
   1.442 +static void TestFileSystemSubTypeQuery()
   1.443 +    {
   1.444 +    test.Next(_L("Test querying sub type of the mounted file system"));
   1.445 +    TFSName fsName;
   1.446 +    TPckgBuf<TFSName> subName;
   1.447 +    TInt i, r;
   1.448 +    TDriveInfo driveInfo;
   1.449 +    TPckgBuf<TBool> fDrvSyncBuf;
   1.450 +
   1.451 +
   1.452 +    for(i = EDriveA; i <= EDriveZ; ++i, subName.Zero())
   1.453 +        {
   1.454 +        r = TheFs.FileSystemName(fsName, i);
   1.455 +        if (r == KErrNone)
   1.456 +            {
   1.457 +            test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
   1.458 +            r=TheFs.Drive(driveInfo, i);
   1.459 +            test(r==KErrNone);
   1.460 +            
   1.461 +            if (driveInfo.iType==EMediaNotPresent)
   1.462 +                {
   1.463 +                test.Printf(_L("The media is not present.\n"));
   1.464 +                r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
   1.465 +                test(r == KErrNone || r == KErrNotReady);
   1.466 +                }
   1.467 +            else if (driveInfo.iType==EMediaCdRom)
   1.468 +                {
   1.469 +                test.Printf(_L("CD ROM with no media will report not ready!\n"));
   1.470 +                r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
   1.471 +                test(r == KErrNotReady);
   1.472 +                }
   1.473 +            else
   1.474 +                {
   1.475 +                r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
   1.476 +                test_KErrNone(r);
   1.477 +
   1.478 +                //-- test EIsDriveSync command
   1.479 +                r = TheFs.QueryVolumeInfoExt(i, EIsDriveSync, fDrvSyncBuf);
   1.480 +                test(r == KErrNone);
   1.481 +                if(fDrvSyncBuf())
   1.482 +                    test.Printf(_L("The drive is Synchronous.\n"));
   1.483 +                else
   1.484 +                    test.Printf(_L("The drive is Asynchronous.\n"));
   1.485 +
   1.486 +                //-----------------
   1.487 +                
   1.488 +                // if Fat, testing returning sub type name
   1.489 +                if (fsName.CompareF(KFileSystemName_FAT)==0)
   1.490 +                    {
   1.491 +                    test(r == KErrNone);
   1.492 +                    test(subName().CompareF(KFSSubType_FAT12)==0 ||
   1.493 +                         subName().CompareF(KFSSubType_FAT16)==0 ||
   1.494 +                         subName().CompareF(KFSSubType_FAT32)==0);
   1.495 +                    continue;
   1.496 +                    }
   1.497 +                
   1.498 +                // if Lffs, testing returning file system name
   1.499 +                if (fsName.CompareF(_L("Lffs"))==0)
   1.500 +                    {
   1.501 +                    test(r == KErrNone);
   1.502 +                    test(subName().CompareF(_L("Lffs"))==0);
   1.503 +                    continue;
   1.504 +                    }
   1.505 +                // if rofs, testing returning file system name
   1.506 +                if (fsName.CompareF(_L("rofs"))==0)
   1.507 +                    {
   1.508 +                    test(r == KErrNone);
   1.509 +                    test(subName().CompareF(_L("rofs"))==0);
   1.510 +                    continue;
   1.511 +                    }
   1.512 +                // if Composite, testing returning file system name
   1.513 +                if (fsName.CompareF(_L("Composite"))==0)
   1.514 +                    {
   1.515 +                    test(r == KErrNone);
   1.516 +                    test(subName().CompareF(_L("Composite"))==0);
   1.517 +                    continue;
   1.518 +                    }
   1.519 +
   1.520 +                // else
   1.521 +                test(r == KErrNone);
   1.522 +                test(subName().Length()!=0);
   1.523 +                
   1.524 +                }
   1.525 +            }
   1.526 +        }
   1.527 +    }
   1.528 +
   1.529 +//----------------------------------------------------------------------------------------------
   1.530 +//! @SYMTestCaseID      PBASE-t_fsys-0318
   1.531 +//! @SYMTestType        CIT
   1.532 +//! @SYMPREQ            CR0882
   1.533 +//! @SYMTestCaseDesc    This test case is testing querying file system's cluster size using 
   1.534 +//!                     RFs::QueryVolumeInfoExt() API.
   1.535 +//! @SYMTestActions     1   querys cluster size of file system on volumes mounted with 'Fat' file system
   1.536 +//!                     2   querys cluster size of file system on volumes mounted with 'Lffs' file system
   1.537 +//!                     3   querys cluster size of file system on volumes mounted with other file systems
   1.538 +//! @SYMTestExpectedResults 
   1.539 +//!                     1   returned error code should be KErrNone, cluster size should be non-zero
   1.540 +//!                     2   returned error code should be KErrNone, cluster size should be 512
   1.541 +//!                     3   returned error code should be KErrNone, cluster size should be KErrNotSupported
   1.542 +//! @SYMTestPriority        High
   1.543 +//! @SYMTestStatus          Implemented
   1.544 +//----------------------------------------------------------------------------------------------
   1.545 +static void TestFileSystemClusterSizeQuery()
   1.546 +    {
   1.547 +    test.Next(_L("Test querying cluster size information of the mounted file system"));
   1.548 +    TFullName fsName;
   1.549 +    TPckgBuf<TVolumeIOParamInfo> ioInfo;
   1.550 +    TInt i, r;
   1.551 +    TDriveInfo driveInfo;
   1.552 +    for(i = EDriveA; i <= EDriveZ; ++i)
   1.553 +        {
   1.554 +        r = TheFs.FileSystemName(fsName, i);
   1.555 +        if (r == KErrNone)
   1.556 +            {
   1.557 +            test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
   1.558 +
   1.559 +            r=TheFs.Drive(driveInfo, i);
   1.560 +            test(r==KErrNone);
   1.561 +            // if no media present
   1.562 +            if (driveInfo.iType==EMediaNotPresent)
   1.563 +                {
   1.564 +                r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
   1.565 +                test(r == KErrNone || r == KErrNotReady);
   1.566 +                }
   1.567 +            else if (driveInfo.iType==EMediaCdRom)
   1.568 +                {
   1.569 +                test.Printf(_L("CD ROM with no media!\n"));
   1.570 +                r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
   1.571 +                test(r == KErrNone || r == KErrNotReady);
   1.572 +                }
   1.573 +            else
   1.574 +                {
   1.575 +                r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
   1.576 +                test(KErrNone == r);
   1.577 +                // if Fat
   1.578 +                if (fsName.CompareF(KFileSystemName_FAT)==0)
   1.579 +                    {
   1.580 +                    test(ioInfo().iClusterSize != 0);
   1.581 +                    continue;
   1.582 +                    }
   1.583 +                // else if Lffs
   1.584 +                if (fsName.CompareF(_L("Lffs"))==0)
   1.585 +                    {
   1.586 +                        TBusLocalDrive drive;   
   1.587 +                        TBool changeFlag = EFalse;  
   1.588 +                        TInt locDriveNumber;
   1.589 +                        TLocalDriveCaps DriveCaps;
   1.590 +                        TLocalDriveCapsV7 DriveCapsV7;
   1.591 +                        for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++)
   1.592 +                        {
   1.593 +                            r = drive.Connect(locDriveNumber,changeFlag);
   1.594 +                            if(r==KErrNone)
   1.595 +                            {
   1.596 +                                
   1.597 +                                TPckg<TLocalDriveCaps> capsPckg(DriveCaps);
   1.598 +                                r=drive.Caps(capsPckg);
   1.599 +                                if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS))
   1.600 +                                {
   1.601 +                                    break;
   1.602 +                                }
   1.603 +                                drive.Disconnect();
   1.604 +                            }
   1.605 +                        }
   1.606 +                        TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7);
   1.607 +                        r=drive.Caps(capsPckg);
   1.608 +                        test(r==KErrNone);
   1.609 +                        drive.Disconnect();
   1.610 +                        if(DriveCapsV7.iObjectModeSize == 0)
   1.611 +                        {
   1.612 +                    test(ioInfo().iClusterSize == 512);
   1.613 +                    continue;
   1.614 +                        }
   1.615 +                        else
   1.616 +                        {
   1.617 +                            test((TUint32)(ioInfo().iClusterSize) == DriveCapsV7.iObjectModeSize);
   1.618 +                            continue;
   1.619 +                        }
   1.620 +                    }
   1.621 +                // else
   1.622 +                //-- we can not suggest anything about unknown filesystem, thus do not check the result.
   1.623 +                //test(ioInfo().iClusterSize == KErrNotSupported);
   1.624 +                
   1.625 +                }
   1.626 +            }
   1.627 +        }
   1.628 +    }
   1.629 +
   1.630 +//----------------------------------------------------------------------------------------------
   1.631 +//! @SYMTestCaseID      PBASE-t_fsys-0319
   1.632 +//! @SYMTestType        CIT
   1.633 +//! @SYMPREQ            CR0882
   1.634 +//! @SYMTestCaseDesc    This test case is testing querying block size of underlying media using 
   1.635 +//!                     RFs::QueryVolumeInfoExt() API.
   1.636 +//! @SYMTestActions     1   querys block size on volumes mounted with MMC card type of media
   1.637 +//!                     2   querys block size on volumes mounted with RAM type of media
   1.638 +//!                     3   querys block size on volumes mounted with NOR flash type of media
   1.639 +//!                     4   querys block size on volumes mounted with Nand flash (code) type of media
   1.640 +//!                     5   querys block size on volumes mounted with Nand flash (data) type of media
   1.641 +//! @SYMTestExpectedResults 
   1.642 +//!                     1   returned error code should be KErrNone, block size should be 512
   1.643 +//!                     2   returned error code should be KErrNone, block size should be KDefaultVolumeBlockSize
   1.644 +//!                     3   returned error code should be KErrNone, block size should be KDefaultVolumeBlockSize
   1.645 +//!                     4   returned error code should be KErrNone, block size should be 512
   1.646 +//!                     5   returned error code should be KErrNone, block size should be 512
   1.647 +//! @SYMTestPriority        High
   1.648 +//! @SYMTestStatus          Implemented
   1.649 +//----------------------------------------------------------------------------------------------
   1.650 +static void TestMediaBlockSizeQuery()
   1.651 +    {
   1.652 +    test.Next(_L("Test querying block size information of the underlying media"));
   1.653 +    #if defined(__WINS__)
   1.654 +        test.Printf(_L("This test case runs on hardware only"));
   1.655 +        return;
   1.656 +    
   1.657 +    #else   // test runs on hardware only.
   1.658 +    TFSName fsName;
   1.659 +    TPckgBuf<TVolumeIOParamInfo> ioInfo;
   1.660 +    TInt i, r;
   1.661 +    TDriveInfo driveInfo;
   1.662 +    for(i = EDriveA; i <= EDriveZ; ++i)
   1.663 +        {
   1.664 +        r = TheFs.FileSystemName(fsName, i);
   1.665 +        if (r == KErrNone)
   1.666 +            {
   1.667 +            test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
   1.668 +            r=TheFs.Drive(driveInfo, i);
   1.669 +            test(r==KErrNone);
   1.670 +            // if no media present
   1.671 +            if (driveInfo.iType==EMediaNotPresent)
   1.672 +                {
   1.673 +                r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
   1.674 +                test(r == KErrNone || r == KErrNotReady);
   1.675 +                }
   1.676 +            else if (driveInfo.iType==EMediaCdRom)
   1.677 +                {
   1.678 +                test.Printf(_L("CD ROM with no media will report not ready!\n"));
   1.679 +                r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
   1.680 +                test(r == KErrNotReady);
   1.681 +                }
   1.682 +            else
   1.683 +                {
   1.684 +                r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
   1.685 +                test(KErrNone == r);
   1.686 +                // if MMC, test block size >= 512;
   1.687 +                // (Version 4.3 MMC cards introduce the concept of a "Super Page" which should be used as
   1.688 +                // guide when calculating the cluster size. For these cards the reported block size may be 
   1.689 +                // any multiple of 512).
   1.690 +                if ((driveInfo.iType == EMediaHardDisk) && 
   1.691 +                    (driveInfo.iDriveAtt & KDriveAttRemovable) &&
   1.692 +                    (driveInfo.iDriveAtt & KDriveAttLocal))
   1.693 +                    {
   1.694 +                    test(ioInfo().iBlockSize >= 512);
   1.695 +                    continue;
   1.696 +                    }
   1.697 +                // if RAM, test block size == 1;
   1.698 +                if ((driveInfo.iType == EMediaRam) && 
   1.699 +                    (driveInfo.iDriveAtt & KDriveAttLocal) &&
   1.700 +                    (driveInfo.iDriveAtt & KDriveAttInternal))
   1.701 +                    {
   1.702 +                    test(ioInfo().iBlockSize == 1);
   1.703 +                    continue;
   1.704 +                    }
   1.705 +                // if NOR flash, test block size == 512 (default block size);
   1.706 +                if ((driveInfo.iType == EMediaFlash) && 
   1.707 +                    (driveInfo.iDriveAtt & KDriveAttLocal) &&
   1.708 +                    (driveInfo.iDriveAtt & KDriveAttInternal))
   1.709 +                    {
   1.710 +                    TBusLocalDrive drive;   
   1.711 +                    TBool changeFlag = EFalse;  
   1.712 +                    TInt locDriveNumber;
   1.713 +                    TLocalDriveCaps DriveCaps;
   1.714 +                    TLocalDriveCapsV7 DriveCapsV7;
   1.715 +                    for(locDriveNumber = 0; locDriveNumber < KMaxLocalDrives; locDriveNumber++)
   1.716 +                        {
   1.717 +                        r = drive.Connect(locDriveNumber,changeFlag);
   1.718 +                        if(r==KErrNone)
   1.719 +                            {
   1.720 +                            TPckg<TLocalDriveCaps> capsPckg(DriveCaps);
   1.721 +                            r=drive.Caps(capsPckg);
   1.722 +                            if((r==KErrNone) && (DriveCaps.iFileSystemId==KDriveFileSysLFFS))
   1.723 +                                {
   1.724 +                                break;
   1.725 +                                }
   1.726 +                            drive.Disconnect();
   1.727 +                            }
   1.728 +                        }
   1.729 +                    TPckg<TLocalDriveCapsV7> capsPckg(DriveCapsV7);
   1.730 +                    r=drive.Caps(capsPckg);
   1.731 +                    test(r==KErrNone);
   1.732 +                    if ((fsName.CompareF(_L("Lffs"))==0) && (DriveCapsV7.iObjectModeSize != 0))
   1.733 +                        {                   
   1.734 +                        test(ioInfo().iBlockSize == (TInt) DriveCapsV7.iObjectModeSize);
   1.735 +                        continue;
   1.736 +                        }
   1.737 +                    else
   1.738 +                        {
   1.739 +                        test(ioInfo().iBlockSize == (TInt) KDefaultVolumeBlockSize);
   1.740 +                        continue;
   1.741 +                        }
   1.742 +                    }
   1.743 +                // if Nand flash (with Fat file system), test block size == 512 (small-block) or 2048 (large-block)
   1.744 +                if ((driveInfo.iType == EMediaNANDFlash) &&
   1.745 +                    (driveInfo.iDriveAtt & KDriveAttLocal) &&
   1.746 +                    (driveInfo.iDriveAtt & KDriveAttInternal))
   1.747 +                    {
   1.748 +                    test(ioInfo().iBlockSize == 512 || ioInfo().iBlockSize == 2048);
   1.749 +                    continue;
   1.750 +                    }
   1.751 +                }
   1.752 +            }
   1.753 +        }
   1.754 +    #endif // __WINS__
   1.755 +    }
   1.756 +
   1.757 +//----------------------------------------------------------------------------------------------
   1.758 +//! @SYMTestCaseID      PBASE-t_fsys-0320
   1.759 +//! @SYMTestType        CIT
   1.760 +//! @SYMPREQ            CR0882
   1.761 +//! @SYMTestCaseDesc    This test case is testing wrapper API RFs::FileSystemSubType() has the same
   1.762 +//!                     behaviours as RFs::QueryVolumeInfoExt()
   1.763 +//! @SYMTestActions     1   querys file system sub type name by both APIs
   1.764 +//! @SYMTestExpectedResults 
   1.765 +//!                     1   returned error codes and descriptors of both API should be identical
   1.766 +//! @SYMTestPriority        High
   1.767 +//! @SYMTestStatus          Implemented
   1.768 +//----------------------------------------------------------------------------------------------
   1.769 +static void TestFileSystemSubType()
   1.770 +    {
   1.771 +    test.Next(_L("Test wrapper API RFs::FileSystemSubType()'s behaviour"));
   1.772 +    TFSName fsName;
   1.773 +    TPckgBuf<TFSName> subName;
   1.774 +    TInt r;
   1.775 +    TFSName subName1;
   1.776 +    TInt r1;
   1.777 +    
   1.778 +    for(TInt i = EDriveA; i <= EDriveZ; ++i)
   1.779 +        {
   1.780 +        r = TheFs.FileSystemName(fsName, i);
   1.781 +        if (r == KErrNone)
   1.782 +            {
   1.783 +            test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
   1.784 +            r = TheFs.QueryVolumeInfoExt(i, EFileSystemSubType, subName);
   1.785 +            r1 = TheFs.FileSystemSubType(i, subName1);
   1.786 +            test(r==r1);
   1.787 +            if (subName().Length())
   1.788 +                {
   1.789 +                test(subName().CompareF(subName1)==0);
   1.790 +                }
   1.791 +            else
   1.792 +                {
   1.793 +                test(subName1.Length()==0);
   1.794 +                }
   1.795 +            }
   1.796 +        }
   1.797 +    }
   1.798 +
   1.799 +//----------------------------------------------------------------------------------------------
   1.800 +//! @SYMTestCaseID      PBASE-t_fsys-0321
   1.801 +//! @SYMTestType        CIT
   1.802 +//! @SYMPREQ            CR0882
   1.803 +//! @SYMTestCaseDesc    This test case is testing wrapper API RFs::VolumeIOParam() has the same
   1.804 +//!                     behaviours as RFs::QueryVolumeInfoExt()
   1.805 +//! @SYMTestActions     1   querys volume IO params by both APIs
   1.806 +//! @SYMTestExpectedResults 
   1.807 +//!                     1   returned error codes and IO param values of both API should be identical
   1.808 +//! @SYMTestPriority        High
   1.809 +//! @SYMTestStatus          Implemented
   1.810 +//----------------------------------------------------------------------------------------------
   1.811 +static void TestVolumeIOParam()
   1.812 +    {
   1.813 +    test.Next(_L("Test wrapper API RFs::VolumeIOParam()'s behaviour"));
   1.814 +    TFSName fsName;
   1.815 +    TPckgBuf<TVolumeIOParamInfo> ioInfo;
   1.816 +    TInt r;
   1.817 +    TVolumeIOParamInfo ioInfo1;
   1.818 +    TInt r1;
   1.819 +    
   1.820 +    for(TInt i = EDriveA; i <= EDriveZ; ++i)
   1.821 +        {
   1.822 +        r = TheFs.FileSystemName(fsName, i);
   1.823 +        if (r == KErrNone)
   1.824 +            {
   1.825 +            test.Printf(_L("Tested on drive: %c.\n"), (char)(i+'A'));
   1.826 +            r = TheFs.QueryVolumeInfoExt(i, EIOParamInfo, ioInfo);
   1.827 +            r1 = TheFs.VolumeIOParam(i, ioInfo1);
   1.828 +            test(r==r1);
   1.829 +            test(ioInfo().iBlockSize == ioInfo1.iBlockSize);
   1.830 +            test(ioInfo().iClusterSize == ioInfo1.iClusterSize);
   1.831 +            test(ioInfo().iRecReadBufSize == ioInfo1.iRecReadBufSize);
   1.832 +            test(ioInfo().iRecWriteBufSize == ioInfo1.iRecWriteBufSize);
   1.833 +            }
   1.834 +        }
   1.835 +    }
   1.836 +
   1.837 +
   1.838 +//----------------------------------------------------------------------------------------------
   1.839 +//! @SYMTestCaseID      PBASE-t_fsys-0322
   1.840 +//! @SYMTestType        CIT
   1.841 +//! @SYMPREQ            CR0882
   1.842 +//! @SYMTestCaseDesc    This test case is testing RFs::QueryVolumeInfoExt() API on a testing file system
   1.843 +//! @SYMTestActions     0   mounts testing file system on a certain drive
   1.844 +//!                     1   querys file system's sub type name on the drive under testing
   1.845 +//!                     2   querys file system's cluster size on the drive under testing
   1.846 +//! @SYMTestExpectedResults 
   1.847 +//!                     1   returned error code should be KErrNone, sub type name should match 'Test3SubType'
   1.848 +//!                     2   returned error code should be KErrNone, cluster size should equal 1024
   1.849 +//! @SYMTestPriority        High
   1.850 +//! @SYMTestStatus          Implemented
   1.851 +//----------------------------------------------------------------------------------------------
   1.852 +static void TestQueryVolumeInfoExtOnTestFS(TInt aDrive)
   1.853 +    {
   1.854 +    if (aDrive==EDriveC) // Can't test on C:
   1.855 +        return;
   1.856 +
   1.857 +    TInt r;
   1.858 +
   1.859 +    test.Printf(_L("Tested on drive: %c.\n"), (char)(aDrive+'A'));
   1.860 +
   1.861 +    // Mount a new CTestFileSystem on the drive under test
   1.862 +    test.Next(_L("Test RFs::QueryVolumeInfoExt() on Testing File System"));
   1.863 +    r = TheFs.AddFileSystem(_L("T_TFSYS3"));
   1.864 +    if (r != KErrNone && r != KErrAlreadyExists)
   1.865 +        {
   1.866 +        test.Printf(_L("error=%d"),r);
   1.867 +        test(EFalse);
   1.868 +        }
   1.869 +    TFSName oldFs;
   1.870 +    r = TheFs.FileSystemName(oldFs,aDrive);
   1.871 +    test(r==KErrNone);
   1.872 +    r = TheFs.DismountFileSystem(oldFs,aDrive);
   1.873 +    if (r != KErrNone)
   1.874 +        {
   1.875 +        test.Printf(_L("Error = %d"),r);    
   1.876 +        test(EFalse);
   1.877 +        }
   1.878 +    r = TheFs.MountFileSystem(_L("Test3"),aDrive);
   1.879 +    test(r==KErrNone);
   1.880 +    TFSName newFs;
   1.881 +    r = TheFs.FileSystemName(newFs,aDrive);
   1.882 +    test(r==KErrNone);
   1.883 +    test(newFs.Compare(_L("Test3"))==0);
   1.884 +
   1.885 +    // Sub type name query: 
   1.886 +    TPckgBuf<TFSName> subNameP;
   1.887 +    r = TheFs.QueryVolumeInfoExt(aDrive, EFileSystemSubType, subNameP);
   1.888 +    test(r==KErrNone);
   1.889 +    test(subNameP() == _L("Test3SubType"));
   1.890 +
   1.891 +    // Cluster size querys:
   1.892 +    TPckgBuf<TVolumeIOParamInfo> ioInfoP;
   1.893 +    r = TheFs.QueryVolumeInfoExt(aDrive, EIOParamInfo, ioInfoP);
   1.894 +    test(r==KErrNone);
   1.895 +    test(ioInfoP().iClusterSize==1024);
   1.896 +
   1.897 +    // Mount the original file system back
   1.898 +    r=TheFs.DismountFileSystem(newFs,aDrive);
   1.899 +    test(r==KErrNone);
   1.900 +    r=TheFs.MountFileSystem(oldFs,aDrive);
   1.901 +    test(r==KErrNone);
   1.902 +    
   1.903 +    r=TheFs.RemoveFileSystem(_L("Test3"));
   1.904 +    if(r!=KErrNone)
   1.905 +        {
   1.906 +        test.Printf(_L("error=%d"),r);
   1.907 +        test(EFalse);
   1.908 +        }
   1.909 +    }
   1.910 +
   1.911 +
   1.912 +//----------------------------------------------------------------------------------------------
   1.913 +/**
   1.914 +    Test remounting the file system with objects opened.
   1.915 +    scenario:
   1.916 +    1. create a file
   1.917 +    2. open it.
   1.918 +    3. forcedly remount the file system 
   1.919 +    4. read this file (this will imply remounting the filesystem)
   1.920 +*/
   1.921 +static void TestRemountFSWithOpenedObjects()
   1.922 +{
   1.923 +    test.Next(_L("Testing forcedly remounting FS with objects opened.\n"));
   1.924 +    
   1.925 +    TInt nRes;
   1.926 +    
   1.927 +    //-- 1. create a file
   1.928 +    _LIT(KFile, "\\test_file.file");
   1.929 +    const TUint KFileSz = 5000;
   1.930 +    
   1.931 +    nRes = CreateCheckableStuffedFile(TheFs, KFile, KFileSz);
   1.932 +    test_KErrNone(nRes);
   1.933 +
   1.934 +    RFile file;
   1.935 +
   1.936 +    //-- 2. open this file
   1.937 +    nRes = file.Open(TheFs, KFile, EFileRead);
   1.938 +    test_KErrNone(nRes);
   1.939 +
   1.940 +    //-- 2.1 try to dismount the FS, it must fail because of the opened object.
   1.941 +    TBuf<40> fsName;
   1.942 +    nRes = TheFs.FileSystemName(fsName, CurrentDrive());
   1.943 +    test_KErrNone(nRes);
   1.944 +
   1.945 +    nRes = TheFs.DismountFileSystem(fsName, CurrentDrive());
   1.946 +    test(nRes == KErrInUse);
   1.947 +
   1.948 +
   1.949 +    //-- 3. forcedly remount the drive
   1.950 +    nRes = TheFs.RemountDrive(CurrentDrive());
   1.951 +    if(nRes == KErrNotSupported)
   1.952 +    {//-- this feature is not supported and the test is inconsistent.
   1.953 +        test.Printf(_L("RemountDrive() is not supported, the test is inconsistent!"));
   1.954 +        
   1.955 +        //-- remounting must work at least on MMC drives
   1.956 +        const TBool isFAT = Is_Fat(TheFs, CurrentDrive());
   1.957 +
   1.958 +        TDriveInfo  driveInfo;
   1.959 +        nRes = TheFs.Drive(driveInfo, CurrentDrive());
   1.960 +        test_KErrNone(nRes);
   1.961 +
   1.962 +        test(!isFAT || (!(driveInfo.iDriveAtt & KDriveAttRemovable)));
   1.963 +
   1.964 +    }
   1.965 +    else
   1.966 +    {
   1.967 +        test_KErrNone(nRes);
   1.968 +    }
   1.969 +
   1.970 +    User::After(500*K1mSec);
   1.971 +
   1.972 +    //-- 4. read this file. The FS will be remounted and the read must be OK.
   1.973 +    TBuf8<40> buf;
   1.974 +    nRes = file.Read(0, buf, 30);
   1.975 +    test_KErrNone(nRes);
   1.976 +    
   1.977 +    file.Close();
   1.978 +
   1.979 +    //-- 5. verify the file, just in case.
   1.980 +    nRes = VerifyCheckableFile(TheFs, KFile);
   1.981 +    test_KErrNone(nRes);
   1.982 +
   1.983 +    //-- 6. delete the file
   1.984 +    TheFs.Delete(KFile);
   1.985 +
   1.986 +}
   1.987 +//----------------------------------------------------------------------------------------------
   1.988 +static void TestFileSystem_MaxSupportedFileSizeQuery()
   1.989 +{
   1.990 +    test.Next(_L("Test querying max. supported file size on this file system"));
   1.991 +    TFullName fsName;
   1.992 +    TPckgBuf<TVolumeIOParamInfo> ioInfo;
   1.993 +    TVolumeIOParamInfo& volInfo = ioInfo();
   1.994 +
   1.995 +    const TInt drvNo=CurrentDrive();
   1.996 +
   1.997 +    TInt nRes;
   1.998 +
   1.999 +    nRes = TheFs.FileSystemName(fsName, drvNo);
  1.1000 +    test_KErrNone(nRes);
  1.1001 +
  1.1002 +    nRes = TheFs.QueryVolumeInfoExt(drvNo, EIOParamInfo, ioInfo);
  1.1003 +    test_KErrNone(nRes);
  1.1004 +
  1.1005 +    test.Printf(_L("FS:'%S' Max File Size:0x%LX\n"), &fsName, volInfo.iMaxSupportedFileSize);
  1.1006 +    if(volInfo.iMaxSupportedFileSize == KMaxTUint64)
  1.1007 +    {
  1.1008 +        test.Printf(_L("Max File Size query isn't supported by this FS\n"));
  1.1009 +    }
  1.1010 +
  1.1011 +
  1.1012 +    //-- check the value for FAT FS only. 
  1.1013 +    if(Is_Fat(TheFs, drvNo))
  1.1014 +    {
  1.1015 +        test(volInfo.iMaxSupportedFileSize == KMaxSupportedFatFileSize);
  1.1016 +    }
  1.1017 +
  1.1018 +}
  1.1019 +
  1.1020 +//----------------------------------------------------------------------------------------------
  1.1021 +GLDEF_C void CallTestsL()
  1.1022 +//
  1.1023 +// Do all tests
  1.1024 +//
  1.1025 +    {
  1.1026 +
  1.1027 +    //-- set up console output 
  1.1028 +    Fat_Test_Utils::SetConsole(test.Console()); 
  1.1029 +
  1.1030 +    TInt drive=CurrentDrive();
  1.1031 +
  1.1032 +    PrintDrvInfo(TheFs, drive);
  1.1033 +
  1.1034 +    //Do not run this test on the NAND drive, as
  1.1035 +    //this has the FTL mounted as a primary extension
  1.1036 +    //which causes the test to fail
  1.1037 +    #if defined(__WINS__)
  1.1038 +        if (drive==EDriveU)
  1.1039 +            return;
  1.1040 +    #else
  1.1041 +        TDriveInfo driveInfo;
  1.1042 +        TheFs.Drive(driveInfo,drive);
  1.1043 +        if (driveInfo.iType == EMediaNANDFlash)
  1.1044 +            {
  1.1045 +            return;
  1.1046 +            }
  1.1047 +    #endif
  1.1048 +
  1.1049 +    //---------------------------------------
  1.1050 +
  1.1051 +    TestFileSystemNames();
  1.1052 +    TestDismountFileSystem(CurrentDrive());
  1.1053 +#if defined(__EPOC32__)
  1.1054 +    TestFileSystem(CurrentDrive());
  1.1055 +#endif
  1.1056 +
  1.1057 +    TestMountInvalidDrive();
  1.1058 +    
  1.1059 +    TestMountingBrokenMedia(CurrentDrive());
  1.1060 +    TestSubstDriveMediaSerialNumber();
  1.1061 +
  1.1062 +    TestFileSystemSubTypeQuery();
  1.1063 +    TestFileSystemClusterSizeQuery();
  1.1064 +    TestMediaBlockSizeQuery();
  1.1065 +    TestFileSystemSubType();
  1.1066 +    TestVolumeIOParam();
  1.1067 +    TestQueryVolumeInfoExtOnTestFS(CurrentDrive());
  1.1068 +
  1.1069 +    TestFileSystem_MaxSupportedFileSizeQuery();
  1.1070 +
  1.1071 +    TestRemountFSWithOpenedObjects();
  1.1072 +    
  1.1073 +    
  1.1074 +    }