os/kernelhwsrv/kerneltest/f32test/bench/t_fat_perf.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) 1996-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
// File Name:		f32test/bench/t_fat_perf.cpp
sl@0
    15
// This file contains implementation for the functions called 
sl@0
    16
// by test cases from the command line to test FAT Performance on
sl@0
    17
// large number of files (PREQ 1885).
sl@0
    18
// 
sl@0
    19
//
sl@0
    20
sl@0
    21
//Include files
sl@0
    22
#include <e32test.h>
sl@0
    23
#include <f32file.h>
sl@0
    24
#include <f32dbg.h>
sl@0
    25
#include "t_server.h"
sl@0
    26
#include "t_fat_perf.h"
sl@0
    27
sl@0
    28
sl@0
    29
sl@0
    30
LOCAL_C void ClearCache(TInt); 
sl@0
    31
sl@0
    32
RTest test(_L("T_FAT_PERF"));
sl@0
    33
sl@0
    34
TFileName 	gPath;
sl@0
    35
TFileName 	gFileNameBase;
sl@0
    36
TInt 		gFileNo = 0;
sl@0
    37
TInt		gTestCase = -1;
sl@0
    38
TInt		gCacheClear = 0;
sl@0
    39
TInt        gZeroPadFileNumberForFixedLengthFileNames = 0;
sl@0
    40
sl@0
    41
sl@0
    42
//-----------------------------------------------------------------------------
sl@0
    43
sl@0
    44
TNamingSchemeParam::TNamingSchemeParam() 
sl@0
    45
    : iConOrRan(EConsecutive), iUniOrAsc(EAscii), iZeroPadFileNumber(EFalse), iMaxFileNameLength(0), iMinStringLength(0)
sl@0
    46
    {
sl@0
    47
    iFileNameBase = _L("");
sl@0
    48
    }
sl@0
    49
sl@0
    50
//-----------------------------------------------------------------------------
sl@0
    51
/**
sl@0
    52
  	This function creates the files in the following directories
sl@0
    53
  	INITIAL CONDITION: FILL FOLLOWING SUB-DIRS WITH 1600 FILES
sl@0
    54
	"\\DIR1\\"...2000 files ("ABCD1ABCD2ABCD3ABCD4ABCD5ABCD_1 ~ 2000.TXT")
sl@0
    55
	"\\DIR1\\DIR11\\"...1600 files ("ABCD1ABCD2ABCD3ABCD4ABCD5ABCD_1 ~ 1600.TXT")
sl@0
    56
	"\\DIR1\\DIR11\\DIR111\\"...1610 files ("ABCD1ABCD2ABCD3ABCD4ABCD5ABCD_1 ~ 1600.TXT") + "ANOTHERLONGFILENAME_1~10.TXT"
sl@0
    57
	"\\DIR1\\DIR12RAN\\"...1600 files ("...random string (31~34)....TXT")
sl@0
    58
	"\\DIR2\\"...1600 files ("ABCD1ABCD2ABCD3ABCD4ABCD5ABCD_1 ~ 1600.TXT")
sl@0
    59
 */
sl@0
    60
//-----------------------------------------------------------------------------
sl@0
    61
sl@0
    62
