os/kernelhwsrv/kerneltest/f32test/bench/t_fsrdirload.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) 2006-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
// f32test\bench\t_fsrdirload.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <f32file.h>
sl@0
    19
#include <e32test.h>
sl@0
    20
#include "t_select.h"
sl@0
    21
#include "..\server\t_server.h"
sl@0
    22
#include "t_benchmain.h"
sl@0
    23
sl@0
    24
sl@0
    25
GLDEF_D RTest test(_L("File Server Benchmarks, Dir Load"));
sl@0
    26
sl@0
    27
//----------------------------------------------------------------------------------------------
sl@0
    28
//! @SYMTestCaseID      PBASE-T_FSRDIRLOAD-0273
sl@0
    29
//! @SYMTestType        CIT
sl@0
    30
//! @SYMPREQ            PREQ000
sl@0
    31
//! @SYMTestCaseDesc    This test case is measuring performance of the FAT implementation.  
sl@0
    32
//! @SYMTestActions     0.  Expects the files to exist in order to successful execution
sl@0
    33
//!						1.	Time the listing of each directory sorted by name
sl@0
    34
//!						2.	Time the listing of each directory sorted by extension
sl@0
    35
//!						3.	Time the listing of each directory sorted by size
sl@0
    36
//!						4.	Time the listing of each directory sorted by date
sl@0
    37
//!						5.	Time the search of each file in a directory sorted by name
sl@0
    38
//!						6.	Time the search of each file in a directory sorted by extension
sl@0
    39
//!						7.	Time the search of each file in a directory sorted by size
sl@0
    40
//!						8.	Time the search of each file in a directory sorted by date
sl@0
    41
//!
sl@0
    42
//! @SYMTestExpectedResults Finishes if the system behaves as expected, panics otherwise
sl@0
    43
//! @SYMTestPriority        High
sl@0
    44
//! @SYMTestStatus          Implemented
sl@0
    45
//----------------------------------------------------------------------------------------------
sl@0
    46
sl@0
    47
sl@0
    48
LOCAL_D RSemaphore client;
sl@0
    49
LOCAL_D TRequestStatus stat;
sl@0
    50
LOCAL_D TBuf8<4096> buf;
sl@0
    51
sl@0
    52
LOCAL_D TDriveList gDriveList;
sl@0
    53
sl@0
    54
sl@0
    55
_LIT(KDirMultipleName2, "dir%d_%d\\");
sl@0
    56
sl@0
    57
/** Sort a directory with different criterias 
sl@0
    58
sl@0
    59
	@param aN 		Number of files in the directory
sl@0
    60
	@param aKey		Type of sorting to use
sl@0
    61
	@param aStep 	Test step
sl@0
    62
*/
sl@0
    63
