os/kernelhwsrv/kerneltest/f32test/concur/t_cfsperform.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2004-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
// tests read/write throughput on two drives simultaneously
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
//! @file f32test\concur\t_cfsbench.cpp
sl@0
    19
sl@0
    20
#include <f32file.h>
sl@0
    21
#include <e32test.h>
sl@0
    22
#include <f32dbg.h>
sl@0
    23
#include "t_server.h"
sl@0
    24
#include "t_tdebug.h"
sl@0
    25
sl@0
    26
//IMPORT_C TUint32 DebugRegister();
sl@0
    27
sl@0
    28
sl@0
    29
GLDEF_D RTest test(_L("T_CFSBENCH"));
sl@0
    30
GLDEF_D	RFs TheFs;
sl@0
    31
sl@0
    32
LOCAL_D TFullName gFsName;
sl@0
    33
LOCAL_D TFullName gFsName1;
sl@0
    34
LOCAL_D TFullName gFsName2;
sl@0
    35
LOCAL_D TFullName gOldFsName;
sl@0
    36
LOCAL_D TFullName gNewFsName;
sl@0
    37
LOCAL_D TBool     gNoMedia = ETrue;
sl@0
    38
sl@0
    39
_LIT(KFsFile, "CFAFSDLY");
sl@0
    40
_LIT(KFsName, "DelayFS");
sl@0
    41
sl@0
    42
LOCAL_D const TInt32 KSecond = 1000000;
sl@0
    43
LOCAL_D const TInt32 KTimeBM = 20;
sl@0
    44
sl@0
    45
sl@0
    46
LOCAL_D const TInt32 KBufLen = 0x100;
sl@0
    47
sl@0
    48
LOCAL_D const TInt32 KMaxLag = 4;
sl@0
    49
sl@0
    50
LOCAL_D TBool gVerbose = EFalse;
sl@0
    51
sl@0
    52
TBuf16<KBufLen> gResults;
sl@0
    53
sl@0
    54
const TInt KMaxFileSize = (4*1024*1024);
sl@0
    55
const TInt KMinBufferSize = (16);
sl@0
    56
const TInt KMaxBufferSize = (512*1024);
sl@0
    57
const TInt KMaxIter = 17;
sl@0
    58
sl@0
    59
sl@0
    60
TBool gReadTests = EFalse;
sl@0
    61
TBool gWriteTests = EFalse;
sl@0
    62
TBool gAsyncTests = EFalse;
sl@0
    63
TBool gSyncTests = EFalse;
sl@0
    64
sl@0
    65
sl@0
    66
LOCAL_C TInt32 GetSpeed(TInt aOps, TInt aBufSize, TInt64 aDtime)
sl@0
    67
/// Calculate and return the throughput from the umber of blocks transferred
sl@0
    68
/// and the elapsed time.
sl@0
    69
	{
sl@0
    70
	TInt64 dsize = MAKE_TINT64(0, aOps) * MAKE_TINT64(0, aBufSize) * MAKE_TINT64(0, KSecond);
sl@0
    71
	TInt32 speed = I64LOW((dsize + aDtime/2) / aDtime);
sl@0
    72
	return speed;
sl@0
    73
	}
sl@0
    74
sl@0
    75
LOCAL_C TBool DriveIsOK(TChar c)
sl@0
    76
/// Test that a selected drive leter is OK to write files.
sl@0
    77
	{
sl@0
    78
	TInt r;
sl@0
    79
	TInt drv;
sl@0
    80
	r=TheFs.CharToDrive(c, drv);
sl@0
    81
	if (r != KErrNone)
sl@0
    82
		return EFalse;
sl@0
    83
	TDriveInfo info;
sl@0
    84
	r=TheFs.Drive(info,drv);
sl@0
    85
	test(r==KErrNone);
sl@0
    86
	return (info.iDriveAtt != 0 && !(info.iDriveAtt & KDriveAttRom));
sl@0
    87
	}
sl@0
    88
sl@0
    89
LOCAL_C TChar MountTestFileSystem(TInt aDrive)
sl@0
    90
//
sl@0
    91
// Mount a new CTestFileSystem on the drive under test
sl@0
    92
//
sl@0
    93
	{
sl@0
    94
	TInt r;
sl@0
    95
	TBuf<64> b;
sl@0
    96
	TChar c;
sl@0
    97
	r=TheFs.DriveToChar(aDrive,c);
sl@0
    98
	test(r==KErrNone);
sl@0
    99
	b.Format(_L("Mount test file system on %c:"),(TUint)c);
sl@0
   100
	test.Next(b);
sl@0
   101
sl@0
   102
	r=TheFs.AddFileSystem(KFsFile);
sl@0
   103
	test(r==KErrNone || r==KErrAlreadyExists);
sl@0
   104
	
sl@0
   105
	r=TheFs.FileSystemName(gOldFsName,aDrive);
sl@0
   106
	test(r==KErrNone || r==KErrNotFound);
sl@0
   107
sl@0
   108
	TDriveInfo drv;
sl@0
   109
	r = TheFs.Drive(drv, aDrive);
sl@0
   110
	test(r == KErrNone);
sl@0
   111
sl@0
   112
	gNoMedia = (drv.iType == EMediaUnknown || drv.iType == EMediaNotPresent);
sl@0
   113
sl@0
   114
	if (gOldFsName.Length() > 0)
sl@0
   115
		{
sl@0
   116
		TTest::Printf(_L("Dismount %C: %S"), (TUint)c, &gOldFsName);
sl@0
   117
		r=TheFs.DismountFileSystem(gOldFsName,aDrive);
sl@0
   118
		test(r==KErrNone);
sl@0
   119
		}
sl@0
   120
sl@0
   121
	r=TheFs.MountFileSystem(KFsName,aDrive);
sl@0
   122
	test(r==KErrNone);
sl@0
   123
sl@0
   124
	r=TheFs.FileSystemName(gNewFsName,aDrive);
sl@0
   125
	test(r==KErrNone);
sl@0
   126
	test(gNewFsName.CompareF(KFsName)==0);
sl@0
   127
	return c;
sl@0
   128
	}
sl@0
   129
sl@0
   130
LOCAL_C void UnmountFileSystem(TInt aDrive)
sl@0
   131
