os/kernelhwsrv/kerneltest/f32test/server/t_bigfile.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     4 // under the terms of the License "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // N.B. Before running this test on WINS, ensure that the estart.txt file contains 
    15 // nothing but  EFAT32 i.e. no EFAT - otherwise the FAT16 file system will be used
    16 // On target ensure that the FAT32 filesystem is in the ROM instead of the FAT16 file system
    17 // This test expects the following files to be present before running the test:
    18 // size			name
    19 // 2147483647	\F32-TST\File2GBMinusOne.txt
    20 // 2147483648	\F32-TST\File2GB.txt
    21 // 3221225472	\F32-TST\File3GB.txt
    22 // 4294967295	\F32-TST\File4GBMinusOne.txt	// may be absent on an 8GB disk
    23 // For verification purposes, Every 4 bytes of each file contains the current position, e.g.
    24 // 0000: 00 00 00 00 
    25 // 0004: 04 00 00 00
    26 // 0008: 08 00 00 00
    27 // .. etc
    28 // These files can be created using the BigFileWriter tool in f32test/tool
    29 // If this test is run on the emulator and the __MOUNT_RAW_EXT__ macro is defined (see below) then
    30 // the T_RAWEXT file system extension will be loaded; this extension allows reading and writing to 
    31 // a windows disk in "raw" format, thus allowing direct access to a windows disk. see f32test/ext/t_rawext
    32 // for more details.
    33 // 
    34 //
    35 
    36 
    37 #include <f32file.h>
    38 #include <e32test.h>
    39 #include <e32svr.h>
    40 #include "t_server.h"
    41 
    42 
    43 GLDEF_D RTest test(_L("T_BIGFILE"));
    44 
    45 #ifdef __WINS__
    46 // enable this macro to mount the RAWEXT.FXT file system extension to test on a particular windows drive
    47 #define __MOUNT_RAW_EXT__
    48 #endif
    49 
    50 #ifdef __MOUNT_RAW_EXT__
    51 _LIT(KExtName,"RAWEXT");
    52 
    53 _LIT(KFAT32FName,"EFAT32");
    54 _LIT(KFATName,"FAT");
    55 
    56 TFullName gOldFsName;
    57 #endif
    58 
    59 TInt gDrive;
    60 TBool gNTFS=EFalse;
    61 
    62 const TUint K1Kb = 1 << 10;
    63 //const TUint K1Mb = 1 << 20;
    64 const TUint K1Gb = 1 << 30;
    65 const TUint K2Gb = 0x80000000;
    66 const TUint K2GbMinusOne = 0x7FFFFFFF;
    67 const TUint K3Gb = 0xC0000000;
    68 const TUint K4GbMinusOne = 0xFFFFFFFF;
    69 const TUint KPosMask     = 0xFFFFFFFC;
    70 
    71 //const TUint KBigFileSizeSigned = KMaxTInt32;		// 2Gb -1
    72 //const TUint KBigFileSizeUnsigned = KMaxTUint32;	// 4Gb -1
    73 
    74 const TInt KBufSize = (256 * K1Kb);
    75 HBufC8* gBuf = NULL;
    76 TPtr8 gBufPtr(NULL, 0, 0);
    77 
    78 
    79 _LIT(KFile2GBMinusOne, "File2GBMinusOne.txt");
    80 _LIT(KFile2GB, "File2GB.txt");
    81 _LIT(KFile3GB, "File3GB.txt");
    82 _LIT(KFile4GBMinusOne, "File4GBMinusOne.txt");
    83 TInt gFilesInDirectory = 4;
    84 
    85 
    86 // return ETrue if the specifiled file is present
    87 TBool FilePresent(const TDesC& aFileName)
    88 	{
    89 	TEntry entry;
    90 	TInt r = TheFs.Entry(aFileName, entry);
    91 	return (r == KErrNone ? (TBool)ETrue : (TBool)EFalse);
    92 	}
    93 
    94 class CFileManObserver : public CBase, public MFileManObserver
    95 	{
    96 public:
    97 	CFileManObserver(CFileMan* aFileMan);
    98 
    99 	TControl NotifyFileManStarted();
   100 	TControl NotifyFileManOperation();
   101 	TControl NotifyFileManEnded();
   102 private:
   103 	CFileMan* iFileMan;
   104 public:
   105 	TInt iNotifyEndedSuccesses;
   106 	TInt iNotifyEndedFailures;
   107 	};
   108 
   109 CFileManObserver::CFileManObserver(CFileMan* aFileMan)
   110 	{
   111 	__DECLARE_NAME(_S("CFileManObserver"));
   112 	iFileMan=aFileMan;
   113 	}
   114 
   115 MFileManObserver::TControl CFileManObserver::NotifyFileManStarted()
   116 	{
   117 	TInt lastError = iFileMan->GetLastError();
   118 	TFileName fileName = iFileMan->CurrentEntry().iName;
   119 	test.Printf(_L("NotifyFileManStarted(): Error %d File %S\n"),lastError, &fileName);
   120 	return(MFileManObserver::EContinue);
   121 	}
   122 
   123 MFileManObserver::TControl CFileManObserver::NotifyFileManOperation()
   124 	{
   125 	TInt lastError = iFileMan->GetLastError();
   126 	TFileName fileName = iFileMan->CurrentEntry().iName;
   127 	test.Printf(_L("NotifyFileManOperation(): Error %d File %S\n"),lastError, &fileName);
   128 	return(MFileManObserver::EContinue);
   129 	}
   130 
   131 MFileManObserver::TControl CFileManObserver::NotifyFileManEnded()
   132 	{
   133 	TInt lastError = iFileMan->GetLastError();
   134 	TFileName fileName = iFileMan->CurrentEntry().iName;
   135 	test.Printf(_L("NotifyFileManEnded(): Error %d File %S\n"),lastError, &fileName);
   136 	if (lastError == KErrNone)
   137 		iNotifyEndedSuccesses++;
   138 	else
   139 		iNotifyEndedFailures++;
   140 	return(MFileManObserver::EContinue);
   141 	}
   142 
   143 
   144 
   145 //----------------------------------------------------------------------------------------------
   146 //! @SYMTestCaseID      PBASE-T_BIGFILE-0001
   147 //! @SYMTestType        CIT
   148 //! @SYMTestCaseDesc    Test that 2GB-1 file can be opened and read
   149 //! @SYMTestActions     Open the file, seek to end-1K and read some data. Verify the results
   150 //! @SYMTestExpectedResults Should succeed
   151 //! @SYMTestPriority    High
   152 //! @SYMTestStatus      Implemented
   153 //----------------------------------------------------------------------------------------------
   154 void OpenAndRead2GBMinusOne()
   155 	{
   156 	RFile f;
   157 	TEntry entry;
   158 	TUint testSize;
   159 	TUint size;
   160 	TUint testPos;
   161 	TInt r;
   162 
   163 	TPtr8 bufPtr = gBuf->Des();
   164 	bufPtr.SetLength(bufPtr.MaxLength());
   165 
   166 	const TFileName fname = KFile2GBMinusOne();
   167 
   168 	test.Next(_L("2GBMinusOne File: Open"));
   169 
   170 	r = f.Open(TheFs, fname, EFileRead);
   171 	test(r==KErrNone);
   172 
   173 	testSize = K2GbMinusOne;
   174 	
   175 	test.Next(_L("2GBMinusOne File: Read"));
   176 
   177 	r=f.Size((TInt&) size);
   178 	test(r==KErrNone);
   179 	test(size == testSize);
   180 	
   181 	r = TheFs.Entry(fname, entry);
   182 	test(r==KErrNone);
   183 	test ((TUint) entry.iSize == testSize);
   184 
   185 	// seek to just below 2GB
   186 	testPos = (K2GbMinusOne - K1Kb) & KPosMask;
   187 	r = f.Seek(ESeekStart, (TInt&) testPos);
   188 	test(r==KErrNone);
   189 
   190 	r = f.Read(bufPtr);
   191 	test(r==KErrNone);
   192 
   193 	TUint posRead =  * ((TUint*) &bufPtr[0]);
   194 	test.Printf(_L("position read %08X, expected %08X\n"), posRead, testPos);
   195 	test(posRead == testPos);
   196 
   197 	f.Close();
   198 	}
   199 
   200 //----------------------------------------------------------------------------------------------
   201 //! @SYMTestCaseID      PBASE-T_BIGFILE-0002
   202 //! @SYMTestType        CIT
   203 //! @SYMTestCaseDesc    Test that attempting to open a 2GB file fails
   204 //! @SYMTestActions     Open the file
   205 //! @SYMTestExpectedResults KErrToBig
   206 //! @SYMTestPriority    High
   207 //! @SYMTestStatus      Implemented
   208 //----------------------------------------------------------------------------------------------
   209 void Open2GB()
   210 	{
   211 	RFile f;
   212 	TEntry entry;
   213 	TUint testSize;
   214 	TInt r;
   215 
   216 	TPtr8 bufPtr = gBuf->Des();
   217 	bufPtr.SetLength(bufPtr.MaxLength());
   218 
   219 	const TFileName fname = KFile2GB();
   220 	testSize = K2Gb;
   221 
   222 	test.Next(_L("2GB File: Test the size with RFs::Entry"));
   223 	r = TheFs.Entry(fname, entry);
   224 	test(r==KErrNone);
   225 	test ((TUint) entry.iSize == testSize);
   226 
   227 	test.Next(_L("2GB File: Attempt to open (should fail with KErrToBig)"));
   228 
   229 	r = f.Open(TheFs, fname, EFileRead);
   230 	test(r==KErrTooBig);
   231 	}
   232 
   233 //----------------------------------------------------------------------------------------------
   234 //! @SYMTestCaseID      PBASE-T_BIGFILE-0003
   235 //! @SYMTestType        CIT
   236 //! @SYMTestCaseDesc    Test that attempting to open a 2GB file fails
   237 //! @SYMTestActions     Open the file
   238 //! @SYMTestExpectedResults KErrToBig
   239 //! @SYMTestPriority    High
   240 //! @SYMTestStatus      Implemented
   241 //----------------------------------------------------------------------------------------------
   242 void Open3GB()
   243 	{
   244 	RFile f;
   245 	TEntry entry;
   246 	TUint testSize;
   247 	TInt r;
   248 
   249 	TPtr8 bufPtr = gBuf->Des();
   250 	bufPtr.SetLength(bufPtr.MaxLength());
   251 
   252 	const TFileName fname = KFile3GB();
   253 	testSize = K3Gb;
   254 
   255 	test.Next(_L("3GB File: Test the size with RFs::Entry"));
   256 	r = TheFs.Entry(fname, entry);
   257 	test(r==KErrNone);
   258 	test ((TUint) entry.iSize == testSize);
   259 
   260 	test.Next(_L("3GB File: Attempt to open (should fail with KErrToBig)"));
   261 
   262 	r = f.Open(TheFs, fname, EFileRead);
   263 	test(r==KErrTooBig);
   264 	}
   265 
   266 //----------------------------------------------------------------------------------------------
   267 //! @SYMTestCaseID      PBASE-T_BIGFILE-0004
   268 //! @SYMTestType        CIT
   269 //! @SYMTestCaseDesc    Test that attempting to open a 4GB file fails
   270 //! @SYMTestActions     Open the file
   271 //! @SYMTestExpectedResults KErrToBig
   272 //! @SYMTestPriority    High
   273 //! @SYMTestStatus      Implemented
   274 //----------------------------------------------------------------------------------------------
   275 void Open4GB()
   276 	{
   277 	RFile f;
   278 	TEntry entry;
   279 	TUint testSize;
   280 	TInt r;
   281 
   282 	TPtr8 bufPtr = gBuf->Des();
   283 	bufPtr.SetLength(bufPtr.MaxLength());
   284 
   285 	const TFileName fname = KFile4GBMinusOne();
   286 	testSize = K4GbMinusOne;
   287 
   288 	test.Next(_L("4GB File: Test the size with RFs::Entry"));
   289 	r = TheFs.Entry(fname, entry);
   290 	
   291 	test(r==KErrNone);
   292 	test ((TUint) entry.iSize == testSize);
   293 
   294 	test.Next(_L("4GB File: Attempt to open (should fail with KErrToBig)"));
   295 
   296 	r = f.Open(TheFs, fname, EFileRead);
   297 	test(r==KErrTooBig);
   298 	}
   299 
   300 //----------------------------------------------------------------------------------------------
   301 //! @SYMTestCaseID      PBASE-T_BIGFILE-0005
   302 //! @SYMTestType        CIT
   303 //! @SYMTestCaseDesc    Attempt to append to the end of a 2GB-1 file
   304 //! @SYMTestActions     Open the file, seek to end and write one byte
   305 //! @SYMTestExpectedResults RFile::Write(0 returns KErrToBig
   306 //! @SYMTestPriority    High
   307 //! @SYMTestStatus      Implemented
   308 //----------------------------------------------------------------------------------------------
   309 void Extend2GBMinusOne()
   310 	{
   311 	RFile f;
   312 	TEntry entry;
   313 	TUint testSize;
   314 	TUint size;
   315 	TUint testPos;
   316 	TInt r;
   317 
   318 	TPtr8 bufPtr = gBuf->Des();
   319 	bufPtr.SetLength(bufPtr.MaxLength());
   320 
   321 	const TFileName fname = KFile2GBMinusOne();
   322 	testSize = K2GbMinusOne;
   323 
   324 	test.Next(_L("2GBMinusOne File: Open"));
   325 
   326 	r = f.Open(TheFs, fname, EFileRead | EFileWrite);
   327 	test(r==KErrNone);
   328 
   329 	
   330 	test.Next(_L("2GBMinusOne File: Attempt to extend"));
   331 
   332 	r=f.Size((TInt&) size);
   333 	test(r==KErrNone);
   334 	test(size == testSize);
   335 	
   336 	r = TheFs.Entry(fname, entry);
   337 	test(r==KErrNone);
   338 	test ((TUint) entry.iSize == testSize);
   339 
   340 	// seek to end
   341 	testPos = 0;
   342 	r = f.Seek(ESeekEnd, (TInt&) testPos);
   343 	test(r==KErrNone);
   344 
   345 	bufPtr.SetLength(1);
   346 	r = f.Write(bufPtr);
   347 	test(r==KErrTooBig);
   348 
   349 	f.Close();
   350 	}
   351 
   352 //----------------------------------------------------------------------------------------------
   353 //! @SYMTestCaseID      PBASE-T_BIGFILE-0006
   354 //! @SYMTestType        CIT
   355 //! @SYMTestCaseDesc    Check that deleting a large file frees cluster properly
   356 //! @SYMTestActions     Delete the passed file name, call RFs::CheckDisk
   357 //!						On windows, we could run chkdsk utility 
   358 //! @SYMTestExpectedResults RFs::CheckDisk returns success
   359 //! @SYMTestPriority    High
   360 //! @SYMTestStatus      Implemented
   361 //----------------------------------------------------------------------------------------------
   362 void DeleteLargeFile(const TDesC& aFileName)
   363 	{
   364 	test.Next(_L("Delete large file"));
   365 	test.Printf(_L("Deleting %S\n"), &aFileName);
   366 
   367 	TInt r = TheFs.Delete(aFileName);
   368 	test(r==KErrNone);
   369 
   370 	CheckDisk();
   371 	}
   372 
   373 
   374 //----------------------------------------------------------------------------------------------
   375 //! @SYMTestCaseID      PBASE-T_BIGFILE-0007
   376 //! @SYMTestType        CIT
   377 //! @SYMTestCaseDesc    Check that we can get a valid directory listing of a directory 
   378 //!						containing large files using RDir and then CDir
   379 //! @SYMTestActions     Open the directory using RDir and examine the results
   380 //!						On windows, we could run chkdsk utility 
   381 //! @SYMTestExpectedResults The expected number of files should exist with the correct sizes
   382 //! @SYMTestPriority    High
   383 //! @SYMTestStatus      Implemented
   384 //----------------------------------------------------------------------------------------------
   385 void ReadDirectory()
   386 	{
   387 	test.Next(_L("Read a directory containing large files using RDir"));
   388 
   389 	RDir dir;
   390 	TInt r = dir.Open(TheFs, _L("*.*"), KEntryAttNormal);
   391 	test (r == KErrNone);
   392 	
   393 	TEntryArray entryArray;
   394 	r = dir.Read(entryArray);
   395 	test (r == KErrEof);
   396 
   397 	test(entryArray.Count() == gFilesInDirectory);
   398 
   399 	TInt n;
   400 	for (n=0; n<entryArray.Count(); n++)
   401 		{
   402 		const TEntry& entry = entryArray[n];
   403 		if (entry.iName.MatchF(KFile2GBMinusOne()) == 0)
   404 			{
   405 			test((TUint) entry.iSize == K2GbMinusOne);
   406 			}
   407 		else if (entry.iName.MatchF(KFile2GB()) == 0)
   408 			{
   409 			test((TUint) entry.iSize == K2Gb);
   410 			}
   411 		else if (entry.iName.MatchF(KFile3GB()) == 0)
   412 			{
   413 			test((TUint) entry.iSize == K3Gb);
   414 			}
   415 		else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
   416 			{
   417 			test((TUint) entry.iSize == K4GbMinusOne);
   418 			}
   419 		else
   420 			test(EFalse);
   421 		}
   422 
   423 	dir.Close();
   424 
   425 	test.Next(_L("Read a directory containing large files using CDir & sort by size"));
   426 	CDir* dirList;
   427 	r=TheFs.GetDir(_L("*.*"), KEntryAttMaskSupported, ESortBySize, dirList);
   428 	test(r==KErrNone);
   429 	test(dirList->Count() == gFilesInDirectory);
   430 	for (n=0; n<dirList->Count(); n++)
   431 		{
   432 		TEntry entry;
   433 		entry=(*dirList)[n];
   434 		// test.Printf(_L("#%d: %08X %d %S"), n, entry.iSize, entry.iSize, &entry.iName);
   435 		if (entry.iName.MatchF(KFile2GBMinusOne()) == 0)
   436 			{
   437 			test((TUint) entry.iSize == K2GbMinusOne);
   438 			test(n == 0);	// test entry has been sorted correctly (i.e. according to size)
   439 			}
   440 		else if (entry.iName.MatchF(KFile2GB()) == 0)
   441 			{
   442 			test((TUint) entry.iSize == K2Gb);
   443 			test(n == 1);
   444 			}
   445 		else if (entry.iName.MatchF(KFile3GB()) == 0)
   446 			{
   447 			test((TUint) entry.iSize == K3Gb);
   448 			test(n == 2);
   449 			}
   450 		else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
   451 			{
   452 			test((TUint) entry.iSize == K4GbMinusOne);
   453 			test(n == 3);
   454 			}
   455 		else
   456 			test(EFalse);
   457 		}
   458 
   459 	delete dirList;
   460 
   461 	
   462 	}
   463 
   464 //----------------------------------------------------------------------------------------------
   465 //! @SYMTestCaseID      PBASE-T_BIGFILE-0008
   466 //! @SYMTestType        CIT
   467 //! @SYMTestCaseDesc    Check that we can a move a directory containing large files 
   468 //!						Using CFileMan::Move()	
   469 //! @SYMTestActions     Use CFileMan::Move() to move files from one directory to another
   470 //! @SYMTestExpectedResults The files should be moved correctly
   471 //! @SYMTestPriority    High
   472 //! @SYMTestStatus      Implemented
   473 //----------------------------------------------------------------------------------------------
   474 void MoveDirectory()
   475 	{
   476 	test.Next(_L("Move a directory containing large files"));
   477 
   478 	CFileMan* fileMan = CFileMan::NewL(TheFs);
   479 	test(fileMan != NULL);
   480 	
   481 	TPath filePathOld = gSessionPath;
   482 	filePathOld+= _L("*.*");
   483 	TPath filePathNew =	_L("?:\\TEST\\");
   484 	TChar driveLetter;
   485 	TInt r=TheFs.DriveToChar(gDrive,driveLetter);
   486 	test(r==KErrNone);
   487 	filePathNew[0] = (TText) driveLetter;
   488 
   489 	// move to new directory
   490 	r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
   491 	test(r == KErrNone);
   492 
   493 	// then move back again
   494 	r = fileMan->Move(filePathNew, filePathOld);
   495 	test(r == KErrNone);
   496 
   497 	delete fileMan;
   498 	}
   499 
   500 
   501 //----------------------------------------------------------------------------------------------
   502 //! @SYMTestCaseID      PBASE-T_BIGFILE-0009
   503 //! @SYMTestType        CIT
   504 //! @SYMTestCaseDesc    Check that we can copy a directory containing large file(s)
   505 //!						Using CFileMan::Copy()	
   506 //! @SYMTestActions     Use CFileMan::Copy() to copy files from one directory to another
   507 //! @SYMTestExpectedResults The files should be copied correctly
   508 //! @SYMTestPriority    High
   509 //! @SYMTestStatus      Implemented
   510 //----------------------------------------------------------------------------------------------
   511 void CopyDirectory()
   512 	{
   513 	test.Next(_L("Copy a directory containing large files"));
   514 	CFileMan* fileMan = CFileMan::NewL(TheFs);
   515 	test(fileMan != NULL);
   516 	
   517 	CFileManObserver* observer = new CFileManObserver(fileMan);
   518 	test(observer != NULL);
   519 
   520 	TPath filePathOld = gSessionPath;
   521 	filePathOld+= _L("*.*");
   522 	TPath filePathNew =	_L("?:\\TEST\\");
   523 	TChar driveLetter;
   524 	TInt r = TheFs.DriveToChar(gDrive,driveLetter);
   525 	test(r == KErrNone);
   526 	filePathNew[0] = (TText) driveLetter;
   527 
   528 	// create some small files in the source directory 
   529 	// so that there is a combination of small files and one large files
   530 	RFile file;
   531 	_LIT(KFileSmall1, "FileSmallOne.txt");
   532 	_LIT(KFileSmall2, "FileSmallTwo.txt");
   533 	_LIT(KFileSmall3, "FileSmallThree.txt");
   534 	r = file.Create(TheFs, KFileSmall1(), EFileWrite | EFileShareAny);
   535 	test(r == KErrNone);
   536 	r = file.Write(_L8("1"));
   537 	test(r == KErrNone);
   538 	file.Close();
   539 
   540 	r = file.Create(TheFs, KFileSmall2(), EFileWrite | EFileShareAny);
   541 	test(r == KErrNone);
   542 	r = file.Write(_L8("12"));
   543 	test(r == KErrNone);
   544 	file.Close();
   545 
   546 	r = file.Create(TheFs, KFileSmall3(), EFileWrite | EFileShareAny);
   547 	test(r == KErrNone);
   548 	r = file.Write(_L8("123"));
   549 	test(r == KErrNone);
   550 	file.Close();
   551 
   552 	// copy to new directory
   553 	r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
   554 	test(r == KErrNone || r == KErrTooBig);
   555 
   556 
   557 	// check SMALL files have been copied
   558 	RDir dir;
   559 	r = dir.Open(TheFs, filePathNew, KEntryAttNormal);
   560 	test (r == KErrNone);
   561 	TEntryArray entryArray;
   562 	r = dir.Read(entryArray);
   563 	test (r == KErrEof);
   564 	test(entryArray.Count() == 3);
   565 	dir.Close();
   566 	
   567 	// then delete the new directory
   568 	r = fileMan->Delete(filePathNew);
   569 	test(r == KErrNone);
   570 
   571 	
   572 	// attempt to copy to new directory again - this time with an observer
   573 	fileMan->SetObserver(observer);
   574 	r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
   575 	test(r == KErrNone || r == KErrTooBig);
   576 	
   577 	// test that 3 small files were copied and 1 or 2 large files failed to copy
   578 	// (For 8 GB disk, the 4GB file is missing)
   579 	test(observer->iNotifyEndedSuccesses == 3);
   580 	test(observer->iNotifyEndedFailures == 1 || observer->iNotifyEndedFailures == 2);
   581 
   582 	// check SMALL files have been copied
   583 	r = dir.Open(TheFs, filePathNew, KEntryAttNormal);
   584 	test (r == KErrNone);
   585 	r = dir.Read(entryArray);
   586 	test (r == KErrEof);
   587 	test(entryArray.Count() == 3);
   588 	dir.Close();
   589 	
   590 	// then delete the new directory
   591 	r = fileMan->Delete(filePathNew);
   592 	test(r == KErrNone);
   593 
   594 	delete observer;
   595 	delete fileMan;
   596 	}
   597 
   598 
   599 //----------------------------------------------------------------------------------------------
   600 //! @SYMTestCaseID      PBASE-T_BIGFILE-000A
   601 //! @SYMTestType        CIT
   602 //! @SYMTestCaseDesc    Check that CDirScan works correctly with a directory containing large file(s)
   603 //! @SYMTestActions     Use CFileMan::Copy() to copy files from one directory to another
   604 //! @SYMTestExpectedResults The files should be copied correctly
   605 //! @SYMTestPriority    High
   606 //! @SYMTestStatus      Implemented
   607 //----------------------------------------------------------------------------------------------
   608 TInt ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError)
   609 	{
   610 	TInt r;
   611 	TFileName dirName;
   612 
   613 	CDirScan* scanner = NULL;
   614 	TRAP(r, scanner = CDirScan::NewL(TheFs));
   615 	test(r == KErrNone && scanner);
   616 
   617 	TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection));
   618 	test(r == KErrNone);
   619 	
   620 	CDir *entryList=NULL;
   621 	TInt filesFound = 0;
   622 	for (;;)
   623 		{
   624 		TRAP(r, scanner->NextL(entryList));
   625 		test(r == aError);
   626 		if (entryList==NULL)
   627 			break;
   628 		TInt count = entryList->Count();
   629 		while (count--)
   630 			{
   631 			TEntry data=(*entryList)[count];
   632 			TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
   633 			dirName = path;
   634 			dirName.Append(data.iName);
   635 			test.Printf(_L("    %S\n"),&dirName);
   636 			filesFound++;
   637 			}
   638 
   639 		delete entryList;
   640 		entryList=NULL;
   641 		}
   642 	delete scanner;
   643 
   644 	return filesFound;
   645 	}
   646 
   647 
   648 
   649 GLDEF_C void CallTestsL()
   650 //
   651 // Do tests relative to the session path
   652 //
   653 	{
   654 	
   655 #if defined(__WINS__)
   656 	if (gSessionPath[0]=='C')
   657 		gNTFS=ETrue;
   658 	else
   659 		gNTFS=EFalse;
   660 #endif
   661 
   662 	// don't test on NTFS
   663 	if (gNTFS)
   664 		{
   665 		test.Printf(_L("Skipping test: Drive is NTFS\n"));
   666 		return;
   667 		}
   668 
   669 	TInt r;
   670 
   671 	r = TheFs.CharToDrive(gDriveToTest, gDrive);
   672 	test(r==KErrNone);
   673 
   674 #ifdef __MOUNT_RAW_EXT__
   675 	r=TheFs.FileSystemName(gOldFsName, gDrive);
   676 	test(r==KErrNone);
   677 
   678 	if (gOldFsName.CompareF(KFATName) != 0)
   679 		{
   680 		test.Printf(_L("Skipping test: Not a FAT drive\n"));
   681 		return;
   682 		}
   683 
   684     r = TheFs.AddExtension(KExtName);
   685     test(r==KErrNone || r==KErrAlreadyExists);
   686     r = TheFs.MountExtension(KExtName, gDrive);
   687     test(r==KErrNone || r==KErrAlreadyExists);
   688 #endif
   689 
   690 	TVolumeInfo vi;
   691 	test((r = TheFs.Volume(vi, gDrive)) == KErrNone);
   692 	test.Printf(_L("vi.iSize = %ld\n"), vi.iSize);
   693 	
   694 	// don't test if media sise is less than 7GB
   695 	if (vi.iSize < TInt64(K1Gb) * TInt64(7))
   696 		{
   697 		test.Printf(_L("Skipping test: Drive is not big enough\n"));
   698 		}
   699 	if (!FilePresent(KFile2GB()))
   700 		{
   701 		test.Printf(_L("Skipping test: Test files not present on drive\n"));
   702 		}
   703 	else
   704 		{
   705 		gBuf = HBufC8::NewL(KBufSize);
   706 		if (gBuf == NULL)
   707 			User::Leave(KErrNoMemory);
   708 		gBufPtr = gBuf->Des();
   709 
   710 
   711 		TInt r;
   712 
   713 		// Test that RFs::CheckDisk() succeeds with large files present
   714 		CheckDisk();
   715 		
   716 		test.Next(_L("Scan Drive"));
   717 		r = TheFs.ScanDrive(gSessionPath);
   718 		test (r == KErrNone);
   719 
   720 		// NB the 4GB file will not be present unless the disk is > 8GB (because it doesn't fit)
   721 		if (!FilePresent(KFile4GBMinusOne()))
   722 			gFilesInDirectory--;
   723 
   724 		// test CDirScan
   725 		// the number of files & directories found should be 5 or 4
   726 		TInt filesFound = ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone);
   727 		test (filesFound == gFilesInDirectory+1);
   728 		filesFound = ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone);
   729 		test (filesFound == gFilesInDirectory+1);
   730 
   731 		OpenAndRead2GBMinusOne();
   732 		Open2GB();
   733 		Open3GB();
   734 
   735 		// the 4GB file will not be present unless the disk is > 8GB
   736 		if (FilePresent(KFile4GBMinusOne()))
   737 			Open4GB();
   738 
   739 		Extend2GBMinusOne();
   740 
   741 		ReadDirectory();
   742 
   743 		MoveDirectory();
   744 
   745 		
   746 		// delete the 2 smaller files to make some space
   747 		DeleteLargeFile(KFile2GB());
   748 		DeleteLargeFile(KFile2GBMinusOne());
   749 		
   750 		CopyDirectory();
   751 		
   752 		// delete the 3GB file and check the disk
   753 		DeleteLargeFile(KFile3GB());
   754 
   755 		if (FilePresent(KFile4GBMinusOne()))
   756 			DeleteLargeFile(KFile4GBMinusOne());
   757 
   758 		// Finally check that we can format the drive...
   759 		Format (gDrive);
   760 		}
   761 
   762 #ifdef __MOUNT_RAW_EXT__
   763 	r = TheFs.DismountExtension(KExtName, gDrive);
   764 	test(r==KErrNone);
   765 
   766 	r = TheFs.RemoveExtension(KExtName);
   767 	test(r==KErrNone);
   768 
   769 #endif
   770 
   771 	delete gBuf; gBuf = NULL;
   772 	}
   773