os/kernelhwsrv/kerneltest/f32test/server/t_falsespace.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <f32file.h>
sl@0
    17
#include <e32test.h>
sl@0
    18
#include <e32svr.h>
sl@0
    19
#include <e32math.h>
sl@0
    20
sl@0
    21
#include "fat_utils.h"
sl@0
    22
#include "t_server.h"
sl@0
    23
#include "t_chlffs.h"
sl@0
    24
sl@0
    25
using namespace Fat_Test_Utils;
sl@0
    26
sl@0
    27
RTest test(_L("t_falsespace"));
sl@0
    28
sl@0
    29
const TInt KNumberThreads=2;
sl@0
    30
const TInt KHeapSize=0x2000;
sl@0
    31
sl@0
    32
static TInt RsrvSpaceThread(TAny* aArg);
sl@0
    33
static TInt SessCloseThread(TAny* aArg);
sl@0
    34
static void GetFreeDiskSpace(TInt64 &aFree);
sl@0
    35
sl@0
    36
sl@0
    37
TInt gCount;		//count of files used to fill up the disk
sl@0
    38
TInt gTestDrive;	//drive number of the drive currently being tested
sl@0
    39
sl@0
    40
TChar gCh;
sl@0
    41
sl@0
    42
_LIT(KBasePath,"\\F32-TST\\FILLDIR\\");
sl@0
    43
_LIT(KBaseName,"\\F32-TST\\FILLDIR\\FILE");
sl@0
    44
sl@0
    45
_LIT(KTestFile,"?:\\test.txt");
sl@0
    46
_LIT8(KTestData, "12345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678123456781234567812345678");
sl@0
    47
_LIT(KDir, "?:\\adodgydir\\");
sl@0
    48
_LIT(KDrv,"?:\\");	
sl@0
    49
_LIT(KNewName,"?:\\newname.txt");
sl@0
    50
sl@0
    51
sl@0
    52
void FormatDrive()
sl@0
    53
{
sl@0
    54
    TInt nRes;
sl@0
    55
sl@0
    56
    
sl@0
    57
    #if 0
sl@0
    58
    //-- FAT32 SPC:1; for the FAT32 testing on the emulator 
sl@0
    59
    TFatFormatParam fp;
sl@0
    60
    fp.iFatType = EFat32;
sl@0
    61
    fp.iSecPerCluster = 1;
sl@0
    62
sl@0
    63
	nRes = FormatFatDrive(TheFs, gTestDrive, ETrue, &fp);	
sl@0
    64
    #else
sl@0
    65
sl@0
    66
    nRes = FormatFatDrive(TheFs, gTestDrive, ETrue);	
sl@0
    67
sl@0
    68
    #endif
sl@0
    69
sl@0
    70
    test(nRes == KErrNone);
sl@0
    71
}
sl@0
    72
sl@0
    73
void SynchronousClose(RFs &aSession)
sl@0
    74
	{
sl@0
    75
	TRequestStatus s;
sl@0
    76
	aSession.NotifyDestruction(s);
sl@0
    77
	test(s.Int()==KRequestPending);
sl@0
    78
	aSession.Close();
sl@0
    79
	User::WaitForRequest(s);
sl@0
    80
	}
sl@0
    81
sl@0
    82
sl@0
    83
static TInt CreateFileX(const TDesC& aBaseName,TInt aX, TInt aFileSize)
sl@0
    84
//
sl@0
    85
// Create a large file. Return KErrEof or KErrNone
sl@0
    86
//
sl@0
    87
	{
sl@0
    88
sl@0
    89
	TBuf<128> fileName=aBaseName;
sl@0
    90
	fileName.AppendNum(aX);
sl@0
    91
	RFile file;
sl@0
    92
sl@0
    93
	TInt r=file.Replace(TheFs,fileName,EFileWrite);
sl@0
    94
	if (r==KErrDiskFull)
sl@0
    95
		return(r);
sl@0
    96
	if (r!=KErrNone)
sl@0
    97
		{
sl@0
    98
		test.Printf(_L("ERROR:: Replace returned %d\n"),r);
sl@0
    99
		test(0);
sl@0
   100
		return(KErrDiskFull);
sl@0
   101
		}
sl@0
   102
sl@0
   103
	if (!IsTestingLFFS())
sl@0
   104
		r=file.SetSize(aFileSize);
sl@0
   105
	else
sl@0
   106
		{
sl@0
   107
    	TBuf8<1024> testdata(1024);
sl@0
   108
    	TInt count=(aFileSize/testdata.Length());
sl@0
   109
    	r=KErrNone;
sl@0
   110
    	while (count-- && r==KErrNone) 
sl@0
   111
        	r=file.Write(testdata);
sl@0
   112
		}
sl@0
   113
	if (r==KErrDiskFull)
sl@0
   114
		{
sl@0
   115
		file.Close();
sl@0
   116
		return(r);
sl@0
   117
		}
sl@0
   118
	if (r!=KErrNone)
sl@0
   119
		{
sl@0
   120
		test.Printf(_L("ERROR:: SetSize/Write returned %d\n"),r);
sl@0
   121
		test(0);
sl@0
   122
		//test.Getch();
sl@0
   123
		file.Close();
sl@0
   124
		return(KErrDiskFull);
sl@0
   125
		}
sl@0
   126
sl@0
   127
	file.Close();
sl@0
   128
sl@0
   129
	test.Printf(_L("Created file %d size %d\n"),aX,aFileSize);
sl@0
   130
	return(KErrNone);
sl@0
   131
	}
sl@0
   132
sl@0
   133
LOCAL_C TInt DeleteFileX(const TDesC& aBaseName,TInt aX)
sl@0
   134
//
sl@0
   135
// Delete a large file
sl@0
   136
//
sl@0
   137
	{
sl@0
   138
	TBuf<128> fileName=aBaseName;
sl@0
   139
	fileName.AppendNum(aX);
sl@0
   140
	return TheFs.Delete(fileName);
sl@0
   141
	}
sl@0
   142
sl@0
   143
sl@0
   144
static void FillUpDisk()
sl@0
   145
//
sl@0
   146
// Test that a full disk is ok
sl@0
   147