/// Unmount a test filesystem and mount the old one.
sl@0
   132
	{
sl@0
   133
	TChar c;
sl@0
   134
	TInt r=TheFs.DriveToChar(aDrive,c);
sl@0
   135
	test(r==KErrNone);
sl@0
   136
	r=TheFs.DismountFileSystem(gNewFsName,aDrive);
sl@0
   137
	test(r==KErrNone);
sl@0
   138
	// if there's no media present, don't try to mount it
sl@0
   139
	if (gNoMedia)
sl@0
   140
		{
sl@0
   141
		test.Printf(_L("No media on %C: so don't remount it"), (TUint)c);
sl@0
   142
		}
sl@0
   143
	else if (gOldFsName.Length() > 0)
sl@0
   144
		{
sl@0
   145
		test.Printf(_L("Mount    %C: %S"), (TUint)c, &gOldFsName);
sl@0
   146
		r=TheFs.MountFileSystem(gOldFsName,aDrive);
sl@0
   147
		test(r==KErrNone);
sl@0
   148
		}
sl@0
   149
	if (r != KErrNone)
sl@0
   150
		test.Printf(_L("Error %d remounting %S on %C\n"), r, &gOldFsName, (TUint)c);
sl@0
   151
	}
sl@0
   152
sl@0
   153
LOCAL_C void RemountFileSystem(TInt aDrive, TBool aSync)
sl@0
   154
/// Unmount and remount the file system on the specified drive in the
sl@0
   155
/// selected mode.
sl@0
   156
/// @param aDrive Drive number (EDriveC etc.).
sl@0
   157
/// @param aSync  Mount synchronous if true, asynchronous if not.
sl@0
   158
	{
sl@0
   159
	TChar c;
sl@0
   160
	TInt r=TheFs.DriveToChar(aDrive,c);
sl@0
   161
	r=TheFs.FileSystemName(gFsName, aDrive);
sl@0
   162
	test(r==KErrNone || r==KErrNotFound);
sl@0
   163
sl@0
   164
	if (gFsName.Length() > 0)
sl@0
   165
		{
sl@0
   166
		r=TheFs.DismountFileSystem(gFsName, aDrive);
sl@0
   167
		if(r!=KErrNone)
sl@0
   168
			{
sl@0
   169
			test.Printf(_L("Error = %d"),r);
sl@0
   170
			test(EFalse);
sl@0
   171
			}
sl@0
   172
		}
sl@0
   173
sl@0
   174
	TBufC<16> type = _L("asynchronous");
sl@0
   175
	if (aSync)
sl@0
   176
		type = _L("synchronous");
sl@0
   177
	if (gVerbose)
sl@0
   178
		test.Printf(_L("Mount filesystem %c: %-8S as %S\n"), (TUint)c, &gFsName, &type);
sl@0
   179
sl@0
   180
#ifdef __CONCURRENT_FILE_ACCESS__
sl@0
   181
	r=TheFs.MountFileSystem(gFsName, aDrive, aSync);
sl@0
   182
#else
sl@0
   183
	r=TheFs.MountFileSystem(gFsName, aDrive);
sl@0
   184
#endif
sl@0
   185
sl@0
   186
	test(r==KErrNone);
sl@0
   187
	}
sl@0
   188
sl@0
   189
enum TOper
sl@0
   190
	{
sl@0
   191
	ERead,
sl@0
   192
	EWrite
sl@0
   193
	};
sl@0
   194
sl@0
   195
sl@0
   196
// ---------------------------------------------------------------------------
sl@0
   197
sl@0
   198
class RFileOps
sl@0
   199
/// Do operations on a file.
sl@0
   200
	{
sl@0
   201
public:
sl@0
   202
	RFileOps();
sl@0
   203
sl@0
   204
	enum TOper
sl@0
   205
	{
sl@0
   206
	ERead,
sl@0
   207
	EWrite
sl@0
   208
	};
sl@0
   209
	
sl@0
   210
	
sl@0
   211
	TInt Init(TChar dr, TInt aBufSize);
sl@0
   212
	void DeInit();
sl@0
   213
	void CalculateFreeSpace();
sl@0
   214
sl@0
   215
	TInt Open(TOper aOper);
sl@0
   216
	TInt Close();
sl@0
   217
	TInt Delete();
sl@0
   218
	TInt Reset();
sl@0
   219
	TInt Erase();
sl@0
   220
	TInt Write();
sl@0
   221
	TInt Read();
sl@0
   222
	TInt End();
sl@0
   223
	TInt CreateReadFile();
sl@0
   224
sl@0
   225
public:
sl@0
   226
	TFileName      iNameRead;
sl@0
   227
	TFileName      iNameWrite;
sl@0
   228
	RFile          iF;
sl@0
   229
sl@0
   230
	HBufC8* iBuffer[KMaxLag];
sl@0
   231
	TPtr8* iBufPtr[KMaxLag];
sl@0
   232
sl@0
   233
	TRequestStatus iStatus[KMaxLag];
sl@0
   234
	TInt iPtr;
sl@0
   235
	TInt iNum;
sl@0
   236
	TInt iOps;
sl@0
   237
	TInt iMax;
sl@0
   238
	TBool iOpen;
sl@0
   239
	TInt iBufSize;
sl@0
   240
	TChar iDrvCh;
sl@0
   241
	TInt64 iFree;
sl@0
   242
	TInt iFileSize;
sl@0
   243
	// counters
sl@0
   244
	TInt iFileWraps;
sl@0
   245
	TInt iFileSyncAccesses;
sl@0
   246
	TInt iFileAsyncAccesses;
sl@0
   247
	};
sl@0
   248
sl@0
   249
RFileOps::RFileOps() : iPtr(0), iNum(0), iOps(0), iMax(0), iOpen(EFalse)
sl@0
   250
	{
sl@0
   251
	for (TInt i = 0; i < KMaxLag; i++)
sl@0
   252
		{
sl@0
   253
		iStatus[i] = KErrNone;
sl@0
   254
		iBuffer[i] = NULL;
sl@0
   255
		iBufPtr[i] = NULL;
sl@0
   256
		}
sl@0
   257
sl@0
   258
	}
sl@0
   259
sl@0
   260
TInt RFileOps::Init(TChar aDrvCh, TInt aBufSize)
sl@0
   261
	{
sl@0
   262
	TInt r = KErrNone;
sl@0
   263
sl@0
   264
	test(!iOpen);
sl@0
   265
sl@0
   266
	iDrvCh = aDrvCh;
sl@0
   267
	iBufSize = aBufSize;
sl@0
   268
	iNameWrite.Format(_L("%c:\\TESTWT"), (TUint)aDrvCh);
sl@0
   269
	iNameRead.Format(_L("%c:\\TESTRD"), (TUint)aDrvCh);
sl@0
   270
	
sl@0
   271
	for (TInt i = 0; i < KMaxLag; i++)
sl@0
   272
		{
sl@0
   273
		iStatus[i] = KErrNone;
sl@0
   274
sl@0
   275
		iBuffer[i] = HBufC8::NewL(aBufSize);
sl@0
   276
		if (iBuffer[i] == NULL)
sl@0
   277
			return KErrNoMemory;
sl@0
   278
		iBufPtr[i] = new TPtr8(iBuffer[i]->Des());
sl@0
   279
		//TPtr8 buffer(iBuffer[i]->Des());
sl@0
   280
		//buffer.Fill(TChar('_'), aBufSize);
sl@0
   281
		iBufPtr[i]->Fill(TChar('_'), aBufSize);
sl@0
   282
		}
sl@0
   283
sl@0
   284
	return r;
sl@0
   285
	}