LOCAL_C void DoTestCaseSetup()
sl@0
    63
	{
sl@0
    64
	test.Next(_L(" 'Test Setup' - 00"));
sl@0
    65
sl@0
    66
	TMLUnitParam mlParam = 
sl@0
    67
		{
sl@0
    68
		12345	// iID
sl@0
    69
		};
sl@0
    70
	CMeasureAndLogUnit* measureAndLogUnit = CMeasureAndLogUnit::NewLC(mlParam);
sl@0
    71
	CExecutionUnit* execUnit = CExecutionUnit::NewLC(measureAndLogUnit, gDriveToTest);
sl@0
    72
sl@0
    73
	TInt curDriveNum;
sl@0
    74
	TInt err = TheFs.CharToDrive(gDriveToTest, curDriveNum);
sl@0
    75
	test(KErrNone == err);
sl@0
    76
	FormatFatDrive(TheFs,curDriveNum, EQuickFormat, NULL, EFalse);
sl@0
    77
sl@0
    78
/*-----------------------------------------------------------------------------
sl@0
    79
 * Setup for "\\DIR1\\"
sl@0
    80
 *-----------------------------------------------------------------------------*/
sl@0
    81
sl@0
    82
   	TNamingSchemeParam namingScheme;
sl@0
    83
	namingScheme.iConOrRan 			       = EConsecutive;
sl@0
    84
	namingScheme.iUniOrAsc 			       = EAscii;
sl@0
    85
	namingScheme.iZeroPadFileNumber   = EFalse;
sl@0
    86
	namingScheme.iFileNameBase 		       = _L("ABCD1ABCD2ABCD3ABCD4ABCD5ABCD_");
sl@0
    87
	namingScheme.iMaxFileNameLength        = 0;
sl@0
    88
	namingScheme.iMinStringLength 	       = 0;
sl@0
    89
	
sl@0
    90
	TDirUnitParam dirParam1;
sl@0
    91
	dirParam1.iPriority 			= 1;
sl@0
    92
	dirParam1.iDirName 				= _L("?:\\DIR1\\");
sl@0
    93
	dirParam1.iRuns 				= 1;
sl@0
    94
	dirParam1.iFilesPerRun 			= 2000;
sl@0
    95
	dirParam1.iSampleInterval 		= 0;
sl@0
    96
	dirParam1.iNamingScheme 		= namingScheme;
sl@0
    97
	dirParam1.iFileOpMode 			= EFATPerfFileCreate;
sl@0
    98
	
sl@0
    99
	execUnit->AddDirUnitL(dirParam1);
sl@0
   100
	
sl@0
   101
/*-----------------------------------------------------------------------------
sl@0
   102
 * Setup for "\\DIR1\\DIR11\\"
sl@0
   103
 *-----------------------------------------------------------------------------*/
sl@0
   104
sl@0
   105
	TDirUnitParam dirParam11		= dirParam1;
sl@0
   106
	dirParam11.iDirName 			= _L("?:\\DIR1\\DIR11\\");
sl@0
   107
	dirParam11.iFilesPerRun			= 1600;
sl@0
   108
	dirParam11.iSampleInterval		= 0;
sl@0
   109
sl@0
   110
	execUnit->AddDirUnitL(dirParam11);
sl@0
   111
	
sl@0
   112
/*-----------------------------------------------------------------------------
sl@0
   113
 * Setup for "\\DIR1\\DIR11\\DIR111\\"
sl@0
   114
 *-----------------------------------------------------------------------------*/
sl@0
   115
sl@0
   116
	TDirUnitParam dirParam111		= dirParam1;
sl@0
   117
	dirParam111.iDirName 			= 	_L("?:\\DIR1\\DIR11\\DIR111\\");
sl@0
   118
	dirParam111.iFilesPerRun		= 1600;
sl@0
   119
	dirParam111.iSampleInterval		= 0;
sl@0
   120
sl@0
   121
	execUnit->AddDirUnitL(dirParam111);
sl@0
   122
sl@0
   123
/*-----------------------------------------------------------------------------
sl@0
   124
 * Test setup for "\\DIR1\\DIR11\\DIR111\\" with "ANOTHERLONGFILENAME_" file
sl@0
   125
 *-----------------------------------------------------------------------------*/
sl@0
   126
sl@0
   127
	TNamingSchemeParam namingScheme111A = namingScheme;
sl@0
   128
	namingScheme111A.iFileNameBase 		= _L("ANOTHERLONGFILENAME_");
sl@0
   129
sl@0
   130
	TDirUnitParam dirParam111A		= dirParam1;
sl@0
   131
	dirParam111A.iDirName 			= 	_L("?:\\DIR1\\DIR11\\DIR111\\");
sl@0
   132
	dirParam111A.iFilesPerRun		= 10;
sl@0
   133
	dirParam111A.iSampleInterval	= 0;
sl@0
   134
	dirParam111A.iNamingScheme 		= namingScheme111A;
sl@0
   135
	
sl@0
   136
	execUnit->AddDirUnitL(dirParam111A);
sl@0
   137
sl@0
   138
/*-----------------------------------------------------------------------------
sl@0
   139
 * Setup for "\\DIR1\\DIR12RAN\\"
sl@0
   140
 *-----------------------------------------------------------------------------*/
sl@0
   141
sl@0
   142
	TNamingSchemeParam namingScheme12 = namingScheme;
sl@0
   143
	namingScheme12.iConOrRan 			   = ERandom;
sl@0
   144
	namingScheme12.iZeroPadFileNumber = EFalse;
sl@0
   145
	namingScheme12.iFileNameBase 		   = _L("");
sl@0
   146
	namingScheme12.iMaxFileNameLength 	   = 34;
sl@0
   147
	namingScheme12.iMinStringLength 	   = 31;
sl@0
   148
sl@0
   149
	TDirUnitParam dirParam12		= dirParam1;
sl@0
   150
	dirParam12.iDirName 			= _L("?:\\DIR1\\DIR12RAN\\");
sl@0
   151
	dirParam12.iFilesPerRun			= 1600;
sl@0
   152
	dirParam12.iSampleInterval		= 0;
sl@0
   153
	dirParam12.iNamingScheme 		= namingScheme12;
sl@0
   154
	
sl@0
   155
	execUnit->AddDirUnitL(dirParam12);
sl@0
   156
sl@0
   157
/*-----------------------------------------------------------------------------
sl@0
   158
 * Setup for "\\DIR2\\"
sl@0
   159
 *-----------------------------------------------------------------------------*/
sl@0
   160
sl@0
   161
	TDirUnitParam dirParam2		= dirParam1;
sl@0
   162
	dirParam2.iDirName 			= _L("?:\\DIR2\\");
sl@0
   163
	dirParam2.iFilesPerRun		= 1600;
sl@0
   164
	dirParam2.iSampleInterval	= 0;
sl@0
   165
	dirParam2.iNamingScheme 	= namingScheme;
sl@0
   166
	
sl@0
   167
	execUnit->AddDirUnitL(dirParam2);
sl@0
   168
sl@0
   169
	execUnit->Run();
sl@0
   170
	CleanupStack::PopAndDestroy(2);
sl@0
   171
	}
