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