//
sl@0
   148
	{
sl@0
   149
sl@0
   150
	test.Start(_L("Fill disk to capacity"));
sl@0
   151
	TInt r=TheFs.MkDirAll(KBasePath);
sl@0
   152
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   153
	gCount=0;
sl@0
   154
	TFileName sessionPath;
sl@0
   155
	r=TheFs.SessionPath(sessionPath);
sl@0
   156
	test(r==KErrNone);
sl@0
   157
	TBuf<128> fileName=KBaseName();
sl@0
   158
	
sl@0
   159
	TInt64 freespace=0;
sl@0
   160
	TInt64 freespaceBeforeScanDrive = 0;
sl@0
   161
	TInt64 freespaceAfterScanDrive = 0;
sl@0
   162
	
sl@0
   163
	do
sl@0
   164
		{
sl@0
   165
		GetFreeDiskSpace(freespace);
sl@0
   166
		TInt fillfilesize=0;
sl@0
   167
		if (I64HIGH(freespace))
sl@0
   168
			fillfilesize=KMaxTInt;
sl@0
   169
		else
sl@0
   170
			fillfilesize=I64LOW(freespace)* 7/8;
sl@0
   171
sl@0
   172
		FOREVER
sl@0
   173
			{
sl@0
   174
			TInt r=CreateFileX(fileName,gCount,fillfilesize);
sl@0
   175
			if (r==KErrDiskFull)
sl@0
   176
				{
sl@0
   177
				if(fillfilesize <= 2)
sl@0
   178
					break;
sl@0
   179
				else
sl@0
   180
					fillfilesize=fillfilesize/2;
sl@0
   181
				}
sl@0
   182
			test(r==KErrNone || r==KErrDiskFull);
sl@0
   183
			if(r==KErrNone)
sl@0
   184
				gCount++;
sl@0
   185
			}
sl@0
   186
sl@0
   187
		r=TheFs.CheckDisk(fileName);
sl@0
   188
		if (r!=KErrNone && r!=KErrNotSupported)
sl@0
   189
			{
sl@0
   190
			test.Printf(_L("ERROR:: CheckDisk returned %d\n"),r);
sl@0
   191
			test(0);
sl@0
   192
sl@0
   193
			}
sl@0
   194
sl@0
   195
		// Test that scan drive passes on a full disk
sl@0
   196
		// DEF071696 - KErrCorrupt on Scan Drive 
sl@0
   197
		GetFreeDiskSpace(freespaceBeforeScanDrive);
sl@0
   198
		test.Printf(_L("Before ScanDrive freeSpace = %08X:%08X\n"),
sl@0
   199
			I64HIGH(freespaceBeforeScanDrive), I64LOW(freespaceBeforeScanDrive));
sl@0
   200
		r = TheFs.ScanDrive(fileName);
sl@0
   201
		if (r!=KErrNone && r!=KErrNotSupported)
sl@0
   202
			{
sl@0
   203
			test.Printf(_L("ScanDrive returned %d\n"), r);
sl@0
   204
			test(0);
sl@0
   205
			}
sl@0
   206
		GetFreeDiskSpace(freespaceAfterScanDrive);
sl@0
   207
		test.Printf(_L("After ScanDrive freeSpace = %08X:%08X\n"),
sl@0
   208
			I64HIGH(freespaceAfterScanDrive), I64LOW(freespaceAfterScanDrive));
sl@0
   209
		}
sl@0
   210
		while (freespaceBeforeScanDrive != freespaceAfterScanDrive );
sl@0
   211
sl@0
   212
	gCount--;
sl@0
   213
sl@0
   214
	test.End();
sl@0
   215
	}
sl@0
   216
sl@0
   217
static void GetFreeDiskSpace(TInt64 &aFree)
sl@0
   218
//
sl@0
   219
//	Get free disk space
sl@0
   220
//
sl@0
   221
	{
sl@0
   222
	TVolumeInfo v;
sl@0
   223
sl@0
   224
	TInt r=TheFs.Volume(v,gTestDrive);
sl@0
   225
	test(r==KErrNone);
sl@0
   226
	aFree=v.iFree;
sl@0
   227
	}
sl@0
   228
sl@0
   229
sl@0
   230
static void Test1()
sl@0
   231
//
sl@0
   232
//	Test the API fundamentaly works for one session
sl@0
   233
//
sl@0
   234
	{
sl@0
   235
	test.Next(_L("Test Disk Space reserve APIs"));
sl@0
   236
	TInt r=0;
sl@0
   237
	
sl@0
   238
    FormatDrive();
sl@0
   239
	
sl@0
   240
	TInt64 free2;
sl@0
   241
	TInt64 free1; 
sl@0
   242
	TInt64 diff;
sl@0
   243
sl@0
   244
	r=TheFs.GetReserveAccess(gTestDrive);
sl@0
   245
	test(r==KErrPermissionDenied);
sl@0
   246
	
sl@0
   247
	//make sure nothing odd happens if we didnt already have access
sl@0
   248
	r=TheFs.ReleaseReserveAccess(gTestDrive);
sl@0
   249
	test(r==KErrNone);
sl@0
   250
sl@0
   251
	
sl@0
   252
	GetFreeDiskSpace(free2);
sl@0
   253
sl@0
   254
	r=TheFs.ReserveDriveSpace(gTestDrive,0x1000);
sl@0
   255
	test(r==KErrNone);
sl@0
   256
sl@0
   257
	GetFreeDiskSpace(free1);
sl@0
   258
	diff = free2 - free1;
sl@0
   259
	test(I64INT(diff) > 0xfe0 && I64INT(diff) < 0x1100); 
sl@0
   260
	
sl@0
   261
	r=TheFs.GetReserveAccess(gTestDrive);
sl@0
   262
	test(r==KErrNone);
sl@0
   263
sl@0
   264
	GetFreeDiskSpace(free1);
sl@0
   265
	TInt64 temp = free2-free1;
sl@0
   266
	test(I64INT(temp)>(-0x90) && I64INT(temp)<0x90);
sl@0
   267
	
sl@0
   268
	r=TheFs.ReleaseReserveAccess(gTestDrive);
sl@0
   269
	test(r==KErrNone);
sl@0
   270
	GetFreeDiskSpace(free1);
sl@0
   271
sl@0
   272
	diff = free2 - free1;
sl@0
   273
	test(I64INT(diff) > 0xfe0 && I64INT(diff) < 0x1100);
sl@0
   274
	
sl@0
   275
	
sl@0
   276
	//test reallocation of reserved space is possible
sl@0
   277
	r=TheFs.ReserveDriveSpace(gTestDrive,0x2000);
sl@0
   278
	test(r==KErrNone);
sl@0
   279
sl@0
   280
	//test upper limit of reserved space 
sl@0
   281
	r=TheFs.ReserveDriveSpace(gTestDrive,0x2000000);
sl@0
   282
	test(r==KErrArgument);
sl@0
   283
sl@0
   284
	r=TheFs.ReserveDriveSpace(gTestDrive,0);
sl@0
   285
	test(r==KErrNone);
sl@0
   286
	
sl@0
   287
	r=TheFs.GetReserveAccess(gTestDrive);
sl@0
   288
	test(r==KErrPermissionDenied);
sl@0
   289
sl@0
   290
	//make sure nothing odd happens if we didnt already have access
sl@0
   291
	r=TheFs.ReleaseReserveAccess(gTestDrive);
sl@0
   292
	test(r==KErrNone);
sl@0
   293
	
sl@0
   294
	r=TheFs.ReserveDriveSpace(gTestDrive,-45);
sl@0
   295
	test(r==KErrArgument);
sl@0
   296
	}