sl@0
   172
sl@0
   173
//-----------------------------------------------------------------------------
sl@0
   174
/**
sl@0
   175
This function creates a files in the valid directory path
sl@0
   176
*/
sl@0
   177
//-----------------------------------------------------------------------------
sl@0
   178
LOCAL_C void DoTestCaseCreateFile()
sl@0
   179
	{
sl@0
   180
	test.Next(_L(" 'Create File' - 01"));
sl@0
   181
sl@0
   182
	TMLUnitParam mlParam = 
sl@0
   183
		{
sl@0
   184
		12345	// iID
sl@0
   185
		};
sl@0
   186
	CMeasureAndLogUnit* measureAndLogUnit = CMeasureAndLogUnit::NewLC(mlParam);
sl@0
   187
	CExecutionUnit* execUnit = CExecutionUnit::NewLC(measureAndLogUnit, gDriveToTest);
sl@0
   188
sl@0
   189
	ClearCache(gCacheClear);
sl@0
   190
	
sl@0
   191
	TNamingSchemeParam namingScheme;
sl@0
   192
	namingScheme.iZeroPadFileNumber = 	gZeroPadFileNumberForFixedLengthFileNames;
sl@0
   193
	
sl@0
   194
	TDirUnitParam dirParam1;
sl@0
   195
	dirParam1.iPriority 			= 1;
sl@0
   196
	dirParam1.iDirName 				= _L("");
sl@0
   197
	dirParam1.iRuns 				= 1;
sl@0
   198
	dirParam1.iFilesPerRun 			= 0;
sl@0
   199
	dirParam1.iSampleInterval 		= 1;
sl@0
   200
	dirParam1.iNamingScheme 		= namingScheme;
sl@0
   201
	dirParam1.iFileOpMode 			= EFATPerfFileCreate;
sl@0
   202
	
sl@0
   203
		
sl@0
   204
	TFileName path = _L("?:\\");
sl@0
   205
	path.Append(gPath);
sl@0
   206
	if (path[path.Length() - 1] != '\\')
sl@0
   207
		{
sl@0
   208
		path.Append('\\');
sl@0
   209
		}
sl@0
   210
	
sl@0
   211
	dirParam1.iDirName = path;
sl@0
   212
	dirParam1.iFilesPerRun = gFileNo;
sl@0
   213
	dirParam1.iNamingScheme.iFileNameBase = gFileNameBase;
sl@0
   214
sl@0
   215
	execUnit->AddDirUnitL(dirParam1);
sl@0
   216
	execUnit->Run();
sl@0
   217
sl@0
   218
	CleanupStack::PopAndDestroy(2);
sl@0
   219
	
sl@0
   220
	}
sl@0
   221
sl@0
   222
//-----------------------------------------------------------------------------
sl@0
   223
/**
sl@0
   224
This function opens file in the valid directoy path
sl@0
   225
*/
sl@0
   226
//-----------------------------------------------------------------------------
sl@0
   227
sl@0
   228