sl@0
   286
sl@0
   287
void RFileOps::DeInit()
sl@0
   288
	{
sl@0
   289
	test(!iOpen);
sl@0
   290
sl@0
   291
	for (TInt i = 0; i < KMaxLag; i++)
sl@0
   292
		{
sl@0
   293
		delete iBuffer[i];
sl@0
   294
		iBuffer[i] = NULL;
sl@0
   295
		delete iBufPtr[i];
sl@0
   296
		iBufPtr[i] = NULL;
sl@0
   297
		}
sl@0
   298
sl@0
   299
	}
sl@0
   300
sl@0
   301
void RFileOps::CalculateFreeSpace()
sl@0
   302
	{
sl@0
   303
	TVolumeInfo vol;
sl@0
   304
	TInt        drv;
sl@0
   305
	
sl@0
   306
	
sl@0
   307
	TInt r = TheFs.CharToDrive(iDrvCh, drv);
sl@0
   308
	if (r != KErrNone)
sl@0
   309
		TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), (TUint)iDrvCh, r);
sl@0
   310
sl@0
   311
	r = TheFs.Volume(vol, drv);
sl@0
   312
	if (r != KErrNone)
sl@0
   313
		TTest::Fail(HERE, _L("Volume(%c:) returned %d"), (TUint)iDrvCh, r);
sl@0
   314
sl@0
   315
	iFree = vol.iFree;
sl@0
   316
sl@0
   317
	TInt64 fileSize = iFree / 2;
sl@0
   318
	if (fileSize > KMaxFileSize)
sl@0
   319
		fileSize = KMaxFileSize;
sl@0
   320
	iFileSize = I64LOW(fileSize);
sl@0
   321
sl@0
   322
sl@0
   323
	// calculate the number of buffers to use
sl@0
   324
	// if we assume we'll be able to use half the available disk space
sl@0
   325
	TInt max = iFileSize / iBufSize;
sl@0
   326
	iMax = max;
sl@0
   327
sl@0
   328
    if (gVerbose)
sl@0
   329
		{
sl@0
   330
		test.Printf(_L("Free space on drive %c = %d KB\n"), (TUint)iDrvCh, I64LOW(iFree/1024));
sl@0
   331
		test.Printf(_L("File Size = %d KB. Using %d buffers of size %d\n"), iFileSize/1024, iMax, iBufSize);
sl@0
   332
		}
sl@0
   333
sl@0
   334
	}
sl@0
   335
sl@0
   336
sl@0
   337
TInt RFileOps::Open(TOper aOper)
sl@0
   338
/// Open the file for testing, give error if there is not enough space for it.
sl@0
   339
	{
sl@0
   340
	TInt r;
sl@0
   341
sl@0
   342
	test(!iOpen);
sl@0
   343
sl@0
   344
sl@0
   345
	// reset counters
sl@0
   346
	iFileWraps = 0;
sl@0
   347
	iFileSyncAccesses = 0;
sl@0
   348
	iFileAsyncAccesses = 0;
sl@0
   349
	
sl@0
   350
	TheFs.Delete(iNameWrite);
sl@0
   351
sl@0
   352
	if (aOper == ERead)
sl@0
   353
		{
sl@0
   354
		r = iF.Open(TheFs, iNameRead, EFileStreamText | EFileRead);
sl@0
   355
		if (r != KErrNone)
sl@0
   356
			return r;
sl@0
   357
sl@0
   358
		TInt sizeFile = 0;
sl@0
   359
		r = iF.Size(sizeFile);
sl@0
   360
		test(r == KErrNone);
sl@0
   361
        if (gVerbose)
sl@0
   362
			{
sl@0
   363
			test.Printf(_L("File Size = %d, %d buffers of size %d\n"), sizeFile, iMax, iBufSize);
sl@0
   364
			}
sl@0
   365
		iMax = sizeFile / iBufSize;
sl@0
   366
		}
sl@0
   367
	else
sl@0
   368
		{
sl@0
   369
		CalculateFreeSpace();
sl@0
   370
sl@0
   371
		if (iMax < KMaxLag)
sl@0
   372
			{
sl@0
   373
			test.Printf(_L("Insufficient free space on drive %c, deleting read file\n"), (TUint)iDrvCh);
sl@0
   374
			TInt maxOld = iMax;
sl@0
   375
			TheFs.Delete(iNameRead);
sl@0
   376
			CalculateFreeSpace();
sl@0
   377
			test.Printf(_L("Old available buffers = %d, new available buffers = %d\n"), maxOld, iMax);
sl@0
   378
			}
sl@0
   379
			if (iMax < KMaxLag)
sl@0
   380
				TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available. Only %d buffers of %d bytes available"),
sl@0
   381
												  I64LOW(iFree/1024), iMax, iBufSize );
sl@0
   382
sl@0
   383
		r = iF.Replace(TheFs, iNameWrite, EFileStreamText | EFileWrite);
sl@0
   384
		}
sl@0
   385
sl@0
   386
	if (r == KErrNone)
sl@0
   387
		iOpen = ETrue;
sl@0
   388
sl@0
   389
	
sl@0
   390
	Reset();
sl@0
   391
sl@0
   392
	return r;
sl@0
   393
	}
sl@0
   394
sl@0
   395
// Close and delete the file, returning the number of operations done.
sl@0
   396
TInt RFileOps::Close()
sl@0
   397
	{
sl@0
   398
	if (!iOpen)
sl@0
   399
		return 0;
sl@0
   400
sl@0
   401
	iF.Close();
sl@0
   402
	iOpen = EFalse;
sl@0
   403
sl@0
   404
	// always delete the write file
sl@0
   405
	TheFs.Delete(iNameWrite);
sl@0
   406
	
sl@0
   407
	
sl@0
   408
	return iNum;
sl@0
   409
	}
sl@0
   410
sl@0
   411
TInt RFileOps::Delete()
sl@0
   412
	{
sl@0
   413
	TInt r = TheFs.Delete(iNameRead);
sl@0
   414
	r = TheFs.Delete(iNameWrite);
sl@0
   415
	return r;
sl@0
   416
	}
sl@0
   417
sl@0
   418
sl@0
   419
TInt RFileOps::Reset()
sl@0
   420