LOCAL_C TInt SortFile(TInt aN, TEntryKey aKey, TInt aStep)
sl@0
    64
	{
sl@0
    65
	TBuf16<100> dir1;
sl@0
    66
	TBuf16<100> dir2;
sl@0
    67
	TBuf16<100> dir3;
sl@0
    68
    TBuf16<100> temp;
sl@0
    69
	
sl@0
    70
	TInt r = 0;
sl@0
    71
	TTime startTime;
sl@0
    72
	TTime endTime;
sl@0
    73
	TTimeIntervalMicroSeconds timeTaken(0);
sl@0
    74
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
sl@0
    75
sl@0
    76
	if(aN <= gFilesLimit) 
sl@0
    77
		{	
sl@0
    78
		CDir* dirPtr;
sl@0
    79
			
sl@0
    80
		dir1 = gSessionPath;
sl@0
    81
		dir2 = gSessionPath;
sl@0
    82
		dir3 = gSessionPath;
sl@0
    83
		
sl@0
    84
		temp.Format(KDirMultipleName2, 1, aN);
sl@0
    85
		dir1.Append(temp);
sl@0
    86
		
sl@0
    87
		temp.Format(KDirMultipleName2, 2, aN);
sl@0
    88
		dir2.Append(temp);
sl@0
    89
		
sl@0
    90
		temp.Format(KDirMultipleName2, 3, aN);
sl@0
    91
		dir3.Append(temp);
sl@0
    92
		
sl@0
    93
		dir1.Append(_L("*.*"));
sl@0
    94
		dir2.Append(_L("*.*"));
sl@0
    95
		dir3.Append(_L("*.*"));
sl@0
    96
		
sl@0
    97
		if(gTypes >= 1) 
sl@0
    98
			{		
sl@0
    99
			startTime.HomeTime();
sl@0
   100
			r = TheFs.GetDir(dir1,KEntryAttMaskSupported,ESortNone,dirPtr);
sl@0
   101
			FailIfError(r);
sl@0
   102
sl@0
   103
			r = dirPtr->Sort(aKey);
sl@0
   104
			FailIfError(r);
sl@0
   105
sl@0
   106
			endTime.HomeTime();
sl@0
   107
			delete dirPtr;
sl@0
   108
			
sl@0
   109
			timeTaken = endTime.MicroSecondsFrom(startTime);
sl@0
   110
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   111
			}
sl@0
   112
sl@0
   113
		if(gTypes >= 2) 
sl@0
   114
			{	
sl@0
   115
			startTime.HomeTime();
sl@0
   116
			r = TheFs.GetDir(dir2,KEntryAttMaskSupported,ESortNone,dirPtr);
sl@0
   117
			FailIfError(r);
sl@0
   118
			
sl@0
   119
			r = dirPtr->Sort(aKey);
sl@0
   120
			FailIfError(r);
sl@0
   121
			endTime.HomeTime();
sl@0
   122
			
sl@0
   123
			timeTaken = endTime.MicroSecondsFrom(startTime);
sl@0
   124
			delete dirPtr;
sl@0
   125
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   126
			}
sl@0
   127
		
sl@0
   128
		if(gTypes >= 3) 
sl@0
   129
			{	
sl@0
   130
			startTime.HomeTime();
sl@0
   131
			r = TheFs.GetDir(dir3,KEntryAttMaskSupported,ESortNone,dirPtr);
sl@0
   132
			FailIfError(r);
sl@0
   133
			
sl@0
   134
			r = dirPtr->Sort(aKey);
sl@0
   135
			FailIfError(r);
sl@0
   136
			
sl@0
   137
			endTime.HomeTime();
sl@0
   138
			timeTaken=endTime.MicroSecondsFrom(startTime);
sl@0
   139
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   140
			delete dirPtr;
sl@0
   141
			}
sl@0
   142
		}
sl@0
   143
	
sl@0
   144
	PrintResult(aStep, 1, aN);
sl@0
   145
	PrintResultTime(aStep, 2, timeTaken1);
sl@0
   146
	PrintResultTime(aStep, 3, timeTaken2);
sl@0
   147
	PrintResultTime(aStep, 4, timeTaken3);
sl@0
   148
		
sl@0
   149
	return KErrNone;
sl@0
   150
	}
sl@0
   151
sl@0
   152
/** Sort a directory with different type of files and find a particular one
sl@0
   153
sl@0
   154
	@param aN 		Number of files in the directory
sl@0
   155
	@param aKey		Type of sorting to use
sl@0
   156
	@param aStep 	Test step
sl@0
   157
*/
sl@0
   158