LOCAL_C void DoTestCaseOpenFile()
sl@0
   229
	{
sl@0
   230
	test.Next(_L(" 'Open File' - 02"));
sl@0
   231
sl@0
   232
	TMLUnitParam mlParam = 
sl@0
   233
		{
sl@0
   234
		12345	// iID
sl@0
   235
		};
sl@0
   236
	CMeasureAndLogUnit* measureAndLogUnit = CMeasureAndLogUnit::NewLC(mlParam);
sl@0
   237
	CExecutionUnit* execUnit = CExecutionUnit::NewLC(measureAndLogUnit, gDriveToTest);
sl@0
   238
sl@0
   239
	ClearCache(gCacheClear);
sl@0
   240
	
sl@0
   241
	TNamingSchemeParam namingScheme;
sl@0
   242
	namingScheme.iZeroPadFileNumber = gZeroPadFileNumberForFixedLengthFileNames;
sl@0
   243
	
sl@0
   244
	TDirUnitParam dirParam1;
sl@0
   245
	dirParam1.iPriority 			= 1;
sl@0
   246
	dirParam1.iDirName 				= _L("");
sl@0
   247
	dirParam1.iRuns 				= 1;
sl@0
   248
	dirParam1.iFilesPerRun 			= 0;
sl@0
   249
	dirParam1.iSampleInterval 		= 1;
sl@0
   250
	dirParam1.iNamingScheme 		= namingScheme;
sl@0
   251
	dirParam1.iFileOpMode 			= EFATPerfFileOpen;
sl@0
   252
	
sl@0
   253
	
sl@0
   254
	TFileName path = _L("?:\\");
sl@0
   255
	path.Append(gPath);
sl@0
   256
	if (path[path.Length() - 1] != '\\')
sl@0
   257
		{
sl@0
   258
		path.Append('\\');
sl@0
   259
		}
sl@0
   260
	
sl@0
   261
	dirParam1.iDirName = path;
sl@0
   262
	dirParam1.iFilesPerRun = gFileNo;
sl@0
   263
	dirParam1.iNamingScheme.iFileNameBase = gFileNameBase;
sl@0
   264
sl@0
   265
	execUnit->AddDirUnitL(dirParam1);
sl@0
   266
	execUnit->Run();
sl@0
   267
sl@0
   268
	CleanupStack::PopAndDestroy(2);
sl@0
   269
	
sl@0
   270
	}
sl@0
   271
sl@0
   272
//-----------------------------------------------------------------------------
sl@0
   273
/**
sl@0
   274
This function deletes the files in the valid directory path
sl@0
   275
*/
sl@0
   276
//-----------------------------------------------------------------------------
sl@0
   277
sl@0
   278
LOCAL_C void DoTestCaseDeleteFile()
sl@0
   279
	{
sl@0
   280
	test.Next(_L(" 'Delete File' - 03"));
sl@0
   281
sl@0
   282
	TMLUnitParam mlParam = 
sl@0
   283
		{
sl@0
   284
		12345	// iID
sl@0
   285
		};
sl@0
   286
	CMeasureAndLogUnit* measureAndLogUnit = CMeasureAndLogUnit::NewLC(mlParam);
sl@0
   287
	CExecutionUnit* execUnit = CExecutionUnit::NewLC(measureAndLogUnit, gDriveToTest);
sl@0
   288
sl@0
   289
	ClearCache(gCacheClear);
sl@0
   290
	
sl@0
   291
	TNamingSchemeParam namingScheme;
sl@0
   292
	namingScheme.iZeroPadFileNumber = gZeroPadFileNumberForFixedLengthFileNames;
sl@0
   293
	
sl@0
   294
	TDirUnitParam dirParam1;
sl@0
   295
	dirParam1.iPriority 			= 1;
sl@0
   296
	dirParam1.iDirName 				= _L("");
sl@0
   297
	dirParam1.iRuns 				= 1;
sl@0
   298
	dirParam1.iFilesPerRun 			= 0;
sl@0
   299
	dirParam1.iSampleInterval 		= 1;
sl@0
   300
	dirParam1.iNamingScheme 		= namingScheme;
sl@0
   301
	dirParam1.iFileOpMode 			= EFATPerfFileDelete;
sl@0
   302
	
sl@0
   303
	TFileName path = _L("?:\\");
sl@0
   304
	path.Append(gPath);
sl@0
   305
	if (path[path.Length() - 1] != '\\')
sl@0
   306
		{
sl@0
   307
		path.Append('\\');
sl@0
   308
		}
sl@0
   309
	
sl@0
   310
	dirParam1.iDirName = path;
sl@0
   311
	dirParam1.iFilesPerRun = gFileNo;
sl@0
   312
	dirParam1.iNamingScheme.iFileNameBase = gFileNameBase;
sl@0
   313
sl@0
   314
	execUnit->AddDirUnitL(dirParam1);
sl@0
   315
	execUnit->Run();
sl@0
   316
sl@0
   317
	CleanupStack::PopAndDestroy(2);
sl@0
   318
	
sl@0
   319
	}
sl@0
   320
sl@0
   321
//-----------------------------------------------------------------------------
sl@0
   322
/**
sl@0
   323
PREQ1885  - optional test case 
sl@0
   324
This function writes data into the files in the valid directory path
sl@0
   325
*/
sl@0
   326
//-----------------------------------------------------------------------------
sl@0
   327