sl@0
   297
sl@0
   298
sl@0
   299
static void Test2()
sl@0
   300
//
sl@0
   301
//	Test multiple sessions, ensure the drive limit is not exceeded
sl@0
   302
//	
sl@0
   303
	{
sl@0
   304
sl@0
   305
	test.Next(_L("Test Session and total reserve limits"));
sl@0
   306
	
sl@0
   307
    FormatDrive();
sl@0
   308
	
sl@0
   309
	TInt i=0;
sl@0
   310
	TInt r=0;
sl@0
   311
	RFs sessions[17];
sl@0
   312
	TVolumeInfo v;
sl@0
   313
sl@0
   314
	//Connect Sessions
sl@0
   315
	for(i=0; i<17; i++)
sl@0
   316
		{
sl@0
   317
		r = sessions[i].Connect();
sl@0
   318
		test(r==KErrNone);
sl@0
   319
		}
sl@0
   320
sl@0
   321
	test.Next(_L("Test breaching sesson reserve limit"));
sl@0
   322
	r=sessions[0].ReserveDriveSpace(gTestDrive,0x10001);
sl@0
   323
	test(r==KErrArgument);
sl@0
   324
sl@0
   325
	//Get Volume Free Space
sl@0
   326
	r = sessions[0].Volume(v, gTestDrive);
sl@0
   327
sl@0
   328
	if(v.iFree > 0x100000)
sl@0
   329
		{
sl@0
   330
		test.Next(_L("Test breaching drive reserve limit"));
sl@0
   331
sl@0
   332
		for (i=0; i<16; i++)
sl@0
   333
			{
sl@0
   334
			r=sessions[i].ReserveDriveSpace(gTestDrive,0x10000);
sl@0
   335
			test(r==KErrNone);
sl@0
   336
			}
sl@0
   337
sl@0
   338
		//The straw
sl@0
   339
		r=sessions[16].ReserveDriveSpace(gTestDrive,0x10);
sl@0
   340
		test(r==KErrTooBig);
sl@0
   341
		}
sl@0
   342
	else
sl@0
   343
		{
sl@0
   344
		test.Printf(_L("Drive too small: breaching drive reserve limit test skipped\n"));
sl@0
   345
		test.Next(_L("Testing exhausting available drive free space instead"));
sl@0
   346
sl@0
   347
		for(i=0; (v.iFree -= 0x10000) >= 0; i++)
sl@0
   348
			{
sl@0
   349
			r=sessions[i].ReserveDriveSpace(gTestDrive,0x10000);
sl@0
   350
			test(r==KErrNone);
sl@0
   351
			}
sl@0
   352
sl@0
   353
		//The straw
sl@0
   354
		r=sessions[i].ReserveDriveSpace(gTestDrive,0x10000);
sl@0
   355
		test(r==KErrDiskFull);
sl@0
   356
		}
sl@0
   357
sl@0
   358
	//Close Sessions
sl@0
   359
	for(i=0; i<17; i++)
sl@0
   360
		{
sl@0
   361
		SynchronousClose(sessions[i]);
sl@0
   362
		}
sl@0
   363
	}
sl@0
   364
sl@0
   365
static void Test3()
sl@0
   366
//
sl@0
   367
//	Test session cleanup
sl@0
   368
//		
sl@0
   369
	{
sl@0
   370
	test.Next(_L("Test session close and clean up of resrved space"));
sl@0
   371
sl@0
   372
	FormatDrive();
sl@0
   373
	
sl@0
   374
	RFs fs1;
sl@0
   375
	RFs fs2;
sl@0
   376
	TInt64 free2(0);
sl@0
   377
	TInt64 free1(0); 
sl@0
   378
	TInt64 diff(0);
sl@0
   379
	
sl@0
   380
	TInt r=0;
sl@0
   381
	r = fs1.Connect();
sl@0
   382
	test(r==KErrNone);
sl@0
   383
	r = fs2.Connect();
sl@0
   384
	test(r==KErrNone);
sl@0
   385
sl@0
   386
	GetFreeDiskSpace(free1);
sl@0
   387
sl@0
   388
	r=fs1.ReserveDriveSpace(gTestDrive,0x10000);
sl@0
   389
	test(r==KErrNone);
sl@0
   390
	r=fs2.ReserveDriveSpace(gTestDrive,0x10000);
sl@0
   391
	test(r==KErrNone);
sl@0
   392
sl@0
   393
	GetFreeDiskSpace(free2);
sl@0
   394
	diff = free1 - free2;
sl@0
   395
	test(I64INT(diff)>0x1FBD0 && I64INT(diff)<0x21000); 
sl@0
   396
sl@0
   397
	SynchronousClose(fs1);
sl@0
   398
sl@0
   399
	GetFreeDiskSpace(free2);
sl@0
   400
	diff = free1-free2;
sl@0
   401
	test(I64INT(diff)>0xFA00 && I64INT(diff)<0x103C4); 
sl@0
   402
sl@0
   403
	r = fs1.Connect();
sl@0
   404
	test(r==KErrNone);
sl@0
   405
sl@0
   406
	GetFreeDiskSpace(free1);
sl@0
   407
	diff= free1-free2;
sl@0
   408
	test(I64INT(diff)== 0 || I64INT(diff)<0xFA0 ); 
sl@0
   409
sl@0
   410
	r=fs1.ReserveDriveSpace(gTestDrive,0x10000);
sl@0
   411
	test(r==KErrNone);
sl@0
   412
sl@0
   413
	GetFreeDiskSpace(free2);
sl@0
   414
	diff = free1 - free2;
sl@0
   415
	test(I64INT(diff)>0xFA00 && I64INT(diff)<0x103C4); 
sl@0
   416
sl@0
   417
	// Make sure no reserve space is allocated
sl@0
   418
	r=fs1.ReserveDriveSpace(gTestDrive,0);
sl@0
   419
	test(r==KErrNone);
sl@0
   420
	r=fs2.ReserveDriveSpace(gTestDrive,0);
sl@0
   421
	test(r==KErrNone);
sl@0
   422
sl@0
   423
	// Now fill up the disk
sl@0
   424
	FillUpDisk();
sl@0
   425
	
sl@0
   426
	// Should fail as there is no space
sl@0
   427
	r=fs1.ReserveDriveSpace(gTestDrive,0x10000);
sl@0
   428
	test(r==KErrDiskFull);
sl@0
   429
sl@0
   430
	SynchronousClose(fs1);
sl@0
   431
	SynchronousClose(fs2);
sl@0
   432
	}