LOCAL_C TInt SortFindFile(TInt aN, TEntryKey aKey, TInt aStep )
sl@0
   159
	{
sl@0
   160
	TBuf16<100> dir1;
sl@0
   161
	TBuf16<100> dir2;
sl@0
   162
	TBuf16<100> dir3;
sl@0
   163
    TBuf16<100> temp;
sl@0
   164
	
sl@0
   165
	TInt r = 0;
sl@0
   166
	TTime startTime;
sl@0
   167
	TTime endTime;
sl@0
   168
	TTimeIntervalMicroSeconds timeTaken(0);
sl@0
   169
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
sl@0
   170
	
sl@0
   171
	if(aN <= gFilesLimit) 
sl@0
   172
		{	
sl@0
   173
		CDir* dirPtr;
sl@0
   174
		TInt i = 0;
sl@0
   175
		TBool found = EFalse;
sl@0
   176
			
sl@0
   177
		dir1 = gSessionPath;
sl@0
   178
		dir2 = gSessionPath;
sl@0
   179
		dir3 = gSessionPath;
sl@0
   180
		
sl@0
   181
		temp.Format(KDirMultipleName2, 1, aN);
sl@0
   182
		dir1.Append(temp);
sl@0
   183
		
sl@0
   184
		temp.Format(KDirMultipleName2, 2, aN);
sl@0
   185
		dir2.Append(temp);
sl@0
   186
		
sl@0
   187
		temp.Format(KDirMultipleName2, 3, aN);
sl@0
   188
		dir3.Append(temp);
sl@0
   189
		
sl@0
   190
		dir1.Append(_L("*.*"));
sl@0
   191
		dir2.Append(_L("*.*"));
sl@0
   192
		dir3.Append(_L("*.*"));
sl@0
   193
		
sl@0
   194
		if(gTypes >= 1) 
sl@0
   195
			{	
sl@0
   196
			startTime.HomeTime();
sl@0
   197
			r = TheFs.GetDir(dir1, KEntryAttMaskSupported, aKey, dirPtr);
sl@0
   198
			FailIfError(r);
sl@0
   199
			
sl@0
   200
			found = EFalse; 
sl@0
   201
			i = 0;
sl@0
   202
			while((i < dirPtr->Count()) && (!found))
sl@0
   203
				{
sl@0
   204
				TEntry e = (*dirPtr)[i];
sl@0
   205
				if(e.iName == _L("last.txt")) found = ETrue;		
sl@0
   206
				i++;	
sl@0
   207
				}
sl@0
   208
			
sl@0
   209
			endTime.HomeTime();
sl@0
   210
			delete dirPtr;
sl@0
   211
			
sl@0
   212
			timeTaken = endTime.MicroSecondsFrom(startTime);
sl@0
   213
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   214
			}
sl@0
   215
		
sl@0
   216
		if(gTypes >= 2) 
sl@0
   217
			{	
sl@0
   218
			startTime.HomeTime();
sl@0
   219
			r = TheFs.GetDir(dir2, KEntryAttMaskSupported, aKey, dirPtr);
sl@0
   220
			FailIfError(r);
sl@0
   221
			
sl@0
   222
			found = EFalse; 
sl@0
   223
			i = 0;
sl@0
   224
			while((i < dirPtr->Count()) && (!found))
sl@0
   225
				{
sl@0
   226
				TEntry e = (*dirPtr)[i];
sl@0
   227
				if(e.iName == _L("last.txt")) found = ETrue;
sl@0
   228
				i++;	
sl@0
   229
				}
sl@0
   230
sl@0
   231
			endTime.HomeTime();
sl@0
   232
			timeTaken = endTime.MicroSecondsFrom(startTime);
sl@0
   233
			delete dirPtr;
sl@0
   234
			
sl@0
   235
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   236
			}
sl@0
   237
		
sl@0
   238
		if(gTypes >= 3) 
sl@0
   239
			{		
sl@0
   240
			startTime.HomeTime();
sl@0
   241
			r = TheFs.GetDir(dir3, KEntryAttMaskSupported, aKey, dirPtr);
sl@0
   242
			FailIfError(r);
sl@0
   243
			
sl@0
   244
			found = EFalse; 
sl@0
   245
			i = 0;
sl@0
   246
			while((i<dirPtr->Count()) && (!found))
sl@0
   247
				{
sl@0
   248
				TEntry e = (*dirPtr)[i];
sl@0
   249
				if(e.iName == _L("last.txt")) found = ETrue;
sl@0
   250
				i++;	
sl@0
   251
				}
sl@0
   252
			
sl@0
   253
			endTime.HomeTime();
sl@0
   254
			timeTaken = endTime.MicroSecondsFrom(startTime);
sl@0
   255
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   256
			delete dirPtr;
sl@0
   257
			}
sl@0
   258
		}
sl@0
   259
	
sl@0
   260
	PrintResult(aStep, 1, aN);
sl@0
   261
	PrintResultTime(aStep, 2, timeTaken1);
sl@0
   262
	PrintResultTime(aStep, 3, timeTaken2);
sl@0
   263
	PrintResultTime(aStep, 4, timeTaken3);
sl@0
   264
sl@0
   265
	return KErrNone;
sl@0
   266
	}
sl@0
   267
	
sl@0
   268
	
sl@0
   269