sl@0
   328
LOCAL_C void DoTestCaseWriteFile()
sl@0
   329
	{
sl@0
   330
	test.Next(_L(" 'Write File'  - 04 - Write 4KB of Data"));
sl@0
   331
sl@0
   332
	TMLUnitParam mlParam = 
sl@0
   333
		{
sl@0
   334
		12345	// iID
sl@0
   335
		};
sl@0
   336
	CMeasureAndLogUnit* measureAndLogUnit = CMeasureAndLogUnit::NewLC(mlParam);
sl@0
   337
	CExecutionUnit* execUnit = CExecutionUnit::NewLC(measureAndLogUnit, gDriveToTest);
sl@0
   338
sl@0
   339
	ClearCache(gCacheClear);
sl@0
   340
	
sl@0
   341
	TNamingSchemeParam namingScheme;
sl@0
   342
	namingScheme.iZeroPadFileNumber = gZeroPadFileNumberForFixedLengthFileNames;
sl@0
   343
sl@0
   344
	TDirUnitParam dirParam1;
sl@0
   345
	dirParam1.iPriority 			= 1;
sl@0
   346
	dirParam1.iDirName 				= _L("");
sl@0
   347
	dirParam1.iRuns 				= 1;
sl@0
   348
	dirParam1.iFilesPerRun 			= 0;
sl@0
   349
	dirParam1.iSampleInterval 		= 1;
sl@0
   350
	dirParam1.iNamingScheme 		= namingScheme;
sl@0
   351
	dirParam1.iFileOpMode 			= EFATPerfFileWrite;
sl@0
   352
	
sl@0
   353
	TFileName path = _L("?:\\");
sl@0
   354
	path.Append(gPath);
sl@0
   355
	if (path[path.Length() - 1] != '\\')
sl@0
   356
		{
sl@0
   357
		path.Append('\\');
sl@0
   358
		}
sl@0
   359
	
sl@0
   360
	dirParam1.iDirName = path;
sl@0
   361
	dirParam1.iFilesPerRun = gFileNo;
sl@0
   362
	dirParam1.iNamingScheme.iFileNameBase = gFileNameBase;
sl@0
   363
sl@0
   364
	execUnit->AddDirUnitL(dirParam1);
sl@0
   365
	execUnit->Run();
sl@0
   366
sl@0
   367
	CleanupStack::PopAndDestroy(2);
sl@0
   368
	
sl@0
   369
	}
sl@0
   370
sl@0
   371
//-----------------------------------------------------------------------------
sl@0
   372
/**
sl@0
   373
PREQ1885  - optional test case  
sl@0
   374
This function Reads data from the files in the valid directory path
sl@0
   375
*/
sl@0
   376
//-----------------------------------------------------------------------------
sl@0
   377
sl@0
   378
LOCAL_C void DoTestCaseReadFile()
sl@0
   379
	{
sl@0
   380
	test.Next(_L(" 'Read File' - 05 Read 4KB of data"));
sl@0
   381
sl@0
   382
	TMLUnitParam mlParam = 
sl@0
   383
		{
sl@0
   384
		12345	// iID
sl@0
   385
		};
sl@0
   386
	CMeasureAndLogUnit* measureAndLogUnit = CMeasureAndLogUnit::NewLC(mlParam);
sl@0
   387
	CExecutionUnit* execUnit = CExecutionUnit::NewLC(measureAndLogUnit, gDriveToTest);
sl@0
   388
sl@0
   389
	ClearCache(gCacheClear);
sl@0
   390
		
sl@0
   391
	TNamingSchemeParam namingScheme;
sl@0
   392
    namingScheme.iZeroPadFileNumber = gZeroPadFileNumberForFixedLengthFileNames;
sl@0
   393
    
sl@0
   394
	TDirUnitParam dirParam1;
sl@0
   395
	dirParam1.iPriority 			= 1;
sl@0
   396
	dirParam1.iDirName 				= _L("");
sl@0
   397
	dirParam1.iRuns 				= 1;
sl@0
   398
	dirParam1.iFilesPerRun 			= 0;
sl@0
   399
	dirParam1.iSampleInterval 		= 1;
sl@0
   400
	dirParam1.iNamingScheme 		= namingScheme;
sl@0
   401
	dirParam1.iFileOpMode 			= EFATPerfFileRead;
sl@0
   402
	
sl@0
   403
sl@0
   404
	TFileName path = _L("?:\\");
sl@0
   405
	path.Append(gPath);
sl@0
   406
	if (path[path.Length() - 1] != '\\')
sl@0
   407
		{
sl@0
   408
		path.Append('\\');
sl@0
   409
		}
sl@0
   410
	
sl@0
   411
	dirParam1.iDirName = path;
sl@0
   412
	dirParam1.iFilesPerRun = gFileNo;
sl@0
   413
	dirParam1.iNamingScheme.iFileNameBase = gFileNameBase;
sl@0
   414
sl@0
   415
	execUnit->AddDirUnitL(dirParam1);
sl@0
   416
	execUnit->Run();
sl@0
   417
sl@0
   418
	CleanupStack::PopAndDestroy(2);
sl@0
   419
	
sl@0
   420
	}