sl@0
   433
sl@0
   434
sl@0
   435
static void Test4()
sl@0
   436
//
sl@0
   437
//	Test real out of disk space conditions i.e. properly run out of disk space and try to 
sl@0
   438
//	reserve an area etc
sl@0
   439
//	
sl@0
   440
	{
sl@0
   441
	test.Next(_L("Test Filling disk and using APIs"));
sl@0
   442
sl@0
   443
	if(IsTestingLFFS())
sl@0
   444
		{
sl@0
   445
		//-- This test is not valid for LFFS, because free space on this FS can change itself because of some 
sl@0
   446
        //-- internal FS activities
sl@0
   447
		test.Printf(_L("This test is inconsistent on LFFS\n"));
sl@0
   448
		return;
sl@0
   449
		}
sl@0
   450
	
sl@0
   451
    FormatDrive();
sl@0
   452
sl@0
   453
	RFs fs;
sl@0
   454
	TInt r=fs.Connect();
sl@0
   455
	test(r==KErrNone);
sl@0
   456
	TInt64 freeA(0);
sl@0
   457
	TInt64 freeB(0);
sl@0
   458
	RFile file;
sl@0
   459
sl@0
   460
									//start with known amount of space
sl@0
   461
sl@0
   462
	//create a single file to use for futher tests
sl@0
   463
	TBuf<20> buf;
sl@0
   464
	buf=KTestFile;
sl@0
   465
	buf[0]=(TUint16)gCh;
sl@0
   466
sl@0
   467
	r=file.Replace(fs, buf, EFileWrite);
sl@0
   468
	test(r==KErrNone);
sl@0
   469
sl@0
   470
	r=file.Write(KTestData());
sl@0
   471
	test(r==KErrNone);
sl@0
   472
sl@0
   473
	file.Close();
sl@0
   474
sl@0
   475
	r=fs.ReserveDriveSpace(gTestDrive,0x10000);		//reserve some disk space
sl@0
   476
	test(r==KErrNone);
sl@0
   477
		
sl@0
   478
	FillUpDisk();									//fill up the disk
sl@0
   479
sl@0
   480
	TVolumeInfo v;									//get disk space
sl@0
   481
	r=fs.Volume(v,gTestDrive);
sl@0
   482
	test(r==KErrNone);
sl@0
   483
	freeA=v.iFree;
sl@0
   484
sl@0
   485
	r=fs.GetReserveAccess(gTestDrive);				//get access to reserve space
sl@0
   486
	test(r==KErrNone);
sl@0
   487
sl@0
   488
	r=fs.Volume(v,gTestDrive);						//get disk space
sl@0
   489
	test(r==KErrNone);
sl@0
   490
	freeB=v.iFree;
sl@0
   491
	
sl@0
   492
	r=fs.ReleaseReserveAccess(gTestDrive);			//release reserve space
sl@0
   493
	test(r==KErrNone);
sl@0
   494
	
sl@0
   495
	test(freeA == (freeB - 0x10000));				//test difference in space is equal to the amount reserved
sl@0
   496
sl@0
   497
	r=fs.Volume(v,gTestDrive);						//get disk space
sl@0
   498
	test(r==KErrNone);
sl@0
   499
	freeB=v.iFree;
sl@0
   500
	test(freeA == freeB);							//check reading is still correct
sl@0
   501
	
sl@0
   502
	TBuf <20> dir = KDir();
sl@0
   503
	dir[0]=(TUint16)gCh;
sl@0
   504
	r=fs.MkDir(dir);
sl@0
   505
	test(r==KErrDiskFull);
sl@0
   506
sl@0
   507
	r=fs.MkDirAll(dir);
sl@0
   508
	test(r==KErrDiskFull);
sl@0
   509
sl@0
   510
	TFileName temp;
sl@0
   511
	TBuf<5> drv = KDrv();
sl@0
   512
	drv[0]=(TUint16)gCh;
sl@0
   513
	r=file.Temp(fs, drv, temp, EFileWrite);
sl@0
   514
	test(r==KErrDiskFull);
sl@0
   515
sl@0
   516
	r=file.Replace(fs, buf, EFileWrite);
sl@0
   517
	test(r==KErrDiskFull);
sl@0
   518
sl@0
   519
	r=file.Create(fs, buf, EFileWrite);
sl@0
   520
	test(r==KErrDiskFull);
sl@0
   521
sl@0
   522
	r=file.Open(fs, buf, EFileWrite);
sl@0
   523
	test(r==KErrNone);
sl@0
   524
sl@0
   525
	r=file.Write(128, KTestData());
sl@0
   526
sl@0
   527
	if ((gDriveCacheFlags & EFileCacheWriteOn) && (r == KErrNone))
sl@0
   528
		r = file.Flush();
sl@0
   529
	
sl@0
   530
	test(r==KErrDiskFull);
sl@0
   531
sl@0
   532
	r=file.SetSize(0x1000);
sl@0
   533
	test(r==KErrDiskFull);
sl@0
   534
sl@0
   535
	r=file.SetAtt(KEntryAttHidden,0); 
sl@0
   536
	test(r==KErrDiskFull);
sl@0
   537
sl@0
   538
	TTime dtime;
sl@0
   539
	r=file.SetModified(dtime); 
sl@0
   540
	test(r==KErrDiskFull);
sl@0
   541
sl@0
   542
	r=file.Set(dtime,KEntryAttHidden,0);
sl@0
   543
	test(r==KErrDiskFull);
sl@0
   544
sl@0
   545
	r=file.Rename(buf);
sl@0
   546
	test(r==KErrDiskFull);
sl@0
   547
sl@0
   548
	file.Close();
sl@0
   549
sl@0
   550
sl@0
   551
	// Test that we can create a temporary file & write to it after acquiring reserved access, 
sl@0
   552
	r=fs.GetReserveAccess(gTestDrive);				//get access to reserve space
sl@0
   553
	test(r==KErrNone);
sl@0
   554
sl@0
   555
	r=fs.Volume(v,gTestDrive);						//get disk space
sl@0
   556
	test(r==KErrNone);
sl@0
   557
	freeA = v.iFree;
sl@0
   558
sl@0
   559
	r=file.Temp(fs, drv, temp, EFileWrite);
sl@0
   560
	test(r==KErrNone);
sl@0
   561
sl@0
   562
	r = file.Write(KTestData());
sl@0
   563
	test (r == KErrNone);
sl@0
   564
sl@0
   565
	// If write caching is enabled, call RFs::Entry() to flush the file "anonymously"
sl@0
   566
	if ((gDriveCacheFlags & EFileCacheWriteOn) && (r == KErrNone))
sl@0
   567
		{
sl@0
   568
		r = file.Flush();
sl@0
   569
		test (r == KErrNone);
sl@0
   570
		}
sl@0
   571
sl@0
   572
	r=fs.Volume(v,gTestDrive);						//get disk space
sl@0
   573
	test(r==KErrNone);
sl@0
   574
	freeB = v.iFree;
sl@0
   575
	test (freeB < freeA);
sl@0
   576
sl@0
   577
	file.Close();
sl@0
   578
sl@0
   579
	r=fs.ReleaseReserveAccess(gTestDrive);			//release reserve space
sl@0
   580
	test(r==KErrNone);
sl@0
   581
sl@0
   582
sl@0
   583
	TBuf<20> newname =KNewName();
sl@0
   584
	newname[0]=(TUint16)gCh;
sl@0
   585
	r=fs.Rename(buf, newname);
sl@0
   586
	test(r==KErrDiskFull);
sl@0
   587
sl@0
   588
	r=fs.Replace(buf, newname);
sl@0
   589
	test(r==KErrDiskFull);
sl@0
   590
sl@0
   591
	r=fs.SetEntry(buf, dtime, KEntryAttHidden, 0);
sl@0
   592
	test(r==KErrDiskFull);
sl@0
   593
sl@0
   594
	r=fs.CreatePrivatePath(gTestDrive);
sl@0
   595
	test(r==KErrDiskFull);
sl@0
   596
sl@0
   597
	r=fs.SetVolumeLabel(_L("Moooo"), gTestDrive);
sl@0
   598
	test(r==KErrDiskFull);	
sl@0
   599
sl@0
   600
	r=fs.SetModified(buf, dtime);
sl@0
   601
	test(r==KErrDiskFull);	
sl@0
   602
sl@0
   603
	SynchronousClose(fs);
sl@0
   604
	}