/// Reset all of the counts.
sl@0
   421
	{
sl@0
   422
	TInt err = KErrNone;
sl@0
   423
sl@0
   424
	iPtr = 0;
sl@0
   425
	iNum = 0;
sl@0
   426
	iOps = 0;
sl@0
   427
	return err;
sl@0
   428
	}
sl@0
   429
sl@0
   430
TInt RFileOps::CreateReadFile()
sl@0
   431
	{
sl@0
   432
	TInt r = KErrNone;
sl@0
   433
sl@0
   434
	CalculateFreeSpace();	// get iMax
sl@0
   435
sl@0
   436
	if (iOpen)
sl@0
   437
		iF.Close();
sl@0
   438
	iOpen = EFalse;
sl@0
   439
sl@0
   440
sl@0
   441
	r = iF.Open(TheFs, iNameRead, EFileStreamText | EFileRead);
sl@0
   442
	if (r == KErrNone)
sl@0
   443
		{
sl@0
   444
		if (gVerbose)
sl@0
   445
			test.Printf(_L("temp file already exists.\n"));
sl@0
   446
		iF.Close();
sl@0
   447
sl@0
   448
		return r;
sl@0
   449
		}
sl@0
   450
sl@0
   451
sl@0
   452
	r = iF.Replace(TheFs, iNameRead, EFileStreamText | EFileWrite);
sl@0
   453
	if (r != KErrNone)
sl@0
   454
		return r;
sl@0
   455
	
sl@0
   456
	iOpen = ETrue;
sl@0
   457
	
sl@0
   458
	Reset();
sl@0
   459
sl@0
   460
sl@0
   461
	test.Printf(_L("Creating temp file on drive %c of size %d..."), (TUint)iDrvCh, iFileSize);
sl@0
   462
sl@0
   463
	HBufC8* buf = HBufC8::NewL(KMaxBufferSize);
sl@0
   464
	TPtr8 bufptr(buf->Des());
sl@0
   465
	bufptr.Fill(TChar('_'), KMaxBufferSize);
sl@0
   466
sl@0
   467
	test(buf != NULL);
sl@0
   468
	for (TInt pos=0; pos<iFileSize; pos+= buf->Length())
sl@0
   469
		{
sl@0
   470
		r = iF.Write(pos, bufptr);
sl@0
   471
		if (r != KErrNone)
sl@0
   472
			test.Printf(_L("Write() returned %d\n"), r);
sl@0
   473
sl@0
   474
		test(r == KErrNone);
sl@0
   475
		}
sl@0
   476
	delete buf; buf = NULL;
sl@0
   477
sl@0
   478
	//	if (gVerbose)
sl@0
   479
		test.Printf(_L("Done.\n"));
sl@0
   480
sl@0
   481
	iF.Close();
sl@0
   482
	iOpen = EFalse;
sl@0
   483
sl@0
   484
	return r;
sl@0
   485
	}
sl@0
   486
sl@0
   487
TInt RFileOps::Write()
sl@0
   488
/// If there is a free buffer available, start a write.
sl@0
   489
	{
sl@0
   490
	if (!iOpen)
sl@0
   491
		return 0;
sl@0
   492
sl@0
   493
	while (iNum < iOps && iStatus[iNum%KMaxLag] != KRequestPending)
sl@0
   494
		{
sl@0
   495
		TInt status = iStatus[iNum%KMaxLag].Int();
sl@0
   496
		test (status == KErrNone);
sl@0
   497
		iNum++;
sl@0
   498
		}
sl@0
   499
	
sl@0
   500
	if (iOps < KMaxLag || iStatus[iPtr] != KRequestPending)
sl@0
   501
		{
sl@0
   502
		TInt pos = iOps%iMax * iBufSize;
sl@0
   503
sl@0
   504
		iF.Write(pos, *iBufPtr[iPtr], iStatus[iPtr]);
sl@0
   505
sl@0
   506
		TInt status = iStatus[iPtr].Int();
sl@0
   507
sl@0
   508
        if (gVerbose)
sl@0
   509
			{
sl@0
   510
			test.Printf(_L("Writing buf #%d to drive %c at pos %d, status = %d\n"), 
sl@0
   511
				iPtr, (TUint)iDrvCh, pos, status);
sl@0
   512
			}
sl@0
   513
		test (status == KErrNone || status == KRequestPending);
sl@0
   514
sl@0
   515
		iOps++;
sl@0
   516
		iPtr++;
sl@0
   517
		iPtr %= KMaxLag;
sl@0
   518
		return 1;
sl@0
   519
		}
sl@0
   520
	return 0;
sl@0
   521
	}
sl@0
   522
sl@0
   523
TInt RFileOps::Read()
sl@0
   524
/// If there is a free buffer available, start a read.
sl@0
   525
	{
sl@0
   526
	if (!iOpen)
sl@0
   527
		return 0;
sl@0
   528
sl@0
   529
	while (iNum < iOps && iStatus[iNum%KMaxLag] != KRequestPending)
sl@0
   530
		{
sl@0
   531
		TInt status = iStatus[iNum%KMaxLag].Int();
sl@0
   532
		if (status != KErrNone)
sl@0
   533
			test.Printf(_L("drive %c, iNum = %d, iOps=%d, Status = %d\n"), (TUint)iDrvCh, iNum, iOps, status);
sl@0
   534
		test (status == KErrNone);
sl@0
   535
sl@0
   536
		iNum++;
sl@0
   537
		}
sl@0
   538
	if (iOps < KMaxLag || iStatus[iPtr] != KRequestPending)
sl@0
   539
		{
sl@0
   540
		TInt pos = iOps%iMax * iBufSize;
sl@0
   541
sl@0
   542
		iBufPtr[iPtr]->SetLength(0);
sl@0
   543
sl@0
   544
		iF.Read(pos, *iBufPtr[iPtr], iStatus[iPtr]);
sl@0
   545
sl@0
   546
		TInt len = iBufPtr[iPtr]->Length();
sl@0
   547
		TInt status = iStatus[iPtr].Int();
sl@0
   548
		
sl@0
   549
		TInt err = KErrNone;
sl@0
   550
sl@0
   551
		if (status == KErrNone)
sl@0
   552
			{
sl@0
   553
			iFileSyncAccesses++;
sl@0
   554
			if (len < iBufPtr[iPtr]->MaxLength())
sl@0
   555
				err = KErrUnderflow;
sl@0
   556
			}
sl@0
   557
		else if (status == KRequestPending)
sl@0
   558
			{
sl@0
   559
			iFileAsyncAccesses++;
sl@0
   560
			}
sl@0
   561
		else
sl@0
   562
			{
sl@0
   563
			err = status;
sl@0
   564
			}
sl@0
   565
sl@0
   566
		if (gVerbose || err != KErrNone)
sl@0
   567
			{
sl@0
   568
			test.Printf(_L("Reading buf #%d, drive %c, pos %d, status %d, len %d, iNum %d, iOps %d, iMax %d\n"), 
sl@0
   569
				iPtr, (TUint)iDrvCh, pos, status, len, iNum, iOps, iMax);
sl@0
   570
			}
sl@0
   571
sl@0
   572
		test (err == KErrNone);
sl@0
   573
sl@0
   574
		iOps++;
sl@0
   575
		iPtr++;
sl@0
   576
		iPtr %= KMaxLag;
sl@0
   577
sl@0
   578
		// have we wrapped to postion zero ?
sl@0
   579
		if (iOps % iMax == 0)
sl@0
   580
			iFileWraps++;
sl@0
   581
sl@0
   582
		return 1;
sl@0
   583
		}
sl@0
   584
	return 0;
sl@0
   585
	}