sl@0
   421
sl@0
   422
//-----------------------------------------------------------------------------
sl@0
   423
/**
sl@0
   424
This function Dumps the information about Directory Cache
sl@0
   425
*/
sl@0
   426
//
sl@0
   427
LOCAL_C void DoTestCaseDirCacheInfo()
sl@0
   428
	{
sl@0
   429
	ClearCache(gCacheClear);
sl@0
   430
	RDebug::Print(_L("Dumping DirCache Info - Only for DEBUG Mode \n"));
sl@0
   431
	#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
sl@0
   432
        TInt ret = TheFs.ControlIo(CurrentDrive(), ETestFATDirCacheInfo);    // For DirCache info
sl@0
   433
        if (ret != KErrNone)
sl@0
   434
            {
sl@0
   435
            RDebug::Print(_L("RFs::ControlIo() returned %d when attempting to dump cache info"), ret);
sl@0
   436
            }
sl@0
   437
        ret = TheFs.ControlIo(CurrentDrive(), ETestDumpFATDirCache);  // For Dumping DirCache contents
sl@0
   438
        if (ret != KErrNone)
sl@0
   439
            {
sl@0
   440
            RDebug::Print(_L("RFs::ControlIo() returned %d when attempting to dump cache contents"), ret);
sl@0
   441
            }
sl@0
   442
	#endif
sl@0
   443
	}
sl@0
   444
sl@0
   445
/* To clear the cache - remount drive */
sl@0
   446
sl@0
   447
LOCAL_C void ClearCache(TInt gCacheClear)
sl@0
   448
    {
sl@0
   449
    TInt rel = KErrNone;
sl@0
   450
    if (gCacheClear == 1)
sl@0
   451
        {
sl@0
   452
        // Remount the drive to clear the cache 
sl@0
   453
        rel = RemountFS (TheFs, CurrentDrive(), NULL);
sl@0
   454
        if (rel != KErrNone)
sl@0
   455
            {
sl@0
   456
            RDebug::Print(_L("<<Error>>: Remounting: %d\n"), rel);
sl@0
   457
            User::Leave(rel);
sl@0
   458
            }	
sl@0
   459
        }
sl@0
   460
sl@0
   461
    }
sl@0
   462
sl@0
   463
sl@0
   464
/* Function for command line arguments for the tests */
sl@0
   465
