os/kernelhwsrv/kerneltest/f32test/filesystem/fat/t_compat32.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/filesystem/fat/t_compat32.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,566 @@
     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\fat32\t_compat32.cpp
    1.18 +//
    1.19 +//
    1.20 +
    1.21 +#define __E32TEST_EXTENSION__
    1.22 +
    1.23 +#include <f32file.h>
    1.24 +#include <e32svr.h>
    1.25 +#include <e32test.h>
    1.26 +#include <f32dbg.h>
    1.27 +#include "t_server.h"
    1.28 +
    1.29 +#include "fat_utils.h"
    1.30 +using namespace Fat_Test_Utils;
    1.31 +
    1.32 +RTest test(_L("T_COMPAT32"));
    1.33 +
    1.34 +static RRawDisk TheDisk;
    1.35 +static TFatBootSector gBootSector;
    1.36 +
    1.37 +
    1.38 +static void QuickFormat()
    1.39 +    {
    1.40 +    FormatFatDrive(TheFs, CurrentDrive(), ETrue);
    1.41 +    }
    1.42 +
    1.43 +static void ReadBootSector(TFatBootSector& aBootSector)
    1.44 +	{
    1.45 +
    1.46 +    TInt nRes = ReadBootSector(TheFs, CurrentDrive(), KBootSectorNum<<KDefaultSectorLog2, aBootSector);
    1.47 +    test(nRes == KErrNone);
    1.48 +
    1.49 +    if(!aBootSector.IsValid())
    1.50 +        {
    1.51 +        test.Printf(_L("Wrong bootsector! Dump:\n"));
    1.52 +        aBootSector.PrintDebugInfo();
    1.53 +        test(0);
    1.54 +        }
    1.55 +	}
    1.56 +
    1.57 +
    1.58 +static void GetBootInfo()
    1.59 +	{
    1.60 +	QuickFormat();
    1.61 +	ReadBootSector(gBootSector);
    1.62 +	}
    1.63 +
    1.64 +enum TNameCase
    1.65 +	{
    1.66 +	EUpper, // Test directory entries with 8.3 uppercase (no VFAT entries expected)
    1.67 +	ELower, // Test directory entries with 8.3 lowercase (   VFAT entries expected)
    1.68 +	EMixed  // Test directory entries with 8.3 mixed     (   VFAT entries expected)
    1.69 +	};
    1.70 +
    1.71 +
    1.72 +/**
    1.73 +    Fiddles with root directory entries.
    1.74 +    Creates a file, if it has 1 VFAT and 1 DOS dir. entries, places an illegal lower case
    1.75 +    symbol to the DOS entry, fixing VFAT name checksums
    1.76 +*/
    1.77 +static void DoFiddleWithFileNames(TNameCase aCase)
    1.78 +{
    1.79 +	TFileName fileName = _L("\\WORD");
    1.80 +	TBool expectVfatEntry = EFalse;
    1.81 +
    1.82 +	switch(aCase)
    1.83 +		{
    1.84 +		case EUpper:
    1.85 +			break;
    1.86 +
    1.87 +		case ELower:
    1.88 +			fileName = _L("\\word");
    1.89 +			expectVfatEntry = ETrue;
    1.90 +			break;
    1.91 +
    1.92 +		case EMixed:
    1.93 +			fileName = _L("\\WoRd");
    1.94 +			expectVfatEntry = ETrue;
    1.95 +			break;
    1.96 +
    1.97 +		default:
    1.98 +			test(0);
    1.99 +			break;
   1.100 +		}
   1.101 +
   1.102 +	RFile file;
   1.103 +	TInt r=file.Create(TheFs,fileName,EFileRead);
   1.104 +	test(r==KErrNone);
   1.105 +	file.Close();
   1.106 +//	Assume this file is the first entry in the root directory
   1.107 +
   1.108 +
   1.109 +	r=TheDisk.Open(TheFs,CurrentDrive());
   1.110 +	test(r==KErrNone);
   1.111 +
   1.112 +    //-- read 1st dir. entry it can be FAT or VFat , depending on the filename
   1.113 +    const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
   1.114 +
   1.115 +    TFatDirEntry fatEntry1;
   1.116 +	TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
   1.117 +
   1.118 +    test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
   1.119 +
   1.120 +    if(!fatEntry1.IsVFatEntry())
   1.121 +    {//-- we expected FAT entry, everything is OK
   1.122 +        test(!expectVfatEntry);
   1.123 +    }
   1.124 +    else
   1.125 +    {//-- we have 2 FAT entries, 1st is VFat, 2nd is DOS.
   1.126 +     //-- put lower case letters into DOS entry( not compliant with FAT specs), correct VFat entries checksums,
   1.127 +     //-- in this case the system shall correctly deal with the file, using long names.
   1.128 +
   1.129 +        test(expectVfatEntry);
   1.130 +        test(fatEntry1.iData[0] == 0x41); //-- must have only 2 entries
   1.131 +
   1.132 +        //-- read DOS entry now
   1.133 +        TFatDirEntry fatEntry2;
   1.134 +        TPtr8 ptrEntry2((TUint8*)&fatEntry2,sizeof(TFatDirEntry));
   1.135 +        const TInt posEntry2 = posEntry1 + sizeof(TFatDirEntry); //-- dir entry2 position
   1.136 +
   1.137 +        test(TheDisk.Read(posEntry2, ptrEntry2)==KErrNone);
   1.138 +
   1.139 +        //-- ensure that the name and checksum are correct
   1.140 +        test(fatEntry1.iData[13] == CalculateShortNameCheckSum(fatEntry2.Name()));
   1.141 +        test(fatEntry2.Name()==_L8("WORD       "));
   1.142 +
   1.143 +        //-- put lower case symbol to the DOS entry and fix the checksum
   1.144 +        _LIT8(KBadDosName, "Word       ");
   1.145 +        fatEntry2.SetName(KBadDosName);
   1.146 +        fatEntry1.iData[13] = CalculateShortNameCheckSum(fatEntry2.Name());
   1.147 +
   1.148 +        //-- write data to the disk
   1.149 +        test(TheDisk.Write(posEntry1, ptrEntry1)==KErrNone);
   1.150 +        test(TheDisk.Write(posEntry2, ptrEntry2)==KErrNone);
   1.151 +
   1.152 +    }
   1.153 +
   1.154 +	TheDisk.Close();
   1.155 +
   1.156 +}
   1.157 +
   1.158 +//
   1.159 +// Replace a 8.3 filename with upper and lower case letters which is, actually out of FAT specs.
   1.160 +// I.e. VFAT entries are valid, but DOS entry has a lower case symbol, which is wrong.
   1.161 +//
   1.162 +LOCAL_C void Test1(TNameCase aCase)
   1.163 +	{
   1.164 +	test.Next(_L("Replace a file with a wrong DOS entry"));
   1.165 +	QuickFormat();
   1.166 +
   1.167 +    //-- N.B. This shall be the before any dir. entries creation in the root directory
   1.168 +    //-- because it directly accesses the directory's 1st file
   1.169 +    DoFiddleWithFileNames(aCase);
   1.170 +
   1.171 +    RFile file;
   1.172 +    TInt r;
   1.173 +
   1.174 +	r=file.Replace(TheFs,_L("\\FILE.TMP"),EFileRead);
   1.175 +	test(r==KErrNone);
   1.176 +	r=file.Write(_L8("Hello World"));
   1.177 +	file.Close();
   1.178 +
   1.179 +	r=TheFs.Replace(_L("\\File.tmp"),_L("\\Word"));
   1.180 +	test(r==KErrNone);
   1.181 +
   1.182 +	CDir* entryCount;
   1.183 +	r=TheFs.GetDir(_L("\\*.*"),KEntryAttMaskSupported,ESortNone,entryCount);
   1.184 +	test(r==KErrNone);
   1.185 +	TInt count=entryCount->Count();
   1.186 +
   1.187 +	test(count==1);
   1.188 +	delete entryCount;
   1.189 +	}
   1.190 +
   1.191 +
   1.192 +//
   1.193 +// Renaming a 8.3 filename with upper and lower case letters which is, actually out of FAT specs.
   1.194 +// I.e. VFAT entries are valid, but DOS entry has a lower case symbol, which is wrong.
   1.195 +//
   1.196 +LOCAL_C void Test2(TNameCase aCase)
   1.197 +	{
   1.198 +	test.Next(_L("Rename a file with a wrong DOS entry"));
   1.199 +	QuickFormat();
   1.200 +	RFile file;
   1.201 +    TInt r;
   1.202 +
   1.203 +    //-- N.B. This shall be the before any dir. entries creation in the root dir
   1.204 +    //-- because it directly accesses the directory's 1st file
   1.205 +    DoFiddleWithFileNames(aCase);
   1.206 +
   1.207 +	r=file.Create(TheFs,_L("\\TEST"),EFileRead);
   1.208 +	test(r==KErrNone);
   1.209 +	file.Close();
   1.210 +
   1.211 +	r=TheFs.Rename(_L("\\TEST"),_L("\\Word"));
   1.212 +	test(r==KErrAlreadyExists);
   1.213 +	r=TheFs.Delete(_L("\\TEST"));
   1.214 +	test(r==KErrNone);
   1.215 +
   1.216 +	CDir* entryCount;
   1.217 +	r=TheFs.GetDir(_L("\\*.*"),KEntryAttMaskSupported,ESortNone,entryCount);
   1.218 +	test(r==KErrNone);
   1.219 +	TInt count=entryCount->Count();
   1.220 +	test(count==1);
   1.221 +	delete entryCount;
   1.222 +	}
   1.223 +
   1.224 +
   1.225 +//---------------------------------------------
   1.226 +//! @SYMTestCaseID			PBASE-T_COMPAT32-0686
   1.227 +//! @SYMTestType			CT
   1.228 +//! @SYMREQ					DEF115314
   1.229 +//! @SYMTestCaseDesc		Test character '`' (0x60) is recognized as a legal char for short file names.
   1.230 +//! @SYMTestActions			Creates a file named "\x60\x60\x60.TXT", checks only DOS entry is created for
   1.231 +//!							it and its short name equals "```.TXT" instead of "___.TXT"
   1.232 +//! @SYMTestExpectedResults	The operation completes with error code KErrNone;
   1.233 +//! @SYMTestPriority		High
   1.234 +//! @SYMTestStatus			Implemented
   1.235 +//---------------------------------------------
   1.236 +void TestDEF115314()
   1.237 +	{
   1.238 +	test.Next(_L("Test DEF115314: TTG:<`(0x60) code cannot be used as valid Short File Name>"));
   1.239 +	QuickFormat();
   1.240 +	RFile file;
   1.241 +    TInt r;
   1.242 +
   1.243 +    TFileName fn;
   1.244 +    fn.Format(_L("%c:\\\x60\x60\x60.TXT"), (TUint8)gDriveToTest);
   1.245 +
   1.246 +    r = TheFs.Delete(fn);
   1.247 +	test(r==KErrNone || r==KErrNotFound);
   1.248 +
   1.249 +	r = file.Create(TheFs, fn, EFileRead);
   1.250 +	test(r==KErrNone);
   1.251 +	file.Close();
   1.252 +
   1.253 +	r=TheDisk.Open(TheFs,CurrentDrive());
   1.254 +	test(r==KErrNone);
   1.255 +
   1.256 +    //-- read 1st dir. it should be DOS Entry
   1.257 +    const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
   1.258 +    TFatDirEntry fatEntry1;
   1.259 +	TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
   1.260 +    test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
   1.261 +    TheDisk.Close();
   1.262 +    test(!fatEntry1.IsVFatEntry());
   1.263 +
   1.264 +    // tests short name
   1.265 +    TFileName sn;
   1.266 +    r = TheFs.GetShortName(fn, sn);
   1.267 +    test(r==KErrNone);
   1.268 +    test(sn.Compare(_L("```.TXT"))==0);
   1.269 +
   1.270 +    r = TheFs.Delete(fn);
   1.271 +	test(r==KErrNone);
   1.272 +	}
   1.273 +
   1.274 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   1.275 +_LIT(KTestLocale, 			"t_tlocl_cp932.dll");
   1.276 +_LIT(KTestUnicodeFileName, 	"\\\x65B0\x6587\x4EF6");
   1.277 +#endif //_DEBUG || _DEBUG_RELEASE
   1.278 +
   1.279 +//---------------------------------------------
   1.280 +//! @SYMTestCaseID			PBASE-T_COMPAT32-0685
   1.281 +//! @SYMTestType			CT
   1.282 +//! @SYMREQ					DEF113633
   1.283 +//! @SYMTestCaseDesc		Test FAT volume creates VFat entries for short unicode named files
   1.284 +//! @SYMTestActions			Enables FatUtilityFunctions. Loads cp932 codepage dll. Create a file
   1.285 +//!							named as "\x65B0\x6587\x4EF6", checks both a VFat entry and a DOS
   1.286 +//!							entry have been created for the file.
   1.287 +//! @SYMTestExpectedResults	The operation completes with error code KErrNone;
   1.288 +//! @SYMTestPriority		High
   1.289 +//! @SYMTestStatus			Implemented
   1.290 +//---------------------------------------------
   1.291 +void TestDEF113633()
   1.292 +	{
   1.293 +	test.Next(_L("Test DEF113633 - FAT should create VFat entries for unicode character contained file names"));
   1.294 +#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   1.295 +	QuickFormat();
   1.296 +	RFile file;
   1.297 +    TInt r;
   1.298 +    TInt drvNum;
   1.299 +
   1.300 +    r = TheFs.CharToDrive(gDriveToTest,drvNum);
   1.301 +	test(r==KErrNone);
   1.302 +
   1.303 +    // turn on FatUtilityFunctions
   1.304 +    r = TheFs.ControlIo(drvNum, KControlIoEnableFatUtilityFunctions);
   1.305 +	test(r==KErrNone);
   1.306 +
   1.307 +	// load cp932 codepage dll
   1.308 +	r = UserSvr::ChangeLocale(KTestLocale);
   1.309 +	test(r==KErrNone);
   1.310 +
   1.311 +    // create file "\x65B0\x6587\x4EF6", check DOS entry & VFat entry
   1.312 +	r = file.Create(TheFs, KTestUnicodeFileName, EFileRead);
   1.313 +	test(r==KErrNone);
   1.314 +	file.Close();
   1.315 +
   1.316 +	r=TheDisk.Open(TheFs,CurrentDrive());
   1.317 +	test(r==KErrNone);
   1.318 +
   1.319 +    //-- read 1st dir. it should be VFat
   1.320 +//    const TInt posEntry1=gRootDirStart; //-- dir entry1 position
   1.321 +    const TInt posEntry1=gBootSector.RootDirStartSector() << KDefaultSectorLog2; //-- dir entry1 position
   1.322 +    TFatDirEntry fatEntry1;
   1.323 +	TPtr8 ptrEntry1((TUint8*)&fatEntry1,sizeof(TFatDirEntry));
   1.324 +
   1.325 +    test(TheDisk.Read(posEntry1, ptrEntry1)==KErrNone);
   1.326 +
   1.327 +    test(fatEntry1.IsVFatEntry());
   1.328 +
   1.329 +    test(fatEntry1.iData[0] == 0x41); //-- must have only 2 entries
   1.330 +
   1.331 +    //-- read DOS entry now
   1.332 +    TFatDirEntry fatEntry2;
   1.333 +    TPtr8 ptrEntry2((TUint8*)&fatEntry2,sizeof(TFatDirEntry));
   1.334 +    const TInt posEntry2 = posEntry1 + sizeof(TFatDirEntry); //-- dir entry2 position
   1.335 +
   1.336 +    test(TheDisk.Read(posEntry2, ptrEntry2)==KErrNone);
   1.337 +
   1.338 +    //-- ensure that the name and checksum are correct
   1.339 +    test(!fatEntry2.IsVFatEntry());
   1.340 +    test(fatEntry1.iData[13] == CalculateShortNameCheckSum(fatEntry2.Name()));
   1.341 +
   1.342 +    // delete file
   1.343 +    TheDisk.Close();
   1.344 +    r = TheFs.Delete(KTestUnicodeFileName);
   1.345 +	test(r==KErrNone);
   1.346 +
   1.347 +	// turn off FatUtilityFunctions
   1.348 +	r = TheFs.ControlIo(drvNum, KControlIoDisableFatUtilityFunctions);
   1.349 +	test(r==KErrNone);
   1.350 +
   1.351 +#else
   1.352 +	test.Printf(_L("Test only runs on DEBUG builds, see test logs of debug builds for details."));
   1.353 +#endif  // _DEBUG) || _DEBUG_RELEASE
   1.354 +	}
   1.355 +
   1.356 +
   1.357 +
   1.358 +
   1.359 +//---------------------------------------------
   1.360 +// If the parent directory of a directory is the root directory,
   1.361 +// the '..' entry should point to start cluster 0 in any case
   1.362 +//---------------------------------------------
   1.363 +void TestPDEF116912()
   1.364 +	{
   1.365 +	test.Next(_L("Test PDEF116912 - Check that '..' parent cluster address is 0 after renaming\n"));
   1.366 +
   1.367 +  	TInt drvNum;
   1.368 +	test(KErrNone == TheFs.CharToDrive(gDriveToTest, drvNum));
   1.369 +
   1.370 +	if(!Is_Fat32(TheFs, drvNum))
   1.371 +		{
   1.372 +		_LIT(KMessage, "Test only applicable to FAT32 file systems. Skipping.\n");
   1.373 +		test.Printf(KMessage);
   1.374 +		return;
   1.375 +		}
   1.376 +
   1.377 +	QuickFormat();
   1.378 +
   1.379 +	_LIT(KDirA, "\\dirA\\");
   1.380 +	_LIT(KDirB, "\\dirB\\");
   1.381 +
   1.382 +	test(KErrNone == TheFs.MkDir(KDirA));
   1.383 +	test(KErrNone == TheFs.Rename(KDirA, KDirB));
   1.384 +
   1.385 +	test(gBootSector.IsValid());
   1.386 +	TInt mediaPosition = gBootSector.RootDirStartSector() * gBootSector.BytesPerSector();
   1.387 +
   1.388 +	TFatDirEntry dirEntry;
   1.389 +	TPtr8 ptrEntry((TUint8*) &dirEntry,sizeof(TFatDirEntry));
   1.390 +
   1.391 +	_LIT8(KDirBMatchPattern, "DIRB *");
   1.392 +	_LIT8(KDotDotMatchPattern, ".. *");
   1.393 +
   1.394 +	const TInt KMaxEntriesToSearch = (gBootSector.SectorsPerCluster() * gBootSector.BytesPerSector()) / KSizeOfFatDirEntry;
   1.395 +	test(KErrNone == TheDisk.Open(TheFs, drvNum));
   1.396 +
   1.397 +	for(TInt c = 0; c < KMaxEntriesToSearch; c++)
   1.398 +		{
   1.399 +	    test(KErrNone == TheDisk.Read(mediaPosition, ptrEntry));
   1.400 +
   1.401 +		if(KErrNotFound == ptrEntry.Match(KDirBMatchPattern))
   1.402 +			{
   1.403 +			// keep scanning
   1.404 +			mediaPosition += sizeof(TFatDirEntry);
   1.405 +			}
   1.406 +		else
   1.407 +			{
   1.408 +			// found, locate '..' entry
   1.409 +			test(dirEntry.StartCluster() >= KFatFirstSearchCluser);
   1.410 +			mediaPosition  = gBootSector.FirstDataSector();
   1.411 +			mediaPosition += (dirEntry.StartCluster() - KFatFirstSearchCluser) * gBootSector.SectorsPerCluster();
   1.412 +			mediaPosition *= gBootSector.BytesPerSector();
   1.413 +			mediaPosition += KSizeOfFatDirEntry; // '..' is always the 2nd entry
   1.414 +
   1.415 +			test(KErrNone == TheDisk.Read(mediaPosition, ptrEntry));
   1.416 +
   1.417 +			test(KErrNotFound != ptrEntry.Match(KDotDotMatchPattern));
   1.418 +			test(dirEntry.StartCluster() == 0);
   1.419 +
   1.420 +			TheDisk.Close();
   1.421 +			return;
   1.422 +			}
   1.423 +		}
   1.424 +
   1.425 +	// dirB entry not found - test failed
   1.426 +	TheDisk.Close();
   1.427 +	test(0);
   1.428 +	}
   1.429 +
   1.430 +//---------------------------------------------
   1.431 +/**
   1.432 +    Test replacing files by theis short names
   1.433 +*/
   1.434 +void TestReplaceByShortName()
   1.435 +{
   1.436 +    test.Next(_L("Test replacing files using short names\n"));
   1.437 +    QuickFormat();
   1.438 +
   1.439 +    _LIT(KLongName1,  "abcdefghi.txt");
   1.440 +    _LIT(KShortName1, "ABCDEF~1.TXT");
   1.441 +    const TInt KFile1Sz = 100;
   1.442 +
   1.443 +    _LIT(KLongName2,  "abcdefghij.txt");
   1.444 +    _LIT(KShortName2, "ABCDEF~2.TXT");
   1.445 +    const TInt KFile2Sz = 200;
   1.446 +
   1.447 +
   1.448 +    TInt        nRes;
   1.449 +    TFileName   fn;
   1.450 +    TEntry      entry;
   1.451 +
   1.452 +    TheFs.SetSessionPath(_L("\\"));
   1.453 +
   1.454 +    nRes = CreateCheckableStuffedFile(TheFs, KLongName1, KFile1Sz);
   1.455 +    test_KErrNone(nRes);
   1.456 +
   1.457 +    nRes = TheFs.GetShortName(KLongName1, fn);
   1.458 +    test(nRes == KErrNone && fn == KShortName1); //-- just check short name generation
   1.459 +
   1.460 +    nRes =CreateCheckableStuffedFile(TheFs, KLongName2, KFile2Sz);
   1.461 +    test_KErrNone(nRes);
   1.462 +
   1.463 +    nRes = TheFs.GetShortName(KLongName2, fn);
   1.464 +    test(nRes == KErrNone && fn == KShortName2); //-- just check short name generation
   1.465 +
   1.466 +    //-- try to replace the file with itself using its short name alias
   1.467 +    //-- nothing shall happen and the file must remain the same
   1.468 +    nRes = TheFs.Replace(KLongName1, KShortName1);
   1.469 +    test(nRes == KErrNone);
   1.470 +
   1.471 +    nRes = TheFs.Entry(KLongName1, entry);
   1.472 +    test(nRes == KErrNone);
   1.473 +    test(entry.iSize == KFile1Sz);
   1.474 +
   1.475 +    nRes = TheFs.Entry(KShortName1, entry);
   1.476 +    test(nRes == KErrNone);
   1.477 +    test(entry.iSize == KFile1Sz);
   1.478 +
   1.479 +
   1.480 +    nRes = TheFs.Replace(KShortName1, KLongName1);
   1.481 +    test(nRes == KErrNone);
   1.482 +
   1.483 +    nRes = TheFs.Entry(KLongName1, entry);
   1.484 +    test(nRes == KErrNone);
   1.485 +    test(entry.iSize == KFile1Sz);
   1.486 +
   1.487 +    nRes = TheFs.Entry(KShortName1, entry);
   1.488 +    test(nRes == KErrNone);
   1.489 +    test(entry.iSize == KFile1Sz);
   1.490 +
   1.491 +    nRes = VerifyCheckableFile(TheFs, KLongName1);
   1.492 +    test(nRes == KErrNone);
   1.493 +
   1.494 +    nRes = VerifyCheckableFile(TheFs, KShortName1);
   1.495 +    test(nRes == KErrNone);
   1.496 +
   1.497 +
   1.498 +    //-- replace "abcdefghi.txt" by "ABCDEF~2.TXT" which is the alias for "abcdefghij.txt"
   1.499 +    //-- expected: contents and all attributes of the "abcdefghij.txt" is replaced with "abcdefghi.txt"
   1.500 +    //-- "abcdefghi.txt" entries gets deleted.
   1.501 +
   1.502 +    nRes = TheFs.Replace(KLongName1, KShortName2);
   1.503 +    test(nRes == KErrNone);
   1.504 +
   1.505 +    //User::After(5*K1Sec);
   1.506 +    /*
   1.507 +    nRes = VerifyCheckableFile(TheFs, KLongName2);
   1.508 +    test(nRes == KErrNone);
   1.509 +
   1.510 +    nRes = VerifyCheckableFile(TheFs, KShortName2);
   1.511 +    test(nRes == KErrNone);
   1.512 +    */
   1.513 +
   1.514 +
   1.515 +    nRes = TheFs.Entry(KLongName2, entry);
   1.516 +    test(nRes == KErrNone);
   1.517 +    test(entry.iSize == KFile1Sz);
   1.518 +
   1.519 +    nRes = TheFs.Entry(KShortName2, entry);
   1.520 +    test(nRes == KErrNone);
   1.521 +    test(entry.iSize == KFile1Sz && entry.iName == KLongName2);
   1.522 +
   1.523 +
   1.524 +}
   1.525 +
   1.526 +
   1.527 +GLDEF_C void CallTestsL()
   1.528 +//
   1.529 +// Call tests that may leave
   1.530 +//
   1.531 +	{
   1.532 +
   1.533 +	TInt drvNum;
   1.534 +	TInt r=TheFs.CharToDrive(gDriveToTest,drvNum);
   1.535 +	test(r==KErrNone);
   1.536 +
   1.537 +    if (!Is_Fat(TheFs,drvNum))
   1.538 +		{
   1.539 +		test.Printf(_L("CallTestsL: Skipped: Requires FAT filesystem to run.\n"));
   1.540 +		return;
   1.541 +		}
   1.542 +
   1.543 +
   1.544 +    //-- set up console output
   1.545 +    SetConsole(test.Console());
   1.546 +
   1.547 +    //-- print drive information
   1.548 +    PrintDrvInfo(TheFs, drvNum);
   1.549 +
   1.550 +	GetBootInfo();
   1.551 +
   1.552 +	Test1(EUpper); // Test directory entries with 8.3 uppercase (no VFAT entries expected)
   1.553 +	Test1(ELower); // Test directory entries with 8.3 lowercase (   VFAT entries expected)
   1.554 +	Test1(EMixed); // Test directory entries with 8.3 mixed     (   VFAT entries expected)
   1.555 +
   1.556 +	Test2(EUpper); // Test directory entries with 8.3 uppercase (no VFAT entries expected)
   1.557 +	Test2(ELower); // Test directory entries with 8.3 lowercase (   VFAT entries expected)
   1.558 +	Test2(EMixed); // Test directory entries with 8.3 mixed     (   VFAT entries expected)
   1.559 +
   1.560 +	TestDEF115314();
   1.561 +	TestDEF113633();
   1.562 +	TestPDEF116912();
   1.563 +
   1.564 +    TestReplaceByShortName();
   1.565 +
   1.566 +	}
   1.567 +
   1.568 +
   1.569 +