sl@0
   586
sl@0
   587
sl@0
   588
TInt RFileOps::End()
sl@0
   589
/// Wait until all outstanding operations have ended, then return the number.
sl@0
   590
	{
sl@0
   591
	if (!iOpen)
sl@0
   592
		return 0;
sl@0
   593
sl@0
   594
	if (gVerbose)
sl@0
   595
		test.Printf(_L("Waiting for reads/writes to %c to complete, iNum=%d, iOps=%d...\n"), (TUint)iDrvCh, iNum, iOps);
sl@0
   596
	
sl@0
   597
	while (iNum < iOps)
sl@0
   598
		{
sl@0
   599
		if (iStatus[iNum%KMaxLag] == KRequestPending)
sl@0
   600
			{
sl@0
   601
			User::WaitForRequest(iStatus[iNum%KMaxLag]);
sl@0
   602
			}
sl@0
   603
		else
sl@0
   604
			{
sl@0
   605
			TInt status = iStatus[iNum%KMaxLag].Int();
sl@0
   606
			if (gVerbose || (status != KErrNone && status != KRequestPending))
sl@0
   607
				test.Printf(_L("Buf#%d: Status = %d\n"), iNum, status);
sl@0
   608
			test (status == KErrNone || status == KRequestPending);
sl@0
   609
			iNum++;
sl@0
   610
			}
sl@0
   611
		}
sl@0
   612
sl@0
   613
	return iNum;
sl@0
   614
	}
sl@0
   615
sl@0
   616
LOCAL_C TInt testAsyncAccess(
sl@0
   617
	TInt aDrive1,
sl@0
   618
	TInt aDrive2, 
sl@0
   619
	TInt aBufSize1, 
sl@0
   620
	TInt aBufSize2, 
sl@0
   621
	TBool aSync1, 
sl@0
   622
	TBool aSync2,
sl@0
   623
	TInt& aThroughput1,
sl@0
   624
	TInt& aThroughput2)
sl@0
   625
//
sl@0
   626
// Test one drive against the other.
sl@0
   627
