author | Mike Kinghan <mikek@symbian.org> |
Mon, 19 Jul 2010 08:40:05 +0100 | |
branch | GCC_SURGE |
changeset 209 | 6035754ebf88 |
parent 206 | ced41fd9a298 |
permissions | -rw-r--r-- |
0 | 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_fsropen.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <f32file.h> |
|
19 |
#include <e32test.h> |
|
20 |
#include "t_select.h" |
|
206
ced41fd9a298
Fix for bug 3288 - "No such file or directory" breaks in f32test Linux build
Mike Kinghan <mikek@symbian.org>
parents:
0
diff
changeset
|
21 |
#include "../server/t_server.h" |
0 | 22 |
#include "t_benchmain.h" |
23 |
||
24 |
GLDEF_D RTest test(_L("File Server Benchmarks, Open File")); |
|
25 |
||
26 |
//---------------------------------------------------------------------------------------------- |
|
27 |
//! @SYMTestCaseID PBASE-T_FSROPEN-0275 |
|
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 the opening and read of 4 Kb of last.txt file in each directory |
|
33 |
//! 2. Time the opening and read of 4 Kb of last.txt file in each directory |
|
34 |
//! with two clients accessing the directory |
|
35 |
//! 3. Time the opening and read of 4 Kb of last.txt file in each directory |
|
36 |
//! with two clients accessing different directories |
|
37 |
//! |
|
38 |
//! @SYMTestExpectedResults Finishes if the system behaves as expected, panics otherwise |
|
39 |
//! @SYMTestPriority High |
|
40 |
//! @SYMTestStatus Implemented |
|
41 |
//---------------------------------------------------------------------------------------------- |
|
42 |
||
43 |
||
44 |
LOCAL_D RSemaphore client; |
|
45 |
LOCAL_D const TInt KHeapSize=0x6000; |
|
46 |
LOCAL_D TBuf8<4096> buf; |
|
47 |
||
48 |
LOCAL_D TDriveList gDriveList; |
|
49 |
LOCAL_D TFileName gFindEntryDir; |
|
50 |
LOCAL_D TBuf<100> gFindDir; |
|
51 |
||
52 |
LOCAL_D TFileName gFindEntryDir2; |
|
53 |
LOCAL_D TBuf<100> gFindDir2; |
|
54 |
||
55 |
// Concurrent thread |
|
56 |
RThread gSpeedy; |
|
57 |
RThread gSpeedyII; |
|
58 |
||
59 |
LOCAL_D TInt ThreadCount=0; |
|
60 |
||
61 |
_LIT(KDirMultipleName2, "dir%d_%d\\"); |
|
62 |
||
63 |
/** Find entry in directory |
|
64 |
||
65 |
*/ |
|
66 |
LOCAL_C TInt FindEntryAccess2(TAny*) |
|
67 |
{ |
|
68 |
RFs fs; |
|
69 |
TInt r = fs.Connect(); |
|
70 |
RTest test(_L("test 2")); |
|
71 |
||
72 |
r = fs.SetSessionPath(gSessionPath); |
|
73 |
||
74 |
client.Signal(); |
|
75 |
||
76 |
FOREVER |
|
77 |
{ |
|
78 |
TEntry entry; |
|
79 |
||
80 |
r = fs.Entry(gFindEntryDir2, entry); |
|
81 |
FailIfError(r); |
|
82 |
test.Printf(_L("1")); |
|
83 |
r=fs.Entry(gFindDir2, entry); |
|
84 |
FailIfError(r); |
|
85 |
} |
|
86 |
} |
|
87 |
||
88 |
/** Starts two concurrent client sessions in the same directory |
|
89 |
||
90 |
*/ |
|
91 |
LOCAL_C void DoTest(TThreadFunction aFunction) |
|
92 |
{ |
|
93 |
TBuf<50> buf = _L("Speedy"); |
|
94 |
buf.AppendNum(ThreadCount++); |
|
95 |
TInt r = gSpeedy.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL); |
|
96 |
FailIfError(r); |
|
97 |
||
98 |
buf = _L("Speedy"); |
|
99 |
buf.AppendNum(ThreadCount++); |
|
100 |
r = gSpeedyII.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL); |
|
101 |
FailIfError(r); |
|
102 |
||
103 |
gSpeedy.SetPriority(EPriorityLess); |
|
104 |
gSpeedyII.SetPriority(EPriorityLess); |
|
105 |
||
106 |
gSpeedy.Resume(); |
|
107 |
gSpeedyII.Resume(); |
|
108 |
||
109 |
client.Wait(); |
|
110 |
client.Wait(); |
|
111 |
} |
|
112 |
||
113 |
/** Starts two concurrent client sessions in different directories |
|
114 |
||
115 |
*/ |
|
116 |
LOCAL_C void DoTest2(TThreadFunction aFunction) |
|
117 |
{ |
|
118 |
TBuf<50> buf=_L("Speedy"); |
|
119 |
buf.AppendNum(ThreadCount++); |
|
120 |
TInt r = gSpeedy.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL); |
|
121 |
FailIfError(r); |
|
122 |
||
123 |
buf = _L("Speedy"); |
|
124 |
buf.AppendNum(ThreadCount++); |
|
125 |
r = gSpeedyII.Create(buf, FindEntryAccess2, KDefaultStackSize, KHeapSize, KHeapSize, NULL); |
|
126 |
FailIfError(r); |
|
127 |
||
128 |
gSpeedy.SetPriority(EPriorityLess); |
|
129 |
gSpeedyII.SetPriority(EPriorityLess); |
|
130 |
||
131 |
gSpeedy.Resume(); |
|
132 |
gSpeedyII.Resume(); |
|
133 |
||
134 |
client.Wait(); |
|
135 |
client.Wait(); |
|
136 |
} |
|
137 |
||
138 |
/** Kills the concurrent session |
|
139 |
||
140 |
*/ |
|
141 |
LOCAL_C void DoTestKill() |
|
142 |
{ |
|
143 |
gSpeedy.Kill(KErrNone); |
|
144 |
gSpeedy.Close(); |
|
145 |
||
146 |
gSpeedyII.Kill(KErrNone); |
|
147 |
gSpeedyII.Close(); |
|
148 |
} |
|
149 |
||
150 |
/** Find entry in directory |
|
151 |
||
152 |
*/ |
|
153 |
LOCAL_C TInt FindEntryAccess(TAny*) |
|
154 |
{ |
|
155 |
RFs fs; |
|
156 |
TInt r = fs.Connect(); |
|
157 |
RTest test(_L("test 2")); |
|
158 |
||
159 |
fs.SetSessionPath(gSessionPath); |
|
160 |
||
161 |
client.Signal(); |
|
162 |
||
163 |
FOREVER |
|
164 |
{ |
|
165 |
TEntry entry; |
|
166 |
||
167 |
r = fs.Entry(gFindEntryDir, entry); |
|
168 |
FailIfError(r); |
|
169 |
||
170 |
r = fs.Entry(gFindDir,entry); |
|
171 |
FailIfError(r); |
|
172 |
} |
|
173 |
} |
|
174 |
||
175 |
/** Find last.txt by opening it and with two threads accessing the current directory |
|
176 |
and looking for the same file |
|
177 |
||
178 |
@param aN Number of files in the directory |
|
179 |
@param aStep Test step |
|
180 |
*/ |
|
181 |
LOCAL_C void FindFileM2(TInt aN, TInt aStep) |
|
182 |
{ |
|
183 |
TBuf16<100> dir1; |
|
184 |
TBuf16<100> dir2; |
|
185 |
TBuf16<100> dir3; |
|
186 |
TBuf16<100> dirtemp; |
|
187 |
||
188 |
TInt r = 0; |
|
189 |
||
190 |
TTime startTime; |
|
191 |
TTime endTime; |
|
192 |
TTimeIntervalMicroSeconds timeTaken(0); |
|
193 |
RFile file; |
|
194 |
TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; |
|
195 |
||
196 |
if(aN <= gFilesLimit) |
|
197 |
{ |
|
198 |
dir1 = gSessionPath; |
|
199 |
dir2 = gSessionPath; |
|
200 |
dir3 = gSessionPath; |
|
201 |
||
202 |
dirtemp.Format(KDirMultipleName2, 1, aN); |
|
203 |
dir1.Append(dirtemp); |
|
204 |
gFindDir = dir1; |
|
205 |
||
206 |
dirtemp.Format(KDirMultipleName2, 2, aN); |
|
207 |
dir2.Append(dirtemp); |
|
208 |
||
209 |
dirtemp.Format(KDirMultipleName2, 3, aN); |
|
210 |
dir3.Append(dirtemp); |
|
211 |
||
212 |
dir1.Append(KCommonFile); |
|
213 |
||
214 |
if(gTypes >= 1) |
|
215 |
{ |
|
216 |
gFindEntryDir = dir1; |
|
217 |
DoTest(FindEntryAccess); |
|
218 |
||
219 |
User::After(200); |
|
220 |
startTime.HomeTime(); |
|
221 |
||
222 |
r = file.Open(TheFs, dir1, EFileShareAny|EFileWrite); |
|
223 |
FailIfError(r); |
|
224 |
||
225 |
endTime.HomeTime(); |
|
226 |
||
227 |
DoTestKill(); |
|
228 |
file.Close(); |
|
229 |
||
230 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
231 |
timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
232 |
} |
|
233 |
||
234 |
if(gTypes >= 2) |
|
235 |
{ |
|
236 |
gFindDir = dir2; |
|
237 |
dir2.Append(KCommonFile); |
|
238 |
gFindEntryDir = dir2; |
|
239 |
||
240 |
DoTest(FindEntryAccess); |
|
241 |
User::After(200); |
|
242 |
startTime.HomeTime(); |
|
243 |
||
244 |
r = file.Open(TheFs, dir2, EFileShareAny|EFileWrite); |
|
245 |
FailIfError(r); |
|
246 |
||
247 |
endTime.HomeTime(); |
|
248 |
||
249 |
DoTestKill(); |
|
250 |
file.Close(); |
|
251 |
||
252 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
253 |
timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
254 |
} |
|
255 |
||
256 |
if(gTypes >= 3) |
|
257 |
{ |
|
258 |
gFindDir = dir3; |
|
259 |
dir3.Append(KCommonFile); |
|
260 |
||
261 |
gFindEntryDir = dir3; |
|
262 |
DoTest(FindEntryAccess); |
|
263 |
||
264 |
User::After(200); |
|
265 |
startTime.HomeTime(); |
|
266 |
||
267 |
r=file.Open(TheFs, dir3, EFileShareAny|EFileWrite); |
|
268 |
FailIfError(r); |
|
269 |
||
270 |
endTime.HomeTime(); |
|
271 |
DoTestKill(); |
|
272 |
file.Close(); |
|
273 |
||
274 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
275 |
timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
276 |
||
277 |
} |
|
278 |
} |
|
279 |
||
280 |
PrintResult(aStep, 1, aN); |
|
281 |
PrintResultTime(aStep, 2, timeTaken1); |
|
282 |
PrintResultTime(aStep, 3, timeTaken2); |
|
283 |
PrintResultTime(aStep, 4, timeTaken3); |
|
284 |
} |
|
285 |
||
286 |
/** Find last.txt by opening it and without any other process |
|
287 |
||
288 |
@param aN Number of files in the directory |
|
289 |
@param aStep Test step |
|
290 |
*/ |
|
291 |
LOCAL_C void OpenFile(TInt aN, TInt aStep) |
|
292 |
{ |
|
293 |
TBuf16<100> dir1; |
|
294 |
TBuf16<100> dir2; |
|
295 |
TBuf16<100> dir3; |
|
296 |
TBuf16<100> dirtemp; |
|
297 |
||
298 |
TInt r = 0; |
|
299 |
TInt pos = 0; |
|
300 |
TTime startTime; |
|
301 |
TTime endTime; |
|
302 |
TTimeIntervalMicroSeconds timeTaken(0); |
|
303 |
TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; |
|
304 |
RFile file; |
|
305 |
||
306 |
if(aN <= gFilesLimit) |
|
307 |
{ |
|
308 |
dir1 = gSessionPath; |
|
309 |
dir2 = gSessionPath; |
|
310 |
dir3 = gSessionPath; |
|
311 |
||
312 |
dirtemp.Format(KDirMultipleName, 1, aN); |
|
313 |
dir1.Append(dirtemp); |
|
314 |
||
315 |
dirtemp.Format(KDirMultipleName, 2, aN); |
|
316 |
dir2.Append(dirtemp); |
|
317 |
||
318 |
dirtemp.Format(KDirMultipleName, 3, aN); |
|
319 |
dir3.Append(dirtemp); |
|
320 |
||
321 |
dir1.Append(KCommonFile); |
|
322 |
dir2.Append(KCommonFile); |
|
323 |
dir3.Append(KCommonFile); |
|
324 |
||
325 |
if(gTypes >= 1) |
|
326 |
{ |
|
327 |
startTime.HomeTime(); |
|
328 |
||
329 |
r = file.Open(TheFs, dir1, EFileShareAny|EFileRead); |
|
330 |
FailIfError(r); |
|
331 |
r = file.Seek(ESeekStart, pos); |
|
332 |
FailIfError(r); |
|
333 |
r = file.Read(buf); |
|
334 |
FailIfError(r); |
|
335 |
||
336 |
endTime.HomeTime(); |
|
337 |
file.Close(); |
|
338 |
||
339 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
340 |
timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
341 |
||
342 |
} |
|
343 |
||
344 |
if(gTypes >= 2) |
|
345 |
{ |
|
346 |
startTime.HomeTime(); |
|
347 |
||
348 |
r = file.Open(TheFs, dir2, EFileShareAny|EFileRead); |
|
349 |
FailIfError(r); |
|
350 |
r = file.Seek(ESeekStart,pos); |
|
351 |
FailIfError(r); |
|
352 |
r = file.Read(buf); |
|
353 |
FailIfError(r); |
|
354 |
||
355 |
endTime.HomeTime(); |
|
356 |
||
357 |
file.Close(); |
|
358 |
||
359 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
360 |
timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
361 |
} |
|
362 |
||
363 |
if(gTypes >= 3) |
|
364 |
{ |
|
365 |
startTime.HomeTime(); |
|
366 |
||
367 |
r = file.Open(TheFs, dir3, EFileShareAny|EFileRead); |
|
368 |
FailIfError(r); |
|
369 |
r = file.Seek(ESeekStart, pos); |
|
370 |
FailIfError(r); |
|
371 |
r = file.Read(buf); |
|
372 |
FailIfError(r); |
|
373 |
||
374 |
endTime.HomeTime(); |
|
375 |
file.Close(); |
|
376 |
||
377 |
timeTaken=endTime.MicroSecondsFrom(startTime); |
|
378 |
timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
379 |
} |
|
380 |
} |
|
381 |
||
382 |
PrintResult(aStep, 1, aN); |
|
383 |
PrintResultTime(aStep, 2, timeTaken1); |
|
384 |
PrintResultTime(aStep, 3, timeTaken2); |
|
385 |
PrintResultTime(aStep, 4, timeTaken3); |
|
386 |
||
387 |
} |
|
388 |
||
389 |
/** Find last.txt with TFindFile and with two threads accessing the current directory and other one |
|
390 |
||
391 |
@param aN Number of files in the directory |
|
392 |
@param aStep Test step |
|
393 |
*/ |
|
394 |
LOCAL_C void FindFileMD1(TInt aN, TInt aStep) |
|
395 |
{ |
|
396 |
TBuf16<100> dir1; |
|
397 |
TBuf16<100> dir2; |
|
398 |
TBuf16<100> dir3; |
|
399 |
TBuf16<100> dir4; |
|
400 |
TBuf16<100> dirtemp; |
|
401 |
||
402 |
TInt r = 0; |
|
403 |
TFindFile find(TheFs); |
|
404 |
TTime startTime; |
|
405 |
TTime endTime; |
|
406 |
TTimeIntervalMicroSeconds timeTaken(0); |
|
407 |
TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; |
|
408 |
||
409 |
if(aN <= gFilesLimit) |
|
410 |
{ |
|
411 |
dir1 = gSessionPath; |
|
412 |
dir2 = gSessionPath; |
|
413 |
dir3 = gSessionPath; |
|
414 |
||
415 |
dirtemp.Format(KDirMultipleName2,1,aN); |
|
416 |
dir1.Append(dirtemp); |
|
417 |
||
418 |
gFindDir = dir1; |
|
419 |
dirtemp.Format(KDirMultipleName, 2, aN); |
|
420 |
dir2.Append(dirtemp); |
|
421 |
||
422 |
dirtemp.Format(KDirMultipleName, 3, aN); |
|
423 |
dir3.Append(dirtemp); |
|
424 |
||
425 |
dir4=gSessionPath; |
|
426 |
dirtemp.Format(KDirMultipleName, 3, 300); |
|
427 |
||
428 |
dir4.Append(dirtemp); |
|
429 |
gFindDir2 = dir4; |
|
430 |
||
431 |
dir1.Append(KCommonFile); |
|
432 |
dir2.Append(KCommonFile); |
|
433 |
dir3.Append(KCommonFile); |
|
434 |
dir4.Append(KCommonFile); |
|
435 |
gFindEntryDir2 = dir4; |
|
436 |
||
437 |
if(gTypes >= 1) |
|
438 |
{ |
|
439 |
||
440 |
gFindEntryDir = dir1; |
|
441 |
||
442 |
dir4.Format(KDirMultipleName, 1, aN); |
|
443 |
||
444 |
DoTest2(FindEntryAccess); |
|
445 |
startTime.HomeTime(); |
|
446 |
||
447 |
r = find.FindByPath(dir1, &dir4); |
|
448 |
FailIfError(r); |
|
449 |
||
450 |
endTime.HomeTime(); |
|
451 |
DoTestKill(); |
|
452 |
||
453 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
454 |
timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
455 |
} |
|
456 |
||
457 |
if(gTypes >= 2) |
|
458 |
{ |
|
459 |
dir4.Format(KDirMultipleName, 2, aN); |
|
460 |
||
461 |
gFindEntryDir=dir2; |
|
462 |
||
463 |
DoTest2(FindEntryAccess); |
|
464 |
||
465 |
startTime.HomeTime(); |
|
466 |
||
467 |
r = find.FindByPath(dir2,&dir4); |
|
468 |
FailIfError(r); |
|
469 |
||
470 |
endTime.HomeTime(); |
|
471 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
472 |
||
473 |
DoTestKill(); |
|
474 |
||
475 |
timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
476 |
} |
|
477 |
||
478 |
if(gTypes >= 3) |
|
479 |
{ |
|
480 |
dir4.Format(KDirMultipleName, 3, aN); |
|
481 |
gFindEntryDir = dir3; |
|
482 |
||
483 |
DoTest2(FindEntryAccess); |
|
484 |
||
485 |
startTime.HomeTime(); |
|
486 |
||
487 |
r = find.FindByPath(dir3,&dir4); |
|
488 |
FailIfError(r); |
|
489 |
||
490 |
endTime.HomeTime(); |
|
491 |
DoTestKill(); |
|
492 |
||
493 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
494 |
timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
495 |
} |
|
496 |
} |
|
497 |
||
498 |
PrintResult(aStep, 1, aN); |
|
499 |
PrintResultTime(aStep, 2, timeTaken1); |
|
500 |
PrintResultTime(aStep, 3, timeTaken2); |
|
501 |
PrintResultTime(aStep, 4, timeTaken3); |
|
502 |
} |
|
503 |
||
504 |
||
505 |
/** Find last.txt by opening the file and with two threads accessing the current directory and other one |
|
506 |
||
507 |
@param aN Number of files in the directory |
|
508 |
@param aStep Test step |
|
509 |
*/ |
|
510 |
LOCAL_C void FindFileMD2(TInt aN, TInt aStep) |
|
511 |
{ |
|
512 |
TBuf16<100> dir1; |
|
513 |
TBuf16<100> dir2; |
|
514 |
TBuf16<100> dir3; |
|
515 |
TBuf16<100> dir4; |
|
516 |
TBuf16<100> dirtemp; |
|
517 |
||
518 |
TInt r = 0; |
|
519 |
||
520 |
TTime startTime; |
|
521 |
TTime endTime; |
|
522 |
TTimeIntervalMicroSeconds timeTaken(0); |
|
523 |
TInt timeTaken1 = -1, timeTaken2 = -1, timeTaken3 = -1; |
|
524 |
||
525 |
RFile file; |
|
526 |
||
527 |
if(aN <= gFilesLimit) |
|
528 |
{ |
|
529 |
dir1 = gSessionPath; |
|
530 |
dir2 = gSessionPath; |
|
531 |
dir3 = gSessionPath; |
|
532 |
dir4 = gSessionPath; |
|
533 |
||
534 |
dirtemp.Format(KDirMultipleName2, 1, aN); |
|
535 |
dir1.Append(dirtemp); |
|
536 |
gFindDir = dir1; |
|
537 |
||
538 |
dirtemp.Format(KDirMultipleName2, 2, aN); |
|
539 |
dir2.Append(dirtemp); |
|
540 |
||
541 |
dirtemp.Format(KDirMultipleName2, 3, aN); |
|
542 |
dir3.Append(dirtemp); |
|
543 |
||
544 |
dir1.Append(KCommonFile); |
|
545 |
gFindEntryDir = dir1; |
|
546 |
||
547 |
dirtemp.Format(KDirMultipleName, 3, 300); |
|
548 |
dir4.Append(dirtemp); |
|
549 |
gFindDir2 = dir4; |
|
550 |
dir4.Append(KCommonFile); |
|
551 |
gFindEntryDir2 = dir4; |
|
552 |
||
553 |
if(gTypes >= 1) |
|
554 |
{ |
|
555 |
DoTest2(FindEntryAccess); |
|
556 |
User::After(200); |
|
557 |
||
558 |
startTime.HomeTime(); |
|
559 |
||
560 |
r = file.Open(TheFs,dir1,EFileShareAny|EFileWrite); |
|
561 |
FailIfError(r); |
|
562 |
||
563 |
endTime.HomeTime(); |
|
564 |
||
565 |
DoTestKill(); |
|
566 |
file.Close(); |
|
567 |
||
568 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
569 |
timeTaken1 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
570 |
} |
|
571 |
||
572 |
if(gTypes >= 2) |
|
573 |
{ |
|
574 |
gFindDir = dir2; |
|
575 |
dir2.Append(KCommonFile); |
|
576 |
gFindEntryDir = dir2; |
|
577 |
||
578 |
DoTest2(FindEntryAccess); |
|
579 |
User::After(200); |
|
580 |
||
581 |
startTime.HomeTime(); |
|
582 |
||
583 |
r = file.Open(TheFs, dir2, EFileShareAny|EFileWrite); |
|
584 |
FailIfError(r); |
|
585 |
||
586 |
endTime.HomeTime(); |
|
587 |
||
588 |
DoTestKill(); |
|
589 |
file.Close(); |
|
590 |
||
591 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
592 |
timeTaken2 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
593 |
} |
|
594 |
||
595 |
if(gTypes >= 3) |
|
596 |
{ |
|
597 |
gFindDir = dir3; |
|
598 |
dir3.Append(KCommonFile); |
|
599 |
gFindEntryDir = dir3; |
|
600 |
DoTest2(FindEntryAccess); |
|
601 |
||
602 |
User::After(200); |
|
603 |
startTime.HomeTime(); |
|
604 |
||
605 |
r = file.Open(TheFs, dir3, EFileShareAny|EFileWrite); |
|
606 |
FailIfError(r); |
|
607 |
||
608 |
endTime.HomeTime(); |
|
609 |
DoTestKill(); |
|
610 |
file.Close(); |
|
611 |
||
612 |
timeTaken = endTime.MicroSecondsFrom(startTime); |
|
613 |
timeTaken3 = I64LOW(timeTaken.Int64() / gTimeUnit); |
|
614 |
} |
|
615 |
} |
|
616 |
||
617 |
PrintResult(aStep, 1, aN); |
|
618 |
PrintResultTime(aStep, 2, timeTaken1); |
|
619 |
PrintResultTime(aStep, 3, timeTaken2); |
|
620 |
PrintResultTime(aStep, 4, timeTaken3); |
|
621 |
} |
|
622 |
||
623 |
/** Times the system when opening a file with multiple clients accessing the directory |
|
624 |
Precondition: This test expects the drive already filled with files |
|
625 |
||
626 |
@param aSelector Configuration in case of manual execution |
|
627 |
*/ |
|
628 |
LOCAL_C TInt TestOpenEntry(TAny* aSelector) |
|
629 |
{ |
|
630 |
TInt i = 100, r = 0; |
|
631 |
TInt testStep = 1; |
|
632 |
TTime startTime; |
|
633 |
TTime endTime; |
|
634 |
TTimeIntervalSeconds timeTaken; |
|
635 |
||
636 |
Validate(aSelector); |
|
637 |
||
638 |
test.Printf(_L("#~TS_Title_%d,%d: Open and read 4 Kb entry last.txt, RFile::Open \n"), gTestHarness, gTestCase); |
|
639 |
startTime.HomeTime(); |
|
640 |
||
641 |
while(i <= KMaxFiles) |
|
642 |
{ |
|
643 |
if(i == 100 || i == 1000 || i == 5000 || i == 10000) |
|
644 |
OpenFile(i, testStep++); |
|
645 |
i += 100; |
|
646 |
} |
|
647 |
||
648 |
gTestCase++; |
|
649 |
||
650 |
endTime.HomeTime(); |
|
651 |
r = endTime.SecondsFrom(startTime, timeTaken); |
|
652 |
FailIfError(r); |
|
653 |
test.Printf(_L("#~TS_Timing_%d,%d=%d\n"), gTestHarness, gTestCase, timeTaken.Int()); |
|
654 |
||
655 |
return(KErrNone); |
|
656 |
} |
|
657 |
||
658 |
/** Times the system when opening a file with multiple clients accessing the directory |
|
659 |
Precondition: This test expects the drive already filled with files |
|
660 |
||
661 |
@param aSelector Configuration in case of manual execution |
|
662 |
*/ |
|
663 |
LOCAL_C TInt TestOpenEntryMultipleClients(TAny* aSelector) |
|
664 |
{ |
|
665 |
TInt i = 100, r = 0; |
|
666 |
TInt testStep; |
|
667 |
TTime startTime; |
|
668 |
TTime endTime; |
|
669 |
TTimeIntervalSeconds timeTaken; |
|
670 |
||
671 |
Validate(aSelector); |
|
672 |
||
673 |
test.Printf(_L("#~TS_Title_%d,%d: Find entry mult clients accessing same directory, RFile::Open \n"), gTestHarness, gTestCase); |
|
674 |
startTime.HomeTime(); |
|
675 |
||
676 |
i = 100; |
|
677 |
testStep = 1; |
|
678 |
while(i <= KMaxFiles) |
|
679 |
{ |
|
680 |
if(i == 100 || i == 1000 || i == 5000 || i == 10000) |
|
681 |
FindFileM2(i, testStep++); |
|
682 |
i += 100; |
|
683 |
} |
|
684 |
||
685 |
gTestCase++; |
|
686 |
||
687 |
endTime.HomeTime(); |
|
688 |
r = endTime.SecondsFrom(startTime, timeTaken); |
|
689 |
FailIfError(r); |
|
690 |
test.Printf(_L("#~TS_Timing_%d,%d=%d\n"), gTestHarness, gTestCase, timeTaken.Int()); |
|
691 |
||
692 |
return(KErrNone); |
|
693 |
} |
|
694 |
||
695 |
/** Times the system when opening a file with multiple clients accessing dif directory |
|
696 |
Precondition: This test expects the drive already filled with files |
|
697 |
||
698 |
@param aSelector Configuration in case of manual execution |
|
699 |
*/ |
|
700 |
LOCAL_C TInt TestOpenEntryMultipleClientsDD(TAny* aSelector) |
|
701 |
{ |
|
702 |
TInt i = 100, r = 0; |
|
703 |
TInt testStep; |
|
704 |
TTime startTime; |
|
705 |
TTime endTime; |
|
706 |
TTimeIntervalSeconds timeTaken; |
|
707 |
||
708 |
Validate(aSelector); |
|
709 |
||
710 |
test.Printf(_L("#~TS_Title_%d,%d: Find entry mult clients accessing dif directory, TFindFile\n"), gTestHarness, gTestCase); |
|
711 |
startTime.HomeTime(); |
|
712 |
||
713 |
testStep = 1; |
|
714 |
while(i <= KMaxFiles) |
|
715 |
{ |
|
716 |
if(i == 100 || i == 1000 || i == 5000 || i == 10000) |
|
717 |
FindFileMD1(i, testStep++); |
|
718 |
i += 100; |
|
719 |
} |
|
720 |
||
721 |
gTestCase++; |
|
722 |
||
723 |
endTime.HomeTime(); |
|
724 |
r = endTime.SecondsFrom(startTime, timeTaken); |
|
725 |
FailIfError(r); |
|
726 |
test.Printf(_L("#~TS_Timing_%d,%d=%d\n"), gTestHarness, gTestCase, timeTaken.Int()); |
|
727 |
||
728 |
||
729 |
test.Printf(_L("#~TS_Title_%d,%d: Find entry mult clients accessing dif directory, RFile::Open \n"), gTestHarness, gTestCase); |
|
730 |
startTime.HomeTime(); |
|
731 |
||
732 |
i = 100; |
|
733 |
testStep = 1; |
|
734 |
while(i <= KMaxFiles) |
|
735 |
{ |
|
736 |
if(i == 100 || i == 1000 || i == 5000 || i == 10000) |
|
737 |
FindFileMD2(i, testStep++); |
|
738 |
i += 100; |
|
739 |
} |
|
740 |
||
741 |
gTestCase++; |
|
742 |
||
743 |
endTime.HomeTime(); |
|
744 |
r = endTime.SecondsFrom(startTime, timeTaken); |
|
745 |
FailIfError(r); |
|
746 |
test.Printf(_L("#~TS_Timing_%d,%d=%d\n"), gTestHarness, gTestCase, timeTaken.Int()); |
|
747 |
||
748 |
return(KErrNone); |
|
749 |
} |
|
750 |
||
751 |
/** It goes automatically through all the options |
|
752 |
||
753 |
@param aSelector Configuration in case of manual execution |
|
754 |
*/ |
|
755 |
LOCAL_C TInt TestAll(TAny* aSelector) |
|
756 |
{ |
|
757 |
Validate(aSelector); |
|
758 |
||
759 |
TestOpenEntry(aSelector); |
|
760 |
TestOpenEntryMultipleClients(aSelector); |
|
761 |
TestOpenEntryMultipleClientsDD(aSelector); |
|
762 |
||
763 |
return(KErrNone); |
|
764 |
} |
|
765 |
||
766 |
/** Call all tests |
|
767 |
||
768 |
*/ |
|
769 |
GLDEF_C void CallTestsL() |
|
770 |
{ |
|
771 |
TInt r = client.CreateLocal(0); |
|
772 |
FailIfError(r); |
|
773 |
||
774 |
CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console()); |
|
775 |
||
776 |
gFileSize = 8; |
|
777 |
||
778 |
// Each test case of the suite has an identifyer for parsing purposes of the results |
|
779 |
gTestHarness = 4; |
|
780 |
gTestCase = 1; |
|
781 |
||
782 |
CreateDirWithNFiles(300, 3); |
|
783 |
PrintHeaders(1, _L("t_fsropen. File Open")); |
|
784 |
||
785 |
if(gMode == 0) |
|
786 |
{ // Manual |
|
787 |
gSessionPath=_L("?:\\"); |
|
788 |
TCallBack createFiles(TestFileCreate, TheSelector); |
|
789 |
TCallBack openFile(TestOpenEntry, TheSelector); |
|
790 |
TCallBack openFileMC(TestOpenEntryMultipleClients, TheSelector); |
|
791 |
TCallBack openFileMCDD(TestOpenEntryMultipleClientsDD, TheSelector); |
|
792 |
TCallBack allOpen(TestAll,TheSelector); |
|
793 |
TheSelector->AddDriveSelectorL(TheFs); |
|
794 |
TheSelector->AddLineL(_L("Create all files"), createFiles); |
|
795 |
TheSelector->AddLineL(_L("Open random file"), openFile); |
|
796 |
TheSelector->AddLineL(_L("With mult clients same directory"), openFileMC); |
|
797 |
TheSelector->AddLineL(_L("With mult clients dif large directories"), openFileMCDD); |
|
798 |
TheSelector->AddLineL(_L("All options"), allOpen); |
|
799 |
TheSelector->Run(); |
|
800 |
} |
|
801 |
else |
|
802 |
{ // Automatic |
|
803 |
TestAll(TheSelector); |
|
804 |
} |
|
805 |
||
806 |
client.Close(); |
|
807 |
test.Printf(_L("#~TestEnd_%d\n"), gTestHarness); |
|
808 |
delete TheSelector; |
|
809 |
} |