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_fsrrepeat.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <f32file.h>
|
|
19 |
#include <e32test.h>
|
|
20 |
#include "t_select.h"
|
|
21 |
#include "t_benchmain.h"
|
|
22 |
|
|
23 |
|
|
24 |
GLDEF_D RTest test(_L("FS Benchmarks, Open and read 4 KB"));
|
|
25 |
|
|
26 |
//----------------------------------------------------------------------------------------------
|
|
27 |
//! @SYMTestCaseID PBASE-T_FSRREPEAT-0276
|
|
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 3 times 4 Kb of last.txt file in each directory
|
|
33 |
//! 2. Time the opening and read 3 times 4 Kb of last.txt file in each directory
|
|
34 |
//! with two clients accessing the directory
|
|
35 |
//! 3. Time the opening and read 3 times 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,write_screen;
|
|
45 |
LOCAL_D const TInt KHeapSize=0x4000;
|
|
46 |
|
|
47 |
LOCAL_D TDriveList gDriveList;
|
|
48 |
|
|
49 |
LOCAL_D TFileName gDelEntryDir;
|
|
50 |
LOCAL_D TFileName gDelEntryDir2;
|
|
51 |
|
|
52 |
// Concurrent threads
|
|
53 |
RThread gSpeedy;
|
|
54 |
RThread gSpeedyII;
|
|
55 |
TInt gT1;
|
|
56 |
TInt gT2;
|
|
57 |
TBool gKillMe = EFalse;
|
|
58 |
|
|
59 |
LOCAL_D TInt ThreadCount = 0;
|
|
60 |
LOCAL_D TBuf8<4096> buf;
|
|
61 |
|
|
62 |
_LIT(KDirMultipleName2, "dir%d_%d\\");
|
|
63 |
|
|
64 |
_LIT(KDeleteMe,"DELETE%d.ME");
|
|
65 |
_LIT(KDeleteMe2,"BLABLA%d.RHD");
|
|
66 |
|
|
67 |
|
|
68 |
/** Delete entry in directory
|
|
69 |
|
|
70 |
*/
|
|
71 |
LOCAL_C TInt DeleteEntryAccess2(TAny* )
|
|
72 |
{
|
|
73 |
RFs fs;
|
|
74 |
TInt r = fs.Connect();
|
|
75 |
TBuf<100> dirfile;
|
|
76 |
TBuf<50> filename;
|
|
77 |
RFile file;
|
|
78 |
|
|
79 |
fs.SetSessionPath(gSessionPath);
|
|
80 |
filename.Format(KDeleteMe2, gT2);
|
|
81 |
|
|
82 |
dirfile = gDelEntryDir2;
|
|
83 |
dirfile.Append(filename);
|
|
84 |
|
|
85 |
client.Signal();
|
|
86 |
|
|
87 |
FOREVER
|
|
88 |
{
|
|
89 |
if(!gKillMe)
|
|
90 |
{
|
|
91 |
r = file.Create(fs, dirfile, EFileShareAny|EFileWrite);
|
|
92 |
if(r == KErrAlreadyExists)
|
|
93 |
r = file.Open(fs, dirfile, EFileShareAny|EFileWrite);
|
|
94 |
file.Close();
|
|
95 |
FailIfError(r);
|
|
96 |
|
|
97 |
r = fs.Delete(dirfile);
|
|
98 |
if((r != KErrNone) && (r != KErrInUse))
|
|
99 |
{
|
|
100 |
test.Printf(_L("error = %d\n"), r);
|
|
101 |
}
|
|
102 |
test((r == KErrNone) || (r == KErrInUse));
|
|
103 |
}
|
|
104 |
}
|
|
105 |
}
|
|
106 |
|
|
107 |
/** Delete entry in directory
|
|
108 |
|
|
109 |
*/
|
|
110 |
LOCAL_C TInt DeleteEntryAccess(TAny*)
|
|
111 |
{
|
|
112 |
RFs fs2;
|
|
113 |
TInt r = fs2.Connect();
|
|
114 |
TBuf<100> dirfile;
|
|
115 |
TBuf<50> filename;
|
|
116 |
RFile file2;
|
|
117 |
RTest test(_L("test 2"));
|
|
118 |
|
|
119 |
fs2.SetSessionPath(gSessionPath);
|
|
120 |
filename.Format(KDeleteMe,gT1);
|
|
121 |
|
|
122 |
dirfile = gDelEntryDir;
|
|
123 |
dirfile.Append(filename);
|
|
124 |
|
|
125 |
client.Signal();
|
|
126 |
|
|
127 |
FOREVER
|
|
128 |
{
|
|
129 |
if(!gKillMe)
|
|
130 |
{
|
|
131 |
r = file2.Create(fs2, dirfile, EFileShareAny|EFileWrite);
|
|
132 |
if(r == KErrAlreadyExists)
|
|
133 |
r = file2.Open(fs2, dirfile, EFileShareAny|EFileWrite);
|
|
134 |
file2.Close();
|
|
135 |
FailIfError(r);
|
|
136 |
|
|
137 |
r = fs2.Delete(dirfile);
|
|
138 |
if((r != KErrNone) && (r != KErrInUse))
|
|
139 |
{
|
|
140 |
test.Printf(_L("error = %d\n"), r);
|
|
141 |
}
|
|
142 |
test((r == KErrNone) || (r == KErrInUse));
|
|
143 |
}
|
|
144 |
}
|
|
145 |
}
|
|
146 |
|
|
147 |
/** Starts two concurrent client sessions in different directories
|
|
148 |
|
|
149 |
*/
|
|
150 |
LOCAL_C void DoTest2(TThreadFunction aFunction)
|
|
151 |
{
|
|
152 |
gKillMe = EFalse;
|
|
153 |
|
|
154 |
TBuf<20> buf = _L("Speedy");
|
|
155 |
buf.AppendNum(ThreadCount++);
|
|
156 |
gT1 = ThreadCount;
|
|
157 |
TInt r = gSpeedy.Create(buf, aFunction, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
158 |
FailIfError(r);
|
|
159 |
|
|
160 |
buf = _L("Speedy");
|
|
161 |
buf.AppendNum(ThreadCount++);
|
|
162 |
gT2 = ThreadCount;
|
|
163 |
r = gSpeedyII.Create(buf, DeleteEntryAccess2, KDefaultStackSize, KHeapSize, KHeapSize, NULL);
|
|
164 |
FailIfError(r);
|
|
165 |
|
|
166 |
gSpeedy.SetPriority(EPriorityLess);
|
|
167 |
gSpeedyII.SetPriority(EPriorityLess);
|
|
168 |
|
|
169 |
gSpeedy.Resume();
|
|
170 |
gSpeedyII.Resume();
|
|
171 |
|
|
172 |
client.Wait();
|
|
173 |
client.Wait();
|
|
174 |
}
|
|
175 |
|
|
176 |
/** Kills the concurrent session
|
|
177 |
|
|
178 |
*/
|
|
179 |
LOCAL_C void DoTestKill()
|
|
180 |
{
|
|
181 |
gKillMe = ETrue;
|
|
182 |
User::After(10000000);
|
|
183 |
|
|
184 |
gSpeedy.Kill(KErrNone);
|
|
185 |
gSpeedy.Close();
|
|
186 |
|
|
187 |
gSpeedyII.Kill(KErrNone);
|
|
188 |
gSpeedyII.Close();
|
|
189 |
}
|
|
190 |
|
|
191 |
/** Open last.txt with RFs and without any other process
|
|
192 |
|
|
193 |
@param aN Number of files in the directory
|
|
194 |
@param aType Type of files
|
|
195 |
@param aStep Test step
|
|
196 |
*/
|
|
197 |
LOCAL_C void OpenFile(TInt aN, TInt aType, TInt aStep)
|
|
198 |
{
|
|
199 |
TBuf16<100> file;
|
|
200 |
TBuf16<100> dir;
|
|
201 |
|
|
202 |
TInt r = 0;
|
|
203 |
TTime startTime;
|
|
204 |
TTime endTime;
|
|
205 |
TTimeIntervalMicroSeconds timeTaken(0);
|
|
206 |
TInt timeTakenArray[3] = {-1, -1, -1};
|
|
207 |
TInt i;
|
|
208 |
RFile f;
|
|
209 |
|
|
210 |
if(aN <= gFilesLimit)
|
|
211 |
{
|
|
212 |
if(aType <= gTypes)
|
|
213 |
{
|
|
214 |
file = gSessionPath;
|
|
215 |
|
|
216 |
dir.Format(KDirMultipleName2, aType, aN);
|
|
217 |
file.Append(dir);
|
|
218 |
|
|
219 |
file.Append(KCommonFile);
|
|
220 |
|
|
221 |
i = 0;
|
|
222 |
while(i < 3)
|
|
223 |
{
|
|
224 |
startTime.HomeTime();
|
|
225 |
|
|
226 |
r = f.Open(TheFs, file, EFileShareAny|EFileRead);
|
|
227 |
FailIfError(r);
|
|
228 |
r = f.Read(buf);
|
|
229 |
FailIfError(r);
|
|
230 |
|
|
231 |
f.Close();
|
|
232 |
|
|
233 |
endTime.HomeTime();
|
|
234 |
|
|
235 |
timeTaken = endTime.MicroSecondsFrom(startTime);
|
|
236 |
timeTakenArray[i++] = I64LOW(timeTaken.Int64() / gTimeUnit);
|
|
237 |
}
|
|
238 |
}
|
|
239 |
}
|
|
240 |
|
|
241 |
dir.Format(KDirMultipleName,aType,aN);
|
|
242 |
|
|
243 |
PrintResultS(aStep, 1, dir);
|
|
244 |
PrintResultTime(aStep, 2, timeTakenArray[0]);
|
|
245 |
PrintResultTime(aStep, 3, timeTakenArray[1]);
|
|
246 |
PrintResultTime(aStep, 4, timeTakenArray[2]);
|
|
247 |
}
|
|
248 |
|
|
249 |
/** Times the opening of a file and read operation
|
|
250 |
Precondition: This test expects the drive already filled with the right files
|
|
251 |
|
|
252 |
@param aSelector Configuration in case of manual execution
|
|
253 |
*/
|
|
254 |
LOCAL_C TInt TestOpen(TAny* aSelector)
|
|
255 |
{
|
|
256 |
TInt i = 100, j;
|
|
257 |
TInt testStep;
|
|
258 |
|
|
259 |
Validate(aSelector);
|
|
260 |
|
|
261 |
test.Printf(_L("#~TS_Title_%d,%d: Open last.txt and read 4 K repeatedly, RFs::Open\n"), gTestHarness, gTestCase);
|
|
262 |
|
|
263 |
i = 100;
|
|
264 |
testStep = 1;
|
|
265 |
while(i <= KMaxFiles)
|
|
266 |
{
|
|
267 |
if(i == 100 || i == 1000 || i == 5000 || i == 10000)
|
|
268 |
{
|
|
269 |
j = 1;
|
|
270 |
while(j <= KMaxTypes)
|
|
271 |
{
|
|
272 |
OpenFile(i, j, testStep++);
|
|
273 |
j++;
|
|
274 |
}
|
|
275 |
}
|
|
276 |
i += 100;
|
|
277 |
}
|
|
278 |
|
|
279 |
gTestCase++;
|
|
280 |
return(KErrNone);
|
|
281 |
}
|
|
282 |
|
|
283 |
/** Times the opening of a file and read operation with two threads accessing
|
|
284 |
different directories
|
|
285 |
|
|
286 |
@param aSelector Configuration in case of manual execution
|
|
287 |
*/
|
|
288 |
LOCAL_C TInt TestOpenMultSame(TAny* aSelector)
|
|
289 |
{
|
|
290 |
TInt i = 100,j;
|
|
291 |
TBuf16<50> directory;
|
|
292 |
TBuf16<50> dirtemp;
|
|
293 |
TInt testStep;
|
|
294 |
|
|
295 |
Validate(aSelector);
|
|
296 |
|
|
297 |
test.Printf(_L("#~TS_Title_%d,%d: Open last.txt and read 4 K repeatedly with mult clients accessing, RFs::Open\n"), gTestHarness, gTestCase);
|
|
298 |
|
|
299 |
i = 100;
|
|
300 |
testStep = 1;
|
|
301 |
while(i <= KMaxFiles)
|
|
302 |
{
|
|
303 |
if(i == 100 || i == 1000 || i == 5000 || i == 10000)
|
|
304 |
{
|
|
305 |
j = 1;
|
|
306 |
while(j <= KMaxTypes)
|
|
307 |
{
|
|
308 |
directory = gSessionPath;
|
|
309 |
dirtemp.Format(KDirMultipleName2, j, i);
|
|
310 |
directory.Append(dirtemp);
|
|
311 |
gDelEntryDir = directory;
|
|
312 |
gDelEntryDir2 = directory;
|
|
313 |
|
|
314 |
DoTest2(DeleteEntryAccess);
|
|
315 |
|
|
316 |
OpenFile(i, j, testStep++);
|
|
317 |
|
|
318 |
DoTestKill();
|
|
319 |
|
|
320 |
j++;
|
|
321 |
}
|
|
322 |
}
|
|
323 |
i += 100;
|
|
324 |
}
|
|
325 |
|
|
326 |
gTestCase++;
|
|
327 |
return(KErrNone);
|
|
328 |
}
|
|
329 |
|
|
330 |
/** Times the opening of a file and read operation with two threads accessing
|
|
331 |
different directories
|
|
332 |
|
|
333 |
@param aSelector Configuration in case of manual execution
|
|
334 |
*/
|
|
335 |
LOCAL_C TInt TestOpenMultDif(TAny* aSelector)
|
|
336 |
{
|
|
337 |
TInt i = 100,j;
|
|
338 |
TBuf16<50> directory;
|
|
339 |
TBuf16<50> dirtemp;
|
|
340 |
TInt testStep;
|
|
341 |
|
|
342 |
Validate(aSelector);
|
|
343 |
|
|
344 |
CreateDirWithNFiles(300,3);
|
|
345 |
|
|
346 |
directory = gSessionPath;
|
|
347 |
dirtemp.Format(KDirMultipleName2, 3, 300);
|
|
348 |
directory.Append(dirtemp);
|
|
349 |
|
|
350 |
gDelEntryDir2 = directory;
|
|
351 |
|
|
352 |
test.Printf(_L("#~TS_Title_%d,%d: Open last.txt and read 4 K repeatedly mult clients accessing dif dirs, RFs::Open\n"), gTestHarness, gTestCase);
|
|
353 |
|
|
354 |
i = 100;
|
|
355 |
testStep = 1;
|
|
356 |
while(i <= KMaxFiles)
|
|
357 |
{
|
|
358 |
if(i == 100 || i == 1000 || i == 5000 || i == 10000)
|
|
359 |
{
|
|
360 |
j = 1;
|
|
361 |
while(j <= KMaxTypes)
|
|
362 |
{
|
|
363 |
directory = gSessionPath;
|
|
364 |
dirtemp.Format(KDirMultipleName2, j, i);
|
|
365 |
directory.Append(dirtemp);
|
|
366 |
gDelEntryDir = directory;
|
|
367 |
|
|
368 |
DoTest2(DeleteEntryAccess);
|
|
369 |
|
|
370 |
OpenFile(i, j, testStep++);
|
|
371 |
|
|
372 |
DoTestKill();
|
|
373 |
|
|
374 |
j++;
|
|
375 |
}
|
|
376 |
}
|
|
377 |
i += 100;
|
|
378 |
}
|
|
379 |
|
|
380 |
gTestCase++;
|
|
381 |
return(KErrNone);
|
|
382 |
}
|
|
383 |
|
|
384 |
/** It goes automatically through all the options
|
|
385 |
|
|
386 |
@param aSelector Configuration in case of manual execution
|
|
387 |
*/
|
|
388 |
LOCAL_C TInt TestAll(TAny* aSelector)
|
|
389 |
{
|
|
390 |
|
|
391 |
TestOpen(aSelector);
|
|
392 |
TestOpenMultSame(aSelector);
|
|
393 |
TestOpenMultDif(aSelector);
|
|
394 |
|
|
395 |
return(KErrNone);
|
|
396 |
}
|
|
397 |
|
|
398 |
/** Call all tests
|
|
399 |
|
|
400 |
*/
|
|
401 |
GLDEF_C void CallTestsL()
|
|
402 |
{
|
|
403 |
|
|
404 |
TInt r=client.CreateLocal(0);
|
|
405 |
FailIfError(r);
|
|
406 |
|
|
407 |
gFileSize = 8;
|
|
408 |
|
|
409 |
// Each test case of the suite has an identifyer for parsing purposes of the results
|
|
410 |
gTestHarness = 5;
|
|
411 |
gTestCase = 1;
|
|
412 |
|
|
413 |
PrintHeaders(2, _L("t_fsrrepeat. Repeat reading"));
|
|
414 |
|
|
415 |
CSelectionBox* TheSelector = CSelectionBox::NewL(test.Console());
|
|
416 |
|
|
417 |
|
|
418 |
if(gMode == 0)
|
|
419 |
{ // Manual
|
|
420 |
gSessionPath = _L("?:\\");
|
|
421 |
TCallBack createFiles(TestFileCreate,TheSelector);
|
|
422 |
TCallBack openF(TestOpen,TheSelector);
|
|
423 |
TCallBack openMultSame(TestOpenMultSame,TheSelector);
|
|
424 |
TCallBack openMultDif(TestOpenMultDif,TheSelector);
|
|
425 |
TCallBack openAll(TestAll,TheSelector);
|
|
426 |
TheSelector->AddDriveSelectorL(TheFs);
|
|
427 |
TheSelector->AddLineL(_L("Create all files"),createFiles);
|
|
428 |
TheSelector->AddLineL(_L("Open and read repeatedly"),openF);
|
|
429 |
TheSelector->AddLineL(_L("Same mult clients same dir "),openMultSame);
|
|
430 |
TheSelector->AddLineL(_L("Same mult clients dif dir"),openMultDif);
|
|
431 |
TheSelector->AddLineL(_L("Execute all options"),openAll);
|
|
432 |
TheSelector->Run();
|
|
433 |
}
|
|
434 |
else
|
|
435 |
{ // Automatic
|
|
436 |
TestAll(TheSelector);
|
|
437 |
}
|
|
438 |
|
|
439 |
client.Close();
|
|
440 |
test.Printf(_L("#~TestEnd_%d\n"), gTestHarness);
|
|
441 |
delete TheSelector;
|
|
442 |
}
|