//
sl@0
   628
    {
sl@0
   629
	TInt r;
sl@0
   630
sl@0
   631
	RFileOps f1;
sl@0
   632
	RFileOps f2;
sl@0
   633
sl@0
   634
	TChar dc1;
sl@0
   635
	TChar dc2;
sl@0
   636
sl@0
   637
	TInt   op1 = 0;
sl@0
   638
	TInt   op2 = 0;
sl@0
   639
	RTimer timer;
sl@0
   640
	TRequestStatus tstat;
sl@0
   641
	TTime startTime;
sl@0
   642
	TTime endTime;
sl@0
   643
	TTimeIntervalMicroSeconds timeTaken(0);
sl@0
   644
	TInt64 dtime;
sl@0
   645
sl@0
   646
	aThroughput1 = aThroughput2 = 0;
sl@0
   647
sl@0
   648
	if (aBufSize1 == 0 && aBufSize2 == 0)
sl@0
   649
		return KErrNone;
sl@0
   650
sl@0
   651
	timer.CreateLocal();
sl@0
   652
sl@0
   653
sl@0
   654
	r = TheFs.DriveToChar(aDrive1, dc1);
sl@0
   655
	test(r == KErrNone);
sl@0
   656
	r = TheFs.DriveToChar(aDrive2, dc2);
sl@0
   657
	test(r == KErrNone);
sl@0
   658
sl@0
   659
	// allocate buffers
sl@0
   660
	r = f1.Init(dc1, aBufSize1);
sl@0
   661
		test(r == KErrNone);
sl@0
   662
	r = f2.Init(dc2, aBufSize2);
sl@0
   663
	test(r == KErrNone);
sl@0
   664
sl@0
   665
	
sl@0
   666
	_LIT(KSync, " sync");
sl@0
   667
	_LIT(KAsync, "async");
sl@0
   668
	if (gVerbose)
sl@0
   669
		test.Printf(_L("%c: (%S) %d, %c: (%S) %d\n"), 
sl@0
   670
			(TUint)dc1, 
sl@0
   671
			aSync1?&KSync:&KAsync,
sl@0
   672
			aBufSize1, 
sl@0
   673
			(TUint)dc2, 
sl@0
   674
			aSync2?&KSync:&KAsync,
sl@0
   675
			aBufSize2);
sl@0
   676
sl@0
   677
	RemountFileSystem(aDrive1, aSync1);
sl@0
   678
	RemountFileSystem(aDrive2, aSync2);
sl@0
   679
sl@0
   680
	if (gReadTests)
sl@0
   681
		{
sl@0
   682
		//********************************************************************
sl@0
   683
		// read test
sl@0
   684
		//********************************************************************
sl@0
   685
sl@0
   686
		if (aBufSize1 > 0)
sl@0
   687
			{
sl@0
   688
			r = f1.CreateReadFile();
sl@0
   689
			test(r == KErrNone);
sl@0
   690
			}
sl@0
   691
		if (aBufSize2 > 0)
sl@0
   692
			{
sl@0
   693
			r = f2.CreateReadFile();
sl@0
   694
			test(r == KErrNone);
sl@0
   695
			}
sl@0
   696
sl@0
   697
		if (aBufSize1 > 0)
sl@0
   698
			r = f1.Open(RFileOps::ERead);
sl@0
   699
		test(r == KErrNone);
sl@0
   700
		
sl@0
   701
		if (aBufSize2 > 0)
sl@0
   702
			r = f2.Open(RFileOps::ERead);
sl@0
   703
		test(r == KErrNone);
sl@0
   704
sl@0
   705
sl@0
   706
		timer.After(tstat, KTimeBM * KSecond);
sl@0
   707
sl@0
   708
		startTime.HomeTime();
sl@0
   709
sl@0
   710
		while (tstat == KRequestPending)
sl@0
   711
			{
sl@0
   712
			TInt num = 0;
sl@0
   713
			if (aBufSize1 > 0)
sl@0
   714
				num = f1.Read();
sl@0
   715
			if (aBufSize2 > 0)
sl@0
   716
				num += f2.Read();
sl@0
   717
			if (num == 0)
sl@0
   718
				User::WaitForAnyRequest();
sl@0
   719
			}
sl@0
   720
		timer.Cancel();	
sl@0
   721
sl@0
   722
		if (aBufSize1 > 0)
sl@0
   723
			op1 = f1.End();
sl@0
   724
		if (aBufSize2 > 0)
sl@0
   725
			op2 = f2.End();
sl@0
   726
sl@0
   727
		endTime.HomeTime();
sl@0
   728
		timeTaken=endTime.MicroSecondsFrom(startTime);
sl@0
   729
sl@0
   730
		//********************************************************************
sl@0
   731
		// Read test end
sl@0
   732
		//********************************************************************
sl@0
   733
		}	// if (gReadTests)
sl@0
   734
		
sl@0
   735
	if (gWriteTests)
sl@0
   736
		{
sl@0
   737
		//********************************************************************
sl@0
   738
		// write test
sl@0
   739
		//********************************************************************
sl@0
   740
		if (aBufSize1 > 0)
sl@0
   741
			{
sl@0
   742
			r = f1.Open(RFileOps::EWrite);
sl@0
   743
			test(r == KErrNone);
sl@0
   744
			}
sl@0
   745
	
sl@0
   746
		if (aBufSize2 > 0)
sl@0
   747
			{
sl@0
   748
			r = f2.Open(RFileOps::EWrite);
sl@0
   749
			test(r == KErrNone);
sl@0
   750
			}
sl@0
   751
sl@0
   752
		timer.After(tstat, KTimeBM * KSecond);
sl@0
   753
sl@0
   754
		startTime.HomeTime();
sl@0
   755
sl@0
   756
		while (tstat == KRequestPending)
sl@0
   757
			{
sl@0
   758
			TInt num = 0;
sl@0
   759
			if (aBufSize1 > 0)
sl@0
   760
				num = f1.Write();
sl@0
   761
			if (aBufSize2 > 0)
sl@0
   762
				num += f2.Write();
sl@0
   763
			if (num == 0)
sl@0
   764
				User::WaitForAnyRequest();
sl@0
   765
			}
sl@0
   766
		timer.Cancel();
sl@0
   767
sl@0
   768
		if (aBufSize1 > 0)
sl@0
   769
			op1 = f1.End();
sl@0
   770
		if (aBufSize2 > 0)
sl@0
   771
			op2 = f2.End();
sl@0
   772
sl@0
   773
sl@0
   774
		endTime.HomeTime();
sl@0
   775
		timeTaken=endTime.MicroSecondsFrom(startTime);
sl@0
   776
sl@0
   777
		//********************************************************************
sl@0
   778
		// Write test end
sl@0
   779
		//********************************************************************
sl@0
   780
sl@0
   781
		}	// if gWriteTests
sl@0
   782
sl@0
   783
	dtime = timeTaken.Int64();
sl@0
   784
sl@0
   785
	aThroughput1 = GetSpeed(op1, aBufSize1, dtime);
sl@0
   786
	aThroughput2 = GetSpeed(op2, aBufSize2, dtime);
sl@0
   787
sl@0
   788
	test.Printf(_L("%c:,%c:,%10d,%10d,%10d,%10d\n"), 
sl@0
   789
		(TUint)dc1, (TUint)dc2, 
sl@0
   790
		aBufSize1,aBufSize2,
sl@0
   791
		aThroughput1,
sl@0
   792
		aThroughput2
sl@0
   793
		);
sl@0
   794
sl@0
   795
	
sl@0
   796
	if (gVerbose)
sl@0
   797
		{
sl@0
   798
		test.Printf(_L("%c: %d async reads, %d sync reads, wraps = %d\n"), 
sl@0
   799
			(TUint)dc1, f1.iFileAsyncAccesses, f1.iFileSyncAccesses, f1.iFileWraps);
sl@0
   800
		test.Printf(_L("%c: %d async reads, %d sync reads, wraps = %d\n"), 
sl@0
   801
			(TUint)dc2, f2.iFileAsyncAccesses, f2.iFileSyncAccesses, f2.iFileWraps);
sl@0
   802
		}
sl@0
   803
sl@0
   804
sl@0
   805
	f1.Close();
sl@0
   806
	f2.Close();
sl@0
   807
sl@0
   808
sl@0
   809
	timer.Close();
sl@0
   810
sl@0
   811
	f1.DeInit();
sl@0
   812
	f2.DeInit();
sl@0
   813
sl@0
   814
	return KErrNone;
sl@0
   815
    }
sl@0
   816
sl@0
   817
LOCAL_C TInt parseCmd(TChar& aDrvCh1, TChar& aDrvCh2)
sl@0
   818
/// Get parameters from the comand line; if there aren't enough then
sl@0
   819
/// prompt the user for them and return KErrAbort if ^C is pressed.
sl@0
   820
	{
sl@0
   821
	while (aDrvCh1 < 'A' || aDrvCh1 > 'Z')
sl@0
   822
		{
sl@0
   823
		test.Printf(_L("Enter drive letter: "));
sl@0
   824
		while (aDrvCh1 < 'A' || aDrvCh1 > 'Z')
sl@0
   825
			{
sl@0
   826
			if (aDrvCh1 == 0x03)
sl@0
   827
				return KErrAbort;
sl@0
   828
			aDrvCh1 = User::UpperCase(test.Getch());
sl@0
   829
			}
sl@0
   830
		if (!DriveIsOK(aDrvCh1))
sl@0
   831
			{
sl@0
   832
			test.Printf(_L("%c: is not a valid drive\n"), (TUint)aDrvCh1);
sl@0
   833
			aDrvCh1 = 0;
sl@0
   834
			}
sl@0
   835
		else
sl@0
   836
			{
sl@0
   837
			TInt drv;
sl@0
   838
			TheFs.CharToDrive(aDrvCh1, drv);
sl@0
   839
			TheFs.FileSystemName(gFsName1, drv);
sl@0
   840
			test.Printf(_L("%c: (%S)\n"), (TUint)aDrvCh1, &gFsName1);
sl@0
   841
			}
sl@0
   842
		}
sl@0
   843
sl@0
   844
	while (aDrvCh2 < 'A' || aDrvCh2 > 'Z')
sl@0
   845
		{
sl@0
   846
		test.Printf(_L("Enter drive letter: "));
sl@0
   847
		while (aDrvCh2 < 'A' || aDrvCh2 > 'Z')
sl@0
   848
			{
sl@0
   849
			if (aDrvCh2 == 0x03)
sl@0
   850
				return KErrAbort;
sl@0
   851
			aDrvCh2 = User::UpperCase(test.Getch());
sl@0
   852
			}
sl@0
   853
		if (!DriveIsOK(aDrvCh2))
sl@0
   854
			{
sl@0
   855
			test.Printf(_L("%c: is not a valid drive\n"), (TUint)aDrvCh2);
sl@0
   856
			aDrvCh2 = 0;
sl@0
   857
			}
sl@0
   858
		else
sl@0
   859
			{
sl@0
   860
			TInt drv;
sl@0
   861
			TheFs.CharToDrive(aDrvCh2, drv);
sl@0
   862
			TheFs.FileSystemName(gFsName2, drv);
sl@0
   863
			test.Printf(_L("%c: (%S)\n"), (TUint)aDrvCh2, &gFsName2);
sl@0
   864
			}
sl@0
   865
		}
sl@0
   866
	return KErrNone;
sl@0
   867
	}