sl@0
   605
sl@0
   606
	
sl@0
   607
sl@0
   608
static void Test5()
sl@0
   609
//
sl@0
   610
//
sl@0
   611
//
sl@0
   612
	{
sl@0
   613
	test.Next(_L("Test Session limits"));
sl@0
   614
sl@0
   615
	if(IsTestingLFFS())
sl@0
   616
		{
sl@0
   617
		//-- This test is not valid for LFFS, because free space on this FS can change itself because of some 
sl@0
   618
        //-- internal FS activities
sl@0
   619
		test.Printf(_L("This test is inconsistent on LFFS\n"));
sl@0
   620
		return;
sl@0
   621
		}
sl@0
   622
sl@0
   623
sl@0
   624
	RFs fs1;
sl@0
   625
	RFs fs2;
sl@0
   626
	TInt r=KErrNone;
sl@0
   627
sl@0
   628
	r=fs1.Connect();
sl@0
   629
	test(r==KErrNone);
sl@0
   630
	r=fs2.Connect();
sl@0
   631
	test(r==KErrNone);
sl@0
   632
sl@0
   633
	FormatDrive();
sl@0
   634
sl@0
   635
	r=fs1.ReserveDriveSpace(gTestDrive,0x10000);		
sl@0
   636
	test(r==KErrNone);
sl@0
   637
sl@0
   638
	r=fs2.ReserveDriveSpace(gTestDrive,0x10000);		
sl@0
   639
	test(r==KErrNone);
sl@0
   640
sl@0
   641
	FillUpDisk();									
sl@0
   642
sl@0
   643
	r=fs1.GetReserveAccess(gTestDrive);				
sl@0
   644
	test(r==KErrNone);
sl@0
   645
sl@0
   646
	TBuf<20> dir = KDir();
sl@0
   647
	dir[0]=(TUint16)gCh;
sl@0
   648
sl@0
   649
sl@0
   650
	r=fs2.MkDir(dir);
sl@0
   651
	test(r==KErrDiskFull);
sl@0
   652
sl@0
   653
	r=fs1.ReserveDriveSpace(gTestDrive,0); //can not release reserve space while you have reserve access
sl@0
   654
	test(r==KErrInUse);
sl@0
   655
sl@0
   656
	r=fs1.ReleaseReserveAccess(gTestDrive);				
sl@0
   657
	test(r==KErrNone);
sl@0
   658
sl@0
   659
	r=fs1.ReserveDriveSpace(gTestDrive,0); 
sl@0
   660
	test(r==KErrNone);
sl@0
   661
sl@0
   662
	r=fs2.MkDir(dir);
sl@0
   663
	test(r==KErrNone);
sl@0
   664
sl@0
   665
	SynchronousClose(fs1);
sl@0
   666
	SynchronousClose(fs2);
sl@0
   667
	}
sl@0
   668
sl@0
   669
static TInt RsrvSpaceThread(TAny* aArg)
sl@0
   670
	{
sl@0
   671
	TInt r=KErrNone;
sl@0
   672
	TInt64 fr1;
sl@0
   673
	TInt64 fr2;
sl@0
   674
	TInt64 diff;
sl@0
   675
sl@0
   676
	TVolumeInfo v;
sl@0
   677
	r=((RFs*)aArg)->Volume(v,gTestDrive);
sl@0
   678
	if(r!=KErrNone)
sl@0
   679
		return(r);
sl@0
   680
sl@0
   681
	fr1=v.iFree;
sl@0
   682
sl@0
   683
	r=((RFs*)aArg)->ReserveDriveSpace(gTestDrive,0x10000); 
sl@0
   684
	if(r!=KErrNone)
sl@0
   685
		return(r);
sl@0
   686
sl@0
   687
	r=((RFs*)aArg)->Volume(v,gTestDrive);
sl@0
   688
	if(r!=KErrNone)
sl@0
   689
		return(r);
sl@0
   690
	fr2=v.iFree;
sl@0
   691
	
sl@0
   692
	diff=fr1-fr2;
sl@0
   693
	if(!(I64INT(diff)> 0xef38 && I64INT(diff)<0xf100))
sl@0
   694
		return(KErrGeneral);
sl@0
   695
	return r;
sl@0
   696
	}
sl@0
   697
sl@0
   698
