|
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_benchmain.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <f32file.h> |
|
19 #include <e32test.h> |
|
20 #include <e32hal.h> |
|
21 #include <e32math.h> |
|
22 #include <f32dbg.h> |
|
23 #include "t_benchmain.h" |
|
24 #include "t_chlffs.h" |
|
25 |
|
26 RFs TheFs; |
|
27 TFileName gSessionPath; |
|
28 TFileName gExeFileName(RProcess().FileName()); |
|
29 TInt gAllocFailOff=KAllocFailureOff; |
|
30 TInt gAllocFailOn=KAllocFailureOff; |
|
31 TInt64 gSeed = 51703; |
|
32 TInt gFilesLimit; |
|
33 TInt gTypes; |
|
34 TInt gMode; |
|
35 TInt gFormat = EFalse; |
|
36 TInt gMinutes; |
|
37 TInt gFileSize = 0; // In Kbytes |
|
38 |
|
39 TInt gTestHarness = 0; |
|
40 TInt gTestCase = 1; |
|
41 TInt gTimeUnit = 1000; // values: 1 - us, 1000 - ms, 1000000 - s |
|
42 |
|
43 |
|
44 TChar gDriveToTest = ' '; |
|
45 |
|
46 |
|
47 //////////////////////////////////////////////////////////// |
|
48 // Template functions encapsulating ControlIo magic |
|
49 // |
|
50 template <class C> |
|
51 |
|
52 TInt controlIo(RFs &fs, TInt drv, TInt fkn, C &c) |
|
53 { |
|
54 TPtr8 ptrC((TUint8 *)&c, sizeof(C), sizeof(C)); |
|
55 |
|
56 TInt r = fs.ControlIo(drv, fkn, ptrC); |
|
57 |
|
58 return r; |
|
59 } |
|
60 |
|
61 /** Prints headers of FAT32 and File Cache benchmarking |
|
62 |
|
63 @param aType type of test (FAT32 = 1/2 or File Cache = 3/4/5) |
|
64 @param |
|
65 */ |
|
66 void PrintHeaders(TInt aType, TPtrC16 aTitle ) |
|
67 { |
|
68 TBuf16<250> title = _L("#~TestTitle_%d: "); |
|
69 |
|
70 title.Append(aTitle); |
|
71 title.Append(_L("\n")); |
|
72 |
|
73 test.Printf(_L("#~TestId=%d\n"), gTestHarness); |
|
74 test.Printf(title, gTestHarness); |
|
75 test.Printf(_L("#~Report Variant: \n")); |
|
76 test.Printf(_L("#~Report Description: \n")); |
|
77 |
|
78 _LIT(KSeconds,"seconds"); |
|
79 _LIT(KMilliSecs,"milliseconds"); |
|
80 _LIT(KMicroSecs,"microseconds"); |
|
81 |
|
82 TPtrC16 timeUnit; |
|
83 if (gTimeUnit == 1) |
|
84 timeUnit.Set(KMicroSecs); |
|
85 else if (gTimeUnit == 1000) |
|
86 timeUnit.Set(KMilliSecs); |
|
87 else if (gTimeUnit == 1000000) |
|
88 timeUnit.Set(KSeconds); |
|
89 else |
|
90 { |
|
91 test.Printf(_L("Please, check gTimeUnit value\n")); |
|
92 test(EFalse); |
|
93 } |
|
94 |
|
95 |
|
96 if(aType == 1) |
|
97 { // All FAT32 tests but t_fsrrepeat |
|
98 test.Printf(_L("#~TestParam_%d: MaxFiles=%d, type=%d, mode=%d, timeUnit=%S\n"), gTestHarness, gFilesLimit, gTypes, gMode, &timeUnit); |
|
99 |
|
100 test.Printf(_L("#~TestRows_%d: 4\n"), gTestHarness); |
|
101 test.Printf(_L("#~TestColumns_%d: 4, NFiles, 8_3, 20_chars, 50_50\n"), gTestHarness); |
|
102 } |
|
103 else if(aType == 2) |
|
104 { // t_fsrrepeat |
|
105 test.Printf(_L("#~TestParam_%d: MaxFiles=%d, type=%d, mode=%d, timeUnit=%S\n"), gTestHarness, gFilesLimit, gTypes, gMode, &timeUnit); |
|
106 |
|
107 test.Printf(_L("#~TestRows_%d: 12\n"), gTestHarness); |
|
108 test.Printf(_L("#~TestColumns_%d: 4, DirName, 1st, 2nd, 3rd\n"), gTestHarness); |
|
109 } |
|
110 else if(aType == 3) |
|
111 { // Large sequential reads/writes |
|
112 test.Printf(_L("#~TestParam_%d: mode=%d, timeUnit=%S\n"), gTestHarness, gMode, &timeUnit); |
|
113 |
|
114 test.Printf(_L("#~TestRows_%d: 8\n"), gTestHarness); |
|
115 test.Printf(_L("#~TestColumns_%d: 4, bsize, 100KB, 1MB, 10MB\n"), gTestHarness); |
|
116 } |
|
117 else if(aType == 4) |
|
118 { // Small random reads/writes |
|
119 test.Printf(_L("#~TestParam_%d: mode=%d, timeUnit=%S\n"), gTestHarness, gMode, &timeUnit); |
|
120 |
|
121 test.Printf(_L("#~TestRows_%d: 11\n"), gTestHarness); |
|
122 test.Printf(_L("#~TestColumns_%d: 8, bsize, 1KB, 2KB, 4KB, 8KB, 16KB, 32KB, 64KB\n"), gTestHarness); |
|
123 } |
|
124 else if(aType == 5) |
|
125 { // Streaming |
|
126 test.Printf(_L("#~TestParam_%d: mode=%d, timeUnit=%S\n"), gTestHarness, gMode, &timeUnit); |
|
127 |
|
128 test.Printf(_L("#~TestRows_%d: 6\n"), gTestHarness); |
|
129 test.Printf(_L("#~TestColumns_%d: 4, bsize, 5m_w, 15s_w_r, 15s_w_r \n"), gTestHarness); |
|
130 } |
|
131 else |
|
132 { |
|
133 test.Printf(_L("Check the function PrintHeaders() in t_benchmain.cpp, which wasn't called with the right parameters\n")); |
|
134 test(EFalse); |
|
135 } |
|
136 |
|
137 } |
|
138 |
|
139 /** Prints a line of results |
|
140 |
|
141 @param aPosX Row of the table |
|
142 @param aPosY Column of the table |
|
143 @param aValue Value figure for that position |
|
144 */ |
|
145 void PrintResultTime( TInt aPosX, TInt aPosY, TInt aValue) |
|
146 { |
|
147 test.Printf(_L("#~TS_Res_%d,%d,[%d,%d]=%d\n "), gTestHarness, gTestCase, aPosX, aPosY, aValue ); |
|
148 } |
|
149 |
|
150 |
|
151 /** Prints any other type of data |
|
152 |
|
153 @param aPosX Row of the table |
|
154 @param aPosY Column of the table |
|
155 @param aValue Value figure for that position |
|
156 */ |
|
157 void PrintResult( TInt aPosX, TInt aPosY, TInt aValue) |
|
158 { |
|
159 test.Printf(_L("#~TS_Res_%d,%d,[%d,%d]=%d\n "), gTestHarness, gTestCase, aPosX, aPosY, aValue); |
|
160 } |
|
161 |
|
162 /** Prints string |
|
163 |
|
164 @param aPosX Row of the table |
|
165 @param aPosY Column of the table |
|
166 @param aValue Value figure for that position |
|
167 */ |
|
168 void PrintResultS( TInt aPosX, TInt aPosY, TDes16& aValue) |
|
169 { |
|
170 TBuf16<250> buffer = _L("#~TS_Res_%d,%d,[%d,%d]="); |
|
171 |
|
172 buffer.Append(aValue); |
|
173 buffer.Append(_L("\n")); |
|
174 test.Printf(buffer, gTestHarness, gTestCase, aPosX, aPosY); |
|
175 } |
|
176 |
|
177 /** Call all RFormat methods |
|
178 |
|
179 @param aDrive Drive to be formatted |
|
180 */ |
|
181 void FormatFat(TDriveUnit aDrive) |
|
182 { |
|
183 RFormat format; |
|
184 TPckgBuf<TInt> count; |
|
185 TInt r = format.Open(TheFs, aDrive.Name(), EQuickFormat, count()); |
|
186 FailIfError(r); |
|
187 |
|
188 test(count() == 100); |
|
189 TRequestStatus status; |
|
190 while (count()) |
|
191 { |
|
192 format.Next(count, status); |
|
193 User::WaitForRequest(status); |
|
194 test(status == KErrNone || status == KErrNotSupported); |
|
195 } |
|
196 |
|
197 format.Close(); |
|
198 test.Printf(_L("Drive formatted\n")); |
|
199 } |
|
200 |
|
201 /** Validates the drive selection |
|
202 |
|
203 @param aDrive Drive to be validated |
|
204 @param aTest Type of test |
|
205 */ |
|
206 TInt ValidateDriveSelection(TDriveUnit aDrive,TSelectedTest aTest) |
|
207 { |
|
208 if ((aDrive == EDriveZ) || ((aDrive == EDriveC) && (aTest == ELocalDriveTest))) |
|
209 { |
|
210 test.Printf(_L("Test not available for this drive\n")); |
|
211 test.Printf(_L("Press any key to continue...\n")); |
|
212 return (KErrNotSupported); |
|
213 } |
|
214 else |
|
215 return (KErrNone); |
|
216 } |
|
217 |
|
218 /** Validates the selection for this tests and update appropriate variables |
|
219 |
|
220 @param aSelector This object is meant to give information about what needs |
|
221 to be tests in manual mode |
|
222 */ |
|
223 TInt Validate(TAny* aSelector) |
|
224 { |
|
225 if(gMode == 0) |
|
226 { |
|
227 if (((CSelectionBox*)aSelector)->CurrentKeyPress() != EKeyEnter) |
|
228 return(KErrNone); |
|
229 |
|
230 TInt r = ValidateDriveSelection(((CSelectionBox*)aSelector)->CurrentDrive(),EFileSeekTest); |
|
231 if (r == KErrNotSupported) |
|
232 return (r); |
|
233 |
|
234 TDriveUnit drive = ((CSelectionBox*)aSelector)->CurrentDrive(); |
|
235 gSessionPath[0] = TUint8('A' + drive); |
|
236 r = TheFs.SetSessionPath(gSessionPath); |
|
237 FailIfError(r); |
|
238 } |
|
239 |
|
240 return KErrNone; |
|
241 } |
|
242 |
|
243 /** Prints current volume information |
|
244 |
|
245 */ |
|
246 void PrintVolInfo() |
|
247 { |
|
248 TVolumeInfo volInfo; |
|
249 TInt r; |
|
250 |
|
251 r = TheFs.Volume(volInfo); |
|
252 FailIfError(r); |
|
253 |
|
254 test.Printf(_L("DriveAtt:0x%X, MediaAtt:0x%X, Free:%d KBytes\n"), volInfo.iDrive.iDriveAtt, volInfo.iDrive.iMediaAtt, (TUint32)(volInfo.iFree / 1024)); |
|
255 } |
|
256 |
|
257 /** Create directory with a number of files, with specified file name type |
|
258 |
|
259 @param aN number of files to create |
|
260 @param aType file names type : 1 - 8.3, 2 - 20 characters, 3 - 50/50 |
|
261 */ |
|
262 TInt CreateDirWithNFiles(TInt aN, TInt aType) |
|
263 { |
|
264 TInt i,r=0; |
|
265 |
|
266 RFile file; |
|
267 TBuf16<50> directory; |
|
268 TBuf16<50> dirtemp; |
|
269 |
|
270 TBuf16<50> path; |
|
271 TBuf16<50> buffer(50); |
|
272 |
|
273 dirtemp.Format(KDirMultipleName,aType, aN); |
|
274 directory=gSessionPath; |
|
275 directory.Append(dirtemp); |
|
276 |
|
277 r = TheFs.MkDir(directory); |
|
278 test(r == KErrNone || r == KErrAlreadyExists); |
|
279 |
|
280 const TUint KNumFilesPrintTreshold = 100; |
|
281 const TInt KFileSize = gFileSize * 1024; |
|
282 |
|
283 PrintVolInfo(); |
|
284 |
|
285 i = 0; |
|
286 while( i < aN ) |
|
287 { |
|
288 // generate file name depending on type required |
|
289 switch(aType) |
|
290 { |
|
291 case 1: // 8.3 filemnames |
|
292 FileNamesGeneration(buffer, 8, i, i%3+1); |
|
293 break; |
|
294 |
|
295 case 2: // 20 characrer filenames |
|
296 FileNamesGeneration(buffer, 20, i, i%3+1); |
|
297 break; |
|
298 |
|
299 case 3: // 50/50 mix |
|
300 if(i%2) |
|
301 FileNamesGeneration(buffer, 8, i, i%3+1) ; |
|
302 else |
|
303 FileNamesGeneration(buffer, 20, i, i%3+1) ; |
|
304 break; |
|
305 default: |
|
306 test(0); |
|
307 break; |
|
308 }; |
|
309 path = directory; |
|
310 path.Append(buffer); |
|
311 |
|
312 // create or replace a file |
|
313 r = file.Replace(TheFs, path, EFileShareAny|EFileWrite); |
|
314 if(r != KErrNone) |
|
315 { |
|
316 PrintVolInfo(); |
|
317 test.Printf(_L("Error creating file: %S, %d\n"), &path, r); |
|
318 test(0); |
|
319 } |
|
320 |
|
321 // set file size if required, file contents doesn't matter |
|
322 if(gFileSize > 0) |
|
323 { |
|
324 r = file.SetSize(KFileSize); |
|
325 if(r != KErrNone) |
|
326 { |
|
327 PrintVolInfo(); |
|
328 test.Printf(_L("Error setting file size: %S, %d, err:%d\n"), &path, KFileSize, r); |
|
329 test(0); |
|
330 } |
|
331 } |
|
332 |
|
333 file.Close(); |
|
334 |
|
335 if(i > 0 && ((i+1)%KNumFilesPrintTreshold) == 0) |
|
336 { |
|
337 test.Printf(_L("created %d files, type:%d\n"), i + 1, aType); |
|
338 } |
|
339 |
|
340 i++; |
|
341 }//while |
|
342 |
|
343 |
|
344 // write "last.txt" file to the end of directory |
|
345 path = directory; |
|
346 path.Append(KCommonFile); |
|
347 r = file.Replace(TheFs,path,EFileShareAny|EFileWrite); |
|
348 if(r != KErrNone) |
|
349 { |
|
350 PrintVolInfo(); |
|
351 test.Printf(_L("Error creating file: %S, %d\n"), &path, r); |
|
352 test(0); |
|
353 } |
|
354 |
|
355 // put random content to the "last.txt" file if specified length of files > 0 |
|
356 if(gFileSize > 0) |
|
357 { |
|
358 r = file.SetSize(gFileSize * 1024); // gFileSize is in KBytes |
|
359 if(r != KErrNone) |
|
360 { |
|
361 PrintVolInfo(); |
|
362 test.Printf(_L("Error setting file size: %S, %d\n"), &path, r); |
|
363 test(0); |
|
364 } |
|
365 } |
|
366 |
|
367 file.Close(); |
|
368 |
|
369 return(KErrNone); |
|
370 } |
|
371 |
|
372 |
|
373 /** |
|
374 Creates 12 directories with different sort of files and namefiles |
|
375 100 files with 8.3, 20 chars and 50/50 |
|
376 1000 files with 8.3, 20 chars and 50/50 |
|
377 5000 files with 8.3, 20 chars and 50/50 |
|
378 10000 files with 8.3, 20 chars and 50/50 |
|
379 */ |
|
380 TInt TestFileCreate(TAny* aSelector) |
|
381 { |
|
382 TInt i = 100, j = 1; |
|
383 |
|
384 Validate(aSelector); |
|
385 |
|
386 while(i <= gFilesLimit) |
|
387 { |
|
388 if(i == 100) |
|
389 { |
|
390 j = 1; |
|
391 while(j <= gTypes) |
|
392 CreateDirWithNFiles(100, j++); |
|
393 } |
|
394 if(i == 1000) |
|
395 { |
|
396 j=1; |
|
397 while(j <= gTypes) |
|
398 CreateDirWithNFiles(1000, j++); |
|
399 } |
|
400 if(i == 5000) |
|
401 { |
|
402 j = 1; |
|
403 while(j <= gTypes) |
|
404 CreateDirWithNFiles(5000, j++); |
|
405 } |
|
406 if(i == 10000) |
|
407 { |
|
408 j = 1; |
|
409 while(j <= gTypes) |
|
410 CreateDirWithNFiles(10000, j++); |
|
411 } |
|
412 i += 100; |
|
413 } |
|
414 |
|
415 return(KErrNone); |
|
416 } |
|
417 |
|
418 /** Generate a filename according to the parameters configuration |
|
419 |
|
420 @param aBuffer Buffer where the name of the file will be returned |
|
421 @param aLong Length of the name of the file |
|
422 @param aPos Number to be attached to the name of the file |
|
423 @param ext Type of extension (1/2/3) |
|
424 */ |
|
425 void FileNamesGeneration(TDes16& aBuffer, TInt aLong, TInt aPos,TInt ext) |
|
426 { |
|
427 TInt padding; |
|
428 TInt i=0; |
|
429 TBuf16<10> tempbuf; |
|
430 |
|
431 _LIT(KNumber,"%d"); |
|
432 tempbuf.Format(KNumber, aPos); |
|
433 padding = aLong - tempbuf.Size() / 2; |
|
434 aBuffer = _L(""); |
|
435 while(i < padding) |
|
436 { |
|
437 aBuffer.Append('F'); |
|
438 i++; |
|
439 } |
|
440 |
|
441 _LIT(KExtension1, ".TXT"); |
|
442 _LIT(KExtension2, ".HTM"); |
|
443 _LIT(KExtension3, ".LOG"); |
|
444 |
|
445 aBuffer.Append(tempbuf); |
|
446 switch(ext) |
|
447 { |
|
448 case 1: aBuffer.Append(KExtension1);break; |
|
449 case 2: aBuffer.Append(KExtension2);break; |
|
450 case 3: aBuffer.Append(KExtension3);break; |
|
451 default: aBuffer.Append(KExtension1);break; |
|
452 } |
|
453 } |
|
454 |
|
455 /** Do a checkdisk and report failure |
|
456 |
|
457 */ |
|
458 void CheckDisk() |
|
459 { |
|
460 test.Next(_L("Check Disk")); |
|
461 TInt r = TheFs.CheckDisk(gSessionPath); |
|
462 if (r != KErrNone && r != KErrNotSupported && r != KErrPermissionDenied) |
|
463 ReportCheckDiskFailure(r); |
|
464 } |
|
465 |
|
466 /** Report a disk failure |
|
467 |
|
468 @param aRet The error will be returned in this variable |
|
469 */ |
|
470 void ReportCheckDiskFailure(TInt aRet) |
|
471 { |
|
472 test.Printf(_L("CHECKDISK FAILED: ")); |
|
473 switch(aRet) |
|
474 { |
|
475 case 1: test.Printf(_L("File cluster chain contains a bad value (<2 or >maxCluster)\n")); break; |
|
476 case 2: test.Printf(_L("Two files are linked to the same cluster\n")); break; |
|
477 case 3: test.Printf(_L("Unallocated cluster contains a value != 0\n")); break; |
|
478 case 4: test.Printf(_L("Size of file != number of clusters in chain\n")); break; |
|
479 default: test.Printf(_L("Undefined Error value %d\n"),aRet); |
|
480 } |
|
481 } |
|
482 |
|
483 |
|
484 /** Expand the cleanup stack |
|
485 |
|
486 */ |
|
487 void PushLotsL() |
|
488 { |
|
489 TInt i; |
|
490 |
|
491 for(i=0;i<1000;i++) |
|
492 CleanupStack::PushL((CBase*)NULL); |
|
493 |
|
494 CleanupStack::Pop(1000); |
|
495 } |
|
496 |
|
497 /** Do testing on aDrive |
|
498 |
|
499 @param aDrive Drive for the testing |
|
500 */ |
|
501 void DoTests(TInt aDrive) |
|
502 { |
|
503 |
|
504 gSessionPath=_L("?:\\"); |
|
505 TChar driveLetter; |
|
506 TInt r = TheFs.DriveToChar(aDrive, driveLetter); |
|
507 FailIfError(r); |
|
508 gSessionPath[0] = (TText)driveLetter; |
|
509 r = TheFs.SetSessionPath(gSessionPath); |
|
510 FailIfError(r); |
|
511 |
|
512 test.Printf(_L("DoTests() Session Path: %S\n"),&gSessionPath); |
|
513 |
|
514 CheckMountLFFS(TheFs,driveLetter); |
|
515 |
|
516 User::After(1000000); |
|
517 |
|
518 r = TheFs.MkDirAll(gSessionPath); |
|
519 if (r != KErrNone && r != KErrAlreadyExists) |
|
520 { |
|
521 test.Printf(_L("MkDirAll() r %d\n"),r); |
|
522 test(EFalse); |
|
523 } |
|
524 TheFs.ResourceCountMarkStart(); |
|
525 TRAP(r,CallTestsL()); |
|
526 if (r == KErrNone) |
|
527 TheFs.ResourceCountMarkEnd(); |
|
528 else |
|
529 { |
|
530 test.Printf(_L("Error: Leave %d\n"),r); |
|
531 test(EFalse); |
|
532 } |
|
533 |
|
534 CheckDisk(); |
|
535 } |
|
536 |
|
537 /** Syntax of the test |
|
538 |
|
539 @param aOption option 1 is related to FAT32 testing/option 2 relates to the file caching |
|
540 */ |
|
541 void syntax (TInt aOption) |
|
542 { |
|
543 _LIT(KBad, "Wrong argument"); |
|
544 |
|
545 if(aOption == 1) |
|
546 { |
|
547 test.Printf(_L("Usage: \n testname <drive> <100/1000/5000/10000 number of files> <1/2/3 type of files> <mode 0 manual, 1 automatic>\n ")); |
|
548 } |
|
549 else if (aOption == 2) |
|
550 { |
|
551 test.Printf(_L("Usage: \n t_fcachebm <drive> <mode 0 manual, 1 automatic>\n ")); |
|
552 } |
|
553 |
|
554 User::Panic(KBad,KErrArgument); |
|
555 } |
|
556 |
|
557 /** |
|
558 Parse commands : |
|
559 |
|
560 1) t_name drive maxfiles filetypes manual/automatic |
|
561 maxfiles can be: 100, 1000, 5000 or 10000 |
|
562 filetypes can be 1 for 8.3, 2 for 20 chars as well and 3 for all |
|
563 manual 0 and automatic 1 |
|
564 2) t_fcachebm drive manua/automatic |
|
565 3) t_fsrcreatefiles |
|
566 */ |
|
567 void ParseCommandArguments() |
|
568 { |
|
569 TBuf<0x100> cmd; |
|
570 User::CommandLine(cmd); |
|
571 |
|
572 test.Printf(_L("Command line:\n")); |
|
573 test.Printf(cmd); |
|
574 test.Printf(_L("\n")); |
|
575 |
|
576 TLex lex(cmd); |
|
577 lex.SkipSpace(); |
|
578 |
|
579 TPtrC token; |
|
580 TFileName thisfile=RProcess().FileName(); |
|
581 |
|
582 TInt i = 0; |
|
583 TInt testcase = 0; |
|
584 TBool finish = EFalse; |
|
585 _LIT(KCacheBM, "Z:\\sys\\bin\\t_fcachebm.exe"); |
|
586 _LIT(KCreate, "Z:\\sys\\bin\\t_fsrcreatefiles.exe"); |
|
587 |
|
588 test.Printf(KCacheBM); |
|
589 test.Printf(thisfile); |
|
590 while((!finish) && (i <= 5)) |
|
591 { |
|
592 switch(i) |
|
593 { |
|
594 case 0: |
|
595 if((thisfile != KCacheBM) && (thisfile != KCreate)) // FAT32 tests |
|
596 testcase = 1; |
|
597 else if(thisfile == KCreate) // FAT32 test files creation |
|
598 testcase = 3; |
|
599 else // File Cache (PREQ914) performance tests |
|
600 testcase = 2; |
|
601 break; |
|
602 case 1: |
|
603 test.Printf(_L("\nCLP=%S\n"), &token); |
|
604 if(token.Length() != 0) |
|
605 { |
|
606 gDriveToTest = token[0]; |
|
607 gDriveToTest.UpperCase(); |
|
608 if(gMode==1) |
|
609 gSessionPath[0] = (TText)gDriveToTest; |
|
610 } |
|
611 else |
|
612 { |
|
613 gDriveToTest = 'C'; |
|
614 } |
|
615 break; |
|
616 case 2: |
|
617 if((testcase == 1) || (testcase == 3)) // testcase == 1 || testcase == 3 |
|
618 { |
|
619 if(token.Length() != 0) |
|
620 { |
|
621 test.Printf(_L("Number of files=%S\n"),&token); |
|
622 if(token[0]=='5') |
|
623 { |
|
624 gFilesLimit = 5000; |
|
625 } |
|
626 else |
|
627 if(token[0] == '1' && token.Length() == 3) gFilesLimit = 100; |
|
628 else if(token[0] == '1' && token.Length() == 4) gFilesLimit = 1000; |
|
629 else if(token[0] == '1' && token.Length() == 5) gFilesLimit = 10000; |
|
630 else syntax(testcase); |
|
631 } |
|
632 else |
|
633 gFilesLimit = 10000 ; |
|
634 |
|
635 } |
|
636 else // (testcase == 2) |
|
637 { |
|
638 if(token.Length() == 1) |
|
639 { |
|
640 TChar c = token[0]; |
|
641 test.Printf(_L("0 manual/1 automatic ? %S\n"),&token); |
|
642 if(c.IsDigit() && ((c == '0') || (c == '1'))) |
|
643 gMode = c.GetNumericValue(); |
|
644 else syntax(testcase); |
|
645 } |
|
646 else |
|
647 syntax(testcase); |
|
648 } |
|
649 break; |
|
650 case 3: |
|
651 if((testcase == 1) || (testcase == 3)) |
|
652 { |
|
653 if(token.Length() == 1) |
|
654 { |
|
655 TChar c = token[0]; |
|
656 test.Printf(_L("File type=%S\n"), &token); |
|
657 if(c.IsDigit() &&((c == '1') || (c == '2') || (c == '3'))) |
|
658 gTypes = c.GetNumericValue(); |
|
659 else syntax(testcase); |
|
660 } |
|
661 else // Default value |
|
662 gTypes = 3; |
|
663 } |
|
664 break; |
|
665 case 4: |
|
666 if((testcase == 1) || (testcase == 3)) |
|
667 { |
|
668 TChar c = token[0]; |
|
669 if(token.Length() == 1) |
|
670 { |
|
671 test.Printf(_L("0 manual/1 automatic ? %S\n"),&token); |
|
672 if(c.IsDigit() && ((c == '0') || (c == '1'))) |
|
673 gMode = c.GetNumericValue(); |
|
674 else syntax(1); |
|
675 } |
|
676 else |
|
677 gMode = 0; |
|
678 } |
|
679 break; |
|
680 case 5: |
|
681 if(testcase == 3) |
|
682 { |
|
683 TChar c = token[0]; |
|
684 if(c.IsDigit()) |
|
685 gFileSize = c.GetNumericValue(); |
|
686 else syntax(1); |
|
687 } |
|
688 break; |
|
689 |
|
690 default: |
|
691 syntax(testcase); |
|
692 } |
|
693 finish = lex.Eos(); |
|
694 token.Set(lex.NextToken()); |
|
695 i++; |
|
696 } |
|
697 } |
|
698 |
|
699 /** Main function |
|
700 |
|
701 @return KErrNone if everything was ok, panics otherwise |
|
702 */ |
|
703 TInt E32Main() |
|
704 { |
|
705 CTrapCleanup* cleanup; |
|
706 cleanup = CTrapCleanup::New(); |
|
707 TRAPD(r,PushLotsL()); |
|
708 __UHEAP_MARK; |
|
709 |
|
710 test.Title(); |
|
711 test.Start(_L("Starting benchmarking tests...")); |
|
712 |
|
713 ParseCommandArguments(); //need this for drive letter to test and all the parameters |
|
714 |
|
715 r = TheFs.Connect(); |
|
716 FailIfError(r); |
|
717 TheFs.SetAllocFailure(gAllocFailOn); |
|
718 TTime timerC; |
|
719 timerC.HomeTime(); |
|
720 TFileName sessionp; |
|
721 TheFs.SessionPath(sessionp); |
|
722 |
|
723 TInt theDrive; |
|
724 |
|
725 r = TheFs.CharToDrive(gDriveToTest,theDrive); |
|
726 FailIfError(r); |
|
727 |
|
728 PrintDrvInfo(TheFs, theDrive); |
|
729 |
|
730 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
731 TPckgBuf<TIOCacheValues> pkgOrgValues; |
|
732 TIOCacheValues& orgValues=pkgOrgValues(); |
|
733 r = controlIo(TheFs,theDrive, KControlIoCacheCount, orgValues); |
|
734 FailIfError(r); |
|
735 |
|
736 test.Printf(_L("\nNumber of items on close list at beginning=%d\n"), orgValues.iCloseCount); |
|
737 test.Printf(_L("Number of items on free list at beginning=%d\n"), orgValues.iFreeCount); |
|
738 test.Printf(_L("Number of items allocated at beginning=%d\n"), orgValues.iAllocated); |
|
739 #endif |
|
740 |
|
741 DoTests(theDrive); |
|
742 |
|
743 TTime endTimeC; |
|
744 endTimeC.HomeTime(); |
|
745 TTimeIntervalSeconds timeTakenC; |
|
746 r = endTimeC.SecondsFrom(timerC,timeTakenC); |
|
747 FailIfError(r); |
|
748 |
|
749 if(gFormat) |
|
750 { |
|
751 FormatFat(gSessionPath[0]-'A'); |
|
752 } |
|
753 |
|
754 test.Printf(_L("#~T_Timing_%d: %d S\n"), gTestHarness, timeTakenC.Int()); |
|
755 TheFs.SetAllocFailure(gAllocFailOff); |
|
756 |
|
757 #if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
758 TPckgBuf<TIOCacheValues> pkgValues; |
|
759 TIOCacheValues& values=pkgValues(); |
|
760 r = controlIo(TheFs,theDrive, KControlIoCacheCount, values); |
|
761 test(r==KErrNone); |
|
762 |
|
763 test.Printf(_L("\nNumber of items on close list at end=%d\n"),values.iCloseCount); |
|
764 test.Printf(_L("Number of items on free list at end=%d\n"),values.iFreeCount); |
|
765 test.Printf(_L("Number of items allocated at the end=%d\n"),values.iAllocated); |
|
766 |
|
767 test(orgValues.iCloseCount==values.iCloseCount); |
|
768 test(orgValues.iAllocated == values.iAllocated); |
|
769 #endif |
|
770 |
|
771 TheFs.Close(); |
|
772 test.End(); |
|
773 test.Close(); |
|
774 __UHEAP_MARKEND; |
|
775 delete cleanup; |
|
776 return(KErrNone); |
|
777 } |