author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 06 Jul 2010 15:50:07 +0300 | |
changeset 201 | 43365a9b78a3 |
parent 200 | 73ea206103e6 |
child 247 | d8d70de2bd36 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// f32test\server\t_fsched.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
/** |
|
19 |
@file |
|
20 |
@internalTechnology |
|
21 |
*/ |
|
22 |
||
23 |
#define __E32TEST_EXTENSION__ |
|
24 |
||
25 |
#include <f32file.h> |
|
26 |
#include <e32test.h> |
|
27 |
#include <e32svr.h> |
|
28 |
#include <f32dbg.h> |
|
29 |
#include "t_server.h" |
|
30 |
#include <e32twin.h> |
|
31 |
#include <e32cmn.h> |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
32 |
#include "f32_test_utils.h" |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
33 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
34 |
using namespace F32_Test_Utils; |
0 | 35 |
|
36 |
//---------------------------------------------------------------------------------------------- |
|
37 |
//! @SYMTestCaseID PBASE-T_FSCHED-0191 |
|
38 |
//! @SYMTestType CIT |
|
39 |
//! @SYMPREQ PREQ914 |
|
40 |
//! @SYMTestCaseDesc This test case is exercising the Fair Scheduling functionality added to |
|
41 |
//! the File Server. There are negative and positive tests. |
|
42 |
//! @SYMTestActions 0 setup the environment to execute the tests and benchmarks the time |
|
43 |
//! taken to write the two files that are going to be used during the test |
|
44 |
//! 1 TestReadingWhileWriting uses two threads (sync case) to write a big file/ |
|
45 |
//! read a small file simultaneously and verifies that the timing is correct. |
|
46 |
//! Same test in the async case. |
|
47 |
//! 2 TestWritingWhileWriting same test as before, but the two operations are |
|
48 |
//! writes. |
|
49 |
//! 3 TestTwoBigOnes does the same test as 1, but with two big files, ensuring |
|
50 |
//! that the first starting is the first finishing. |
|
51 |
//! 4 TestReadingWhileWritingSameFile reads a file while it is being written. |
|
52 |
//! 5 TestClientDies starts a file write and kills it, then checks the integrity |
|
53 |
//! of the volume. |
|
54 |
//! 6 Finally it performs the benchmark of writing the two files again, to see |
|
55 |
//! if it has been degraded during the execution |
|
56 |
//! |
|
57 |
//! @SYMTestExpectedResults finishes if the fair scheduling behaves as expected, panics otherwise |
|
58 |
//! @SYMTestPriority High |
|
59 |
//! @SYMTestStatus Implemented |
|
60 |
//---------------------------------------------------------------------------------------------- |
|
61 |
||
62 |
||
63 |
class RTestThreadSemaphore : public RSemaphore |
|
64 |
{ |
|
65 |
public: |
|
66 |
inline void Signal(TInt aError = KErrNone) {iError = aError; RSemaphore::Signal();}; |
|
67 |
public: |
|
68 |
TInt iError; |
|
69 |
}; |
|
70 |
||
71 |
// macro to be used in place of test(). Signals main thread if assertion fails |
|
72 |
#define TEST(x) \ |
|
73 |
if (!(x)) \ |
|
74 |
{ \ |
|
75 |
RThread t; \ |
|
76 |
if (t.Id() != gMainThreadId) \ |
|
77 |
client.Signal(KErrGeneral); \ |
|
78 |
test(x); \ |
|
79 |
} |
|
80 |
#define TESTERROR(x) \ |
|
81 |
if (x != KErrNone) \ |
|
82 |
{ \ |
|
83 |
RThread t; \ |
|
84 |
if (t.Id() != gMainThreadId) \ |
|
85 |
RDebug::Print(_L("error %d\n"), x); \ |
|
86 |
else \ |
|
87 |
test.Printf(_L("error %d\n"), x); \ |
|
88 |
TEST(x==KErrNone); \ |
|
89 |
} |
|
90 |
||
91 |
#define CLIENTWAIT() {client.Wait(); test(client.iError == KErrNone);} |
|
92 |
||
93 |
//////////////////////////////////////////////////////////// |
|
94 |
// Template functions encapsulating ControlIo magic |
|
95 |
// |
|
96 |
GLDEF_D template <class C> |
|
97 |
GLDEF_C TInt controlIo(RFs &fs, TInt drv, TInt fkn, C &c) |
|
98 |
{ |
|
99 |
TPtr8 ptrC((TUint8 *)&c, sizeof(C), sizeof(C)); |
|
100 |
||
101 |
TInt r = fs.ControlIo(drv, fkn, ptrC); |
|
102 |
||
103 |
return r; |
|
104 |
} |
|
105 |
||
106 |
||
107 |
GLDEF_D RTest test(_L("T_FSCHED")); |
|
108 |
||
109 |
GLDEF_D RFs TheFs; |
|
110 |
GLDEF_D TInt gDrive; |
|
111 |
GLDEF_D TFileName gSessionPath; |
|
112 |
GLDEF_D TChar gDriveToTest; |
|
113 |
TThreadId gMainThreadId; |
|
114 |
||
115 |
HBufC8* gBuf = NULL; |
|
116 |
TPtr8 gBufReadPtr(NULL, 0); |
|
117 |
HBufC8* gBufSec = NULL; |
|
118 |
TPtr8 gBufWritePtr(NULL, 0); |
|
119 |
||
120 |
const TInt KuStomS = 1000; |
|
121 |
const TInt KOneK = 1024; |
|
122 |
const TInt KOneMeg = KOneK * 1024; |
|
123 |
const TInt KBigBlockSize = KOneMeg ; |
|
124 |
const TInt KBlockSize = KOneK * 129 ; |
|
125 |
const TInt KWaitRequestsTableSize = 70; |
|
126 |
||
127 |
TInt gBigFileSize = 0; |
|
128 |
TInt gSmallFileSize = 0; |
|
129 |
TInt64 gMediaSize = 0; |
|
130 |
TInt gTotalTimeSync[2]; |
|
131 |
TInt gTotalTimeAsync[2]; |
|
132 |
||
133 |
TTimeIntervalMicroSeconds32 gTimeTakenBigFile(0); |
|
134 |
TTimeIntervalMicroSeconds32 gTimeTakenBigBlock(0); |
|
135 |
TBuf16<45> gSmallFile, gBigFile; |
|
136 |
TInt gNextFile=0; |
|
137 |
TTime gTime1; |
|
138 |
TTime gTime2; |
|
139 |
||
140 |
RSemaphore gSync; |
|
141 |
||
142 |
// Concurrent Threads |
|
143 |
RThread gBig; |
|
144 |
RThread gSmall; |
|
145 |
RTestThreadSemaphore client; |
|
146 |
const TInt KHeapSize = 0x4000; |
|
147 |
const TInt KMaxHeapSize = 0x200000; |
|
148 |
TRequestStatus gStatus[KWaitRequestsTableSize]; |
|
149 |
||
150 |
enum TTestState |
|
151 |
{ |
|
152 |
EThreadWait, |
|
153 |
EThreadSignal, |
|
154 |
ENoThreads |
|
155 |
}; |
|
156 |
||
157 |
/** Generates a file name of the form FFFFF*<aPos>.TXT (aLong.3) |
|
158 |
||
159 |
@param aBuffer The filename will be returned here |
|
160 |
@param aLong Defines the longitude of the file name |
|
161 |
@param aPos Defines the number that will be attached to the filename |
|
162 |
*/ |
|
163 |
void FileNameGen(TDes16& aBuffer, TInt aLong, TInt aPos) |
|
164 |
{ |
|
165 |
TInt padding; |
|
166 |
TInt i=0; |
|
167 |
TBuf16<10> tempbuf; |
|
168 |
||
169 |
_LIT(KNumber,"%d"); |
|
170 |
tempbuf.Format(KNumber,aPos); |
|
171 |
padding=aLong-tempbuf.Size()/2; |
|
172 |
aBuffer=_L(""); |
|
173 |
while(i<padding) |
|
174 |
{ |
|
175 |
aBuffer.Append('F'); |
|
176 |
i++; |
|
177 |
} |
|
178 |
aBuffer.Append(tempbuf); |
|
179 |
||
180 |
_LIT(KExtension1, ".TXT"); |
|
181 |
aBuffer.Append(KExtension1); |
|
182 |
} |
|
183 |
||
184 |
||
185 |
/** Reads the parameters from the comand line |
|
186 |
and updates the appropriate variables |
|
187 |
*/ |
|
188 |
void parseCommandLine() |
|
189 |
{ |
|
190 |
TBuf<0x100> cmd; |
|
191 |
User::CommandLine(cmd); |
|
192 |
TLex lex(cmd); |
|
193 |
TPtrC token=lex.NextToken(); |
|
194 |
TInt r=0; |
|
195 |
||
196 |
if(token.Length()!=0) |
|
197 |
{ |
|
198 |
gDriveToTest = token[0]; |
|
199 |
gDriveToTest.UpperCase(); |
|
200 |
} |
|
201 |
else |
|
202 |
{ |
|
203 |
gDriveToTest='C'; |
|
204 |
} |
|
205 |
||
206 |
r = TheFs.CharToDrive(gDriveToTest,gDrive); |
|
207 |
TESTERROR(r); |
|
208 |
gSessionPath = _L("?:\\F32-TST\\"); |
|
209 |
gSessionPath[0] = (TText)(gDrive+'A'); |
|
210 |
test.Printf(_L("\nCLP=%C\n"), (TInt)gDriveToTest); |
|
211 |
} |
|
212 |
||
213 |
/** Verifies the content of a buffer (all the letters are like the first one) |
|
214 |
||
215 |
@param aBuffer Buffer to be verified |
|
216 |
||
217 |
@return KErrNone if all the letters are the same, KErrCorrupt otherwise |
|
218 |
*/ |
|
219 |
TInt VerifyBuffer(TDes8& aBuffer, TChar aExpectedChar) |
|
220 |
{ |
|
221 |
TChar c = aExpectedChar; |
|
222 |
||
223 |
for(TInt i = 1; i<aBuffer.Length(); i++) |
|
224 |
{ |
|
225 |
if(c != (TChar)(aBuffer[i])) |
|
226 |
{ |
|
227 |
RDebug::Print(_L("VerifyBuffer() failed at +%d, %02X != %02X"), i, (TInt) c, aBuffer[i] ); |
|
228 |
return KErrCorrupt; |
|
229 |
} |
|
230 |
} |
|
231 |
||
232 |
return KErrNone; |
|
233 |
} |
|
234 |
||
235 |
/** Fills a buffer with character aC |
|
236 |
||
237 |
@param aBuffer Buffer to be filled, output |
|
238 |
@param aLength Length to be filled |
|
239 |
@param aC Character to be used to fill the buffer |
|
240 |
*/ |
|
241 |
void FillBuffer(TDes8& aBuffer, TInt aLength, TChar aC) |
|
242 |
{ |
|
243 |
test (aBuffer.MaxLength() >= aLength); |
|
244 |
for(TInt i=0; i<aLength; i++) |
|
245 |
{ |
|
246 |
aBuffer.Append(aC); |
|
247 |
} |
|
248 |
} |
|
249 |
||
250 |
/** Waits for all the TRequestStatus in status[] to complete |
|
251 |
||
252 |
@param status Array of TRequestStatus |
|
253 |
@param aLength Length to be filled |
|
254 |
@param aC Character to be used to fill the buffer |
|
255 |
*/ |
|
256 |
void WaitForAll(TRequestStatus* status, TInt aFileSize, TInt aBlockSize) |
|
257 |
{ |
|
258 |
TInt i = 0; |
|
259 |
TInt size = 0; |
|
260 |
||
261 |
if((aFileSize % aBlockSize) == 0 ) |
|
262 |
size = aFileSize/aBlockSize; |
|
263 |
else |
|
264 |
size = (aFileSize/aBlockSize) + 1; |
|
265 |
||
266 |
while(i < size) |
|
267 |
{ |
|
268 |
User::WaitForRequest(status[i++]); |
|
269 |
} |
|
270 |
} |
|
271 |
||
272 |
/** Writes a file synchronously in blocks of aBlockSize size |
|
273 |
||
274 |
@param fs RFs object |
|
275 |
@param aFile File name |
|
276 |
@param aSize Size of the file in bytes |
|
277 |
@param aBlockSize Size of the blocks to be used in bytes |
|
278 |
@param aState Determines if the operation is being done in the main process |
|
279 |
or in a thread |
|
280 |
||
281 |
@return Returns KErrNone if everything ok, otherwise it panics |
|
282 |
*/ |
|
283 |
TInt WriteFile(RFs& fs, TDes16& aFile, TInt aSize, TInt aBlockSize, TTestState aState) |
|
284 |
{ |
|
285 |
TInt r = 0; |
|
286 |
RFile fileWrite; |
|
287 |
||
288 |
TEST(aBlockSize>0); |
|
289 |
||
290 |
r = fileWrite.Replace(fs,aFile,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
|
291 |
TESTERROR(r); |
|
292 |
||
293 |
if(aState==EThreadWait) |
|
294 |
{ |
|
295 |
gSync.Wait(); |
|
296 |
User::After(gTimeTakenBigBlock); |
|
297 |
} |
|
298 |
||
299 |
TInt j = 0; |
|
300 |
while(j < aSize) |
|
301 |
{ |
|
302 |
if((j == 0) && (aState == EThreadSignal)) |
|
303 |
{ |
|
304 |
gSync.Signal(); |
|
305 |
} |
|
306 |
||
307 |
if((aSize - j) >= aBlockSize) // All the blocks but the last one |
|
308 |
r = fileWrite.Write(gBufWritePtr, aBlockSize); |
|
309 |
else // The last block |
|
310 |
r = fileWrite.Write(gBufWritePtr, (aSize - j)); |
|
311 |
||
312 |
TESTERROR(r); |
|
313 |
j += aBlockSize; |
|
314 |
} |
|
315 |
||
316 |
fileWrite.Close(); |
|
317 |
||
318 |
return KErrNone; |
|
319 |
} |
|
320 |
||
321 |
/** Read File in blocks of size aBlockSize |
|
322 |
||
323 |
@param fs RFs object |
|
324 |
@param aFile File name |
|
325 |
@param aBlockSize Size of the blocks to be used in bytes |
|
326 |
@param aState Determines if the operation is being done in the main process |
|
327 |
or in a thread |
|
328 |
||
329 |
@return Returns KErrNone if everything ok, otherwise it panics |
|
330 |
*/ |
|
331 |
TInt ReadFile(RFs& fs, TDes16& aFile, TInt aBlockSize, TTestState aState) |
|
332 |
{ |
|
333 |
RTest test(_L("T_FSCHED")); |
|
334 |
TInt r = 0, size = 0; |
|
335 |
RFile fileRead; |
|
336 |
||
337 |
TEST(aBlockSize > 0); |
|
338 |
||
339 |
r = fileRead.Open(fs, aFile, EFileShareAny|EFileRead|EFileReadDirectIO); |
|
340 |
TESTERROR(r); |
|
341 |
||
342 |
r = fileRead.Size(size); |
|
343 |
TESTERROR(r); |
|
344 |
||
345 |
if(aState == EThreadWait) |
|
346 |
{ |
|
347 |
gSync.Wait(); |
|
348 |
User::After(gTimeTakenBigBlock); |
|
349 |
} |
|
350 |
||
351 |
TInt j = 0; |
|
352 |
while(j < size) |
|
353 |
{ |
|
354 |
if((j == 0)&&(aState == EThreadSignal)) |
|
355 |
{ |
|
356 |
gSync.Signal(); |
|
357 |
} |
|
358 |
r = fileRead.Read(gBufReadPtr, aBlockSize); |
|
359 |
TESTERROR(r); |
|
360 |
r = VerifyBuffer(gBufReadPtr, 'B'); |
|
361 |
TESTERROR(r); |
|
362 |
||
363 |
j += aBlockSize; |
|
364 |
r = fileRead.Size(size); |
|
365 |
TESTERROR(r); |
|
366 |
} |
|
367 |
||
368 |
fileRead.Close(); |
|
369 |
||
370 |
return KErrNone; |
|
371 |
} |
|
372 |
||
373 |
||
374 |
/** Write a file asynchronously in blocks of aBlockSize size |
|
375 |
||
376 |
@param fs RFs object |
|
377 |
@param aFileWrite RFile object, needs to exist beyond the scope of this function |
|
378 |
@param aFile File name |
|
379 |
@param aSize Size of the file in bytes |
|
380 |
@param aBlockSize Size of the blocks to be used in bytes |
|
381 |
@param aStatus TRequestStatus array for all the requests |
|
382 |
*/ |
|
383 |
void WriteFileAsync(RFs& fs, RFile& aFileWrite, TDes16& aFile, TInt aSize, TInt aBlockSize, TRequestStatus aStatus[]) |
|
384 |
{ |
|
385 |
||
386 |
TInt r = 0; |
|
387 |
||
388 |
TEST(aBlockSize > 0); // Block size must be greater than 0 |
|
389 |
||
390 |
r = aFileWrite.Replace(fs,aFile,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
|
391 |
TESTERROR(r); |
|
392 |
||
393 |
TInt j = 0; |
|
394 |
TInt i = 0; |
|
395 |
while(j < aSize) |
|
396 |
{ |
|
397 |
if((aSize - j) >= aBlockSize) // All the blocks but the last one |
|
398 |
aFileWrite.Write(gBufWritePtr, aBlockSize, aStatus[i]); |
|
399 |
else // The last block |
|
400 |
aFileWrite.Write(gBufWritePtr, (aSize - j), aStatus[i]); |
|
401 |
||
402 |
TInt status = aStatus[i].Int(); |
|
403 |
if (status != KErrNone && status != KRequestPending) |
|
404 |
{ |
|
405 |
test.Printf(_L("RFile::Write() returned %d\n"), aStatus[i].Int()); |
|
406 |
} |
|
407 |
||
408 |
test (status == KErrNone || status == KRequestPending); |
|
409 |
i++; |
|
410 |
j += aBlockSize; |
|
411 |
} |
|
412 |
} |
|
413 |
||
414 |
/** Read a file asynchronously in blocks of aBlockSize size |
|
415 |
||
416 |
@param fs RFs object |
|
417 |
@param aFileRead RFile object, needs to exist beyond the scope of this function |
|
418 |
@param aFile File name |
|
419 |
@param aSize Size of the file in bytes |
|
420 |
@param aBlockSize Size of the blocks to be used in bytes |
|
421 |
@param aStatus TRequestStatus array for all the requests |
|
422 |
||
423 |
@return KErrNone |
|
424 |
*/ |
|
425 |
TInt ReadFileAsync(RFs& fs, RFile& aFileRead, TDes16& aFile, TInt aBlockSize, TRequestStatus aStatus[]) |
|
426 |
{ |
|
427 |
TInt r = 0, size = 0; |
|
428 |
||
429 |
TEST(aBlockSize > 0); // Block size must be greater than 0 |
|
430 |
||
431 |
||
432 |
r = aFileRead.Open(fs, aFile, EFileShareAny|EFileRead|EFileReadDirectIO); |
|
433 |
TESTERROR(r); |
|
434 |
||
435 |
r = aFileRead.Size(size); |
|
436 |
TESTERROR(r); |
|
437 |
||
438 |
TInt j = 0, i = 0; |
|
439 |
while(j < size) |
|
440 |
{ |
|
441 |
aFileRead.Read(gBufReadPtr, aBlockSize, aStatus[i]); |
|
442 |
test (aStatus[i].Int() == KErrNone || aStatus[i].Int() == KRequestPending); |
|
443 |
i++; |
|
444 |
TESTERROR(r); |
|
445 |
j += aBlockSize; |
|
446 |
} |
|
447 |
||
448 |
return KErrNone; |
|
449 |
} |
|
450 |
||
451 |
||
452 |
/** |
|
453 |
Write a pattern to 2 files simultaneously in blocks of aBlockSize size and verify that fair scheduling |
|
454 |
does not interfere with the write order by reading both files back and verifying the contents. |
|
455 |
||
456 |
aBlockSize should be slightly bigger that the fair scheduling size |
|
457 |
||
458 |
@param aFs RFs object |
|
459 |
@param aSize Size of the file in bytes |
|
460 |
@param aBlockSize Size of the blocks to be used in bytes, should be slightly bigger that the fair scheduling size |
|
461 |
*/ |
|
462 |
void WriteOrderTest(RFs& aFs, TInt aSize, TInt aBlockSize) |
|
463 |
{ |
|
464 |
TFileName fileName1, fileName2; |
|
465 |
FileNameGen(fileName1, 8, 99); |
|
466 |
FileNameGen(fileName2, 8, 100); |
|
467 |
||
468 |
RFile file1, file2; |
|
469 |
||
470 |
TRequestStatus status1[KWaitRequestsTableSize]; |
|
471 |
TRequestStatus status2[KWaitRequestsTableSize]; |
|
472 |
||
473 |
TInt r = 0; |
|
474 |
||
475 |
TEST(aBlockSize > 0); // Block size must be greater than 0 |
|
476 |
||
477 |
r = file1.Replace(aFs, fileName1,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
|
478 |
TESTERROR(r); |
|
479 |
||
480 |
r = file2.Replace(aFs, fileName2,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
|
481 |
TESTERROR(r); |
|
482 |
||
483 |
||
484 |
HBufC8* buf1 = NULL; |
|
485 |
TRAP(r,buf1 = HBufC8::NewL(KBigBlockSize)); |
|
486 |
TEST(r == KErrNone && buf1 != NULL); |
|
487 |
||
488 |
TInt maxBlockNum = KBigBlockSize / aBlockSize; |
|
489 |
TInt blockNum = 0; |
|
490 |
TInt blocksFree = maxBlockNum; |
|
491 |
||
492 |
TInt blockHead = 0; // ha ha |
|
493 |
TInt blockTail = 0; |
|
494 |
||
495 |
||
496 |
TPtrC8* writeBuffer = new TPtrC8[maxBlockNum]; |
|
497 |
for (TInt n=0; n<maxBlockNum; n++) |
|
498 |
{ |
|
499 |
TUint8* addr = (TUint8*) buf1->Des().Ptr() + (n * aBlockSize); |
|
500 |
writeBuffer[n].Set(addr, aBlockSize); |
|
501 |
} |
|
502 |
||
503 |
TInt j = 0; |
|
504 |
TInt i = 0; |
|
505 |
while(j < aSize) |
|
506 |
{ |
|
507 |
||
508 |
// fill the buffer with a char based on the block number |
|
509 |
TPtr8 bufWritePtr((TUint8*) writeBuffer[blockHead].Ptr(), 0, writeBuffer[blockHead].Length()); |
|
510 |
TUint8* addr = (TUint8*) buf1->Des().Ptr() + (blockHead * aBlockSize); |
|
511 |
bufWritePtr.Set(addr, 0, aBlockSize); |
|
512 |
FillBuffer(bufWritePtr, aBlockSize, 'A'+blockNum); |
|
513 |
||
514 |
//test.Printf(_L("j %d, addr %08X, aSize %d, blockNum %d, blockTail %d, blockHead %d, maxBlockNum %d, blocksFree %d\n"), |
|
515 |
// j, writeBuffer[blockHead].Ptr(), aSize, blockNum, blockTail, blockHead, maxBlockNum, blocksFree); |
|
516 |
||
517 |
if((aSize - j) >= aBlockSize) // All the blocks but the last one |
|
518 |
file1.Write(writeBuffer[blockHead], aBlockSize, status1[blockHead]); |
|
519 |
else // The last block |
|
520 |
file1.Write(writeBuffer[blockHead], (aSize - j), status1[blockHead]); |
|
521 |
||
522 |
if((aSize - j) >= aBlockSize) // All the blocks but the last one |
|
523 |
file2.Write(writeBuffer[blockHead], aBlockSize, status2[blockHead]); |
|
524 |
else // The last block |
|
525 |
file2.Write(writeBuffer[blockHead], (aSize - j), status2[blockHead]); |
|
526 |
||
527 |
TInt status = status1[blockHead].Int(); |
|
528 |
if (status != KErrNone && status != KRequestPending) |
|
529 |
test.Printf(_L("RFile::Write() returned %d\n"), status1[blockHead].Int()); |
|
530 |
test (status == KErrNone || status == KRequestPending); |
|
531 |
||
532 |
status = status2[blockHead].Int(); |
|
533 |
if (status != KErrNone && status != KRequestPending) |
|
534 |
test.Printf(_L("RFile::Write() returned %d\n"), status1[blockHead].Int()); |
|
535 |
test (status == KErrNone || status == KRequestPending); |
|
536 |
||
537 |
i++; |
|
538 |
j += aBlockSize; |
|
539 |
blockNum++; |
|
540 |
blockHead = (blockHead + 1) % maxBlockNum; |
|
541 |
blocksFree--; |
|
542 |
||
543 |
if (blocksFree == 0) |
|
544 |
{ |
|
545 |
//test.Printf(_L("Waiting for block %d\n"), blockTail); |
|
546 |
User::WaitForRequest(status1[blockTail]); |
|
547 |
User::WaitForRequest(status2[blockTail]); |
|
548 |
blockTail = (blockTail + 1) % maxBlockNum; |
|
549 |
blocksFree++; |
|
550 |
} |
|
551 |
||
552 |
} |
|
553 |
||
554 |
while (blockTail != blockHead) |
|
555 |
{ |
|
556 |
//test.Printf(_L("Waiting for block %d\n"), blockTail); |
|
557 |
User::WaitForRequest(status1[blockTail]); |
|
558 |
User::WaitForRequest(status2[blockTail]); |
|
559 |
blockTail = (blockTail + 1) % maxBlockNum; |
|
560 |
blocksFree++; |
|
561 |
} |
|
562 |
||
563 |
file1.Close(); |
|
564 |
file2.Close(); |
|
565 |
||
566 |
// Verify file1 |
|
567 |
r = file1.Open(aFs, fileName1, EFileShareAny|EFileRead|EFileReadDirectIO); |
|
568 |
TESTERROR(r); |
|
569 |
TInt size; |
|
570 |
r = file1.Size(size); |
|
571 |
TESTERROR(r); |
|
572 |
blockNum = 0; |
|
573 |
j = 0; |
|
574 |
while(j < size) |
|
575 |
{ |
|
576 |
TPtr8 readPtr((TUint8*) writeBuffer[0].Ptr(), aBlockSize, aBlockSize); |
|
577 |
r = file1.Read(readPtr); |
|
578 |
TESTERROR(r); |
|
579 |
r = VerifyBuffer(readPtr, 'A' + blockNum); |
|
580 |
TESTERROR(r); |
|
581 |
j += aBlockSize; |
|
582 |
blockNum++; |
|
583 |
} |
|
584 |
||
585 |
// Verify file2 |
|
586 |
r = file2.Open(aFs, fileName2, EFileShareAny|EFileRead|EFileReadDirectIO); |
|
587 |
TESTERROR(r); |
|
588 |
r = file2.Size(size); |
|
589 |
TESTERROR(r); |
|
590 |
blockNum = 0; |
|
591 |
j = 0; |
|
592 |
while(j < size) |
|
593 |
{ |
|
594 |
TPtr8 readPtr((TUint8*) writeBuffer[0].Ptr(), aBlockSize, aBlockSize); |
|
595 |
r = file2.Read(readPtr); |
|
596 |
TESTERROR(r); |
|
597 |
r = VerifyBuffer(readPtr, 'A' + blockNum); |
|
598 |
TESTERROR(r); |
|
599 |
j += aBlockSize; |
|
600 |
blockNum++; |
|
601 |
} |
|
602 |
||
603 |
file2.Close(); |
|
604 |
file1.Close(); |
|
605 |
||
606 |
delete [] writeBuffer; |
|
607 |
delete buf1; |
|
608 |
||
609 |
r = aFs.Delete(fileName1); |
|
610 |
TEST(r == KErrNone); |
|
611 |
r = aFs.Delete(fileName2); |
|
612 |
TEST(r == KErrNone); |
|
613 |
} |
|
614 |
||
615 |
||
616 |
||
617 |
/** Measure the time taken for a big block to be written synchronously |
|
618 |
*/ |
|
619 |
void TimeTakenToWriteBigBlock() |
|
620 |
{ |
|
621 |
TTime startTime; |
|
622 |
TTime endTime; |
|
623 |
RFile fileWrite; |
|
624 |
||
625 |
TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO); |
|
626 |
TESTERROR(r); |
|
627 |
||
628 |
// Calculate how long it takes to write a big block to be able to issue at the right time the concurrent writes |
|
629 |
startTime.HomeTime(); |
|
630 |
||
631 |
r = fileWrite.Write(gBufWritePtr, KBigBlockSize); |
|
632 |
||
633 |
endTime.HomeTime(); |
|
634 |
||
635 |
fileWrite.Close(); |
|
636 |
||
637 |
TESTERROR(r); |
|
638 |
||
639 |
gTimeTakenBigBlock = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()/3); |
|
640 |
||
641 |
test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), gTimeTakenBigBlock.Int() / KuStomS); |
|
642 |
} |
|
643 |
||
644 |
||
645 |
/** Measure the time taken for this file to be written synchronously |
|
646 |
*/ |
|
647 |
void TimeTakenToWriteBigFile(TInt aPos) |
|
648 |
{ |
|
649 |
TTime startTime; |
|
650 |
TTime endTime; |
|
651 |
||
652 |
test((aPos >= 0) && (aPos <= 1)); |
|
653 |
startTime.HomeTime(); |
|
654 |
||
655 |
WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads); |
|
656 |
||
657 |
endTime.HomeTime(); |
|
658 |
||
659 |
gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
|
660 |
||
661 |
||
662 |
test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), gTimeTakenBigFile.Int() / KuStomS); |
|
663 |
||
664 |
gTotalTimeSync[aPos] = Max((gTimeTakenBigFile.Int()/KuStomS), gTotalTimeSync[aPos]) ; |
|
665 |
} |
|
666 |
||
667 |
/** Measure the time taken for this file to be written asynchronously |
|
668 |
*/ |
|
669 |
void TimeTakenToWriteBigFileAsync(TInt aPos) |
|
670 |
{ |
|
671 |
TTime startTime; |
|
672 |
TTime endTime; |
|
673 |
TTime endTime2; |
|
674 |
TRequestStatus status[KWaitRequestsTableSize]; |
|
675 |
RFile bigFile; |
|
676 |
||
677 |
test((aPos >= 0) && (aPos <= 1)); |
|
678 |
||
679 |
startTime.HomeTime(); |
|
680 |
WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); |
|
681 |
endTime.HomeTime(); |
|
682 |
||
683 |
||
684 |
WaitForAll(status, gBigFileSize, KBigBlockSize); |
|
685 |
||
686 |
endTime2.HomeTime(); |
|
687 |
||
688 |
gTimeTakenBigFile=I64LOW(endTime.MicroSecondsFrom(startTime).Int64()); |
|
689 |
bigFile.Close(); |
|
690 |
test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), gTimeTakenBigFile.Int() / KuStomS); |
|
691 |
gTimeTakenBigFile=I64LOW(endTime2.MicroSecondsFrom(startTime).Int64()); |
|
692 |
test.Printf(_L("to actually write it: %d ms\n"),gTimeTakenBigFile.Int() / KuStomS); |
|
693 |
gTotalTimeAsync[aPos] = Max((gTimeTakenBigFile.Int() / KuStomS), gTotalTimeAsync[aPos]) ; |
|
694 |
} |
|
695 |
||
696 |
/** Delete content of directory |
|
697 |
||
698 |
@param aDir Target directory |
|
699 |
||
700 |
@return Error returned if any, otherwise KErrNone |
|
701 |
*/ |
|
702 |
TInt DeleteAll(TDes16& aDir) |
|
703 |
{ |
|
704 |
TBuf16<100> dir; |
|
705 |
CFileMan* fMan=CFileMan::NewL(TheFs); |
|
706 |
TInt r=0; |
|
707 |
||
708 |
dir = aDir; |
|
709 |
dir.Append(_L("F*.*")); |
|
710 |
r = fMan->Delete(dir); |
|
711 |
||
712 |
delete fMan; |
|
713 |
return r; |
|
714 |
} |
|
715 |
||
716 |
/** Read a small file sync, in a different thread |
|
717 |
||
718 |
@return ETrue |
|
719 |
*/ |
|
720 |
TInt ReadSmallFile(TAny* ) |
|
721 |
{ |
|
722 |
RTest test(_L("T_FSCHED")); |
|
723 |
RFs fs; |
|
724 |
TInt r=fs.Connect(); |
|
725 |
TESTERROR(r); |
|
726 |
||
727 |
r = fs.SetSessionPath(gSessionPath); |
|
728 |
TESTERROR(r); |
|
729 |
||
730 |
ReadFile(fs,gSmallFile,KBlockSize, EThreadWait); |
|
731 |
gTime2.HomeTime(); |
|
732 |
||
733 |
client.Signal(); |
|
734 |
||
735 |
fs.Close(); |
|
736 |
test.Close(); |
|
737 |
||
738 |
return ETrue; |
|
739 |
} |
|
740 |
||
741 |
/** Read the big file sync, in a different thread |
|
742 |
||
743 |
@return ETrue |
|
744 |
*/ |
|
745 |
TInt ReadBigFile(TAny* ) |
|
746 |
{ |
|
747 |
RTest test(_L("T_FSCHED")); |
|
748 |
RFs fs; |
|
749 |
TInt r=fs.Connect(); |
|
750 |
TESTERROR(r); |
|
751 |
||
752 |
r=fs.SetSessionPath(gSessionPath); |
|
753 |
TESTERROR(r); |
|
754 |
||
755 |
ReadFile(fs,gBigFile,KBlockSize, EThreadWait); |
|
756 |
gTime2.HomeTime(); |
|
757 |
||
758 |
client.Signal(); |
|
759 |
||
760 |
fs.Close(); |
|
761 |
test.Close(); |
|
762 |
||
763 |
return ETrue; |
|
764 |
} |
|
765 |
||
766 |
/** Write a small file sync, in a different thread |
|
767 |
||
768 |
@return ETrue |
|
769 |
*/ |
|
770 |
TInt WriteSmallFile(TAny* ) |
|
771 |
{ |
|
772 |
RTest test(_L("T_FSCHED")); |
|
773 |
RFs fs; |
|
774 |
TInt r=fs.Connect(); |
|
775 |
TESTERROR(r); |
|
776 |
||
777 |
r=fs.SetSessionPath(gSessionPath); |
|
778 |
TESTERROR(r); |
|
779 |
||
780 |
WriteFile(fs,gSmallFile,gSmallFileSize, KBlockSize, EThreadWait); |
|
781 |
gTime2.HomeTime(); |
|
782 |
||
783 |
client.Signal(); |
|
784 |
||
785 |
fs.Close(); |
|
786 |
test.Close(); |
|
787 |
||
788 |
return ETrue; |
|
789 |
} |
|
790 |
||
791 |
/** Write a big file sync, in a different thread |
|
792 |
||
793 |
@return ETrue |
|
794 |
*/ |
|
795 |
TInt WriteBigFile(TAny* ) |
|
796 |
{ |
|
797 |
RTest test(_L("T_FSCHED")); |
|
798 |
RFs fs; |
|
799 |
TInt r=fs.Connect(); |
|
800 |
TESTERROR(r); |
|
801 |
||
802 |
r=fs.SetSessionPath(gSessionPath); |
|
803 |
TESTERROR(r); |
|
804 |
||
805 |
WriteFile(fs, gBigFile, gBigFileSize, KBigBlockSize, EThreadSignal); |
|
806 |
gTime1.HomeTime(); |
|
807 |
||
808 |
client.Signal(); |
|
809 |
||
810 |
fs.Close(); |
|
811 |
test.Close(); |
|
812 |
||
813 |
return ETrue; |
|
814 |
} |
|
815 |
||
816 |
/** Write big file after a signalling thread has been scheduled, in a different thread |
|
817 |
||
818 |
@return ETrue |
|
819 |
*/ |
|
820 |
TInt WriteBigFile2(TAny* ) |
|
821 |
{ |
|
822 |
RTest test(_L("T_FSCHED")); |
|
823 |
RFs fs; |
|
824 |
TInt r=fs.Connect(); |
|
825 |
TESTERROR(r); |
|
826 |
||
827 |
r = fs.SetSessionPath(gSessionPath); |
|
828 |
TESTERROR(r); |
|
829 |
||
830 |
WriteFile(fs, gSmallFile, gBigFileSize, KBigBlockSize, EThreadWait); |
|
831 |
gTime2.HomeTime(); |
|
832 |
||
833 |
client.Signal(); |
|
834 |
||
835 |
fs.Close(); |
|
836 |
test.Close(); |
|
837 |
||
838 |
return ETrue; |
|
839 |
} |
|
840 |
||
841 |
/** Write a big file async, in a different thread |
|
842 |
||
843 |
@return ETrue |
|
844 |
*/ |
|
845 |
TInt WriteBigFileAsync(TAny* ) |
|
846 |
{ |
|
847 |
RTest test(_L("T_FSCHED")); |
|
848 |
RFs fs; |
|
849 |
TInt r = fs.Connect(); |
|
850 |
TESTERROR(r); |
|
851 |
||
852 |
r=fs.SetSessionPath(gSessionPath); |
|
853 |
TESTERROR(r); |
|
854 |
||
855 |
||
856 |
RFile bigFile; |
|
857 |
||
858 |
WriteFileAsync(fs, bigFile, gSmallFile, gBigFileSize, KBlockSize,gStatus); |
|
859 |
gSync.Signal(); |
|
860 |
WaitForAll(gStatus, gBigFileSize, KBlockSize); |
|
861 |
||
862 |
fs.Close(); |
|
863 |
test.Close(); |
|
864 |
||
865 |
return ETrue; |
|
866 |
} |
|
867 |
||
868 |
/** Delete a big file, in a different thread |
|
869 |
||
870 |
@return ETrue |
|
871 |
*/ |
|
872 |
TInt DeleteBigFile(TAny* ) |
|
873 |
{ |
|
874 |
RTest test(_L("T_FSCHED")); |
|
875 |
RFs fs; |
|
876 |
TInt r = fs.Connect(); |
|
877 |
TESTERROR(r); |
|
878 |
||
879 |
r = fs.SetSessionPath(gSessionPath); |
|
880 |
TESTERROR(r); |
|
881 |
||
882 |
gSync.Wait(); |
|
883 |
||
884 |
r = fs.Delete(gBigFile); |
|
885 |
#if defined(__WINS__) |
|
886 |
TEST(r == KErrInUse || r == KErrNone); |
|
887 |
#else |
|
888 |
test_Equal(KErrInUse, r); |
|
889 |
#endif |
|
890 |
||
891 |
client.Signal(); |
|
892 |
||
893 |
fs.Close(); |
|
894 |
test.Close(); |
|
895 |
||
896 |
return ETrue; |
|
897 |
} |
|
898 |
||
899 |
/** Reads a small file while writing a big one |
|
900 |
||
901 |
*/ |
|
902 |
void TestReadingWhileWriting() |
|
903 |
{ |
|
904 |
TInt r = 0; |
|
905 |
TTime time1; |
|
906 |
TTime time2; |
|
907 |
||
908 |
time1.HomeTime(); |
|
909 |
||
910 |
// Write the small file and take the appropriate measures |
|
911 |
WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads); |
|
912 |
||
913 |
// Sync test |
|
914 |
TBuf<20> buf=_L("Big Write"); |
|
915 |
r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
916 |
TEST(r == KErrNone); |
|
917 |
||
918 |
buf = _L("Small Read"); |
|
919 |
r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
920 |
TEST(r == KErrNone); |
|
921 |
||
922 |
gBig.Resume(); |
|
923 |
gSmall.Resume(); |
|
924 |
||
925 |
CLIENTWAIT(); |
|
926 |
CLIENTWAIT(); |
|
927 |
||
928 |
gBig.Close(); |
|
929 |
gSmall.Close(); |
|
930 |
||
931 |
||
932 |
TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2); |
|
933 |
test.Printf(_L("\nSync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
934 |
TReal time=I64LOW(timeTaken.Int64() / KuStomS); |
|
935 |
#if !defined(__WINS__) |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
936 |
// If this condition fails, it means that writing the sync file while fairscheduling a small sync read takes too long |
0 | 937 |
test.Printf(_L("time: %f\n"), time); |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
938 |
// test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); |
0 | 939 |
test(time > 0); |
940 |
#endif |
|
941 |
||
942 |
// Async test |
|
943 |
TRequestStatus status[KWaitRequestsTableSize]; |
|
944 |
TRequestStatus status2[2]; |
|
945 |
RFile bigFile, smallFile; |
|
946 |
||
947 |
WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize ,status); |
|
948 |
ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 ); |
|
949 |
||
950 |
WaitForAll(status2,KBlockSize , KBlockSize ); |
|
951 |
time1.HomeTime(); |
|
952 |
||
953 |
WaitForAll(status,gBigFileSize, KBigBlockSize); |
|
954 |
||
955 |
time2.HomeTime(); |
|
956 |
bigFile.Close(); |
|
957 |
smallFile.Close(); |
|
958 |
||
959 |
timeTaken = time2.MicroSecondsFrom(time1); |
|
960 |
||
961 |
test.Printf(_L("\nAsync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
962 |
time = I64LOW(timeTaken.Int64() / KuStomS); |
|
963 |
||
964 |
#if !defined(__WINS__) |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
965 |
if (!Is_HVFS(TheFs, gDrive)) |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
966 |
{ |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
967 |
// If this condition fails, it means that writing the async file while fairscheduling a small async read takes too long |
0 | 968 |
test.Printf(_L("time: %f\n"), time); |
969 |
test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
970 |
// test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) ); |
0 | 971 |
test(time > 0); |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
972 |
} |
0 | 973 |
#endif |
974 |
} |
|
975 |
||
976 |
/** Writes a small file while writing a big one |
|
977 |
||
978 |
*/ |
|
979 |
void TestWritingWhileWriting() |
|
980 |
{ |
|
981 |
TInt r = 0; |
|
982 |
TTime time1; |
|
983 |
TTime time2; |
|
984 |
||
985 |
// Sync test |
|
986 |
TBuf<20> buf = _L("Big Write II"); |
|
987 |
r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
988 |
TEST(r == KErrNone); |
|
989 |
||
990 |
buf = _L("Small Write II"); |
|
991 |
r = gSmall.Create(buf, WriteSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
992 |
TEST(r==KErrNone); |
|
993 |
||
994 |
gBig.Resume(); |
|
995 |
gSmall.Resume(); |
|
996 |
||
997 |
CLIENTWAIT(); |
|
998 |
CLIENTWAIT(); |
|
999 |
||
1000 |
gBig.Close(); |
|
1001 |
gSmall.Close(); |
|
1002 |
||
1003 |
TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2); |
|
1004 |
test.Printf(_L("\nSync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
1005 |
TReal time=I64LOW(timeTaken.Int64() / KuStomS); |
|
1006 |
#if !defined(__WINS__) |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1007 |
// If this condition fails, it means that writing the sync file while fairscheduling a small sync write takes too long |
0 | 1008 |
test.Printf(_L("time: %f\n"), time); |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1009 |
// test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); |
0 | 1010 |
test(time > 0); |
1011 |
#endif |
|
1012 |
||
1013 |
// Async test |
|
1014 |
TRequestStatus status[KWaitRequestsTableSize]; |
|
1015 |
TRequestStatus status2[1]; |
|
1016 |
RFile bigFile, smallFile; |
|
1017 |
||
1018 |
WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
|
1019 |
WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2); |
|
1020 |
WaitForAll(status2,gSmallFileSize, KBlockSize); |
|
1021 |
time1.HomeTime(); |
|
1022 |
WaitForAll(status, gBigFileSize, KBigBlockSize); |
|
1023 |
time2.HomeTime(); |
|
1024 |
||
1025 |
timeTaken = time2.MicroSecondsFrom(time1); |
|
1026 |
test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1027 |
time=I64LOW(timeTaken.Int64() / KuStomS); |
0 | 1028 |
#if !defined(__WINS__) |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1029 |
if (!Is_HVFS(TheFs, gDrive)) |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1030 |
{ |
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1031 |
// If this condition fails, it means that writing the async file while fairscheduling a small async write takes too long |
0 | 1032 |
test.Printf(_L("time: %f\n"), time); |
1033 |
test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] ); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1034 |
// test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) ); |
0 | 1035 |
test(time > 0); |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1036 |
} |
0 | 1037 |
#endif |
1038 |
bigFile.Close(); |
|
1039 |
smallFile.Close(); |
|
1040 |
} |
|
1041 |
||
1042 |
/** Writes two big files, ensuring the one that started to be written later ends the last one |
|
1043 |
||
1044 |
*/ |
|
1045 |
void TestTwoBigOnes() |
|
1046 |
{ |
|
1047 |
TInt r = 0; |
|
1048 |
TTime time1; |
|
1049 |
TTime time2; |
|
1050 |
||
1051 |
// Sync test |
|
1052 |
TBuf<20> buf = _L("Big Write IIII"); |
|
1053 |
r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
1054 |
TEST(r == KErrNone); |
|
1055 |
||
1056 |
buf = _L("Big Write The Second"); |
|
1057 |
r = gSmall.Create(buf, WriteBigFile2, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
1058 |
TEST(r == KErrNone); |
|
1059 |
||
1060 |
gBig.Resume(); |
|
1061 |
gSmall.Resume(); |
|
1062 |
||
1063 |
CLIENTWAIT(); |
|
1064 |
CLIENTWAIT(); |
|
1065 |
||
1066 |
gBig.Close(); |
|
1067 |
gSmall.Close(); |
|
1068 |
||
1069 |
TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1); |
|
1070 |
test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
1071 |
||
1072 |
// Async test |
|
1073 |
TRequestStatus status[KWaitRequestsTableSize]; |
|
1074 |
TRequestStatus status2[KWaitRequestsTableSize]; |
|
1075 |
RFile bigFile, bigFile2; |
|
1076 |
||
1077 |
WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
|
1078 |
WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2); |
|
1079 |
WaitForAll(status, gBigFileSize, KBigBlockSize); |
|
1080 |
time1.HomeTime(); |
|
1081 |
WaitForAll(status2, gBigFileSize, KBigBlockSize); |
|
1082 |
time2.HomeTime(); |
|
1083 |
||
1084 |
timeTaken = time2.MicroSecondsFrom(time1); |
|
1085 |
test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
1086 |
bigFile.Close(); |
|
1087 |
bigFile2.Close(); |
|
1088 |
} |
|
1089 |
||
1090 |
/** Reads the file that is being written |
|
1091 |
||
1092 |
*/ |
|
1093 |
void TestReadingWhileWritingSameFile() |
|
1094 |
{ |
|
1095 |
TInt r = 0; |
|
1096 |
TTime time1; |
|
1097 |
||
1098 |
time1.HomeTime(); |
|
1099 |
||
1100 |
// Sync test |
|
1101 |
TBuf<20> buf = _L("Big Write IV"); |
|
1102 |
r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
1103 |
TEST(r == KErrNone); |
|
1104 |
||
1105 |
buf = _L("Read IV"); |
|
1106 |
r = gSmall.Create(buf, ReadBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
1107 |
TEST(r == KErrNone); |
|
1108 |
||
1109 |
gBig.Resume(); |
|
1110 |
gSmall.Resume(); |
|
1111 |
||
1112 |
CLIENTWAIT(); |
|
1113 |
CLIENTWAIT(); |
|
1114 |
||
1115 |
CLOSE_AND_WAIT(gBig); |
|
1116 |
CLOSE_AND_WAIT(gSmall); |
|
1117 |
||
1118 |
TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1); |
|
1119 |
test.Printf(_L("\nSync write finished %d ms before the read ended\n"),I64LOW(timeTaken.Int64() / KuStomS)); |
|
1120 |
||
1121 |
} |
|
1122 |
||
1123 |
/** Client dying uncleanly before the operation is finished |
|
1124 |
||
1125 |
*/ |
|
1126 |
void TestClientDies() |
|
1127 |
{ |
|
1128 |
TInt r = 0; |
|
1129 |
||
1130 |
||
1131 |
TBuf<20> drive = _L("?:\\"); |
|
1132 |
TVolumeInfo volInfo; |
|
1133 |
drive[0]=(TText)(gDrive+'A'); |
|
1134 |
||
1135 |
r = TheFs.CheckDisk(drive); |
|
1136 |
TEST(r == KErrNone || r == KErrNotSupported); |
|
1137 |
||
1138 |
// Sync test |
|
1139 |
TBuf<20> buf = _L("Big Write V"); |
|
1140 |
r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
1141 |
TEST(r == KErrNone); |
|
1142 |
||
1143 |
TRequestStatus status; |
|
1144 |
gBig.Logon(status); |
|
1145 |
gBig.Resume(); |
|
1146 |
gSync.Wait(); |
|
1147 |
||
1148 |
// Kill the writing thread and wait for it to die. |
|
1149 |
||
1150 |
if(status.Int() == KRequestPending) |
|
1151 |
{// the people who wrote this test did not consider the case when the file write finishes before they try to kill the thread. |
|
1152 |
gBig.Kill(KErrGeneral); |
|
1153 |
User::WaitForRequest(status); |
|
1154 |
TEST(gBig.ExitReason() == KErrGeneral); |
|
1155 |
TEST(gBig.ExitType() == EExitKill); |
|
1156 |
} |
|
1157 |
||
1158 |
||
1159 |
// Make sure the thread is destroyed and the handles it owned and IPCs |
|
1160 |
// it executed are closed/cancelled. |
|
1161 |
CLOSE_AND_WAIT(gBig); |
|
1162 |
||
1163 |
||
1164 |
r = TheFs.Volume(volInfo, gDrive); |
|
1165 |
TESTERROR(r); |
|
1166 |
||
1167 |
r = TheFs.CheckDisk(drive); |
|
1168 |
TEST(r == KErrNone || r == KErrNotSupported); |
|
1169 |
||
1170 |
r = TheFs.ScanDrive(drive); |
|
1171 |
TEST(r == KErrNone || r == KErrNotSupported); |
|
1172 |
||
1173 |
test.Printf(_L("Sync operation stopped\n")); |
|
1174 |
||
1175 |
// Async test |
|
1176 |
buf = _L("Big Write VI"); |
|
1177 |
r = gSmall.Create(buf, WriteBigFileAsync, KDefaultStackSize * 2, KHeapSize, KMaxHeapSize, NULL); |
|
1178 |
TEST(r == KErrNone); |
|
1179 |
||
1180 |
gSmall.Logon(status); |
|
1181 |
gSmall.Resume(); |
|
1182 |
gSync.Wait(); |
|
1183 |
||
1184 |
||
1185 |
if(status.Int() == KRequestPending) |
|
1186 |
{ |
|
1187 |
// Kill the writing thread and wait for it to die. |
|
1188 |
gSmall.Kill(KErrGeneral); |
|
1189 |
User::WaitForRequest(status); |
|
1190 |
TEST(gSmall.ExitReason() == KErrGeneral); |
|
1191 |
TEST(gSmall.ExitType() == EExitKill); |
|
1192 |
} |
|
1193 |
||
1194 |
||
1195 |
// Make sure the thread is destroyed and the handles it owned and IPCs |
|
1196 |
// it executed are closed/cancelled. |
|
1197 |
CLOSE_AND_WAIT(gSmall); |
|
1198 |
||
1199 |
r = TheFs.CheckDisk(drive); |
|
1200 |
TEST(r == KErrNone || r == KErrNotSupported); |
|
1201 |
||
1202 |
r=TheFs.ScanDrive(drive); |
|
1203 |
TEST(r == KErrNone || r == KErrNotSupported); |
|
1204 |
||
1205 |
test.Printf(_L("Async operation stopped\n")); |
|
1206 |
} |
|
1207 |
||
1208 |
/** Reads a small file while writing a big one |
|
1209 |
||
1210 |
*/ |
|
1211 |
void TestDeletionWhileWriting() |
|
1212 |
{ |
|
1213 |
TInt r = 0; |
|
1214 |
||
1215 |
// Sync test |
|
1216 |
TBuf<20> buf = _L("Big Write V"); |
|
1217 |
r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
1218 |
TEST(r == KErrNone); |
|
1219 |
||
1220 |
buf = _L("Deletion"); |
|
1221 |
r = gSmall.Create(buf, DeleteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL); |
|
1222 |
TEST(r == KErrNone); |
|
1223 |
||
1224 |
gSmall.Resume(); |
|
1225 |
gBig.Resume(); |
|
1226 |
||
1227 |
CLIENTWAIT(); |
|
1228 |
CLIENTWAIT(); |
|
1229 |
||
1230 |
gBig.Close(); |
|
1231 |
gSmall.Close(); |
|
1232 |
||
1233 |
test.Printf(_L("The file was properly blocked when writing sync, not deleted\n")); |
|
1234 |
||
1235 |
// Async test |
|
1236 |
TRequestStatus status[KWaitRequestsTableSize]; |
|
1237 |
RFile bigFile; |
|
1238 |
RFs fs; |
|
1239 |
||
1240 |
r = fs.Connect(); |
|
1241 |
TESTERROR(r); |
|
1242 |
r = fs.SetSessionPath(gSessionPath); |
|
1243 |
TESTERROR(r); |
|
1244 |
||
1245 |
WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); |
|
1246 |
||
1247 |
r = fs.Delete(gBigFile); |
|
1248 |
TEST(r == KErrInUse); |
|
1249 |
||
1250 |
WaitForAll(status, gBigFileSize, KBigBlockSize); |
|
1251 |
||
1252 |
bigFile.Close(); |
|
1253 |
fs.Close(); |
|
1254 |
||
1255 |
test.Printf(_L("The file was properly blocked when writing async, not deleted\n")); |
|
1256 |
||
1257 |
} |
|
1258 |
||
1259 |
||
1260 |
void TestWriteOrder() |
|
1261 |
{ |
|
1262 |
RFs fs; |
|
1263 |
||
1264 |
TInt r = fs.Connect(); |
|
1265 |
TESTERROR(r); |
|
1266 |
r = fs.SetSessionPath(gSessionPath); |
|
1267 |
TESTERROR(r); |
|
1268 |
||
1269 |
WriteOrderTest(TheFs, gBigFileSize, KBlockSize); |
|
1270 |
||
1271 |
fs.Close(); |
|
1272 |
} |
|
1273 |
||
1274 |
||
1275 |
/** Main tests function |
|
1276 |
*/ |
|
1277 |
void CallTestsL() |
|
1278 |
{ |
|
1279 |
TBuf16<45> dir; |
|
1280 |
TInt r = 0; |
|
1281 |
||
1282 |
||
1283 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1284 |
test.Printf(_L("Disabling Lock Fail simulation ...\n")); |
|
1285 |
// turn OFF lock failure mode (if cache is enabled) |
|
1286 |
||
1287 |
TBool simulatelockFailureMode = EFalse; |
|
1288 |
r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1289 |
test_Value(r, r == KErrNone || r == KErrNotSupported); |
0 | 1290 |
#endif |
1291 |
||
1292 |
// FileNames/File generation |
|
1293 |
test.Start(_L("Preparing the environment\n")); |
|
1294 |
||
1295 |
FileNameGen(gSmallFile, 8, gNextFile++); |
|
1296 |
FileNameGen(gBigFile, 8, gNextFile++); |
|
1297 |
||
1298 |
dir = gSessionPath; |
|
1299 |
dir.Append(gSmallFile); |
|
1300 |
||
1301 |
gSmallFile = dir; |
|
1302 |
dir = gSessionPath; |
|
1303 |
dir.Append(gBigFile); |
|
1304 |
gBigFile = dir; |
|
1305 |
||
1306 |
TRAPD(res,gBuf = HBufC8::NewL(KBigBlockSize)); |
|
1307 |
TEST(res == KErrNone && gBuf != NULL); |
|
1308 |
||
1309 |
gBufWritePtr.Set(gBuf->Des()); |
|
1310 |
FillBuffer(gBufWritePtr, KBigBlockSize, 'B'); |
|
1311 |
||
1312 |
TRAPD(res2, gBufSec = HBufC8::NewL(KBlockSize)); |
|
1313 |
TEST(res2 == KErrNone && gBufSec != NULL); |
|
1314 |
gBufReadPtr.Set(gBufSec->Des()); |
|
1315 |
||
1316 |
test.Next(_L("Benchmarking\n")); |
|
1317 |
TimeTakenToWriteBigFile(0); |
|
1318 |
TimeTakenToWriteBigFileAsync(0); |
|
1319 |
||
1320 |
test.Printf(_L("second try, second timings account for the last comparison\n")); |
|
1321 |
TimeTakenToWriteBigFile(0); |
|
1322 |
TimeTakenToWriteBigFileAsync(0); |
|
1323 |
||
1324 |
TimeTakenToWriteBigBlock(); |
|
1325 |
||
1326 |
test.Next(_L("Big file sync written, small file read from the media at the same time\n")); |
|
1327 |
TestReadingWhileWriting(); |
|
1328 |
||
1329 |
test.Next(_L("Big file written, small file written at the same time\n")); |
|
1330 |
TestWritingWhileWriting(); |
|
1331 |
||
1332 |
test.Next(_L("Big file written async, deletion in the meantime\n")); |
|
1333 |
TestDeletionWhileWriting(); |
|
1334 |
||
1335 |
test.Next(_L("Two big files written at the same time\n")); |
|
1336 |
TestTwoBigOnes(); |
|
1337 |
||
1338 |
test.Next(_L("Big file being written, start reading\n")); |
|
1339 |
TestReadingWhileWritingSameFile(); |
|
1340 |
||
1341 |
test.Next(_L("Client dying unexpectedly\n")); |
|
1342 |
TestClientDies(); |
|
1343 |
||
1344 |
test.Next(_L("Ensure write order is preserved\n")); |
|
1345 |
TestWriteOrder(); |
|
1346 |
||
1347 |
// Format the drive to make sure no blocks are left to be erased in LFFS |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1348 |
if (!Is_Win32(TheFs, gDrive)) |
0 | 1349 |
Format(gDrive); |
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1350 |
|
0 | 1351 |
r = TheFs.MkDirAll(gSessionPath); |
1352 |
||
1353 |
TimeTakenToWriteBigFile(1); |
|
1354 |
TimeTakenToWriteBigFileAsync(1); |
|
1355 |
||
1356 |
// Make sure that the difference between the first time and the last time the files are written doesn't |
|
1357 |
// differ more than 3% |
|
1358 |
test.Printf(_L("Abs(gTotalTimeSync[0]-gTotalTimeSync[1]) :%d\n"), Abs(gTotalTimeSync[0]-gTotalTimeSync[1])); |
|
1359 |
test.Printf(_L("Abs(gTotalTimeAsync[0]-gTotalTimeAsync[1]) :%d\n"), Abs(gTotalTimeAsync[0]-gTotalTimeAsync[1])); |
|
1360 |
test.Printf(_L("gTotalTimeSync[0] :%d\n"), gTotalTimeSync[0]); |
|
1361 |
test.Printf(_L("gTotalTimeAsync[0] :%d\n"), gTotalTimeAsync[0]); |
|
1362 |
||
1363 |
#if !defined(__WINS__) |
|
1364 |
test((Abs(gTotalTimeSync[0]-gTotalTimeSync[1])/gTotalTimeSync[0]) < 0.03); |
|
1365 |
test((Abs(gTotalTimeAsync[0]-gTotalTimeAsync[1])/gTotalTimeAsync[0]) < 0.03); |
|
1366 |
#endif |
|
1367 |
||
1368 |
r = DeleteAll(gSessionPath); |
|
1369 |
TESTERROR(r); |
|
1370 |
||
1371 |
delete gBuf; |
|
1372 |
delete gBufSec; |
|
1373 |
||
1374 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1375 |
// turn lock failure mode back ON (if cache is enabled) |
|
1376 |
simulatelockFailureMode = ETrue; |
|
1377 |
r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1378 |
test_Value(r, r == KErrNone || r == KErrNotSupported); |
0 | 1379 |
#endif |
1380 |
||
1381 |
test.End(); |
|
1382 |
} |
|
1383 |
||
1384 |
/** Initialises semaphores and call the tests |
|
1385 |
*/ |
|
1386 |
void DoTests() |
|
1387 |
{ |
|
1388 |
TInt r = 0; |
|
1389 |
||
1390 |
r = client.CreateLocal(0); |
|
1391 |
TESTERROR(r); |
|
1392 |
||
1393 |
r = gSync.CreateLocal(0); |
|
1394 |
TESTERROR(r); |
|
1395 |
||
1396 |
r = TheFs.SetSessionPath(gSessionPath); |
|
1397 |
TESTERROR(r); |
|
1398 |
||
1399 |
r = TheFs.MkDirAll(gSessionPath); |
|
1400 |
if (r != KErrNone && r != KErrAlreadyExists) |
|
1401 |
{ |
|
1402 |
TESTERROR(r); |
|
1403 |
} |
|
1404 |
TheFs.ResourceCountMarkStart(); |
|
1405 |
TRAP(r,CallTestsL()); |
|
1406 |
if (r == KErrNone) |
|
1407 |
TheFs.ResourceCountMarkEnd(); |
|
1408 |
else |
|
1409 |
{ |
|
1410 |
TESTERROR(r); |
|
1411 |
} |
|
1412 |
} |
|
1413 |
||
1414 |
/** Determines the space that can be used for the files |
|
1415 |
||
1416 |
*/ |
|
1417 |
TBool CheckForDiskSize() |
|
1418 |
{ |
|
1419 |
TVolumeInfo volInfo; |
|
1420 |
TInt r = TheFs.Volume(volInfo, gDrive); |
|
1421 |
TESTERROR(r); |
|
1422 |
||
1423 |
gMediaSize = volInfo.iSize; |
|
1424 |
gSmallFileSize = KBlockSize; |
|
1425 |
gBigFileSize = KBlockSize*20; |
|
1426 |
||
1427 |
while(((2*gBigFileSize)+KOneMeg) > gMediaSize ) |
|
1428 |
{ |
|
1429 |
gBigFileSize -= (2*KBlockSize); |
|
1430 |
} |
|
1431 |
||
1432 |
TReal32 small = (TReal32)(gSmallFileSize/KOneK); |
|
1433 |
TReal32 big = (TReal32)(gBigFileSize/KOneK); |
|
1434 |
||
1435 |
||
1436 |
test.Printf(_L("Small File Size: %.2f KB\n"), small); |
|
1437 |
test.Printf(_L("Big File Size: %.2f KB (%.2f MB)\n"), big, big / KOneK); |
|
1438 |
||
1439 |
if(gBigFileSize< (3*gSmallFileSize)) |
|
1440 |
return EFalse; |
|
1441 |
else |
|
1442 |
return ETrue; |
|
1443 |
} |
|
1444 |
||
1445 |
/** Formats the drive |
|
1446 |
||
1447 |
@param aDrive Drive to be formatted |
|
1448 |
*/ |
|
1449 |
void Format(TInt aDrive) |
|
1450 |
{ |
|
1451 |
||
1452 |
test.Next(_L("Format")); |
|
1453 |
TBuf<4> driveBuf = _L("?:\\"); |
|
1454 |
driveBuf[0] = (TText)(aDrive+'A'); |
|
1455 |
RFormat format; |
|
1456 |
TInt count, prevcount = 0; |
|
1457 |
TInt r = format.Open(TheFs, driveBuf, EQuickFormat, count); |
|
1458 |
TESTERROR(r); |
|
1459 |
||
1460 |
while(count) |
|
1461 |
{ |
|
1462 |
TInt r = format.Next(count); |
|
1463 |
if(count != prevcount) |
|
1464 |
{ |
|
1465 |
test.Printf(_L(".")); |
|
1466 |
prevcount = count; |
|
1467 |
} |
|
1468 |
TESTERROR(r); |
|
1469 |
} |
|
1470 |
||
1471 |
format.Close(); |
|
1472 |
} |
|
1473 |
||
1474 |
/** Main function |
|
1475 |
||
1476 |
@return KErrNone if everything was ok, panics otherwise |
|
1477 |
*/ |
|
1478 |
TInt E32Main() |
|
1479 |
{ |
|
1480 |
RThread t; |
|
1481 |
gMainThreadId = t.Id(); |
|
1482 |
||
1483 |
CTrapCleanup* cleanup; |
|
1484 |
cleanup = CTrapCleanup::New(); |
|
1485 |
||
1486 |
__UHEAP_MARK; |
|
1487 |
test.Start(_L("Starting tests... T_FSCHED")); |
|
1488 |
parseCommandLine(); |
|
1489 |
||
1490 |
TInt r = TheFs.Connect(); |
|
1491 |
TESTERROR(r); |
|
1492 |
||
1493 |
TDriveInfo info; |
|
1494 |
TVolumeInfo volInfo; |
|
1495 |
r = TheFs.Drive(info, gDrive); |
|
1496 |
TESTERROR(r); |
|
1497 |
||
1498 |
if(info.iMediaAtt&KMediaAttVariableSize) |
|
1499 |
{ |
|
1500 |
test.Printf(_L("Tests skipped in RAM drive\n")); |
|
1501 |
goto out; |
|
1502 |
} |
|
1503 |
||
1504 |
r = TheFs.Volume(volInfo, gDrive); |
|
1505 |
if (r == KErrNotReady) |
|
1506 |
{ |
|
1507 |
if (info.iType == EMediaNotPresent) |
|
1508 |
test.Printf(_L("%c: Medium not present - cannot perform test.\n"), (TUint)gDrive + 'A'); |
|
1509 |
else |
|
1510 |
test.Printf(_L("medium found (type %d) but drive %c: not ready\nPrevious test may have hung; else, check hardware.\n"), (TInt)info.iType, (TUint)gDrive + 'A'); |
|
1511 |
} |
|
1512 |
else if (r == KErrCorrupt) |
|
1513 |
{ |
|
1514 |
test.Printf(_L("%c: Media corruption; previous test may have aborted; else, check hardware\n"), (TUint)gDrive + 'A'); |
|
1515 |
} |
|
1516 |
TESTERROR(r); |
|
200
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1517 |
|
73ea206103e6
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
1518 |
if (!Is_Win32(TheFs, gDrive) && (volInfo.iDrive.iMediaAtt & KMediaAttFormattable)) |
0 | 1519 |
Format(gDrive); |
1520 |
||
1521 |
if(CheckForDiskSize()) |
|
1522 |
{ |
|
1523 |
DoTests(); |
|
1524 |
} |
|
1525 |
else |
|
1526 |
{ |
|
1527 |
test.Printf(_L("Skipping tests due to lack of space to perform them in this drive\n")); |
|
1528 |
} |
|
1529 |
out: |
|
1530 |
test.End(); |
|
1531 |
||
1532 |
TheFs.Close(); |
|
1533 |
test.Close(); |
|
1534 |
||
1535 |
__UHEAP_MARKEND; |
|
1536 |
delete cleanup; |
|
1537 |
return(KErrNone); |
|
1538 |
} |