LOCAL_C void ParseMyCommandArguments()
sl@0
   466
	{
sl@0
   467
	TBuf<0x100> cmd;
sl@0
   468
	User::CommandLine(cmd);
sl@0
   469
	TLex lex(cmd);
sl@0
   470
	TPtrC token=lex.NextToken();
sl@0
   471
	TFileName thisfile=RProcess().FileName();
sl@0
   472
	if (token.MatchF(thisfile)==0)
sl@0
   473
		{
sl@0
   474
		token.Set(lex.NextToken());
sl@0
   475
		}
sl@0
   476
	test.Printf(_L("CLP=%S"),&token);
sl@0
   477
sl@0
   478
	if(token.Length()!=0)		
sl@0
   479
		{
sl@0
   480
		gDriveToTest=token[0];
sl@0
   481
		gDriveToTest.UpperCase();
sl@0
   482
		}
sl@0
   483
	else
sl@0
   484
		{
sl@0
   485
		gDriveToTest='C';
sl@0
   486
		return;
sl@0
   487
		}
sl@0
   488
sl@0
   489
	while (!lex.Eos())
sl@0
   490
		{
sl@0
   491
		token.Set(lex.NextToken());
sl@0
   492
		if (token.Compare(_L("-c")) == 0 || token.Compare(_L("-C")) == 0)
sl@0
   493
			{
sl@0
   494
			token.Set(lex.NextToken());
sl@0
   495
			if (token.MatchF(_L("Setup"))==0)
sl@0
   496
				{
sl@0
   497
				
sl@0
   498
				gTestCase = EFATPerfSetup;
sl@0
   499
				
sl@0
   500
				}
sl@0
   501
			else if (token.MatchF(_L("Create"))==0)
sl@0
   502
				{
sl@0
   503
				
sl@0
   504
				gTestCase = EFATPerfCreate; 
sl@0
   505
				
sl@0
   506
				}
sl@0
   507
			
sl@0
   508
			else if (token.MatchF(_L("Open"))==0)
sl@0
   509
				{
sl@0
   510
				
sl@0
   511
				gTestCase = EFATPerfOpen;
sl@0
   512
				
sl@0
   513
				}
sl@0
   514
			
sl@0
   515
			else if (token.MatchF(_L("Delete"))==0)
sl@0
   516
			
sl@0
   517
				{
sl@0
   518
				
sl@0
   519
				gTestCase = EFATPerfDelete;
sl@0
   520
				
sl@0
   521
				}
sl@0
   522
			
sl@0
   523
			else if (token.MatchF(_L("Write"))==0)
sl@0
   524
				{
sl@0
   525
sl@0
   526
				gTestCase = EFATPerfWrite;
sl@0
   527
	
sl@0
   528
				}
sl@0
   529
			
sl@0
   530
			else if (token.MatchF(_L("Read"))==0)
sl@0
   531
		
sl@0
   532
				{
sl@0
   533
				
sl@0
   534
				gTestCase = EFATPerfRead;
sl@0
   535
		
sl@0
   536
				}	
sl@0
   537
			else if (token.MatchF(_L("Dumpinfo"))==0)
sl@0
   538
				{
sl@0
   539
				gTestCase = EFATPerfDirCacheInfo;
sl@0
   540
				}
sl@0
   541
			else
sl@0
   542
				{
sl@0
   543
				test.Printf(_L("Bad command syntax"));
sl@0
   544
				test(EFalse);
sl@0
   545
				}
sl@0
   546
			}
sl@0
   547
		
sl@0
   548
		if (token.Compare(_L("-p")) == 0 || token.Compare(_L("-P")) == 0)
sl@0
   549
			{
sl@0
   550
			token.Set(lex.NextToken());
sl@0
   551
			if (token.Length() != 0)
sl@0
   552
				{
sl@0
   553
				gPath = token;
sl@0
   554
				}
sl@0
   555
			else
sl@0
   556
				{
sl@0
   557
				test.Printf(_L("Bad command syntax"));
sl@0
   558
				test(EFalse);
sl@0
   559
				}
sl@0
   560
			}
sl@0
   561
		
sl@0
   562
		if (token.Compare(_L("-b")) == 0 || token.Compare(_L("-B")) == 0)
sl@0
   563
			{
sl@0
   564
			token.Set(lex.NextToken());
sl@0
   565
			if (token.Length() != 0)
sl@0
   566
				{
sl@0
   567
				gFileNameBase = token;
sl@0
   568
				}
sl@0
   569
			else
sl@0
   570
				{
sl@0
   571
				test.Printf(_L("Bad command syntax"));
sl@0
   572
				test(EFalse);
sl@0
   573
				}
sl@0
   574
			}
sl@0
   575
		
sl@0
   576
		if (token.Compare(_L("-n")) == 0 || token.Compare(_L("-N")) == 0)
sl@0
   577
			{
sl@0
   578
			token.Set(lex.NextToken());
sl@0
   579
			if (token.Length() != 0)
sl@0
   580
				{
sl@0
   581
				TLex tokenLex;
sl@0
   582
				tokenLex.Assign(token);
sl@0
   583
				TInt value;
sl@0
   584
				tokenLex.Val(value);
sl@0
   585
				gFileNo = value;
sl@0
   586
				}
sl@0
   587
			else
sl@0
   588
				{
sl@0
   589
				test.Printf(_L("Bad command syntax"));
sl@0
   590
				test(EFalse);
sl@0
   591
				}
sl@0
   592
			}
sl@0
   593
			
sl@0
   594
		if (token.Compare(_L("-m")) == 0 || token.Compare(_L("-M")) == 0)
sl@0
   595
			{
sl@0
   596
			token.Set(lex.NextToken());
sl@0
   597
			if (token.Length() != 0)
sl@0
   598
				{
sl@0
   599
				TLex tokenLex;
sl@0
   600
				tokenLex.Assign(token);
sl@0
   601
				TInt value;
sl@0
   602
				tokenLex.Val(value);
sl@0
   603
				gCacheClear = value;
sl@0
   604
				}
sl@0
   605
			else
sl@0
   606
				{
sl@0
   607
				test.Printf(_L("Bad command syntax"));
sl@0
   608
				test(EFalse);
sl@0
   609
				}
sl@0
   610
			}
sl@0
   611
		
sl@0
   612
        if (token.Compare(_L("-f")) == 0 || token.Compare(_L("-F")) == 0)
sl@0
   613
            {
sl@0
   614
            token.Set(lex.NextToken());
sl@0
   615
            if (token.Length() != 0)
sl@0
   616
                {
sl@0
   617
                TLex tokenLex;
sl@0
   618
                tokenLex.Assign(token);
sl@0
   619
                TInt value;
sl@0
   620
                tokenLex.Val(value);
sl@0
   621
                gZeroPadFileNumberForFixedLengthFileNames = value;
sl@0
   622
                }
sl@0
   623
            else
sl@0
   624
                {
sl@0
   625
                test.Printf(_L("Bad command syntax"));
sl@0
   626
                test(EFalse);
sl@0
   627
                }
sl@0
   628
            }
sl@0
   629
		}
sl@0
   630
	}
