author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 17:13:29 +0300 | |
changeset 109 | b3a1d9898418 |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2002-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 |
// Do benchmarking comparisons in asynchronous and synchronous modes. |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
//! @file f32test\concur\t_cfsbench.cpp |
|
19 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
20 |
#define __E32TEST_EXTENSION__ |
0 | 21 |
#include <f32file.h> |
22 |
#include <e32test.h> |
|
23 |
#include <f32dbg.h> |
|
24 |
#include "t_server.h" |
|
25 |
#include "t_tdebug.h" |
|
26 |
||
27 |
// The following #defines are for using older (and less accurate) benchmark |
|
28 |
// timings. They use multiple threads to get the operations simultaneous |
|
29 |
// but this is inherrently inaccurate (it depends whether one of them starts |
|
30 |
// and/or ends before the other how accurate the timings are). If you leave |
|
31 |
// them both commented out then the tests will be done in a single thread |
|
32 |
// using asynchronous file operations, thus avoiding the problem. |
|
33 |
||
34 |
// Uncomment the following if you want to test asynchronous file operations |
|
35 |
// using two threads rather than in a single thread. |
|
36 |
||
37 |
// #define TEST_ASYNC_IN_THREAD |
|
38 |
||
39 |
// Uncomment the following if you want to test using synchronous file |
|
40 |
// operations, using two threads to do both at once. |
|
41 |
||
42 |
// #define TEST_SYNC_IN_THREAD |
|
43 |
||
44 |
struct TStats |
|
45 |
// |
|
46 |
// Statistics -- size and time of operations. |
|
47 |
// |
|
48 |
{ |
|
49 |
TInt64 iSize; |
|
50 |
TInt64 iTime; |
|
51 |
void Init() { iSize = 0; iTime = 0; } |
|
52 |
}; |
|
53 |
||
54 |
GLDEF_D RTest test(_L("T_CFSBENCH")); |
|
55 |
GLDEF_D RFs TheFs; |
|
56 |
||
57 |
LOCAL_D TFullName gFsName; |
|
58 |
LOCAL_D TFullName gFsName1; |
|
59 |
LOCAL_D TFullName gFsName2; |
|
60 |
LOCAL_D TFullName gOldFsName; |
|
61 |
LOCAL_D TFullName gNewFsName; |
|
62 |
LOCAL_D TBool gNoMedia = ETrue; |
|
63 |
||
64 |
#if defined(TEST_SYNC_IN_THREAD) || defined(TEST_ASYNC_IN_THREAD) |
|
65 |
LOCAL_D TInt gThreadNumber = 0; |
|
66 |
#endif |
|
67 |
||
68 |
LOCAL_D RMutex gDataLock; |
|
69 |
LOCAL_D TStats gWrStats; |
|
70 |
LOCAL_D TStats gRdStats; |
|
71 |
||
72 |
_LIT(KFsFile, "CFAFSDLY"); |
|
73 |
_LIT(KFsName, "DelayFS"); |
|
74 |
||
75 |
LOCAL_D const TInt32 KSecond = 1000000; |
|
76 |
LOCAL_D const TInt32 KTimeBM = 20; |
|
77 |
LOCAL_D const TInt32 KNumBuf = 100; |
|
78 |
LOCAL_D const TInt32 KBufLen = 0x100; |
|
79 |
LOCAL_D const TInt32 KMaxThr = 10; |
|
80 |
LOCAL_D const TInt32 KMaxLag = 4; |
|
81 |
||
82 |
LOCAL_D TBuf8<KBufLen> gBufferArr[KMaxThr][KNumBuf]; |
|
83 |
LOCAL_D TRequestStatus gStatusArr[KMaxThr][KNumBuf]; |
|
84 |
||
85 |
LOCAL_C void AddStats(TStats& aStats, TInt64 aSize, TInt64 aTime) |
|
86 |
/// Add values to the statistics. |
|
87 |
{ |
|
88 |
gDataLock.Wait(); |
|
89 |
aStats.iSize += aSize; |
|
90 |
aStats.iTime += aTime; |
|
91 |
gDataLock.Signal(); |
|
92 |
} |
|
93 |
||
94 |
LOCAL_C TInt GetSpeed(TStats& aStats) |
|
95 |
/// Calculate and return the data throughput from the statistics, rounded. |
|
96 |
{ |
|
97 |
gDataLock.Wait(); |
|
98 |
TInt speed = I64LOW((aStats.iSize + aStats.iTime/2) / aStats.iTime); |
|
99 |
gDataLock.Signal(); |
|
100 |
return speed; |
|
101 |
} |
|
102 |
||
103 |
LOCAL_C TInt32 GetSpeed(TInt aOps, TInt64 aDtime) |
|
104 |
/// Calculate and return the throughput from the umber of blocks transferred |
|
105 |
/// and the elapsed time. |
|
106 |
{ |
|
107 |
TInt64 dsize = MAKE_TINT64(0, aOps) * MAKE_TINT64(0, KBufLen) * MAKE_TINT64(0, KSecond); |
|
108 |
TInt32 speed = I64LOW((dsize + aDtime/2) / aDtime); |
|
109 |
return speed; |
|
110 |
} |
|
111 |
||
112 |
LOCAL_C TBool DriveIsOK(TChar c) |
|
113 |
/// Test that a selected drive leter is OK to write files. |
|
114 |
{ |
|
115 |
TInt r; |
|
116 |
TInt drv; |
|
117 |
r=TheFs.CharToDrive(c, drv); |
|
118 |
if (r != KErrNone) |
|
119 |
return EFalse; |
|
120 |
TDriveInfo info; |
|
121 |
r=TheFs.Drive(info,drv); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
122 |
test_KErrNone(r); |
0 | 123 |
return (info.iDriveAtt != 0 && !(info.iDriveAtt & KDriveAttRom)); |
124 |
} |
|
125 |
||
126 |
LOCAL_C TChar MountTestFileSystem(TInt aDrive) |
|
127 |
// |
|
128 |
// Mount a new CTestFileSystem on the drive under test |
|
129 |
// |
|
130 |
{ |
|
131 |
TInt r; |
|
132 |
TBuf<64> b; |
|
133 |
TChar c; |
|
134 |
r=TheFs.DriveToChar(aDrive,c); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
135 |
test_KErrNone(r); |
0 | 136 |
b.Format(_L("Mount test file system on %c:"),(TUint)c); |
137 |
test.Next(b); |
|
138 |
||
139 |
r=TheFs.AddFileSystem(KFsFile); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
140 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 141 |
|
142 |
r=TheFs.FileSystemName(gOldFsName,aDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
143 |
test_Value(r, r == KErrNone || r==KErrNotFound); |
0 | 144 |
|
145 |
TDriveInfo drv; |
|
146 |
r = TheFs.Drive(drv, aDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
test_KErrNone(r); |
0 | 148 |
|
149 |
gNoMedia = (drv.iType == EMediaUnknown || drv.iType == EMediaNotPresent); |
|
150 |
||
151 |
if (gOldFsName.Length() > 0) |
|
152 |
{ |
|
153 |
TTest::Printf(_L("Dismount %C: %S"), (TUint)c, &gOldFsName); |
|
154 |
r=TheFs.DismountFileSystem(gOldFsName,aDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
155 |
test_KErrNone(r); |
0 | 156 |
} |
157 |
||
158 |
r=TheFs.MountFileSystem(KFsName,aDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
159 |
test_KErrNone(r); |
0 | 160 |
|
161 |
r=TheFs.FileSystemName(gNewFsName,aDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
162 |
test_KErrNone(r); |
0 | 163 |
test(gNewFsName.CompareF(KFsName)==0); |
164 |
return c; |
|
165 |
} |
|
166 |
||
167 |
LOCAL_C void UnmountFileSystem(TInt aDrive) |
|
168 |
/// Unmount a test filesystem and mount the old one. |
|
169 |
{ |
|
170 |
TChar c; |
|
171 |
TInt r=TheFs.DriveToChar(aDrive,c); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
172 |
test_KErrNone(r); |
0 | 173 |
r=TheFs.DismountFileSystem(gNewFsName,aDrive); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
174 |
test_KErrNone(r); |
0 | 175 |
// if there's no media present, don't try to mount it |
176 |
if (gNoMedia) |
|
177 |
{ |
|
178 |
test.Printf(_L("No media on %C: so don't remount it"), (TUint)c); |
|
179 |
} |
|
180 |
else if (gOldFsName.Length() > 0) |
|
181 |
{ |
|
182 |
test.Printf(_L("Mount %C: %S"), (TUint)c, &gOldFsName); |
|
183 |
r=TheFs.MountFileSystem(gOldFsName,aDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
184 |
test_KErrNone(r); |
0 | 185 |
} |
186 |
if (r != KErrNone) |
|
187 |
test.Printf(_L("Error %d remounting %S on %C\n"), r, &gOldFsName, (TUint)c); |
|
188 |
} |
|
189 |
||
190 |
LOCAL_C void RemountFileSystem(TInt aDrive, TBool aSync) |
|
191 |
/// Unmount and remount the file system on the specified drive in the |
|
192 |
/// selected mode. |
|
193 |
/// @param aDrive Drive number (EDriveC etc.). |
|
194 |
/// @param aSync Mount synchronous if true, asynchronous if not. |
|
195 |
{ |
|
196 |
TChar c; |
|
197 |
TInt r=TheFs.DriveToChar(aDrive,c); |
|
198 |
r=TheFs.FileSystemName(gFsName, aDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
test_Value(r, r == KErrNone || r==KErrNotFound); |
0 | 200 |
|
201 |
if (gFsName.Length() > 0) |
|
202 |
{ |
|
203 |
r=TheFs.DismountFileSystem(gFsName, aDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
204 |
test_KErrNone(r); |
0 | 205 |
} |
206 |
||
207 |
TBufC<16> type = _L("asynchronous"); |
|
208 |
if (aSync) |
|
209 |
type = _L("synchronous"); |
|
210 |
test.Printf(_L("Mount filesystem %c: %-8S as %S\n"), (TUint)c, &gFsName, &type); |
|
211 |
||
212 |
#ifdef __CONCURRENT_FILE_ACCESS__ |
|
213 |
r=TheFs.MountFileSystem(gFsName, aDrive, aSync); |
|
214 |
#else |
|
215 |
r=TheFs.MountFileSystem(gFsName, aDrive); |
|
216 |
#endif |
|
217 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
218 |
test_KErrNone(r); |
0 | 219 |
} |
220 |
||
221 |
enum TOper |
|
222 |
{ |
|
223 |
ERead, |
|
224 |
EWrite |
|
225 |
}; |
|
226 |
||
227 |
// --------------------------------------------------------------------------- |
|
228 |
||
229 |
#if defined(TEST_SYNC_IN_THREAD) |
|
230 |
||
231 |
LOCAL_C TInt testSyncAccess(TAny* aData) |
|
232 |
/// |
|
233 |
/// Test read file handling. |
|
234 |
/// |
|
235 |
/// @param aData pointer to the thread data area |
|
236 |
{ |
|
237 |
TThreadData& data = *(TThreadData*)aData; |
|
238 |
TFileName fileName = data.iFile; |
|
239 |
TBool dowrite = (data.iData != NULL); |
|
240 |
||
241 |
RFs myFs; |
|
242 |
TInt r = myFs.Connect(); |
|
243 |
TEST(r==KErrNone); |
|
244 |
||
245 |
r = myFs.SetSessionPath(gSessionPath); |
|
246 |
if (r != KErrNone) |
|
247 |
TTest::Fail(HERE, _L("SetSessionPath returned %d"), r); |
|
248 |
||
249 |
TVolumeInfo vol; |
|
250 |
TInt drv; |
|
251 |
r = myFs.CharToDrive(fileName[0], drv); |
|
252 |
if (r != KErrNone) |
|
253 |
TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), fileName[0], r); |
|
254 |
r = myFs.Volume(vol, drv); |
|
255 |
if (r != KErrNone) |
|
256 |
TTest::Fail(HERE, _L("Volume() returned %d"), r); |
|
257 |
||
258 |
TInt maxwrite = TInt(vol.iFree / 2 - KBufLen); |
|
259 |
if (maxwrite < KBufLen*2) |
|
260 |
TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"), |
|
261 |
TInt(vol.iFree/1024)); |
|
262 |
||
263 |
RFile f; |
|
264 |
RTimer timer; |
|
265 |
TTime startTime; |
|
266 |
TTime endTime; |
|
267 |
TTimeIntervalMicroSeconds timeTaken; |
|
268 |
||
269 |
TBuf8<KBufLen> buff; |
|
270 |
TRequestStatus tstat; |
|
271 |
||
272 |
TInt wrnum = 0; |
|
273 |
TInt rdnum = 0; |
|
274 |
||
275 |
timer.CreateLocal(); |
|
276 |
||
277 |
if (dowrite) |
|
278 |
{ |
|
279 |
// write tests |
|
280 |
||
281 |
r = f.Replace(myFs, fileName, EFileStreamText | EFileWrite); |
|
282 |
TEST(r==KErrNone); |
|
283 |
||
284 |
// wait for both tasks to have a chance to complete opening the files |
|
285 |
User::After(1000); |
|
286 |
||
287 |
buff.Fill('_', KBufLen); |
|
288 |
||
289 |
timer.After(tstat, KTimeBM * KSecond); |
|
290 |
||
291 |
startTime.HomeTime(); |
|
292 |
||
293 |
while (tstat == KRequestPending) |
|
294 |
{ |
|
295 |
TInt pos = (wrnum * KBufLen) % maxwrite; |
|
296 |
r = f.Write(pos, buff); |
|
297 |
TEST(r==KErrNone); |
|
298 |
++wrnum; |
|
299 |
} |
|
300 |
||
301 |
endTime.HomeTime(); |
|
302 |
timeTaken=endTime.MicroSecondsFrom(startTime); |
|
303 |
||
304 |
TInt64 dtime = timeTaken.Int64(); |
|
305 |
TInt64 dsize = wrnum * KBufLen * TInt64(KSecond); |
|
306 |
TInt32 speed = TInt32((dsize + dtime/2) / dtime); |
|
307 |
AddStats(gWrStats, dsize, dtime); |
|
308 |
||
309 |
TTest::Printf(_L("%8d writes in %6d mS = %8d bytes per second\n"), |
|
310 |
wrnum, TInt32(dtime)/1000, speed); |
|
311 |
||
312 |
timer.Cancel(); |
|
313 |
f.Close(); |
|
314 |
} |
|
315 |
else |
|
316 |
{ |
|
317 |
// read tests |
|
318 |
||
319 |
r = f.Open(myFs, fileName, EFileStreamText); |
|
320 |
TEST(r==KErrNone); |
|
321 |
||
322 |
// wait for both tasks to have a chance to complete opening the files |
|
323 |
User::After(1000); |
|
324 |
||
325 |
timer.After(tstat, KTimeBM * KSecond); |
|
326 |
||
327 |
startTime.HomeTime(); |
|
328 |
||
329 |
while (tstat == KRequestPending) |
|
330 |
{ |
|
331 |
TInt pos = (rdnum * KBufLen) % maxwrite; |
|
332 |
r = f.Read(pos, buff, KBufLen); |
|
333 |
TEST(r==KErrNone); |
|
334 |
++rdnum; |
|
335 |
} |
|
336 |
||
337 |
endTime.HomeTime(); |
|
338 |
timeTaken=endTime.MicroSecondsFrom(startTime); |
|
339 |
||
340 |
TInt64 dtime = timeTaken.Int64(); |
|
341 |
TInt64 dsize = rdnum * KBufLen * TInt64(KSecond); |
|
342 |
TInt32 speed = TInt32((dsize + dtime/2) / dtime); |
|
343 |
AddStats(gRdStats, dsize, dtime); |
|
344 |
||
345 |
// wait to allow the dust to settle |
|
346 |
User::After(KSecond); |
|
347 |
||
348 |
TTest::Printf(_L("%8d reads in %6d mS = %8d bytes per second\n"), |
|
349 |
rdnum, TInt32(dtime)/1000, speed); |
|
350 |
||
351 |
timer.Cancel(); |
|
352 |
timer.Close(); |
|
353 |
f.Close(); |
|
354 |
||
355 |
// delete file after reading it |
|
356 |
myFs.Delete(fileName); |
|
357 |
} |
|
358 |
||
359 |
myFs.Close(); |
|
360 |
return r; |
|
361 |
} |
|
362 |
||
363 |
#endif |
|
364 |
||
365 |
// --------------------------------------------------------------------------- |
|
366 |
||
367 |
#if defined(TEST_ASYNC_IN_THREAD) |
|
368 |
||
369 |
LOCAL_C TInt testAsyncAccess(TAny* aData) |
|
370 |
// |
|
371 |
/// Test read file handling. |
|
372 |
/// |
|
373 |
/// @param aData pointer to the thread data area |
|
374 |
{ |
|
375 |
TThreadData& data = *(TThreadData*)aData; |
|
376 |
TFileName fileName = data.iFile; |
|
377 |
TBool dowrite = (data.iData != NULL); |
|
378 |
TBuf8<KBufLen>* buffer = gBufferArr[data.iNum]; |
|
379 |
TRequestStatus* status = gStatusArr[data.iNum]; |
|
380 |
||
381 |
RFs myFs; |
|
382 |
TInt r = myFs.Connect(); |
|
383 |
TEST(r==KErrNone); |
|
384 |
||
385 |
r = myFs.SetSessionPath(gSessionPath); |
|
386 |
if (r != KErrNone) |
|
387 |
TTest::Fail(HERE, _L("SetSessionPath returned %d"), r); |
|
388 |
||
389 |
TVolumeInfo vol; |
|
390 |
TInt drv; |
|
391 |
r = myFs.CharToDrive(fileName[0], drv); |
|
392 |
if (r != KErrNone) |
|
393 |
TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), fileName[0], r); |
|
394 |
r = myFs.Volume(vol, drv); |
|
395 |
if (r != KErrNone) |
|
396 |
TTest::Fail(HERE, _L("Volume() returned %d"), r); |
|
397 |
||
398 |
TInt64 maxwrite = vol.iFree / 2 - KBufLen; |
|
399 |
if (maxwrite < KBufLen*2) |
|
400 |
TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"), |
|
401 |
TInt(vol.iFree/1024)); |
|
402 |
||
403 |
RFile f; |
|
404 |
RTimer timer; |
|
405 |
TRequestStatus tstat; |
|
406 |
TTime startTime; |
|
407 |
TTime endTime; |
|
408 |
TTimeIntervalMicroSeconds timeTaken; |
|
409 |
||
410 |
TInt wrnum = 0; |
|
411 |
TInt rdnum = 0; |
|
412 |
TInt opnum = 0; |
|
413 |
TInt opfin = 0; |
|
414 |
TInt i; |
|
415 |
||
416 |
timer.CreateLocal(); |
|
417 |
||
418 |
if (dowrite) |
|
419 |
{ |
|
420 |
r = f.Replace(myFs, fileName, EFileStreamText | EFileWrite); |
|
421 |
TEST(r==KErrNone); |
|
422 |
||
423 |
// wait for both tasks to have a chance to complete opening the files |
|
424 |
User::After(1000); |
|
425 |
||
426 |
for (i = 0; i < KNumBuf; i++) |
|
427 |
buffer[i].Fill('_', KBufLen); |
|
428 |
||
429 |
timer.After(tstat, KTimeBM * KSecond); |
|
430 |
||
431 |
startTime.HomeTime(); |
|
432 |
||
433 |
while (tstat == KRequestPending) |
|
434 |
{ |
|
435 |
TInt pos = TInt((wrnum * KBufLen) % maxwrite); |
|
436 |
TInt bnum = opnum++ % KNumBuf; |
|
437 |
f.Write(pos, buffer[bnum], status[bnum]); |
|
438 |
if (opnum - opfin > KMaxLag) |
|
439 |
{ |
|
440 |
while (status[opfin % KNumBuf] == KRequestPending) |
|
441 |
User::WaitForRequest(status[opfin % KNumBuf]); |
|
442 |
opfin++; |
|
443 |
} |
|
444 |
++wrnum; |
|
445 |
} |
|
446 |
||
447 |
while (opfin < opnum) |
|
448 |
{ |
|
449 |
while (status[opfin % KNumBuf] == KRequestPending) |
|
450 |
User::WaitForRequest(status[opfin % KNumBuf]); |
|
451 |
opfin++; |
|
452 |
} |
|
453 |
||
454 |
endTime.HomeTime(); |
|
455 |
TTimeIntervalMicroSeconds timeTaken=endTime.MicroSecondsFrom(startTime); |
|
456 |
||
457 |
TInt64 dtime = timeTaken.Int64(); |
|
458 |
TInt64 dsize = wrnum * KBufLen * TInt64(KSecond); |
|
459 |
TInt32 speed = TInt32((dsize + dtime/2) / dtime); |
|
460 |
AddStats(gWrStats, dsize, dtime); |
|
461 |
||
462 |
TTest::Printf(_L("%8d writes in %6d mS = %8d bytes per second\n"), |
|
463 |
wrnum, TInt32(dtime)/1000, speed); |
|
464 |
} |
|
465 |
else |
|
466 |
{ |
|
467 |
r = f.Open(myFs, fileName, EFileStreamText); |
|
468 |
TEST(r==KErrNone); |
|
469 |
||
470 |
timer.After(tstat, KTimeBM * KSecond); |
|
471 |
||
472 |
startTime.HomeTime(); |
|
473 |
||
474 |
while (tstat == KRequestPending) |
|
475 |
{ |
|
476 |
TInt pos = TInt((rdnum * KBufLen) % maxwrite); |
|
477 |
TInt bnum = opnum++ % KNumBuf; |
|
478 |
f.Read(pos, buffer[bnum], status[bnum]); |
|
479 |
if (opnum - opfin > KMaxLag) |
|
480 |
{ |
|
481 |
User::WaitForRequest(status[opfin++ % KNumBuf]); |
|
482 |
} |
|
483 |
++rdnum; |
|
484 |
} |
|
485 |
||
486 |
while (opfin < opnum) |
|
487 |
{ |
|
488 |
if (status[opfin % KNumBuf] == KRequestPending) |
|
489 |
User::WaitForRequest(status[opfin % KNumBuf]); |
|
490 |
opfin++; |
|
491 |
} |
|
492 |
||
493 |
endTime.HomeTime(); |
|
494 |
timeTaken=endTime.MicroSecondsFrom(startTime); |
|
495 |
TInt64 dtime = timeTaken.Int64(); |
|
496 |
TInt64 dsize = rdnum * KBufLen * TInt64(KSecond); |
|
497 |
TInt32 speed = TInt32((dsize + dtime/2) / dtime); |
|
498 |
AddStats(gRdStats, dsize, dtime); |
|
499 |
||
500 |
// wait to allow the dust to settle |
|
501 |
User::After(KSecond); |
|
502 |
||
503 |
TTest::Printf(_L("%8d reads in %6d mS = %8d bytes per second\n"), |
|
504 |
rdnum, TInt32(dtime)/1000, speed); |
|
505 |
||
506 |
myFs.Delete(fileName); |
|
507 |
} |
|
508 |
||
509 |
timer.Cancel(); |
|
510 |
timer.Close(); |
|
511 |
f.Close(); |
|
512 |
myFs.Close(); |
|
513 |
return r; |
|
514 |
} |
|
515 |
||
516 |
#endif |
|
517 |
||
518 |
// --------------------------------------------------------------------------- |
|
519 |
||
520 |
class TFileOps |
|
521 |
/// Do operations on a file. |
|
522 |
{ |
|
523 |
public: |
|
524 |
TFileOps(); |
|
525 |
TInt Open(TChar dr, TInt n); |
|
526 |
TInt Close(); |
|
527 |
TInt Reset(); |
|
528 |
TInt Erase(); |
|
529 |
TInt Write(); |
|
530 |
TInt Read(); |
|
531 |
TInt End(); |
|
532 |
public: |
|
533 |
TFileName iName; |
|
534 |
RFile iF; |
|
535 |
TBuf8<KBufLen> iBuffer[KMaxLag]; |
|
536 |
TRequestStatus iStatus[KMaxLag]; |
|
537 |
TInt iPtr; |
|
538 |
TInt iNum; |
|
539 |
TInt iOps; |
|
540 |
TInt iMax; |
|
541 |
TBool iOpen; |
|
542 |
}; |
|
543 |
||
544 |
TFileOps::TFileOps() : iPtr(0), iNum(0), iOps(0), iMax(0), iOpen(EFalse) |
|
545 |
{ |
|
546 |
for (TInt i = 0; i < KMaxLag; i++) |
|
547 |
{ |
|
548 |
iStatus[i] = KErrNone; |
|
549 |
iBuffer[i].Fill(TChar('_'), KBufLen); |
|
550 |
} |
|
551 |
} |
|
552 |
||
553 |
TInt TFileOps::Open(TChar aDrvCh, TInt aNum) |
|
554 |
/// Open the file for testing, give error if there is not enough space for it. |
|
555 |
/// @param aDrvCh Drive letter. |
|
556 |
/// @param aNum File number suffix. |
|
557 |
{ |
|
558 |
TVolumeInfo vol; |
|
559 |
TInt drv; |
|
560 |
TInt r = TheFs.CharToDrive(aDrvCh, drv); |
|
561 |
if (r != KErrNone) |
|
562 |
TTest::Fail(HERE, _L("CharToDrive(%c) returned %d"), (TUint)aDrvCh, r); |
|
563 |
r = TheFs.Volume(vol, drv); |
|
564 |
if (r != KErrNone) |
|
565 |
TTest::Fail(HERE, _L("Volume(%c:) returned %d"), (TUint)aDrvCh, r); |
|
566 |
||
567 |
iMax = I64LOW(vol.iFree / MAKE_TINT64(0,KBufLen)) / 2 - 1; |
|
568 |
if (iMax < 10) |
|
569 |
TTest::Fail(HERE, _L("Not enough space to do test, only %d KB available"), |
|
570 |
I64LOW(vol.iFree/1024)); |
|
571 |
||
572 |
Reset(); |
|
573 |
iName.Format(_L("%c:\\TEST_%d"), (TUint)aDrvCh, aNum); |
|
574 |
r = iF.Replace(TheFs, iName, EFileStreamText | EFileWrite); |
|
575 |
if (r == KErrNone) |
|
576 |
iOpen = ETrue; |
|
577 |
return r; |
|
578 |
} |
|
579 |
||
580 |
TInt TFileOps::Close() |
|
581 |
/// Close and delete the file, returning the number of operations done. |
|
582 |
{ |
|
583 |
if (!iOpen) |
|
584 |
return 0; |
|
585 |
iF.Close(); |
|
586 |
TheFs.Delete(iName); |
|
587 |
iOpen = EFalse; |
|
588 |
return iNum; |
|
589 |
} |
|
590 |
||
591 |
TInt TFileOps::Reset() |
|
592 |
/// Reset all of the counts. |
|
593 |
{ |
|
594 |
iPtr = 0; |
|
595 |
iNum = 0; |
|
596 |
iOps = 0; |
|
597 |
return 0; |
|
598 |
} |
|
599 |
||
600 |
TInt TFileOps::Write() |
|
601 |
/// If there is a free buffer available, start a write. |
|
602 |
{ |
|
603 |
if (!iOpen) |
|
604 |
return 0; |
|
605 |
while (iNum < iOps && iStatus[iNum%KMaxLag] != KRequestPending) |
|
606 |
iNum++; |
|
607 |
if (iOps < KMaxLag || iStatus[iPtr] != KRequestPending) |
|
608 |
{ |
|
609 |
TInt pos = iNum%iMax * KBufLen; |
|
610 |
iF.Write(pos, iBuffer[iPtr], iStatus[iPtr]); |
|
611 |
iOps++; |
|
612 |
iPtr++; |
|
613 |
iPtr %= KMaxLag; |
|
614 |
return 1; |
|
615 |
} |
|
616 |
return 0; |
|
617 |
} |
|
618 |
||
619 |
TInt TFileOps::Read() |
|
620 |
/// If there is a free buffer available, start a read. |
|
621 |
{ |
|
622 |
if (!iOpen) |
|
623 |
return 0; |
|
624 |
while (iNum < iOps && iStatus[iNum%KMaxLag] != KRequestPending) |
|
625 |
iNum++; |
|
626 |
if (iOps < KMaxLag || iStatus[iPtr] != KRequestPending) |
|
627 |
{ |
|
628 |
TInt pos = iNum%iMax * KBufLen; |
|
629 |
iF.Read(pos, iBuffer[iPtr], iStatus[iPtr]); |
|
630 |
iOps++; |
|
631 |
iPtr++; |
|
632 |
iPtr %= KMaxLag; |
|
633 |
return 1; |
|
634 |
} |
|
635 |
return 0; |
|
636 |
} |
|
637 |
||
638 |
TInt TFileOps::End() |
|
639 |
/// Wait until all outstanding operations have ended, then return the number. |
|
640 |
{ |
|
641 |
if (!iOpen) |
|
642 |
return 0; |
|
643 |
while (iNum < iOps) |
|
644 |
{ |
|
645 |
if (iStatus[iNum%KMaxLag] == KRequestPending) |
|
646 |
User::WaitForRequest(iStatus[iNum%KMaxLag]); |
|
647 |
else |
|
648 |
iNum++; |
|
649 |
} |
|
650 |
if (iOps < iMax) |
|
651 |
iMax = iOps; |
|
652 |
return iNum; |
|
653 |
} |
|
654 |
||
655 |
LOCAL_C TInt testAsyncAccess(TChar dc1, TChar dc2) |
|
656 |
// |
|
657 |
// Test one drive against the other. |
|
658 |
// |
|
659 |
{ |
|
660 |
TFileOps f1; |
|
661 |
TFileOps f2; |
|
662 |
||
663 |
f1.Open(dc1, 1); |
|
664 |
if (dc1 != dc2) |
|
665 |
f2.Open(dc2, 2); |
|
666 |
||
667 |
TInt op1 = 0; |
|
668 |
TInt op2 = 0; |
|
669 |
RTimer timer; |
|
670 |
TRequestStatus tstat; |
|
671 |
TTime startTime; |
|
672 |
TTime endTime; |
|
673 |
TTimeIntervalMicroSeconds timeTaken; |
|
674 |
||
675 |
timer.CreateLocal(); |
|
676 |
||
677 |
timer.After(tstat, KTimeBM * KSecond); |
|
678 |
||
679 |
startTime.HomeTime(); |
|
680 |
||
681 |
while (tstat == KRequestPending) |
|
682 |
{ |
|
683 |
TInt num = f1.Write(); |
|
684 |
num += f2.Write(); |
|
685 |
if (num == 0) |
|
686 |
User::WaitForAnyRequest(); |
|
687 |
} |
|
688 |
||
689 |
op1 = f1.End(); |
|
690 |
op2 = f2.End(); |
|
691 |
||
692 |
endTime.HomeTime(); |
|
693 |
timeTaken=endTime.MicroSecondsFrom(startTime); |
|
694 |
||
695 |
TInt64 dtime = timeTaken.Int64(); |
|
696 |
||
697 |
TTest::Printf(_L("%c: %8d writes in %6d mS = %8d bytes per second\n"), |
|
698 |
(TUint)dc1, op1, I64LOW(dtime)/1000, GetSpeed(op1, dtime)); |
|
699 |
||
700 |
if (dc1 != dc2) |
|
701 |
TTest::Printf(_L("%c: %8d writes in %6d mS = %8d bytes per second\n"), |
|
702 |
(TUint)dc2, op2, I64LOW(dtime)/1000, GetSpeed(op2, dtime)); |
|
703 |
||
704 |
AddStats(gWrStats, MAKE_TINT64(0, op1 + op2) * MAKE_TINT64(0, KBufLen) * MAKE_TINT64(0, KSecond), dtime); |
|
705 |
||
706 |
// now the reads! |
|
707 |
||
708 |
f1.Reset(); |
|
709 |
f2.Reset(); |
|
710 |
||
711 |
timer.After(tstat, KTimeBM * KSecond); |
|
712 |
||
713 |
startTime.HomeTime(); |
|
714 |
||
715 |
while (tstat == KRequestPending) |
|
716 |
{ |
|
717 |
f1.Read(); |
|
718 |
f2.Read(); |
|
719 |
User::WaitForAnyRequest(); |
|
720 |
} |
|
721 |
||
722 |
op1 = f1.End(); |
|
723 |
op2 = f2.End(); |
|
724 |
||
725 |
endTime.HomeTime(); |
|
726 |
timeTaken=endTime.MicroSecondsFrom(startTime); |
|
727 |
||
728 |
dtime = timeTaken.Int64(); |
|
729 |
||
730 |
TTest::Printf(_L("%c: %8d reads in %6d mS = %8d bytes per second\n"), |
|
731 |
(TUint)dc1, op1, I64LOW(dtime)/1000, GetSpeed(op1, dtime)); |
|
732 |
||
733 |
if (dc1 != dc2) |
|
734 |
TTest::Printf(_L("%c: %8d reads in %6d mS = %8d bytes per second\n"), |
|
735 |
(TUint)dc2, op2, I64LOW(dtime)/1000, GetSpeed(op2, dtime)); |
|
736 |
||
737 |
AddStats(gRdStats, MAKE_TINT64(0, op1 + op2) * MAKE_TINT64(0, KBufLen) * MAKE_TINT64(0, KSecond), dtime); |
|
738 |
||
739 |
test.Printf(_L("\n")); |
|
740 |
test.Printf(_L("average write throughput = %d bytes/sec\n"), GetSpeed(gWrStats)); |
|
741 |
test.Printf(_L("average read throughput = %d bytes/sec\n"), GetSpeed(gRdStats)); |
|
742 |
test.Printf(_L("\n")); |
|
743 |
gWrStats.Init(); |
|
744 |
gRdStats.Init(); |
|
745 |
||
746 |
timer.Cancel(); |
|
747 |
timer.Close(); |
|
748 |
f1.Close(); |
|
749 |
f2.Close(); |
|
750 |
// delay for a second to allow the close to complete before dismounting. |
|
751 |
User::After(1000000); |
|
752 |
return KErrNone; |
|
753 |
} |
|
754 |
||
755 |
#if defined(TEST_SYNC_IN_THREAD) || defined(TEST_ASYNC_IN_THREAD) |
|
756 |
||
757 |
LOCAL_C TInt CreateThread(TThreadFunction aFunc, TChar c, TOper aOper) |
|
758 |
/// Create a thread to do the appropriate operation on a drive. |
|
759 |
{ |
|
760 |
TBuf<2> drive(_L("?")); |
|
761 |
TBuf<64> name; |
|
762 |
drive[0] = TText(c); |
|
763 |
drive.UpperCase(); |
|
764 |
TThreadData& d = TTest::Data(gThreadNumber); |
|
765 |
d.iFile.Format(_L("%S:\\TEST%d.FILE"), &drive, gThreadNumber); |
|
766 |
d.iData = (aOper == EWrite ? &aOper : NULL); |
|
767 |
name.Format(_L("Test_%S_%d"), &drive, gThreadNumber); |
|
768 |
TInt r = TTest::Create(gThreadNumber, aFunc, name); |
|
769 |
++gThreadNumber; |
|
770 |
return r; |
|
771 |
} |
|
772 |
||
773 |
LOCAL_C TInt RunThreads(TThreadFunction aFunc, TChar aDrive1, TChar aDrive2, TOper aOper) |
|
774 |
/// Run threads to test one drive against the other at the same time. |
|
775 |
/// The thread will report any error and return it as a value, the program will |
|
776 |
/// exit at a higher level after cleaning up. |
|
777 |
{ |
|
778 |
TInt r; |
|
779 |
gThreadNumber = 0; |
|
780 |
if ((r = CreateThread(aFunc, aDrive1, aOper)) != KErrNone) return r; |
|
781 |
if ((r = CreateThread(aFunc, aDrive2, aOper)) != KErrNone) return r; |
|
782 |
TTest::Printf(); |
|
783 |
r = TTest::Run(); |
|
784 |
TTest::Printf(); |
|
785 |
return r; |
|
786 |
} |
|
787 |
||
788 |
LOCAL_C TInt testThreads(TThreadFunction aFunc, TChar c, TChar d) |
|
789 |
/// Run threads testing read and write of the drives both ways round. |
|
790 |
/// The thread will report any error and return it as a value, the program will |
|
791 |
/// exit at a higher level after cleaning up. |
|
792 |
{ |
|
793 |
TInt r; |
|
794 |
if ((r = RunThreads(aFunc, c, d, EWrite)) != KErrNone) return r; |
|
795 |
if ((r = RunThreads(aFunc, c, d, ERead)) != KErrNone) return r; |
|
796 |
if ((r = RunThreads(aFunc, d, c, EWrite)) != KErrNone) return r; |
|
797 |
if ((r = RunThreads(aFunc, d, c, ERead)) != KErrNone) return r; |
|
798 |
// display totals; |
|
799 |
test.Printf(_L("average write throughput = %d bytes/sec\n"), GetSpeed(gWrStats)); |
|
800 |
test.Printf(_L("average read throughput = %d bytes/sec\n"), GetSpeed(gRdStats)); |
|
801 |
test.Printf(_L("\n")); |
|
802 |
gWrStats.Init(); |
|
803 |
gRdStats.Init(); |
|
804 |
return r; |
|
805 |
} |
|
806 |
||
807 |
#endif |
|
808 |
||
809 |
LOCAL_C TInt parseCmd(TChar& aDrvCh1, TChar& aDrvCh2) |
|
810 |
/// Get parameters from the comand line; if there aren't enough then |
|
811 |
/// prompt the user for them and return KErrAbort if ^C is pressed. |
|
812 |
{ |
|
813 |
while (aDrvCh1 < 'A' || aDrvCh1 > 'Z') |
|
814 |
{ |
|
815 |
test.Printf(_L("Enter drive letter: ")); |
|
816 |
while (aDrvCh1 < 'A' || aDrvCh1 > 'Z') |
|
817 |
{ |
|
818 |
if (aDrvCh1 == 0x03) |
|
819 |
return KErrAbort; |
|
820 |
aDrvCh1 = User::UpperCase(test.Getch()); |
|
821 |
} |
|
822 |
if (!DriveIsOK(aDrvCh1)) |
|
823 |
{ |
|
824 |
test.Printf(_L("%c: is not a valid drive\n"), (TUint)aDrvCh1); |
|
825 |
aDrvCh1 = 0; |
|
826 |
} |
|
827 |
else |
|
828 |
{ |
|
829 |
TInt drv; |
|
830 |
TheFs.CharToDrive(aDrvCh1, drv); |
|
831 |
TheFs.FileSystemName(gFsName1, drv); |
|
832 |
test.Printf(_L("%c: (%S)\n"), (TUint)aDrvCh1, &gFsName1); |
|
833 |
} |
|
834 |
} |
|
835 |
||
836 |
while (aDrvCh2 < 'A' || aDrvCh2 > 'Z') |
|
837 |
{ |
|
838 |
test.Printf(_L("Enter drive letter: ")); |
|
839 |
while (aDrvCh2 < 'A' || aDrvCh2 > 'Z') |
|
840 |
{ |
|
841 |
if (aDrvCh2 == 0x03) |
|
842 |
return KErrAbort; |
|
843 |
aDrvCh2 = User::UpperCase(test.Getch()); |
|
844 |
} |
|
845 |
if (!DriveIsOK(aDrvCh2)) |
|
846 |
{ |
|
847 |
test.Printf(_L("%c: is not a valid drive\n"), (TUint)aDrvCh2); |
|
848 |
aDrvCh2 = 0; |
|
849 |
} |
|
850 |
else |
|
851 |
{ |
|
852 |
TInt drv; |
|
853 |
TheFs.CharToDrive(aDrvCh2, drv); |
|
854 |
TheFs.FileSystemName(gFsName2, drv); |
|
855 |
test.Printf(_L("%c: (%S)\n"), (TUint)aDrvCh2, &gFsName2); |
|
856 |
} |
|
857 |
} |
|
858 |
return KErrNone; |
|
859 |
} |
|
860 |
||
861 |
GLDEF_C void CallTestsL() |
|
862 |
// |
|
863 |
// Do all tests |
|
864 |
// |
|
865 |
{ |
|
866 |
TInt r = TTest::Init(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
867 |
test_KErrNone(r); |
0 | 868 |
|
869 |
TChar drvch0 = TTest::DefaultDriveChar(); |
|
870 |
TChar drvch1 = 0; |
|
871 |
TChar drvch2 = 0; |
|
872 |
TInt drive0; |
|
873 |
TInt drive1; |
|
874 |
TInt drive2; |
|
875 |
||
876 |
const TInt KMaxArgs = 4; |
|
877 |
TPtrC argv[KMaxArgs]; |
|
878 |
TInt argc = TTest::ParseCommandArguments(argv, KMaxArgs); |
|
879 |
if (argc > 1) |
|
880 |
drvch0 = User::UpperCase(argv[1][0]); |
|
881 |
if (argc > 2) |
|
882 |
drvch1 = User::UpperCase(argv[2][0]); |
|
883 |
if (argc > 3) |
|
884 |
drvch2 = User::UpperCase(argv[3][0]); |
|
885 |
||
886 |
r = TheFs.CharToDrive(drvch0, drive0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
887 |
test_KErrNone(r); |
0 | 888 |
|
889 |
if (TheFs.IsValidDrive(drive0)) |
|
890 |
MountTestFileSystem(drive0); |
|
891 |
else |
|
892 |
test.Printf(_L("Unable to mount test file system\n")); |
|
893 |
||
894 |
r = parseCmd(drvch1, drvch2); |
|
895 |
if (r != KErrNone) |
|
896 |
{ |
|
897 |
UnmountFileSystem(drive0); |
|
898 |
User::Panic(_L("USER ABORT"), 0); |
|
899 |
} |
|
900 |
||
901 |
r = TheFs.CharToDrive(drvch1, drive1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
902 |
test_KErrNone(r); |
0 | 903 |
r = TheFs.CharToDrive(drvch2, drive2); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
904 |
test_KErrNone(r); |
0 | 905 |
|
906 |
r = TheFs.FileSystemName(gFsName1, drive1); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
907 |
test_Value(r, r == KErrNone || r == KErrNotFound); |
0 | 908 |
r = TheFs.FileSystemName(gFsName2, drive2); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
909 |
test_Value(r, r == KErrNone || r == KErrNotFound); |
0 | 910 |
|
911 |
gDataLock.CreateLocal(); |
|
912 |
||
913 |
if (drive1 == drive2) |
|
914 |
{ |
|
915 |
// !!! Disable platform security tests until we get the new APIs |
|
916 |
// if (User::Capability() & KCapabilityRoot) |
|
917 |
// CheckMountLFFS(TheFs, drvch1); |
|
918 |
||
919 |
test.Printf(_L("Using drive %c: (%S)\n"), |
|
920 |
(TUint)drvch1, &gFsName1); |
|
921 |
if (r == KErrNone) |
|
922 |
{ |
|
923 |
test.Next(_L("Test with drive asynchronous")); |
|
924 |
RemountFileSystem(drive1, EFalse); |
|
925 |
testAsyncAccess(drvch1, drvch1); |
|
926 |
} |
|
927 |
||
928 |
if (r == KErrNone) |
|
929 |
{ |
|
930 |
test.Next(_L("Test with drive synchronous")); |
|
931 |
RemountFileSystem(drive1, ETrue); |
|
932 |
testAsyncAccess(drvch1, drvch1); |
|
933 |
} |
|
934 |
} |
|
935 |
else |
|
936 |
{ |
|
937 |
// !!! Disable platform security tests until we get the new APIs |
|
938 |
/* if (User::Capability() & KCapabilityRoot) |
|
939 |
{ |
|
940 |
CheckMountLFFS(TheFs, drvch1); |
|
941 |
CheckMountLFFS(TheFs, drvch2); |
|
942 |
} |
|
943 |
*/ |
|
944 |
test.Printf(_L("Using drives %c: (%S) and %c: (%S)\n"), |
|
945 |
(TUint)drvch1, &gFsName1, (TUint)drvch2, &gFsName2); |
|
946 |
||
947 |
#if !defined(TEST_ASYNC_IN_THREAD) |
|
948 |
||
949 |
if (r == KErrNone) |
|
950 |
{ |
|
951 |
test.Next(_L("Test async r/w with both drives async")); |
|
952 |
RemountFileSystem(drive1, EFalse); |
|
953 |
RemountFileSystem(drive2, EFalse); |
|
954 |
testAsyncAccess(drvch1, drvch2); |
|
955 |
} |
|
956 |
||
957 |
if (r == KErrNone) |
|
958 |
{ |
|
959 |
test.Next(_L("Test async r/w with 1st drive sync and 2nd async")); |
|
960 |
RemountFileSystem(drive1, ETrue); |
|
961 |
RemountFileSystem(drive2, EFalse); |
|
962 |
testAsyncAccess(drvch1, drvch2); |
|
963 |
} |
|
964 |
||
965 |
if (r == KErrNone) |
|
966 |
{ |
|
967 |
test.Next(_L("Test async r/w with 1st drive async and 2nd sync")); |
|
968 |
RemountFileSystem(drive1, EFalse); |
|
969 |
RemountFileSystem(drive2, ETrue); |
|
970 |
testAsyncAccess(drvch1, drvch2); |
|
971 |
} |
|
972 |
||
973 |
if (r == KErrNone) |
|
974 |
{ |
|
975 |
test.Next(_L("Test async r/w with both drives sync")); |
|
976 |
RemountFileSystem(drive1, ETrue); |
|
977 |
RemountFileSystem(drive2, ETrue); |
|
978 |
testAsyncAccess(drvch1, drvch2); |
|
979 |
} |
|
980 |
||
981 |
#else |
|
982 |
||
983 |
if (r == KErrNone) |
|
984 |
{ |
|
985 |
test.Next(_L("Test async r/w with both drives asynchronous")); |
|
986 |
RemountFileSystem(drive1, EFalse); |
|
987 |
RemountFileSystem(drive2, EFalse); |
|
988 |
r = testThreads(testAsyncAccess, drvch1, drvch2); |
|
989 |
} |
|
990 |
||
991 |
if (r == KErrNone) |
|
992 |
{ |
|
993 |
test.Next(_L("Test async r/w with one drive sync and one async")); |
|
994 |
RemountFileSystem(drive1, ETrue); |
|
995 |
RemountFileSystem(drive2, EFalse); |
|
996 |
r = testThreads(testAsyncAccess, drvch1, drvch2); |
|
997 |
} |
|
998 |
||
999 |
if (r == KErrNone) |
|
1000 |
{ |
|
1001 |
test.Next(_L("Test async r/w with both drives synchronous")); |
|
1002 |
RemountFileSystem(drive1, ETrue); |
|
1003 |
RemountFileSystem(drive2, ETrue); |
|
1004 |
r = testThreads(testAsyncAccess, drvch1, drvch2); |
|
1005 |
} |
|
1006 |
#endif |
|
1007 |
||
1008 |
#if defined(TEST_SYNC_IN_THREAD) |
|
1009 |
||
1010 |
if (r == KErrNone) |
|
1011 |
{ |
|
1012 |
test.Next(_L("Test sync r/w with both drives asynchronous")); |
|
1013 |
RemountFileSystem(drive1, EFalse); |
|
1014 |
RemountFileSystem(drive2, EFalse); |
|
1015 |
r = testThreads(testSyncAccess, drvch1, drvch2); |
|
1016 |
} |
|
1017 |
||
1018 |
if (r == KErrNone) |
|
1019 |
{ |
|
1020 |
test.Next(_L("Test sync r/w with one drive sync and one async")); |
|
1021 |
RemountFileSystem(drive1, ETrue); |
|
1022 |
RemountFileSystem(drive2, EFalse); |
|
1023 |
r = testThreads(testSyncAccess, drvch1, drvch2); |
|
1024 |
} |
|
1025 |
||
1026 |
if (r == KErrNone) |
|
1027 |
{ |
|
1028 |
test.Next(_L("Test sync r/w with both drives synchronous")); |
|
1029 |
RemountFileSystem(drive1, ETrue); |
|
1030 |
RemountFileSystem(drive2, ETrue); |
|
1031 |
r = testThreads(testSyncAccess, drvch1, drvch2); |
|
1032 |
} |
|
1033 |
#endif |
|
1034 |
} |
|
1035 |
||
1036 |
gDataLock.Close(); |
|
1037 |
||
1038 |
UnmountFileSystem(drive0); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1039 |
test_Value(r, r == 0); |
0 | 1040 |
} |
1041 |
||
1042 |
||
1043 |
GLDEF_C TInt E32Main() |
|
1044 |
// |
|
1045 |
// Main entry point |
|
1046 |
// |
|
1047 |
{ |
|
1048 |
TInt r; |
|
1049 |
||
1050 |
CTrapCleanup* cleanup; |
|
1051 |
cleanup=CTrapCleanup::New(); |
|
1052 |
__UHEAP_MARK; |
|
1053 |
||
1054 |
test.Title(); |
|
1055 |
test.Start(_L("Starting tests...")); |
|
1056 |
||
1057 |
r=TheFs.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1058 |
test_KErrNone(r); |
0 | 1059 |
|
1060 |
// TheFs.SetAllocFailure(gAllocFailOn); |
|
1061 |
TTime timerC; |
|
1062 |
timerC.HomeTime(); |
|
1063 |
||
1064 |
// Do the tests |
|
1065 |
TRAP(r,CallTestsL()); |
|
1066 |
||
1067 |
// reset the debug register |
|
1068 |
TheFs.SetDebugRegister(0); |
|
1069 |
||
1070 |
TTime endTimeC; |
|
1071 |
endTimeC.HomeTime(); |
|
1072 |
TTimeIntervalSeconds timeTakenC; |
|
1073 |
r=endTimeC.SecondsFrom(timerC,timeTakenC); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1074 |
test_KErrNone(r); |
0 | 1075 |
test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int()); |
1076 |
// TheFs.SetAllocFailure(gAllocFailOff); |
|
1077 |
TheFs.Close(); |
|
1078 |
test.End(); |
|
1079 |
test.Close(); |
|
1080 |
__UHEAP_MARKEND; |
|
1081 |
delete cleanup; |
|
1082 |
return(KErrNone); |
|
1083 |
} |