/** Sort a directory and find a file opens it and reads first 4Kb and last 4Kb
sl@0
   270
sl@0
   271
	@param aN 		Number of files in the directory
sl@0
   272
	@param aKey		Type of sorting to use
sl@0
   273
	@param aStep 	Test step
sl@0
   274
*/
sl@0
   275
LOCAL_C TInt SortFindFileAndOpen(TInt aN, TEntryKey aKey, TInt aStep )
sl@0
   276
	{
sl@0
   277
	TBuf16<100> dir1;
sl@0
   278
	TBuf16<100> dir2;
sl@0
   279
	TBuf16<100> dir3;
sl@0
   280
    TBuf16<100> temp;
sl@0
   281
	
sl@0
   282
	TInt r = 0;
sl@0
   283
	TTime startTime;
sl@0
   284
	TTime endTime;
sl@0
   285
	TTimeIntervalMicroSeconds timeTaken(0);
sl@0
   286
	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1;
sl@0
   287
		
sl@0
   288
	CDir* dirPtr;
sl@0
   289
	TInt i = 0, pos = 0;
sl@0
   290
	TBool found = EFalse;
sl@0
   291
	RFile file;
sl@0
   292
sl@0
   293
	if(aN <= gFilesLimit) 
sl@0
   294
		{		
sl@0
   295
		dir1 = gSessionPath;
sl@0
   296
		dir2 = gSessionPath;
sl@0
   297
		dir3 = gSessionPath;
sl@0
   298
		
sl@0
   299
		temp.Format(KDirMultipleName2, 1, aN);
sl@0
   300
		dir1.Append(temp);
sl@0
   301
		
sl@0
   302
		temp.Format(KDirMultipleName2, 2, aN);
sl@0
   303
		dir2.Append(temp);
sl@0
   304
		
sl@0
   305
		temp.Format(KDirMultipleName2, 3, aN);
sl@0
   306
		dir3.Append(temp);
sl@0
   307
		
sl@0
   308
		dir1.Append(_L("*.*"));
sl@0
   309
		dir2.Append(_L("*.*"));
sl@0
   310
		dir3.Append(_L("*.*"));
sl@0
   311
sl@0
   312
	
sl@0
   313
		if(gTypes >= 1) 
sl@0
   314
			{	
sl@0
   315
			startTime.HomeTime();
sl@0
   316
			r = TheFs.GetDir(dir1, KEntryAttMaskSupported, aKey, dirPtr);
sl@0
   317
			FailIfError(r);
sl@0
   318
			
sl@0
   319
			dir1 = gSessionPath;
sl@0
   320
			temp.Format(KDirMultipleName2, 1, aN);
sl@0
   321
			dir1.Append(temp);
sl@0
   322
			dir1.Append(_L("LAST.TXT"));
sl@0
   323
				
sl@0
   324
			found = EFalse; 
sl@0
   325
			i = 0;
sl@0
   326
			while((i < dirPtr->Count()) && (!found))
sl@0
   327
				{
sl@0
   328
				TEntry e = (*dirPtr)[i];
sl@0
   329
				if(e.iName == _L("LAST.TXT")) 
sl@0
   330
					{
sl@0
   331
					found = ETrue;		
sl@0
   332
					}
sl@0
   333
				else 
sl@0
   334
					{
sl@0
   335
					i++;	
sl@0
   336
					}
sl@0
   337
				}
sl@0
   338
			
sl@0
   339
			test(found);
sl@0
   340
			
sl@0
   341
			file.Open(TheFs, dir1, EFileShareAny|EFileRead);
sl@0
   342
			pos = 0;
sl@0
   343
			file.Seek(ESeekStart, pos);
sl@0
   344
			r = file.Read(buf);
sl@0
   345
			FailIfError(r);
sl@0
   346
			pos = -4 * KOneK; // 4 KB before the end of the file
sl@0
   347
			file.Seek(ESeekEnd, pos);
sl@0
   348
			r = file.Read(buf);
sl@0
   349
			FailIfError(r);
sl@0
   350
			
sl@0
   351
			endTime.HomeTime();
sl@0
   352
			delete dirPtr;
sl@0
   353
			file.Close();
sl@0
   354
			
sl@0
   355
			timeTaken = endTime.MicroSecondsFrom(startTime);
sl@0
   356
			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   357
			}
sl@0
   358
		
sl@0
   359
		if(gTypes >= 2) 
sl@0
   360
			{		
sl@0
   361
			startTime.HomeTime();
sl@0
   362
			r = TheFs.GetDir(dir2, KEntryAttMaskSupported, aKey, dirPtr);
sl@0
   363
			FailIfError(r);
sl@0
   364
			
sl@0
   365
			dir2 = gSessionPath;
sl@0
   366
			temp.Format(KDirMultipleName2, 2, aN); 
sl@0
   367
			dir2.Append(temp);
sl@0
   368
			dir2.Append(_L("LAST.TXT"));
sl@0
   369
sl@0
   370
			found = EFalse; 
sl@0
   371
			i = 0;
sl@0
   372
			while((i < dirPtr->Count()) && (!found))
sl@0
   373
				{
sl@0
   374
				TEntry e = (*dirPtr)[i];
sl@0
   375
				if(e.iName == _L("LAST.TXT")) 
sl@0
   376
					{
sl@0
   377
					found = ETrue;
sl@0
   378
					}
sl@0
   379
				else 
sl@0
   380
					{
sl@0
   381
					i++;	
sl@0
   382
					}
sl@0
   383
				}
sl@0
   384
			
sl@0
   385
			test(found);
sl@0
   386
						
sl@0
   387
			file.Open(TheFs, dir2, EFileShareAny|EFileRead);
sl@0
   388
			pos = 0;
sl@0
   389
			file.Seek(ESeekStart, pos);
sl@0
   390
			r = file.Read(buf);
sl@0
   391
			FailIfError(r);
sl@0
   392
			pos = -4 * KOneK;  // 4 KB before the end of the file
sl@0
   393
			file.Seek(ESeekEnd, pos);
sl@0
   394
			r = file.Read(buf);
sl@0
   395
			FailIfError(r);
sl@0
   396
			
sl@0
   397
			endTime.HomeTime();
sl@0
   398
			timeTaken = endTime.MicroSecondsFrom(startTime);
sl@0
   399
			delete dirPtr;
sl@0
   400
			file.Close();
sl@0
   401
			
sl@0
   402
			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   403
			}
sl@0
   404
		
sl@0
   405
		if(gTypes >= 3) 
sl@0
   406
			{	
sl@0
   407
			startTime.HomeTime();
sl@0
   408
			r = TheFs.GetDir(dir3, KEntryAttMaskSupported, aKey, dirPtr);
sl@0
   409
			FailIfError(r);
sl@0
   410
			
sl@0
   411
			dir3 = gSessionPath;
sl@0
   412
			temp.Format(KDirMultipleName2, 3, aN);
sl@0
   413
			dir3.Append(temp);
sl@0
   414
			dir3.Append(_L("LAST.TXT"));
sl@0
   415
sl@0
   416
			found = EFalse; 
sl@0
   417
			i = 0;
sl@0
   418
			while((i < dirPtr->Count()) && (!found))
sl@0
   419
				{
sl@0
   420
				TEntry e = (*dirPtr)[i];
sl@0
   421
				if(e.iName == _L("LAST.TXT")) 
sl@0
   422
					{
sl@0
   423
					found = ETrue;
sl@0
   424
					}
sl@0
   425
				else 
sl@0
   426
					{
sl@0
   427
					i++;	
sl@0
   428
					}
sl@0
   429
				}
sl@0
   430
			
sl@0
   431
			file.Open(TheFs, dir3, EFileShareAny|EFileRead);
sl@0
   432
			pos = 0;
sl@0
   433
			file.Seek(ESeekStart, pos);
sl@0
   434
			r = file.Read(buf);
sl@0
   435
			FailIfError(r);
sl@0
   436
			pos = -4 * KOneK;  // 4 KB before the end of the file
sl@0
   437
			file.Seek(ESeekEnd, pos);
sl@0
   438
			r = file.Read(buf);
sl@0
   439
			FailIfError(r);
sl@0
   440
			
sl@0
   441
			endTime.HomeTime();
sl@0
   442
			timeTaken = endTime.MicroSecondsFrom(startTime);
sl@0
   443
			file.Close();
sl@0
   444
			
sl@0
   445
			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
sl@0
   446
			delete dirPtr;
sl@0
   447
			}
sl@0
   448
		}
sl@0
   449
	
sl@0
   450
	PrintResult(aStep, 1, aN);
sl@0
   451
	PrintResultTime(aStep, 2, timeTaken1);
sl@0
   452
	PrintResultTime(aStep, 3, timeTaken2);
sl@0
   453
	PrintResultTime(aStep, 4, timeTaken3);
sl@0
   454
sl@0
   455
	return KErrNone;
sl@0
   456
	}
