kerneltest/f32test/bench/t_fsrdirscan.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     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_fsrdirscan.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 GLDEF_D RTest test(_L("File Server Benchmarks, DirScan"));
       
    25 
       
    26 //----------------------------------------------------------------------------------------------
       
    27 //! @SYMTestCaseID      PBASE-T_FSRDIRSCAN-0274
       
    28 //! @SYMTestType        CIT
       
    29 //! @SYMPREQ            PREQ000
       
    30 //! @SYMTestCaseDesc    This test case is measuring performance of the FAT implementation.  
       
    31 //! @SYMTestActions     0.  Expects the files to exist in order to successful execution
       
    32 //!						1.	Time finding an entry in each directory with TFindFile
       
    33 //!						2.	Time finding an entry in each directory with RFile::Open
       
    34 //!						3.	Time finding an entry in each directory with TFindFile with multiple 
       
    35 //!							clients accessing the directory
       
    36 //!						4.	Time finding an entry in each directory with RFile::Open with multiple 
       
    37 //!							clients accessing the directory
       
    38 //!						5.	Time finding an entry in each directory with TFindFile with multiple 
       
    39 //!							clients accessing different directories
       
    40 //!						6.	Time finding an entry in each directory with RFile::Open with multiple 
       
    41 //!							clients accessing different directories
       
    42 //!						7.	Time finding *.txt entries in each directory with TFindFile::FindWildByPath()
       
    43 //!						8.	Time finding *.txt entries in each directory with TFindFile::FindWildByPath() 
       
    44 //!							and different clients accessing the same directory
       
    45 //!						9.	Time finding *.txt entries in each directory with TFindFile::FindWildByPath() 
       
    46 //!							and different clients accessing different directories
       
    47 //!						10.	Time finding ffff*.txt entries in each directory with TFindFile::FindWildByPath()
       
    48 //!						11.	Time finding ffff*.txt entries in each directory with TFindFile::FindWildByPath() 
       
    49 //!							and different clients accessing the same directory
       
    50 //!						12.	Time finding ffff*.txt entries in each directory with TFindFile::FindWildByPath() 
       
    51 //!							and different clients accessing different directories
       
    52 //!						13.	Time finding last.* entry in each directory with TFindFile::FindWildByPath()
       
    53 //!						14.	Time finding last.* entry in each directory with TFindFile::FindWildByPath() 
       
    54 //!							and different clients accessing the same directory
       
    55 //!						15.	Time finding last.* entry in each directory with TFindFile::FindWildByPath() 
       
    56 //!							and different clients accessing different directories
       
    57 //!
       
    58 //! @SYMTestExpectedResults Finishes if the system behaves as expected, panics otherwise
       
    59 //! @SYMTestPriority        High
       
    60 //! @SYMTestStatus          Implemented
       
    61 //----------------------------------------------------------------------------------------------
       
    62 
       
    63 LOCAL_D RSemaphore client;
       
    64 LOCAL_D const TInt KHeapSize = 0x4000;
       
    65 LOCAL_D TBuf8<4096> buf;
       
    66 
       
    67 LOCAL_D TDriveList gDriveList;
       
    68 
       
    69 LOCAL_D TFileName gFindEntryDir;
       
    70 LOCAL_D TBuf<100> gFindDir;
       
    71 
       
    72 LOCAL_D TFileName gFindEntryDir2;
       
    73 LOCAL_D TBuf<100> gFindDir2;
       
    74 
       
    75 // Concurrent threads
       
    76 RThread gSpeedy;
       
    77 RThread gSpeedyII;
       
    78 TInt ThreadCount = 0;
       
    79 
       
    80 _LIT(KDirMultipleName2, "dir%d_%d\\");
       
    81 
       
    82 /** Find entry in directory
       
    83 
       
    84 */
       
    85 LOCAL_C TInt FindEntryAccess2(TAny*)
       
    86 	{
       
    87 	RFs fs;
       
    88 	TInt r  = fs.Connect();
       
    89 	RTest test(_L("test 2")); 
       
    90 	
       
    91 	fs.SetSessionPath(gSessionPath);
       
    92 	
       
    93 	client.Signal();
       
    94 	
       
    95 	FOREVER
       
    96 		{
       
    97 			TEntry entry;
       
    98 			r = fs.Entry(gFindEntryDir2, entry);
       
    99 			FailIfError(r);
       
   100 			r = fs.Entry(gFindDir2,entry);
       
   101 			FailIfError(r);
       
   102 		}
       
   103 	}
       
   104 
       
   105 /** Starts a concurrent client session
       
   106 
       
   107 	@param aFunction Thread to be started twice
       
   108 */
       
   109 LOCAL_C void DoTest(TThreadFunction aFunction)
       
   110 	{
       
   111 	TBuf<20> buf = _L("Speedy");
       
   112 	buf.AppendNum(ThreadCount++);
       
   113 	TInt r = gSpeedy.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
       
   114 	FailIfError(r);
       
   115 
       
   116 	buf = _L("Speedy");
       
   117 	buf.AppendNum(ThreadCount++);
       
   118 	r = gSpeedyII.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
       
   119 	FailIfError(r);
       
   120 
       
   121 	gSpeedy.SetPriority(EPriorityLess);
       
   122     gSpeedyII.SetPriority(EPriorityLess);
       
   123     
       
   124 	gSpeedy.Resume();
       
   125 	gSpeedyII.Resume();
       
   126 	
       
   127 	client.Wait();
       
   128 	client.Wait();
       
   129 	}
       
   130 		
       
   131 /**  Starts a concurrent client session in different directories
       
   132 
       
   133 	@param aFunction Thread to be started 
       
   134 */
       
   135 LOCAL_C void DoTest2(TThreadFunction aFunction)
       
   136 	{
       
   137 	TBuf<20> buf = _L("Speedy");
       
   138 	buf.AppendNum(ThreadCount++);
       
   139 	TInt r = gSpeedy.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
       
   140 	FailIfError(r);
       
   141 
       
   142 	buf = _L("Speedy");
       
   143 	buf.AppendNum(ThreadCount++);
       
   144 	r = gSpeedyII.Create(buf, FindEntryAccess2, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
       
   145 	FailIfError(r);
       
   146 
       
   147  	gSpeedy.SetPriority(EPriorityLess);
       
   148     gSpeedyII.SetPriority(EPriorityLess);
       
   149 	
       
   150 	gSpeedy.Resume();
       
   151 	gSpeedyII.Resume();
       
   152 	
       
   153 	client.Wait();
       
   154 	client.Wait();
       
   155 	}
       
   156 	
       
   157 /** Kills the concurrent session
       
   158 
       
   159 */
       
   160 LOCAL_C void DoTestKill()
       
   161 	{
       
   162 	TInt r = 0;
       
   163 	
       
   164 	gSpeedy.Kill(KErrNone);
       
   165 	FailIfError(r);
       
   166 	gSpeedy.Close();	
       
   167 	
       
   168 	gSpeedyII.Kill(KErrNone);
       
   169 	FailIfError(r);
       
   170 	gSpeedyII.Close();	
       
   171 	}
       
   172 
       
   173 /** Find entry in directory
       
   174 
       
   175 */
       
   176 LOCAL_C TInt FindEntryAccess(TAny*)
       
   177 	{
       
   178 	RFs fs;
       
   179 	TInt r = fs.Connect();
       
   180 	RTest test(_L("test 2")); 
       
   181 	
       
   182 	r = fs.SetSessionPath(gSessionPath);
       
   183 
       
   184 	client.Signal();
       
   185 	
       
   186 	FOREVER
       
   187 		{
       
   188 		TEntry entry;
       
   189 		
       
   190 		r = fs.Entry(gFindEntryDir,entry);
       
   191 		FailIfError(r);
       
   192 		
       
   193 		r = fs.Entry(gFindDir,entry);
       
   194 		FailIfError(r);
       
   195 		}
       
   196 	}
       
   197 
       
   198 /** Find last.txt with TFindFile and with two threads accessing the current directory 
       
   199 	and looking for the same file
       
   200 
       
   201 	@param aN 		Number of files in the directory
       
   202 	@param aStep 	Test step
       
   203 */
       
   204 LOCAL_C void FindFileM1(TInt aN, TInt aStep) 
       
   205 	{
       
   206 	TBuf16<100> dir1;
       
   207 	TBuf16<100> dir2;
       
   208 	TBuf16<100> dir3;
       
   209     TBuf16<100> dir4;
       
   210     TBuf16<100> dirtemp;
       
   211     	
       
   212 	TInt r = 0;
       
   213 	TFindFile find(TheFs);
       
   214 	TTime startTime;
       
   215 	TTime endTime;
       
   216 	TTimeIntervalMicroSeconds timeTaken(0);
       
   217 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
   218 
       
   219 	if(aN <= gFilesLimit) 
       
   220 		{
       
   221 		dir1 = gSessionPath;
       
   222 		dir2 = gSessionPath;
       
   223 		dir3 = gSessionPath;
       
   224 
       
   225 		dirtemp.Format(KDirMultipleName2, 1, aN);
       
   226 		dir1.Append(dirtemp);
       
   227 		gFindDir = dir1;
       
   228 		
       
   229 		dirtemp.Format(KDirMultipleName2, 2, aN);
       
   230 		dir2.Append(dirtemp);
       
   231 
       
   232 		dirtemp.Format(KDirMultipleName2, 3, aN);
       
   233 		dir3.Append(dirtemp);
       
   234 			
       
   235 		dir1.Append(KCommonFile);
       
   236 		dir2.Append(KCommonFile);
       
   237 		dir3.Append(KCommonFile);
       
   238 
       
   239 
       
   240 		if(gTypes >= 1) 
       
   241 			{	
       
   242 			gFindEntryDir = dir1;
       
   243 			DoTest(FindEntryAccess);
       
   244 			
       
   245 			dir4.Format(KDirMultipleName, 1, aN);
       
   246 			startTime.HomeTime();
       
   247 			
       
   248 			r = find.FindByPath(dir1, &dir4);
       
   249 			FailIfError(r);
       
   250 			
       
   251 			endTime.HomeTime();
       
   252 			DoTestKill();
       
   253 			
       
   254 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   255 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   256 			}
       
   257 		
       
   258 		if(gTypes >= 2) 
       
   259 			{	
       
   260 			dir4 = gSessionPath;
       
   261 			dirtemp.Format(KDirMultipleName, 2, aN);
       
   262 			dir4.Append(dirtemp);
       
   263 			gFindDir = dir4;
       
   264 			gFindEntryDir = dir2;
       
   265 		
       
   266 			DoTest(FindEntryAccess);
       
   267 
       
   268 			startTime.HomeTime();
       
   269 
       
   270 			r = find.FindByPath(dir2, &dir4);
       
   271 			FailIfError(r);
       
   272 			
       
   273 			endTime.HomeTime();
       
   274 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   275 			DoTestKill();
       
   276 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   277 			}
       
   278 		
       
   279 		if(gTypes >= 3) 
       
   280 			{	
       
   281 			dir4 = gSessionPath;
       
   282 			dirtemp.Format(KDirMultipleName, 3, aN);
       
   283 			dir4.Append(dirtemp);
       
   284 	
       
   285 			gFindDir = dir4;
       
   286 			gFindEntryDir = dir3;
       
   287 
       
   288 			DoTest(FindEntryAccess);
       
   289 
       
   290 			startTime.HomeTime();
       
   291 
       
   292 			r = find.FindByPath(dir3, &dir4);
       
   293 			FailIfError(r);
       
   294 			
       
   295 			endTime.HomeTime();
       
   296 			DoTestKill();
       
   297 			
       
   298 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   299 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   300 			}
       
   301 		}
       
   302 	
       
   303 	PrintResult(aStep, 1, aN);
       
   304 	PrintResultTime(aStep, 2, timeTaken1);
       
   305 	PrintResultTime(aStep, 3, timeTaken2);
       
   306 	PrintResultTime(aStep, 4, timeTaken3);
       
   307 	}
       
   308 
       
   309 /** Find last.txt by opening it and with two threads accessing the current directory 
       
   310 	and looking for the same file
       
   311 
       
   312 	@param aN 		Number of files in the directory
       
   313 	@param aStep 	Test step
       
   314 */
       
   315 LOCAL_C void FindFileM2(TInt aN, TInt aStep) 
       
   316 	{
       
   317 	TBuf16<100> dir1;
       
   318 	TBuf16<100> dir2;
       
   319 	TBuf16<100> dir3;
       
   320 	TBuf16<100> dirtemp;
       
   321 
       
   322 	TInt r = 0;
       
   323 
       
   324 	TTime startTime;
       
   325 	TTime endTime;
       
   326 	TTimeIntervalMicroSeconds timeTaken(0);
       
   327 	RFile file;
       
   328 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
   329 
       
   330 	if(aN <= gFilesLimit) 
       
   331 		{
       
   332 		dir1 = gSessionPath;
       
   333 		dir2 = gSessionPath;
       
   334 		dir3 = gSessionPath;
       
   335 
       
   336 		dirtemp.Format(KDirMultipleName2, 1, aN);
       
   337 		dir1.Append(dirtemp);
       
   338 		gFindDir = dir1;
       
   339 		
       
   340 		dirtemp.Format(KDirMultipleName2, 2, aN);
       
   341 		dir2.Append(dirtemp);
       
   342 
       
   343 		dirtemp.Format(KDirMultipleName2, 3, aN);
       
   344 		dir3.Append(dirtemp);
       
   345 			
       
   346 		dir1.Append(KCommonFile);
       
   347 		
       
   348 		if(gTypes >= 1) 
       
   349 			{	
       
   350 			gFindEntryDir = dir1;
       
   351 			DoTest(FindEntryAccess);
       
   352 
       
   353 			User::After(200);
       
   354 			
       
   355 			startTime.HomeTime();
       
   356 			
       
   357 			r = file.Open(TheFs,dir1,EFileShareAny|EFileWrite);
       
   358 			FailIfError(r);
       
   359 
       
   360 			endTime.HomeTime();
       
   361 			
       
   362 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   363 
       
   364 			file.Close();
       
   365 			DoTestKill();
       
   366 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   367 			}
       
   368 		
       
   369 		if(gTypes >= 2) 
       
   370 			{	
       
   371 			gFindDir = dir2;
       
   372 			dir2.Append(KCommonFile);
       
   373 			gFindEntryDir = dir2;
       
   374 
       
   375 			DoTest(FindEntryAccess);
       
   376 			
       
   377 			User::After(200);
       
   378 
       
   379 			startTime.HomeTime();
       
   380 			
       
   381 			r = file.Open(TheFs, dir2, EFileShareAny|EFileWrite);
       
   382 			FailIfError(r);
       
   383 			
       
   384 			endTime.HomeTime();
       
   385 			
       
   386 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   387 			file.Close();
       
   388 			DoTestKill();
       
   389 			
       
   390 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   391 			}
       
   392 		
       
   393 		if(gTypes >= 3) 
       
   394 			{	
       
   395 			gFindDir = dir3;	
       
   396 			dir3.Append(KCommonFile);
       
   397 			gFindEntryDir = dir3;
       
   398 		
       
   399 			DoTest(FindEntryAccess);
       
   400 
       
   401 			User::After(200);
       
   402 			
       
   403 			startTime.HomeTime();
       
   404 			
       
   405 			r = file.Open(TheFs, dir3, EFileShareAny|EFileWrite);
       
   406 			FailIfError(r);
       
   407 			
       
   408 			endTime.HomeTime();
       
   409 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   410 			DoTestKill();
       
   411 			
       
   412 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   413 			file.Close();
       
   414 		}
       
   415 	}
       
   416 
       
   417 	PrintResult(aStep, 1, aN);
       
   418 	PrintResultTime(aStep, 2, timeTaken1);
       
   419 	PrintResultTime(aStep, 3, timeTaken2);
       
   420 	PrintResultTime(aStep, 4, timeTaken3);
       
   421 	}
       
   422 
       
   423 /** Find last.txt with TFindFile and without any other process
       
   424 
       
   425 	@param aN 		Number of files in the directory
       
   426 	@param aStep 	Test step
       
   427 */
       
   428 LOCAL_C void FindFile1(TInt aN, TInt aStep) 
       
   429 	{
       
   430 	TBuf16<100> dir1;
       
   431 	TBuf16<100> dir2;
       
   432 	TBuf16<100> dir3;
       
   433     TBuf16<100> dir4;
       
   434     TBuf16<100> dirtemp;
       
   435 	
       
   436 	TInt r = 0;
       
   437 	TFindFile find(TheFs);
       
   438 	TTime startTime;
       
   439 	TTime endTime;
       
   440 	TTimeIntervalMicroSeconds timeTaken(0);
       
   441 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
   442 	
       
   443 	if(aN <= gFilesLimit) 
       
   444 		{
       
   445 		dir1 = gSessionPath;
       
   446 		dir2 = gSessionPath;
       
   447 		dir3 = gSessionPath;
       
   448 
       
   449 		dirtemp.Format(KDirMultipleName2, 1, aN);
       
   450 		dir1.Append(dirtemp);
       
   451 		
       
   452 		dirtemp.Format(KDirMultipleName2, 2, aN);
       
   453 		dir2.Append(dirtemp);
       
   454 
       
   455 		dirtemp.Format(KDirMultipleName2, 3, aN);
       
   456 		dir3.Append(dirtemp);
       
   457 			
       
   458 		dir1.Append(KCommonFile);
       
   459 		dir2.Append(KCommonFile);
       
   460 		dir3.Append(KCommonFile);
       
   461 		
       
   462 		r = TheFs.SetSessionPath(gSessionPath);
       
   463 		FailIfError(r);
       
   464 
       
   465 		if(gTypes >= 1) 
       
   466 			{	
       
   467 			dir4.Format(KDirMultipleName, 1, aN);
       
   468 			
       
   469 			startTime.HomeTime();
       
   470 			
       
   471 			r = find.FindByPath(dir1, &dir4);
       
   472 			FailIfError(r);
       
   473 			
       
   474 			endTime.HomeTime();
       
   475 			
       
   476 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   477 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   478 			}
       
   479 
       
   480 		if(gTypes >= 2) 
       
   481 			{	
       
   482 			dir4.Format(KDirMultipleName, 2, aN);
       
   483 			
       
   484 			startTime.HomeTime();
       
   485 			
       
   486 			r = find.FindByPath(dir2, &dir4);
       
   487 			FailIfError(r);
       
   488 			
       
   489 			endTime.HomeTime();
       
   490 			
       
   491 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   492 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   493 			}
       
   494 
       
   495 		if(gTypes >= 3) 
       
   496 			{	
       
   497 			dir4.Format(KDirMultipleName, 3, aN);
       
   498 			
       
   499 			startTime.HomeTime();
       
   500 			
       
   501 			r = find.FindByPath(dir3, &dir4);
       
   502 			FailIfError(r);
       
   503 			
       
   504 			endTime.HomeTime();
       
   505 			
       
   506 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   507 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   508 			}
       
   509 		}
       
   510 	
       
   511 	PrintResult(aStep, 1, aN);
       
   512 	PrintResultTime(aStep, 2, timeTaken1);
       
   513 	PrintResultTime(aStep, 3, timeTaken2);
       
   514 	PrintResultTime(aStep, 4, timeTaken3);
       
   515 	}
       
   516 
       
   517 /** Find last.txt by opening it and without any other process
       
   518 
       
   519 	@param aN 		Number of files in the directory
       
   520 	@param aStep 	Test step
       
   521 */
       
   522 LOCAL_C void FindFile2(TInt aN, TInt aStep) 
       
   523 	{
       
   524 	TBuf16<100> dir1;
       
   525 	TBuf16<100> dir2;
       
   526 	TBuf16<100> dir3;
       
   527 	TBuf16<100> dirtemp;
       
   528 
       
   529 	TInt r = 0;
       
   530 
       
   531 	TTime startTime;
       
   532 	TTime endTime;
       
   533 	TTimeIntervalMicroSeconds timeTaken(0);
       
   534 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
   535 	
       
   536 	RFile file;
       
   537 	
       
   538 	if(aN <= gFilesLimit) 
       
   539 		{
       
   540 		dir1 = gSessionPath;
       
   541 		dir2 = gSessionPath;
       
   542 		dir3 = gSessionPath;
       
   543 
       
   544 		dirtemp.Format(KDirMultipleName2, 1, aN);
       
   545 		dir1.Append(dirtemp);
       
   546 		
       
   547 		dirtemp.Format(KDirMultipleName2, 2, aN);
       
   548 		dir2.Append(dirtemp);
       
   549 
       
   550 		dirtemp.Format(KDirMultipleName2, 3, aN);
       
   551 		dir3.Append(dirtemp);
       
   552 			
       
   553 		dir1.Append(KCommonFile);
       
   554 		dir2.Append(KCommonFile);
       
   555 		dir3.Append(KCommonFile);
       
   556 
       
   557 		r = TheFs.SetSessionPath(gSessionPath);
       
   558 		FailIfError(r);
       
   559 		
       
   560 		if(gTypes >= 1) 
       
   561 			{	
       
   562 			startTime.HomeTime();
       
   563 			
       
   564 			r = file.Open(TheFs,dir1,EFileShareAny|EFileWrite);
       
   565 			FailIfError(r);
       
   566 			
       
   567 			endTime.HomeTime();
       
   568 
       
   569 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   570 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   571 			file.Close();
       
   572 			}
       
   573 		
       
   574 		if(gTypes >= 2) 
       
   575 			{	
       
   576 			startTime.HomeTime();
       
   577 
       
   578 			r = file.Open(TheFs, dir2, EFileShareAny|EFileWrite);
       
   579 			FailIfError(r);
       
   580 			
       
   581 			endTime.HomeTime();
       
   582 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   583 			file.Close();
       
   584 			
       
   585 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   586 			}
       
   587 
       
   588 		if(gTypes >= 3) 
       
   589 			{	
       
   590 			startTime.HomeTime();
       
   591 
       
   592 			r = file.Open(TheFs, dir3, EFileShareAny|EFileWrite);
       
   593 			FailIfError(r);
       
   594 			
       
   595 			endTime.HomeTime();
       
   596 			
       
   597 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   598 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   599 			file.Close();
       
   600 			}
       
   601 		}
       
   602 	
       
   603 	PrintResult(aStep, 1, aN);
       
   604 	PrintResultTime(aStep, 2, timeTaken1);
       
   605 	PrintResultTime(aStep, 3, timeTaken2);
       
   606 	PrintResultTime(aStep, 4, timeTaken3);
       
   607 	}
       
   608 
       
   609 /** Find last.txt with TFindFile and with two threads accessing the 2 directories
       
   610 
       
   611 	@param aN Number of files in the directory
       
   612 	@param aStep 	Test step
       
   613 */
       
   614 LOCAL_C void FindFileMD1(TInt aN, TInt aStep) 
       
   615 	{
       
   616 	TBuf16<100> dir1;
       
   617 	TBuf16<100> dir2;
       
   618 	TBuf16<100> dir3;
       
   619     TBuf16<100> dir4;
       
   620     TBuf16<100> dirtemp;
       
   621 	
       
   622 	TInt r = 0;
       
   623 	TFindFile find(TheFs);
       
   624 	TTime startTime;
       
   625 	TTime endTime;
       
   626 	TTimeIntervalMicroSeconds timeTaken(0);
       
   627 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
   628 
       
   629 	if(aN <= gFilesLimit) 
       
   630 		{
       
   631 		dir1 = gSessionPath;
       
   632 		dir2 = gSessionPath;
       
   633 		dir3 = gSessionPath;
       
   634 
       
   635 		dirtemp.Format(KDirMultipleName2, 1, aN);
       
   636 		dir1.Append(dirtemp);
       
   637 
       
   638 		dirtemp.Format(KDirMultipleName, 2, aN);
       
   639 		dir2.Append(dirtemp);
       
   640 
       
   641 		dirtemp.Format(KDirMultipleName, 3, aN);
       
   642 		dir3.Append(dirtemp);
       
   643 		
       
   644 		dir4 = gSessionPath;
       
   645 		dirtemp.Format(KDirMultipleName, 3, 300);
       
   646 		
       
   647 		dir4.Append(dirtemp);
       
   648 		
       
   649 		gFindDir = dir1;
       
   650 		gFindDir2 = dir4;
       
   651 		
       
   652 		dir1.Append(KCommonFile);
       
   653 		dir2.Append(KCommonFile);
       
   654 		dir3.Append(KCommonFile);
       
   655 		dir4.Append(KCommonFile);
       
   656 		
       
   657 		gFindEntryDir = dir1;
       
   658 		gFindEntryDir2 = dir4;
       
   659 		
       
   660 
       
   661 		TheFs.SetSessionPath(gSessionPath);
       
   662 		
       
   663 		dir4.Format(KDirMultipleName, 1, aN);
       
   664 		
       
   665 		if(gTypes >= 1) 
       
   666 			{	
       
   667 			DoTest2(FindEntryAccess);
       
   668 
       
   669 			startTime.HomeTime();
       
   670 	 		r = find.FindByPath(dir1, &dir4);
       
   671 			FailIfError(r);
       
   672 			endTime.HomeTime();
       
   673 			
       
   674 			DoTestKill();
       
   675 			
       
   676 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   677 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   678 			}
       
   679 
       
   680 		if(gTypes >= 2) 
       
   681 			{	
       
   682 			dir4 = gSessionPath; 
       
   683 			dirtemp.Format(KDirMultipleName, 2, aN);
       
   684 			dir4.Append(dirtemp);
       
   685 			gFindDir = dir4;
       
   686 			gFindEntryDir=dir2;
       
   687 
       
   688 			DoTest2(FindEntryAccess);
       
   689 			dir4.Format(KDirMultipleName, 2, aN);
       
   690 	
       
   691 			startTime.HomeTime();
       
   692 
       
   693 			r = find.FindByPath(dir2,&dir4);
       
   694 			test(r==KErrNone);
       
   695 			endTime.HomeTime();
       
   696 			timeTaken=endTime.MicroSecondsFrom(startTime);
       
   697 			DoTestKill();
       
   698 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   699 			}
       
   700 		
       
   701 		if(gTypes>=3) 
       
   702 			{	
       
   703 			dir4 = gSessionPath; 
       
   704 			dirtemp.Format(KDirMultipleName, 3, aN);
       
   705 			dir4.Append(dirtemp);
       
   706 
       
   707 			gFindDir = dir4;
       
   708 			gFindEntryDir=dir2;
       
   709 			
       
   710 			DoTest2(FindEntryAccess);
       
   711 			dir4.Format(KDirMultipleName, 3, aN);
       
   712 		
       
   713 			startTime.HomeTime();
       
   714 
       
   715 			r=find.FindByPath(dir3,&dir4);
       
   716 			test(r==KErrNone);
       
   717 			
       
   718 			endTime.HomeTime();
       
   719 			DoTestKill();
       
   720 			
       
   721 			timeTaken=endTime.MicroSecondsFrom(startTime);
       
   722 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   723 			}
       
   724 		}
       
   725 	
       
   726 	PrintResult(aStep, 1, aN);
       
   727 	PrintResultTime(aStep, 2, timeTaken1);
       
   728 	PrintResultTime(aStep, 3, timeTaken2);
       
   729 	PrintResultTime(aStep, 4, timeTaken3);
       
   730 	}
       
   731 
       
   732 
       
   733 /** Find last.txt by opening the file and with two threads accessing the current 
       
   734 	directory and other one 
       
   735 
       
   736 	@param aN Number of files in the directory
       
   737 	@param aStep 	Test step
       
   738 */
       
   739 LOCAL_C void FindFileMD2(TInt aN, TInt aStep) 
       
   740 	{
       
   741 	TBuf16<100> dir1;
       
   742 	TBuf16<100> dir2;
       
   743 	TBuf16<100> dir3;
       
   744 	TBuf16<100> dir4;
       
   745 	TBuf16<100> dirtemp;
       
   746 
       
   747 	TInt r = 0;
       
   748 
       
   749 	TTime startTime;
       
   750 	TTime endTime;
       
   751 	TTimeIntervalMicroSeconds timeTaken(0);
       
   752 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
   753 
       
   754 	RFile file;
       
   755 	
       
   756 	if(aN <= gFilesLimit) 
       
   757 		{
       
   758 		dir1 = gSessionPath;
       
   759 		dir2 = gSessionPath;
       
   760 		dir3 = gSessionPath;
       
   761 
       
   762 		dirtemp.Format(KDirMultipleName2, 1, aN);
       
   763 		dir1.Append(dirtemp);
       
   764 		gFindDir = dir1;
       
   765 		
       
   766 		dirtemp.Format(KDirMultipleName2, 2, aN);
       
   767 		dir2.Append(dirtemp);
       
   768 
       
   769 		dirtemp.Format(KDirMultipleName2, 3, aN);
       
   770 		dir3.Append(dirtemp);
       
   771 			
       
   772 		dir1.Append(KCommonFile);
       
   773 		gFindEntryDir = dir1;
       
   774 		
       
   775 		dir4 = gSessionPath;
       
   776 		dirtemp.Format(KDirMultipleName, 3, 300);
       
   777 		dir4.Append(dirtemp);
       
   778 
       
   779 		
       
   780 		if(gTypes >= 1) 
       
   781 			{	
       
   782 			gFindDir2 = dir4;
       
   783 			dir4.Append(KCommonFile);
       
   784 			gFindEntryDir2 = dir4;
       
   785 
       
   786 			DoTest2(FindEntryAccess);
       
   787 
       
   788 			User::After(200);
       
   789 			
       
   790 			startTime.HomeTime();
       
   791 			
       
   792 			r = file.Open(TheFs,dir1,EFileShareAny|EFileWrite);
       
   793 			FailIfError(r);
       
   794 			
       
   795 			endTime.HomeTime();
       
   796 			
       
   797 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   798 
       
   799 			file.Close();
       
   800 			DoTestKill();
       
   801 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   802 			}
       
   803 		
       
   804 		if(gTypes >= 2) 
       
   805 			{	
       
   806 			gFindDir = dir2;
       
   807 			dir2.Append(KCommonFile);
       
   808 			gFindEntryDir = dir2;
       
   809 			DoTest2(FindEntryAccess);
       
   810 			
       
   811 			User::After(200);
       
   812 			startTime.HomeTime();
       
   813 
       
   814 			r = file.Open(TheFs, dir2, EFileShareAny|EFileWrite);
       
   815 			FailIfError(r);
       
   816 			
       
   817 			endTime.HomeTime();
       
   818 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
   819 			file.Close();
       
   820 			DoTestKill();
       
   821 			
       
   822 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   823 			}
       
   824 			
       
   825 		if(gTypes >= 3) 
       
   826 			{	
       
   827 			gFindDir = dir3;	
       
   828 			dir3.Append(KCommonFile);
       
   829 			gFindEntryDir = dir3;
       
   830 			DoTest2(FindEntryAccess);
       
   831 
       
   832 			User::After(200);
       
   833 			startTime.HomeTime();
       
   834 
       
   835 			r = file.Open(TheFs, dir3, EFileShareAny|EFileWrite);
       
   836 			FailIfError(r);
       
   837 			
       
   838 			endTime.HomeTime();
       
   839 			timeTaken=endTime.MicroSecondsFrom(startTime);
       
   840 			DoTestKill();
       
   841 			
       
   842 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
   843 			file.Close();
       
   844 			}
       
   845 		}
       
   846 
       
   847 	PrintResult(aStep, 1, aN);
       
   848 	PrintResultTime(aStep, 2, timeTaken1);
       
   849 	PrintResultTime(aStep, 3, timeTaken2);
       
   850 	PrintResultTime(aStep, 4, timeTaken3);
       
   851 	}
       
   852 
       
   853 /** The test finds an entry in each directory
       
   854 	Precondition: the drive is already filled with the right files
       
   855 
       
   856 	@param aSelector Configuration in case of manual execution
       
   857 */
       
   858 LOCAL_C TInt TestFindEntry(TAny* aSelector)
       
   859 	{
       
   860 	TInt i = 100;
       
   861 	TInt testStep ;
       
   862 	
       
   863 	Validate(aSelector);
       
   864 	
       
   865 	
       
   866 	test.Printf(_L("#~TS_Title_%d,%d: Find entry last.txt, TFindFile\n"), gTestHarness, gTestCase);
       
   867 	
       
   868 	testStep = 1;
       
   869 	while(i <= KMaxFiles)
       
   870 		{
       
   871 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
   872 			FindFile1(i, testStep++);
       
   873 		i += 100;
       
   874 		}
       
   875 
       
   876 	gTestCase++;
       
   877 	test.Printf(_L("#~TS_Title_%d,%d: Find entry last.txt, RFile::Open \n"), gTestHarness, gTestCase);
       
   878 	
       
   879 	i = 100;
       
   880 	testStep = 1;
       
   881 	while(i <= KMaxFiles)
       
   882 		{
       
   883 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
   884 			FindFile2(i, testStep++);
       
   885 		i += 100;
       
   886 		}
       
   887 
       
   888 	gTestCase++;
       
   889 	return(KErrNone);
       
   890 	}
       
   891 
       
   892 /** The test finds an entry in each directory with multiple clients accessing the same directory
       
   893 	Precondition: the drive is already filled with the right files
       
   894 
       
   895 	@param aSelector Configuration in case of manual execution
       
   896 */
       
   897 LOCAL_C TInt TestFindEntryMultipleClients(TAny* aSelector)
       
   898 	{
       
   899 	TInt i=100;
       
   900 	TInt testStep;
       
   901 	
       
   902 	Validate(aSelector);
       
   903 	
       
   904 	test.Printf(_L("#~TS_Title_%d,%d: Find entry mult clients accessing same directory, TFindFile\n"), gTestHarness, gTestCase);
       
   905 	
       
   906 	i = 100;
       
   907 	testStep = 1;
       
   908 	while(i <= KMaxFiles)
       
   909 		{
       
   910 		if(i == 100 || i==1000 || i==5000 || i==10000)
       
   911 			FindFileM1(i, testStep++);
       
   912 		i+=100;
       
   913 		}
       
   914 
       
   915 	gTestCase++;
       
   916 	test.Printf(_L("#~TS_Title_%d,%d: Find entry mult clients accessing same directory, RFile::Open \n"), gTestHarness, gTestCase);
       
   917 	
       
   918 	i=100;
       
   919 	testStep = 1;
       
   920 	while(i <= KMaxFiles)
       
   921 		{
       
   922 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
   923 			FindFileM2(i, testStep++);
       
   924 		i += 100;
       
   925 		}
       
   926 
       
   927 	gTestCase++;
       
   928 	return(KErrNone);
       
   929 	}
       
   930 
       
   931 /** The test finds an entry in each directory with multiple clients accessing different directories
       
   932 	Precondition: the drive is already filled with the right files
       
   933 
       
   934 	@param aSelector Configuration in case of manual execution
       
   935 */
       
   936 LOCAL_C TInt TestFindEntryMultipleClientsDD(TAny* aSelector)
       
   937 	{
       
   938 	TInt i=100;
       
   939 	TInt testStep;
       
   940 	
       
   941 	Validate(aSelector);
       
   942 	
       
   943 	test.Printf(_L("#~TS_Title_%d,%d: Find entry mult clients accessing dif directory, TFindFile\n"), gTestHarness, gTestCase);
       
   944 	
       
   945 	i = 100;
       
   946 	testStep = 1;
       
   947 	while(i <= KMaxFiles)
       
   948 		{
       
   949 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
   950 			FindFileMD1(i, testStep++);
       
   951 		i += 100;
       
   952 		}
       
   953 
       
   954 	gTestCase++;
       
   955 	test.Printf(_L("#~TS_Title_%d,%d: Find entry mult clients accessing dir directory, RFile::Open \n"), gTestHarness, gTestCase);
       
   956 	
       
   957 	i = 100;
       
   958 	testStep = 1;
       
   959 	while(i <= KMaxFiles)
       
   960 		{
       
   961 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
   962 			FindFileMD2(i, testStep++);
       
   963 		i += 100;
       
   964 		}
       
   965 
       
   966 	gTestCase++;
       
   967 	return(KErrNone);
       
   968 	}
       
   969 
       
   970 /** Find last.txt with TFindFile and with two threads accessing the 2 directories
       
   971 
       
   972 	@param aN 		Number of files in the directory
       
   973 	@param aWild 	Wildcard string to be used in the search
       
   974 	@param aStep 	Test step
       
   975 */
       
   976 LOCAL_C void FindFileWild1(TInt aN, const TDesC& aWild, TInt aStep) 
       
   977 	{
       
   978 	TBuf16<100> dir1;
       
   979 	TBuf16<100> dir2;
       
   980 	TBuf16<100> dir3;
       
   981     TBuf16<100> dir4;
       
   982 
       
   983 	CDir* dir;
       
   984 	TInt r = 0;
       
   985 
       
   986 	TFindFile find(TheFs);
       
   987 	
       
   988 	TTime startTime;
       
   989 	TTime endTime;
       
   990 	TTimeIntervalMicroSeconds timeTaken(0);
       
   991 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
   992 	
       
   993 	if(aN <= gFilesLimit) 
       
   994 		{
       
   995 		dir1 = gSessionPath;
       
   996 		dir2 = gSessionPath;
       
   997 		dir3 = gSessionPath;
       
   998 		
       
   999 		dir4.Format(KDirMultipleName2, 1, aN);
       
  1000 		dir1.Append(dir4);
       
  1001 		
       
  1002 		dir4.Format(KDirMultipleName2, 2, aN);
       
  1003 		dir2.Append(dir4);
       
  1004 		
       
  1005 		dir4.Format(KDirMultipleName2, 3, aN);
       
  1006 		dir3.Append(dir4);
       
  1007 		
       
  1008 		if(gTypes >= 1) 
       
  1009 			{	
       
  1010 			dir4.Format(KDirMultipleName, 1, aN);
       
  1011 			startTime.HomeTime();
       
  1012 			
       
  1013 			r = find.FindWildByPath(aWild, &dir1, dir);
       
  1014 			FailIfError(r);
       
  1015 			
       
  1016 			endTime.HomeTime();
       
  1017 
       
  1018 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1019 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1020 			delete dir;
       
  1021 			}
       
  1022 		
       
  1023 		if(gTypes >= 2) 
       
  1024 			{	
       
  1025 			startTime.HomeTime();
       
  1026 
       
  1027 			r = find.FindWildByPath(_L("*.txt"), &dir2, dir);
       
  1028 			FailIfError(r);
       
  1029 
       
  1030 			endTime.HomeTime();
       
  1031 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1032 			
       
  1033 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1034 			delete dir;
       
  1035 			}
       
  1036 		
       
  1037 		if(gTypes >= 3) 
       
  1038 			{	
       
  1039 			startTime.HomeTime();
       
  1040 			
       
  1041 			r = find.FindWildByPath(_L("*.txt"), &dir3, dir);
       
  1042 			FailIfError(r);
       
  1043 			
       
  1044 			endTime.HomeTime();
       
  1045 			timeTaken=endTime.MicroSecondsFrom(startTime);
       
  1046 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1047 			delete dir;
       
  1048 			}
       
  1049 		}
       
  1050 	
       
  1051 	PrintResult(aStep, 1, aN);
       
  1052 	PrintResultTime(aStep, 2, timeTaken1);
       
  1053 	PrintResultTime(aStep, 3, timeTaken2);
       
  1054 	PrintResultTime(aStep, 4, timeTaken3);
       
  1055 	}
       
  1056 
       
  1057 /** Find last.txt with TFindFile and with two threads accessing the 2 directories
       
  1058 
       
  1059 	@param aN 		Number of files in the directory
       
  1060 	@param aWild 	Wildcard string to be used in the search
       
  1061 	@param aStep 	Test step
       
  1062 */
       
  1063 LOCAL_C void FindFileWild2(TInt aN, const TDesC& aWild, TInt aStep) 
       
  1064 	{
       
  1065 	TBuf16<100> dir1;
       
  1066 	TBuf16<100> dir2;
       
  1067 	TBuf16<100> dir3;
       
  1068     TBuf16<100> dir4;
       
  1069     TBuf16<100> temp;
       
  1070     
       
  1071 	
       
  1072 	TInt r = 0;
       
  1073 	TFindFile find(TheFs);
       
  1074 	TTime startTime;
       
  1075 	TTime endTime;
       
  1076 	TTimeIntervalMicroSeconds timeTaken(0);
       
  1077 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
  1078 	
       
  1079 	CDir* dir;
       
  1080 	
       
  1081 	if(aN <= gFilesLimit) 
       
  1082 		{
       
  1083 		dir1 = gSessionPath;
       
  1084 		dir2 = gSessionPath;
       
  1085 		dir3 = gSessionPath;
       
  1086 		
       
  1087 		dir4.Format(KDirMultipleName2, 1, aN);
       
  1088 		dir1.Append(dir4);
       
  1089 		
       
  1090 		dir4.Format(KDirMultipleName2, 2, aN);
       
  1091 		dir2.Append(dir4);
       
  1092 		
       
  1093 		dir4.Format(KDirMultipleName2, 3, aN);
       
  1094 		dir3.Append(dir4);
       
  1095 		
       
  1096 		gFindDir = dir1;
       
  1097 		
       
  1098 		if(gTypes >= 1) 
       
  1099 			{		
       
  1100 			temp = dir1;
       
  1101 			temp.Append(KCommonFile);
       
  1102 
       
  1103 			gFindEntryDir = temp;
       
  1104 			DoTest(FindEntryAccess);
       
  1105 
       
  1106 			startTime.HomeTime();
       
  1107 			
       
  1108 			r = find.FindWildByPath(aWild, &dir1, dir);
       
  1109 			FailIfError(r);
       
  1110 			
       
  1111 			endTime.HomeTime();
       
  1112 			DoTestKill();
       
  1113 			delete dir;
       
  1114 
       
  1115 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1116 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1117 			}
       
  1118 		
       
  1119 		if(gTypes >= 2) 
       
  1120 			{		
       
  1121 			gFindDir = dir2;
       
  1122 			temp = dir2;
       
  1123 			temp.Append(KCommonFile);
       
  1124 
       
  1125 			gFindEntryDir = temp;
       
  1126 			
       
  1127 
       
  1128 			DoTest(FindEntryAccess);
       
  1129 
       
  1130 			startTime.HomeTime();
       
  1131 
       
  1132 			r = find.FindWildByPath(aWild, &dir2, dir);
       
  1133 			FailIfError(r);
       
  1134 			
       
  1135 			endTime.HomeTime();
       
  1136 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1137 			DoTestKill();
       
  1138 			delete dir;
       
  1139 			
       
  1140 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1141 			}
       
  1142 		
       
  1143 		if(gTypes >= 3) 
       
  1144 			{	
       
  1145 			gFindDir = dir3;
       
  1146 			temp = dir3;
       
  1147 			temp.Append(KCommonFile);
       
  1148 
       
  1149 			gFindEntryDir = temp;
       
  1150 			DoTest(FindEntryAccess);
       
  1151 
       
  1152 			startTime.HomeTime();
       
  1153 			
       
  1154 			r = find.FindWildByPath(aWild, &dir3, dir);
       
  1155 			FailIfError(r);
       
  1156 			
       
  1157 			endTime.HomeTime();
       
  1158 			DoTestKill();
       
  1159 			delete dir;
       
  1160 			
       
  1161 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1162 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1163 			}
       
  1164 		}
       
  1165 	
       
  1166 	PrintResult(aStep, 1, aN);
       
  1167 	PrintResultTime(aStep, 2, timeTaken1);
       
  1168 	PrintResultTime(aStep, 3, timeTaken2);
       
  1169 	PrintResultTime(aStep, 4, timeTaken3);
       
  1170 	}
       
  1171 
       
  1172 /** Find last.txt with TFindFile and with two threads accessing the 2 directories
       
  1173 
       
  1174 	@param aN 		Number of files in the directory
       
  1175 	@param aWild 	Wildcard string to be used in the search
       
  1176 	@param aStep 	Test step
       
  1177 */
       
  1178 LOCAL_C void FindFileWild3(TInt aN, const TDesC& aWild, TInt aStep) 
       
  1179 	{
       
  1180 	TBuf16<100> dir1;
       
  1181 	TBuf16<100> dir2;
       
  1182 	TBuf16<100> dir3;
       
  1183     TBuf16<100> dir4;
       
  1184     TBuf16<100> temp;
       
  1185     TBuf16<100> temp2;
       
  1186 	
       
  1187 	TInt r = 0;
       
  1188 	TFindFile find(TheFs);
       
  1189 	TTime startTime;
       
  1190 	TTime endTime;
       
  1191 	TTimeIntervalMicroSeconds timeTaken(0);
       
  1192 	TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; 
       
  1193 
       
  1194 	CDir* dir;
       
  1195 
       
  1196 	if(aN <= gFilesLimit) 
       
  1197 		{
       
  1198 		dir1 = gSessionPath;
       
  1199 		dir2 = gSessionPath;
       
  1200 		dir3 = gSessionPath;
       
  1201 		
       
  1202 		dir4.Format(KDirMultipleName2, 1, aN);
       
  1203 		dir1.Append(dir4);
       
  1204 			
       
  1205 		temp=gSessionPath;
       
  1206 		dir4.Format(KDirMultipleName, 3, 300);
       
  1207 		
       
  1208 		temp.Append(dir4);
       
  1209 		gFindDir = dir1;
       
  1210 		gFindDir2 = temp;
       
  1211 		
       
  1212 		temp2 = gFindDir;
       
  1213 		temp2.Append(KCommonFile);
       
  1214 		gFindEntryDir = temp2;
       
  1215 		temp2 = gFindDir2;
       
  1216 		temp2.Append(KCommonFile);
       
  1217 		gFindEntryDir2 = temp2;
       
  1218 
       
  1219 		if(gTypes >= 1) 
       
  1220 			{	
       
  1221 			DoTest2(FindEntryAccess);
       
  1222 			
       
  1223 			dir4.Format(KDirMultipleName, 1, aN);
       
  1224 			startTime.HomeTime();
       
  1225 			
       
  1226 			r = find.FindWildByPath(aWild, &dir1, dir);
       
  1227 			FailIfError(r);
       
  1228 			
       
  1229 			endTime.HomeTime();
       
  1230 			DoTestKill();
       
  1231 			delete dir;
       
  1232 			
       
  1233 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1234 			timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1235 			}
       
  1236 		
       
  1237 		if(gTypes >= 2) 
       
  1238 			{	
       
  1239 			dir4.Format(KDirMultipleName2, 2, aN);
       
  1240 			dir2.Append(dir4);
       
  1241 
       
  1242 			temp = dir2;
       
  1243 			temp.Append(KCommonFile);
       
  1244 			gFindDir = dir2;
       
  1245 			gFindEntryDir = temp;
       
  1246 
       
  1247 			DoTest2(FindEntryAccess);
       
  1248 
       
  1249 			startTime.HomeTime();
       
  1250 
       
  1251 			r = find.FindWildByPath(aWild, &dir2, dir);
       
  1252 			FailIfError(r);
       
  1253 			
       
  1254 			endTime.HomeTime();
       
  1255 			DoTestKill();
       
  1256 			delete dir;
       
  1257 	
       
  1258 			timeTaken = endTime.MicroSecondsFrom(startTime);	
       
  1259 			timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1260 			}
       
  1261 			
       
  1262 		if(gTypes >= 3) 
       
  1263 			{	
       
  1264 			dir4.Format(KDirMultipleName2, 3, aN);
       
  1265 			dir3.Append(dir4);
       
  1266 
       
  1267 			temp = dir3;
       
  1268 			temp.Append(KCommonFile);
       
  1269 			gFindDir = dir3;
       
  1270 			gFindEntryDir = temp;
       
  1271 			
       
  1272 			DoTest2(FindEntryAccess);
       
  1273 
       
  1274 			startTime.HomeTime();
       
  1275 
       
  1276 			r = find.FindWildByPath(aWild, &dir3, dir);
       
  1277 			FailIfError(r);
       
  1278 			
       
  1279 			endTime.HomeTime();
       
  1280 			DoTestKill();
       
  1281 			delete dir;
       
  1282 			
       
  1283 			timeTaken = endTime.MicroSecondsFrom(startTime);
       
  1284 			timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit);
       
  1285 			}
       
  1286 		}
       
  1287 	
       
  1288 	PrintResult(aStep, 1, aN);
       
  1289 	PrintResultTime(aStep, 2, timeTaken1);
       
  1290 	PrintResultTime(aStep, 3, timeTaken2);
       
  1291 	PrintResultTime(aStep, 4, timeTaken3);
       
  1292 	}
       
  1293 
       
  1294 /** Times the system when looking for files with patterns
       
  1295 
       
  1296 	@param aSelector Configuration in case of manual execution
       
  1297 */
       
  1298 LOCAL_C TInt TestFileFindPattern(TAny* aSelector)
       
  1299 	{
       
  1300 	TInt i = 100;
       
  1301 	TInt testStep;
       
  1302 	
       
  1303 	Validate(aSelector);
       
  1304 	
       
  1305 	test.Printf(_L("#~TS_Title_%d,%d: Find *.txt, TFindFile::FindWildByPath() only 1 access to the directory \n"), gTestHarness, gTestCase);
       
  1306 	
       
  1307 	testStep = 1;
       
  1308 	while(i <= KMaxFiles)
       
  1309 		{
       
  1310 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1311 			FindFileWild1(i,_L("*.txt"), testStep++);
       
  1312 		i += 100;
       
  1313 		}
       
  1314 		
       
  1315 	gTestCase++;
       
  1316 	test.Printf(_L("#~TS_Title_%d,%d: Find *.txt, TFindFile::FindWildByPath() multiple clients accessing same directory\n"), gTestHarness, gTestCase);
       
  1317 	
       
  1318 	i = 100;
       
  1319 	testStep = 1;
       
  1320 	while(i <= KMaxFiles)
       
  1321 		{
       
  1322 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1323 			FindFileWild2(i,_L("*.txt"), testStep++);
       
  1324 		i += 100;
       
  1325 		}
       
  1326 
       
  1327 	gTestCase++;
       
  1328 	test.Printf(_L("#~TS_Title_%d,%d: Find *.txt, TFindFile::FindWildByPath() mult clients access dif directories\n"), gTestHarness, gTestCase);
       
  1329 	
       
  1330 	i = 100;
       
  1331 	testStep = 1;
       
  1332 	while(i <= KMaxFiles)
       
  1333 		{
       
  1334 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1335 			FindFileWild3(i,_L("*.txt"), testStep++);
       
  1336 		i += 100;
       
  1337 		}
       
  1338 	
       
  1339 	gTestCase++;
       
  1340 	test.Printf(_L("#~TS_Title_%d,%d: Find ffff*.txt, TFindFile::FindWildByPath() only 1 access to the directory \n"), gTestHarness, gTestCase);
       
  1341 	
       
  1342 	i = 100;
       
  1343 	testStep = 1;
       
  1344 	while(i <= KMaxFiles)
       
  1345 		{
       
  1346 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1347 			FindFileWild1(i,_L("ffff*.txt"), testStep++);
       
  1348 		i += 100;
       
  1349 		}
       
  1350 
       
  1351 	gTestCase++;
       
  1352 	test.Printf(_L("#~TS_Title_%d,%d: Find ffff*.txt, TFindFile::FindWildByPath() mult clients access same directory\n"), gTestHarness, gTestCase);
       
  1353 	
       
  1354 	i = 100;
       
  1355 	testStep = 1;
       
  1356 	while(i <= KMaxFiles)
       
  1357 		{
       
  1358 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1359 			FindFileWild2(i,_L("ffff*.txt"), testStep++);
       
  1360 		i += 100;
       
  1361 		}
       
  1362 
       
  1363 	gTestCase++;
       
  1364 	test.Printf(_L("#~TS_Title_%d,%d: Find ffff*.txt, TFindFile::FindWildByPath() mult clients access dif directories\n"), gTestHarness, gTestCase);
       
  1365 	
       
  1366 	i = 100;
       
  1367 	testStep = 1;
       
  1368 	while(i <= KMaxFiles)
       
  1369 		{
       
  1370 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1371 			FindFileWild3(i,_L("ffff*.txt"), testStep++);
       
  1372 		i += 100;
       
  1373 		}
       
  1374 	
       
  1375 
       
  1376 	gTestCase++;
       
  1377 	test.Printf(_L("\nFind last.*, TFindFile\n"));
       
  1378 	test.Printf(_L("#~TS_Title_%d,%d: Find last.*, TFindFile::FindWildByPath() only 1 access to the directory \n"), gTestHarness, gTestCase);
       
  1379 	
       
  1380 	i = 100;
       
  1381 	testStep = 1;
       
  1382 	while(i<=KMaxFiles)
       
  1383 		{
       
  1384 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1385 			FindFileWild1(i,_L("last.*"), testStep++);
       
  1386 		i += 100;
       
  1387 		}
       
  1388 	
       
  1389 	gTestCase++;
       
  1390 	test.Printf(_L("#~TS_Title_%d,%d: Find last.*, TFindFile::FindWildByPath() mult clients access same directory\n"), gTestHarness, gTestCase);
       
  1391 	
       
  1392 	i = 100;
       
  1393 	testStep = 1;
       
  1394 	while(i <= KMaxFiles)
       
  1395 		{
       
  1396 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1397 			FindFileWild2(i,_L("last.*"), testStep++);
       
  1398 		i += 100;
       
  1399 		}
       
  1400 
       
  1401 	gTestCase++;
       
  1402 	test.Printf(_L("#~TS_Title_%d,%d: Find last.*, TFindFile::FindWildByPath() mult clients access dif directories\n"), gTestHarness, gTestCase);
       
  1403 
       
  1404 	i = 100;
       
  1405 	testStep = 1;
       
  1406 	while(i <= KMaxFiles)
       
  1407 		{
       
  1408 		if(i == 100 || i == 1000 || i == 5000 || i == 10000)
       
  1409 			FindFileWild3(i,_L("last.*"), testStep++);
       
  1410 		i += 100;
       
  1411 		}
       
  1412 	
       
  1413 	gTestCase++;
       
  1414 	return(KErrNone);
       
  1415 	}
       
  1416 
       
  1417 /** It goes automatically through all the options
       
  1418 
       
  1419 	@param aSelector Configuration in case of manual execution
       
  1420 */
       
  1421 LOCAL_C TInt TestAll(TAny* aSelector)
       
  1422 	{
       
  1423 	Validate(aSelector);
       
  1424 
       
  1425 	TestFindEntry(aSelector);
       
  1426 	TestFindEntryMultipleClients(aSelector);
       
  1427 	TestFindEntryMultipleClientsDD(aSelector);
       
  1428 	TestFileFindPattern(aSelector);
       
  1429 
       
  1430 	return(KErrNone);
       
  1431 	}
       
  1432 
       
  1433 /** Call all tests
       
  1434 
       
  1435 */
       
  1436 GLDEF_C void CallTestsL()
       
  1437 	{
       
  1438 
       
  1439 	TInt r = client.CreateLocal(0);
       
  1440 	FailIfError(r);
       
  1441 	
       
  1442 	CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console());
       
  1443 	
       
  1444 	// Each test case of the suite has an identifyer for parsing purposes of the results
       
  1445 	gTestHarness = 3; 	
       
  1446 	gTestCase = 1;
       
  1447 	
       
  1448 	CreateDirWithNFiles(300, 3);
       
  1449 	PrintHeaders(1, _L("t_fsrdirscan. Directory scanning"));
       
  1450 	
       
  1451 	if(gMode==0) 
       
  1452 		{ // Manual	
       
  1453 		gSessionPath=_L("?:\\");
       
  1454 		TCallBack createFiles(TestFileCreate,TheSelector);
       
  1455 		TCallBack findFile(TestFindEntry,TheSelector);
       
  1456 		TCallBack findFileMC(TestFindEntryMultipleClients,TheSelector);
       
  1457 		TCallBack findFileMCDD(TestFindEntryMultipleClientsDD,TheSelector);
       
  1458 		TCallBack findFilePattern(TestFileFindPattern,TheSelector);
       
  1459 		TheSelector->AddDriveSelectorL(TheFs);
       
  1460 		TheSelector->AddLineL(_L("Create all files"),createFiles);
       
  1461 		TheSelector->AddLineL(_L("Find filename"),findFile);
       
  1462 		TheSelector->AddLineL(_L("Find with mult clients same directory"),findFileMC);
       
  1463 		TheSelector->AddLineL(_L("Find with mult clients dif directories"),findFileMCDD);
       
  1464 		TheSelector->AddLineL(_L("All using glob patterns"),findFilePattern);
       
  1465 		TheSelector->Run();
       
  1466 		}
       
  1467 	else 
       
  1468 		{ // Automatic
       
  1469 		TestAll(TheSelector);
       
  1470 		}
       
  1471 	
       
  1472 	client.Close();
       
  1473 	test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);
       
  1474 	delete TheSelector;
       
  1475 	}