author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 16 Apr 2010 16:24:37 +0300 | |
changeset 90 | 947f0dc9f7a8 |
parent 0 | a41df078684a |
child 109 | b3a1d9898418 |
child 175 | 5af6c74cd793 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1997-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_main.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#define __E32TEST_EXTENSION__ |
|
19 |
||
20 |
#include <f32file.h> |
|
21 |
#include <e32test.h> |
|
22 |
#include <e32hal.h> |
|
23 |
#include <e32math.h> |
|
24 |
#include <f32dbg.h> |
|
25 |
#include "t_server.h" |
|
26 |
#include "t_chlffs.h" |
|
27 |
||
28 |
GLDEF_D RFs TheFs; |
|
29 |
GLDEF_D TFileName gSessionPath; |
|
30 |
GLDEF_D TFileName gExeFileName(RProcess().FileName()); |
|
31 |
GLDEF_D TInt gAllocFailOff=KAllocFailureOff; |
|
32 |
GLDEF_D TInt gAllocFailOn=KAllocFailureOff; |
|
33 |
GLDEF_D TInt64 gSeed=51703; |
|
34 |
||
35 |
GLDEF_D TChar gDriveToTest; |
|
36 |
GLDEF_D TVolumeInfo gVolInfo; // volume info for current drive |
|
37 |
GLDEF_D TFileCacheFlags gDriveCacheFlags; |
|
38 |
||
39 |
_LIT(KPrivate, "\\Private\\"); |
|
40 |
||
41 |
||
42 |
//////////////////////////////////////////////////////////// |
|
43 |
// Template functions encapsulating ControlIo magic |
|
44 |
// |
|
45 |
GLDEF_D template <class C> |
|
46 |
GLDEF_C TInt controlIo(RFs &fs, TInt drv, TInt fkn, C &c) |
|
47 |
{ |
|
48 |
TPtr8 ptrC((TUint8 *)&c, sizeof(C), sizeof(C)); |
|
49 |
||
50 |
TInt r = fs.ControlIo(drv, fkn, ptrC); |
|
51 |
||
52 |
return r; |
|
53 |
} |
|
54 |
||
55 |
GLDEF_C void CreateShortName(TDes& aFileName,TInt64& aSeed) |
|
56 |
// |
|
57 |
// Create a random, dos legal 8.3 char name |
|
58 |
// |
|
59 |
{ |
|
60 |
||
61 |
TInt length=Math::Rand(aSeed)%11; |
|
62 |
if (length==0) |
|
63 |
length=1; |
|
64 |
else if (length==3) // don't create three letter names like 'AUX' or 'PRN' |
|
65 |
length++; |
|
66 |
else if (length>8) // end in '.' if no extension |
|
67 |
length++; |
|
68 |
||
69 |
aFileName.SetLength(length); |
|
70 |
for(TInt i=0;i<length;i++) |
|
71 |
{ |
|
72 |
if (i==9) |
|
73 |
{ |
|
74 |
aFileName[i]='.'; |
|
75 |
continue; |
|
76 |
} |
|
77 |
TInt letter=Math::Rand(aSeed)%26; |
|
78 |
aFileName[i]=(TText)('A'+letter); |
|
79 |
} |
|
80 |
} |
|
81 |
||
82 |
_LIT(KFatName, "Fat"); |
|
83 |
_LIT(KFat32Name, "Fat32"); |
|
84 |
||
85 |
static |
|
86 |
TBool isFAT(RFs &aFsSession, TInt aDrive) |
|
87 |
{ |
|
88 |
TFileName f; |
|
89 |
TInt r = aFsSession.FileSystemName(f, aDrive); |
|
90 |
test_Value(r, r == KErrNone || r == KErrNotFound); |
|
91 |
return (f.CompareF(KFatName) == 0 || f.CompareF(KFat32Name) == 0); |
|
92 |
} |
|
93 |
||
94 |
static |
|
95 |
TUint16 getRootEntCnt(RFs &aFsSession, TInt aDrive) |
|
96 |
{ |
|
97 |
RRawDisk rdisk; |
|
98 |
TUint16 rootEntCnt; |
|
99 |
TPtr8 reader((TUint8*)&rootEntCnt, sizeof(rootEntCnt)); |
|
100 |
||
101 |
test_KErrNone(rdisk.Open(aFsSession, aDrive)); |
|
102 |
test_KErrNone(rdisk.Read(17, reader)); // "BPB_RootEntCnt" field at offset 17 |
|
103 |
rdisk.Close(); |
|
104 |
||
105 |
return rootEntCnt; |
|
106 |
} |
|
107 |
||
108 |
GLDEF_C TBool IsFileSystemFAT(RFs &aFsSession,TInt aDrive) |
|
109 |
// |
|
110 |
// return true if FAT on aDrive |
|
111 |
// |
|
112 |
{ |
|
113 |
return (isFAT(aFsSession, aDrive) && getRootEntCnt(aFsSession, aDrive) != 0); |
|
114 |
} |
|
115 |
||
116 |
GLDEF_C TBool IsFileSystemFAT32(RFs &aFsSession,TInt aDrive) |
|
117 |
// |
|
118 |
// return true if FAT32 on aDrive |
|
119 |
// |
|
120 |
{ |
|
121 |
return (isFAT(aFsSession, aDrive) && getRootEntCnt(aFsSession, aDrive) == 0); |
|
122 |
} |
|
123 |
||
124 |
GLDEF_C void CreateLongName(TDes& aFileName,TInt64& aSeed,TInt aLength) |
|
125 |
// |
|
126 |
// Create a random, dos legal 8.3 char name |
|
127 |
// |
|
128 |
{ |
|
129 |
||
130 |
TInt length; |
|
131 |
if (aLength>0) |
|
132 |
length=aLength; |
|
133 |
else |
|
134 |
{ |
|
135 |
length=Math::Rand(aSeed)%128; |
|
136 |
length+=Math::Rand(aSeed)%128; |
|
137 |
length+=Math::Rand(aSeed)%128; |
|
138 |
length+=Math::Rand(aSeed)%128; |
|
139 |
length-=256; |
|
140 |
length=Abs(length); |
|
141 |
if (length==0) |
|
142 |
length=1; |
|
143 |
if (length>220) |
|
144 |
length=31; |
|
145 |
} |
|
146 |
if (length==3) // don't create three letter names like 'AUX' or 'PRN' |
|
147 |
length++; |
|
148 |
||
149 |
aFileName.SetLength(length); |
|
150 |
TInt spaceChar=-1; |
|
151 |
TInt i; |
|
152 |
for(i=0;i<length;i++) |
|
153 |
{ |
|
154 |
StartAgain: |
|
155 |
TChar letter=0; |
|
156 |
TBool illegalChar=ETrue; |
|
157 |
||
158 |
while(illegalChar) |
|
159 |
{ |
|
160 |
#if defined(__WINS__) |
|
161 |
if (gSessionPath[0]=='C') |
|
162 |
letter=(TChar)('A'+Math::Rand(aSeed)%26); |
|
163 |
else |
|
164 |
letter=(TChar)Math::Rand(aSeed)%256; |
|
165 |
#else |
|
166 |
letter=(TChar)Math::Rand(aSeed)%256; |
|
167 |
#endif |
|
168 |
TBool space=letter.IsSpace(); |
|
169 |
if (space && spaceChar==-1) |
|
170 |
spaceChar=i; |
|
171 |
else if (!space && spaceChar!=-1) |
|
172 |
spaceChar=-1; |
|
173 |
||
174 |
switch(letter) |
|
175 |
{ |
|
176 |
case '<': |
|
177 |
case '>': |
|
178 |
case ':': |
|
179 |
case '"': |
|
180 |
case '/': |
|
181 |
case '|': |
|
182 |
case '*': |
|
183 |
case '?': |
|
184 |
case '\\': |
|
185 |
case '\0': |
|
186 |
break; |
|
187 |
default: |
|
188 |
illegalChar=EFalse; |
|
189 |
}; |
|
190 |
} |
|
191 |
aFileName[i]=(TText)letter; |
|
192 |
} |
|
193 |
||
194 |
if (spaceChar!=-1) |
|
195 |
{ |
|
196 |
i=spaceChar; |
|
197 |
goto StartAgain; |
|
198 |
} |
|
199 |
} |
|
200 |
||
201 |
GLDEF_C void CheckEntry(const TDesC& aName,TUint anAttributes,const TTime& aModified) |
|
202 |
// |
|
203 |
// Checks the values associated with an entry |
|
204 |
// |
|
205 |
{ |
|
206 |
||
207 |
TEntry entry; |
|
208 |
TInt r=TheFs.Entry(aName,entry); |
|
209 |
test_KErrNone(r); |
|
210 |
test(entry.iAtt==anAttributes); |
|
211 |
if (aModified!=TTime(0)) |
|
212 |
test(entry.iModified==aModified); |
|
213 |
} |
|
214 |
||
215 |
GLDEF_C void CheckDisk() |
|
216 |
// |
|
217 |
// Do a checkdisk and report failure |
|
218 |
// |
|
219 |
{ |
|
220 |
test.Next(_L("Check Disk")); |
|
221 |
TInt r=TheFs.CheckDisk(gSessionPath); |
|
222 |
if (r!=KErrNone && r!=KErrNotSupported && r!=KErrPermissionDenied) |
|
223 |
ReportCheckDiskFailure(r); |
|
224 |
} |
|
225 |
||
226 |
GLDEF_C void ReportCheckDiskFailure(TInt aRet) |
|
227 |
// |
|
228 |
// Report the failure of checkdisk |
|
229 |
// |
|
230 |
{ |
|
231 |
||
232 |
test.Printf(_L("CHECKDISK FAILED: ")); |
|
233 |
switch(aRet) |
|
234 |
{ |
|
235 |
case 1: test.Printf(_L("File cluster chain contains a bad value (<2 or >maxCluster)\n")); break; |
|
236 |
case 2: test.Printf(_L("Two files are linked to the same cluster\n")); break; |
|
237 |
case 3: test.Printf(_L("Unallocated cluster contains a value != 0\n")); break; |
|
238 |
case 4: test.Printf(_L("Size of file != number of clusters in chain\n")); break; |
|
239 |
default: test.Printf(_L("Undefined Error value %d\n"),aRet); |
|
240 |
} |
|
241 |
test(EFalse); |
|
242 |
} |
|
243 |
||
244 |
GLDEF_C void TurnAllocFailureOff() |
|
245 |
// |
|
246 |
// Switch off all allocFailure |
|
247 |
// |
|
248 |
{ |
|
249 |
||
250 |
test.Printf(_L("Disable Alloc Failure\n")); |
|
251 |
TheFs.SetAllocFailure(gAllocFailOff); |
|
252 |
gAllocFailOn=KAllocFailureOff; // Disable gAllocFailOn |
|
253 |
} |
|
254 |
||
255 |
GLDEF_C void TurnAllocFailureOn() |
|
256 |
// |
|
257 |
// Switch off all allocFailure |
|
258 |
// |
|
259 |
{ |
|
260 |
||
261 |
test.Printf(_L("Enable Alloc Failure\n")); |
|
262 |
gAllocFailOn=KAllocFailureOn; // Enable gAllocFailOn |
|
263 |
TheFs.SetAllocFailure(gAllocFailOn); |
|
264 |
} |
|
265 |
||
266 |
GLDEF_C void MakeFile(const TDesC& aFileName,const TUidType& aUidType,const TDesC8& aFileContents) |
|
267 |
// |
|
268 |
// Make a file and write uid and data |
|
269 |
// |
|
270 |
{ |
|
271 |
||
272 |
RFile file; |
|
273 |
TInt r=file.Replace(TheFs,aFileName,0); |
|
274 |
if (r==KErrPathNotFound) |
|
275 |
{ |
|
276 |
r=TheFs.MkDirAll(aFileName); |
|
277 |
test_KErrNone(r); |
|
278 |
r=file.Replace(TheFs,aFileName,0); |
|
279 |
} |
|
280 |
test_KErrNone(r); |
|
281 |
TCheckedUid checkedUid(aUidType); |
|
282 |
TPtrC8 uidData((TUint8*)&checkedUid,sizeof(TCheckedUid)); |
|
283 |
r=file.Write(uidData); |
|
284 |
test_KErrNone(r); |
|
285 |
r=file.Write(aFileContents); |
|
286 |
test_KErrNone(r); |
|
287 |
file.Close(); |
|
288 |
} |
|
289 |
||
290 |
GLDEF_C void MakeFile(const TDesC& aFileName,const TDesC8& aFileContents) |
|
291 |
// |
|
292 |
// Make a file and write something in it |
|
293 |
// |
|
294 |
{ |
|
295 |
||
296 |
RFile file; |
|
297 |
TInt r=file.Replace(TheFs,aFileName,0); |
|
298 |
if (r==KErrPathNotFound) |
|
299 |
{ |
|
300 |
r=TheFs.MkDirAll(aFileName); |
|
301 |
test_KErrNone(r); |
|
302 |
r=file.Replace(TheFs,aFileName,0); |
|
303 |
} |
|
304 |
test_KErrNone(r); |
|
305 |
r=file.Write(aFileContents); |
|
306 |
test_KErrNone(r); |
|
307 |
file.Close(); |
|
308 |
} |
|
309 |
||
310 |
GLDEF_C void MakeFile(const TDesC& aFileName,TInt anAttributes) |
|
311 |
// |
|
312 |
// Make a file and write something in it |
|
313 |
// |
|
314 |
{ |
|
315 |
||
316 |
RFile file; |
|
317 |
TInt r=file.Replace(TheFs,aFileName,0); |
|
318 |
if (r==KErrPathNotFound) |
|
319 |
{ |
|
320 |
r=TheFs.MkDirAll(aFileName); |
|
321 |
test_KErrNone(r); |
|
322 |
r=file.Replace(TheFs,aFileName,0); |
|
323 |
} |
|
324 |
test_KErrNone(r); |
|
325 |
file.Close(); |
|
326 |
r=TheFs.SetAtt(aFileName,anAttributes,0); |
|
327 |
test_KErrNone(r); |
|
328 |
} |
|
329 |
||
330 |
GLDEF_C void SetSessionPath(const TDesC& aPathName) |
|
331 |
// |
|
332 |
// Set the session path and update gSessionPath |
|
333 |
// |
|
334 |
{ |
|
335 |
||
336 |
TInt r=TheFs.SetSessionPath(aPathName); |
|
337 |
test_KErrNone(r); |
|
338 |
r=TheFs.SessionPath(gSessionPath); |
|
339 |
test_KErrNone(r); |
|
340 |
} |
|
341 |
||
342 |
GLDEF_C void MakeFile(const TDesC& aFileName) |
|
343 |
// |
|
344 |
// Make a file |
|
345 |
// |
|
346 |
{ |
|
347 |
||
348 |
MakeFile(aFileName,_L8("")); |
|
349 |
} |
|
350 |
||
351 |
GLDEF_C void MakeDir(const TDesC& aDirName) |
|
352 |
// |
|
353 |
// Make a directory |
|
354 |
// |
|
355 |
{ |
|
356 |
||
357 |
TInt r=TheFs.MkDirAll(aDirName); |
|
358 |
if (r!=KErrNone && r!=KErrAlreadyExists) |
|
359 |
{ |
|
360 |
test.Printf(_L("%c: MakeDir Error %d\n"),aDirName[0],r); |
|
361 |
test(0); |
|
362 |
} |
|
363 |
} |
|
364 |
||
365 |
GLDEF_C TInt CheckFileExists(const TDesC& aName,TInt aResult,TBool aCompRes/*=ETrue*/) |
|
366 |
// |
|
367 |
// Check aName exists |
|
368 |
// |
|
369 |
{ |
|
370 |
||
371 |
TEntry entry; |
|
372 |
TInt r=TheFs.Entry(aName,entry); |
|
373 |
test_Value(r, r == KErrNone || r == aResult); |
|
374 |
if (aResult!=KErrNone) |
|
375 |
return(0); |
|
376 |
TParsePtrC nameParse(aName); |
|
377 |
TParsePtrC entryParse(entry.iName); |
|
378 |
TBool nameMatch=(entryParse.Name()==nameParse.Name()); |
|
379 |
TBool extMatch=(entryParse.Ext()==nameParse.Ext()) || (entryParse.Ext().Length()<=1 && nameParse.Ext().Length()<=1); |
|
380 |
test((nameMatch && extMatch)==aCompRes); |
|
381 |
return(entry.iSize); |
|
382 |
} |
|
383 |
||
384 |
GLDEF_C void CheckFileContents(const TDesC& aName,const TDesC8& aContents) |
|
385 |
// |
|
386 |
// Check contents of file |
|
387 |
// |
|
388 |
{ |
|
389 |
||
390 |
RFile f; |
|
391 |
TInt r=f.Open(TheFs,aName,EFileRead); |
|
392 |
test_KErrNone(r); |
|
393 |
HBufC8* testBuf=HBufC8::NewL(aContents.Length()); |
|
394 |
test(testBuf!=NULL); |
|
395 |
TPtr8 bufPtr(testBuf->Des()); |
|
396 |
r=f.Read(bufPtr); |
|
397 |
test_KErrNone(r); |
|
398 |
test(bufPtr==aContents); |
|
399 |
r=f.Read(bufPtr); |
|
400 |
test_KErrNone(r); |
|
401 |
test(bufPtr.Length()==0); |
|
402 |
f.Close(); |
|
403 |
User::Free(testBuf); |
|
404 |
} |
|
405 |
||
406 |
GLDEF_C void DeleteTestDirectory() |
|
407 |
// |
|
408 |
// Delete the leaf session path directory |
|
409 |
// |
|
410 |
{ |
|
411 |
||
412 |
TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden"), 0, KEntryAttHidden); |
|
413 |
TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\HiddenFile"), 0, KEntryAttHidden); |
|
414 |
TheFs.SetAtt(_L("\\F32-TST\\SCANTEST\\Left\\Dir3\\Dir4\\Hidden\\System"), 0, KEntryAttSystem); |
|
415 |
test.Next(_L("Delete test directory")); |
|
416 |
CFileMan* fMan=CFileMan::NewL(TheFs); |
|
417 |
test(fMan!=NULL); |
|
418 |
TInt r=TheFs.SessionPath(gSessionPath); |
|
419 |
test_KErrNone(r); |
|
420 |
r=TheFs.CheckDisk(gSessionPath); |
|
421 |
if (r!=KErrNone && r!=KErrNotSupported) |
|
422 |
ReportCheckDiskFailure(r); |
|
423 |
r=fMan->RmDir(gSessionPath); |
|
424 |
test_KErrNone(r); |
|
425 |
delete fMan; |
|
426 |
} |
|
427 |
||
428 |
GLDEF_C void CreateTestDirectory(const TDesC& aSessionPath) |
|
429 |
// |
|
430 |
// Create directory for test |
|
431 |
// |
|
432 |
{ |
|
433 |
TParsePtrC path(aSessionPath); |
|
434 |
test(path.DrivePresent()==EFalse); |
|
435 |
||
436 |
TInt r=TheFs.SetSessionPath(aSessionPath); |
|
437 |
test_KErrNone(r); |
|
438 |
r=TheFs.SessionPath(gSessionPath); |
|
439 |
test_KErrNone(r); |
|
440 |
r=TheFs.MkDirAll(gSessionPath); |
|
441 |
test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
|
442 |
} |
|
443 |
||
444 |
GLDEF_C TInt CurrentDrive() |
|
445 |
// |
|
446 |
// Return the current drive number |
|
447 |
// |
|
448 |
{ |
|
449 |
||
450 |
TInt driveNum; |
|
451 |
TInt r=TheFs.CharToDrive(gSessionPath[0],driveNum); |
|
452 |
test_KErrNone(r); |
|
453 |
return(driveNum); |
|
454 |
} |
|
455 |
||
456 |
GLDEF_C void Format(TInt aDrive) |
|
457 |
// |
|
458 |
// Format current drive |
|
459 |
// |
|
460 |
{ |
|
461 |
||
462 |
test.Next(_L("Format")); |
|
463 |
TBuf<4> driveBuf=_L("?:\\"); |
|
464 |
driveBuf[0]=(TText)(aDrive+'A'); |
|
465 |
RFormat format; |
|
466 |
TInt count; |
|
467 |
TInt r=format.Open(TheFs,driveBuf,EQuickFormat,count); |
|
468 |
test_KErrNone(r); |
|
469 |
while(count) |
|
470 |
{ |
|
471 |
TInt r=format.Next(count); |
|
472 |
test_KErrNone(r); |
|
473 |
} |
|
474 |
format.Close(); |
|
475 |
} |
|
476 |
||
477 |
LOCAL_C void PushLotsL() |
|
478 |
// |
|
479 |
// Expand the cleanup stack |
|
480 |
// |
|
481 |
{ |
|
482 |
TInt i; |
|
483 |
for(i=0;i<1000;i++) |
|
484 |
CleanupStack::PushL((CBase*)NULL); |
|
485 |
CleanupStack::Pop(1000); |
|
486 |
} |
|
487 |
||
488 |
||
489 |
LOCAL_C void DoTests(TInt aDrive) |
|
490 |
// |
|
491 |
// Do testing on aDrive |
|
492 |
// |
|
493 |
{ |
|
494 |
||
495 |
gSessionPath=_L("?:\\F32-TST\\"); |
|
496 |
TChar driveLetter; |
|
497 |
TInt r=TheFs.DriveToChar(aDrive,driveLetter); |
|
498 |
test_KErrNone(r); |
|
499 |
gSessionPath[0]=(TText)driveLetter; |
|
500 |
r=TheFs.SetSessionPath(gSessionPath); |
|
501 |
test_KErrNone(r); |
|
502 |
||
503 |
// !!! Disable platform security tests until we get the new APIs |
|
504 |
// if(User::Capability() & KCapabilityRoot) |
|
505 |
CheckMountLFFS(TheFs,driveLetter); |
|
506 |
||
507 |
User::After(1000000); |
|
508 |
||
509 |
// Format(CurrentDrive()); |
|
510 |
||
511 |
test.Printf(_L("Creating session path")); |
|
512 |
r=TheFs.MkDirAll(gSessionPath); |
|
513 |
if(r == KErrCorrupt) |
|
514 |
{ |
|
515 |
test.Printf(_L("Attempting to create directory \'%S\' failed, KErrCorrupt\n"), &gSessionPath); |
|
516 |
test.Printf(_L("This could be caused by a previous failing test, or a test media defect\n")); |
|
517 |
test.Printf(_L("Formatting drive, retrying MkDirall\nShould subsequent tests fail with KErrCorrupt (%d) as well, replace test medium !\n"), |
|
518 |
r); |
|
519 |
Format(aDrive); |
|
520 |
r=TheFs.MkDirAll(gSessionPath); |
|
521 |
test_KErrNone(r); |
|
522 |
} |
|
523 |
else if (r == KErrNotReady) |
|
524 |
{ |
|
525 |
TDriveInfo d; |
|
526 |
r=TheFs.Drive(d, aDrive); |
|
527 |
test_KErrNone(r); |
|
528 |
if (d.iType == EMediaNotPresent) |
|
529 |
test.Printf(_L("%c: Medium not present - cannot perform test.\n"), (TUint)driveLetter); |
|
530 |
else |
|
531 |
test.Printf(_L("medium found (type %d) but drive %c: not ready\nPrevious test may have hung; else, check hardware.\n"), (TInt)d.iType, (TUint)driveLetter); |
|
532 |
} |
|
533 |
test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
|
534 |
TheFs.ResourceCountMarkStart(); |
|
535 |
test.Printf(_L("Calling main test sequence ...\n")); |
|
536 |
TRAP(r,CallTestsL()); |
|
537 |
test_KErrNone(r); |
|
538 |
test.Printf(_L("test sequence completed without error\n")); |
|
539 |
TheFs.ResourceCountMarkEnd(); |
|
540 |
||
541 |
CheckDisk(); |
|
542 |
TestingLFFS(EFalse); |
|
543 |
} |
|
544 |
||
545 |
||
546 |
void ParseCommandArguments() |
|
547 |
// |
|
548 |
// |
|
549 |
// |
|
550 |
{ |
|
551 |
TBuf<0x100> cmd; |
|
552 |
User::CommandLine(cmd); |
|
553 |
TLex lex(cmd); |
|
554 |
TPtrC token=lex.NextToken(); |
|
555 |
TFileName thisfile=RProcess().FileName(); |
|
556 |
if (token.MatchF(thisfile)==0) |
|
557 |
{ |
|
558 |
token.Set(lex.NextToken()); |
|
559 |
} |
|
560 |
test.Printf(_L("CLP=%S\n"),&token); |
|
561 |
||
562 |
if(token.Length()!=0) |
|
563 |
{ |
|
564 |
gDriveToTest=token[0]; |
|
565 |
gDriveToTest.UpperCase(); |
|
566 |
} |
|
567 |
else |
|
568 |
gDriveToTest='C'; |
|
569 |
} |
|
570 |
||
571 |
TFullName gExtName; |
|
572 |
TBool gPrimaryExtensionExists = EFalse; |
|
573 |
||
574 |
GLDEF_C TInt DismountFileSystem(RFs& aFs, const TDesC& aFileSystemName,TInt aDrive) |
|
575 |
{ |
|
576 |
//Make note of the first extension if it exists, so that we remount |
|
577 |
//it when the file system is remounted. |
|
578 |
TInt r = aFs.ExtensionName(gExtName, aDrive, 0); |
|
579 |
||
580 |
if (r == KErrNone) |
|
581 |
{ |
|
582 |
gPrimaryExtensionExists = ETrue; |
|
583 |
} |
|
584 |
return aFs.DismountFileSystem(aFileSystemName, aDrive); |
|
585 |
} |
|
586 |
||
587 |
GLDEF_C TInt MountFileSystem(RFs& aFs, const TDesC& aFileSystemName,TInt aDrive, TBool aIsSync) |
|
588 |
{ |
|
589 |
TInt r; |
|
590 |
if (gPrimaryExtensionExists) |
|
591 |
{ |
|
592 |
r = aFs.MountFileSystem(aFileSystemName, gExtName, aDrive, aIsSync); |
|
593 |
} |
|
594 |
else |
|
595 |
{ |
|
596 |
r = aFs. MountFileSystem(aFileSystemName, aDrive, aIsSync); |
|
597 |
} |
|
598 |
return r; |
|
599 |
} |
|
600 |
||
601 |
GLDEF_C TInt E32Main() |
|
602 |
// |
|
603 |
// Test with drive nearly full |
|
604 |
// |
|
605 |
{ |
|
606 |
||
607 |
CTrapCleanup* cleanup; |
|
608 |
cleanup=CTrapCleanup::New(); |
|
609 |
TRAPD(r,PushLotsL()); |
|
610 |
__UHEAP_MARK; |
|
611 |
||
612 |
test.Title(); |
|
613 |
test.Start(_L("Starting tests...")); |
|
614 |
||
615 |
||
616 |
ParseCommandArguments(); //need this for drive letter to test |
|
617 |
||
618 |
||
619 |
r=TheFs.Connect(); |
|
620 |
test_KErrNone(r); |
|
621 |
TheFs.SetAllocFailure(gAllocFailOn); |
|
622 |
TTime timerC; |
|
623 |
timerC.HomeTime(); |
|
624 |
TFileName sessionp; |
|
625 |
TheFs.SessionPath(sessionp); |
|
626 |
||
627 |
TBuf<30> privatedir; |
|
628 |
privatedir = KPrivate; |
|
629 |
||
630 |
TUid thisUID = RProcess().Identity(); |
|
631 |
privatedir.AppendFormat(_L("%08x"),thisUID.iUid); |
|
632 |
privatedir.Append(_L("\\")); |
|
633 |
||
634 |
test(privatedir == sessionp.Mid(2,sessionp.Length()-2)); |
|
635 |
||
636 |
test.Printf(_L("sp=%S\n"),&sessionp); |
|
637 |
sessionp[0]=(TText)gDriveToTest; |
|
638 |
test.Printf(_L("sp1=%S\n"),&sessionp); |
|
639 |
||
640 |
TInt theDrive; |
|
641 |
r=TheFs.CharToDrive(gDriveToTest,theDrive); |
|
642 |
test_KErrNone(r); |
|
643 |
||
644 |
// Get the TFileCacheFlags for this drive |
|
645 |
r = TheFs.Volume(gVolInfo, theDrive); |
|
646 |
if (r == KErrNotReady) |
|
647 |
{ |
|
648 |
TDriveInfo info; |
|
649 |
TInt err = TheFs.Drive(info,theDrive); |
|
650 |
test_KErrNone(err); |
|
651 |
if (info.iType == EMediaNotPresent) |
|
652 |
test.Printf(_L("%c: Medium not present - cannot perform test.\n"), (TUint)gDriveToTest); |
|
653 |
else |
|
654 |
test.Printf(_L("%c: medium found (type %d) but drive not ready\nPrevious test may have hung; else, check hardware.\n"), (TUint)gDriveToTest, (TInt)info.iType); |
|
655 |
} |
|
656 |
else if (r == KErrCorrupt) |
|
657 |
{ |
|
658 |
test.Printf(_L("%c: Media corruption; previous test may have aborted; else, check hardware\n"), (TUint)gDriveToTest); |
|
659 |
} |
|
660 |
test_KErrNone(r); |
|
661 |
gDriveCacheFlags = gVolInfo.iFileCacheFlags; |
|
662 |
test.Printf(_L("DriveCacheFlags = %08X\n"), gDriveCacheFlags); |
|
663 |
||
664 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
665 |
test.Printf(_L("\n")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
666 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
667 |
TInt orgSessionCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
668 |
r = controlIo(TheFs,theDrive, KControlIoSessionCount, orgSessionCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
669 |
test(r==KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
670 |
test.Printf(_L("Session count start=%d\n"),orgSessionCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
671 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
672 |
TInt orgObjectCount; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
673 |
r = controlIo(TheFs,theDrive, KControlIoObjectCount, orgObjectCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
674 |
test(r==KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
675 |
test.Printf(_L("Object count start=%d\n"),orgObjectCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
676 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
677 |
|
0 | 678 |
TPckgBuf<TIOCacheValues> pkgOrgValues; |
679 |
TIOCacheValues& orgValues=pkgOrgValues(); |
|
680 |
r = controlIo(TheFs,theDrive, KControlIoCacheCount, orgValues); |
|
681 |
test_KErrNone(r); |
|
682 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
683 |
test.Printf(_L("Requests at start: CloseQ %d FreeQ %d total %d peak %d\n"), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
684 |
orgValues.iCloseCount, orgValues.iFreeCount, orgValues.iTotalCount, orgValues.iRequestCountPeak); |
0 | 685 |
|
686 |
// File cache |
|
687 |
||
688 |
// flush closed files queue |
|
689 |
r = TheFs.ControlIo(theDrive, KControlIoFlushClosedFiles); |
|
690 |
test_KErrNone(r); |
|
691 |
||
692 |
// get number of items on File Cache |
|
693 |
TFileCacheStats startFileCacheStats; |
|
694 |
r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, startFileCacheStats); |
|
695 |
test_Value(r, r == KErrNone || r == KErrNotSupported); |
|
696 |
test.Printf(_L("File cache: Cachelines (free %d, used %d), Segments(allocated %d locked %d). Closed files(%d)\n"), |
|
697 |
startFileCacheStats.iFreeCount, |
|
698 |
startFileCacheStats.iUsedCount, |
|
699 |
startFileCacheStats.iAllocatedSegmentCount, |
|
700 |
startFileCacheStats.iLockedSegmentCount, |
|
701 |
startFileCacheStats.iFilesOnClosedQueue); |
|
702 |
#endif |
|
703 |
||
704 |
DoTests(theDrive); |
|
705 |
||
706 |
TTime endTimeC; |
|
707 |
endTimeC.HomeTime(); |
|
708 |
TTimeIntervalSeconds timeTakenC; |
|
709 |
r=endTimeC.SecondsFrom(timerC,timeTakenC); |
|
710 |
test_KErrNone(r); |
|
711 |
test.Printf(_L("Time taken for test = %d seconds\n"),timeTakenC.Int()); |
|
712 |
TheFs.SetAllocFailure(gAllocFailOff); |
|
713 |
||
714 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
715 |
// Close and then re-open the main file server session to force the closure of |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
716 |
// any sub-sessions which may have been left open.... |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
717 |
// NB: This won't help if the test has opened another session & left sub-sessions open. |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
718 |
TheFs.Close(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
719 |
r=TheFs.Connect(); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
720 |
test(r==KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
721 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
722 |
// Display the file cache stats before closing the file queue |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
723 |
TFileCacheStats endFileCacheStats; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
724 |
r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, endFileCacheStats); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
725 |
test_Value(r, r == KErrNone || r == KErrNotSupported); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
726 |
test.Printf(_L("File cache: Cachelines (free %d, used %d), Segments(allocated %d locked %d). Closed files(%d)\n"), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
727 |
endFileCacheStats.iFreeCount, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
728 |
endFileCacheStats.iUsedCount, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
729 |
endFileCacheStats.iAllocatedSegmentCount, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
730 |
endFileCacheStats.iLockedSegmentCount, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
731 |
endFileCacheStats.iFilesOnClosedQueue); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
732 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
733 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
734 |
// Wait up to 3 seconds for all file server sessions & objects to close |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
735 |
// and then test session & object counts haven't changed |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
736 |
TInt endSessionCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
737 |
TInt endObjectCount = 0; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
738 |
for (TInt n=0; n<3; n++) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
739 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
740 |
// Flush the closed files queue as a file-cache object on the closed queue is counted as an open object |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
741 |
test.Printf(_L("Flushing close queue...\n")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
742 |
r = TheFs.ControlIo(theDrive, KControlIoFlushClosedFiles); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
743 |
test_KErrNone(r); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
744 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
745 |
r = controlIo(TheFs,theDrive, KControlIoSessionCount, endSessionCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
746 |
test(r==KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
747 |
test.Printf(_L("Session count end=%d\n"),endSessionCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
748 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
749 |
r = controlIo(TheFs,theDrive, KControlIoObjectCount, endObjectCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
750 |
test(r==KErrNone); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
751 |
test.Printf(_L("Object count end=%d\n"),endObjectCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
752 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
753 |
if (endSessionCount == orgSessionCount && endObjectCount == orgObjectCount) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
754 |
break; |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
755 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
756 |
test.Printf(_L("Warning: Session/object count leak\n")); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
757 |
User::After(1000000); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
758 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
759 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
760 |
// some tests don't close their sessions, so this test won't work until |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
761 |
// all the tests are fixed : |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
762 |
// test(endSessionCount == orgSessionCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
763 |
// test(endObjectCount == orgObjectCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
764 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
765 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
766 |
// Test that the File cache hasn't leaked .... |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
767 |
r = controlIo(TheFs,theDrive, KControlIoFileCacheStats, endFileCacheStats); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
768 |
test_Value(r, r == KErrNone || r == KErrNotSupported); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
769 |
test.Printf(_L("File cache: Cachelines (free %d, used %d), Segments(allocated %d locked %d). Closed files(%d)\n"), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
770 |
endFileCacheStats.iFreeCount, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
771 |
endFileCacheStats.iUsedCount, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
772 |
endFileCacheStats.iAllocatedSegmentCount, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
773 |
endFileCacheStats.iLockedSegmentCount, |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
774 |
endFileCacheStats.iFilesOnClosedQueue); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
775 |
if (r == KErrNone) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
776 |
{ |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
777 |
test(startFileCacheStats.iFreeCount == endFileCacheStats.iFreeCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
778 |
test(startFileCacheStats.iUsedCount == endFileCacheStats.iUsedCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
779 |
test(startFileCacheStats.iAllocatedSegmentCount == endFileCacheStats.iAllocatedSegmentCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
780 |
test(startFileCacheStats.iLockedSegmentCount == endFileCacheStats.iLockedSegmentCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
781 |
test(startFileCacheStats.iFileCount == endFileCacheStats.iFileCount); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
782 |
} |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
783 |
#endif |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
784 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
785 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
786 |
|
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
787 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
788 |
// Test that the request allocator hasn't leaked... |
0 | 789 |
TPckgBuf<TIOCacheValues> pkgValues; |
790 |
TIOCacheValues& values=pkgValues(); |
|
791 |
r = controlIo(TheFs,theDrive, KControlIoCacheCount, values); |
|
792 |
test_KErrNone(r); |
|
793 |
||
90
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
794 |
test.Printf(_L("Requests at end: CloseQ %d FreeQ %d total %d peak %d\n"), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
795 |
values.iCloseCount, values.iFreeCount, values.iTotalCount, values.iRequestCountPeak); |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
796 |
test.Printf(_L("Operations at end: FreeQ %d total %d peak=%d\n"), |
947f0dc9f7a8
Revision: 201015
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
797 |
values.iOpFreeCount, values.iOpRequestCount, values.iOpRequestCountPeak); |
0 | 798 |
|
799 |
test(orgValues.iCloseCount==values.iCloseCount); |
|
800 |
test(orgValues.iAllocated == values.iAllocated); |
|
801 |
// The free count can increase if the file server runs out of requests in the RequestAllocator |
|
802 |
// free pool but this should never decrease - this implies a request leak |
|
803 |
test(orgValues.iFreeCount <= values.iFreeCount); |
|
804 |
||
805 |
// The total number of allocated requests should be equal to : |
|
806 |
// requests on the close queue + requests on free queue |
|
807 |
// + 1 (because we used one request to issue KControlIoCacheCount) |
|
808 |
// If this doesn't equate then this implies a request leak |
|
809 |
test(values.iTotalCount == values.iCloseCount + values.iFreeCount + 1); |
|
810 |
#endif |
|
811 |
||
812 |
TheFs.Close(); |
|
813 |
test.End(); |
|
814 |
test.Close(); |
|
815 |
__UHEAP_MARKEND; |
|
816 |
delete cleanup; |
|
817 |
return(KErrNone); |
|
818 |
} |
|
819 |
||
820 |