sl@0
   457
sl@0
   458
/** Times the directory listing sorted by name, extension, size and date
sl@0
   459
sl@0
   460
	@param aSelector Configuration in case of manual execution
sl@0
   461
*/
sl@0
   462
LOCAL_C TInt TestDirListing(TAny* aSelector)
sl@0
   463
	{
sl@0
   464
	TInt i = 100;
sl@0
   465
	TInt testStep;
sl@0
   466
	
sl@0
   467
	Validate(aSelector);
sl@0
   468
	
sl@0
   469
	test.Printf(_L("#~TS_Title_%d,%d: Directory listing sorted by name \n"), gTestHarness, gTestCase);
sl@0
   470
	
sl@0
   471
	testStep = 1;
sl@0
   472
	while(i <= KMaxFiles)
sl@0
   473
		{
sl@0
   474
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   475
			{
sl@0
   476
			SortFile(i, ESortByName, testStep++);
sl@0
   477
			}
sl@0
   478
		i += 100;
sl@0
   479
		}
sl@0
   480
sl@0
   481
	gTestCase++;
sl@0
   482
	test.Printf(_L("#~TS_Title_%d,%d: Directory listing sorted by extension\n"), gTestHarness, gTestCase);
sl@0
   483
	
sl@0
   484
	i = 100;
sl@0
   485
	testStep = 1;
sl@0
   486
	while(i <= KMaxFiles)
sl@0
   487
		{
sl@0
   488
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   489
			{
sl@0
   490
			SortFile(i, ESortByExt, testStep++);
sl@0
   491
			}
sl@0
   492
		i += 100;
sl@0
   493
		}
sl@0
   494
sl@0
   495
	gTestCase++;
sl@0
   496
	test.Printf(_L("#~TS_Title_%d,%d: Directory listing sorted by size \n"), gTestHarness, gTestCase);
sl@0
   497
sl@0
   498
	i = 100;
sl@0
   499
	testStep = 1;
sl@0
   500
	while(i <= KMaxFiles)
sl@0
   501
		{
sl@0
   502
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   503
			{
sl@0
   504
			SortFile(i, ESortBySize, testStep++);
sl@0
   505
			}
sl@0
   506
		i += 100;
sl@0
   507
		}
sl@0
   508
sl@0
   509
	gTestCase++;
sl@0
   510
	test.Printf(_L("#~TS_Title_%d,%d: Directory listing sorted by date \n"), gTestHarness, gTestCase);
sl@0
   511
	
sl@0
   512
	i = 100;
sl@0
   513
	testStep = 1;
sl@0
   514
	while(i <= KMaxFiles)
sl@0
   515
		{
sl@0
   516
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   517
			{
sl@0
   518
			SortFile(i, ESortByDate, testStep++);
sl@0
   519
			}
sl@0
   520
		i += 100;
sl@0
   521
		}
sl@0
   522
sl@0
   523
	gTestCase++;
sl@0
   524
	return KErrNone;
sl@0
   525
	}