sl@0
   868
sl@0
   869
sl@0
   870
typedef TInt RESULTS[KMaxIter][KMaxIter]; 
sl@0
   871
LOCAL_C void PrintResults(RESULTS& aResults, TChar aDrvCh, TChar aDrvCh2)
sl@0
   872
	{
sl@0
   873
	TInt bufSize2;
sl@0
   874
	TInt drive1Index, drive2Index;
sl@0
   875
sl@0
   876
	test.Printf(_L("*** Throughput for drive %c ***\n"), (TUint)aDrvCh);
sl@0
   877
sl@0
   878
	test.Printf(_L("         BufferSize (%C:)....\n"), (TUint)aDrvCh2);
sl@0
   879
	gResults.Zero();
sl@0
   880
	for (bufSize2 = drive2Index = 0; bufSize2 <= KMaxBufferSize; bufSize2 = bufSize2 << 1, drive2Index++)
sl@0
   881
		{
sl@0
   882
		gResults.AppendFormat(_L("%10d,"), bufSize2);
sl@0
   883
		if (bufSize2 == 0)
sl@0
   884
			bufSize2 = KMinBufferSize >> 1;
sl@0
   885
		}
sl@0
   886
	test.Printf(_L("%S\n"), &gResults);
sl@0
   887
	
sl@0
   888
	for (drive1Index = 0; drive1Index < KMaxIter; drive1Index++)
sl@0
   889
		{
sl@0
   890
		gResults.Zero();
sl@0
   891
		for (drive2Index = 0; drive2Index < KMaxIter; drive2Index++)
sl@0
   892
			{
sl@0
   893
			gResults.AppendFormat(_L("%10d,"), aResults[drive1Index][drive2Index]);
sl@0
   894
			}
sl@0
   895
		test.Printf(_L("%S\n"), &gResults);
sl@0
   896
		}
sl@0
   897
sl@0
   898
	}
sl@0
   899
sl@0
   900
sl@0
   901
//
sl@0
   902
// Do all tests
sl@0
   903
//
sl@0
   904