sl@0
   631
sl@0
   632
sl@0
   633
/* System Info */
sl@0
   634
LOCAL_C void GetSystemInfo()
sl@0
   635
	{
sl@0
   636
	test.Next(_L("Get System Info"));
sl@0
   637
	TFSName fsName;
sl@0
   638
	TInt drvNo = -1; 
sl@0
   639
	TInt err = TheFs.CharToDrive(gDriveToTest, drvNo);
sl@0
   640
	test(err == KErrNone);
sl@0
   641
	err = TheFs.FileSystemSubType(drvNo, fsName);
sl@0
   642
	test(err == KErrNone);
sl@0
   643
	test.Printf(_L("File System: [%S]\n"), &fsName);
sl@0
   644
	TVolumeIOParamInfo ioParam;
sl@0
   645
	err = TheFs.VolumeIOParam(drvNo, ioParam);
sl@0
   646
	test(err == KErrNone);
sl@0
   647
	test.Printf(_L("Sector Size: [%d Bytes]\n"), ioParam.iBlockSize);
sl@0
   648
	test.Printf(_L("Cluster Size: [%d Bytes]\n"), ioParam.iClusterSize);
sl@0
   649
	}
sl@0
   650
sl@0
   651
//-----------------------------------------------------------------------------
sl@0
   652
/**
sl@0
   653
Main Function to call specific test features
sl@0
   654
*/
sl@0
   655
//-----------------------------------------------------------------------------
sl@0
   656
void CallTestsL()
sl@0
   657
	{
sl@0
   658
	
sl@0
   659
	//Interpreting Command Line Arguments
sl@0
   660
	ParseMyCommandArguments(); 
sl@0
   661
	
sl@0
   662
sl@0
   663
	// Get Drive Information
sl@0
   664
	GetSystemInfo(); 
sl@0
   665
 	
sl@0
   666
 	
sl@0
   667
 	// Switch Case for Test Functions
sl@0
   668
 	switch(gTestCase)
sl@0
   669
		{
sl@0
   670
	
sl@0
   671
	    //Test Setup
sl@0
   672
		case EFATPerfSetup:    
sl@0
   673
			{
sl@0
   674
			DoTestCaseSetup();
sl@0
   675
			break;
sl@0
   676
			}
sl@0
   677
		
sl@0
   678
		//File Create
sl@0
   679
		case EFATPerfCreate:
sl@0
   680
			{
sl@0
   681
			DoTestCaseCreateFile();
sl@0
   682
			break;
sl@0
   683
			}
sl@0
   684
	  	
sl@0
   685
	  	// File Open 
sl@0
   686
		case EFATPerfOpen:
sl@0
   687
			{
sl@0
   688
			DoTestCaseOpenFile();
sl@0
   689
			break;
sl@0
   690
			}
sl@0
   691
		
sl@0
   692
		// File Delete
sl@0
   693
		case EFATPerfDelete:
sl@0
   694
			{
sl@0
   695
			DoTestCaseDeleteFile();
sl@0
   696
			break;
sl@0
   697
			}
sl@0
   698
		// File Write
sl@0
   699
		case EFATPerfWrite:
sl@0
   700
			{
sl@0
   701
			DoTestCaseWriteFile();
sl@0
   702
			break;
sl@0
   703
			}
sl@0
   704
		
sl@0
   705
		// File Read
sl@0
   706
		case EFATPerfRead:
sl@0
   707
			{
sl@0
   708
			DoTestCaseReadFile();
sl@0
   709
			break;
sl@0
   710
			}
sl@0
   711
		// Print / Dump DirCache Info
sl@0
   712
		case EFATPerfDirCacheInfo:
sl@0
   713
			{
sl@0
   714
			DoTestCaseDirCacheInfo();
sl@0
   715
			break;
sl@0
   716
			}
sl@0
   717
		
sl@0
   718
		default:
sl@0
   719
			break;
sl@0
   720
		}
sl@0
   721
sl@0
   722
	}
sl@0
   723
sl@0
   724
/*-- EOF--*/