static TInt SessCloseThread(TAny* aArg)
sl@0
   699
	{
sl@0
   700
	TInt r=KErrNone;
sl@0
   701
	TInt64 fr1;
sl@0
   702
	TInt64 fr2;
sl@0
   703
	TInt64 diff;
sl@0
   704
sl@0
   705
	TVolumeInfo v;
sl@0
   706
	r=((RFs*)aArg)->Volume(v,gTestDrive);
sl@0
   707
	if(r!=KErrNone)
sl@0
   708
		return(r);
sl@0
   709
	fr1=v.iFree;
sl@0
   710
sl@0
   711
	((RFs*)aArg)->ReserveDriveSpace(gTestDrive,0x1000);
sl@0
   712
	
sl@0
   713
	r=((RFs*)aArg)->Volume(v,gTestDrive);
sl@0
   714
	if(r!=KErrNone)
sl@0
   715
		return(r);
sl@0
   716
	fr2=v.iFree;
sl@0
   717
sl@0
   718
	diff=fr2-fr1;
sl@0
   719
	if(!(I64INT(diff)> 0xef38 && I64INT(diff)<0xf100))
sl@0
   720
		return(KErrGeneral);
sl@0
   721
sl@0
   722
	SynchronousClose(*((RFs*)aArg));
sl@0
   723
sl@0
   724
	return r;
sl@0
   725
	}
sl@0
   726
sl@0
   727
static void Test6()
sl@0
   728
//
sl@0
   729
//	Test sharabale session
sl@0
   730
//
sl@0
   731
	{
sl@0
   732
	
sl@0
   733
	test.Next(_L("Test sharable session"));
sl@0
   734
sl@0
   735
	RFs fsess;
sl@0
   736
	TInt r=KErrNone;
sl@0
   737
	TInt64 free1(0);
sl@0
   738
	TInt64 free2(0);
sl@0
   739
	TInt64 diff(0);
sl@0
   740
	RThread t[KNumberThreads];
sl@0
   741
	TRequestStatus tStat[KNumberThreads];
sl@0
   742
sl@0
   743
	r=fsess.Connect();
sl@0
   744
	test(r==KErrNone);
sl@0
   745
sl@0
   746
	FormatDrive();
sl@0
   747
sl@0
   748
	r= fsess.ShareAuto();
sl@0
   749
	test(r==KErrNone);
sl@0
   750
sl@0
   751
	GetFreeDiskSpace(free1);
sl@0
   752
sl@0
   753
	fsess.ReserveDriveSpace(gTestDrive,0x1000);
sl@0
   754
		
sl@0
   755
	r = t[0].Create(_L("Sub_Thread1"),RsrvSpaceThread,KDefaultStackSize,KHeapSize,KHeapSize,&fsess); 
sl@0
   756
	test(r==KErrNone);
sl@0
   757
sl@0
   758
	t[0].Rendezvous(tStat[0]);
sl@0
   759
	t[0].Resume();
sl@0
   760
sl@0
   761
	User::WaitForRequest(tStat[0]);
sl@0
   762
sl@0
   763
	t[0].Close();
sl@0
   764
	test(tStat[0]==KErrNone);
sl@0
   765
sl@0
   766
	r = t[1].Create(_L("Sub_Thread2"),SessCloseThread,KDefaultStackSize,KHeapSize,KHeapSize,&fsess); 
sl@0
   767
	test(r==KErrNone);
sl@0
   768
sl@0
   769
	t[1].Rendezvous(tStat[1]);
sl@0
   770
	t[1].Resume();
sl@0
   771
sl@0
   772
	User::WaitForRequest(tStat[1]);
sl@0
   773
sl@0
   774
	t[1].Close();
sl@0
   775
	test(tStat[1]==KErrNone);
sl@0
   776
sl@0
   777
	GetFreeDiskSpace(free2);
sl@0
   778
sl@0
   779
	diff = free1-free2;
sl@0
   780
	test(I64INT(diff)== 0 || I64INT(diff)<0xFA0 );
sl@0
   781
	}
sl@0
   782
sl@0
   783
sl@0
   784
static void Test7()
sl@0
   785
//
sl@0
   786
// Tests notifier events for sessions with and without reserved access
sl@0
   787