GLDEF_C void CallTestsL()
sl@0
   905
	{
sl@0
   906
	TInt r = TTest::Init();
sl@0
   907
	test(r == KErrNone);
sl@0
   908
sl@0
   909
	TChar drvch1 = 0;
sl@0
   910
	TChar drvch2 = 0;
sl@0
   911
	TInt  drive1;
sl@0
   912
	TInt  drive2;
sl@0
   913
sl@0
   914
	const TInt KMaxArgs = 5;
sl@0
   915
	TPtrC argv[KMaxArgs];
sl@0
   916
	TInt  argc = TTest::ParseCommandArguments(argv, KMaxArgs);
sl@0
   917
	if (argc > 1)
sl@0
   918
		drvch1 = User::UpperCase(argv[1][0]);
sl@0
   919
	if (argc > 2)
sl@0
   920
		drvch2 = User::UpperCase(argv[2][0]);
sl@0
   921
sl@0
   922
	TBool testFs = EFalse;
sl@0
   923
sl@0
   924
	for (TInt n=3; n<argc; n++)
sl@0
   925
		{
sl@0
   926
		if (argc > 3)
sl@0
   927
			{
sl@0
   928
			if (argv[n].Compare(_L("verbose")) == 0)
sl@0
   929
				gVerbose = ETrue;
sl@0
   930
			if (argv[n].Compare(_L("read")) == 0)
sl@0
   931
				gReadTests = ETrue;
sl@0
   932
			if (argv[n].Compare(_L("write")) == 0)
sl@0
   933
				gWriteTests = ETrue;
sl@0
   934
sl@0
   935
			if (argv[n].Compare(_L("async")) == 0)
sl@0
   936
				gAsyncTests = ETrue;
sl@0
   937
			if (argv[n].Compare(_L("sync")) == 0)
sl@0
   938
				gSyncTests = ETrue;
sl@0
   939
sl@0
   940
			if (argv[n].Compare(_L("testfs")) == 0)
sl@0
   941
				testFs = ETrue;
sl@0
   942
			}
sl@0
   943
		}
sl@0
   944
sl@0
   945
	if ((!gReadTests && !gWriteTests) ||
sl@0
   946
		(!gAsyncTests && !gSyncTests))
sl@0
   947
		{
sl@0
   948
	    test.Printf(_L("T_CFSPERFORM - tests read/write throughput on two drives simultaneously\n"));
sl@0
   949
	    test.Printf(_L("Syntax : t_cfsperform <Drive1> <Drive2> [verbose] [testfs] read|write sync|async\n"));
sl@0
   950
	    test.Printf(_L("Where  : async = concurrent access, sync = non-concurrent access\n"));
sl@0
   951
	    test.Printf(_L("E.g.   : t_cfsperform c d read async\n"));
sl@0
   952
	    test.Printf(_L("Press any key"));
sl@0
   953
		test.Getch();	
sl@0
   954
		test.Printf(_L("\n"));
sl@0
   955
		return;
sl@0
   956
		}
sl@0
   957
sl@0
   958
sl@0
   959
	r = parseCmd(drvch1, drvch2);
sl@0
   960
	if (r != KErrNone)
sl@0
   961
		{
sl@0
   962
		User::Panic(_L("USER ABORT"), 0);
sl@0
   963
		}
sl@0
   964
sl@0
   965
	r = TheFs.CharToDrive(drvch1, drive1);
sl@0
   966
	test(r == KErrNone);
sl@0
   967
	r = TheFs.CharToDrive(drvch2, drive2);
sl@0
   968
	test(r == KErrNone);
sl@0
   969
	
sl@0
   970
	r = TheFs.FileSystemName(gFsName1, drive1);
sl@0
   971
	test(r == KErrNone || r == KErrNotFound);
sl@0
   972
	r = TheFs.FileSystemName(gFsName2, drive2);
sl@0
   973
	test(r == KErrNone || r == KErrNotFound);
sl@0
   974
sl@0
   975
	if (testFs)
sl@0
   976
		{
sl@0
   977
		MountTestFileSystem(drive1);
sl@0
   978
		MountTestFileSystem(drive2);
sl@0
   979
		}
sl@0
   980
sl@0
   981
sl@0
   982
	TInt bufSize1;
sl@0
   983
	TInt bufSize2;
sl@0
   984
sl@0
   985
	// delete temp files before starting
sl@0
   986
	RFileOps f;
sl@0
   987
	f.Init(drvch1, 256);
sl@0
   988
	f.Delete();
sl@0
   989
	f.DeInit();
sl@0
   990
	f.Init(drvch2, 256);
sl@0
   991
	f.Delete();
sl@0
   992
	f.DeInit();
sl@0
   993
sl@0
   994
sl@0
   995
	TInt resultsDrive1[KMaxIter][KMaxIter];
sl@0
   996
	TInt resultsDrive2[KMaxIter][KMaxIter];
sl@0
   997
	TInt drive1Index;
sl@0
   998
	TInt drive2Index;
sl@0
   999
sl@0
  1000
	test.Printf(_L("      BufSize(%c) BufSize(%c) ThruPut(%c) ThruPut(%c) \n"),
sl@0
  1001
				(TUint)drvch1, (TUint)drvch2, (TUint)drvch1, (TUint)drvch2);
sl@0
  1002
sl@0
  1003
	for (bufSize1 = drive1Index = 0; bufSize1 <= KMaxBufferSize; bufSize1 = bufSize1 << 1, drive1Index++)
sl@0
  1004
		{
sl@0
  1005
		for (bufSize2 = drive2Index = 0; bufSize2 <= KMaxBufferSize; bufSize2 = bufSize2 << 1, drive2Index++)
sl@0
  1006
			{
sl@0
  1007
sl@0
  1008
//			// !!! Disable platform security tests until we get the new APIs
sl@0
  1009
//			if (User::Capability() & KCapabilityRoot)
sl@0
  1010
//				{
sl@0
  1011
//				CheckMountLFFS(TheFs, drvch1);
sl@0
  1012
//				CheckMountLFFS(TheFs, drvch2);
sl@0
  1013
//				}
sl@0
  1014
sl@0
  1015
			if (gVerbose)
sl@0
  1016
				test.Printf(_L("Using drives %c: (%S) and %c: (%S)\n"),
sl@0
  1017
							(TUint)drvch1, &gFsName1, (TUint)drvch2, &gFsName2);
sl@0
  1018
sl@0
  1019
			TInt throughputDrive1;
sl@0
  1020
			TInt throughputDrive2;
sl@0
  1021
			TBool sync = EFalse;
sl@0
  1022
			if (gSyncTests)
sl@0
  1023
				sync = ETrue;
sl@0
  1024
sl@0
  1025
			testAsyncAccess(
sl@0
  1026
				drive1, drive2, 
sl@0
  1027
				bufSize1, bufSize2, 
sl@0
  1028
				sync, sync, 
sl@0
  1029
				throughputDrive1, throughputDrive2);
sl@0
  1030
sl@0
  1031
			resultsDrive1[drive1Index][drive2Index] = throughputDrive1;
sl@0
  1032
			resultsDrive2[drive1Index][drive2Index] = throughputDrive2;
sl@0
  1033
sl@0
  1034
			// buffer size sequence is 0,16,32,64,128, ...
sl@0
  1035
			if (bufSize2 == 0)
sl@0
  1036
				bufSize2 = KMinBufferSize >> 1;
sl@0
  1037
			}
sl@0
  1038
		// buffer size sequence is 0,16,32,64,128, ...
sl@0
  1039
		if (bufSize1 == 0)
sl@0
  1040
			bufSize1 = KMinBufferSize >> 1;
sl@0
  1041
		}
sl@0
  1042
sl@0
  1043
sl@0
  1044
sl@0
  1045
	PrintResults(resultsDrive1, drvch1, drvch2);
sl@0
  1046
	PrintResults(resultsDrive2, drvch2, drvch2);
sl@0
  1047
sl@0
  1048
sl@0
  1049
	if (testFs)
sl@0
  1050
		{
sl@0
  1051
		UnmountFileSystem(drive1);
sl@0
  1052
		UnmountFileSystem(drive2);
sl@0
  1053
		}
sl@0
  1054
	test(r == 0);
sl@0
  1055
	}
sl@0
  1056
sl@0
  1057
sl@0
  1058
GLDEF_C TInt E32Main()
sl@0
  1059
// 
sl@0
  1060
// Main entry point
sl@0
  1061
//
sl@0
  1062
    {
sl@0
  1063
	TInt r;
sl@0
  1064
    CTrapCleanup* cleanup;
sl@0
  1065
    cleanup=CTrapCleanup::New();
sl@0
  1066
    __UHEAP_MARK;
sl@0
  1067
sl@0
  1068
    test.Title();
sl@0
  1069
    test.Start(_L("Starting tests..."));
sl@0
  1070
sl@0
  1071
    r=TheFs.Connect();
sl@0
  1072
    test(r==KErrNone);
sl@0
  1073
sl@0
  1074
    // TheFs.SetAllocFailure(gAllocFailOn);
sl@0
  1075
    TTime timerC;
sl@0
  1076
    timerC.HomeTime();
sl@0
  1077
	// Do the tests
sl@0
  1078
    TRAP(r,CallTestsL());
sl@0
  1079
sl@0
  1080
    // reset the debug register
sl@0
  1081
    TheFs.SetDebugRegister(0);
sl@0
  1082
sl@0
  1083
    TTime endTimeC;
sl@0
  1084
    endTimeC.HomeTime();
sl@0
  1085
    TTimeIntervalSeconds timeTakenC;
sl@0
  1086
    r=endTimeC.SecondsFrom(timerC,timeTakenC);
sl@0
  1087
    test(r==KErrNone);
sl@0
  1088
    test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int());
sl@0
  1089
    // TheFs.SetAllocFailure(gAllocFailOff);
sl@0
  1090
    TheFs.Close();
sl@0
  1091
    test.End();
sl@0
  1092
    test.Close();
sl@0
  1093
    __UHEAP_MARKEND;
sl@0
  1094
    delete cleanup;
sl@0
  1095
    return(KErrNone);
sl@0
  1096
    }