sl@0
   526
sl@0
   527
/** Times the operations required to find a file ordering the list of files by orted by name,
sl@0
   528
	extension, size and date
sl@0
   529
	
sl@0
   530
	@param aSelector Configuration in case of manual execution
sl@0
   531
*/
sl@0
   532
LOCAL_C TInt TestFindFile(TAny* aSelector)
sl@0
   533
	{
sl@0
   534
	TInt i = 100;
sl@0
   535
	TInt testStep;
sl@0
   536
	
sl@0
   537
	Validate(aSelector);
sl@0
   538
	
sl@0
   539
	test.Printf(_L("#~TS_Title_%d,%d: Find file when sorted by name \n"), gTestHarness, gTestCase);
sl@0
   540
sl@0
   541
	i = 100;
sl@0
   542
	testStep = 1;
sl@0
   543
	while(i <= KMaxFiles)
sl@0
   544
		{
sl@0
   545
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   546
			{
sl@0
   547
			SortFindFile(i, ESortByName, testStep++);
sl@0
   548
			}
sl@0
   549
		i += 100;
sl@0
   550
		}
sl@0
   551
sl@0
   552
	gTestCase++;
sl@0
   553
	test.Printf(_L("#~TS_Title_%d,%d: Find file when sorted by extension\n"), gTestHarness, gTestCase);
sl@0
   554
sl@0
   555
	i = 100;
sl@0
   556
	testStep = 1;
sl@0
   557
	while(i <= KMaxFiles)
sl@0
   558
		{
sl@0
   559
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   560
			{
sl@0
   561
			SortFindFile(i, ESortByExt, testStep++);
sl@0
   562
			}
sl@0
   563
		i += 100;
sl@0
   564
		}
sl@0
   565
sl@0
   566
	gTestCase++;
sl@0
   567
	test.Printf(_L("#~TS_Title_%d,%d: Find file when sorted by size \n"), gTestHarness, gTestCase);
sl@0
   568
sl@0
   569
	i = 100;
sl@0
   570
	testStep = 1;
sl@0
   571
	while(i <= KMaxFiles)
sl@0
   572
		{
sl@0
   573
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   574
			{
sl@0
   575
			SortFindFile(i, ESortBySize, testStep++);
sl@0
   576
			}
sl@0
   577
		i += 100;
sl@0
   578
		}
sl@0
   579
	
sl@0
   580
	gTestCase++;	
sl@0
   581
	test.Printf(_L("#~TS_Title_%d,%d: Find file when sorted by date \n"), gTestHarness, gTestCase);
sl@0
   582
	
sl@0
   583
	i = 100;
sl@0
   584
	testStep = 1;
sl@0
   585
	while(i <= KMaxFiles)
sl@0
   586
		{
sl@0
   587
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   588
			{
sl@0
   589
			SortFindFile(i, ESortByDate, testStep++);
sl@0
   590
			}
sl@0
   591
		i += 100;
sl@0
   592
		}
sl@0
   593
	
sl@0
   594
	gTestCase++;
sl@0
   595
	
sl@0
   596
	return KErrNone;
sl@0
   597
	}
