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