author | Mike Kinghan <mikek@symbian.org> |
Sun, 18 Jul 2010 10:20:49 +0100 | |
branch | GCC_SURGE |
changeset 206 | ced41fd9a298 |
parent 109 | b3a1d9898418 |
child 132 | e4a7b1cbe40c |
child 210 | b592f7984442 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// e32test\mmu\t_nandpaging.cpp |
|
15 |
// Suite of tests specifically to test the demand paging subsystem when |
|
16 |
// booted from NAND. |
|
17 |
// 002 Read/Write and Page test |
|
18 |
// 003 Defering test |
|
19 |
// |
|
20 |
// |
|
21 |
||
22 |
//! @SYMTestCaseID KBASE-T_NANDPAGING-0332 |
|
23 |
//! @SYMTestType UT |
|
24 |
//! @SYMPREQ PREQ1110 |
|
25 |
//! @SYMTestCaseDesc Demand Paging Nand Paging tests. |
|
26 |
//! @SYMTestActions 001 Check that the rom is paged |
|
27 |
//! @SYMTestExpectedResults All tests should pass. |
|
28 |
//! @SYMTestPriority High |
|
29 |
//! @SYMTestStatus Implemented |
|
30 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
31 |
#define __E32TEST_EXTENSION__ |
0 | 32 |
#include <e32test.h> |
33 |
RTest test(_L("T_NANDPAGING")); |
|
34 |
||
35 |
#include <e32rom.h> |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
36 |
#include <e32svr.h> |
0 | 37 |
#include <u32hal.h> |
38 |
#include <f32file.h> |
|
39 |
#include <f32dbg.h> |
|
40 |
#include "testdefs.h" |
|
41 |
#include <hal.h> |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
42 |
#include "nfe.h" |
0 | 43 |
|
44 |
||
45 |
TInt DriveNumber=-1; // Parameter - Which drive? -1 = autodetect. |
|
46 |
TInt locDriveNumber; |
|
47 |
||
48 |
TInt MaxDeferLoops=40; // Parameter - Defer test, for how long? |
|
49 |
TInt Maxloops=400; // Parameter - RW Soak, for how long? |
|
50 |
TBool Forever=EFalse; // Parameter - RW Soak forever? |
|
51 |
||
52 |
TBool Testing=ETrue; // Used to communicate when testing has finished between threads. |
|
53 |
||
54 |
RFs TheFs; |
|
55 |
TBusLocalDrive Drive; |
|
56 |
TLocalDriveCapsV4 DriveCaps; |
|
57 |
||
58 |
TInt PagedTrashCount=0; // Incremented by threads, is used to detect preemption. |
|
59 |
TInt GlobError=KErrNone; // To communicate an error between threads. |
|
60 |
TBool CtrlIoCollectGarbageSupported = ETrue; |
|
61 |
TBool CtrlIoGetDeferStatsSupported = ETrue; |
|
62 |
||
63 |
||
64 |
const TInt KDiskSectorShift=9; |
|
65 |
const TInt KBufSizeInSectors=8; |
|
66 |
const TInt KBufSizeInBytes=(KBufSizeInSectors<<KDiskSectorShift)*40; |
|
67 |
||
68 |
LOCAL_D TBuf8<KBufSizeInBytes> Buffer; |
|
69 |
||
70 |
||
71 |
||
72 |
// Three functions for the garbage test. |
|
73 |
// CreateFile creates a file, and sets up the buffer for WriteNumber. |
|
74 |
// After the code has finished writing numbers to the start, |
|
75 |
// CloseAndDestroy cleans up. |
|
76 |
||
77 |
void CreateFile(RFile &aFile,const TDesC& aFileName) |
|
78 |
{ |
|
79 |
TBuf<256> fileName; |
|
80 |
fileName.Append((TChar)('A'+DriveNumber)); |
|
81 |
fileName+=_L(":\\f32-tst\\"); |
|
82 |
TInt r=TheFs.MkDirAll(fileName); |
|
83 |
test(r==KErrNone || r== KErrAlreadyExists); |
|
84 |
||
85 |
fileName += aFileName; |
|
86 |
||
87 |
r=aFile.Replace(TheFs,fileName,EFileWrite); |
|
88 |
if (r!=KErrNone) |
|
89 |
test.Printf(_L("Error %d: file '%S' could not be created\n"),r,&fileName); |
|
90 |
test(r==KErrNone); |
|
91 |
Buffer.SetLength(4); |
|
92 |
} |
|
93 |
||
94 |
void CloseAndDestroy(RFile &aFile) |
|
95 |
{ |
|
96 |
TBuf<256> fileName; |
|
97 |
aFile.FullName(fileName); |
|
98 |
aFile.Close(); |
|
99 |
TheFs.Delete(fileName); |
|
100 |
} |
|
101 |
||
102 |
TInt WriteNumber(RFile &aFile) |
|
103 |
{ |
|
104 |
TInt r; |
|
105 |
Buffer[0]++; |
|
106 |
r = aFile.Write(0,Buffer); |
|
107 |
if (r==KErrNone) |
|
108 |
return aFile.Flush(); |
|
109 |
else |
|
110 |
return r; |
|
111 |
} |
|
112 |
||
113 |
||
114 |
||
115 |
// The r/w soaktest leaves the drive in a mess. |
|
116 |
// Formatting is needed afterwards. |
|
117 |
||
118 |
void silentFormat(TInt driveNo) |
|
119 |
{ |
|
120 |
TBuf<4> driveBuf=_L("?:\\"); |
|
121 |
RFormat format; |
|
122 |
TInt count; |
|
123 |
||
124 |
driveBuf[0] = (TText)(driveNo + 'A'); |
|
125 |
||
126 |
TInt r = format.Open(TheFs, driveBuf, EHighDensity, count); |
|
127 |
test(r == KErrNone); |
|
128 |
||
129 |
while(count) |
|
130 |
{ |
|
131 |
r=format.Next(count); |
|
132 |
test(r == KErrNone); |
|
133 |
} |
|
134 |
||
135 |
format.Close(); |
|
136 |
} |
|
137 |
||
138 |
// Finds the 1st r/w NAND drive, or checks the specified one fits requirements |
|
139 |
||
140 |
static TInt FindFsNANDDrive() |
|
141 |
{ |
|
142 |
TDriveList driveList; |
|
143 |
TDriveInfo driveInfo; |
|
144 |
TInt r=TheFs.DriveList(driveList); |
|
145 |
test(r == KErrNone); |
|
146 |
||
147 |
for (TInt drvNum= (DriveNumber<0)?0:DriveNumber; drvNum<KMaxDrives; ++drvNum) |
|
148 |
{ |
|
149 |
if(!driveList[drvNum]) |
|
150 |
continue; //-- skip unexisting drive |
|
151 |
||
152 |
test(TheFs.Drive(driveInfo, drvNum) == KErrNone); |
|
153 |
||
154 |
if ((driveInfo.iMediaAtt&KMediaAttPageable) && |
|
155 |
(driveInfo.iType == EMediaNANDFlash) && |
|
156 |
(driveInfo.iDriveAtt & KDriveAttInternal)) |
|
157 |
{ |
|
158 |
TBool readOnly = driveInfo.iMediaAtt & KMediaAttWriteProtected; // skip ROFS partitions |
|
159 |
if(!readOnly) |
|
160 |
{ |
|
161 |
if ((drvNum==DriveNumber) || (DriveNumber<0)) // only test if running on this drive |
|
162 |
{ |
|
163 |
return (drvNum); |
|
164 |
} |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
return (-1); |
|
169 |
} |
|
170 |
||
171 |
||
172 |
// |
|
173 |
// Writes to main area for the entire disk and reads back to verify. |
|
174 |
// The function is called from TestNandAccuratcy, which will have also |
|
175 |
// started the background RepeatedPagingThread |
|
176 |
// |
|
177 |
void testWriteMain() |
|
178 |
{ |
|
179 |
TInt i; |
|
180 |
TInt r; |
|
181 |
TInt changeCount=0; |
|
182 |
TInt totChangeCount=0; |
|
183 |
TInt cCount=0; |
|
184 |
TInt fullcCount=0; |
|
185 |
TInt oldPagedTrashCount=0; |
|
186 |
TInt delta=0; |
|
187 |
TInt high=0; |
|
188 |
TInt tot=0; |
|
189 |
TInt fullTot=0; |
|
190 |
TInt blockNo; |
|
191 |
||
192 |
// read size is 64K |
|
193 |
TInt readSize = (64*1024); |
|
194 |
TInt64 size = DriveCaps.iSize - (DriveCaps.iSize % readSize); |
|
195 |
||
196 |
// print position every 128K |
|
197 |
TInt64 printBlockPos = 128 * 1024; |
|
198 |
test (size > printBlockPos); |
|
199 |
||
200 |
// check for paging activity every 1MB |
|
201 |
TInt64 checkChangePos = 1024*1024; |
|
202 |
while (checkChangePos > size) |
|
203 |
checkChangePos>>= 1; |
|
204 |
||
205 |
||
206 |
SDeferStats stats; |
|
207 |
TInt pageGarbageCount=0; |
|
208 |
TInt pageOtherCount=0; |
|
209 |
TInt normalGarbageCount=0; |
|
210 |
TInt normalOtherCount=0; |
|
211 |
||
212 |
||
213 |
Buffer.SetLength(2*readSize); |
|
214 |
||
215 |
TPtr8 subBuf1(&Buffer[0],readSize); |
|
216 |
TPtrC8 subBuf2(&Buffer[readSize], readSize); |
|
217 |
||
218 |
test.Printf(_L("Page size = %d\n"), DriveCaps.iNumBytesMain); |
|
219 |
test.Printf(_L("Erase block size = %d\n"), DriveCaps.iEraseBlockSize); |
|
220 |
test.Printf(_L("Media size (rounded down) = %ld\n"), size); |
|
221 |
||
222 |
for(i = 0; i<readSize; i++) |
|
223 |
Buffer[readSize+i] = (char)(i%100); |
|
224 |
||
225 |
// Zero Stats |
|
226 |
if(CtrlIoGetDeferStatsSupported) |
|
227 |
{ |
|
228 |
TPtr8 statsBuf((TUint8*) &stats, sizeof(stats)); |
|
229 |
test(Drive.ControlIO(KNandGetDeferStats,statsBuf,0)==KErrNone); |
|
230 |
} |
|
231 |
||
232 |
||
233 |
while (((totChangeCount<Maxloops) || Forever) && (GlobError==KErrNone)) |
|
234 |
{ |
|
235 |
for(TInt64 pos=0; |
|
236 |
(pos<size) && ((totChangeCount<Maxloops) || Forever) && (GlobError==KErrNone); |
|
237 |
pos+=(TUint)(readSize)) |
|
238 |
{ |
|
239 |
blockNo=I64LOW(pos / DriveCaps.iEraseBlockSize); |
|
240 |
if ((pos % printBlockPos) == 0) |
|
241 |
test.Printf(_L("Block %d at pos %lu \r"), blockNo, pos); |
|
242 |
||
243 |
//write the pattern |
|
244 |
r = Drive.Write(pos,subBuf2); |
|
245 |
test(r==KErrNone); |
|
246 |
||
247 |
//read back and verify |
|
248 |
r = Drive.Read(pos,readSize,subBuf1); |
|
249 |
test(r==KErrNone); |
|
250 |
||
251 |
for(i=0;i<readSize;i++) |
|
252 |
if(Buffer[i]!=Buffer[readSize+i]) |
|
253 |
{ |
|
254 |
r = KErrCorrupt; |
|
255 |
break; |
|
256 |
} |
|
257 |
delta = PagedTrashCount-oldPagedTrashCount; |
|
258 |
cCount++; |
|
259 |
if (delta) |
|
260 |
{ |
|
261 |
if (delta>high) |
|
262 |
high=delta; |
|
263 |
tot+=delta; |
|
264 |
||
265 |
oldPagedTrashCount=PagedTrashCount; |
|
266 |
changeCount++; |
|
267 |
} |
|
268 |
||
269 |
if ((pos > 0) && (pos % checkChangePos) == 0) |
|
270 |
{ |
|
271 |
totChangeCount+=changeCount; |
|
272 |
if(CtrlIoGetDeferStatsSupported) |
|
273 |
{ |
|
274 |
test.Printf(_L("\nHigh%4d Avg%2d %d%% CC=%4d \n"), high, (TInt) (tot/cCount), (TInt)(changeCount*100)/cCount, totChangeCount); |
|
275 |
||
276 |
TPtr8 statsBuf((TUint8*) &stats, sizeof(stats)); |
|
277 |
Drive.ControlIO(KNandGetDeferStats,statsBuf,0); |
|
278 |
test.Printf(_L("PG %d PO %d(%d%%) NG %d NO %d\n"),stats.iPageGarbage, stats.iPageOther, (TInt) ((stats.iPageOther*100)/cCount), stats.iNormalGarbage, stats.iNormalOther); |
|
279 |
||
280 |
test(stats.iPageOther>0); |
|
281 |
pageGarbageCount+=stats.iPageGarbage; |
|
282 |
pageOtherCount+=stats.iPageOther; |
|
283 |
normalGarbageCount+=stats.iNormalGarbage; |
|
284 |
normalOtherCount+=stats.iNormalOther; |
|
285 |
} |
|
286 |
||
287 |
high=0; |
|
288 |
||
289 |
fullTot+=tot; |
|
290 |
tot=0; |
|
291 |
||
292 |
fullcCount+=cCount; |
|
293 |
cCount=0; |
|
294 |
changeCount=0; |
|
295 |
} |
|
296 |
||
297 |
test(r==KErrNone); |
|
298 |
} // for loop |
|
299 |
||
300 |
if (CtrlIoGetDeferStatsSupported) |
|
301 |
{ |
|
302 |
test.Printf(_L("\nTotals: Avg %2d %d%% CC=%4d \n"), fullTot/fullcCount, (TInt)(totChangeCount*100)/fullcCount, totChangeCount); |
|
303 |
test.Printf(_L("PG %d PO %d(%d%%) NG %d NO %d\n"),pageGarbageCount, pageOtherCount,(TInt) (pageOtherCount*100/fullcCount), normalGarbageCount, normalOtherCount ); |
|
304 |
} |
|
305 |
||
306 |
// If totChangeCount does not change, nand maybe busy waiting. |
|
307 |
test(totChangeCount>0); |
|
308 |
} // while () |
|
309 |
||
310 |
if (GlobError!=KErrNone) |
|
311 |
{ |
|
312 |
test.Printf(_L("\nPaging failed with %x\n"), GlobError); |
|
313 |
test(0); |
|
314 |
} |
|
315 |
else |
|
316 |
test.Printf(_L("\ndone\n")); |
|
317 |
} |
|
318 |
||
319 |
||
320 |
TUint8 ReadByte(volatile TUint8* aPtr) |
|
321 |
{ |
|
322 |
return *aPtr; |
|
323 |
} |
|
324 |
||
325 |
#define READ(a) ReadByte((volatile TUint8*)(a)) |
|
326 |
||
327 |
TUint32 RandomNo =0; |
|
328 |
||
329 |
TUint32 Random() |
|
330 |
{ |
|
331 |
RandomNo = RandomNo*69069+1; |
|
332 |
return RandomNo; |
|
333 |
} |
|
334 |
||
335 |
||
336 |
// Many instances of this run while testWriteMain runs, |
|
337 |
// to cause random background paging. |
|
338 |
||
339 |
LOCAL_C TInt RepeatedPagingThread(TAny* aUseTb) |
|
340 |
{ |
|
341 |
TBool trashBurst = EFalse; |
|
342 |
// This makes the paging system continually page stuff. |
|
343 |
// get info about a paged ROM... |
|
344 |
||
345 |
TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
|
346 |
TUint8* start = (TUint8*)romHeader+romHeader->iPageableRomStart; |
|
347 |
TUint size = romHeader->iPageableRomSize; |
|
348 |
TInt pageSize = 0; |
|
349 |
PagedTrashCount=1; |
|
350 |
||
351 |
UserSvr::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&pageSize,0); |
|
352 |
RandomNo=123; |
|
353 |
PagedTrashCount++; |
|
354 |
||
355 |
while (Testing) |
|
356 |
{ |
|
357 |
TInt r=UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0); |
|
358 |
if (Random() & 1) |
|
359 |
User::AfterHighRes(500+Random() & 2047); |
|
360 |
||
361 |
if (r<0) |
|
362 |
{ |
|
363 |
GlobError=r; |
|
364 |
PagedTrashCount=99; |
|
365 |
return (KErrNone); |
|
366 |
} |
|
367 |
if (trashBurst) |
|
368 |
{ |
|
369 |
if ((Random() & 0xf) == 0xf) |
|
370 |
trashBurst=EFalse; |
|
371 |
PagedTrashCount++; |
|
372 |
} |
|
373 |
else |
|
374 |
{ |
|
375 |
||
376 |
for(TInt i=size/(pageSize); (i>0) && !trashBurst; --i) |
|
377 |
{ |
|
378 |
READ(start+((TInt64(Random())*TInt64(size))>>32)); |
|
379 |
if ((RandomNo & 0x3f) == 0x3f) |
|
380 |
{ |
|
381 |
trashBurst= (TBool) aUseTb; |
|
382 |
} |
|
383 |
PagedTrashCount++; |
|
384 |
if (RandomNo & 1) |
|
385 |
User::AfterHighRes(500+Random() & 2047); |
|
386 |
} |
|
387 |
} |
|
388 |
||
389 |
} |
|
390 |
return(KErrNone); |
|
391 |
} |
|
392 |
||
393 |
||
394 |
// This starts up multiple instances of repeatedPagingThread, and runs testWriteMain. |
|
395 |
// After its done, it calls format, to clean up the drive. |
|
396 |
||
397 |
void TestNandAccuratcy() |
|
398 |
{ |
|
399 |
RThread thisThread; |
|
400 |
const TInt KNoThreads=10; |
|
401 |
TInt i; |
|
402 |
test.Printf(_L("Reset concurrency stats\n")); |
|
403 |
||
404 |
i=UserSvr::HalFunction(EHalGroupMedia,EMediaHalResetConcurrencyInfo,(TAny*)locDriveNumber,(TAny*)EMediaPagingStatsRom); |
|
405 |
test(i==KErrNone || i==KErrNotSupported); |
|
406 |
if(i==KErrNotSupported) |
|
407 |
test.Printf(_L("Concurrency stats not supported on this build\n")); |
|
408 |
i=UserSvr::HalFunction(EHalGroupMedia,EMediaHalResetPagingBenchmark,(TAny*)locDriveNumber,(TAny*)EMediaPagingStatsRom); |
|
409 |
test(i==KErrNone || i==KErrNotSupported); |
|
410 |
if(i==KErrNotSupported) |
|
411 |
test.Printf(_L("Benchmark stats not supported on this build\n")); |
|
412 |
||
413 |
if (Maxloops>0) |
|
414 |
{ |
|
415 |
TRequestStatus stat[KNoThreads]; |
|
416 |
// Start Read Test |
|
417 |
RThread repeatedPagingThread[KNoThreads]; |
|
418 |
||
419 |
test.Next(_L("Read/Write and Page test")); |
|
420 |
||
421 |
Testing=ETrue; |
|
422 |
for (i=0; i<KNoThreads; i++) |
|
423 |
{ |
|
424 |
||
425 |
test(repeatedPagingThread[i].Create(_L(""),RepeatedPagingThread,KDefaultStackSize,NULL,(TAny*) ETrue)==KErrNone); |
|
426 |
repeatedPagingThread[i].Logon(stat[i]); |
|
427 |
test(stat[i]==KRequestPending); |
|
428 |
repeatedPagingThread[i].Resume(); |
|
429 |
} |
|
430 |
// Start repeated paging. |
|
431 |
thisThread.SetPriority(EPriorityMore); |
|
432 |
testWriteMain(); |
|
433 |
Testing = 0; |
|
434 |
thisThread.SetPriority(EPriorityNormal); |
|
435 |
for (i=0; i<KNoThreads; i++) |
|
436 |
User::WaitForRequest(stat[i]); |
|
437 |
||
438 |
test.Printf(_L("Collect concurrency stats\n")); |
|
439 |
SMediaROMPagingConcurrencyInfo info; |
|
440 |
SPagingBenchmarkInfo infoBench; |
|
441 |
i=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetROMConcurrencyInfo,(TAny*)locDriveNumber,&info); |
|
442 |
test(i==KErrNone || i==KErrNotSupported); |
|
443 |
TInt r=UserSvr::HalFunction(EHalGroupMedia,EMediaHalGetROMPagingBenchmark,(TAny*)locDriveNumber,&infoBench); |
|
444 |
test(r==KErrNone || r==KErrNotSupported); |
|
445 |
if(i==KErrNone) |
|
446 |
{ |
|
447 |
test.Printf(_L("Media concurrency stats:\n\n")); |
|
448 |
test.Printf(_L("The total number of page in requests issued whilst processing other page in requests: %d\n"),info.iTotalConcurrentReqs); |
|
449 |
test.Printf(_L("The total number of page in requests issued with at least one queue not empty: %d\n"),info.iTotalReqIssuedNonEmptyQ); |
|
450 |
test.Printf(_L("The maximum number of pending page in requests in the main queue any time during this session: %d\n"),info.iMaxReqsInPending); |
|
451 |
test.Printf(_L("The maximum number of pending page in requests in the deferred queue any time during this session: %d\n"),info.iMaxReqsInDeferred); |
|
452 |
test.Printf(_L("The total number of page in requests first-time deferred during this session: %d\n"),info.iTotalFirstTimeDeferrals); |
|
453 |
test.Printf(_L("The total number of page in requests re-deferred during this session: %d\n"),info.iTotalReDeferrals); |
|
454 |
test.Printf(_L("The maximum number of deferrals of any single page in request during this session: %d\n"),info.iMaxDeferrals); |
|
455 |
test.Printf(_L("The total number of times the main queue was emptied when completing an asynchronous request during this session: %d\n"),info.iTotalSynchEmptiedMainQ); |
|
456 |
test.Printf(_L("The total number of page in requests serviced from main queue when completing an asynchronous request: %d\n"),info.iTotalSynchServicedFromMainQ); |
|
457 |
test.Printf(_L("The total number of page in requests deferred after being picked out of main queue when completing an asynchronous request: %d\n"),info.iTotalSynchDeferredFromMainQ); |
|
458 |
test.Printf(_L("The total number of times the page in DFC run with an empty main queue during this session: %d\n"),info.iTotalRunDry); |
|
459 |
test.Printf(_L("The total number of dry runs of paging DFC avoided during this session: %d\n"),info.iTotalDryRunsAvoided); |
|
460 |
} |
|
461 |
||
462 |
if(r==KErrNone) |
|
463 |
{ |
|
464 |
TInt freq = 0; |
|
465 |
r = HAL::Get(HAL::EFastCounterFrequency, freq); |
|
466 |
if (r==KErrNone) |
|
467 |
{ |
|
468 |
TReal mult = 1000000.0 / freq; |
|
469 |
TReal min = 0.0; |
|
470 |
TReal max = 0.0; |
|
471 |
TReal avg = 0.0; |
|
472 |
if (infoBench.iCount != 0) |
|
473 |
{ |
|
474 |
min = infoBench.iMinTime * mult; |
|
475 |
max = infoBench.iMaxTime * mult; |
|
476 |
avg = (infoBench.iTotalTime * mult) / infoBench.iCount; |
|
477 |
} |
|
478 |
test.Printf(_L("Media benchmarks:\n\n")); |
|
479 |
test.Printf(_L("The total number of page in requests issued: %d\n"),infoBench.iCount); |
|
480 |
test.Printf(_L("The average latency of any page in request in the Media subsystem: %9.1f(us)\n"),avg); |
|
481 |
test.Printf(_L("The maximum latency of any page in request in the Media subsystem: %9.1f(us)\n"),max); |
|
482 |
test.Printf(_L("The minimum latency of any page in request in the Media subsystem: %9.1f(us)\n"),min); |
|
483 |
} |
|
484 |
} |
|
485 |
||
486 |
test.Printf(_L("Formatting...\n")); |
|
487 |
silentFormat(DriveNumber); |
|
488 |
} |
|
489 |
else |
|
490 |
test.Next(_L("Read/Write test - Skipped!")); |
|
491 |
||
492 |
} |
|
493 |
||
494 |
||
495 |
// ************************************************************************************ |
|
496 |
||
497 |
||
498 |
// This code causes a flush |
|
499 |
// It is done in a second thread to see if you really do get just |
|
500 |
// one deferral, with the other page requests just waiting in line. |
|
501 |
// (Paging is not re-entrant) |
|
502 |
||
503 |
TInt PagesBeingPaged=0; |
|
504 |
RMutex PageMutex; |
|
505 |
RSemaphore PageSemaphore; |
|
506 |
RSemaphore PageDoneSemaphore; |
|
507 |
||
508 |
LOCAL_C TInt CausePage(TAny*) |
|
509 |
{ |
|
510 |
TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
|
511 |
TUint8* start = (TUint8*)romHeader+romHeader->iPageableRomStart; |
|
512 |
TUint size = romHeader->iPageableRomSize; |
|
513 |
TUint8* addr=NULL; |
|
514 |
TBool flush; |
|
515 |
while (Testing) |
|
516 |
{ |
|
517 |
PageSemaphore.Wait(); // wait for main thread to want paging. |
|
518 |
flush = (PagesBeingPaged==0); |
|
519 |
addr=start+((TInt64(Random())*TInt64(size))>>32); |
|
520 |
PageDoneSemaphore.Signal(); // Acknolage request. |
|
521 |
||
522 |
PageMutex.Wait(); |
|
523 |
PagesBeingPaged++; |
|
524 |
PageMutex.Signal(); |
|
525 |
||
526 |
if (flush) |
|
527 |
UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0); |
|
528 |
READ(addr); |
|
529 |
||
530 |
PageMutex.Wait(); |
|
531 |
PagesBeingPaged--; |
|
532 |
PageMutex.Signal(); |
|
533 |
} |
|
534 |
return 0; |
|
535 |
} |
|
536 |
||
537 |
||
538 |
// TestDefered causes garbage collection, and then triggers paging to happen, which should be defered. |
|
539 |
// One would only expect one defered request, as the paging system is not reentrant, but this is checked. |
|
540 |
||
541 |
void TestDefered() |
|
542 |
{ |
|
543 |
if (MaxDeferLoops==0) |
|
544 |
{ |
|
545 |
test.Next(_L("Defering test - Skipped!")); |
|
546 |
return; |
|
547 |
} |
|
548 |
||
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
549 |
// If the NFE test media driver extension is present, ALL the drive is encrypted; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
550 |
// this means that there will be very few free blocks in the free block reservoir: this effectively |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
551 |
// disables background garbage collection and all block erasing needs to happen on the fly... |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
552 |
TNfeDeviceInfo nfeDeviceinfo; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
553 |
TPtr8 nfeDeviceInfoBuf((TUint8*) &nfeDeviceinfo, sizeof(nfeDeviceinfo)); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
554 |
nfeDeviceInfoBuf.FillZ(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
555 |
TInt r = Drive.QueryDevice((RLocalDrive::TQueryDevice) EQueryNfeDeviceInfo, nfeDeviceInfoBuf); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
556 |
/* |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
557 |
if (r == KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
558 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
559 |
test.Printf(_L("NFE device detected, aborting garbage collection test for now\n")); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
560 |
return; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
561 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
562 |
*/ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
563 |
// Create some free blocks by creating a huge file and then deleting it.... |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
564 |
if (r == KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
565 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
566 |
test.Printf(_L("NFE device detected\n")); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
567 |
RFile file; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
568 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
569 |
TBuf<256> tempFileName = _L("?:\\f32-tst\\"); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
570 |
tempFileName[0] = 'A'+DriveNumber; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
571 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
572 |
r = TheFs.MkDirAll(tempFileName); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
573 |
test(r==KErrNone || r== KErrAlreadyExists); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
574 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
575 |
tempFileName+= _L("TEMP.TXT"); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
576 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
577 |
r = file.Replace(TheFs, tempFileName, EFileWrite); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
578 |
test_KErrNone(r); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
579 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
580 |
for (TInt fileSize = KMaxTInt; fileSize > 0; fileSize >>= 1) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
581 |
{ |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
582 |
r = file.SetSize(fileSize); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
583 |
test.Printf(_L("Setting file size to %d, r %d\n"), fileSize, r); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
584 |
if (r == KErrNone) |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
585 |
break; |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
586 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
587 |
file.Close(); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
588 |
r = TheFs.Delete(tempFileName); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
589 |
test_KErrNone(r); |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
590 |
} |
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
591 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
592 |
|
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
593 |
|
0 | 594 |
TInt timeout; |
595 |
TInt writesNeeded=100; |
|
596 |
RFile tempFile; |
|
597 |
TInt i; |
|
598 |
TInt ii; |
|
599 |
TInt runs=0; |
|
600 |
||
601 |
SDeferStats stats; |
|
602 |
TInt pageGarbageCount=0; |
|
603 |
TInt pageOtherCount=0; |
|
604 |
TInt normalGarbageCount=0; |
|
605 |
TInt normalOtherCount=0; |
|
606 |
||
607 |
||
608 |
// Set up thread sync |
|
609 |
test(PageMutex.CreateLocal()==KErrNone); |
|
610 |
test(PageSemaphore.CreateLocal(0)==KErrNone); |
|
611 |
test(PageDoneSemaphore.CreateLocal(0)==KErrNone); |
|
612 |
||
613 |
||
614 |
||
615 |
const TInt KMaxPageThreads = 2; |
|
616 |
UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0); |
|
617 |
// Set up threads |
|
618 |
RThread pageThread[KMaxPageThreads]; |
|
619 |
TRequestStatus stat[KMaxPageThreads]; |
|
620 |
Testing=ETrue; |
|
621 |
for (i=0; i<KMaxPageThreads; i++) |
|
622 |
{ |
|
623 |
test(pageThread[i].Create(_L(""),CausePage,KDefaultStackSize,NULL,NULL)==KErrNone); |
|
624 |
pageThread[i].Logon(stat[i]); |
|
625 |
test(stat[i]==KRequestPending); |
|
626 |
pageThread[i].SetPriority(EPriorityMore); |
|
627 |
pageThread[i].Resume(); |
|
628 |
} |
|
629 |
||
630 |
||
631 |
test.Next(_L("Defering test")); |
|
632 |
||
633 |
// clear counters |
|
634 |
TPtr8 statsBuf((TUint8*) &stats, sizeof(stats)); |
|
635 |
test(Drive.ControlIO(KNandGetDeferStats,statsBuf,0)==KErrNone); |
|
636 |
||
637 |
CreateFile(tempFile,_L("nandpage.txt")); |
|
638 |
||
639 |
||
640 |
for (ii=0; ii<MaxDeferLoops; ii++) // Repeat the test, 'MaxDeferLoops' number of times. This can be set on cammand line. |
|
641 |
{ |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
642 |
writesNeeded=100; |
0 | 643 |
timeout=20; |
644 |
do // while ((pageGarbageCount==0) && (timeout>0)); |
|
645 |
// ie, while garbage collection hasn't happened, or timed out |
|
646 |
{ |
|
647 |
timeout--; |
|
648 |
pageGarbageCount=0; |
|
649 |
pageOtherCount=0; |
|
650 |
normalGarbageCount=0; |
|
651 |
normalOtherCount=0; |
|
652 |
||
653 |
// Give somethng for garbage collector to collect |
|
654 |
for (i=0; i<writesNeeded; i++) |
|
655 |
test(WriteNumber(tempFile)==KErrNone); |
|
656 |
||
657 |
// Force Collection. (Normally only happens in Idle) |
|
658 |
r = Drive.ControlIO(KNandCollectGarbage,NULL,NULL); |
|
659 |
test(r==KErrNone); |
|
660 |
||
661 |
// Since garbage Colleciton should be going now, watch it, until its finished. |
|
662 |
do |
|
663 |
{ |
|
664 |
runs = PagesBeingPaged; |
|
665 |
for (i=runs; i<KMaxPageThreads; i++) |
|
666 |
PageSemaphore.Signal(); // Trigger Paging. |
|
667 |
||
668 |
for (i=runs; i<KMaxPageThreads; i++) |
|
669 |
PageDoneSemaphore.Wait(); |
|
670 |
||
671 |
TInt tries = 10; |
|
672 |
do { // If we get zero hits, maybe the page hasnt hit yet. |
|
673 |
tries--; |
|
674 |
User::AfterHighRes(1000+Random() & 2047); // Throw some uncertainly into things |
|
675 |
||
676 |
TPtr8 statsBuf((TUint8*) &stats, sizeof(stats)); |
|
677 |
r = Drive.ControlIO(KNandGetDeferStats,statsBuf,0); |
|
678 |
test (r == KErrNone); |
|
679 |
pageGarbageCount+=stats.iPageGarbage; |
|
680 |
pageOtherCount+=stats.iPageOther; |
|
681 |
normalGarbageCount+=stats.iNormalGarbage; |
|
682 |
normalOtherCount+=stats.iNormalOther; |
|
683 |
} while ((pageGarbageCount==0) && (tries>0)); // If we get zero hits, maybe the page hasnt hit yet |
|
684 |
} |
|
685 |
while (stats.iPageGarbage>0); // Keep going until collection seems to have finished. |
|
686 |
||
687 |
// The paging system is not reentrant, so should never get more then one. |
|
688 |
test(stats.iPageGarbage<2); |
|
689 |
||
690 |
test.Printf(_L("%d: PG %d PO %d NG %d NO %d\n"),ii,pageGarbageCount, pageOtherCount, normalGarbageCount, normalOtherCount ); |
|
691 |
// if no collection, probebly didnt write enough to trigger it, so up the quantity. |
|
692 |
if (pageGarbageCount==0) |
|
693 |
{ |
|
694 |
writesNeeded+=writesNeeded/2; |
|
695 |
test.Printf(_L("Writes needed = %d\n"),writesNeeded); |
|
696 |
} |
|
697 |
||
698 |
} |
|
699 |
while ((pageGarbageCount==0) && (timeout>0)); |
|
700 |
test(timeout>0); |
|
701 |
||
702 |
} // end for MaxDeferLoops. |
|
703 |
||
704 |
// Clean up. . . . . |
|
705 |
||
706 |
Testing=EFalse; // Setting this causes the CausePage threads to exit. |
|
707 |
||
708 |
// Wait for threads to exit, signaling the semaphore in case they where waiting on it. |
|
709 |
for (i=0; i<KMaxPageThreads; i++) |
|
710 |
PageSemaphore.Signal(); |
|
711 |
for (i=0; i<KMaxPageThreads; i++) |
|
712 |
User::WaitForRequest(stat[i]); |
|
713 |
||
714 |
PageMutex.Close(); |
|
715 |
PageSemaphore.Close(); |
|
716 |
PageDoneSemaphore.Close(); |
|
717 |
CloseAndDestroy(tempFile); |
|
718 |
} |
|
719 |
||
720 |
||
721 |
// ************************************************************************************ |
|
722 |
||
723 |
// |
|
724 |
// The gubbins that starts all the tests |
|
725 |
// |
|
726 |
// ParseCommandLine reads the arguments and sets globals accordingly. |
|
727 |
// |
|
728 |
||
729 |
void ParseCommandLine() |
|
730 |
{ |
|
731 |
TBuf<32> args; |
|
732 |
User::CommandLine(args); |
|
733 |
TLex lex(args); |
|
734 |
||
735 |
FOREVER |
|
736 |
{ |
|
737 |
||
738 |
TPtrC token=lex.NextToken(); |
|
739 |
if(token.Length()!=0) |
|
740 |
{ |
|
741 |
if ((token.Length()==2) && (token[1]==':')) |
|
742 |
DriveNumber=User::UpperCase(token[0])-'A'; |
|
743 |
else if (token.Length()==1) |
|
744 |
{ |
|
745 |
TChar driveLetter = User::UpperCase(token[0]); |
|
746 |
if ((driveLetter>='A') && (driveLetter<='Z')) |
|
747 |
DriveNumber=driveLetter - (TChar) 'A'; |
|
748 |
else |
|
749 |
test.Printf(_L("Unknown argument '%S' was ignored.\n"), &token); |
|
750 |
} |
|
751 |
else if ((token==_L("help")) || (token==_L("-h")) || (token==_L("-?"))) |
|
752 |
{ |
|
753 |
test.Printf(_L("\nUsage: t_nandpaging <driveletter> [rwsoak <cc>] [defer <c>]\n'-' indicated infinity.\n\n")); |
|
754 |
test.Getch(); |
|
755 |
Maxloops=0; |
|
756 |
} |
|
757 |
else if (token==_L("rwsoak")) |
|
758 |
{ |
|
759 |
TPtrC val=lex.NextToken(); |
|
760 |
TLex lexv(val); |
|
761 |
TInt v; |
|
762 |
||
763 |
if (val==_L("-")) |
|
764 |
Forever=ETrue; |
|
765 |
else |
|
766 |
if (lexv.Val(v)==KErrNone) |
|
767 |
Maxloops=v; |
|
768 |
else |
|
769 |
test.Printf(_L("Bad value for rwsoak '%S' was ignored.\n"), &val); |
|
770 |
} |
|
771 |
else if (token==_L("defer")) |
|
772 |
{ |
|
773 |
TPtrC val=lex.NextToken(); |
|
774 |
TLex lexv(val); |
|
775 |
TInt v; |
|
776 |
||
777 |
if (val==_L("-")) |
|
778 |
MaxDeferLoops=KMaxTInt; |
|
779 |
else |
|
780 |
if (lexv.Val(v)==KErrNone) |
|
781 |
MaxDeferLoops=v; |
|
782 |
else |
|
783 |
test.Printf(_L("Bad value for defer '%S' was ignored.\n"), &val); |
|
784 |
} |
|
785 |
else |
|
786 |
test.Printf(_L("Unknown argument '%S' was ignored.\n"), &token); |
|
787 |
} |
|
788 |
else |
|
789 |
break; |
|
790 |
||
791 |
} |
|
792 |
} |
|
793 |
||
794 |
// |
|
795 |
// E32Main |
|
796 |
// |
|
797 |
||
798 |
TInt E32Main() |
|
799 |
{ |
|
800 |
TInt r; |
|
801 |
test.Title(); |
|
802 |
||
803 |
test.Printf(_L("key\n---\n")); |
|
804 |
test.Printf(_L("PG: Paging requests defered due to Garbage\n")); |
|
805 |
test.Printf(_L("PO: Paging requests defered due to other operations\n")); |
|
806 |
test.Printf(_L("NG: Normal requests defered due to Garbage\n")); |
|
807 |
test.Printf(_L("NO: Normal requests defered due to other operations\n\n")); |
|
808 |
||
809 |
||
810 |
test.Start(_L("Check that the rom is paged")); |
|
811 |
TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
|
812 |
||
813 |
if (romHeader->iPageableRomStart==NULL) |
|
814 |
test.Printf(_L("Test ROM is not paged - test skipped!\r\n")); |
|
815 |
else |
|
816 |
{ |
|
817 |
ParseCommandLine(); |
|
818 |
test(TheFs.Connect()==KErrNone); |
|
819 |
||
820 |
r=UserSvr::HalFunction(EHalGroupVM,EVMHalFlushCache,0,0); |
|
821 |
if(r<0) |
|
822 |
{ |
|
823 |
test.Printf(_L("DemandPagingFlushPages Error = %d\n"),r); |
|
824 |
test(0); |
|
825 |
} |
|
826 |
||
827 |
DriveNumber = FindFsNANDDrive(); |
|
828 |
||
829 |
if(DriveNumber<0) |
|
830 |
test.Printf(_L("NAND Flash not found - test skipped!\r\n")); |
|
831 |
else |
|
832 |
{ |
|
833 |
RFile file; |
|
834 |
TBuf<256> fileName; |
|
835 |
fileName.Append((TChar)('A'+DriveNumber)); |
|
836 |
fileName+=_L(":\\f32-tst\\"); |
|
837 |
TInt r=TheFs.MkDirAll(fileName); |
|
838 |
test(r==KErrNone || r== KErrAlreadyExists); |
|
839 |
fileName += _L("annoyingflies.txt"); |
|
840 |
r=file.Replace(TheFs,fileName,EFileWrite); |
|
841 |
if (r!=KErrNone) |
|
842 |
test.Printf(_L("Error %d: file '%S' could not be created\n"),r,&fileName); |
|
843 |
test(r==KErrNone); |
|
844 |
r=file.Write(_L8("Flies as big as sparrows indoletly buzzing in the warm air, heavy with the stench of rotting carcasses")); |
|
845 |
if (r!=KErrNone) |
|
846 |
test.Printf(_L("Error %d: could not write to file\n"),r); |
|
847 |
test(r==KErrNone); |
|
848 |
||
849 |
test(file.Flush() == KErrNone); |
|
850 |
||
851 |
SBlockMapInfo info; |
|
852 |
TInt64 start=0; |
|
853 |
r=file.BlockMap(info,start, -1,ETestDebug); |
|
854 |
if (r!=KErrNone && r!=KErrCompletion) |
|
855 |
test.Printf(_L("Error %d: could not obtain block map\n"),r); |
|
856 |
test(r==KErrNone || r==KErrCompletion); |
|
857 |
locDriveNumber=info.iLocalDriveNumber; |
|
858 |
test.Printf(_L("Found drive: %c (NAND drive %d)\r\n"), DriveNumber+'A',locDriveNumber); |
|
859 |
file.Close(); |
|
860 |
||
861 |
// Connect to device driver |
|
862 |
TBool changeFlag = EFalse; |
|
863 |
r = Drive.Connect(locDriveNumber,changeFlag); |
|
864 |
TPckg<TLocalDriveCapsV4> capsPack(DriveCaps); |
|
865 |
Drive.Caps(capsPack); |
|
866 |
test(r == KErrNone); |
|
867 |
||
868 |
r = Drive.ControlIO(KNandCollectGarbage,NULL,NULL); |
|
869 |
if (r!=KErrNone) |
|
870 |
{ |
|
871 |
test.Printf(_L("LocalDrive does not support the KNandCollectGarbage ControlIO request\n")); |
|
872 |
CtrlIoCollectGarbageSupported = EFalse; |
|
873 |
} |
|
874 |
||
875 |
SDeferStats stats; |
|
876 |
TPtr8 statsBuf((TUint8*) &stats, sizeof(stats)); |
|
877 |
r = Drive.ControlIO(KNandGetDeferStats,statsBuf,0); |
|
878 |
if (r == KErrNone) |
|
879 |
{ |
|
880 |
if (stats.iSynchronousMediaDriver) |
|
881 |
{ |
|
882 |
test.Printf(_L("Media drive is synchronous - test skipped!\r\n")); |
|
883 |
test.End(); |
|
884 |
return 0; |
|
885 |
} |
|
886 |
} |
|
887 |
else |
|
888 |
{ |
|
889 |
test.Printf(_L("LocalDrive does not support the KNandGetDeferStats ControlIO request\n")); |
|
890 |
CtrlIoGetDeferStatsSupported = EFalse; |
|
891 |
} |
|
892 |
||
893 |
||
894 |
test.Printf(_L("LocalDrive Connected\n")); |
|
895 |
// |
|
896 |
// Run tests |
|
897 |
// |
|
898 |
TestNandAccuratcy(); |
|
899 |
if(CtrlIoCollectGarbageSupported && CtrlIoGetDeferStatsSupported) |
|
900 |
TestDefered(); |
|
901 |
// |
|
902 |
// Free device and end test program |
|
903 |
// |
|
904 |
Drive.Disconnect(); |
|
905 |
} |
|
906 |
} |
|
907 |
||
908 |
test.End(); |
|
909 |
return 0; |
|
910 |
} |
|
911 |
||
912 |