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