author | Mike Kinghan <mikek@symbian.org> |
Thu, 25 Nov 2010 14:35:45 +0000 | |
branch | GCC_SURGE |
changeset 305 | 1ba12ef4ef89 |
parent 201 | 43365a9b78a3 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1995-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_filecache.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
#define __E32TEST_EXTENSION__ |
|
18 |
#include <f32file.h> |
|
19 |
#include <e32test.h> |
|
20 |
#include <e32svr.h> |
|
21 |
#include <f32dbg.h> |
|
22 |
#include "t_server.h" |
|
23 |
#include <e32twin.h> |
|
24 |
#include <e32rom.h> |
|
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
25 |
#include <u32hal.h> |
0 | 26 |
|
27 |
||
28 |
//---------------------------------------------------------------------------------------------- |
|
29 |
//! @SYMTestCaseID PBASE-T_FILECACHE-0189 |
|
30 |
//! @SYMTestType UT |
|
31 |
//! @SYMPREQ PREQ914 |
|
32 |
//! @SYMTestCaseDesc Unit tests for fair scheduling, read caching and lazy writing |
|
33 |
//! @SYMTestActions 0 setup the environment to execute the tests |
|
34 |
//! 1 Reads a file with different blocksizes |
|
35 |
//! 2 Write a file with different blocksizes |
|
36 |
//! 3 Small reads while controlling the cache |
|
37 |
//! 4 Read operations with and without read ahead |
|
38 |
//! 5 Write operations with write buffer |
|
39 |
//! @SYMTestExpectedResults finishes if the implementation of PREQ914 behaves as expected, panics otherwise |
|
40 |
//! @SYMTestPriority High |
|
41 |
//! @SYMTestStatus Critical |
|
42 |
//---------------------------------------------------------------------------------------------- |
|
43 |
||
44 |
||
45 |
//#define SYMBIAN_TEST_EXTENDED_BUFFER_SIZES |
|
46 |
||
47 |
||
48 |
GLDEF_D RTest test(_L("T_FILECACHE")); |
|
49 |
||
50 |
GLDEF_D RFs TheFs; |
|
51 |
GLDEF_D TChar gDriveToTest; |
|
52 |
GLDEF_D TInt gDrive; |
|
53 |
GLDEF_D TFileName gSessionPath; |
|
54 |
||
55 |
GLDEF_D TVolumeInfo gVolInfo; // volume info for current drive |
|
56 |
GLDEF_D TFileCacheFlags gDriveCacheFlags = TFileCacheFlags(0); |
|
57 |
||
58 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
59 |
static TFileCacheConfig gFileCacheConfig; |
|
60 |
static TBool gDisplayCacheFlags = EFalse; |
|
61 |
static TBool gWriteCacheFlags = EFalse; |
|
62 |
static TBool gRomPaged = EFalse; |
|
63 |
#endif |
|
64 |
static TBool gRunTests = ETrue; |
|
65 |
static TBool gRunUnitTests = ETrue; |
|
66 |
static TBool gRunPerformanceTests = EFalse; |
|
67 |
static TBool gRunManualTests = EFalse; |
|
68 |
||
69 |
||
70 |
LOCAL_D TInt KMaxFileSize = 768 * 1024; |
|
71 |
||
72 |
// Chosing a file size of 128K ensures entire file will be cached |
|
73 |
//LOCAL_D TInt KMaxFileSize = 128 * 1024; |
|
74 |
||
75 |
LOCAL_D TBuf8<256*1024> DataBuf; |
|
76 |
||
77 |
const TInt KBufSize = 513 * 1024 - 16; |
|
78 |
HBufC8* gBuf = NULL; |
|
79 |
||
80 |
||
81 |
LOCAL_D TPtr8 gBufPtr(NULL, 0); |
|
82 |
||
83 |
const TReal KOneK = 1024; |
|
84 |
const TReal KOneMeg = 1024 * KOneK; |
|
85 |
||
86 |
const TInt KSegmentSize = 4096; |
|
87 |
const TInt KSegmentSizeMask = (4096-1); |
|
88 |
||
89 |
GLDEF_D template <class C> |
|
90 |
GLDEF_C TInt controlIo(RFs &fs, TInt drv, TInt fkn, C &c) |
|
91 |
{ |
|
92 |
TPtr8 ptrC((TUint8 *)&c, sizeof(C), sizeof(C)); |
|
93 |
||
94 |
TInt r = fs.ControlIo(drv, fkn, ptrC); |
|
95 |
||
96 |
return r; |
|
97 |
} |
|
98 |
||
99 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
100 |
void PrintFileCacheStats(TFileCacheStats& fileCacheStats, TBool aDisplay = ETrue) |
|
101 |
{ |
|
102 |
TInt r = controlIo(TheFs,gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
103 |
test_KErrNone(r); |
|
104 |
if (!aDisplay) |
|
105 |
return; |
|
106 |
test.Printf(_L("File cache: Cachelines (free %d, used %d), Segments(allocated %d locked %d). Closed files(%d) Holes %d Failures (commit %d Lock %d)\n"), |
|
107 |
fileCacheStats.iFreeCount, fileCacheStats.iUsedCount, fileCacheStats.iAllocatedSegmentCount,fileCacheStats.iLockedSegmentCount,fileCacheStats.iFilesOnClosedQueue, fileCacheStats.iHoleCount, fileCacheStats.iCommitFailureCount, fileCacheStats.iLockFailureCount); |
|
108 |
test.Printf(_L("File cache: iUncachedPacketsRead %d iUncachedBytesRead %d iUncachedPacketsWritten %d iUncachedBytesWritten %d\n"), |
|
109 |
fileCacheStats.iUncachedPacketsRead, |
|
110 |
fileCacheStats.iUncachedBytesRead, |
|
111 |
fileCacheStats.iUncachedPacketsWritten, |
|
112 |
fileCacheStats.iUncachedBytesWritten); |
|
113 |
} |
|
114 |
||
115 |
void PrintFileCacheConfig(TFileCacheConfig& aFileCacheConfig, TBool aDisplay = ETrue) |
|
116 |
{ |
|
117 |
TInt r = controlIo(TheFs,gDrive, KControlIoFileCacheConfig, aFileCacheConfig); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
test_KErrNone(r); |
0 | 119 |
if (!aDisplay) |
120 |
return; |
|
121 |
||
122 |
test.Printf(_L("File cache:\nDrive %c\nFlags %08X\nFileCacheReadAsync %d\nFairSchedulingLen %d\nCacheSize %d\nMaxReadAheadLen %d\nClosedFileKeepAliveTime %d\nDirtyDataFlushTime %d"), |
|
123 |
aFileCacheConfig.iDrive + 'A', |
|
124 |
aFileCacheConfig.iFlags, |
|
125 |
aFileCacheConfig.iFileCacheReadAsync, |
|
126 |
aFileCacheConfig.iFairSchedulingLen, |
|
127 |
aFileCacheConfig.iCacheSize, |
|
128 |
aFileCacheConfig.iMaxReadAheadLen, |
|
129 |
aFileCacheConfig.iClosedFileKeepAliveTime, |
|
130 |
aFileCacheConfig.iDirtyDataFlushTime); |
|
131 |
||
132 |
} |
|
133 |
||
134 |
void TestDirtyDataWrittenToDisk(TFileCacheStats& fileCacheStats) |
|
135 |
{ |
|
136 |
test.Next(_L("test dirty data has been written to disk")); |
|
137 |
// wait a maximum of double KDefaultDirtyDataFlushTime for dirty data to be flushed |
|
138 |
const TInt KWaitTime = 250; // 250 milisecs |
|
139 |
for (TInt n=0; n<(gFileCacheConfig.iDirtyDataFlushTime/1000)<<1 ; n+= KWaitTime) |
|
140 |
{ |
|
141 |
test.Printf(_L("After %d milisecs : "), n ); |
|
142 |
PrintFileCacheStats(fileCacheStats); |
|
143 |
User::After(KWaitTime * 1000); // wait 100 ms |
|
144 |
if (fileCacheStats.iLockedSegmentCount == 0) |
|
145 |
break; |
|
146 |
} |
|
147 |
PrintFileCacheStats(fileCacheStats); |
|
148 |
test(fileCacheStats.iLockedSegmentCount == 0); |
|
149 |
} |
|
150 |
#endif |
|
151 |
||
152 |
void TestsInit() |
|
153 |
{ |
|
154 |
gBuf = HBufC8::NewL(KBufSize); |
|
155 |
test(gBuf!=NULL); |
|
156 |
gBufPtr.Set(gBuf->Des()); |
|
157 |
} |
|
158 |
void TestsEnd() |
|
159 |
{ |
|
160 |
delete gBuf; |
|
161 |
gBuf = NULL; |
|
162 |
} |
|
163 |
||
164 |
LOCAL_C void SetSessionPath(TInt aDrive) |
|
165 |
{ |
|
166 |
gSessionPath=_L("?:\\F32-TST\\"); |
|
167 |
TChar driveLetter; |
|
168 |
TInt r=TheFs.DriveToChar(aDrive,driveLetter); |
|
169 |
test_KErrNone(r); |
|
170 |
gSessionPath[0]=(TText)driveLetter; |
|
171 |
r=TheFs.SetSessionPath(gSessionPath); |
|
172 |
test_KErrNone(r); |
|
173 |
} |
|
174 |
||
175 |
LOCAL_C void PrintFileMode(TUint aFileMode) |
|
176 |
{ |
|
177 |
TBuf<80> buf; |
|
178 |
||
179 |
buf.Format(_L("FileMode = %08X"), aFileMode); |
|
180 |
||
181 |
if (aFileMode & EFileWriteBuffered) |
|
182 |
buf.Append(_L(", EFileWriteBuffered")); |
|
183 |
||
184 |
if (aFileMode & EFileWriteDirectIO) |
|
185 |
buf.Append(_L(", EFileWriteDirectIO")); |
|
186 |
||
187 |
if (aFileMode & EFileReadBuffered) |
|
188 |
buf.Append(_L(", EFileReadBuffered")); |
|
189 |
||
190 |
if (aFileMode & EFileReadDirectIO) |
|
191 |
buf.Append(_L(", EFileReadDirectIO")); |
|
192 |
||
193 |
if (aFileMode & EFileReadAheadOn) |
|
194 |
buf.Append(_L(", EFileReadAheadOn")); |
|
195 |
||
196 |
if (aFileMode & EFileReadAheadOff) |
|
197 |
buf.Append(_L(", EFileReadAheadOff")); |
|
198 |
||
199 |
buf.Append(_L("\n")); |
|
200 |
test.Printf(buf); |
|
201 |
} |
|
202 |
||
203 |
void FillBuffer(TDes8& aBuffer, TInt aLength) |
|
204 |
{ |
|
205 |
test (aBuffer.MaxLength() >= aLength); |
|
206 |
for(TInt i=0; i<aLength; i+=2) |
|
207 |
{ |
|
208 |
aBuffer[i]=(TUint8) (i >> 8); |
|
209 |
aBuffer[i+1]=(TUint8) i; |
|
210 |
} |
|
211 |
} |
|
212 |
||
213 |
void TestBufferFail(TDes8& aBuffer, TInt aPos, TInt aLength) |
|
214 |
{ |
|
215 |
test.Printf(_L("TestBuffer failed at pos %d len %d\n"), aPos, aLength); |
|
216 |
||
217 |
#define PRINTCH(ch) ((ch >= 0x20 && ch < 0x7F)?ch:' ') |
|
218 |
TInt startPos = Max(0, aPos - 64); |
|
219 |
TInt endPos = startPos + 64; |
|
220 |
||
221 |
for(TInt n=startPos; n<=endPos; n+=16) |
|
222 |
RDebug::Print(_L("%08X: %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X [%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c]"), |
|
223 |
//&aBuffer[aPos+n], |
|
224 |
n, |
|
225 |
aBuffer[n+0], aBuffer[n+1], aBuffer[n+2], aBuffer[n+3], aBuffer[n+4], aBuffer[n+5], aBuffer[n+6], aBuffer[n+7], aBuffer[n+8], aBuffer[n+9], aBuffer[n+10], aBuffer[n+11], aBuffer[n+12], aBuffer[n+13], aBuffer[n+14], aBuffer[n+15], |
|
226 |
PRINTCH(aBuffer[n+0]), PRINTCH(aBuffer[n+1]), PRINTCH(aBuffer[n+2]), PRINTCH(aBuffer[n+3]), PRINTCH(aBuffer[n+4]), PRINTCH(aBuffer[n+5]), PRINTCH(aBuffer[n+6]), PRINTCH(aBuffer[n+7]), PRINTCH(aBuffer[n+8]), PRINTCH(aBuffer[n+9]), PRINTCH(aBuffer[n+10]), PRINTCH(aBuffer[n+11]), PRINTCH(aBuffer[n+12]), PRINTCH(aBuffer[n+13]), PRINTCH(aBuffer[n+14]), PRINTCH(aBuffer[n+15])); |
|
227 |
||
228 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
229 |
TInt x; |
|
230 |
TInt r = controlIo(TheFs,gDrive, KControlIoFileCacheDump, x); |
|
231 |
test_KErrNone(r); |
|
232 |
#endif |
|
233 |
test (0); |
|
234 |
} |
|
235 |
||
236 |
void TestBuffer(TDes8& aBuffer, TInt aPos, TInt aLength) |
|
237 |
{ |
|
238 |
TInt pos = aPos; |
|
239 |
for(TInt i=0; i<aLength; i++, pos++) |
|
240 |
{ |
|
241 |
if (pos & 1) |
|
242 |
{ |
|
243 |
if (aBuffer[pos] != (TUint8) pos-1) |
|
244 |
TestBufferFail(aBuffer, pos, aLength); |
|
245 |
} |
|
246 |
else |
|
247 |
{ |
|
248 |
if (aBuffer[pos] != (TUint8) (pos >> 8)) |
|
249 |
TestBufferFail(aBuffer, pos, aLength); |
|
250 |
} |
|
251 |
} |
|
252 |
} |
|
253 |
||
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
254 |
TInt FreeRam() |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
255 |
{ |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
256 |
// wait for any async cleanup in the supervisor to finish first... |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
257 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
258 |
|
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
259 |
TMemoryInfoV1Buf meminfo; |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
260 |
UserHal::MemoryInfo(meminfo); |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
261 |
return meminfo().iFreeRamInBytes; |
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
262 |
} |
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
263 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
264 |
void LowMemoryTest() |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
265 |
{ |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
266 |
TInt fileSize = 0; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
267 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
268 |
const TInt KWriteLen = 128*1024; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
269 |
test.Next(_L("Test appending to a file with low memory")); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
270 |
gBufPtr.SetLength(KBufSize); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
271 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
272 |
RFile f; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
273 |
TFileName testFile = _L("TEST.BIN"); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
274 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
275 |
TInt r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteBuffered); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
276 |
test_KErrNone(r); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
277 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
278 |
TInt pos = 0; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
279 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
280 |
TPtrC8 writePtr; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
281 |
writePtr.Set(gBufPtr.MidTPtr(pos, KWriteLen)); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
282 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
283 |
r = f.Write(pos, writePtr); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
284 |
test_KErrNone(r); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
285 |
pos+= writePtr.Length(); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
286 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
287 |
r = f.Size(fileSize); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
288 |
test_KErrNone(r); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
289 |
test_Equal(fileSize,pos); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
290 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
291 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
292 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
293 |
TUint freeRam = FreeRam(); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
294 |
const TInt KPageSize=4096; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
295 |
freeRam = (freeRam + KPageSize -1) & ~(KPageSize-1); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
296 |
test.Printf(_L("FreeRam = %d"), freeRam); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
297 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
298 |
RChunk chunk; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
299 |
TChunkCreateInfo chunkInfo; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
300 |
chunkInfo.SetDisconnected(0, 0, freeRam); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
301 |
chunkInfo.SetPaging(TChunkCreateInfo::EUnpaged); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
302 |
test_KErrNone(chunk.Create(chunkInfo)); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
303 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
304 |
test.Printf(_L("Gobbling all of memory...")); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
305 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
306 |
TUint commitEnd; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
307 |
for (commitEnd = 0; commitEnd < freeRam; commitEnd += KPageSize) |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
308 |
{ |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
309 |
r = chunk.Commit(commitEnd,KPageSize); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
310 |
if (r != KErrNone) |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
311 |
break; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
312 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
313 |
} |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
314 |
test.Printf(_L("commitEnd %d, r %d"), commitEnd, r); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
315 |
test_Value(r, r == KErrNoMemory || r == KErrNone); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
316 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
317 |
test.Printf(_L("FreeRam = %d"), FreeRam()); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
318 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
319 |
pos-= KSegmentSize; |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
320 |
writePtr.Set(gBufPtr.MidTPtr(pos, KWriteLen)); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
321 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
322 |
test.Printf(_L("Writing to file...")); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
323 |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
324 |
// now we have gobbled all or most of memory, the next write can fail |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
325 |
// if it does keep decommitting memory until it succeeds and then test that the file size is correct |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
326 |
commitEnd = 0; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
327 |
do { |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
328 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
329 |
r = f.Write(pos, writePtr); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
330 |
test_Value(r, r == KErrNoMemory || r == KErrNone); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
331 |
if (r == KErrNoMemory) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
332 |
{ |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
333 |
chunk.Decommit(commitEnd,KPageSize); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
334 |
commitEnd += KPageSize; |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
335 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
336 |
} |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
337 |
while (r == KErrNoMemory); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
338 |
|
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
339 |
pos+= writePtr.Length(); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
340 |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
341 |
test.Printf(_L("Gsetting size of file ...")); |
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
342 |
r = f.Size(fileSize); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
343 |
test_KErrNone(r); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
344 |
test_Equal(fileSize,pos); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
345 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
346 |
test.Printf(_L("Closing file ...")); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
347 |
f.Close(); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
348 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
349 |
test.Printf(_L("Closing chunk ...")); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
350 |
chunk.Close(); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
351 |
|
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
352 |
test.Printf(_L("FreeRam = %d"), FreeRam()); |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
353 |
} |
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
354 |
|
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
355 |
|
0 | 356 |
|
357 |
LOCAL_C void UnitTests() |
|
358 |
// |
|
359 |
// Test read file handling. |
|
360 |
// |
|
361 |
{ |
|
362 |
||
363 |
test.Start(_L("File cache read and write unit tests")); |
|
364 |
||
365 |
//TheFs.SetDebugRegister(KCACHE); |
|
366 |
||
367 |
RFile f; |
|
368 |
TInt r; |
|
369 |
TInt pos; |
|
370 |
TInt len; |
|
371 |
TInt testNum; |
|
372 |
||
373 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
374 |
TBool simulatelockFailureMode; |
|
375 |
TFileCacheStats fileCacheStats; |
|
376 |
r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
377 |
test_KErrNone(r); |
0 | 378 |
test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue); |
379 |
test(fileCacheStats.iFilesOnClosedQueue == 0); |
|
380 |
#endif |
|
381 |
||
382 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
383 |
// turn OFF lock failure mode |
|
384 |
simulatelockFailureMode = EFalse; |
|
385 |
r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
386 |
test_KErrNone(r); |
0 | 387 |
#endif |
388 |
||
389 |
TFileName testFile = _L("TEST.BIN"); |
|
390 |
||
391 |
//********************************** |
|
392 |
// Test Read-Modify-Write |
|
393 |
//********************************** |
|
394 |
test.Next(_L("Test read-modify-write")); |
|
395 |
gBufPtr.SetLength(KBufSize); |
|
396 |
FillBuffer(gBufPtr, KBufSize); |
|
397 |
TestBuffer(gBufPtr, 0,KBufSize); |
|
398 |
TPtrC8 writePtr; |
|
399 |
TPtr8 readPtr(gBuf->Des()); |
|
400 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
401 |
TInt uncachedBytesRead; |
|
402 |
TInt uncachedPacketsRead; |
|
403 |
#endif |
|
404 |
||
152
657f875b013e
Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
139
diff
changeset
|
405 |
LowMemoryTest(); |
139
95f71bcdcdb7
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
109
diff
changeset
|
406 |
|
0 | 407 |
// create an empty file, so that any writes overlapping segemt boundaries |
408 |
// need a read first |
|
409 |
// create a test file using directIO and then re-open it in buffered mode, |
|
410 |
// so that any writes overlapping segemt boundaries need a read first |
|
411 |
r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteDirectIO); |
|
412 |
test_KErrNone(r); |
|
413 |
writePtr.Set(gBuf->Des()); |
|
414 |
r = f.Write(0, writePtr); |
|
415 |
test_KErrNone(r); |
|
416 |
f.Close(); |
|
417 |
r = f.Open(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered); |
|
418 |
test_KErrNone(r); |
|
419 |
||
420 |
TInt cacheLineLen = 128*1024; |
|
421 |
||
422 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
423 |
PrintFileCacheStats(fileCacheStats); |
|
424 |
uncachedBytesRead = fileCacheStats.iUncachedBytesRead; |
|
425 |
uncachedPacketsRead = fileCacheStats.iUncachedPacketsRead; |
|
426 |
#endif |
|
427 |
||
428 |
// write 1 partial segment at offset 0 to 7 in segment |
|
429 |
test.Next(_L("Test read-modify-write #1")); |
|
430 |
pos = cacheLineLen*0 + KSegmentSize*2 + 0; |
|
431 |
len = 7; |
|
432 |
writePtr.Set(gBuf->Mid(pos, len)); |
|
433 |
r = f.Write(pos, writePtr, len); |
|
434 |
test_KErrNone(r); |
|
435 |
// read back & verify whole segment |
|
436 |
pos&= ~KSegmentSizeMask; len = (len + KSegmentSize-1) & ~KSegmentSizeMask; |
|
437 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
438 |
readPtr.SetLength(len); |
|
439 |
readPtr.FillZ(); |
|
440 |
r = f.Read(pos, readPtr, len); |
|
441 |
test_KErrNone(r); |
|
442 |
TestBuffer(gBufPtr, pos, len); |
|
443 |
test_KErrNone(r); |
|
444 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
445 |
PrintFileCacheStats(fileCacheStats); |
|
446 |
test (fileCacheStats.iUncachedBytesRead - uncachedBytesRead == KSegmentSize); |
|
447 |
test (fileCacheStats.iUncachedPacketsRead - uncachedPacketsRead == 1); |
|
448 |
uncachedBytesRead = fileCacheStats.iUncachedBytesRead; |
|
449 |
uncachedPacketsRead = fileCacheStats.iUncachedPacketsRead; |
|
450 |
#endif |
|
451 |
||
452 |
// write 1 partial segment at offset 7 to 4096 in segment |
|
453 |
test.Next(_L("Test read-modify-write #2")); |
|
454 |
pos = cacheLineLen*0 + KSegmentSize*3 + 7; |
|
455 |
len = KSegmentSize - 7; |
|
456 |
writePtr.Set(gBuf->Mid(pos, len)); |
|
457 |
r = f.Write(pos, writePtr, len); |
|
458 |
test_KErrNone(r); |
|
459 |
// read back & verify whole segment |
|
460 |
pos&= ~KSegmentSizeMask; len = (len + KSegmentSize-1) & ~KSegmentSizeMask; |
|
461 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
462 |
readPtr.SetLength(len); |
|
463 |
readPtr.FillZ(); |
|
464 |
r = f.Read(pos, readPtr, len); |
|
465 |
test_KErrNone(r); |
|
466 |
TestBuffer(gBufPtr, pos, len); |
|
467 |
test_KErrNone(r); |
|
468 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
469 |
PrintFileCacheStats(fileCacheStats); |
|
470 |
test (fileCacheStats.iUncachedBytesRead - uncachedBytesRead == KSegmentSize); |
|
471 |
test (fileCacheStats.iUncachedPacketsRead - uncachedPacketsRead == 1); |
|
472 |
uncachedBytesRead = fileCacheStats.iUncachedBytesRead; |
|
473 |
uncachedPacketsRead = fileCacheStats.iUncachedPacketsRead; |
|
474 |
#endif |
|
475 |
||
476 |
// write 1 partial segment at offset 7 to 37 in segment |
|
477 |
test.Next(_L("Test read-modify-write #3")); |
|
478 |
pos = cacheLineLen*0 + KSegmentSize*4 + 7; |
|
479 |
len = 30; |
|
480 |
writePtr.Set(gBuf->Mid(pos, len)); |
|
481 |
r = f.Write(pos, writePtr, len); |
|
482 |
test_KErrNone(r); |
|
483 |
// read back & verify whole segment |
|
484 |
pos&= ~KSegmentSizeMask; len = (len + KSegmentSize-1) & ~KSegmentSizeMask; |
|
485 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
486 |
readPtr.SetLength(len); |
|
487 |
readPtr.FillZ(); |
|
488 |
r = f.Read(pos, readPtr, len); |
|
489 |
test_KErrNone(r); |
|
490 |
TestBuffer(gBufPtr, pos, len); |
|
491 |
test_KErrNone(r); |
|
492 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
493 |
PrintFileCacheStats(fileCacheStats); |
|
494 |
test (fileCacheStats.iUncachedBytesRead - uncachedBytesRead == KSegmentSize); |
|
495 |
test (fileCacheStats.iUncachedPacketsRead - uncachedPacketsRead == 1); |
|
496 |
uncachedBytesRead = fileCacheStats.iUncachedBytesRead; |
|
497 |
uncachedPacketsRead = fileCacheStats.iUncachedPacketsRead; |
|
498 |
#endif |
|
499 |
||
500 |
// write 2 segments, first and last both partial |
|
501 |
test.Next(_L("Test read-modify-write #4")); |
|
502 |
pos = cacheLineLen*1 + KSegmentSize*2 + 3; |
|
503 |
len = KSegmentSize * 1; |
|
504 |
writePtr.Set(gBuf->Mid(pos, len)); |
|
505 |
r = f.Write(pos, writePtr, len); |
|
506 |
test_KErrNone(r); |
|
507 |
// read back & verify whole segment |
|
508 |
pos&= ~KSegmentSizeMask; len = (len + KSegmentSize-1) & ~KSegmentSizeMask; |
|
509 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
510 |
readPtr.SetLength(len); |
|
511 |
readPtr.FillZ(); |
|
512 |
r = f.Read(pos, readPtr, len); |
|
513 |
test_KErrNone(r); |
|
514 |
TestBuffer(gBufPtr, pos, len); |
|
515 |
test_KErrNone(r); |
|
516 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
517 |
PrintFileCacheStats(fileCacheStats); |
|
518 |
test (fileCacheStats.iUncachedBytesRead - uncachedBytesRead == KSegmentSize*2); |
|
519 |
// should read both segments in one read as they are contiguous |
|
520 |
test (fileCacheStats.iUncachedPacketsRead - uncachedPacketsRead == 1); |
|
521 |
uncachedBytesRead = fileCacheStats.iUncachedBytesRead; |
|
522 |
uncachedPacketsRead = fileCacheStats.iUncachedPacketsRead; |
|
523 |
#endif |
|
524 |
||
525 |
// write 3 segments, first and last both partial |
|
526 |
test.Next(_L("Test read-modify-write #5")); |
|
527 |
pos = cacheLineLen*2 + KSegmentSize*2 + 7; |
|
528 |
len = KSegmentSize * 2; |
|
529 |
writePtr.Set(gBuf->Mid(pos, len)); |
|
530 |
r = f.Write(pos, writePtr, len); |
|
531 |
test_KErrNone(r); |
|
532 |
// read back & verify whole segment |
|
533 |
pos&= ~KSegmentSizeMask; len = (len + KSegmentSize-1) & ~KSegmentSizeMask; |
|
534 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
535 |
readPtr.SetLength(len); |
|
536 |
readPtr.FillZ(); |
|
537 |
r = f.Read(pos, readPtr, len); |
|
538 |
test_KErrNone(r); |
|
539 |
TestBuffer(gBufPtr, pos, len); |
|
540 |
test_KErrNone(r); |
|
541 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
542 |
PrintFileCacheStats(fileCacheStats); |
|
543 |
test (fileCacheStats.iUncachedBytesRead - uncachedBytesRead == KSegmentSize*2); |
|
544 |
test (fileCacheStats.iUncachedPacketsRead - uncachedPacketsRead == 2); |
|
545 |
uncachedBytesRead = fileCacheStats.iUncachedBytesRead; |
|
546 |
uncachedPacketsRead = fileCacheStats.iUncachedPacketsRead; |
|
547 |
#endif |
|
548 |
||
549 |
f.Close(); |
|
550 |
||
551 |
//************************************************************** |
|
552 |
// Test dirty data NOT written to disk if continuously writing to a file which fits in tke cache |
|
553 |
//************************************************************** |
|
554 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
555 |
test.Printf(_L("Test dirty data NOT written to disk if continuously writing to a file which fits in tke cache...\n")); |
|
556 |
||
557 |
// flush closed files queue to empty cache |
|
558 |
test.Printf(_L("Flushing close queue to empty cache...\n")); |
|
559 |
r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles); |
|
560 |
test_KErrNone(r); |
|
561 |
||
562 |
r = f.Replace(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered); |
|
563 |
test_KErrNone(r); |
|
564 |
||
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
565 |
r = f.SetSize(gFileCacheConfig.iCacheSize); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
566 |
test_KErrNone(r); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
567 |
|
0 | 568 |
RTimer timer; |
569 |
timer.CreateLocal(); |
|
570 |
TRequestStatus reqStat; |
|
571 |
timer.After(reqStat,gFileCacheConfig.iClosedFileKeepAliveTime*3); // write 3 times the flush timer |
|
572 |
||
573 |
pos = 0; |
|
574 |
TInt bufLen = 7; |
|
575 |
TInt maxLockedSegmentCount = 0; |
|
576 |
while (reqStat == KRequestPending) |
|
577 |
{ |
|
578 |
bufLen = (bufLen + 1023) & 0x3FFF; |
|
579 |
len = Min(bufLen, KBufSize - pos); |
|
580 |
len = Min(len, gFileCacheConfig.iCacheSize-pos); |
|
581 |
TPtrC8 writePtr = gBuf->Mid(pos, len); |
|
582 |
r = f.Write(pos, writePtr, len); |
|
583 |
test_KErrNone(r); |
|
584 |
pos+= len; |
|
585 |
TInt r = controlIo(TheFs,gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
586 |
test_KErrNone(r); |
|
587 |
// test the locked (i.e. dirty) count always goes up & never down (down would indicate a flush) |
|
588 |
if (fileCacheStats.iLockedSegmentCount != maxLockedSegmentCount) |
|
589 |
test.Printf(_L("iLockedSegmentCount %d...\n"), fileCacheStats.iLockedSegmentCount); |
|
590 |
||
591 |
test(fileCacheStats.iLockedSegmentCount >= maxLockedSegmentCount); |
|
592 |
maxLockedSegmentCount = Max(maxLockedSegmentCount, fileCacheStats.iLockedSegmentCount); |
|
593 |
// wrap to start of file |
|
594 |
if (pos >= gFileCacheConfig.iCacheSize) |
|
595 |
pos = 0; |
|
596 |
} |
|
597 |
timer.Close(); |
|
598 |
||
599 |
test(fileCacheStats.iLockedSegmentCount > 0); |
|
600 |
||
601 |
if (gDriveCacheFlags & (EFileCacheWriteEnabled | EFileCacheWriteOn)) |
|
602 |
TestDirtyDataWrittenToDisk(fileCacheStats); |
|
603 |
f.Close(); |
|
604 |
#endif |
|
605 |
||
606 |
||
607 |
//************************************************************** |
|
608 |
// Test dirty data written to disk |
|
609 |
//************************************************************** |
|
610 |
enum {ETestDataWrittenAfterTimeout, ETestDataWrittenAfterFileClose, ETestDataWrittenAfterSessionClose, ETestEnd}; |
|
611 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
612 |
for (testNum = 0; testNum < ETestEnd; testNum++) |
|
613 |
#else |
|
614 |
for (testNum = 0; testNum < 1; testNum++) |
|
615 |
#endif |
|
616 |
{ |
|
617 |
switch(testNum) |
|
618 |
{ |
|
619 |
case ETestDataWrittenAfterTimeout : test.Next(_L("ETestDataWrittenAfterTimeout")); break; |
|
620 |
case ETestDataWrittenAfterFileClose : test.Next(_L("ETestDataWrittenAfterFileClose")); break; |
|
621 |
case ETestDataWrittenAfterSessionClose : test.Next(_L("ETestDataWrittenAfterSessionClose")); break; |
|
622 |
}; |
|
623 |
||
624 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
625 |
// flush closed files queue to empty cache |
|
626 |
test.Printf(_L("Flushing close queue to empty cache...\n")); |
|
627 |
r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles); |
|
628 |
test_KErrNone(r); |
|
629 |
#endif |
|
630 |
||
631 |
r = f.Replace(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered); |
|
632 |
test_KErrNone(r); |
|
633 |
||
634 |
||
635 |
gBufPtr.SetLength(KBufSize); |
|
636 |
||
637 |
test.Printf(_L("writing file in small blocks to test write caching...\n")); |
|
638 |
||
639 |
FillBuffer(gBufPtr, KBufSize); |
|
640 |
TestBuffer(gBufPtr, 0,KBufSize); |
|
641 |
||
642 |
pos = 0; |
|
643 |
TInt bufLen = 7; |
|
644 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
645 |
TInt maxLockedSegmentCount = 0; |
|
646 |
TInt maxUsedCount = 0; |
|
647 |
#endif |
|
648 |
while (pos < KBufSize) |
|
649 |
{ |
|
650 |
bufLen = (bufLen + 1023) & 0x3FFF; |
|
651 |
len = Min(bufLen, KBufSize - pos); |
|
652 |
//RDebug::Print(_L("write len %d"), len); |
|
653 |
TPtrC8 writePtr = gBuf->Mid(pos, len); |
|
654 |
r = f.Write(pos, writePtr, len); |
|
655 |
test_KErrNone(r); |
|
656 |
pos+= len; |
|
657 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
658 |
// PrintFileCacheStats(fileCacheStats); |
|
659 |
TInt r = controlIo(TheFs,gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
660 |
test_KErrNone(r); |
|
661 |
maxLockedSegmentCount = Max(maxLockedSegmentCount, fileCacheStats.iLockedSegmentCount); |
|
662 |
maxUsedCount = Max(maxUsedCount, fileCacheStats.iUsedCount); |
|
663 |
#endif |
|
664 |
} |
|
665 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
666 |
test.Next(_L("Test maxiimum locked page and cacheline count is reasonable")); |
|
667 |
test.Printf(_L("maxLockedSegmentCount %d maxUsedCount %d"), maxLockedSegmentCount, maxUsedCount); |
|
668 |
test (maxLockedSegmentCount > 0 && maxLockedSegmentCount <= (gFileCacheConfig.iCacheSize * 2) / KSegmentSize ); |
|
669 |
test (maxUsedCount > 0 && maxUsedCount <= 5); |
|
670 |
#endif |
|
671 |
||
672 |
||
673 |
||
674 |
if (testNum == ETestDataWrittenAfterTimeout) |
|
675 |
{ |
|
676 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
677 |
if (gDriveCacheFlags & (EFileCacheWriteEnabled | EFileCacheWriteOn)) |
|
678 |
TestDirtyDataWrittenToDisk(fileCacheStats); |
|
679 |
#endif |
|
680 |
f.Close(); |
|
681 |
} |
|
682 |
||
683 |
if (testNum == ETestDataWrittenAfterFileClose) |
|
684 |
{ |
|
685 |
f.Close(); |
|
686 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
687 |
test.Next(_L("test dirty data has been written to disk after file close")); |
|
688 |
PrintFileCacheStats(fileCacheStats); |
|
689 |
test(fileCacheStats.iLockedSegmentCount == 0); |
|
690 |
#endif |
|
691 |
} |
|
692 |
||
693 |
if (testNum == ETestDataWrittenAfterSessionClose) |
|
694 |
{ |
|
695 |
// verify that closing the file server session (i.e. not the file) |
|
696 |
// flushes the data to disk... |
|
697 |
// *** NB This is likely to complete sometime AFTER returning from RFs::Close() |
|
698 |
// *** as the file server doesn't wait for the disconnect thread to complete !!! |
|
699 |
||
700 |
TheFs.Close(); |
|
701 |
TheFs.Connect(); |
|
702 |
SetSessionPath(gDrive); |
|
703 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
704 |
test.Next(_L("Test dirty data is eventually written to disk after session close")); |
|
705 |
TestDirtyDataWrittenToDisk(fileCacheStats); |
|
706 |
test(fileCacheStats.iLockedSegmentCount == 0); |
|
707 |
#endif |
|
708 |
} |
|
709 |
||
710 |
} // for (TInt testNum = 0; testNum < ETestEnd; testNum++) |
|
711 |
||
712 |
||
713 |
//#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
714 |
// PrintFileCacheStats(fileCacheStats); |
|
715 |
//#endif |
|
716 |
||
717 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
718 |
// flush closed files queue to empty cache |
|
719 |
test.Printf(_L("Flushing close queue to empty cache...\n")); |
|
720 |
r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles); |
|
721 |
test_KErrNone(r); |
|
722 |
#endif |
|
723 |
||
724 |
r = f.Open(TheFs, testFile, EFileRead | EFileReadBuffered | EFileWrite); |
|
725 |
test_KErrNone(r); |
|
726 |
||
727 |
TInt size; |
|
728 |
r = f.Size(size); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
729 |
test_KErrNone(r); |
0 | 730 |
test (size = KBufSize); |
731 |
||
732 |
readPtr.Set(gBuf->Des()); |
|
733 |
||
734 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
735 |
// Allocate full cachelines - so we can enable hole testing |
|
736 |
TBool allocateAllSegmentsInCacheLine = ETrue; |
|
737 |
r = controlIo(TheFs, gDrive, KControlIoAllocateMaxSegments, allocateAllSegmentsInCacheLine); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
738 |
test_KErrNone(r); |
0 | 739 |
PrintFileCacheStats(fileCacheStats, EFalse); |
740 |
TInt holesDetected = fileCacheStats.iHoleCount; |
|
741 |
TInt lockFailures = fileCacheStats.iCommitFailureCount + fileCacheStats.iLockFailureCount; |
|
742 |
#endif |
|
743 |
||
744 |
test.Next(_L("Test reading a partially filled cacheline")); |
|
745 |
// create a cacheline with only the first segment filled |
|
746 |
TInt startPos = KSegmentSize; |
|
747 |
pos = startPos; |
|
748 |
len = KSegmentSize; |
|
749 |
writePtr.Set(gBuf->Mid(pos, len)); |
|
750 |
r = f.Write(pos, writePtr, len); |
|
751 |
test_KErrNone(r); |
|
752 |
||
753 |
// read from first & second segments |
|
754 |
pos = startPos; |
|
755 |
len = 8192; |
|
756 |
RDebug::Print(_L("+%x, %x\n"), pos, len); |
|
757 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
758 |
readPtr.SetLength(len); |
|
759 |
r = f.Read(pos, readPtr, len); |
|
760 |
test_KErrNone(r); |
|
761 |
TestBuffer(gBufPtr, pos, len); |
|
762 |
||
763 |
||
764 |
test.Next(_L("Test reading an empty segment towards the end of a partially filled cacheline (hole test)")); |
|
765 |
// read from segment #4 and beyond end of cacheline into next |
|
766 |
pos = startPos + KSegmentSize * 4; |
|
767 |
len = KSegmentSize * 33; // 132 K |
|
768 |
RDebug::Print(_L("+%x, %x\n"), pos, len); |
|
769 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
770 |
readPtr.SetLength(len); |
|
771 |
r = f.Read(pos, readPtr, len); |
|
772 |
test_KErrNone(r); |
|
773 |
TestBuffer(gBufPtr, pos, len); |
|
774 |
||
775 |
||
776 |
test.Next(_L("Test writing to an empty segment towards the end of a partially filled cacheline (hole test)")); |
|
777 |
// create a cacheline with only the first segment filled |
|
778 |
startPos = 256 * 1024; |
|
779 |
pos = startPos; |
|
780 |
len = KSegmentSize; |
|
781 |
writePtr.Set(gBuf->Mid(pos, len)); |
|
782 |
r = f.Write(pos, writePtr, len); |
|
783 |
test_KErrNone(r); |
|
784 |
||
785 |
||
786 |
// write into segment 3, 4 & 5 |
|
787 |
pos = startPos + KSegmentSize * 2; |
|
788 |
len = KSegmentSize * 3; |
|
789 |
writePtr.Set(gBuf->Mid(pos, len)); |
|
790 |
r = f.Write(pos, writePtr, len); |
|
791 |
test_KErrNone(r); |
|
792 |
// read back whole cacheline & verify |
|
793 |
pos = startPos; |
|
794 |
len = KSegmentSize * 32; // 128 K |
|
795 |
RDebug::Print(_L("+%x, %x\n"), pos, len); |
|
796 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
797 |
readPtr.SetLength(len); |
|
798 |
r = f.Read(pos, readPtr, len); |
|
799 |
test_KErrNone(r); |
|
800 |
TestBuffer(gBufPtr, pos, len); |
|
801 |
||
802 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
803 |
PrintFileCacheStats(fileCacheStats); |
|
804 |
if (fileCacheStats.iCommitFailureCount + fileCacheStats.iLockFailureCount != lockFailures) |
|
805 |
{ |
|
806 |
if (gRomPaged) |
|
807 |
{ |
|
808 |
test.Printf(_L("Lock failures detected on paged ROM, abandoning hole test")); |
|
809 |
} |
|
810 |
else |
|
811 |
{ |
|
812 |
test.Printf(_L("Unexpected lock failures detected on unpaged ROM!!!")); |
|
813 |
test(0); |
|
814 |
} |
|
815 |
} |
|
816 |
else |
|
817 |
{ |
|
818 |
test(fileCacheStats.iHoleCount > holesDetected); |
|
819 |
} |
|
820 |
// Don't allocate full cachelines any more |
|
821 |
allocateAllSegmentsInCacheLine = EFalse; |
|
822 |
r = controlIo(TheFs, gDrive, KControlIoAllocateMaxSegments, allocateAllSegmentsInCacheLine); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
823 |
test_KErrNone(r); |
0 | 824 |
#endif |
825 |
||
826 |
||
827 |
||
828 |
gBufPtr.FillZ(); |
|
829 |
gBufPtr.SetLength(KBufSize); |
|
830 |
||
831 |
||
832 |
||
833 |
readPtr.SetLength(0); |
|
834 |
||
835 |
||
836 |
// read from middle of fifth sector to half way thru seventh |
|
837 |
test.Next(_L("Test read that spans two pages")); |
|
838 |
pos = 512*4 + 16; |
|
839 |
len = 512*2; |
|
840 |
RDebug::Print(_L("+%x, %x\n"), pos, len); |
|
841 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
842 |
readPtr.SetLength(len); |
|
843 |
r = f.Read(pos, readPtr, len); |
|
844 |
test_KErrNone(r); |
|
845 |
TestBuffer(gBufPtr, pos, len); |
|
846 |
||
847 |
||
848 |
||
849 |
// read to end of file |
|
850 |
test.Next(_L("Test reading past end of file")); |
|
851 |
pos = KBufSize - 0x100; // 0xfb05; |
|
852 |
len = KBufSize - pos; |
|
853 |
// pos = KBufSize - 16; |
|
854 |
// len = 512;; |
|
855 |
// len = Min(len, KBufSize-pos); |
|
856 |
RDebug::Print(_L("+%x, %x\n"), pos, len); |
|
857 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
858 |
readPtr.SetLength(len); |
|
859 |
r = f.Read(pos, readPtr, len/* + 0x67*/); |
|
860 |
test_KErrNone(r); |
|
861 |
||
862 |
test.Next(_L("Test async reads")); |
|
863 |
// issue 2 async reads |
|
864 |
pos = KSegmentSize*7 + 16; |
|
865 |
len = KSegmentSize; |
|
866 |
RDebug::Print(_L("+%x, %x\n"), pos, len); |
|
867 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
868 |
readPtr.SetLength(len); |
|
869 |
||
870 |
TInt pos2 = pos + len; |
|
871 |
TInt len2 = KSegmentSize; |
|
872 |
TPtr8 readPtr2 = gBuf->Des(); |
|
873 |
readPtr2.Set(gBufPtr.MidTPtr(pos2, len2)); |
|
874 |
readPtr2.SetLength(len2); |
|
875 |
||
876 |
TRequestStatus status1(KRequestPending); |
|
877 |
TRequestStatus status2(KRequestPending); |
|
878 |
||
879 |
f.Read(pos, readPtr, len, status1); |
|
880 |
f.Read(readPtr2, len2, status2); |
|
881 |
||
882 |
||
883 |
User::WaitForRequest(status1); |
|
884 |
User::WaitForRequest(status2); |
|
885 |
test.Printf(_L("status1 %d status2 %d\n"), status1.Int(), status2.Int()); |
|
886 |
TestBuffer(gBufPtr, pos, len); |
|
887 |
TestBuffer(gBufPtr, pos2, len2); |
|
888 |
||
889 |
||
890 |
test.Next(_L("Read entire file")); |
|
891 |
||
892 |
for (pos = 0, len = 1; len <= 1024 && pos < KBufSize; len = (len+1) & 0x3FF) |
|
893 |
{ |
|
894 |
len = Min(len, KBufSize-pos); |
|
895 |
// RDebug::Print(_L("+%x, %x\n"), pos, len); |
|
896 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
897 |
readPtr.SetLength(len); |
|
898 |
||
899 |
r = f.Read(pos, readPtr, len); |
|
900 |
test_KErrNone(r); |
|
901 |
TestBuffer(gBufPtr, pos, len); |
|
902 |
test_KErrNone(r); |
|
903 |
pos+= len; |
|
904 |
} |
|
905 |
||
906 |
TestBuffer(gBufPtr, 0, KBufSize); |
|
907 |
||
908 |
// read from position zero to ensure it's cached |
|
909 |
pos = 0; |
|
910 |
len = 512; |
|
911 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
912 |
readPtr.SetLength(len); |
|
913 |
r = f.Read(pos, readPtr, len); |
|
914 |
test_KErrNone(r); |
|
915 |
TestBuffer(gBufPtr, pos, len); |
|
916 |
test_KErrNone(r); |
|
917 |
||
918 |
f.Close(); |
|
919 |
||
920 |
||
921 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
922 |
r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
923 |
test_KErrNone(r); |
0 | 924 |
test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue); |
925 |
test(fileCacheStats.iFilesOnClosedQueue == 1); |
|
926 |
#endif |
|
927 |
// |
|
928 |
||
929 |
||
930 |
//************************************************************** |
|
931 |
// Test closed file queue |
|
932 |
//************************************************************** |
|
933 |
enum |
|
934 |
{ |
|
935 |
ETestCloseQueueEmptyAfterTimeout, |
|
936 |
ETestCloseQueueEmptyAfterOpenWithDirectIo, |
|
937 |
ETestCloseQueueEmptyAfterDelete, |
|
938 |
ETestCloseEnd}; |
|
939 |
for (testNum = 0; testNum < ETestCloseEnd; testNum++) |
|
940 |
{ |
|
941 |
||
942 |
test.Next(_L("Reopen file & verify closed queue is empty")); |
|
943 |
||
944 |
r = f.Open(TheFs, testFile, EFileRead | EFileReadBuffered); |
|
945 |
test_KErrNone(r); |
|
946 |
pos = 0; |
|
947 |
len = 512; |
|
948 |
readPtr.Set(gBufPtr.MidTPtr(pos, len)); |
|
949 |
readPtr.SetLength(len); |
|
950 |
r = f.Read(pos, readPtr, len); |
|
951 |
test_KErrNone(r); |
|
952 |
TestBuffer(gBufPtr, pos, len); |
|
953 |
test_KErrNone(r); |
|
954 |
||
955 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
956 |
r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
957 |
test_KErrNone(r); |
0 | 958 |
test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue); |
959 |
test(fileCacheStats.iFilesOnClosedQueue == 0); |
|
960 |
#endif |
|
961 |
f.Close(); |
|
962 |
||
963 |
test.Next(_L("close & verify file is back on close queue")); |
|
964 |
||
965 |
||
966 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
967 |
r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
968 |
test_KErrNone(r); |
0 | 969 |
test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue); |
970 |
test(fileCacheStats.iFilesOnClosedQueue == 1); |
|
971 |
#endif |
|
972 |
||
973 |
if (testNum == ETestCloseQueueEmptyAfterDelete) |
|
974 |
{ |
|
975 |
test.Next(_L("delete file and verify closed queue is empty")); |
|
976 |
r = TheFs.Delete(testFile); |
|
977 |
test_KErrNone(r); |
|
978 |
} |
|
979 |
if (testNum == ETestCloseQueueEmptyAfterTimeout) |
|
980 |
{ |
|
981 |
test.Next(_L("wait for a while and verify closed queue is empty")); |
|
982 |
// wait for closed file queue to empty |
|
983 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
984 |
User::After(gFileCacheConfig.iClosedFileKeepAliveTime + 1000000); |
|
985 |
#endif |
|
986 |
} |
|
987 |
if (testNum == ETestCloseQueueEmptyAfterOpenWithDirectIo) |
|
988 |
{ |
|
989 |
test.Next(_L("Re-open file in directIo mode and then close and verify closed queue is empty")); |
|
990 |
r = f.Open(TheFs, testFile, EFileRead | EFileReadDirectIO); |
|
991 |
test_KErrNone(r); |
|
992 |
f.Close(); |
|
993 |
} |
|
994 |
||
995 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
996 |
r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
997 |
test_KErrNone(r); |
0 | 998 |
test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue); |
999 |
test(fileCacheStats.iFilesOnClosedQueue == 0); |
|
1000 |
#endif |
|
1001 |
} |
|
1002 |
||
1003 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1004 |
// turn lock failure mode back ON (if enabled) |
|
1005 |
simulatelockFailureMode = ETrue; |
|
1006 |
r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1007 |
test_KErrNone(r); |
0 | 1008 |
#endif |
1009 |
||
1010 |
//************************************************************** |
|
1011 |
// Test opening a file with a silly open mode flags combinations |
|
1012 |
//************************************************************** |
|
1013 |
test.Next(_L("Open file with illegal cache on/off bits")); |
|
1014 |
r = f.Open(TheFs, testFile, EFileRead | EFileReadBuffered | EFileReadDirectIO); |
|
1015 |
test_Value(r, r==KErrArgument); |
|
1016 |
r = f.Open(TheFs, testFile, EFileRead | EFileWriteBuffered | EFileWriteDirectIO); |
|
1017 |
test_Value(r, r==KErrArgument); |
|
1018 |
//********************************** |
|
1019 |
// Test that continuously appending to a file yields the correct size... |
|
1020 |
// NB: Must have lock failure more ON in debug mode for this test to pass |
|
1021 |
//********************************** |
|
1022 |
test.Next(_L("Test appending to a file & checking the file size...")); |
|
1023 |
gBufPtr.SetLength(KBufSize); |
|
1024 |
||
1025 |
r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteBuffered); |
|
1026 |
test_KErrNone(r); |
|
1027 |
||
1028 |
const TInt KWriteLen = KSegmentSize+1; |
|
1029 |
writePtr.Set(gBuf->Des().Ptr(), KWriteLen); |
|
1030 |
||
1031 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1032 |
r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1033 |
test_KErrNone(r); |
0 | 1034 |
test.Printf(_L("Number of Write-throughs with dirty data=%d\n"),fileCacheStats.iWriteThroughWithDirtyDataCount); |
1035 |
TInt writeThroughWithDirtyDataCountOld = fileCacheStats.iWriteThroughWithDirtyDataCount; |
|
1036 |
TInt writeThroughWithDirtyDataCountNew = writeThroughWithDirtyDataCountOld; |
|
1037 |
#endif |
|
1038 |
||
1039 |
TInt fileSize = 0; |
|
1040 |
for (TInt i=0; i<4; i++) |
|
1041 |
{ |
|
1042 |
fileSize = 0; |
|
1043 |
r = f.SetSize(fileSize); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1044 |
test_KErrNone(r); |
0 | 1045 |
for (pos = 0; pos < KMaxFileSize; ) |
1046 |
{ |
|
1047 |
r = f.Write(pos, writePtr); |
|
1048 |
if (r != KErrNone) |
|
1049 |
{ |
|
1050 |
test.Printf(_L("Iter #%d, write pos %d size %d, Write() returned %d"), i, pos, fileSize, r); |
|
1051 |
r = f.Flush(); |
|
1052 |
test.Printf(_L("Flush returned %d"), r); |
|
1053 |
test(0); |
|
1054 |
} |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1055 |
test_KErrNone(r); |
0 | 1056 |
pos+= writePtr.Length(); |
1057 |
||
1058 |
r = f.Size(fileSize); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1059 |
test_KErrNone(r); |
0 | 1060 |
if (fileSize != pos) |
1061 |
{ |
|
1062 |
test.Printf(_L("Iter #%d, write pos %d != size %d"), i, pos, fileSize); |
|
1063 |
r = f.Flush(); |
|
1064 |
test.Printf(_L("Flush returned %d"), r); |
|
1065 |
test(0); |
|
1066 |
} |
|
1067 |
test (fileSize == pos); |
|
1068 |
||
1069 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1070 |
r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1071 |
test_KErrNone(r); |
0 | 1072 |
writeThroughWithDirtyDataCountNew = fileCacheStats.iWriteThroughWithDirtyDataCount; |
1073 |
if (writeThroughWithDirtyDataCountNew > writeThroughWithDirtyDataCountOld) |
|
1074 |
{ |
|
1075 |
test.Printf(_L("Iter #%d, write pos %d size %d"), i, pos, fileSize); |
|
1076 |
test.Printf(_L("Number of Write-throughs with dirty data=%d\n"),fileCacheStats.iWriteThroughWithDirtyDataCount); |
|
1077 |
i = 4; |
|
1078 |
break; |
|
1079 |
} |
|
1080 |
#endif |
|
1081 |
||
1082 |
} |
|
1083 |
} |
|
1084 |
||
1085 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1086 |
test(writeThroughWithDirtyDataCountNew > writeThroughWithDirtyDataCountOld); |
|
1087 |
#endif |
|
1088 |
||
1089 |
||
1090 |
f.Close(); |
|
1091 |
||
1092 |
||
1093 |
//TheFs.SetDebugRegister(0); |
|
1094 |
test.End(); |
|
1095 |
} |
|
1096 |
||
1097 |
||
1098 |
// This thread is used to test what happens if requests are sent to the file server |
|
1099 |
// while the drive thread is hung in the critical notifier server. The requests should |
|
1100 |
// complete immediately with KErrNotReady |
|
1101 |
TInt ReaderThread(TAny* aFileName) |
|
1102 |
{ |
|
1103 |
RTest test(_L("T_FILECACHE, ReaderThread")); |
|
1104 |
||
1105 |
TDesC& fileName = *(TDesC*) aFileName; |
|
1106 |
||
1107 |
RFs fs; |
|
1108 |
TInt r = fs.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1109 |
test_KErrNone(r); |
0 | 1110 |
r = fs.SetSessionPath(gSessionPath); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1111 |
test_KErrNone(r); |
0 | 1112 |
|
1113 |
||
1114 |
RFile file; |
|
1115 |
r = file.Open(fs, fileName, EFileRead | EFileReadBuffered | EFileShareReadersOrWriters); |
|
1116 |
test_KErrNone(r); |
|
1117 |
||
1118 |
RTimer timer; |
|
1119 |
timer.CreateLocal(); |
|
1120 |
TRequestStatus reqStat; |
|
1121 |
timer.After(reqStat,10000000); // Read for 10 secs |
|
1122 |
||
1123 |
TInt pos=0; |
|
1124 |
TInt KReadLen = 32768; |
|
1125 |
TInt retCode = KErrNone; |
|
1126 |
||
1127 |
for (TInt i=0; reqStat == KRequestPending; i++) |
|
1128 |
{ |
|
1129 |
r = file.Read(pos, DataBuf, KReadLen); |
|
1130 |
test_Value(r, r == KErrNone || r == KErrNotReady); |
|
1131 |
||
1132 |
//test.Printf(_L("ReaderThread: iter %d, read at %d ret %d\n"), i, pos, r); |
|
1133 |
if (r == KErrNotReady) |
|
1134 |
retCode = r; |
|
1135 |
else if (r == KErrNone) |
|
1136 |
pos = DataBuf.Length() == 0 ? 0: pos + DataBuf.Length(); |
|
1137 |
if (retCode == KErrNotReady) |
|
1138 |
test.Printf(_L("ReaderThread: iter %d, read at %d ret %d \n"), i, pos, r); |
|
1139 |
} |
|
1140 |
||
1141 |
timer.Close(); |
|
1142 |
file.Close(); |
|
1143 |
fs.Close(); |
|
1144 |
||
1145 |
return retCode; |
|
1146 |
} |
|
1147 |
||
1148 |
||
1149 |
void ManualTests() |
|
1150 |
{ |
|
1151 |
RFile f; |
|
1152 |
TInt r; |
|
1153 |
gBufPtr.SetLength(KBufSize); |
|
1154 |
FillBuffer(gBufPtr, KBufSize); |
|
1155 |
TestBuffer(gBufPtr, 0,KBufSize); |
|
1156 |
||
1157 |
TPtrC8 writePtr; |
|
1158 |
writePtr.Set(gBuf->Des()); |
|
1159 |
||
1160 |
TFileName testFile = _L("TEST.BIN"); |
|
1161 |
||
1162 |
#if defined(_DEBUG) |
|
1163 |
test.Next(_L("Testing writing and then closing with an immediate simulated card eject")); |
|
1164 |
test.Printf(_L("**********************************************************\n")); |
|
1165 |
test.Printf(_L("When critical notifier message appears, PRESS RETRY\n")); |
|
1166 |
test.Printf(_L("**********************************************************\n")); |
|
1167 |
||
1168 |
r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteBuffered | EFileShareReadersOrWriters); |
|
1169 |
test_KErrNone(r); |
|
1170 |
||
1171 |
test.Printf(_L("Writing....")); |
|
1172 |
r = f.Write(0, writePtr); |
|
1173 |
test.Printf(_L("Write returned %d\n"), r); |
|
1174 |
test_KErrNone(r); |
|
1175 |
||
1176 |
r=TheFs.ControlIo(gDrive, KControlIoSimulateFileCacheWriteFailure); |
|
1177 |
test_KErrNone(r); |
|
1178 |
||
1179 |
f.Close(); |
|
1180 |
||
1181 |
TEntry entry; |
|
1182 |
||
1183 |
// wait for re-insertion.... |
|
1184 |
do |
|
1185 |
{ |
|
1186 |
r = TheFs.Entry(testFile, entry); |
|
1187 |
User::After(500000); |
|
1188 |
} |
|
1189 |
while (r == KErrNotReady); |
|
1190 |
test_KErrNone(r); |
|
1191 |
||
1192 |
test.Printf(_L("FileSize %d expected %d\n"), entry.iSize, writePtr.Length()); |
|
1193 |
||
1194 |
// test all data is written to disk |
|
1195 |
test (entry.iSize == writePtr.Length()); |
|
1196 |
#endif |
|
1197 |
||
1198 |
||
1199 |
test.Next(_L("Testing writing and then ejecting card")); |
|
1200 |
||
1201 |
// r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteDirectIO); |
|
1202 |
r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteBuffered | EFileShareReadersOrWriters); |
|
1203 |
test_KErrNone(r); |
|
1204 |
writePtr.Set(gBuf->Des()); |
|
1205 |
||
1206 |
||
1207 |
// set the file size first so that the cluster chain already exists |
|
1208 |
r = f.SetSize(writePtr.Length()); |
|
1209 |
test.Printf(_L("SetSize returned %d")); |
|
1210 |
||
1211 |
// Create another thread which will attempt to issue reads while this thread is suspended |
|
1212 |
// These reads should complete with KErrNotReady |
|
1213 |
const TInt KHeapSize = 32768; |
|
1214 |
test.Printf(_L("Creating file-reading thread\n")); |
|
1215 |
RThread readerThread; |
|
1216 |
readerThread.Create(_L("FileReaderThread"), ReaderThread, KDefaultStackSize, KHeapSize, KHeapSize, &testFile); |
|
1217 |
||
1218 |
test.Printf(_L("Writing....")); |
|
1219 |
r = f.Write(0, writePtr); |
|
1220 |
test.Printf(_L("Write returned %d\n"), r); |
|
1221 |
||
1222 |
||
1223 |
test.Printf(_L("Waiting 5 seconds.\n")); |
|
1224 |
test.Printf(_L("**********************************************************\n")); |
|
1225 |
test.Printf(_L("Please press a key, EJECT MEDIA BEFORE WRITE TIMER EXPIRES,\n")); |
|
1226 |
test.Printf(_L("wait for critical notifier, replace media and retry\n")); |
|
1227 |
test.Printf(_L("**********************************************************\n")); |
|
1228 |
// test.Printf(_L("press any key...")); |
|
1229 |
test.Getch(); |
|
1230 |
test.Printf(_L("\n")); |
|
1231 |
||
1232 |
test.Printf(_L("Writing....")); |
|
1233 |
r = f.Write(0, writePtr); |
|
1234 |
test.Printf(_L("Write returned %d\n"), r); |
|
1235 |
readerThread.Resume(); |
|
1236 |
||
1237 |
User::After(5000000); |
|
1238 |
||
1239 |
do |
|
1240 |
{ |
|
1241 |
test.Printf(_L("Flushing....\n")); |
|
1242 |
r = f.Flush(); |
|
1243 |
test.Printf(_L("Flush returned %d\n"), r); |
|
1244 |
if (r != KErrNone) |
|
1245 |
User::After(5000000); |
|
1246 |
} |
|
1247 |
while (r != KErrNone); |
|
1248 |
||
1249 |
||
1250 |
// r = f.Write(0, writePtr); |
|
1251 |
// test.Printf(_L("Write returned %d")); |
|
1252 |
||
1253 |
// test_KErrNone(r); |
|
1254 |
||
1255 |
test.Next(_L("Testing reader thread completed with KErrNotReady")); |
|
1256 |
TRequestStatus status; |
|
1257 |
readerThread.Logon(status); |
|
1258 |
readerThread.Resume(); |
|
1259 |
User::WaitForRequest(status); |
|
1260 |
test.Printf(_L("ReaderThread status %d\n"), status.Int()); |
|
1261 |
test (status.Int() == KErrNotReady); |
|
1262 |
readerThread.Close(); |
|
1263 |
||
1264 |
test.Printf(_L("press any key...")); |
|
1265 |
test.Getch(); |
|
1266 |
test.Printf(_L("\n")); |
|
1267 |
||
1268 |
f.Close(); |
|
1269 |
} |
|
1270 |
||
1271 |
||
1272 |
LOCAL_C void DoTestFileRead(TUint aFileMode, TInt aReadBlockSize) |
|
1273 |
// |
|
1274 |
// Do Read Test |
|
1275 |
// |
|
1276 |
{ |
|
1277 |
||
1278 |
RFile file; |
|
1279 |
TInt r=file.Open(TheFs,_L("READTEST.XXX"),EFileStream | aFileMode); |
|
1280 |
test_KErrNone(r); |
|
1281 |
||
1282 |
TInt maxReadCount=KMaxFileSize/aReadBlockSize; |
|
1283 |
TInt loopCount=0; |
|
1284 |
||
1285 |
TTime startTime; |
|
1286 |
TTime endTime; |
|
1287 |
||
1288 |
RTimer timer; |
|
1289 |
timer.CreateLocal(); |
|
1290 |
TRequestStatus reqStat; |
|
1291 |
timer.After(reqStat,10000000); // After 10 secs |
|
1292 |
startTime.HomeTime(); |
|
1293 |
||
1294 |
FOREVER |
|
1295 |
{ |
|
1296 |
TInt pos=0; |
|
1297 |
file.Seek(ESeekStart,pos); |
|
1298 |
for(TInt ii=0;ii<maxReadCount;ii++) |
|
1299 |
{ |
|
1300 |
r = file.Read(DataBuf,aReadBlockSize); |
|
1301 |
test_KErrNone(r); |
|
1302 |
#if defined(_DEBUG) |
|
1303 |
for(TInt jj=0;jj<DataBuf.Size();jj++) |
|
1304 |
{ |
|
1305 |
if (DataBuf[jj] != ((jj+ii*aReadBlockSize)%256)) |
|
1306 |
{ |
|
1307 |
test.Printf(_L("len %d size %d jj %d ii %d"), DataBuf.Length(), DataBuf.Size(), jj, ii); |
|
1308 |
test(0); |
|
1309 |
} |
|
1310 |
// test(DataBuf[jj] == ((jj+ii*aReadBlockSize)%256) ); |
|
1311 |
} |
|
1312 |
#endif |
|
1313 |
if (reqStat!=KRequestPending) |
|
1314 |
{ |
|
1315 |
endTime.HomeTime(); |
|
1316 |
||
1317 |
TInt functionCalls=loopCount*maxReadCount+ii; |
|
1318 |
// TReal rate = ( TReal32(functionCalls) * TReal32(aReadBlockSize) ) / 10; |
|
1319 |
// test.Printf(_L("Read %5d byte blocks:\t%11.3f KBytes/s\n"), aReadBlockSize, rate / (KOneK)); |
|
1320 |
||
1321 |
TReal transferRate = |
|
1322 |
(TReal32(functionCalls) * TReal32(aReadBlockSize)) / |
|
1323 |
TReal(endTime.MicroSecondsFrom(startTime).Int64()) * TReal(KOneMeg) / TReal(KOneK); |
|
1324 |
test.Printf(_L("Read %5d byte blocks:\t%11.3f KBytes/s\n"), aReadBlockSize,transferRate); |
|
1325 |
||
1326 |
timer.Close(); |
|
1327 |
file.Close(); |
|
1328 |
||
1329 |
return; |
|
1330 |
} |
|
1331 |
} |
|
1332 |
loopCount++; |
|
1333 |
} |
|
1334 |
} |
|
1335 |
||
1336 |
LOCAL_C void DoTestFileWrite(TUint aFileMode, TInt aWriteBlockSize) |
|
1337 |
// |
|
1338 |
// Do Write benchmark |
|
1339 |
// |
|
1340 |
{ |
|
1341 |
DataBuf.SetLength(aWriteBlockSize); |
|
1342 |
TInt maxWriteCount=KMaxFileSize/aWriteBlockSize; |
|
1343 |
TInt loopCount=0; |
|
1344 |
||
1345 |
RFile file; |
|
1346 |
TInt r = file.Replace(TheFs,_L("WRITETST"),EFileStream | aFileMode); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1347 |
test_KErrNone(r); |
0 | 1348 |
|
1349 |
TTime startTime; |
|
1350 |
TTime endTime; |
|
1351 |
||
1352 |
RTimer timer; |
|
1353 |
timer.CreateLocal(); |
|
1354 |
TRequestStatus reqStat; |
|
1355 |
timer.After(reqStat,10000000); // After 10 secs |
|
1356 |
startTime.HomeTime(); |
|
1357 |
||
1358 |
||
1359 |
||
1360 |
FOREVER |
|
1361 |
{ |
|
1362 |
TInt pos=0; |
|
1363 |
file.Seek(ESeekStart,pos); |
|
1364 |
for(TInt ii=0;ii<maxWriteCount;ii++) |
|
1365 |
{ |
|
1366 |
r = file.Write(DataBuf); |
|
1367 |
test_KErrNone(r); |
|
1368 |
if (reqStat!=KRequestPending) |
|
1369 |
{ |
|
1370 |
||
1371 |
// TReal rate = (TReal32(functionCalls) * TReal32(aWriteBlockSize)) / 10; |
|
1372 |
// test.Printf(_L("Write %5d byte blocks:\t%11.3f KBytes/s\n"), aWriteBlockSize, rate / (KOneK)); |
|
1373 |
||
1374 |
r = file.Flush(); |
|
1375 |
test_KErrNone(r); |
|
1376 |
||
1377 |
endTime.HomeTime(); |
|
1378 |
||
1379 |
TInt functionCalls=loopCount*maxWriteCount+ii; |
|
1380 |
TReal transferRate = |
|
1381 |
(TReal32(functionCalls) * TReal32(aWriteBlockSize)) / |
|
1382 |
TReal(endTime.MicroSecondsFrom(startTime).Int64()) * TReal(KOneMeg) / TReal(KOneK); |
|
1383 |
test.Printf(_L("Write %5d byte blocks:\t%11.3f KBytes/s\n"), aWriteBlockSize,transferRate); |
|
1384 |
||
1385 |
file.Close(); |
|
1386 |
timer.Close(); |
|
1387 |
TInt r=TheFs.Delete(_L("WRITETST")); |
|
1388 |
test_KErrNone(r); |
|
1389 |
return; |
|
1390 |
} |
|
1391 |
} |
|
1392 |
loopCount++; |
|
1393 |
} |
|
1394 |
} |
|
1395 |
||
1396 |
LOCAL_C void TestFileRead(TUint aFileMode) |
|
1397 |
// |
|
1398 |
// Benchmark read method |
|
1399 |
// |
|
1400 |
{ |
|
1401 |
||
1402 |
// ClearSessionDirectory(); |
|
1403 |
test.Next(_L("Benchmark read method")); |
|
1404 |
// test.Printf(_L("aFileMode %08X\n"), aFileMode); |
|
1405 |
PrintFileMode(aFileMode); |
|
1406 |
||
1407 |
// Create test data |
|
1408 |
TBuf8<1024> testdata(1024); |
|
1409 |
for (TInt i=0;i<testdata.MaxSize();i++) |
|
1410 |
testdata[i]=TText8(i%256); |
|
1411 |
||
1412 |
// create & fill the file |
|
1413 |
RFile file; |
|
1414 |
TInt r=file.Replace(TheFs,_L("READTEST.XXX"),EFileStream | aFileMode); |
|
1415 |
test_KErrNone(r); |
|
1416 |
||
1417 |
test.Printf(_L("Creating test file.....")); |
|
1418 |
TInt count=KMaxFileSize/testdata.Length(); |
|
1419 |
while (count--) |
|
1420 |
file.Write(testdata); |
|
1421 |
file.Close(); |
|
1422 |
test.Printf(_L("done.\n")); |
|
1423 |
||
1424 |
#ifdef SYMBIAN_TEST_EXTENDED_BUFFER_SIZES |
|
1425 |
||
1426 |
DoTestFileRead(aFileMode, 1); |
|
1427 |
DoTestFileRead(aFileMode, 2); |
|
1428 |
DoTestFileRead(aFileMode, 4); |
|
1429 |
DoTestFileRead(aFileMode, 8); |
|
1430 |
DoTestFileRead(aFileMode, 16); |
|
1431 |
DoTestFileRead(aFileMode, 32); |
|
1432 |
DoTestFileRead(aFileMode, 64); |
|
1433 |
DoTestFileRead(aFileMode, 128); |
|
1434 |
DoTestFileRead(aFileMode, 256); |
|
1435 |
DoTestFileRead(aFileMode, 512); |
|
1436 |
DoTestFileRead(aFileMode, 1024); |
|
1437 |
DoTestFileRead(aFileMode, 2048); |
|
1438 |
DoTestFileRead(aFileMode, 4096); |
|
1439 |
DoTestFileRead(aFileMode, 8192); |
|
1440 |
DoTestFileRead(aFileMode, 16384); |
|
1441 |
DoTestFileRead(aFileMode, 32768); |
|
1442 |
DoTestFileRead(aFileMode, 65536); |
|
1443 |
DoTestFileRead(aFileMode, 131072); |
|
1444 |
#else |
|
1445 |
//TheFs.SetDebugRegister(KCACHE); |
|
1446 |
DoTestFileRead(aFileMode, 1); |
|
1447 |
DoTestFileRead(aFileMode, 16); |
|
1448 |
DoTestFileRead(aFileMode, 512); |
|
1449 |
//TheFs.SetDebugRegister(0); |
|
1450 |
DoTestFileRead(aFileMode, 4 * 1024); |
|
1451 |
DoTestFileRead(aFileMode, 32 * 1024); |
|
1452 |
DoTestFileRead(aFileMode, 64 * 1024); |
|
1453 |
DoTestFileRead(aFileMode, 128 * 1024); |
|
1454 |
DoTestFileRead(aFileMode, 256 * 1024); |
|
1455 |
#endif |
|
1456 |
||
1457 |
r=TheFs.Delete(_L("READTEST.XXX")); |
|
1458 |
||
1459 |
||
1460 |
||
1461 |
test_KErrNone(r); |
|
1462 |
} |
|
1463 |
||
1464 |
||
1465 |
LOCAL_C void TestFileWrite(TUint aFileMode) |
|
1466 |
// |
|
1467 |
// Benchmark write method |
|
1468 |
// |
|
1469 |
{ |
|
1470 |
// ClearSessionDirectory(); |
|
1471 |
test.Next(_L("Benchmark write method")); |
|
1472 |
// test.Printf(_L("aFileMode %08X\n"), aFileMode); |
|
1473 |
PrintFileMode(aFileMode); |
|
1474 |
||
1475 |
||
1476 |
// RFile file; |
|
1477 |
// TInt r = file.Replace(TheFs,_L("WRITETST"),EFileStream | aFileMode); |
|
1478 |
// test_KErrNone(r); |
|
1479 |
||
1480 |
||
1481 |
#ifdef SYMBIAN_TEST_EXTENDED_BUFFER_SIZES |
|
1482 |
DoTestFileWrite(aFileMode, 1); |
|
1483 |
DoTestFileWrite(aFileMode, 2); |
|
1484 |
DoTestFileWrite(aFileMode, 4); |
|
1485 |
DoTestFileWrite(aFileMode, 8); |
|
1486 |
DoTestFileWrite(aFileMode, 16); |
|
1487 |
DoTestFileWrite(aFileMode, 32); |
|
1488 |
DoTestFileWrite(aFileMode, 64); |
|
1489 |
DoTestFileWrite(aFileMode, 128); |
|
1490 |
DoTestFileWrite(aFileMode, 256); |
|
1491 |
DoTestFileWrite(aFileMode, 512); |
|
1492 |
DoTestFileWrite(aFileMode, 1024); |
|
1493 |
DoTestFileWrite(aFileMode, 2048); |
|
1494 |
DoTestFileWrite(aFileMode, 4096); |
|
1495 |
DoTestFileWrite(aFileMode, 8192); |
|
1496 |
DoTestFileWrite(aFileMode, 16384); |
|
1497 |
DoTestFileWrite(aFileMode, 32768); |
|
1498 |
DoTestFileWrite(aFileMode, 65536); |
|
1499 |
DoTestFileWrite(aFileMode, 131072); |
|
1500 |
#else |
|
1501 |
DoTestFileWrite(aFileMode, 1); |
|
1502 |
DoTestFileWrite(aFileMode, 16); |
|
1503 |
DoTestFileWrite(aFileMode, 512); |
|
1504 |
DoTestFileWrite(aFileMode, 4 * 1024); |
|
1505 |
DoTestFileWrite(aFileMode, 32 * 1024); |
|
1506 |
DoTestFileWrite(aFileMode, 64 * 1024); |
|
1507 |
DoTestFileWrite(aFileMode, 128 * 1024); |
|
1508 |
DoTestFileWrite(aFileMode, 256 * 1024); |
|
1509 |
#endif |
|
1510 |
} |
|
1511 |
||
1512 |
enum CommandId { |
|
1513 |
CMD_NO_COMMAND, |
|
1514 |
CMD_HELP, |
|
1515 |
CMD_DISPLAY_CACHE_FLAGS, |
|
1516 |
CMD_WRITE_CACHE_FLAGS, |
|
1517 |
CMD_PERFORMANCE_TEST, |
|
1518 |
CMD_MANUAL_TEST |
|
1519 |
}; |
|
1520 |
||
1521 |
||
1522 |
class CommandLineOption { |
|
1523 |
public: |
|
1524 |
CommandLineOption(const TPtrC &s, CommandId i) : str(s), id(i) { } |
|
1525 |
||
1526 |
const TPtrC str; |
|
1527 |
CommandId id; |
|
1528 |
||
1529 |
private: |
|
1530 |
CommandLineOption() { } |
|
1531 |
}; |
|
1532 |
||
1533 |
// Lists of command line options |
|
1534 |
static const CommandLineOption commandList[] = { |
|
1535 |
CommandLineOption(_L("-help"), CMD_HELP), |
|
1536 |
CommandLineOption(_L("-h"), CMD_HELP), |
|
1537 |
CommandLineOption(_L("-?"), CMD_HELP), |
|
1538 |
CommandLineOption(_L("/?"), CMD_HELP), |
|
1539 |
CommandLineOption(_L("-d"), CMD_DISPLAY_CACHE_FLAGS), |
|
1540 |
CommandLineOption(_L("-w"), CMD_WRITE_CACHE_FLAGS), |
|
1541 |
CommandLineOption(_L("-p"), CMD_PERFORMANCE_TEST), |
|
1542 |
CommandLineOption(_L("-m"), CMD_MANUAL_TEST), |
|
1543 |
}; |
|
1544 |
||
1545 |
||
1546 |
||
1547 |
LOCAL_C void printHelp() { |
|
1548 |
test.Printf(_L("Option Explanation\r\n")); |
|
1549 |
test.Printf(_L("-help Print this text\r\n")); |
|
1550 |
test.Printf(_L("-d Display cache flags\n")); |
|
1551 |
test.Printf(_L("-p Performance test\n")); |
|
1552 |
} |
|
1553 |
||
1554 |
||
1555 |
||
1556 |
///////////////////////////////////////////////////////////////////////////// |
|
1557 |
// Function: |
|
1558 |
// bool parseCommandLine() |
|
1559 |
// |
|
1560 |
// Parameters: |
|
1561 |
// - |
|
1562 |
// |
|
1563 |
// Return value: |
|
1564 |
// true if command line options was correct, false if any command was |
|
1565 |
// invalid |
|
1566 |
// |
|
1567 |
// Purpose: |
|
1568 |
// Parses the command line |
|
1569 |
// |
|
1570 |
///////////////////////////////////////////////////////////////////////////// |
|
1571 |
||
1572 |
//TBuf<512> commandLine; |
|
1573 |
||
1574 |
||
1575 |
LOCAL_C bool ParseCommandLine( const TDesC& aCommand ) |
|
1576 |
{ |
|
1577 |
TLex lex(aCommand); |
|
1578 |
TInt tokenCount = 0; |
|
1579 |
||
1580 |
gDriveToTest='C'; |
|
1581 |
gRunTests = ETrue; |
|
1582 |
||
1583 |
for (TPtrC token=lex.NextToken(); token.Length() != 0;token.Set(lex.NextToken())) |
|
1584 |
{ |
|
1585 |
tokenCount++; |
|
1586 |
||
1587 |
// |
|
1588 |
// Search the list of commands for a match. |
|
1589 |
// |
|
1590 |
CommandId commandId = CMD_NO_COMMAND; |
|
1591 |
for (TUint i = 0; i < sizeof commandList / sizeof commandList[0]; i++) |
|
1592 |
{ |
|
1593 |
if (token.CompareF(commandList[i].str) == 0) |
|
1594 |
{ |
|
1595 |
// |
|
1596 |
// Found a matching string |
|
1597 |
// |
|
1598 |
commandId = commandList[i].id; |
|
1599 |
break; |
|
1600 |
} |
|
1601 |
} |
|
1602 |
||
1603 |
switch (commandId) |
|
1604 |
{ |
|
1605 |
case CMD_NO_COMMAND: |
|
1606 |
{ |
|
1607 |
TFileName thisfile=RProcess().FileName(); |
|
1608 |
if (token.MatchF(thisfile)==0) |
|
1609 |
{ |
|
1610 |
token.Set(lex.NextToken()); |
|
1611 |
} |
|
1612 |
test.Printf(_L("CLP=%S\n"),&token); |
|
1613 |
||
1614 |
TChar ch = token[0]; |
|
1615 |
if (ch.IsAlpha()) |
|
1616 |
{ |
|
1617 |
if(token.Length()!=0) |
|
1618 |
{ |
|
1619 |
gDriveToTest=token[0]; |
|
1620 |
gDriveToTest.UpperCase(); |
|
1621 |
} |
|
1622 |
else |
|
1623 |
gDriveToTest='C'; |
|
1624 |
lex.NextToken(); |
|
1625 |
} |
|
1626 |
} |
|
1627 |
break; |
|
1628 |
||
1629 |
case CMD_HELP: |
|
1630 |
printHelp(); |
|
1631 |
gRunTests = EFalse; |
|
1632 |
break; |
|
1633 |
||
1634 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1635 |
case CMD_WRITE_CACHE_FLAGS: |
|
1636 |
{ |
|
1637 |
token.Set(lex.NextToken()); |
|
1638 |
if (token.Length() == 0) { |
|
1639 |
printHelp(); |
|
1640 |
return false; |
|
1641 |
} |
|
1642 |
// |
|
1643 |
// Extract flags (in hex) from next token. |
|
1644 |
// |
|
1645 |
TPtrC numStr(token); |
|
1646 |
TUint val; |
|
1647 |
TInt r = TLex(numStr).Val(val, EHex); |
|
1648 |
if (r != KErrNone) { |
|
1649 |
printHelp(); |
|
1650 |
return false; |
|
1651 |
} |
|
1652 |
gDriveCacheFlags = TFileCacheFlags(val); |
|
1653 |
gWriteCacheFlags = ETrue; |
|
1654 |
gRunTests = EFalse; |
|
1655 |
break; |
|
1656 |
} |
|
1657 |
||
1658 |
case CMD_DISPLAY_CACHE_FLAGS: |
|
1659 |
gDisplayCacheFlags = ETrue; |
|
1660 |
gRunTests = EFalse; |
|
1661 |
break; |
|
1662 |
#endif |
|
1663 |
case CMD_PERFORMANCE_TEST: |
|
1664 |
gRunPerformanceTests = ETrue; |
|
1665 |
gRunUnitTests = EFalse; |
|
1666 |
break; |
|
1667 |
||
1668 |
case CMD_MANUAL_TEST: |
|
1669 |
gRunManualTests = ETrue; |
|
1670 |
gRunUnitTests = EFalse; |
|
1671 |
break; |
|
1672 |
||
1673 |
default: |
|
1674 |
test.Printf(_L("Sorry, command option '%S' not implemented\n"), |
|
1675 |
&token); |
|
1676 |
break; |
|
1677 |
} |
|
1678 |
||
1679 |
} |
|
1680 |
return true; |
|
1681 |
} |
|
1682 |
||
1683 |
||
1684 |
LOCAL_C TBool parseCommandLine() { |
|
1685 |
// |
|
1686 |
// Loop through all tokens in the command line |
|
1687 |
// |
|
1688 |
TInt cmdLineLen = User::CommandLineLength(); |
|
1689 |
HBufC* cmdLineBuf = HBufC::New( cmdLineLen ); |
|
1690 |
if( !cmdLineBuf ) |
|
1691 |
{ |
|
1692 |
return false; |
|
1693 |
} |
|
1694 |
TPtr ptr = cmdLineBuf->Des(); |
|
1695 |
User::CommandLine(ptr); |
|
1696 |
||
1697 |
bool err = ParseCommandLine( *cmdLineBuf ); |
|
1698 |
delete cmdLineBuf; |
|
1699 |
return err; |
|
1700 |
} |
|
1701 |
||
1702 |
GLDEF_C void CallTestsL() |
|
1703 |
// |
|
1704 |
// Do tests relative to the session path |
|
1705 |
// |
|
1706 |
{ |
|
1707 |
TestsInit(); |
|
1708 |
||
1709 |
TVolumeInfo volInfo; |
|
1710 |
TInt r = TheFs.Volume(volInfo, gDrive); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1711 |
test_KErrNone(r); |
0 | 1712 |
|
1713 |
TFullName extName; |
|
1714 |
r = TheFs.ExtensionName(extName,gDrive, 0); |
|
1715 |
if (r == KErrNone) |
|
1716 |
{ |
|
1717 |
test.Printf(_L("File system extension present (%S)\n"), &extName); |
|
1718 |
} |
|
1719 |
||
1720 |
if ((volInfo.iDrive.iType == EMediaRam) || |
|
1721 |
((gDriveCacheFlags & (EFileCacheReadEnabled | EFileCacheReadOn)) == 0)) |
|
1722 |
{ |
|
1723 |
if (gRunPerformanceTests) |
|
1724 |
{ |
|
1725 |
TestFileRead(EFileReadDirectIO); |
|
1726 |
TestFileWrite(EFileWriteDirectIO); |
|
1727 |
} |
|
1728 |
TestsEnd(); |
|
1729 |
return; |
|
1730 |
} |
|
1731 |
||
1732 |
if (gRunUnitTests) |
|
1733 |
UnitTests(); |
|
1734 |
||
1735 |
if (gRunManualTests) |
|
1736 |
{ |
|
1737 |
ManualTests(); |
|
1738 |
} |
|
1739 |
||
1740 |
if (gRunPerformanceTests) |
|
1741 |
{ |
|
1742 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1743 |
// turn OFF lock failure mode |
|
1744 |
TBool simulatelockFailureMode = EFalse; |
|
1745 |
r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1746 |
test_KErrNone(r); |
0 | 1747 |
#endif |
1748 |
||
1749 |
TestFileRead(EFileReadDirectIO); |
|
1750 |
if (gDriveCacheFlags & (EFileCacheReadEnabled | EFileCacheReadOn)) |
|
1751 |
{ |
|
1752 |
TestFileRead(EFileReadBuffered | EFileReadAheadOff); |
|
1753 |
TestFileRead(EFileReadBuffered | EFileReadAheadOn); |
|
1754 |
} |
|
1755 |
||
1756 |
TestFileWrite(EFileWriteDirectIO); |
|
1757 |
||
1758 |
if (gDriveCacheFlags & (EFileCacheWriteEnabled | EFileCacheWriteOn)) |
|
1759 |
TestFileWrite(EFileWriteBuffered); |
|
1760 |
||
1761 |
||
1762 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1763 |
// turn lock failure mode back ON (if enabled) |
|
1764 |
simulatelockFailureMode = ETrue; |
|
1765 |
r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1766 |
test_KErrNone(r); |
0 | 1767 |
#endif |
1768 |
} // if (gRunPerformanceTests) |
|
1769 |
||
1770 |
TestsEnd(); |
|
1771 |
} |
|
1772 |
||
1773 |
||
1774 |
||
1775 |
LOCAL_C void DoTests(TInt aDrive) |
|
1776 |
// |
|
1777 |
// Do testing on aDrive |
|
1778 |
// |
|
1779 |
{ |
|
1780 |
||
1781 |
SetSessionPath(aDrive); |
|
1782 |
||
1783 |
// !!! Disable platform security tests until we get the new APIs |
|
1784 |
// if(User::Capability() & KCapabilityRoot) |
|
1785 |
// CheckMountLFFS(TheFs,driveLetter); |
|
1786 |
||
1787 |
User::After(1000000); |
|
1788 |
||
1789 |
TInt r=TheFs.MkDirAll(gSessionPath); |
|
1790 |
test_Value(r, r == KErrNone || r == KErrAlreadyExists); |
|
1791 |
TheFs.ResourceCountMarkStart(); |
|
1792 |
||
1793 |
TRAP(r,CallTestsL()); |
|
1794 |
test_KErrNone(r); |
|
1795 |
||
1796 |
TheFs.ResourceCountMarkEnd(); |
|
1797 |
} |
|
1798 |
||
1799 |
||
1800 |
void Format(TInt aDrive) |
|
1801 |
// |
|
1802 |
// Format current drive |
|
1803 |
// |
|
1804 |
{ |
|
1805 |
||
1806 |
test.Next(_L("Format")); |
|
1807 |
TBuf<4> driveBuf=_L("?:\\"); |
|
1808 |
driveBuf[0]=(TText)(aDrive+'A'); |
|
1809 |
RFormat format; |
|
1810 |
TInt count; |
|
1811 |
TInt r=format.Open(TheFs,driveBuf,EQuickFormat,count); |
|
1812 |
//TInt r=format.Open(TheFs,driveBuf,EFullFormat,count); |
|
1813 |
test.Printf(_L("RFormat::Open() returned %d\n"), r); |
|
1814 |
test_KErrNone(r); |
|
1815 |
while(count) |
|
1816 |
{ |
|
1817 |
TInt r=format.Next(count); |
|
1818 |
test_KErrNone(r); |
|
1819 |
} |
|
1820 |
format.Close(); |
|
1821 |
} |
|
1822 |
||
1823 |
GLDEF_C TInt E32Main() |
|
1824 |
// |
|
1825 |
// Test with drive nearly full |
|
1826 |
// |
|
1827 |
{ |
|
1828 |
||
1829 |
CTrapCleanup* cleanup; |
|
1830 |
cleanup=CTrapCleanup::New(); |
|
1831 |
||
1832 |
__UHEAP_MARK; |
|
1833 |
||
1834 |
TBool parseOk = parseCommandLine(); |
|
1835 |
if (!parseOk) |
|
1836 |
User::Leave(KErrNotSupported); |
|
1837 |
||
1838 |
||
1839 |
TInt r = TheFs.Connect(); |
|
1840 |
test_KErrNone(r); |
|
1841 |
||
1842 |
r=TheFs.CharToDrive(gDriveToTest,gDrive); |
|
1843 |
test_KErrNone(r); |
|
1844 |
||
1845 |
#if !defined(__WINS__) |
|
1846 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1847 |
test.Start(_L("Check that the rom is paged")); |
|
1848 |
TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
|
1849 |
if (romHeader->iPageableRomStart != NULL) |
|
1850 |
{ |
|
1851 |
test.Printf(_L("ROM is paged\n")); |
|
1852 |
gRomPaged = ETrue; |
|
1853 |
} |
|
1854 |
#endif |
|
1855 |
#endif |
|
1856 |
||
1857 |
// Get the TFileCacheFlags for this drive |
|
1858 |
r = TheFs.Volume(gVolInfo, gDrive); |
|
1859 |
if (r == KErrNotReady) |
|
1860 |
{ |
|
1861 |
TDriveInfo info; |
|
1862 |
TInt err = TheFs.Drive(info,gDrive); |
|
1863 |
test_KErrNone(err); |
|
1864 |
if (info.iType == EMediaNotPresent) |
|
1865 |
test.Printf(_L("%c: Medium not present - cannot perform test.\n"), (TUint)gDriveToTest); |
|
1866 |
else |
|
1867 |
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)gDriveToTest); |
|
1868 |
} |
|
1869 |
else if (r == KErrCorrupt) |
|
1870 |
{ |
|
1871 |
test.Printf(_L("%c: Media corruption; previous test may have aborted; else, check hardware\n"), (TUint)gDriveToTest); |
|
1872 |
} |
|
1873 |
test_KErrNone(r); |
|
1874 |
gDriveCacheFlags = gVolInfo.iFileCacheFlags; |
|
1875 |
test.Printf(_L("DriveCacheFlags for drive %C = %08X\n"), (TInt) gDriveToTest, gDriveCacheFlags); |
|
1876 |
||
1877 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1878 |
PrintFileCacheConfig(gFileCacheConfig, gDrive); |
|
1879 |
||
1880 |
if (gDisplayCacheFlags) |
|
1881 |
{ |
|
1882 |
test.Printf(_L("Press any key...\n")); |
|
1883 |
test.Getch(); |
|
1884 |
} |
|
1885 |
||
1886 |
if (gWriteCacheFlags) |
|
1887 |
{ |
|
1888 |
test.Printf(_L("Writing DriveCacheFlags for drive %C = %08X\n"), (TInt) gDriveToTest, gDriveCacheFlags); |
|
1889 |
r = controlIo(TheFs,gDrive, KControlIoFileCacheFlagsWrite, gDriveCacheFlags); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1890 |
test_KErrNone(r); |
0 | 1891 |
} |
1892 |
#endif |
|
1893 |
||
1894 |
if (gRunTests) |
|
1895 |
{ |
|
1896 |
test.Title(); |
|
1897 |
||
1898 |
||
1899 |
test.Start(_L("Starting tests...")); |
|
1900 |
||
1901 |
if ((gVolInfo.iDrive.iMediaAtt & KMediaAttFormattable)) |
|
1902 |
Format(gDrive); |
|
1903 |
||
1904 |
//TheFs.SetDebugRegister(KCACHE); |
|
1905 |
DoTests(gDrive); |
|
1906 |
//TheFs.SetDebugRegister(0); |
|
201
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1907 |
|
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1908 |
if ((gVolInfo.iDrive.iMediaAtt & KMediaAttFormattable)) |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1909 |
Format(gDrive); |
43365a9b78a3
Revision: 201027
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
152
diff
changeset
|
1910 |
|
0 | 1911 |
test.End(); |
1912 |
// } |
|
1913 |
} |
|
1914 |
||
1915 |
#if defined(_DEBUG) || defined(_DEBUG_RELEASE) |
|
1916 |
TFileCacheStats fileCacheStats; |
|
1917 |
PrintFileCacheStats(fileCacheStats); |
|
1918 |
#endif |
|
1919 |
||
1920 |
TheFs.Close(); |
|
1921 |
test.Close(); |
|
1922 |
__UHEAP_MARKEND; |
|
1923 |
delete cleanup; |
|
1924 |
return(KErrNone); |
|
1925 |
} |