//
sl@0
   788
	{
sl@0
   789
	if(IsTestingLFFS())
sl@0
   790
		{
sl@0
   791
		// This test is not valid for LFFS...
sl@0
   792
		test.Printf(_L("Test reserved access notification not run for LFFS\n"));
sl@0
   793
		return;
sl@0
   794
		}
sl@0
   795
sl@0
   796
	
sl@0
   797
	test.Next(_L("Test reserved access notification"));
sl@0
   798
	
sl@0
   799
	FormatDrive();
sl@0
   800
sl@0
   801
	RFs theNrm;
sl@0
   802
	RFs theRes;
sl@0
   803
sl@0
   804
	TInt err = theNrm.Connect();
sl@0
   805
	test(KErrNone == err);
sl@0
   806
sl@0
   807
	err = theRes.Connect();
sl@0
   808
	test(KErrNone == err);
sl@0
   809
sl@0
   810
sl@0
   811
	TInt64 freeSpace(0);
sl@0
   812
	GetFreeDiskSpace(freeSpace);
sl@0
   813
sl@0
   814
	RFs theTestSession;
sl@0
   815
	theTestSession.Connect();
sl@0
   816
sl@0
   817
	_LIT(KFileFiller, "?:\\t_falseSpaceFiller");
sl@0
   818
	TBuf<25> fileName;
sl@0
   819
	fileName = KFileFiller;
sl@0
   820
	fileName[0] = (TUint16)gCh;
sl@0
   821
sl@0
   822
	err = theTestSession.Connect();
sl@0
   823
	test(err == KErrNone);
sl@0
   824
sl@0
   825
	// determine the cluster size
sl@0
   826
	RFile theFile;
sl@0
   827
	err=theFile.Replace(theTestSession, fileName, EFileShareAny | EFileWrite);
sl@0
   828
	test(err==KErrNone);
sl@0
   829
sl@0
   830
	// Neither notifier should be triggered here
sl@0
   831
	err = theFile.SetSize(1);
sl@0
   832
	test(KErrNone == err);
sl@0
   833
	theFile.Close();
sl@0
   834
sl@0
   835
	TInt64 newFreeSpace;
sl@0
   836
	GetFreeDiskSpace(newFreeSpace);
sl@0
   837
	TInt clusterSize = TInt(freeSpace - newFreeSpace);
sl@0
   838
	theTestSession.Delete(fileName);
sl@0
   839
	GetFreeDiskSpace(newFreeSpace);
sl@0
   840
	test (newFreeSpace == freeSpace);
sl@0
   841
sl@0
   842
	TInt resSpace = Max(0x1000, clusterSize);
sl@0
   843
		
sl@0
   844
	TVolumeInfo volInfo;
sl@0
   845
	theNrm.Volume(volInfo, gTestDrive);
sl@0
   846
	test(volInfo.iFree == freeSpace);
sl@0
   847
sl@0
   848
	err = theRes.ReserveDriveSpace(gTestDrive, resSpace);
sl@0
   849
	test(KErrNone == err);
sl@0
   850
	err = theRes.GetReserveAccess(gTestDrive);
sl@0
   851
	test(KErrNone == err);
sl@0
   852
sl@0
   853
	theRes.Volume(volInfo, gTestDrive);
sl@0
   854
	test(volInfo.iFree == freeSpace);
sl@0
   855
sl@0
   856
	theNrm.Volume(volInfo, gTestDrive);
sl@0
   857
	test(volInfo.iFree == freeSpace - resSpace);
sl@0
   858
sl@0
   859
sl@0
   860
	//
sl@0
   861
	// Register the notifiers and verify that the only the "Normal"
sl@0
   862
	// and not the "Reserved" session is triggered.
sl@0
   863
	//
sl@0
   864
	TRequestStatus statNrm;
sl@0
   865
	TRequestStatus statRes;
sl@0
   866
sl@0
   867
	TInt64 threshold(freeSpace - resSpace*2);
sl@0
   868
	theNrm.NotifyDiskSpace(threshold, gTestDrive, statNrm);
sl@0
   869
	theRes.NotifyDiskSpace(threshold, gTestDrive, statRes);
sl@0
   870
	test((statNrm == KRequestPending) && (statRes == KRequestPending));
sl@0
   871
sl@0
   872
sl@0
   873
	//
sl@0
   874
	// Main part of the test starts here.
sl@0
   875
	// First we create a new file, then we increase its size to cause the
sl@0
   876
	// "Normal" notifier to trigger but not the "Reserved" notifier
sl@0
   877
	//
sl@0
   878
	err=theFile.Replace(theTestSession, fileName, EFileShareAny | EFileWrite);
sl@0
   879
	test(err==KErrNone);
sl@0
   880
	test((statNrm == KRequestPending) && (statRes == KRequestPending));
sl@0
   881
sl@0
   882
	// Neither notifier should be triggered here
sl@0
   883
	err = theFile.SetSize(resSpace);
sl@0
   884
	test(KErrNone == err);
sl@0
   885
	test((statNrm == KRequestPending) && (statRes == KRequestPending));
sl@0
   886
sl@0
   887
	// This should trigger the "Normal" notifier, but not the "Reserved" one
sl@0
   888
	err = theFile.SetSize(2*resSpace);
sl@0
   889
	test(KErrNone == err);
sl@0
   890
	test((statNrm == KErrNone) && (statRes == KRequestPending));
sl@0
   891
sl@0
   892
sl@0
   893
	//
sl@0
   894
	// Reset the "Normal" notifier then increase the amount of reserved space
sl@0
   895
	// on the drive. This should re-trigger the "Normal" notifier but leave
sl@0
   896
	// the "Reserved" notifier untouched.
sl@0
   897
	//
sl@0
   898
	theNrm.NotifyDiskSpace(threshold - resSpace, gTestDrive, statNrm);
sl@0
   899
	test((statNrm == KRequestPending) && (statRes == KRequestPending));
sl@0
   900
sl@0
   901
	err = theTestSession.ReserveDriveSpace(gTestDrive, resSpace * 3);
sl@0
   902
	if (err != KErrArgument)	// will have exceeded limit if resSpace = 32K
sl@0
   903
		{
sl@0
   904
		test(err == KErrNone);
sl@0
   905
		test((statNrm == KErrNone) && (statRes == KRequestPending));
sl@0
   906
		}
sl@0
   907
sl@0
   908
	//
sl@0
   909
	// All done - tidy up.
sl@0
   910
	//
sl@0
   911
	theFile.Close();
sl@0
   912
	theTestSession.Delete(fileName);
sl@0
   913
	theTestSession.Close();
sl@0
   914
	theNrm.Close();
sl@0
   915
	theRes.Close();
sl@0
   916
	}
sl@0
   917
sl@0
   918
LOCAL_C void TestForDEF142554()
sl@0
   919
    {
sl@0
   920
    test.Next(_L("Test for DEF142554: test RFile::Modified and RFile::Att when disk full"));
sl@0
   921
    
sl@0
   922
    Format(gTestDrive);
sl@0
   923
    
sl@0
   924
    TUint att;
sl@0
   925
    TTime time;
sl@0
   926
    
sl@0
   927
    RFs fs;
sl@0
   928
    TInt err = fs.Connect();
sl@0
   929
    test(err == KErrNone);
sl@0
   930
sl@0
   931
    RFile file;
sl@0
   932
    TBuf<20> fileName;
sl@0
   933
    fileName = KTestFile;
sl@0
   934
    fileName[0] = (TUint16)gCh;
sl@0
   935
    
sl@0
   936
    err = fs.ReserveDriveSpace(gTestDrive,0x10000); 
sl@0
   937
    test(err == KErrNone);
sl@0
   938
sl@0
   939
    err = file.Replace(fs, fileName, EFileWrite);
sl@0
   940
    test(err == KErrNone);
sl@0
   941
sl@0
   942
    err = file.Write(KTestData);
sl@0
   943
    test(err == KErrNone);
sl@0
   944
    
sl@0
   945
    err = file.Flush();
sl@0
   946
    test(err == KErrNone);
sl@0
   947
    
sl@0
   948
    file.Close();
sl@0
   949
    
sl@0
   950
    err = file.Open(fs, fileName, EFileRead);
sl@0
   951
    test(err == KErrNone);
sl@0
   952
    
sl@0
   953
    err = file.Att(att);
sl@0
   954
    test(err == KErrNone);
sl@0
   955
    
sl@0
   956
    err = file.Modified(time);
sl@0
   957
    test(err == KErrNone);
sl@0
   958
    
sl@0
   959
    file.Close();
sl@0
   960
    
sl@0
   961
    FillUpDisk();
sl@0
   962
    
sl@0
   963
    err = file.Open(fs, fileName, EFileRead);
sl@0
   964
    test(err == KErrNone);
sl@0
   965
    
sl@0
   966
    TUint att1;
sl@0
   967
    err = file.Att(att1);
sl@0
   968
    test(err == KErrNone);
sl@0
   969
    test(att1 == att);
sl@0
   970
    
sl@0
   971
    TTime time1;
sl@0
   972
    err = file.Modified(time1);
sl@0
   973
    test(err == KErrNone);
sl@0
   974
    test(time1 == time);
sl@0
   975
    
sl@0
   976
    file.Close();
sl@0
   977
    fs.Close();
sl@0
   978
    
sl@0
   979
    }
sl@0
   980
sl@0
   981
sl@0
   982
//-----------------------------------------------------------------------------
sl@0
   983