sl@0
   598
sl@0
   599
/** Times the opening of a file and read of the first 4 Kb when sorted by name, 
sl@0
   600
	extension, size and date
sl@0
   601
sl@0
   602
	@param aSelector Configuration in case of manual execution
sl@0
   603
*/
sl@0
   604
LOCAL_C TInt TestOpenReadFile(TAny* aSelector)
sl@0
   605
	{
sl@0
   606
	TInt i = 100;
sl@0
   607
	TInt testStep;
sl@0
   608
	
sl@0
   609
	Validate(aSelector);
sl@0
   610
	
sl@0
   611
	test.Printf(_L("#~TS_Title_%d,%d: Open and read file when sorted by name \n"), gTestHarness, gTestCase);
sl@0
   612
sl@0
   613
	i = 100;
sl@0
   614
	testStep = 1;
sl@0
   615
	while(i <= KMaxFiles)
sl@0
   616
		{
sl@0
   617
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   618
			{
sl@0
   619
			SortFindFileAndOpen(i, ESortByName, testStep++);
sl@0
   620
			}
sl@0
   621
		i += 100;
sl@0
   622
		}
sl@0
   623
	
sl@0
   624
	gTestCase++;
sl@0
   625
	test.Printf(_L("#~TS_Title_%d,%d: Open and read file when sorted by extension\n"), gTestHarness, gTestCase);
sl@0
   626
sl@0
   627
	i = 100;
sl@0
   628
	testStep = 1;
sl@0
   629
	while(i <= KMaxFiles)
sl@0
   630
		{
sl@0
   631
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   632
			{
sl@0
   633
			SortFindFileAndOpen(i, ESortByExt, testStep++);
sl@0
   634
			}
sl@0
   635
		i += 100;
sl@0
   636
		}
sl@0
   637
sl@0
   638
	gTestCase++;
sl@0
   639
	test.Printf(_L("#~TS_Title_%d,%d: Open and read when sorted by size \n"), gTestHarness, gTestCase);
sl@0
   640
sl@0
   641
	i=100;
sl@0
   642
	testStep = 1;
sl@0
   643
	while(i <= KMaxFiles)
sl@0
   644
		{
sl@0
   645
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   646
			{
sl@0
   647
			SortFindFileAndOpen(i, ESortBySize, testStep++);
sl@0
   648
			}
sl@0
   649
		i += 100;
sl@0
   650
		}
sl@0
   651
sl@0
   652
	gTestCase++;
sl@0
   653
	test.Printf(_L("#~TS_Title_%d,%d: Open and read file when sorted by date \n"), gTestHarness, gTestCase);
sl@0
   654
sl@0
   655
	i = 100;
sl@0
   656
	testStep = 1;
sl@0
   657
	while(i <= KMaxFiles)
sl@0
   658
		{
sl@0
   659
		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
sl@0
   660
			{
sl@0
   661
			SortFindFileAndOpen(i, ESortByDate, testStep++);
sl@0
   662
			}
sl@0
   663
		i += 100;
sl@0
   664
		}
sl@0
   665
	
sl@0
   666
	gTestCase++;
sl@0
   667
	return KErrNone;
sl@0
   668
	}
