1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/kernelhwsrv/kerneltest/f32test/server/t_bigfile.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,773 @@
1.4 +// Copyright (c) 2007-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 +// N.B. Before running this test on WINS, ensure that the estart.txt file contains
1.18 +// nothing but EFAT32 i.e. no EFAT - otherwise the FAT16 file system will be used
1.19 +// On target ensure that the FAT32 filesystem is in the ROM instead of the FAT16 file system
1.20 +// This test expects the following files to be present before running the test:
1.21 +// size name
1.22 +// 2147483647 \F32-TST\File2GBMinusOne.txt
1.23 +// 2147483648 \F32-TST\File2GB.txt
1.24 +// 3221225472 \F32-TST\File3GB.txt
1.25 +// 4294967295 \F32-TST\File4GBMinusOne.txt // may be absent on an 8GB disk
1.26 +// For verification purposes, Every 4 bytes of each file contains the current position, e.g.
1.27 +// 0000: 00 00 00 00
1.28 +// 0004: 04 00 00 00
1.29 +// 0008: 08 00 00 00
1.30 +// .. etc
1.31 +// These files can be created using the BigFileWriter tool in f32test/tool
1.32 +// If this test is run on the emulator and the __MOUNT_RAW_EXT__ macro is defined (see below) then
1.33 +// the T_RAWEXT file system extension will be loaded; this extension allows reading and writing to
1.34 +// a windows disk in "raw" format, thus allowing direct access to a windows disk. see f32test/ext/t_rawext
1.35 +// for more details.
1.36 +//
1.37 +//
1.38 +
1.39 +
1.40 +#include <f32file.h>
1.41 +#include <e32test.h>
1.42 +#include <e32svr.h>
1.43 +#include "t_server.h"
1.44 +
1.45 +
1.46 +GLDEF_D RTest test(_L("T_BIGFILE"));
1.47 +
1.48 +#ifdef __WINS__
1.49 +// enable this macro to mount the RAWEXT.FXT file system extension to test on a particular windows drive
1.50 +#define __MOUNT_RAW_EXT__
1.51 +#endif
1.52 +
1.53 +#ifdef __MOUNT_RAW_EXT__
1.54 +_LIT(KExtName,"RAWEXT");
1.55 +
1.56 +_LIT(KFAT32FName,"EFAT32");
1.57 +_LIT(KFATName,"FAT");
1.58 +
1.59 +TFullName gOldFsName;
1.60 +#endif
1.61 +
1.62 +TInt gDrive;
1.63 +TBool gNTFS=EFalse;
1.64 +
1.65 +const TUint K1Kb = 1 << 10;
1.66 +//const TUint K1Mb = 1 << 20;
1.67 +const TUint K1Gb = 1 << 30;
1.68 +const TUint K2Gb = 0x80000000;
1.69 +const TUint K2GbMinusOne = 0x7FFFFFFF;
1.70 +const TUint K3Gb = 0xC0000000;
1.71 +const TUint K4GbMinusOne = 0xFFFFFFFF;
1.72 +const TUint KPosMask = 0xFFFFFFFC;
1.73 +
1.74 +//const TUint KBigFileSizeSigned = KMaxTInt32; // 2Gb -1
1.75 +//const TUint KBigFileSizeUnsigned = KMaxTUint32; // 4Gb -1
1.76 +
1.77 +const TInt KBufSize = (256 * K1Kb);
1.78 +HBufC8* gBuf = NULL;
1.79 +TPtr8 gBufPtr(NULL, 0, 0);
1.80 +
1.81 +
1.82 +_LIT(KFile2GBMinusOne, "File2GBMinusOne.txt");
1.83 +_LIT(KFile2GB, "File2GB.txt");
1.84 +_LIT(KFile3GB, "File3GB.txt");
1.85 +_LIT(KFile4GBMinusOne, "File4GBMinusOne.txt");
1.86 +TInt gFilesInDirectory = 4;
1.87 +
1.88 +
1.89 +// return ETrue if the specifiled file is present
1.90 +TBool FilePresent(const TDesC& aFileName)
1.91 + {
1.92 + TEntry entry;
1.93 + TInt r = TheFs.Entry(aFileName, entry);
1.94 + return (r == KErrNone ? (TBool)ETrue : (TBool)EFalse);
1.95 + }
1.96 +
1.97 +class CFileManObserver : public CBase, public MFileManObserver
1.98 + {
1.99 +public:
1.100 + CFileManObserver(CFileMan* aFileMan);
1.101 +
1.102 + TControl NotifyFileManStarted();
1.103 + TControl NotifyFileManOperation();
1.104 + TControl NotifyFileManEnded();
1.105 +private:
1.106 + CFileMan* iFileMan;
1.107 +public:
1.108 + TInt iNotifyEndedSuccesses;
1.109 + TInt iNotifyEndedFailures;
1.110 + };
1.111 +
1.112 +CFileManObserver::CFileManObserver(CFileMan* aFileMan)
1.113 + {
1.114 + __DECLARE_NAME(_S("CFileManObserver"));
1.115 + iFileMan=aFileMan;
1.116 + }
1.117 +
1.118 +MFileManObserver::TControl CFileManObserver::NotifyFileManStarted()
1.119 + {
1.120 + TInt lastError = iFileMan->GetLastError();
1.121 + TFileName fileName = iFileMan->CurrentEntry().iName;
1.122 + test.Printf(_L("NotifyFileManStarted(): Error %d File %S\n"),lastError, &fileName);
1.123 + return(MFileManObserver::EContinue);
1.124 + }
1.125 +
1.126 +MFileManObserver::TControl CFileManObserver::NotifyFileManOperation()
1.127 + {
1.128 + TInt lastError = iFileMan->GetLastError();
1.129 + TFileName fileName = iFileMan->CurrentEntry().iName;
1.130 + test.Printf(_L("NotifyFileManOperation(): Error %d File %S\n"),lastError, &fileName);
1.131 + return(MFileManObserver::EContinue);
1.132 + }
1.133 +
1.134 +MFileManObserver::TControl CFileManObserver::NotifyFileManEnded()
1.135 + {
1.136 + TInt lastError = iFileMan->GetLastError();
1.137 + TFileName fileName = iFileMan->CurrentEntry().iName;
1.138 + test.Printf(_L("NotifyFileManEnded(): Error %d File %S\n"),lastError, &fileName);
1.139 + if (lastError == KErrNone)
1.140 + iNotifyEndedSuccesses++;
1.141 + else
1.142 + iNotifyEndedFailures++;
1.143 + return(MFileManObserver::EContinue);
1.144 + }
1.145 +
1.146 +
1.147 +
1.148 +//----------------------------------------------------------------------------------------------
1.149 +//! @SYMTestCaseID PBASE-T_BIGFILE-0001
1.150 +//! @SYMTestType CIT
1.151 +//! @SYMTestCaseDesc Test that 2GB-1 file can be opened and read
1.152 +//! @SYMTestActions Open the file, seek to end-1K and read some data. Verify the results
1.153 +//! @SYMTestExpectedResults Should succeed
1.154 +//! @SYMTestPriority High
1.155 +//! @SYMTestStatus Implemented
1.156 +//----------------------------------------------------------------------------------------------
1.157 +void OpenAndRead2GBMinusOne()
1.158 + {
1.159 + RFile f;
1.160 + TEntry entry;
1.161 + TUint testSize;
1.162 + TUint size;
1.163 + TUint testPos;
1.164 + TInt r;
1.165 +
1.166 + TPtr8 bufPtr = gBuf->Des();
1.167 + bufPtr.SetLength(bufPtr.MaxLength());
1.168 +
1.169 + const TFileName fname = KFile2GBMinusOne();
1.170 +
1.171 + test.Next(_L("2GBMinusOne File: Open"));
1.172 +
1.173 + r = f.Open(TheFs, fname, EFileRead);
1.174 + test(r==KErrNone);
1.175 +
1.176 + testSize = K2GbMinusOne;
1.177 +
1.178 + test.Next(_L("2GBMinusOne File: Read"));
1.179 +
1.180 + r=f.Size((TInt&) size);
1.181 + test(r==KErrNone);
1.182 + test(size == testSize);
1.183 +
1.184 + r = TheFs.Entry(fname, entry);
1.185 + test(r==KErrNone);
1.186 + test ((TUint) entry.iSize == testSize);
1.187 +
1.188 + // seek to just below 2GB
1.189 + testPos = (K2GbMinusOne - K1Kb) & KPosMask;
1.190 + r = f.Seek(ESeekStart, (TInt&) testPos);
1.191 + test(r==KErrNone);
1.192 +
1.193 + r = f.Read(bufPtr);
1.194 + test(r==KErrNone);
1.195 +
1.196 + TUint posRead = * ((TUint*) &bufPtr[0]);
1.197 + test.Printf(_L("position read %08X, expected %08X\n"), posRead, testPos);
1.198 + test(posRead == testPos);
1.199 +
1.200 + f.Close();
1.201 + }
1.202 +
1.203 +//----------------------------------------------------------------------------------------------
1.204 +//! @SYMTestCaseID PBASE-T_BIGFILE-0002
1.205 +//! @SYMTestType CIT
1.206 +//! @SYMTestCaseDesc Test that attempting to open a 2GB file fails
1.207 +//! @SYMTestActions Open the file
1.208 +//! @SYMTestExpectedResults KErrToBig
1.209 +//! @SYMTestPriority High
1.210 +//! @SYMTestStatus Implemented
1.211 +//----------------------------------------------------------------------------------------------
1.212 +void Open2GB()
1.213 + {
1.214 + RFile f;
1.215 + TEntry entry;
1.216 + TUint testSize;
1.217 + TInt r;
1.218 +
1.219 + TPtr8 bufPtr = gBuf->Des();
1.220 + bufPtr.SetLength(bufPtr.MaxLength());
1.221 +
1.222 + const TFileName fname = KFile2GB();
1.223 + testSize = K2Gb;
1.224 +
1.225 + test.Next(_L("2GB File: Test the size with RFs::Entry"));
1.226 + r = TheFs.Entry(fname, entry);
1.227 + test(r==KErrNone);
1.228 + test ((TUint) entry.iSize == testSize);
1.229 +
1.230 + test.Next(_L("2GB File: Attempt to open (should fail with KErrToBig)"));
1.231 +
1.232 + r = f.Open(TheFs, fname, EFileRead);
1.233 + test(r==KErrTooBig);
1.234 + }
1.235 +
1.236 +//----------------------------------------------------------------------------------------------
1.237 +//! @SYMTestCaseID PBASE-T_BIGFILE-0003
1.238 +//! @SYMTestType CIT
1.239 +//! @SYMTestCaseDesc Test that attempting to open a 2GB file fails
1.240 +//! @SYMTestActions Open the file
1.241 +//! @SYMTestExpectedResults KErrToBig
1.242 +//! @SYMTestPriority High
1.243 +//! @SYMTestStatus Implemented
1.244 +//----------------------------------------------------------------------------------------------
1.245 +void Open3GB()
1.246 + {
1.247 + RFile f;
1.248 + TEntry entry;
1.249 + TUint testSize;
1.250 + TInt r;
1.251 +
1.252 + TPtr8 bufPtr = gBuf->Des();
1.253 + bufPtr.SetLength(bufPtr.MaxLength());
1.254 +
1.255 + const TFileName fname = KFile3GB();
1.256 + testSize = K3Gb;
1.257 +
1.258 + test.Next(_L("3GB File: Test the size with RFs::Entry"));
1.259 + r = TheFs.Entry(fname, entry);
1.260 + test(r==KErrNone);
1.261 + test ((TUint) entry.iSize == testSize);
1.262 +
1.263 + test.Next(_L("3GB File: Attempt to open (should fail with KErrToBig)"));
1.264 +
1.265 + r = f.Open(TheFs, fname, EFileRead);
1.266 + test(r==KErrTooBig);
1.267 + }
1.268 +
1.269 +//----------------------------------------------------------------------------------------------
1.270 +//! @SYMTestCaseID PBASE-T_BIGFILE-0004
1.271 +//! @SYMTestType CIT
1.272 +//! @SYMTestCaseDesc Test that attempting to open a 4GB file fails
1.273 +//! @SYMTestActions Open the file
1.274 +//! @SYMTestExpectedResults KErrToBig
1.275 +//! @SYMTestPriority High
1.276 +//! @SYMTestStatus Implemented
1.277 +//----------------------------------------------------------------------------------------------
1.278 +void Open4GB()
1.279 + {
1.280 + RFile f;
1.281 + TEntry entry;
1.282 + TUint testSize;
1.283 + TInt r;
1.284 +
1.285 + TPtr8 bufPtr = gBuf->Des();
1.286 + bufPtr.SetLength(bufPtr.MaxLength());
1.287 +
1.288 + const TFileName fname = KFile4GBMinusOne();
1.289 + testSize = K4GbMinusOne;
1.290 +
1.291 + test.Next(_L("4GB File: Test the size with RFs::Entry"));
1.292 + r = TheFs.Entry(fname, entry);
1.293 +
1.294 + test(r==KErrNone);
1.295 + test ((TUint) entry.iSize == testSize);
1.296 +
1.297 + test.Next(_L("4GB File: Attempt to open (should fail with KErrToBig)"));
1.298 +
1.299 + r = f.Open(TheFs, fname, EFileRead);
1.300 + test(r==KErrTooBig);
1.301 + }
1.302 +
1.303 +//----------------------------------------------------------------------------------------------
1.304 +//! @SYMTestCaseID PBASE-T_BIGFILE-0005
1.305 +//! @SYMTestType CIT
1.306 +//! @SYMTestCaseDesc Attempt to append to the end of a 2GB-1 file
1.307 +//! @SYMTestActions Open the file, seek to end and write one byte
1.308 +//! @SYMTestExpectedResults RFile::Write(0 returns KErrToBig
1.309 +//! @SYMTestPriority High
1.310 +//! @SYMTestStatus Implemented
1.311 +//----------------------------------------------------------------------------------------------
1.312 +void Extend2GBMinusOne()
1.313 + {
1.314 + RFile f;
1.315 + TEntry entry;
1.316 + TUint testSize;
1.317 + TUint size;
1.318 + TUint testPos;
1.319 + TInt r;
1.320 +
1.321 + TPtr8 bufPtr = gBuf->Des();
1.322 + bufPtr.SetLength(bufPtr.MaxLength());
1.323 +
1.324 + const TFileName fname = KFile2GBMinusOne();
1.325 + testSize = K2GbMinusOne;
1.326 +
1.327 + test.Next(_L("2GBMinusOne File: Open"));
1.328 +
1.329 + r = f.Open(TheFs, fname, EFileRead | EFileWrite);
1.330 + test(r==KErrNone);
1.331 +
1.332 +
1.333 + test.Next(_L("2GBMinusOne File: Attempt to extend"));
1.334 +
1.335 + r=f.Size((TInt&) size);
1.336 + test(r==KErrNone);
1.337 + test(size == testSize);
1.338 +
1.339 + r = TheFs.Entry(fname, entry);
1.340 + test(r==KErrNone);
1.341 + test ((TUint) entry.iSize == testSize);
1.342 +
1.343 + // seek to end
1.344 + testPos = 0;
1.345 + r = f.Seek(ESeekEnd, (TInt&) testPos);
1.346 + test(r==KErrNone);
1.347 +
1.348 + bufPtr.SetLength(1);
1.349 + r = f.Write(bufPtr);
1.350 + test(r==KErrTooBig);
1.351 +
1.352 + f.Close();
1.353 + }
1.354 +
1.355 +//----------------------------------------------------------------------------------------------
1.356 +//! @SYMTestCaseID PBASE-T_BIGFILE-0006
1.357 +//! @SYMTestType CIT
1.358 +//! @SYMTestCaseDesc Check that deleting a large file frees cluster properly
1.359 +//! @SYMTestActions Delete the passed file name, call RFs::CheckDisk
1.360 +//! On windows, we could run chkdsk utility
1.361 +//! @SYMTestExpectedResults RFs::CheckDisk returns success
1.362 +//! @SYMTestPriority High
1.363 +//! @SYMTestStatus Implemented
1.364 +//----------------------------------------------------------------------------------------------
1.365 +void DeleteLargeFile(const TDesC& aFileName)
1.366 + {
1.367 + test.Next(_L("Delete large file"));
1.368 + test.Printf(_L("Deleting %S\n"), &aFileName);
1.369 +
1.370 + TInt r = TheFs.Delete(aFileName);
1.371 + test(r==KErrNone);
1.372 +
1.373 + CheckDisk();
1.374 + }
1.375 +
1.376 +
1.377 +//----------------------------------------------------------------------------------------------
1.378 +//! @SYMTestCaseID PBASE-T_BIGFILE-0007
1.379 +//! @SYMTestType CIT
1.380 +//! @SYMTestCaseDesc Check that we can get a valid directory listing of a directory
1.381 +//! containing large files using RDir and then CDir
1.382 +//! @SYMTestActions Open the directory using RDir and examine the results
1.383 +//! On windows, we could run chkdsk utility
1.384 +//! @SYMTestExpectedResults The expected number of files should exist with the correct sizes
1.385 +//! @SYMTestPriority High
1.386 +//! @SYMTestStatus Implemented
1.387 +//----------------------------------------------------------------------------------------------
1.388 +void ReadDirectory()
1.389 + {
1.390 + test.Next(_L("Read a directory containing large files using RDir"));
1.391 +
1.392 + RDir dir;
1.393 + TInt r = dir.Open(TheFs, _L("*.*"), KEntryAttNormal);
1.394 + test (r == KErrNone);
1.395 +
1.396 + TEntryArray entryArray;
1.397 + r = dir.Read(entryArray);
1.398 + test (r == KErrEof);
1.399 +
1.400 + test(entryArray.Count() == gFilesInDirectory);
1.401 +
1.402 + TInt n;
1.403 + for (n=0; n<entryArray.Count(); n++)
1.404 + {
1.405 + const TEntry& entry = entryArray[n];
1.406 + if (entry.iName.MatchF(KFile2GBMinusOne()) == 0)
1.407 + {
1.408 + test((TUint) entry.iSize == K2GbMinusOne);
1.409 + }
1.410 + else if (entry.iName.MatchF(KFile2GB()) == 0)
1.411 + {
1.412 + test((TUint) entry.iSize == K2Gb);
1.413 + }
1.414 + else if (entry.iName.MatchF(KFile3GB()) == 0)
1.415 + {
1.416 + test((TUint) entry.iSize == K3Gb);
1.417 + }
1.418 + else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
1.419 + {
1.420 + test((TUint) entry.iSize == K4GbMinusOne);
1.421 + }
1.422 + else
1.423 + test(EFalse);
1.424 + }
1.425 +
1.426 + dir.Close();
1.427 +
1.428 + test.Next(_L("Read a directory containing large files using CDir & sort by size"));
1.429 + CDir* dirList;
1.430 + r=TheFs.GetDir(_L("*.*"), KEntryAttMaskSupported, ESortBySize, dirList);
1.431 + test(r==KErrNone);
1.432 + test(dirList->Count() == gFilesInDirectory);
1.433 + for (n=0; n<dirList->Count(); n++)
1.434 + {
1.435 + TEntry entry;
1.436 + entry=(*dirList)[n];
1.437 + // test.Printf(_L("#%d: %08X %d %S"), n, entry.iSize, entry.iSize, &entry.iName);
1.438 + if (entry.iName.MatchF(KFile2GBMinusOne()) == 0)
1.439 + {
1.440 + test((TUint) entry.iSize == K2GbMinusOne);
1.441 + test(n == 0); // test entry has been sorted correctly (i.e. according to size)
1.442 + }
1.443 + else if (entry.iName.MatchF(KFile2GB()) == 0)
1.444 + {
1.445 + test((TUint) entry.iSize == K2Gb);
1.446 + test(n == 1);
1.447 + }
1.448 + else if (entry.iName.MatchF(KFile3GB()) == 0)
1.449 + {
1.450 + test((TUint) entry.iSize == K3Gb);
1.451 + test(n == 2);
1.452 + }
1.453 + else if (entry.iName.MatchF(KFile4GBMinusOne()) == 0)
1.454 + {
1.455 + test((TUint) entry.iSize == K4GbMinusOne);
1.456 + test(n == 3);
1.457 + }
1.458 + else
1.459 + test(EFalse);
1.460 + }
1.461 +
1.462 + delete dirList;
1.463 +
1.464 +
1.465 + }
1.466 +
1.467 +//----------------------------------------------------------------------------------------------
1.468 +//! @SYMTestCaseID PBASE-T_BIGFILE-0008
1.469 +//! @SYMTestType CIT
1.470 +//! @SYMTestCaseDesc Check that we can a move a directory containing large files
1.471 +//! Using CFileMan::Move()
1.472 +//! @SYMTestActions Use CFileMan::Move() to move files from one directory to another
1.473 +//! @SYMTestExpectedResults The files should be moved correctly
1.474 +//! @SYMTestPriority High
1.475 +//! @SYMTestStatus Implemented
1.476 +//----------------------------------------------------------------------------------------------
1.477 +void MoveDirectory()
1.478 + {
1.479 + test.Next(_L("Move a directory containing large files"));
1.480 +
1.481 + CFileMan* fileMan = CFileMan::NewL(TheFs);
1.482 + test(fileMan != NULL);
1.483 +
1.484 + TPath filePathOld = gSessionPath;
1.485 + filePathOld+= _L("*.*");
1.486 + TPath filePathNew = _L("?:\\TEST\\");
1.487 + TChar driveLetter;
1.488 + TInt r=TheFs.DriveToChar(gDrive,driveLetter);
1.489 + test(r==KErrNone);
1.490 + filePathNew[0] = (TText) driveLetter;
1.491 +
1.492 + // move to new directory
1.493 + r = fileMan->Move(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
1.494 + test(r == KErrNone);
1.495 +
1.496 + // then move back again
1.497 + r = fileMan->Move(filePathNew, filePathOld);
1.498 + test(r == KErrNone);
1.499 +
1.500 + delete fileMan;
1.501 + }
1.502 +
1.503 +
1.504 +//----------------------------------------------------------------------------------------------
1.505 +//! @SYMTestCaseID PBASE-T_BIGFILE-0009
1.506 +//! @SYMTestType CIT
1.507 +//! @SYMTestCaseDesc Check that we can copy a directory containing large file(s)
1.508 +//! Using CFileMan::Copy()
1.509 +//! @SYMTestActions Use CFileMan::Copy() to copy files from one directory to another
1.510 +//! @SYMTestExpectedResults The files should be copied correctly
1.511 +//! @SYMTestPriority High
1.512 +//! @SYMTestStatus Implemented
1.513 +//----------------------------------------------------------------------------------------------
1.514 +void CopyDirectory()
1.515 + {
1.516 + test.Next(_L("Copy a directory containing large files"));
1.517 + CFileMan* fileMan = CFileMan::NewL(TheFs);
1.518 + test(fileMan != NULL);
1.519 +
1.520 + CFileManObserver* observer = new CFileManObserver(fileMan);
1.521 + test(observer != NULL);
1.522 +
1.523 + TPath filePathOld = gSessionPath;
1.524 + filePathOld+= _L("*.*");
1.525 + TPath filePathNew = _L("?:\\TEST\\");
1.526 + TChar driveLetter;
1.527 + TInt r = TheFs.DriveToChar(gDrive,driveLetter);
1.528 + test(r == KErrNone);
1.529 + filePathNew[0] = (TText) driveLetter;
1.530 +
1.531 + // create some small files in the source directory
1.532 + // so that there is a combination of small files and one large files
1.533 + RFile file;
1.534 + _LIT(KFileSmall1, "FileSmallOne.txt");
1.535 + _LIT(KFileSmall2, "FileSmallTwo.txt");
1.536 + _LIT(KFileSmall3, "FileSmallThree.txt");
1.537 + r = file.Create(TheFs, KFileSmall1(), EFileWrite | EFileShareAny);
1.538 + test(r == KErrNone);
1.539 + r = file.Write(_L8("1"));
1.540 + test(r == KErrNone);
1.541 + file.Close();
1.542 +
1.543 + r = file.Create(TheFs, KFileSmall2(), EFileWrite | EFileShareAny);
1.544 + test(r == KErrNone);
1.545 + r = file.Write(_L8("12"));
1.546 + test(r == KErrNone);
1.547 + file.Close();
1.548 +
1.549 + r = file.Create(TheFs, KFileSmall3(), EFileWrite | EFileShareAny);
1.550 + test(r == KErrNone);
1.551 + r = file.Write(_L8("123"));
1.552 + test(r == KErrNone);
1.553 + file.Close();
1.554 +
1.555 + // copy to new directory
1.556 + r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
1.557 + test(r == KErrNone || r == KErrTooBig);
1.558 +
1.559 +
1.560 + // check SMALL files have been copied
1.561 + RDir dir;
1.562 + r = dir.Open(TheFs, filePathNew, KEntryAttNormal);
1.563 + test (r == KErrNone);
1.564 + TEntryArray entryArray;
1.565 + r = dir.Read(entryArray);
1.566 + test (r == KErrEof);
1.567 + test(entryArray.Count() == 3);
1.568 + dir.Close();
1.569 +
1.570 + // then delete the new directory
1.571 + r = fileMan->Delete(filePathNew);
1.572 + test(r == KErrNone);
1.573 +
1.574 +
1.575 + // attempt to copy to new directory again - this time with an observer
1.576 + fileMan->SetObserver(observer);
1.577 + r = fileMan->Copy(filePathOld, filePathNew, CFileMan::ERecurse | CFileMan::EOverWrite);
1.578 + test(r == KErrNone || r == KErrTooBig);
1.579 +
1.580 + // test that 3 small files were copied and 1 or 2 large files failed to copy
1.581 + // (For 8 GB disk, the 4GB file is missing)
1.582 + test(observer->iNotifyEndedSuccesses == 3);
1.583 + test(observer->iNotifyEndedFailures == 1 || observer->iNotifyEndedFailures == 2);
1.584 +
1.585 + // check SMALL files have been copied
1.586 + r = dir.Open(TheFs, filePathNew, KEntryAttNormal);
1.587 + test (r == KErrNone);
1.588 + r = dir.Read(entryArray);
1.589 + test (r == KErrEof);
1.590 + test(entryArray.Count() == 3);
1.591 + dir.Close();
1.592 +
1.593 + // then delete the new directory
1.594 + r = fileMan->Delete(filePathNew);
1.595 + test(r == KErrNone);
1.596 +
1.597 + delete observer;
1.598 + delete fileMan;
1.599 + }
1.600 +
1.601 +
1.602 +//----------------------------------------------------------------------------------------------
1.603 +//! @SYMTestCaseID PBASE-T_BIGFILE-000A
1.604 +//! @SYMTestType CIT
1.605 +//! @SYMTestCaseDesc Check that CDirScan works correctly with a directory containing large file(s)
1.606 +//! @SYMTestActions Use CFileMan::Copy() to copy files from one directory to another
1.607 +//! @SYMTestExpectedResults The files should be copied correctly
1.608 +//! @SYMTestPriority High
1.609 +//! @SYMTestStatus Implemented
1.610 +//----------------------------------------------------------------------------------------------
1.611 +TInt ScanDir(const TDesC& aName, CDirScan::TScanDirection aDirection, TInt aError)
1.612 + {
1.613 + TInt r;
1.614 + TFileName dirName;
1.615 +
1.616 + CDirScan* scanner = NULL;
1.617 + TRAP(r, scanner = CDirScan::NewL(TheFs));
1.618 + test(r == KErrNone && scanner);
1.619 +
1.620 + TRAP(r, scanner->SetScanDataL(aName,KEntryAttDir,ESortByName|EAscending,aDirection));
1.621 + test(r == KErrNone);
1.622 +
1.623 + CDir *entryList=NULL;
1.624 + TInt filesFound = 0;
1.625 + for (;;)
1.626 + {
1.627 + TRAP(r, scanner->NextL(entryList));
1.628 + test(r == aError);
1.629 + if (entryList==NULL)
1.630 + break;
1.631 + TInt count = entryList->Count();
1.632 + while (count--)
1.633 + {
1.634 + TEntry data=(*entryList)[count];
1.635 + TBuf<KMaxFileName> path=scanner->AbbreviatedPath();
1.636 + dirName = path;
1.637 + dirName.Append(data.iName);
1.638 + test.Printf(_L(" %S\n"),&dirName);
1.639 + filesFound++;
1.640 + }
1.641 +
1.642 + delete entryList;
1.643 + entryList=NULL;
1.644 + }
1.645 + delete scanner;
1.646 +
1.647 + return filesFound;
1.648 + }
1.649 +
1.650 +
1.651 +
1.652 +GLDEF_C void CallTestsL()
1.653 +//
1.654 +// Do tests relative to the session path
1.655 +//
1.656 + {
1.657 +
1.658 +#if defined(__WINS__)
1.659 + if (gSessionPath[0]=='C')
1.660 + gNTFS=ETrue;
1.661 + else
1.662 + gNTFS=EFalse;
1.663 +#endif
1.664 +
1.665 + // don't test on NTFS
1.666 + if (gNTFS)
1.667 + {
1.668 + test.Printf(_L("Skipping test: Drive is NTFS\n"));
1.669 + return;
1.670 + }
1.671 +
1.672 + TInt r;
1.673 +
1.674 + r = TheFs.CharToDrive(gDriveToTest, gDrive);
1.675 + test(r==KErrNone);
1.676 +
1.677 +#ifdef __MOUNT_RAW_EXT__
1.678 + r=TheFs.FileSystemName(gOldFsName, gDrive);
1.679 + test(r==KErrNone);
1.680 +
1.681 + if (gOldFsName.CompareF(KFATName) != 0)
1.682 + {
1.683 + test.Printf(_L("Skipping test: Not a FAT drive\n"));
1.684 + return;
1.685 + }
1.686 +
1.687 + r = TheFs.AddExtension(KExtName);
1.688 + test(r==KErrNone || r==KErrAlreadyExists);
1.689 + r = TheFs.MountExtension(KExtName, gDrive);
1.690 + test(r==KErrNone || r==KErrAlreadyExists);
1.691 +#endif
1.692 +
1.693 + TVolumeInfo vi;
1.694 + test((r = TheFs.Volume(vi, gDrive)) == KErrNone);
1.695 + test.Printf(_L("vi.iSize = %ld\n"), vi.iSize);
1.696 +
1.697 + // don't test if media sise is less than 7GB
1.698 + if (vi.iSize < TInt64(K1Gb) * TInt64(7))
1.699 + {
1.700 + test.Printf(_L("Skipping test: Drive is not big enough\n"));
1.701 + }
1.702 + if (!FilePresent(KFile2GB()))
1.703 + {
1.704 + test.Printf(_L("Skipping test: Test files not present on drive\n"));
1.705 + }
1.706 + else
1.707 + {
1.708 + gBuf = HBufC8::NewL(KBufSize);
1.709 + if (gBuf == NULL)
1.710 + User::Leave(KErrNoMemory);
1.711 + gBufPtr = gBuf->Des();
1.712 +
1.713 +
1.714 + TInt r;
1.715 +
1.716 + // Test that RFs::CheckDisk() succeeds with large files present
1.717 + CheckDisk();
1.718 +
1.719 + test.Next(_L("Scan Drive"));
1.720 + r = TheFs.ScanDrive(gSessionPath);
1.721 + test (r == KErrNone);
1.722 +
1.723 + // NB the 4GB file will not be present unless the disk is > 8GB (because it doesn't fit)
1.724 + if (!FilePresent(KFile4GBMinusOne()))
1.725 + gFilesInDirectory--;
1.726 +
1.727 + // test CDirScan
1.728 + // the number of files & directories found should be 5 or 4
1.729 + TInt filesFound = ScanDir(_L("\\"), CDirScan::EScanUpTree, KErrNone);
1.730 + test (filesFound == gFilesInDirectory+1);
1.731 + filesFound = ScanDir(_L("\\"), CDirScan::EScanDownTree, KErrNone);
1.732 + test (filesFound == gFilesInDirectory+1);
1.733 +
1.734 + OpenAndRead2GBMinusOne();
1.735 + Open2GB();
1.736 + Open3GB();
1.737 +
1.738 + // the 4GB file will not be present unless the disk is > 8GB
1.739 + if (FilePresent(KFile4GBMinusOne()))
1.740 + Open4GB();
1.741 +
1.742 + Extend2GBMinusOne();
1.743 +
1.744 + ReadDirectory();
1.745 +
1.746 + MoveDirectory();
1.747 +
1.748 +
1.749 + // delete the 2 smaller files to make some space
1.750 + DeleteLargeFile(KFile2GB());
1.751 + DeleteLargeFile(KFile2GBMinusOne());
1.752 +
1.753 + CopyDirectory();
1.754 +
1.755 + // delete the 3GB file and check the disk
1.756 + DeleteLargeFile(KFile3GB());
1.757 +
1.758 + if (FilePresent(KFile4GBMinusOne()))
1.759 + DeleteLargeFile(KFile4GBMinusOne());
1.760 +
1.761 + // Finally check that we can format the drive...
1.762 + Format (gDrive);
1.763 + }
1.764 +
1.765 +#ifdef __MOUNT_RAW_EXT__
1.766 + r = TheFs.DismountExtension(KExtName, gDrive);
1.767 + test(r==KErrNone);
1.768 +
1.769 + r = TheFs.RemoveExtension(KExtName);
1.770 + test(r==KErrNone);
1.771 +
1.772 +#endif
1.773 +
1.774 + delete gBuf; gBuf = NULL;
1.775 + }
1.776 +