sl@0
   984
/**
sl@0
   985
    test creation of the the file that crosses 4G boundary on the FAT media
sl@0
   986
sl@0
   987
*/
sl@0
   988
static void TestFAT4G_Boundary()
sl@0
   989
	{
sl@0
   990
    const TInt64 K4Gig = 4*(TInt64)K1GigaByte;
sl@0
   991
sl@0
   992
	test.Next(_L("Test files crossing 4G boundary on FAT"));
sl@0
   993
sl@0
   994
    if(!Is_Fat32(TheFs, gTestDrive))
sl@0
   995
		{
sl@0
   996
		test.Printf(_L("This test requires FAT32. Skipping.\n"));
sl@0
   997
		return;
sl@0
   998
		}
sl@0
   999
sl@0
  1000
    TVolumeInfo volInfo;
sl@0
  1001
	
sl@0
  1002
	TInt nRes = TheFs.Volume(volInfo,gTestDrive);
sl@0
  1003
	test(nRes == KErrNone);
sl@0
  1004
	
sl@0
  1005
    if(volInfo.iSize < K4Gig+K1MegaByte)
sl@0
  1006
		{
sl@0
  1007
		test.Printf(_L("This test requires volume > 4G. Skipping.\n"));
sl@0
  1008
		return;
sl@0
  1009
		}
sl@0
  1010
	
sl@0
  1011
    //-- 1. format the volume
sl@0
  1012
    FormatDrive();
sl@0
  1013
sl@0
  1014
    //-- find out media position of the data region start
sl@0
  1015
    TFatBootSector bootSector;
sl@0
  1016
    nRes = ReadBootSector(TheFs, gTestDrive, 0, bootSector);
sl@0
  1017
    test(nRes == KErrNone);
sl@0
  1018
    test(bootSector.IsValid());
sl@0
  1019
sl@0
  1020
    const TInt64 dataStartPos = bootSector.FirstDataSector() << KDefaultSectorLog2;
sl@0
  1021
    const TInt64 lowRegion = K4Gig - dataStartPos - K1MegaByte; 
sl@0
  1022
sl@0
  1023
sl@0
  1024
    //-- 2. create several empty files that take a bit less that 4gig
sl@0
  1025
    //-- the drive is freshly formatted and the files will expand linearry
sl@0
  1026
    _LIT(KBaseFN, "\\LargeFile");
sl@0
  1027
    
sl@0
  1028
    const TInt MaxDummyFiles = 5;
sl@0
  1029
    const TUint32 DummyFileLen = (TUint32)(lowRegion / MaxDummyFiles);
sl@0
  1030
	TInt i;
sl@0
  1031
    for(i=0; i<MaxDummyFiles; ++i)
sl@0
  1032
		{
sl@0
  1033
        nRes = CreateFileX(KBaseFN, i, DummyFileLen); 
sl@0
  1034
        test(nRes == KErrNone);
sl@0
  1035
		}
sl@0
  1036
sl@0
  1037
    //-- 3. create a real file that crosses 4G boundary
sl@0
  1038
    nRes = CreateCheckableStuffedFile(TheFs, KBaseFN, 5*K1MegaByte);
sl@0
  1039
    test(nRes == KErrNone);
sl@0
  1040
    
sl@0
  1041
    test.Printf(_L("Verifying the file that crosses 4G boundary.\n"));
sl@0
  1042
sl@0
  1043
    nRes = VerifyCheckableFile(TheFs, KBaseFN);
sl@0
  1044
    test(nRes == KErrNone);
sl@0
  1045
sl@0
  1046
	
sl@0
  1047
	nRes = TheFs.Delete(KBaseFN);
sl@0
  1048
	test(nRes == KErrNone);
sl@0
  1049
    for(i=0; i<MaxDummyFiles; ++i)
sl@0
  1050
	    {
sl@0
  1051
        nRes = DeleteFileX(KBaseFN, i); 
sl@0
  1052
        test(nRes == KErrNone);
sl@0
  1053
		}
sl@0
  1054
	}
sl@0
  1055
sl@0
  1056
//-----------------------------------------------------------------------------
sl@0
  1057
sl@0
  1058
GLDEF_C void CallTestsL()
sl@0
  1059
//
sl@0
  1060
// Do tests relative to session path
sl@0
  1061
//
sl@0
  1062
	{
sl@0
  1063
    //-- set up console output 
sl@0
  1064
    Fat_Test_Utils::SetConsole(test.Console()); 
sl@0
  1065
sl@0
  1066
sl@0
  1067
	if (gSessionPath[0]=='C')	//only test on non C drives
sl@0
  1068
		{
sl@0
  1069
		test.Printf(_L("TEST NOT RUN FOR THIS DRIVE"));
sl@0
  1070
		return;
sl@0
  1071
		}
sl@0
  1072
	
sl@0
  1073
	if (UserSvr::DebugMask(2)&0x00000002) // TESTFAST mode set? (for automated test builds)
sl@0
  1074
		if(IsTestingLFFS())
sl@0
  1075
			{
sl@0
  1076
			// Don't run on LFFS (to increase speed of automated testing)
sl@0
  1077
			test.Printf(_L("TEST NOT RUN FOR THIS DRIVE"));
sl@0
  1078
			return;
sl@0
  1079
			}
sl@0
  1080
sl@0
  1081
	//get the number of the drive we are currently testing
sl@0
  1082
	TInt r=0;
sl@0
  1083
	r=RFs::CharToDrive(gSessionPath[0],gTestDrive);
sl@0
  1084
    test(r==KErrNone);
sl@0
  1085
sl@0
  1086
	r=RFs::DriveToChar(gTestDrive,gCh);
sl@0
  1087
	test(r==KErrNone);
sl@0
  1088
sl@0
  1089
    //-- print drive information
sl@0
  1090
    PrintDrvInfo(TheFs, gTestDrive);
sl@0
  1091
sl@0
  1092
	Test1();	//General test for new APIs
sl@0
  1093
	Test2();	//Test to ensure drive and session reserve limits are not exceeded
sl@0
  1094
	Test3();
sl@0
  1095
	Test4();	//test filling the drive and that each checked API fails
sl@0
  1096
	Test5();
sl@0
  1097
	Test6();
sl@0
  1098
	Test7();
sl@0
  1099
	TestForDEF142554();
sl@0
  1100
	Test2();	//run this test to check reserves are being cleared correctly
sl@0
  1101
sl@0
  1102
	TestFAT4G_Boundary();
sl@0
  1103
    
sl@0
  1104
    TurnAllocFailureOff();
sl@0
  1105
	}
sl@0
  1106
sl@0
  1107
sl@0
  1108
sl@0
  1109