sl@0
   669
sl@0
   670
/** It goes automatically through all the options
sl@0
   671
sl@0
   672
	@param aSelector Configuration in case of manual execution
sl@0
   673
*/
sl@0
   674
LOCAL_C TInt TestAll(TAny* aSelector)
sl@0
   675
	{
sl@0
   676
	Validate(aSelector);
sl@0
   677
	
sl@0
   678
	TestDirListing(aSelector);
sl@0
   679
	TestFindFile(aSelector);
sl@0
   680
	TestOpenReadFile(aSelector);
sl@0
   681
	
sl@0
   682
	return KErrNone;
sl@0
   683
	}
sl@0
   684
sl@0
   685
/** Call all tests
sl@0
   686
sl@0
   687
*/
sl@0
   688
GLDEF_C void CallTestsL()
sl@0
   689
	{
sl@0
   690
	TInt r = client.CreateLocal(0);
sl@0
   691
	FailIfError(r);
sl@0
   692
	
sl@0
   693
	CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console());
sl@0
   694
	
sl@0
   695
	gFileSize = 8;
sl@0
   696
	
sl@0
   697
	// Each test case of the suite has an identifyer for parsing purposes of the results
sl@0
   698
	gTestHarness = 2; 	
sl@0
   699
	gTestCase = 1;
sl@0
   700
	
sl@0
   701
	PrintHeaders(1, _L("t_fsrdirload. Directory loading"));
sl@0
   702
		
sl@0
   703
	if(gMode==0) 
sl@0
   704
		{ // Manual	
sl@0
   705
		gSessionPath = _L("?:\\");
sl@0
   706
		TCallBack createFiles(TestFileCreate,TheSelector);
sl@0
   707
		TCallBack dirListFile(TestDirListing,TheSelector);
sl@0
   708
		TCallBack findFile(TestFindFile,TheSelector);
sl@0
   709
		TCallBack openReadFile(TestOpenReadFile,TheSelector);
sl@0
   710
		TCallBack allFile(TestAll,TheSelector);
sl@0
   711
		TheSelector->AddDriveSelectorL(TheFs);
sl@0
   712
		TheSelector->AddLineL(_L("Create all files"),createFiles);
sl@0
   713
		TheSelector->AddLineL(_L("Directory listings"),dirListFile);
sl@0
   714
		TheSelector->AddLineL(_L("Find file in the listing"),findFile);
sl@0
   715
		TheSelector->AddLineL(_L("Open and read first and last 4KB "),openReadFile);
sl@0
   716
		TheSelector->AddLineL(_L("Three last options together"),allFile);
sl@0
   717
		TheSelector->Run();
sl@0
   718
		}
sl@0
   719
	else 
sl@0
   720
		{ // Automatic
sl@0
   721
		TestAll(TheSelector);
sl@0
   722
		}
sl@0
   723
	
sl@0
   724
	client.Close();
sl@0
   725
	test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);
sl@0
   726
	delete TheSelector;
sl@0
   727
	}