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