author | hgs |
Tue, 02 Nov 2010 15:42:21 +0000 | |
changeset 301 | 172f33f13d7d |
parent 287 | ddfd5aa0d58f |
permissions | -rw-r--r-- |
287 | 1 |
// Copyright (c) 1996-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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\pccd\t_mmcdrv.cpp |
|
15 |
// Test the MultiMediaCard (MMC) media driver |
|
287 | 16 |
// Spare Test case Numbers 0515-0519 |
0 | 17 |
// |
18 |
// |
|
19 |
||
287 | 20 |
#define __E32TEST_EXTENSION__ |
21 |
||
0 | 22 |
#include "../mmu/d_sharedchunk.h" |
23 |
#include <e32test.h> |
|
24 |
#include <e32svr.h> |
|
25 |
#include <e32hal.h> |
|
26 |
#include <e32uid.h> |
|
27 |
#include <f32fsys.h> |
|
28 |
#include <e32def.h> |
|
29 |
#include <e32def_private.h> |
|
30 |
||
31 |
const TInt KDiskSectorSize=512; |
|
32 |
const TInt KDiskSectorShift=9; |
|
33 |
const TUint KDiskSectorMask=0xFFFFFE00; |
|
34 |
const TInt KSectBufSizeInSectors=8; |
|
35 |
const TInt KSectBufSizeInBytes=(KSectBufSizeInSectors<<KDiskSectorShift); |
|
36 |
const TInt KRdWrBufLen=(KSectBufSizeInBytes+KDiskSectorSize); // 4.5K - exceeds driver local buffer size |
|
37 |
||
38 |
const TInt KShortFormatInSectors=1; |
|
39 |
const TInt KShortFormatInBytes=(KShortFormatInSectors<<KDiskSectorShift); |
|
40 |
const TInt KLongFormatInSectors=KSectBufSizeInSectors+1; // 4.5K - exceeds driver local buffer size |
|
41 |
const TInt KLongFormatInBytes=(KLongFormatInSectors<<KDiskSectorShift); |
|
42 |
||
43 |
const TInt KVeryLongSectBufSizeInSectors=4096; // ..2M |
|
44 |
const TInt KVeryLongSectBufSizeInBytes=(KVeryLongSectBufSizeInSectors<<KDiskSectorShift); // |
|
45 |
const TInt KVeryLongRdWrBufLen=(KVeryLongSectBufSizeInBytes+KDiskSectorSize); // 2M + 0.5K |
|
46 |
||
47 |
const TInt KHeapSize=0x4000; |
|
48 |
||
49 |
const TInt64 KDefaultRandSeed = MAKE_TINT64(0x501a501a, 0x501a501a); |
|
50 |
||
51 |
#define TEST_DOOR_CLOSE 0 // see comment in E32Main() |
|
52 |
||
53 |
||
54 |
class TMMCDrive : public TBusLocalDrive |
|
55 |
{ |
|
56 |
public: |
|
57 |
enum TTestMode |
|
58 |
{ |
|
59 |
ETestPartition, |
|
60 |
ETestWholeMedia, |
|
61 |
ETestSharedMemory, |
|
62 |
ETestSharedMemoryCache, |
|
63 |
ETestSharedMemoryFrag, |
|
64 |
ETestSharedMemoryFragCache, |
|
65 |
EMaxTestModes |
|
66 |
}; |
|
67 |
public: |
|
68 |
TMMCDrive(); |
|
69 |
||
70 |
TInt Read(TInt64 aPos, TInt aLength, TDes8& aTrg); |
|
71 |
TInt Write(TInt64 aPos, const TDesC8& aSrc); |
|
72 |
||
73 |
TInt SetTestMode(TTestMode aTestMode); |
|
74 |
TTestMode TestMode(); |
|
75 |
||
76 |
void SetSize(TInt64 aDriveSize, TInt64 aMediaSize); |
|
77 |
TInt64 Size(); |
|
78 |
private: |
|
79 |
TTestMode iTestMode; |
|
80 |
||
81 |
TInt64 iDriveSize; |
|
82 |
TInt64 iMediaSize; |
|
83 |
}; |
|
84 |
||
85 |
// Serial numbers for 'special case' test cards (ie - those with known problems) |
|
86 |
class TKnownCardTypes |
|
87 |
{ |
|
88 |
public: |
|
89 |
enum TCardType |
|
90 |
{ |
|
91 |
EStandardCard = 0, |
|
92 |
EBuffalloMiniSD_32M_ERASE, |
|
93 |
EBuffalloMiniSD_64M_ERASE, |
|
94 |
EBuffalloMiniSD_128M_ERASE, |
|
95 |
EBuffalloMiniSD_256M_ERASE, |
|
96 |
EBuffalloMiniSD_512M_ERASE, |
|
97 |
EBuffalloMiniSD_512M, |
|
98 |
EIntegralHSSD_2G, |
|
99 |
ESanDiskMmcMobile_1GB |
|
100 |
}; |
|
101 |
||
102 |
TKnownCardTypes(TCardType aCardType, const TText8* aSerialNumber) |
|
103 |
: iCardType(aCardType), iSerialNumber(aSerialNumber) {}; |
|
104 |
||
105 |
TCardType iCardType; |
|
106 |
const TText8* iSerialNumber; |
|
107 |
}; |
|
108 |
||
109 |
LOCAL_D TKnownCardTypes KnownCardTypes[] = |
|
110 |
{ |
|
111 |
//** The Following Buffalo Cards all have a known Mis-Implementation |
|
112 |
// When requesting Erase the area to be erase is specified in terms of a start (CMD32) and stop (CMD33) blocks |
|
113 |
// Specification states that CMD33 refers to the end block in terms of the first byte of that block |
|
114 |
// the Buffallo implementation requires that the last byte of the block is specified. |
|
115 |
||
116 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_32M_ERASE, _S8("936300c70e150d003630333046445004")), |
|
117 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_64M_ERASE, _S8("d96600456d120a003732343046445004")), |
|
118 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_128M_ERASE, _S8("f964000d13150c003630333046445004")), |
|
119 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_256M_ERASE, _S8("4d66004c68120a003732343046445004")), |
|
120 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_512M_ERASE, _S8("db6500824e0010013236333243454228")), |
|
121 |
||
122 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_32M_ERASE, _S8("df6400e60d150d003630333046445004")), |
|
123 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_64M_ERASE, _S8("296600386d120a003732343046445004")), |
|
124 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_128M_ERASE, _S8("b16400f512150c003630333046445004")), |
|
125 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_256M_ERASE, _S8("435600cc390000000000004453474b13")), |
|
126 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_512M_ERASE, _S8("ed6300de700000000000004453474b13")), |
|
127 |
//***********************************************************************************************// |
|
128 |
||
129 |
TKnownCardTypes(TKnownCardTypes::EBuffalloMiniSD_512M, _S8("0d56004e2d0000000000004453474b13")), |
|
130 |
TKnownCardTypes(TKnownCardTypes::EIntegralHSSD_2G, _S8("37570058073099114732304453000027")), |
|
131 |
TKnownCardTypes(TKnownCardTypes::ESanDiskMmcMobile_1GB,_S8("956a1c00001810303030303030000015")) |
|
132 |
}; |
|
133 |
||
134 |
||
135 |
LOCAL_D RTest test(_L("T_MMCDRV")); |
|
136 |
LOCAL_D RTest nTest(_L("This thread doesn't disconnect")); |
|
137 |
LOCAL_D TBool ChangeFlag; |
|
138 |
LOCAL_D TBool SecThreadChangeFlag; |
|
139 |
||
140 |
||
141 |
LOCAL_D TPtr8 wrBuf(NULL, KVeryLongRdWrBufLen); |
|
142 |
LOCAL_D TPtr8 rdBuf(NULL, KVeryLongRdWrBufLen); |
|
143 |
LOCAL_D HBufC8* wrBufH = NULL; |
|
144 |
LOCAL_D HBufC8* rdBufH = NULL; |
|
145 |
||
146 |
LOCAL_D TInt DriveNumber = -1; // Local Drive number |
|
147 |
LOCAL_D TInt RFsDNum = -1; // File Server Drive number |
|
148 |
LOCAL_D TMMCDrive TheMmcDrive; |
|
149 |
LOCAL_D TLocalDriveCapsV5Buf DriveCaps; |
|
150 |
LOCAL_D TKnownCardTypes::TCardType CardType; |
|
151 |
LOCAL_D TBool IsReadOnly; |
|
152 |
||
153 |
LOCAL_D RSharedChunkLdd Ldd; |
|
154 |
LOCAL_D RChunk TheChunk; |
|
155 |
LOCAL_D TInt PageSize; |
|
156 |
const TUint ChunkSize = 0x201000; //2MB+4096bytes > than largest transfer |
|
157 |
||
158 |
const TInt KSingSectorNo=1; |
|
159 |
const TInt64 KTwoGigbytes = 0x80000000; |
|
160 |
||
161 |
TBool mediaChangeSupported=EFalse; // ??? |
|
162 |
TBool ManualMode=EFalse; |
|
163 |
||
164 |
// Wrappers for the test asserts |
|
165 |
GLREF_C void TestIfError( TInt aValue, TInt aLine, const TText* aFile ); |
|
166 |
GLREF_C void TestIfErrorMsg( TInt aValue, TInt aLine, const TText* aFile, const TDesC& aMessageOnError ); |
|
167 |
GLREF_C void TestEqual( TInt aValue, TInt aExpected, TInt aLine, const TText* aFile ); |
|
168 |
GLREF_C void TestEqualMsg( TInt aValue, TInt aExpected, TInt aLine, const TText* aFile, const TDesC& aMessageOnError ); |
|
169 |
GLREF_C void TestEitherEqual( TInt aValue, TInt aExpected1, TInt aExpected2, TInt aLine, const TText* aFile ); |
|
170 |
GLREF_C void TestRange( TInt aValue, TInt aMin, TInt Max, TInt aLine, const TText* aFile ); |
|
171 |
||
172 |
#define TEST_FOR_ERROR2( r, l, f ) TestIfError( r, l, _S(f) ) |
|
173 |
#define TEST_FOR_ERROR_ERRMSG2( r, l, f, m ) TestIfErrorMsg( r, l, _S(f), m ) |
|
174 |
#define TEST_FOR_VALUE2( r, e, l, f ) TestEqual( r, e, l, _S(f) ) |
|
175 |
#define TEST_FOR_VALUE_ERRMSG2( r, e, l, f, m ) TestEqualMsg( r, e, l, _S(f), m ) |
|
176 |
#define TEST_FOR_EITHER_VALUE2( r, e1, e2, l, f ) TestEitherEqual( r, e1, e2, l, _S(f) ) |
|
177 |
#define TEST_FOR_RANGE2( r, min, max, l, f ) TestRange( r, min, max, l, _S(f) ) |
|
178 |
||
179 |
#define TEST_FOR_ERROR( r ) TEST_FOR_ERROR2( r, __LINE__, __FILE__ ) |
|
180 |
#define TEST_FOR_ERROR_ERRMSG( r, m ) TEST_FOR_ERRORMSG2( r, __LINE__, __FILE__, m ) |
|
181 |
#define TEST_FOR_VALUE( r, expected ) TEST_FOR_VALUE2( r, expected, __LINE__, __FILE__ ) |
|
182 |
#define TEST_FOR_VALUE_ERRMSG( r, expected, m ) TEST_FOR_VALUE_ERRMSG2( r, expected, __LINE__, __FILE__, m ) |
|
183 |
#define TEST_FOR_EITHER_VALUE( r, expected1, expected2 ) TEST_FOR_EITHER_VALUE2( r, expected1, expected2, __LINE__, __FILE__ ) |
|
184 |
#define TEST_FOR_RANGE( r, min, max ) TEST_FOR_RANGE2( r, min, max, __LINE__, __FILE__ ) |
|
185 |
||
186 |
GLDEF_C void TestIfError( TInt aValue, TInt aLine, const TText* aFile ) |
|
187 |
{ |
|
188 |
if( aValue < 0 ) |
|
189 |
{ |
|
190 |
_LIT( KErrorTestFailMsg, "ERROR %d\n\r" ); |
|
191 |
test.Printf( KErrorTestFailMsg, aValue ); |
|
192 |
test.operator()( EFalse, aLine, (const TText*)(aFile) ); |
|
193 |
} |
|
194 |
} |
|
195 |
||
196 |
GLDEF_C void TestIfErrorMsg( TInt aValue, TInt aLine, const TText* aFile, const TDesC& aMessageOnError ) |
|
197 |
{ |
|
198 |
if( aValue < 0 ) |
|
199 |
{ |
|
200 |
_LIT( KErrorTestFailMsg, "ERROR %d %S\n\r" ); |
|
201 |
test.Printf( KErrorTestFailMsg, aValue, &aMessageOnError ); |
|
202 |
test.operator()( EFalse, aLine, (const TText*)(aFile) ); |
|
203 |
} |
|
204 |
} |
|
205 |
||
206 |
||
207 |
GLDEF_C void TestEqual( TInt aValue, TInt aExpected, TInt aLine, const TText* aFile ) |
|
208 |
{ |
|
209 |
if( aExpected != aValue ) |
|
210 |
{ |
|
211 |
_LIT( KEqualTestFailMsg, "ERROR %d expected %d\n\r" ); |
|
212 |
test.Printf( KEqualTestFailMsg, aValue, aExpected ); |
|
213 |
test.operator()( EFalse, aLine, (const TText*)(aFile) ); |
|
214 |
} |
|
215 |
} |
|
216 |
||
217 |
GLDEF_C void TestEqualMsg( TInt aValue, TInt aExpected, TInt aLine, const TText* aFile, const TDesC& aMessageOnError ) |
|
218 |
{ |
|
219 |
if( aExpected != aValue ) |
|
220 |
{ |
|
221 |
_LIT( KEqualTestFailMsg, "ERROR %d expected %d %S\n\r" ); |
|
222 |
test.Printf( KEqualTestFailMsg, aValue, aExpected, &aMessageOnError ); |
|
223 |
test.operator()( EFalse, aLine, (const TText*)(aFile) ); |
|
224 |
} |
|
225 |
} |
|
226 |
||
227 |
GLDEF_C void TestEitherEqual( TInt aValue, TInt aExpected1, TInt aExpected2, TInt aLine, const TText* aFile ) |
|
228 |
{ |
|
229 |
if( (aExpected1 != aValue) && (aExpected2 != aValue) ) |
|
230 |
{ |
|
231 |
_LIT( KEqualTestFailMsg, "ERROR %d expected %d or %d\n\r" ); |
|
232 |
test.Printf( KEqualTestFailMsg, aValue, aExpected1, aExpected2 ); |
|
233 |
test.operator()( EFalse, aLine, (const TText*)(aFile) ); |
|
234 |
} |
|
235 |
} |
|
236 |
||
237 |
GLDEF_C void TestRange( TInt aValue, TInt aMin, TInt aMax, TInt aLine, const TText* aFile ) |
|
238 |
{ |
|
239 |
if( (aValue < aMin) || (aValue > aMax) ) |
|
240 |
{ |
|
241 |
_LIT( KRangeTestFailMsg, "ERROR 0x%x expected 0x%x..0x%x\n\r" ); |
|
242 |
test.Printf( KRangeTestFailMsg, aValue, aMin, aMax ); |
|
243 |
test.operator()( EFalse, aLine, (const TText*)(aFile) ); |
|
244 |
} |
|
245 |
} |
|
246 |
||
247 |
//// |
|
248 |
||
249 |
TMMCDrive::TMMCDrive() |
|
250 |
: iTestMode(ETestPartition), |
|
251 |
iDriveSize(0), |
|
252 |
iMediaSize(0) |
|
253 |
{ |
|
254 |
} |
|
255 |
||
256 |
TInt TMMCDrive::Read(TInt64 aPos,TInt aLength,TDes8& aTrg) |
|
257 |
{ |
|
258 |
if(iTestMode == ETestWholeMedia) |
|
259 |
{ |
|
260 |
return TBusLocalDrive::Read(aPos, aLength, &aTrg, KLocalMessageHandle, 0, RLocalDrive::ELocDrvWholeMedia); |
|
261 |
} |
|
262 |
else if(iTestMode != ETestPartition && aLength <= (TInt)ChunkSize) |
|
263 |
{ |
|
264 |
TPtr8 wholeBufPtr(TheChunk.Base(),aLength); |
|
265 |
||
266 |
TInt r = TBusLocalDrive::Read(aPos, aLength, wholeBufPtr); |
|
267 |
||
268 |
aTrg.Copy(wholeBufPtr); |
|
269 |
return r; |
|
270 |
} |
|
271 |
||
272 |
return TBusLocalDrive::Read(aPos, aLength, aTrg); |
|
273 |
} |
|
274 |
||
275 |
TInt TMMCDrive::Write(TInt64 aPos,const TDesC8& aSrc) |
|
276 |
{ |
|
277 |
if(iTestMode == ETestWholeMedia) |
|
278 |
{ |
|
279 |
return TBusLocalDrive::Write(aPos, aSrc.Length(), &aSrc, KLocalMessageHandle, 0, RLocalDrive::ELocDrvWholeMedia); |
|
280 |
} |
|
281 |
else if(iTestMode != ETestPartition && aSrc.Length() <= (TInt)ChunkSize) |
|
282 |
{ |
|
283 |
TPtr8 wholeBufPtr(TheChunk.Base(),aSrc.Length()); |
|
284 |
wholeBufPtr.Copy(aSrc); |
|
285 |
||
286 |
TInt r = TBusLocalDrive::Write(aPos, wholeBufPtr); |
|
287 |
||
288 |
return r; |
|
289 |
} |
|
290 |
||
291 |
return TBusLocalDrive::Write(aPos, aSrc); |
|
292 |
} |
|
293 |
||
294 |
TInt TMMCDrive::SetTestMode(TTestMode aTestMode) |
|
295 |
{ |
|
296 |
switch (aTestMode) |
|
297 |
{ |
|
298 |
case ETestWholeMedia : test.Printf(_L("\nTesting Whole Media\n")); break; |
|
299 |
case ETestPartition : test.Printf(_L("\nTesting Partition\n")); break; |
|
300 |
case ETestSharedMemory : test.Printf(_L("\nTesting Shared Memory\n")); break; |
|
301 |
case ETestSharedMemoryCache : test.Printf(_L("\nTesting Shared Memory (Caching)\n")); break; |
|
302 |
case ETestSharedMemoryFrag : test.Printf(_L("\nTesting Shared Memory (Fragmented)\n")); break; |
|
303 |
default : test.Printf(_L("\nTesting Shared Memory (Fragmented/Caching)\n")); break; |
|
304 |
} |
|
305 |
||
306 |
if(aTestMode == ETestWholeMedia && iMediaSize == 0) |
|
307 |
{ |
|
308 |
test.Printf(_L("...not supported")); |
|
309 |
return KErrNotSupported; |
|
310 |
} |
|
311 |
||
312 |
iTestMode = aTestMode; |
|
313 |
return KErrNone; |
|
314 |
} |
|
315 |
||
316 |
TMMCDrive::TTestMode TMMCDrive::TestMode() |
|
317 |
{ |
|
318 |
return iTestMode; |
|
319 |
} |
|
320 |
||
321 |
void TMMCDrive::SetSize(TInt64 aDriveSize, TInt64 aMediaSize) |
|
322 |
{ |
|
323 |
iDriveSize = aDriveSize; |
|
324 |
iMediaSize = aMediaSize; |
|
325 |
} |
|
326 |
||
327 |
TInt64 TMMCDrive::Size() |
|
328 |
{ |
|
329 |
switch (iTestMode) |
|
330 |
{ |
|
331 |
case ETestWholeMedia : return iMediaSize; |
|
332 |
default : return iDriveSize; |
|
333 |
} |
|
334 |
} |
|
335 |
||
336 |
////// |
|
337 |
||
338 |
GLDEF_C void DumpBuffer( const TDesC8& aBuffer ) |
|
339 |
/** |
|
340 |
* Dump the content of aBuffer in hex |
|
341 |
*/ |
|
342 |
{ |
|
343 |
static const TText hextab[16] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', |
|
344 |
'A', 'B', 'C', 'D', 'E', 'F' }; |
|
345 |
const TInt KBytesPerLine = 32; |
|
346 |
const TInt KCharsPerLine = KBytesPerLine * 2; |
|
347 |
||
348 |
TInt remaining = aBuffer.Length(); |
|
349 |
TUint8* pSrc = const_cast<TUint8*>(aBuffer.Ptr()); |
|
350 |
||
351 |
TBuf<KCharsPerLine> line; |
|
352 |
line.SetLength( KCharsPerLine ); // don't need to print trailing space |
|
353 |
TInt bytesPerLine = KBytesPerLine; |
|
354 |
TInt lineOffs = 0; |
|
355 |
while( remaining ) |
|
356 |
{ |
|
357 |
if( remaining < KBytesPerLine ) |
|
358 |
{ |
|
359 |
bytesPerLine = remaining; |
|
360 |
line.SetLength( (bytesPerLine*2) ); |
|
361 |
} |
|
362 |
TUint16* pDest = const_cast<TUint16*>(line.Ptr()); |
|
363 |
remaining -= bytesPerLine; |
|
364 |
for( TInt i = bytesPerLine; i > 0; --i ) |
|
365 |
{ |
|
366 |
TUint8 c = *pSrc++; |
|
367 |
*pDest++ = hextab[c >> 4]; |
|
368 |
*pDest++ = hextab[c & 0xF]; |
|
369 |
} |
|
370 |
_LIT( KFmt, "%06x: %S\n\r" ); |
|
371 |
test.Printf( KFmt, lineOffs, &line ); |
|
372 |
lineOffs += bytesPerLine; |
|
373 |
} |
|
374 |
} |
|
375 |
||
376 |
||
377 |
GLDEF_C TBool CompareBuffers( const TDesC8& aBuf1, const TDesC8& aBuf2 ) |
|
378 |
{ |
|
379 |
TInt count = 32; |
|
380 |
if (aBuf1.Length() < count) |
|
381 |
count = aBuf1.Length(); |
|
382 |
||
383 |
||
384 |
for (TInt i = 0; i < (aBuf1.Length()-count); i+= count) |
|
385 |
{ |
|
386 |
if( aBuf1.Mid(i,count).Compare(aBuf2.Mid(i,count)) != 0) |
|
387 |
{ |
|
388 |
// now need to find where mismatch ends |
|
389 |
TInt j =i; |
|
390 |
for (; j <= (aBuf1.Length()-count); j+= count) |
|
391 |
{ |
|
392 |
if( aBuf1.Mid(j,count).Compare(aBuf2.Mid(j,count)) == 0) break; |
|
393 |
} |
|
394 |
test.Printf(_L("buf1 len: %d, buf2 len: %d\n"),aBuf1.Length(),aBuf2.Length()); |
|
395 |
test.Printf( _L("Buffer mismatch @%d to %d (%d Bytes)\n\r"),i,j, (j-i) ); |
|
396 |
test.Printf( _L("buffer 1 ------------------\n\r") ); |
|
397 |
DumpBuffer( aBuf1.Mid(i,(j-i)) ); |
|
398 |
test.Printf( _L("buffer 2 ------------------\n\r") ); |
|
399 |
DumpBuffer( aBuf2.Mid(i,(j-i)) ); |
|
400 |
test.Printf(_L("buf1 len: %d, buf2 len: %d\n"),aBuf1.Length(),aBuf2.Length()); |
|
401 |
test.Printf( _L("Buffer mismatch @%d to %d (%d Bytes)\n\r"),i,j, (j-i) ); |
|
402 |
return EFalse; |
|
403 |
} |
|
404 |
} |
|
405 |
return ETrue; |
|
406 |
} |
|
407 |
||
408 |
||
409 |
void singleSectorRdWrTest(TInt aSectorOffset,TInt aLen) |
|
410 |
// |
|
411 |
// Perform a write / read test on a single sector (KSingSectorNo). Verify that the |
|
412 |
// write / read back is successful and that the rest of the sector is unchanged. |
|
413 |
// |
|
414 |
{ |
|
415 |
||
416 |
TBuf8<KDiskSectorSize> saveBuf; |
|
417 |
test.Start(_L("Single sector write/read test")); |
|
418 |
test(aSectorOffset+aLen<=KDiskSectorSize); |
|
419 |
||
420 |
// Now save state of sector before we write to it |
|
421 |
TInt secStart=(KSingSectorNo<<KDiskSectorShift); |
|
422 |
test(TheMmcDrive.Read(secStart,KDiskSectorSize,saveBuf)==KErrNone); |
|
423 |
||
424 |
// Write zero's to another sector altogether (to ensure drivers |
|
425 |
// local buffer hasn't already got test pattern we expect). |
|
426 |
wrBuf.Fill(0,KDiskSectorSize); |
|
427 |
test(TheMmcDrive.Write((KSingSectorNo+4)<<KDiskSectorShift,wrBuf)==KErrNone); |
|
428 |
||
429 |
// Write / read back sector in question |
|
430 |
wrBuf.SetLength(aLen); |
|
431 |
for (TInt i=0;i<aLen;i++) |
|
432 |
wrBuf[i]=(TUint8)(0xFF-i); |
|
433 |
test(TheMmcDrive.Write((secStart+aSectorOffset),wrBuf)==KErrNone); |
|
434 |
rdBuf.Fill(0,aLen); |
|
435 |
test(TheMmcDrive.Read((secStart+aSectorOffset),aLen,rdBuf)==KErrNone); |
|
436 |
test(CompareBuffers(rdBuf, wrBuf)); |
|
437 |
//test(rdBuf.Compare(wrBuf)==0); |
|
438 |
||
439 |
// Now check the rest of the sector is unchanged |
|
440 |
rdBuf.Fill(0,KDiskSectorSize); |
|
441 |
test(TheMmcDrive.Read(secStart,KDiskSectorSize,rdBuf)==KErrNone); |
|
442 |
saveBuf.Replace(aSectorOffset,aLen,wrBuf); |
|
443 |
test(CompareBuffers(rdBuf, saveBuf)); |
|
444 |
test.End(); |
|
445 |
} |
|
446 |
||
447 |
const TInt KMultSectorNo=2; |
|
448 |
||
449 |
void MultipleSectorRdWrTestMB(TInt aFirstSectorOffset, TInt aLen, TBool aWrMB, TBool aRdMB) |
|
450 |
// |
|
451 |
// Perform a write / read test over multiple sectors (starting within sector KMultSectorNo). |
|
452 |
// Verify that the write / read back is successful and that the remainder of the first and |
|
453 |
// last sectors are not affected. |
|
454 |
// |
|
455 |
{ |
|
456 |
||
457 |
TBuf8<KDiskSectorSize> saveBuf1; |
|
458 |
TBuf8<KDiskSectorSize> saveBuf2; |
|
459 |
||
460 |
test.Printf(_L(" MBW[%d] : MBR[%d]\n\r"), aWrMB, aRdMB); |
|
461 |
||
462 |
test(aFirstSectorOffset<KDiskSectorSize&&aLen<=KVeryLongRdWrBufLen); |
|
463 |
||
464 |
// If not starting on sector boundary then save 1st sector to check rest of 1st sector is unchanged |
|
465 |
TInt startSecPos=(KMultSectorNo<<KDiskSectorShift); |
|
466 |
if (aFirstSectorOffset!=0) |
|
467 |
test(TheMmcDrive.Read(startSecPos,KDiskSectorSize,saveBuf1)==KErrNone); |
|
468 |
||
469 |
// If not ending on sector boundary then save last sector to check rest of last sector is unchanged |
|
470 |
TInt endOffset=(aFirstSectorOffset+aLen)&(~KDiskSectorMask); |
|
471 |
TInt endSecPos=((startSecPos+aFirstSectorOffset+aLen)&KDiskSectorMask); |
|
472 |
if (endOffset) |
|
473 |
{ |
|
474 |
test(TheMmcDrive.Read(endSecPos,KDiskSectorSize,saveBuf2)==KErrNone); |
|
475 |
} |
|
476 |
||
477 |
// Write zero's to another sector altogether (to ensure drivers |
|
478 |
// local buffer hasn't already got test pattern we expect). |
|
479 |
wrBuf.Fill(0,KSectBufSizeInBytes); |
|
480 |
test(TheMmcDrive.Write((endSecPos+(2*KDiskSectorSize)),wrBuf)==KErrNone); |
|
481 |
||
482 |
TInt i; |
|
483 |
||
484 |
wrBuf.SetLength(aLen); |
|
485 |
for (i=0;i<aLen;i++) |
|
486 |
{ |
|
487 |
wrBuf[i]=(TUint8)(0xFF-i); |
|
488 |
} |
|
489 |
||
490 |
if(aWrMB) |
|
491 |
{ |
|
492 |
test(TheMmcDrive.Write((startSecPos+aFirstSectorOffset),wrBuf)==KErrNone); |
|
493 |
} |
|
494 |
else |
|
495 |
{ |
|
496 |
for (i=0;i<aLen;i+=512) |
|
497 |
{ |
|
498 |
TInt thisLen = (aLen-i) < 512 ? (aLen-i) : 512; |
|
499 |
TPtrC8 sectorWr(wrBuf.Mid(i, thisLen).Ptr(), thisLen); |
|
500 |
test(TheMmcDrive.Write((startSecPos+aFirstSectorOffset+i), sectorWr)==KErrNone); |
|
501 |
} |
|
502 |
} |
|
503 |
||
504 |
rdBuf.Fill(0,aLen); |
|
505 |
rdBuf.SetLength(aLen); |
|
506 |
||
507 |
if(aRdMB) |
|
508 |
{ |
|
509 |
test(TheMmcDrive.Read((startSecPos+aFirstSectorOffset),aLen,rdBuf) == KErrNone); |
|
510 |
} |
|
511 |
else |
|
512 |
{ |
|
513 |
for (i=0;i<aLen;i+=512) |
|
514 |
{ |
|
515 |
TInt thisLen = (aLen-i) < 512 ? (aLen-i) : 512; |
|
516 |
TPtr8 sectorRd(((TUint8*)(rdBuf.Ptr()))+i, thisLen, thisLen); |
|
517 |
test(TheMmcDrive.Read((startSecPos+aFirstSectorOffset+i), thisLen, sectorRd) == KErrNone); |
|
518 |
} |
|
519 |
} |
|
520 |
||
521 |
test(CompareBuffers(rdBuf, wrBuf)); |
|
522 |
||
523 |
// Check rest of first sector involved is unchanged (if offset specified) |
|
524 |
if (aFirstSectorOffset!=0) |
|
525 |
{ |
|
526 |
rdBuf.Fill(0,KDiskSectorSize); |
|
527 |
test(TheMmcDrive.Read(startSecPos,KDiskSectorSize,rdBuf)==KErrNone); |
|
528 |
wrBuf.SetLength(KDiskSectorSize-aFirstSectorOffset); |
|
529 |
saveBuf1.Replace(aFirstSectorOffset,(KDiskSectorSize-aFirstSectorOffset),wrBuf); |
|
530 |
test(rdBuf.Compare(saveBuf1)==0); |
|
531 |
} |
|
532 |
||
533 |
// Check rest of last sector involved is unchanged (if not ending on sector boundary) |
|
534 |
if (endOffset) |
|
535 |
{ |
|
536 |
rdBuf.Fill(0,KDiskSectorSize); |
|
537 |
test(TheMmcDrive.Read(endSecPos,KDiskSectorSize,rdBuf)==KErrNone); |
|
538 |
wrBuf.SetLength(aLen); |
|
539 |
wrBuf.Delete(0,aLen-endOffset); |
|
540 |
saveBuf2.Replace(0,endOffset,wrBuf); |
|
541 |
test(CompareBuffers(rdBuf, saveBuf2)); |
|
542 |
} |
|
543 |
} |
|
544 |
||
545 |
void MultipleSectorRdWrTest(TInt aFirstSectorOffset,TInt aLen, TBool aMBOnly = EFalse) |
|
546 |
// |
|
547 |
// Perform a write / read test over multiple sectors (starting within sector KMultSectorNo). |
|
548 |
// Verify that the write / read back is successful and that the remainder of the first and |
|
549 |
// last sectors are not affected. |
|
550 |
// |
|
551 |
{ |
|
552 |
test.Start(_L("Multiple sector write/read test")); |
|
553 |
||
554 |
if(!aMBOnly) |
|
555 |
{ |
|
556 |
MultipleSectorRdWrTestMB(aFirstSectorOffset, aLen, EFalse, EFalse); |
|
557 |
MultipleSectorRdWrTestMB(aFirstSectorOffset, aLen, EFalse, ETrue); |
|
558 |
MultipleSectorRdWrTestMB(aFirstSectorOffset, aLen, ETrue, EFalse); |
|
559 |
} |
|
560 |
||
561 |
MultipleSectorRdWrTestMB(aFirstSectorOffset, aLen, ETrue, ETrue); |
|
562 |
||
563 |
test.End(); |
|
564 |
} |
|
565 |
||
566 |
LOCAL_C TInt dontDisconnectThread(TAny*) |
|
567 |
{ |
|
568 |
||
569 |
TBusLocalDrive anotherMmcDrive; |
|
570 |
nTest.Title(); |
|
571 |
||
572 |
nTest.Start(_L("Connect to internal drive")); |
|
573 |
anotherMmcDrive.Connect(DriveNumber,SecThreadChangeFlag); |
|
574 |
||
575 |
nTest.Next(_L("Capabilities")); |
|
576 |
TLocalDriveCapsV2 info; |
|
577 |
TPckg<TLocalDriveCapsV2> infoPckg(info); |
|
578 |
nTest(anotherMmcDrive.Caps(infoPckg)==KErrNone); |
|
579 |
nTest(info.iType==EMediaHardDisk); |
|
580 |
||
581 |
nTest.End(); |
|
582 |
return(KErrNone); |
|
583 |
} |
|
584 |
||
585 |
LOCAL_C void ProgressBar(TInt64 aPos,TInt64 anEndPos,TInt anXPos) |
|
586 |
// |
|
587 |
// Display progress of local drive operation on screen (1-16 dots) |
|
588 |
// |
|
589 |
{ |
|
590 |
static TInt64 prev; |
|
591 |
TInt64 curr; |
|
592 |
if ((curr=(aPos-1)/(anEndPos>>4))>prev) |
|
593 |
{ // Update progress bar |
|
594 |
test.Console()->SetPos(anXPos); |
|
595 |
for (TInt64 i=curr;i>=0;i--) |
|
596 |
test.Printf(_L(".")); |
|
597 |
} |
|
598 |
prev=curr; |
|
599 |
} |
|
600 |
||
601 |
||
602 |
/** |
|
603 |
@SYMTestCaseID PBASE-T_MMCDRV-0510 |
|
604 |
@SYMTestCaseDesc Test Write/Read during media Change |
|
605 |
@SYMTestPriority High |
|
606 |
||
607 |
@SYMTestActions |
|
608 |
a.) Test Read during a Media Change |
|
609 |
b.) Test Write during a Media Change |
|
610 |
||
611 |
@SYMTestExpectedResults All tests must pass |
|
612 |
*/ |
|
613 |
LOCAL_C void TestHugeReadWrite(TBool aIsRead, TInt aLen) |
|
614 |
// |
|
615 |
// Writes aLen bytes to the MMC drive. Gives user enough time to flip the media |
|
616 |
// change switch. Request should abort with KErrNotReady on write command, but nothing |
|
617 |
// on read command. |
|
618 |
// Each read or write is started from sector KMultSectNo (2). |
|
619 |
// The media change operation only works when the switch is moved from the closed position |
|
620 |
// to the open position. |
|
621 |
// |
|
622 |
{ |
|
623 |
test.Start(_L("TestHugeReadWrite: media change during I/O test.")); |
|
624 |
test.Printf(_L("aIsRead = %x, aLen = %x.\n"), aIsRead, aLen); |
|
625 |
||
626 |
HBufC8 *buf = HBufC8::New(aLen); |
|
627 |
test(buf != NULL); |
|
628 |
||
629 |
TInt startSectPos = KMultSectorNo << KDiskSectorShift; |
|
630 |
if (aIsRead) |
|
631 |
{ |
|
632 |
test.Printf(_L("Launching %08x byte read at %08x.\n"), aLen, startSectPos); |
|
633 |
test.Printf(_L("Move media change from closed to open position before finished.\n")); |
|
634 |
TPtr8 ptr(buf->Des()); |
|
635 |
TInt r = TheMmcDrive.Read(startSectPos, aLen, ptr); |
|
636 |
test.Printf(_L("r = %d.\n"), r); |
|
637 |
test(r == KErrNone); |
|
638 |
} |
|
639 |
else |
|
640 |
{ |
|
641 |
buf->Des().Fill(0xff, aLen); |
|
642 |
test.Printf(_L("Launching %08x byte write at %08x.\n"), aLen, startSectPos); |
|
643 |
test.Printf(_L("Move media change from closed to open position before finished.\n")); |
|
644 |
TInt r = TheMmcDrive.Write(startSectPos, *buf); |
|
645 |
test.Printf(_L("r = %d.\n"), r); |
|
646 |
test(r == KErrNotReady); |
|
647 |
} |
|
648 |
||
649 |
test.Printf(_L("Pausing for 5 seconds to move media change switch back to closed.\n")); |
|
650 |
User::After(5 * 1000 * 1000); |
|
651 |
delete buf; |
|
652 |
test.End(); |
|
653 |
} |
|
654 |
||
655 |
||
656 |
LOCAL_C void FillBufferWithPattern(TDes8 &aBuf) |
|
657 |
// |
|
658 |
// Fills aBuf with cycling hex digits up to aBuf.Length(). |
|
659 |
// |
|
660 |
{ |
|
661 |
TInt len = aBuf.Length() & ~3; |
|
662 |
for (TInt i = 0; i < len; i+=4) |
|
663 |
{ |
|
664 |
*((TUint32*) &aBuf[i]) = i; |
|
665 |
} |
|
666 |
} |
|
667 |
||
668 |
||
669 |
LOCAL_C void WriteAndReadBack(TInt64 aStartPos, const TDesC8 &aWrBuf) |
|
670 |
// |
|
671 |
// This function tests the multiple block reads when aWrBuf is sufficiently large. |
|
672 |
// |
|
673 |
{ |
|
674 |
test.Start(_L("WriteAndReadBack")); |
|
675 |
||
676 |
TInt r; // general error values |
|
677 |
||
678 |
// Allocate a same size buffer to read back into and compare with. |
|
679 |
HBufC8 *rdBuf = aWrBuf.Alloc(); |
|
680 |
test(rdBuf != NULL); |
|
681 |
TPtr8 rdPtr(rdBuf->Des()); |
|
682 |
||
683 |
test.Next(_L("wrb: writing")); |
|
684 |
r = TheMmcDrive.Write(aStartPos, aWrBuf); |
|
685 |
test.Printf(_L("\nwrb:r=%d"), r); |
|
686 |
test(r == KErrNone); |
|
687 |
||
688 |
test.Printf(_L("\n")); |
|
689 |
test.Next(_L("wrb: reading")); |
|
690 |
r = TheMmcDrive.Read(aStartPos, rdPtr.Length(), rdPtr); |
|
691 |
test.Printf(_L("rb:r=%d"), r); |
|
692 |
test(r == KErrNone); |
|
693 |
||
694 |
// Compare the pattern that has just been read back with the original. |
|
695 |
test.Printf(_L("\n")); |
|
696 |
test.Next(_L("wrb: comparing")); |
|
697 |
test.Printf( |
|
698 |
_L("rdPtr.Length() = %04x, aWrBuf.Length() = %04x"), |
|
699 |
rdPtr.Length(), aWrBuf.Length()); |
|
700 |
test(rdPtr == aWrBuf); |
|
701 |
||
702 |
#if 0 // extra debug when buffers not compare. |
|
703 |
for (TInt j = 0; j < rdPtr.Length(); j++) |
|
704 |
{ |
|
705 |
test.Printf(_L("%d: w%02x r%02x"), j, aWrBuf[j], rdBuf[j]); |
|
706 |
||
707 |
if (rdPtr[j] != aWrBuf[j]) |
|
708 |
{ |
|
709 |
test.Printf(_L("buffer mismatch at %04x: %02x v %02x"), j, rdPtr[j], aWrBuf[j]); |
|
710 |
test(EFalse); |
|
711 |
} |
|
712 |
} |
|
713 |
#endif |
|
714 |
||
715 |
test.Printf(_L("\n")); |
|
716 |
delete rdBuf; |
|
717 |
test.End(); |
|
718 |
} |
|
719 |
||
720 |
/** |
|
721 |
@SYMTestCaseID PBASE-T_MMCDRV-0169 |
|
722 |
@SYMTestCaseDesc Test Multiple Block Reads |
|
723 |
@SYMTestPriority High |
|
724 |
||
725 |
@SYMTestActions |
|
726 |
a.) Test Multiple Block Reads at the internal buffer size |
|
727 |
b.) Test Multiple Block Reads greater than the internal buffer size |
|
728 |
||
729 |
@SYMTestExpectedResults All tests must pass |
|
730 |
||
731 |
@TODO: increase Buffer size to match current reference platform (128KB) |
|
732 |
*/ |
|
733 |
LOCAL_C void TestMultipleBlockReads() |
|
734 |
{ |
|
735 |
// Test multiple block reads. |
|
736 |
static TBuf8<256 * 1024> rw_wrBuf; |
|
737 |
||
738 |
rw_wrBuf.SetLength(rw_wrBuf.MaxLength()); |
|
739 |
FillBufferWithPattern(rw_wrBuf); |
|
740 |
||
741 |
test.Next(_L("Testing multiple block reads at internal buffer size")); |
|
742 |
rw_wrBuf.SetLength(8 * KDiskSectorSize); |
|
743 |
WriteAndReadBack(KMultSectorNo << KDiskSectorShift, rw_wrBuf); |
|
744 |
||
745 |
test.Next(_L("Testing multiple block reads at gt internal buffer size")); |
|
746 |
rw_wrBuf.SetLength(10 * KDiskSectorSize); |
|
747 |
WriteAndReadBack(KMultSectorNo << KDiskSectorShift, rw_wrBuf); |
|
748 |
||
749 |
test.Next(_L("Testing unaligned large block read ")); |
|
750 |
rw_wrBuf.SetLength(rw_wrBuf.MaxLength()); |
|
751 |
WriteAndReadBack((KMultSectorNo << KDiskSectorShift) + 128, rw_wrBuf); |
|
752 |
} |
|
753 |
||
754 |
||
755 |
/** |
|
756 |
@SYMTestCaseID PBASE-T_MMCDRV-0558 |
|
757 |
@SYMTestCaseDesc Test Long Read/Write Boundaries |
|
758 |
@SYMTestPriority High |
|
759 |
||
760 |
@SYMTestActions |
|
761 |
||
762 |
Perform and Write/Read/Verify for the given length (L) of data across the following boundaries. |
|
763 |
Depending on the length provided, this will also perform a partial write/read at the end sector. |
|
764 |
||
765 |
------------------- |
|
766 |
| Start | End | |
|
767 |
|-------------------| |
|
768 |
| 0 | L | |
|
769 |
| 507 | L-507 | |
|
770 |
| 10 | L | |
|
771 |
| 0 | L-3 | |
|
772 |
| 27 | L-512 | |
|
773 |
| 0 | L-509 | |
|
774 |
| 3 | L-3 | |
|
775 |
------------------- |
|
776 |
||
777 |
For each combination, the write/read/verify operations are performed in the following sequence: |
|
778 |
||
779 |
a: Write and Read in single 512-byte blocks. |
|
780 |
b: Write in a single operation (multiple blocks), Read in 512-Byte blocks. |
|
781 |
c: Write in 512-Byte blocks, Read in a single operation (multiple-blocks). |
|
782 |
d: Write and Read in a single operation (multiple-blocks). |
|
783 |
||
784 |
In the cases where a partial read/write operation occurs (ie - the start and/or end position don't lie within |
|
785 |
a sector boundary), the original contents of the start and/or end sectors are read and stored at the start of |
|
786 |
the test, and compared with the contents of the sectors at the end of the test to ensure that unwritten data within |
|
787 |
the sectors remain unaffected. |
|
788 |
||
789 |
@SYMTestExpectedResults All tests must pass |
|
790 |
||
791 |
@SYMPREQ1389 REQ6951 Double Buffering and SD Switch |
|
792 |
*/ |
|
793 |
||
794 |
LOCAL_C void TestLongReadWriteBoundaries(TUint aLen, TBool aMBOnly = EFalse) |
|
795 |
{ |
|
796 |
TBuf<64> b; |
|
797 |
||
798 |
b.Format(_L("MMC drive: Very long RdWr(1) (%dbytes at %d)"),aLen,0); |
|
799 |
test.Next(b); |
|
800 |
MultipleSectorRdWrTest(0, aLen, aMBOnly); // Exceeds driver's buffer, starts/ends on sector boundary |
|
801 |
||
802 |
b.Format(_L("MMC drive: Very long RdWr(2) (%dbytes at %d)"),(aLen-KDiskSectorSize+5),507); |
|
803 |
test.Next(b); |
|
804 |
MultipleSectorRdWrTest(507, (aLen-KDiskSectorSize+5), aMBOnly); // Exceeds driver's buffer, ends on sector boundary |
|
805 |
||
806 |
b.Format(_L("MMC drive: Very long RdWr(3) (%dbytes at %d)"),aLen,10); |
|
807 |
test.Next(b); |
|
808 |
MultipleSectorRdWrTest(10, aLen, aMBOnly); // Exceeds driver's buffer, starts/ends off sector boundary |
|
809 |
||
810 |
b.Format(_L("MMC drive: Very long RdWr(4) (%dbytes at %d)"),(aLen-3),0); |
|
811 |
test.Next(b); |
|
812 |
MultipleSectorRdWrTest(0, aLen-3, aMBOnly); // Exceeds driver's buffer, starts on sector boundary |
|
813 |
||
814 |
b.Format(_L("MMC drive: Very long RdWr(5) (%dbytes at %d)"),(aLen-KDiskSectorSize),27); |
|
815 |
test.Next(b); |
|
816 |
MultipleSectorRdWrTest(27, (aLen-KDiskSectorSize), aMBOnly); // Exceeds driver's buffer (due to start offset), starts/ends off sector boundary |
|
817 |
||
818 |
b.Format(_L("MMC drive: Very long RdWr(6) (%dbytes at %d)"),(aLen-KDiskSectorSize-3),0); |
|
819 |
test.Next(b); |
|
820 |
MultipleSectorRdWrTest(0, aLen-KDiskSectorSize-3, aMBOnly); // Equals driver's buffer, starts on sector boundary |
|
821 |
||
822 |
b.Format(_L("MMC drive: Very long RdWr(7) (%dbytes at %d)"),(aLen-3),3); |
|
823 |
test.Next(b); |
|
824 |
MultipleSectorRdWrTest(3, aLen-3, aMBOnly); // Equals driver's buffer, ends on sector boundary |
|
825 |
} |
|
826 |
||
827 |
||
828 |
/** |
|
829 |
@SYMTestCaseID PBASE-T_MMCDRV-0509 |
|
830 |
@SYMTestCaseDesc Test Sector Read/Writing |
|
831 |
@SYMTestPriority High |
|
832 |
||
833 |
@SYMTestActions |
|
834 |
a.) Test Writing blocks on sector boundaries |
|
835 |
b.) Test Reading blocks on sector boundaries |
|
836 |
c.) Test single sector Write/Read at: |
|
837 |
i.) Sector Start |
|
838 |
ii.) Mid Sector |
|
839 |
iii.) Sector End |
|
840 |
d.) Test Multiple Sector Write/Read: |
|
841 |
i.) Start on Sector Boundary |
|
842 |
ii.) Start/End on Sector Boundary |
|
843 |
iii.) End on Sector Boundary |
|
844 |
e.) Test Write/Read over sector boundary |
|
845 |
||
846 |
@SYMTestExpectedResults All tests must pass |
|
847 |
*/ |
|
848 |
LOCAL_C void TestSectorReadWrite() |
|
849 |
{ |
|
850 |
TBuf<64> b; |
|
851 |
b.Format(_L("MMC drive: Sector RdWr(%d)"), KDiskSectorSize); |
|
852 |
||
853 |
test.Next(b); |
|
854 |
||
855 |
TInt len; |
|
856 |
||
857 |
// Fill wrBuf with a pattern of ascending numbers. |
|
858 |
wrBuf.SetLength(KDiskSectorSize); |
|
859 |
TUint32 *p = REINTERPRET_CAST(TUint32 *, &wrBuf[0]); |
|
860 |
TInt secPos; |
|
861 |
for (secPos = 0; secPos < KDiskSectorSize; secPos++) |
|
862 |
{ |
|
863 |
wrBuf[secPos] = TUint8(secPos % 0x0100); |
|
864 |
} |
|
865 |
||
866 |
// Write 512 byte blocks to the card, writing the sector number to the first |
|
867 |
// word in each buffer. |
|
868 |
||
869 |
test.Printf(_L("Writing ")); |
|
870 |
TInt64 i; |
|
871 |
// for (i=0;i<DriveSize;i+=len) // B - Sector wr/rd on sector boundary |
|
872 |
for (i=0;i<(0x200<<3);i+=len) // B - Sector wr/rd on sector boundary |
|
873 |
{ |
|
874 |
ProgressBar(i, TheMmcDrive.Size(), 11); |
|
875 |
len = KDiskSectorSize < TheMmcDrive.Size() - i ? KDiskSectorSize : I64LOW(TheMmcDrive.Size() - i); |
|
876 |
(*p) = I64LOW(i) / KDiskSectorSize; |
|
877 |
wrBuf.SetLength(len); |
|
878 |
TInt r = TheMmcDrive.Write(i, wrBuf); |
|
879 |
if (r != KErrNone) |
|
880 |
{ |
|
881 |
test.Printf(_L("wt:i = %d, len = %d, r %d"), i, len, r); |
|
882 |
test(EFalse); |
|
883 |
} |
|
884 |
} |
|
885 |
||
886 |
// Read each of the 512 byte blocks back from the card. |
|
887 |
test.Printf(_L("\r\nReading ")); |
|
888 |
// for (i=0;i<TheMmcDrive.Size();i+=len) |
|
889 |
for (i=0;i<(0x200<<3);i+=len) // B - Sector wr/rd on sector boundary |
|
890 |
{ |
|
891 |
ProgressBar(i, TheMmcDrive.Size(), 11); |
|
892 |
len = KDiskSectorSize < TheMmcDrive.Size() - i ? KDiskSectorSize : I64LOW(TheMmcDrive.Size() - i); |
|
893 |
rdBuf.Fill(0,len); |
|
894 |
TInt r = TheMmcDrive.Read(i, len, rdBuf); |
|
895 |
if (r != KErrNone) |
|
896 |
{ |
|
897 |
test.Printf(_L("rd:i = %d, len = %d, r %d"), i, len, r); |
|
898 |
test(EFalse); |
|
899 |
} |
|
900 |
(*p) = (I64LOW(i)/KDiskSectorSize); |
|
901 |
wrBuf.SetLength(len); |
|
902 |
||
903 |
if ((r = rdBuf.Compare(wrBuf)) != 0) |
|
904 |
{ |
|
905 |
test.Printf(_L("wc:i = %d, len = %d, r %d"), i, len, r); |
|
906 |
test.Printf(_L("wc: wrBuf.Length() = %d, rdBuf.Length() = %d"), wrBuf.Length(), rdBuf.Length()); |
|
907 |
TInt j; |
|
908 |
for (j = 0; j < wrBuf.Length() && wrBuf[j] == rdBuf[j]; j++) |
|
909 |
{ |
|
910 |
// empty. |
|
911 |
} |
|
912 |
test.Printf(_L("wc: wrBuf[%d] = %d, rdBuf[%d] = %d"), j, wrBuf[j], j, rdBuf[j]); |
|
913 |
||
914 |
test(EFalse); |
|
915 |
} |
|
916 |
} |
|
917 |
test.Printf(_L("\r\n")); |
|
918 |
||
919 |
b.Format(_L("MMC drive: Short RdWr(1) (%dbytes at %d)"),25,0); |
|
920 |
test.Next(b); |
|
921 |
singleSectorRdWrTest(0,25); // A - Sub-sector wr/rd at sector start |
|
922 |
||
923 |
b.Format(_L("MMC drive: Short RdWr(2) (%dbytes at %d)"),16,277); |
|
924 |
test.Next(b); |
|
925 |
singleSectorRdWrTest(277,16); // E - Sub-sector wr/rd in mid sector |
|
926 |
||
927 |
b.Format(_L("MMC drive: Short RdWr(3) (%dbytes at %d)"),100,412); |
|
928 |
test.Next(b); |
|
929 |
singleSectorRdWrTest(412,100); // F - Sub-sector wr/rd at sector end |
|
930 |
||
931 |
b.Format(_L("MMC drive: Long RdWr(1) (%dbytes at %d)"),KDiskSectorSize+15,0); |
|
932 |
test.Next(b); |
|
933 |
MultipleSectorRdWrTest(0,KDiskSectorSize+15); // C - Long wr/rd starting on sector boundary |
|
934 |
||
935 |
b.Format(_L("MMC drive: Long RdWr(2) (%dbytes at %d)"),(KDiskSectorSize<<1),0); |
|
936 |
test.Next(b); |
|
937 |
MultipleSectorRdWrTest(0,(KDiskSectorSize<<1)); // D - Long wr/rd starting/ending on sector boundary |
|
938 |
||
939 |
b.Format(_L("MMC drive: Long RdWr(3) (%dbytes at %d)"),KDiskSectorSize+3,509); |
|
940 |
test.Next(b); |
|
941 |
MultipleSectorRdWrTest(509,KDiskSectorSize+3); // H - - Long wr/rd ending on sector boundary |
|
942 |
||
943 |
b.Format(_L("MMC drive: Long RdWr(4) (%dbytes at %d)"),(KDiskSectorSize<<1),508); |
|
944 |
test.Next(b); |
|
945 |
MultipleSectorRdWrTest(508,(KDiskSectorSize<<1)); |
|
946 |
||
947 |
b.Format(_L("MMC drive: Sector RdWr across sector boundary(%dbytes at %d)"),KDiskSectorSize,508); |
|
948 |
test.Next(b); |
|
949 |
MultipleSectorRdWrTest(508,KDiskSectorSize); // G - Sector wr/rd over sector boundary |
|
950 |
||
951 |
TestLongReadWriteBoundaries(KRdWrBufLen); // Short length - As per original test |
|
952 |
||
953 |
if (ManualMode) |
|
954 |
{ |
|
955 |
for(TInt bufLen = KRdWrBufLen; bufLen <= 256*1024; bufLen += KRdWrBufLen) |
|
956 |
{ |
|
957 |
TestLongReadWriteBoundaries(bufLen, ETrue); // Very long length - to test Double-Buffering |
|
958 |
} |
|
959 |
||
960 |
TestLongReadWriteBoundaries(KVeryLongRdWrBufLen, ETrue); // Very long length - to test Double-Buffering |
|
961 |
} |
|
962 |
} |
|
963 |
||
964 |
||
965 |
/** |
|
966 |
@SYMTestCaseID PBASE-T_MMCDRV-0168 |
|
967 |
@SYMTestCaseDesc Test Sector Formatting |
|
968 |
@SYMTestPriority High |
|
969 |
||
970 |
@SYMTestActions |
|
971 |
a.) Test Format/Read/Verify Single Sector |
|
972 |
b.) Test Format/Read/Verify Multiple Sectors |
|
973 |
c.) Test Format/Read/Verify Whole Media |
|
974 |
||
975 |
@SYMTestExpectedResults All tests must pass |
|
976 |
*/ |
|
977 |
LOCAL_C void TestFormat() |
|
978 |
{ |
|
979 |
if(TheMmcDrive.TestMode() != TMMCDrive::ETestPartition) |
|
980 |
{ |
|
981 |
test.Printf(_L("Skipping format tests - only supported on Partition Test Mode")); |
|
982 |
return; |
|
983 |
} |
|
984 |
||
985 |
if(CardType == TKnownCardTypes::EBuffalloMiniSD_32M_ERASE || |
|
986 |
CardType == TKnownCardTypes::EBuffalloMiniSD_64M_ERASE || |
|
987 |
CardType == TKnownCardTypes::EBuffalloMiniSD_128M_ERASE || |
|
988 |
CardType == TKnownCardTypes::EBuffalloMiniSD_256M_ERASE || |
|
989 |
CardType == TKnownCardTypes::EBuffalloMiniSD_512M_ERASE |
|
990 |
) |
|
991 |
{ |
|
992 |
//These cards implement the erase command incorrectly |
|
993 |
test.Printf( _L(" -- Skipping Format Tests - Known card detected --\n") ); |
|
994 |
return; |
|
995 |
} |
|
996 |
||
997 |
test.Next(_L("MMC drive: Format sectors (short)")); |
|
998 |
TBuf8<KDiskSectorSize> savBuf1,savBuf2; |
|
999 |
TInt fmtTestPos=(10<<KDiskSectorShift); |
|
1000 |
// Save sectors surrounding those which will be formatted |
|
1001 |
test(TheMmcDrive.Read((fmtTestPos-KDiskSectorSize),KDiskSectorSize,savBuf1)==KErrNone); |
|
1002 |
test(TheMmcDrive.Read((fmtTestPos+KShortFormatInBytes),KDiskSectorSize,savBuf2)==KErrNone); |
|
1003 |
||
1004 |
// Fill buffer with 0xCC |
|
1005 |
// (i.e. a value which is not going to be written by formatting the device) |
|
1006 |
// & then write to area which is to be formatted |
|
1007 |
wrBuf.SetLength(KShortFormatInBytes); |
|
1008 |
wrBuf.Fill(0xCC); |
|
1009 |
test(TheMmcDrive.Write(fmtTestPos, wrBuf)==KErrNone); |
|
1010 |
||
1011 |
||
1012 |
test(TheMmcDrive.Format(fmtTestPos,KShortFormatInBytes)==KErrNone); |
|
1013 |
test(TheMmcDrive.Read(fmtTestPos,KShortFormatInBytes,rdBuf)==KErrNone); |
|
1014 |
||
1015 |
TUint8 defEraseVal = rdBuf[0]; |
|
1016 |
test(defEraseVal == 0x00 || defEraseVal == 0xFF); // The card should erase with 0x00 or 0xFF |
|
1017 |
wrBuf.Fill(defEraseVal ,KShortFormatInBytes); |
|
1018 |
test(rdBuf.Compare(wrBuf)==0); |
|
1019 |
||
1020 |
// Check that surrounding sectors unaffected |
|
1021 |
test(TheMmcDrive.Read((fmtTestPos-KDiskSectorSize),KDiskSectorSize,rdBuf)==KErrNone); |
|
1022 |
test(rdBuf.Compare(savBuf1)==0); |
|
1023 |
test(TheMmcDrive.Read((fmtTestPos+KShortFormatInBytes),KDiskSectorSize,rdBuf)==KErrNone); |
|
1024 |
test(rdBuf.Compare(savBuf2)==0); |
|
1025 |
||
1026 |
test.Next(_L("MMC drive: Format sectors (long)")); |
|
1027 |
fmtTestPos+=(4<<KDiskSectorShift); |
|
1028 |
// Save sectors surrounding those which will be formatted |
|
1029 |
test(TheMmcDrive.Read((fmtTestPos-KDiskSectorSize),KDiskSectorSize,savBuf1)==KErrNone); |
|
1030 |
test(TheMmcDrive.Read((fmtTestPos+KLongFormatInBytes),KDiskSectorSize,savBuf2)==KErrNone); |
|
1031 |
||
1032 |
// Fill buffer with 0xCC |
|
1033 |
// (i.e. a value which is not going to be written by formatting the device) |
|
1034 |
// & then write to area which is to be formatted |
|
1035 |
wrBuf.SetLength(KLongFormatInBytes); |
|
1036 |
wrBuf.Fill(0xCC); |
|
1037 |
test(TheMmcDrive.Write(fmtTestPos, wrBuf)==KErrNone); |
|
1038 |
||
1039 |
test(TheMmcDrive.Format(fmtTestPos,KLongFormatInBytes)==KErrNone); |
|
1040 |
test(TheMmcDrive.Read(fmtTestPos,KLongFormatInBytes,rdBuf)==KErrNone); |
|
1041 |
||
1042 |
defEraseVal = rdBuf[0]; |
|
1043 |
test(defEraseVal == 0x00 || defEraseVal == 0xFF); // The card should erase with 0x00 or 0xFF |
|
1044 |
wrBuf.Fill(defEraseVal,KLongFormatInBytes); |
|
1045 |
TInt cmpRes = rdBuf.Compare(wrBuf); |
|
1046 |
if(cmpRes != 0) |
|
1047 |
{ |
|
1048 |
test.Printf(_L("\n\rExpected 0x%02x\n\r")); |
|
1049 |
for(TInt x=0; x<KLongFormatInBytes; x+=8) |
|
1050 |
{ |
|
1051 |
test.Printf(_L("%08x : %02x %02x %02x %02x %02x %02x %02x %02x\n\r"), x, rdBuf[x],rdBuf[x+1],rdBuf[x+2],rdBuf[x+3],rdBuf[x+4],rdBuf[x+5],rdBuf[x+6],rdBuf[x+7]); |
|
1052 |
} |
|
1053 |
} |
|
1054 |
test(cmpRes==0); |
|
1055 |
||
1056 |
// Check that surrounding sectors unaffected |
|
1057 |
test(TheMmcDrive.Read((fmtTestPos-KDiskSectorSize),KDiskSectorSize,rdBuf)==KErrNone); |
|
1058 |
test(rdBuf.Compare(savBuf1)==0); |
|
1059 |
test(TheMmcDrive.Read((fmtTestPos+KLongFormatInBytes),KDiskSectorSize,rdBuf)==KErrNone); |
|
1060 |
test(rdBuf.Compare(savBuf2)==0); |
|
1061 |
||
1062 |
if (ManualMode) |
|
1063 |
{ |
|
1064 |
test.Next(_L("Fill the drive with garbage")); |
|
1065 |
TInt64 driveSize = TheMmcDrive.Size(); |
|
1066 |
TInt wtLen = wrBuf.MaxLength(); |
|
1067 |
TInt64 i; |
|
1068 |
for (i=0; i<driveSize; i+=wtLen) |
|
1069 |
{ |
|
1070 |
ProgressBar(i,driveSize,11); |
|
1071 |
wtLen = wtLen < driveSize - i ? wtLen : I64LOW(driveSize - i); |
|
1072 |
wrBuf.Fill(0xCC,wtLen); |
|
1073 |
||
1074 |
wrBuf.SetLength(wtLen); |
|
1075 |
||
1076 |
test.Printf(_L("writing pos %08lX len %08X\n"), i, wrBuf.Length()); |
|
1077 |
test(TheMmcDrive.Write(i, wrBuf) == KErrNone); |
|
1078 |
} |
|
1079 |
||
1080 |
test.Next(_L("MMC drive: Format entire disk")); |
|
1081 |
TFormatInfo fi; |
|
1082 |
test.Printf(_L("Formatting ")); |
|
1083 |
TInt ret; |
|
1084 |
TInt stage = 0; |
|
1085 |
while((ret=TheMmcDrive.Format(fi))!=KErrEof) |
|
1086 |
{ |
|
1087 |
stage++; |
|
1088 |
ProgressBar((fi.i512ByteSectorsFormatted<<9),TheMmcDrive.Size(),11); |
|
1089 |
test(ret==KErrNone); |
|
1090 |
} |
|
1091 |
||
1092 |
test.Printf(_L("\r\nReading ")); |
|
1093 |
||
1094 |
TInt len = KVeryLongSectBufSizeInBytes; |
|
1095 |
||
1096 |
for (i=0; i<TheMmcDrive.Size(); i+=len) |
|
1097 |
{ |
|
1098 |
ProgressBar(i,TheMmcDrive.Size(),11); |
|
1099 |
len = len < TheMmcDrive.Size() - i ? len : I64LOW(TheMmcDrive.Size() - i); |
|
1100 |
rdBuf.Fill(0x55,len); |
|
1101 |
test(TheMmcDrive.Read(i,len,rdBuf) == KErrNone); |
|
1102 |
||
1103 |
const TInt wholeSectors = len / KDiskSectorSize; |
|
1104 |
const TInt rem = len - (wholeSectors * KDiskSectorSize); |
|
1105 |
||
1106 |
TInt sec; |
|
1107 |
for(sec=1;sec<wholeSectors; sec++) // Start at Base+1 - Card may have written an MBR at sector 0 |
|
1108 |
{ |
|
1109 |
wrBuf.SetLength(KDiskSectorSize); |
|
1110 |
defEraseVal = rdBuf[sec * KDiskSectorSize]; |
|
1111 |
test(defEraseVal == 0x00 || defEraseVal == 0xFF); // The card should erase with 0x00 or 0xFF |
|
1112 |
wrBuf.Fill(defEraseVal, KDiskSectorSize); |
|
1113 |
test( CompareBuffers( wrBuf, rdBuf.Mid( sec * KDiskSectorSize, KDiskSectorSize ) ) ); |
|
1114 |
} |
|
1115 |
||
1116 |
if(rem > 0) |
|
1117 |
{ |
|
1118 |
wrBuf.SetLength(rem); |
|
1119 |
defEraseVal = rdBuf[sec * KDiskSectorSize]; |
|
1120 |
test(defEraseVal == 0x00 || defEraseVal == 0xFF); // The card should erase with 0x00 or 0xFF |
|
1121 |
wrBuf.Fill(defEraseVal, rem); |
|
1122 |
test( CompareBuffers( wrBuf, rdBuf.Mid( sec * KDiskSectorSize, rem ) ) ); |
|
1123 |
} |
|
1124 |
} |
|
1125 |
} |
|
1126 |
} |
|
1127 |
||
1128 |
||
1129 |
class TRandGen |
|
1130 |
{ |
|
1131 |
public: |
|
1132 |
TRandGen(); |
|
1133 |
void Seed(); |
|
1134 |
void Seed( const TInt64& aSeed ); |
|
1135 |
TUint Next(); |
|
1136 |
||
1137 |
private: |
|
1138 |
TInt64 iValue; |
|
1139 |
}; |
|
1140 |
||
1141 |
||
1142 |
TRandGen::TRandGen() |
|
1143 |
: iValue(KDefaultRandSeed) |
|
1144 |
{ |
|
1145 |
} |
|
1146 |
||
1147 |
||
1148 |
void TRandGen::Seed( const TInt64& aSeed ) |
|
1149 |
{ |
|
1150 |
iValue = aSeed; |
|
1151 |
} |
|
1152 |
||
1153 |
void TRandGen::Seed() |
|
1154 |
{ |
|
1155 |
iValue = KDefaultRandSeed; |
|
1156 |
} |
|
1157 |
||
1158 |
TUint TRandGen::Next() |
|
1159 |
{ |
|
1160 |
iValue *= 214013; |
|
1161 |
iValue += 2531011; |
|
1162 |
return static_cast<TUint>( I64LOW(iValue) ); |
|
1163 |
} |
|
1164 |
||
1165 |
||
1166 |
GLDEF_C void FillRandomBuffer( TDes8& aBuf, TRandGen& aRand ) |
|
1167 |
/** |
|
1168 |
* Fill buffer aBuf with data generated by aRand |
|
1169 |
*/ |
|
1170 |
{ |
|
1171 |
TUint l = aBuf.MaxLength(); |
|
1172 |
aBuf.SetLength( l ); |
|
1173 |
TUint* p = (TUint*)aBuf.Ptr(); |
|
1174 |
||
1175 |
// Do any unaligned bytes at the start |
|
1176 |
TInt preAlign = (TUint)p & 3; |
|
1177 |
if( preAlign ) |
|
1178 |
{ |
|
1179 |
preAlign = 4 - preAlign; |
|
1180 |
TUint8* p8 = (TUint8*)p; |
|
1181 |
TUint rand = aRand.Next(); |
|
1182 |
while( preAlign && l ) |
|
1183 |
{ |
|
1184 |
*p8 = (TUint8)(rand & 0xFF); |
|
1185 |
rand >>= 8; |
|
1186 |
++p8; |
|
1187 |
--preAlign; |
|
1188 |
--l; |
|
1189 |
} |
|
1190 |
p = (TUint*)p8; |
|
1191 |
} |
|
1192 |
||
1193 |
for( ; l > 3; l-=4 ) |
|
1194 |
{ |
|
1195 |
*p++ = aRand.Next(); |
|
1196 |
} |
|
1197 |
// Fill in any trailing bytes |
|
1198 |
if( l > 0 ) |
|
1199 |
{ |
|
1200 |
TUint8* q = (TUint8*)p; |
|
1201 |
TUint r = aRand.Next(); |
|
1202 |
if( l > 1 ) |
|
1203 |
{ |
|
1204 |
*((TUint16*)q) = (TUint16)(r & 0xFFFF); |
|
1205 |
q += 2; |
|
1206 |
l -= 2; |
|
1207 |
r >>= 16; |
|
1208 |
} |
|
1209 |
if( l > 0 ) |
|
1210 |
{ |
|
1211 |
*q = (TUint8)(r & 0xFF); |
|
1212 |
} |
|
1213 |
} |
|
1214 |
} |
|
1215 |
||
1216 |
GLDEF_C void FillRandomBuffer( HBufC8* aBuf, TRandGen& aRand ) |
|
1217 |
/** |
|
1218 |
* Fill buffer aBuf with data generated by aRand |
|
1219 |
* For convenience this version takes a HBufC8* |
|
1220 |
*/ |
|
1221 |
{ |
|
1222 |
TPtr8 ptr = aBuf->Des(); |
|
1223 |
FillRandomBuffer( ptr, aRand ); |
|
1224 |
} |
|
1225 |
||
1226 |
||
1227 |
/** |
|
1228 |
@SYMTestCaseID PBASE-T_MMCDRV-0164 |
|
1229 |
@SYMTestCaseDesc Test MMC Drive Capabilities |
|
1230 |
@SYMTestPriority High |
|
1231 |
||
1232 |
@SYMTestActions |
|
1233 |
a. Obtain MMC Drive Capabilities |
|
1234 |
b. If the card size is greater than 2GBytes, test that the driver reports FAT32 file system supported. |
|
1235 |
c. Test that the type of media is reported as EMediaHardDisk |
|
1236 |
d. Test that the drive attributes report KDriveAttLocal and KDriveAttRemovable |
|
1237 |
e. Test that the drive attributes do not report KDriveAttRemote |
|
1238 |
f. If the drive is not write protected or a ROM card, test that the media attributes report that the drive is formattable |
|
1239 |
g. If the drive is write protected or a ROM card, test that the media attributes do not report that the drive is formattable |
|
1240 |
h. Test that the media attributes do not report variable sized media. |
|
1241 |
||
1242 |
@SYMTestExpectedResults All tests must pass |
|
1243 |
||
1244 |
@SYMPREQ1389 CR0795 Support for >2G SD Cards |
|
1245 |
*/ |
|
1246 |
TBool TestDriveInfo() |
|
1247 |
{ |
|
1248 |
test.Next( _L("Test drive info") ); |
|
1249 |
||
1250 |
TEST_FOR_ERROR( TheMmcDrive.Caps( DriveCaps ) ); |
|
1251 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1252 |
test.Printf( _L("Caps V1:\n\tiSize=0x%lx\n\tiType=%d\n\tiConnectionBusType=%d\n\tiDriveAtt=0x%x\n\tiMediaAtt=0x%x\n\tiBaseAddress=0x%x\n\tiFileSystemId=0x%x\n\tiPartitionType=0x%x\n"), |
0 | 1253 |
DriveCaps().iSize, |
1254 |
DriveCaps().iType, |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1255 |
DriveCaps().iConnectionBusType, |
0 | 1256 |
DriveCaps().iDriveAtt, |
1257 |
DriveCaps().iMediaAtt, |
|
1258 |
DriveCaps().iBaseAddress, |
|
1259 |
DriveCaps().iFileSystemId, |
|
1260 |
DriveCaps().iPartitionType ); |
|
1261 |
||
1262 |
test.Printf( _L("Caps V2:\n\tiHiddenSectors=0x%x\n\tiEraseBlockSize=0x%x\nCaps V3:\n\tiExtraInfo=%x\n\tiMaxBytesPerFormat=0x%x\n"), |
|
1263 |
DriveCaps().iHiddenSectors, |
|
1264 |
DriveCaps().iEraseBlockSize, |
|
1265 |
DriveCaps().iExtraInfo, |
|
1266 |
DriveCaps().iMaxBytesPerFormat ); |
|
1267 |
||
1268 |
test.Printf( _L("Format info:\n\tiCapacity=0x%lx\n\tiSectorsPerCluster=0x%x\n\tiSectorsPerTrack=0x%x\n\tiNumberOfSides=0x%x\n\tiFatBits=%d\n"), |
|
1269 |
DriveCaps().iFormatInfo.iCapacity, |
|
1270 |
DriveCaps().iFormatInfo.iSectorsPerCluster, |
|
1271 |
DriveCaps().iFormatInfo.iSectorsPerTrack, |
|
1272 |
DriveCaps().iFormatInfo.iNumberOfSides, |
|
1273 |
DriveCaps().iFormatInfo.iFATBits ); |
|
1274 |
||
1275 |
if(DriveCaps().iSerialNumLength > 0) |
|
1276 |
{ |
|
1277 |
test.Printf( _L("Serial Number : ") ); |
|
1278 |
TBuf8<2*KMaxSerialNumLength> snBuf; |
|
1279 |
TUint i; |
|
1280 |
for (i=0; i<DriveCaps().iSerialNumLength; i++) |
|
1281 |
{ |
|
1282 |
snBuf.AppendNumFixedWidth( DriveCaps().iSerialNum[i], EHex, 2 ); |
|
1283 |
test.Printf( _L("%02x"), DriveCaps().iSerialNum[i]); |
|
1284 |
} |
|
1285 |
test.Printf( _L("\n") ); |
|
1286 |
||
1287 |
CardType = TKnownCardTypes::EStandardCard; |
|
1288 |
for(i=0; i < sizeof(KnownCardTypes) / sizeof(TKnownCardTypes); i++) |
|
1289 |
{ |
|
1290 |
TPtrC8 serial(KnownCardTypes[i].iSerialNumber); |
|
1291 |
if(snBuf.Compare(serial) == 0) |
|
1292 |
{ |
|
1293 |
CardType = KnownCardTypes[i].iCardType; |
|
1294 |
break; |
|
1295 |
} |
|
1296 |
} |
|
1297 |
} |
|
1298 |
else |
|
1299 |
{ |
|
1300 |
test.Printf( _L("Serial Number : Not Supported") ); |
|
1301 |
} |
|
1302 |
||
1303 |
// DriveSize - The size of the partition to which the test is connected. |
|
1304 |
// MediaSize - The entire size of the media containing the partition. |
|
1305 |
||
1306 |
TInt64 mediaSize = DriveCaps().MediaSizeInBytes(); |
|
1307 |
TheMmcDrive.SetSize(DriveCaps().iSize, mediaSize); |
|
1308 |
if(mediaSize == 0) |
|
1309 |
{ |
|
1310 |
test.Printf(_L("Check entire media size: Not Supported\r\n")); |
|
1311 |
} |
|
1312 |
||
1313 |
test.Printf(_L("Entire media size: %ld\r\n"),mediaSize); |
|
1314 |
test.Printf(_L("Partition size: %ld\r\n"),DriveCaps().iSize); |
|
1315 |
test.Printf(_L("Hidden sectors: %d\r\n"),DriveCaps().iHiddenSectors); |
|
1316 |
||
1317 |
||
1318 |
TEST_FOR_VALUE( DriveCaps().iFileSystemId, KDriveFileSysFAT ); |
|
1319 |
||
1320 |
// Test that a drive >2GB is marked as requesting FAT32 |
|
1321 |
if( DriveCaps().iSize > KTwoGigbytes && DriveCaps().iExtraInfo) |
|
1322 |
{ |
|
1323 |
TEST_FOR_VALUE( DriveCaps().iFormatInfo.iFATBits, TLDFormatInfo::EFB32 ); |
|
1324 |
} |
|
1325 |
||
1326 |
TEST_FOR_VALUE( DriveCaps().iType, EMediaHardDisk ); |
|
1327 |
||
1328 |
const TUint KExpectedDriveAtt = KDriveAttLocal | KDriveAttRemovable; |
|
1329 |
const TUint KNotExpectedDriveAtt = KDriveAttRemote; |
|
1330 |
TEST_FOR_VALUE( DriveCaps().iDriveAtt & KExpectedDriveAtt, KExpectedDriveAtt ); |
|
1331 |
TEST_FOR_VALUE( DriveCaps().iDriveAtt & KNotExpectedDriveAtt, 0 ); |
|
1332 |
||
1333 |
TUint expectedMediaAtt = KMediaAttFormattable; |
|
1334 |
TUint notExpectedMediaAtt = KMediaAttVariableSize; |
|
1335 |
||
1336 |
TBool isReadOnly = DriveCaps().iMediaAtt & KMediaAttWriteProtected; |
|
1337 |
if(isReadOnly) |
|
1338 |
{ |
|
1339 |
expectedMediaAtt &= ~KMediaAttFormattable; |
|
1340 |
||
1341 |
test.Printf( _L("\n ---------------------------\n") ); |
|
1342 |
test.Printf( _L(" Media is Write Protected\n") ); |
|
1343 |
if((DriveCaps().iMediaAtt & KMediaAttFormattable) != KMediaAttFormattable) |
|
1344 |
{ |
|
1345 |
test.Printf( _L(" Media is a ROM card\n") ); |
|
1346 |
} |
|
1347 |
test.Printf( _L(" Some tests will be skipped\n") ); |
|
1348 |
test.Printf( _L(" ---------------------------\n") ); |
|
1349 |
} |
|
1350 |
||
1351 |
TEST_FOR_VALUE( DriveCaps().iMediaAtt & expectedMediaAtt, expectedMediaAtt ); |
|
1352 |
TEST_FOR_VALUE( DriveCaps().iMediaAtt & notExpectedMediaAtt, 0 ); |
|
1353 |
||
1354 |
return(isReadOnly); |
|
1355 |
} |
|
1356 |
||
1357 |
||
1358 |
/** |
|
1359 |
@SYMTestCaseID PBASE-T_MMCDRV-0165 |
|
1360 |
@SYMTestCaseDesc Test MMC Card Reads |
|
1361 |
@SYMTestPriority High |
|
1362 |
||
1363 |
@SYMTestActions |
|
1364 |
a. Read 64K in one operation from the start of the media and store the contents. |
|
1365 |
b. Read 512 byte blocks from the start of the media at various offsets and compare with initial read. |
|
1366 |
b. Read 64K in 512 byte blocks from the start of the media and compare with the initial read. |
|
1367 |
c. read 64K from the end of the drive |
|
1368 |
||
1369 |
@SYMTestExpectedResults All tests must pass |
|
1370 |
||
1371 |
@SYMPREQ1389 CR0795 Support for >2G SD Cards |
|
1372 |
*/ |
|
1373 |
void TestRead() |
|
1374 |
{ |
|
1375 |
// This just tests that we can read *something* from the drive |
|
1376 |
// We check elsewhere that we can read what we've written |
|
1377 |
test.Next( _L("Test reading" ) ); |
|
1378 |
||
1379 |
HBufC8* bigBuf = HBufC8::New( 65536 ); |
|
1380 |
HBufC8* smallBuf = HBufC8::New( 512 ); |
|
1381 |
||
1382 |
test( bigBuf != NULL ); |
|
1383 |
test( smallBuf != NULL ); |
|
1384 |
TPtr8 bigPtr( bigBuf->Des() ); |
|
1385 |
TPtr8 smallPtr( smallBuf->Des() ); |
|
1386 |
||
1387 |
test.Printf( _L("Read block from start of media\n") ); |
|
1388 |
TEST_FOR_ERROR( TheMmcDrive.Read( TInt64(0), 65536, bigPtr) ); |
|
1389 |
||
1390 |
test.Printf( _L("Read smaller blocks which should match the data in big block\n\r" ) ); |
|
1391 |
TInt i; |
|
1392 |
for( i = 0; i <= 512; ++i ) |
|
1393 |
{ |
|
1394 |
test.Printf( _L("\toffset: %d\r"), i ); |
|
1395 |
TEST_FOR_ERROR( TheMmcDrive.Read( TInt64(i), 512, smallPtr ) ); |
|
1396 |
test( CompareBuffers( smallBuf->Des(), bigBuf->Mid( i, 512 ) ) ); |
|
1397 |
} |
|
1398 |
||
1399 |
for( i = 512; i <= 65536-512; i += 512 ) |
|
1400 |
{ |
|
1401 |
test.Printf( _L("\toffset: %d\r"), i ); |
|
1402 |
TEST_FOR_ERROR( TheMmcDrive.Read( TInt64(i), 512, smallPtr ) ); |
|
1403 |
test( CompareBuffers( smallBuf->Des(), bigBuf->Mid( i, 512 ) ) ); |
|
1404 |
} |
|
1405 |
||
1406 |
test.Printf( _L("\nTest read from end of drive\n") ); |
|
1407 |
||
1408 |
if(CardType == TKnownCardTypes::EBuffalloMiniSD_512M || |
|
1409 |
CardType == TKnownCardTypes::EIntegralHSSD_2G) |
|
1410 |
{ |
|
1411 |
// These cards have issues with reading at the end of the drive... |
|
1412 |
test.Printf( _L(" -- Skipping Test - Known card detected --\n") ); |
|
1413 |
} |
|
1414 |
else |
|
1415 |
{ |
|
1416 |
TEST_FOR_ERROR( TheMmcDrive.Read( TheMmcDrive.Size() - 65536, 65536, bigPtr) ); |
|
1417 |
} |
|
1418 |
||
1419 |
delete smallBuf; |
|
1420 |
delete bigBuf; |
|
1421 |
} |
|
1422 |
||
1423 |
||
1424 |
/** |
|
1425 |
@SYMTestCaseID PBASE-T_MMCDRV-0511 |
|
1426 |
@SYMTestCaseDesc Test Moving Read/Write |
|
1427 |
@SYMTestPriority High |
|
1428 |
||
1429 |
@SYMTestActions |
|
1430 |
a.) Test Read/Verify Whole Sectors |
|
1431 |
b.) Test Read/Verify Sliding sector sized window |
|
1432 |
c.) Test Read/Verify Sliding byte sized window |
|
1433 |
d.) Test Read/Verify Increasing sized window |
|
1434 |
e.) Test Write/Read/Verify Whole Sectors |
|
1435 |
f.) Test Write/Read/Verify Sliding sector sized window |
|
1436 |
g.) Test Write/Read/Verify Increasing sized window |
|
1437 |
||
1438 |
@SYMTestExpectedResults All tests must pass |
|
1439 |
*/ |
|
1440 |
void DoReadWriteTest( TInt64 aPos, TInt aWindowSize, TBool aQuick ) |
|
1441 |
{ |
|
1442 |
// Do various read/write tests within a aWindowSize window starting at aPos |
|
1443 |
HBufC8* wholeBuf = HBufC8::New( aWindowSize ); |
|
1444 |
test( wholeBuf != NULL ); |
|
1445 |
||
1446 |
HBufC8* readBuf = HBufC8::New( aWindowSize ); |
|
1447 |
test( readBuf != NULL ); |
|
1448 |
||
1449 |
TBuf8<512> sectorBuf; |
|
1450 |
TRandGen rand; |
|
1451 |
||
1452 |
test.Printf( _L("Walking sector read\n\r") ); |
|
1453 |
FillRandomBuffer( wholeBuf, rand ); |
|
1454 |
TPtr8 wholeBufPtr( wholeBuf->Des() ); |
|
1455 |
TEST_FOR_ERROR( TheMmcDrive.Write( aPos, *wholeBuf ) ); |
|
1456 |
||
1457 |
// Read each sector back and check that it's correct |
|
1458 |
TInt64 pos( aPos ); |
|
1459 |
TInt i; |
|
1460 |
for( i = 0; i < aWindowSize - 512; i += 512 ) |
|
1461 |
{ |
|
1462 |
pos = aPos + i; |
|
1463 |
test.Printf(_L("\tRead @0x%lx\r"), pos); |
|
1464 |
TEST_FOR_ERROR( TheMmcDrive.Read( pos, 512, sectorBuf ) ); |
|
1465 |
test( CompareBuffers( sectorBuf, wholeBuf->Mid( i, 512 ) ) ); |
|
1466 |
} |
|
1467 |
||
1468 |
test.Printf( _L("\nSliding sector read\n\r") ); |
|
1469 |
// Slide a sector-sized window over the data |
|
1470 |
TInt maxl = Min( aWindowSize - 512, 512 * 3 ); |
|
1471 |
for( i = 0; i < maxl; i++ ) |
|
1472 |
{ |
|
1473 |
pos = aPos + i; |
|
1474 |
test.Printf(_L("\tRead @0x%lx\r"), pos); |
|
1475 |
TEST_FOR_ERROR( TheMmcDrive.Read( pos, 512, sectorBuf ) ); |
|
1476 |
test( CompareBuffers( sectorBuf, wholeBuf->Mid( i, 512 ) ) ); |
|
1477 |
} |
|
1478 |
||
1479 |
if( !aQuick ) |
|
1480 |
{ |
|
1481 |
test.Printf( _L("\nSliding byte read\n\r") ); |
|
1482 |
// Slide a byte-sized window over the data |
|
1483 |
for( i = 0; i < maxl; i++ ) |
|
1484 |
{ |
|
1485 |
pos = aPos + i; |
|
1486 |
test.Printf(_L("\tRead @0x%lx\r"), pos); |
|
1487 |
TEST_FOR_ERROR( TheMmcDrive.Read( pos, 1, sectorBuf ) ); |
|
1488 |
test( CompareBuffers( sectorBuf, wholeBuf->Mid( i, 1 ) ) ); |
|
1489 |
} |
|
1490 |
||
1491 |
test.Printf( _L("\nGrowing read\n\r") ); |
|
1492 |
// Read from an increasing-sized window |
|
1493 |
for( i = 1; i < 512; i++ ) |
|
1494 |
{ |
|
1495 |
test.Printf(_L("\tRead length: %d\r"), i); |
|
1496 |
TEST_FOR_ERROR( TheMmcDrive.Read( aPos, i, sectorBuf ) ); |
|
1497 |
test( CompareBuffers( sectorBuf, wholeBuf->Left( i ) ) ); |
|
1498 |
} |
|
1499 |
||
1500 |
test.Printf( _L("\nDownward-expanding read\n\r") ); |
|
1501 |
// Read from a window that grows downward from the end of the test region |
|
1502 |
for( i = 1; i <= 512; i++ ) |
|
1503 |
{ |
|
1504 |
pos = aPos + aWindowSize - i; |
|
1505 |
test.Printf(_L("\t[pos:len] %lx:%d\r"), pos, i); |
|
1506 |
TEST_FOR_ERROR( TheMmcDrive.Read( pos, i, sectorBuf ) ); |
|
1507 |
test( CompareBuffers( sectorBuf, wholeBuf->Mid( aWindowSize - i, i ) ) ); |
|
1508 |
} |
|
1509 |
} |
|
1510 |
||
1511 |
test.Printf( _L("\nWalking sector write\n\r") ); |
|
1512 |
// Overwrite each sector and check the whole region is correct |
|
1513 |
for( i = 0; i < aWindowSize - 512; i += 512 ) |
|
1514 |
{ |
|
1515 |
FillRandomBuffer( sectorBuf, rand ); |
|
1516 |
pos = aPos + i; |
|
1517 |
test.Printf(_L("\tWrite @0x%lx\r"), pos); |
|
1518 |
TEST_FOR_ERROR( TheMmcDrive.Write( pos, sectorBuf ) ); |
|
1519 |
wholeBufPtr.MidTPtr( i, 512 ) = sectorBuf; // update our match data |
|
1520 |
||
1521 |
TPtr8 ptr( readBuf->Des() ); |
|
1522 |
TEST_FOR_ERROR( TheMmcDrive.Read( aPos, aWindowSize, ptr ) ); |
|
1523 |
test( CompareBuffers( *readBuf, *wholeBuf ) ); |
|
1524 |
} |
|
1525 |
||
1526 |
if( !aQuick ) |
|
1527 |
{ |
|
1528 |
test.Printf( _L("\nSliding sector overwrite\n\r") ); |
|
1529 |
// Overwrite a sector-sized region that slides across the test region |
|
1530 |
for( i = 0; i < maxl; i += 1 ) |
|
1531 |
{ |
|
1532 |
FillRandomBuffer( sectorBuf, rand ); |
|
1533 |
pos = aPos + i; |
|
1534 |
test.Printf(_L("\tWrite @0x%lx\r"), pos); |
|
1535 |
TEST_FOR_ERROR( TheMmcDrive.Write( pos, sectorBuf ) ); |
|
1536 |
wholeBufPtr.MidTPtr( i, 512 ) = sectorBuf; // update our match data |
|
1537 |
||
1538 |
TPtr8 ptr( readBuf->Des() ); |
|
1539 |
TEST_FOR_ERROR( TheMmcDrive.Read( aPos, aWindowSize, ptr ) ); |
|
1540 |
test( CompareBuffers( *readBuf, *wholeBuf ) ); |
|
1541 |
} |
|
1542 |
||
1543 |
test.Printf( _L("\nGrowing sector overwrite\n\r") ); |
|
1544 |
// Overwrite an expanding region starting at aPos |
|
1545 |
for( i = 1; i < 512; i += 1 ) |
|
1546 |
{ |
|
1547 |
FillRandomBuffer( sectorBuf, rand ); |
|
1548 |
test.Printf(_L("\tWrite length: %d\r"), i); |
|
1549 |
sectorBuf.SetLength( i ); |
|
1550 |
TEST_FOR_ERROR( TheMmcDrive.Write( aPos, sectorBuf ) ); |
|
1551 |
wholeBufPtr.LeftTPtr( i ) = sectorBuf; // update our match data |
|
1552 |
||
1553 |
TPtr8 ptr( readBuf->Des() ); |
|
1554 |
TEST_FOR_ERROR( TheMmcDrive.Read( aPos, aWindowSize, ptr ) ); |
|
1555 |
test( CompareBuffers( *readBuf, *wholeBuf ) ); |
|
1556 |
} |
|
1557 |
} |
|
1558 |
||
1559 |
test.Printf( _L("\nTest zero-length read\n") ); |
|
1560 |
FillRandomBuffer( sectorBuf, rand ); |
|
1561 |
TEST_FOR_ERROR( TheMmcDrive.Read( aPos, 0, sectorBuf ) ); |
|
1562 |
TEST_FOR_VALUE( sectorBuf.Length(), 0 ); |
|
1563 |
||
1564 |
delete wholeBuf; |
|
1565 |
delete readBuf; |
|
1566 |
} |
|
1567 |
||
1568 |
||
1569 |
// This tests for a bug observed in certain ESanDiskMmcMobile_1GB cards which never exit the busy state |
|
1570 |
// when writing a buffer which is one sector bigger than the PSL buffer size (resulting in a single write |
|
1571 |
// request split into 2 fragments, the last of which is one sector only). The "fix" for this is to make the |
|
1572 |
// PSL reject CMD23 (SET_BLOCK_COUNT) for these particular cards, forcing the PIL to issue a CMD12 (STOP_TRANSMISSION) |
|
1573 |
void TestFragmentedWrite(TInt aLength) |
|
1574 |
{ |
|
1575 |
test.Next( _L("Test a large write just bigger than PSL buffer size") ); |
|
1576 |
||
1577 |
HBufC8* bigBuf = HBufC8::New( aLength); |
|
1578 |
test( bigBuf != NULL ); |
|
1579 |
TPtr8 bigPtr( bigBuf->Des() ); |
|
1580 |
||
1581 |
TInt64 startPos = 0; |
|
1582 |
||
1583 |
// for a dual-slot enabled H4, buffer size is 132K - (512 * 2) = 131K |
|
1584 |
||
1585 |
||
1586 |
test.Printf( _L("Initializing buffer contents...\n")); |
|
1587 |
bigPtr.SetLength(aLength); |
|
1588 |
TInt n; |
|
1589 |
for (n=0; n<aLength; n++) |
|
1590 |
{ |
|
1591 |
bigPtr[n] = (TUint8) n; |
|
1592 |
} |
|
1593 |
||
1594 |
bigPtr.SetLength(aLength); |
|
1595 |
test.Printf( _L("Write %d sectors\n"), bigPtr.Length() / 512); |
|
1596 |
TEST_FOR_ERROR( TheMmcDrive.Write( startPos, bigPtr) ); |
|
1597 |
||
1598 |
||
1599 |
bigPtr.SetLength(aLength); |
|
1600 |
bigPtr.FillZ(); |
|
1601 |
||
1602 |
test.Printf( _L("Read %d sectors\n"), bigPtr.Length() / 512); |
|
1603 |
TEST_FOR_ERROR( TheMmcDrive.Read( startPos, bigPtr.Length(), bigPtr) ); |
|
1604 |
||
1605 |
test.Printf( _L("Read #1 len %d \n"), bigPtr.Length()); |
|
1606 |
||
1607 |
for (n=0; n< 0 + aLength; n++) |
|
1608 |
{ |
|
1609 |
if (bigPtr[n] != (TUint8) n) |
|
1610 |
{ |
|
1611 |
test.Printf(_L("mismatch at %lx [0x%02x] != [0x%02x]"), n, bigPtr[n], (TUint8) n); |
|
1612 |
test(0); |
|
1613 |
} |
|
1614 |
} |
|
1615 |
||
1616 |
delete bigBuf; |
|
1617 |
} |
|
1618 |
||
1619 |
void TestWrite() |
|
1620 |
{ |
|
1621 |
// for a dual-slot enabled H4, buffer size is 132K - (512 * 2) = 131K |
|
1622 |
TestFragmentedWrite(131*1024 + 512); |
|
1623 |
// for a single-slot enabled H4, buffer size is 132K - (512 * 1) = 131K + 512 |
|
1624 |
TestFragmentedWrite(131*1024 + 1024); |
|
1625 |
||
1626 |
||
1627 |
test.Next( _L("Test writing to drive") ); |
|
1628 |
DoReadWriteTest( 0, 65536, EFalse ); |
|
1629 |
} |
|
1630 |
||
1631 |
||
1632 |
/** |
|
1633 |
@SYMTestCaseID PBASE-T_MMCDRV-0166 |
|
1634 |
@SYMTestCaseDesc Test MMC Card accesses at the end of the media |
|
1635 |
@SYMTestPriority High |
|
1636 |
||
1637 |
@SYMTestActions |
|
1638 |
a. If the card is not read-only, perform read/write tests at the last 64K of the media. |
|
1639 |
b. Test that all accesses beyond the end of the media produce an error. |
|
1640 |
||
1641 |
@SYMTestExpectedResults All tests must pass |
|
1642 |
||
1643 |
@SYMPREQ1389 CR0795 Support for >2G SD Cards |
|
1644 |
*/ |
|
1645 |
void TestCapacity() |
|
1646 |
{ |
|
1647 |
if(!IsReadOnly) |
|
1648 |
{ |
|
1649 |
test.Next( _L("Test access at end of media") ); |
|
1650 |
DoReadWriteTest( TheMmcDrive.Size() - 65536, 65536, ETrue ); |
|
1651 |
} |
|
1652 |
||
1653 |
test.Printf( _L("Test accesses past end of media produce an error\n") ); |
|
1654 |
||
1655 |
TBuf8<1024> buf; |
|
1656 |
||
1657 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size(), 1, buf ) ); |
|
1658 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size(), 2, buf ) ); |
|
1659 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size(), 512, buf ) ); |
|
1660 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size() + 1, 512, buf ) ); |
|
1661 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size() + 512, 512, buf ) ); |
|
1662 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size() - 1, 2, buf ) ); |
|
1663 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size() - 511, 512, buf ) ); |
|
1664 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size() - 512, 513, buf ) ); |
|
1665 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size() - 65536, 65537, buf ) ); |
|
1666 |
test( KErrNone != TheMmcDrive.Read( TheMmcDrive.Size() - 512, 1024, buf ) ); |
|
1667 |
} |
|
1668 |
||
1669 |
||
1670 |
void WriteAcrossBoundaries(TInt64 aBoundary) |
|
1671 |
{ |
|
1672 |
test.Printf( _L("Test for aliasing around boundary\n") ); |
|
1673 |
TBuf8<512> bufLo; |
|
1674 |
TBuf8<512> bufHi; |
|
1675 |
TBuf8<8192> bufRead; |
|
1676 |
||
1677 |
bufLo.Fill( 0xE4, 512 ); |
|
1678 |
bufHi.Fill( 0x19, 512 ); |
|
1679 |
||
1680 |
TEST_FOR_ERROR( TheMmcDrive.Write( 0, bufLo ) ); |
|
1681 |
TEST_FOR_ERROR( TheMmcDrive.Write( aBoundary, bufHi ) ); |
|
1682 |
TEST_FOR_ERROR( TheMmcDrive.Read( 0, 512, bufRead ) ); |
|
1683 |
test( bufRead == bufLo ); |
|
1684 |
TEST_FOR_ERROR( TheMmcDrive.Read( aBoundary, 512, bufRead ) ); |
|
1685 |
test( bufRead == bufHi ); |
|
1686 |
||
1687 |
bufHi.Fill( 0xBB, 1 ); |
|
1688 |
TEST_FOR_ERROR( TheMmcDrive.Write( aBoundary, bufHi ) ); |
|
1689 |
TEST_FOR_ERROR( TheMmcDrive.Read( 0, 512, bufRead ) ); |
|
1690 |
test( bufRead == bufLo ); |
|
1691 |
||
1692 |
bufHi.Fill( 0xCC, 1 ); |
|
1693 |
TEST_FOR_ERROR( TheMmcDrive.Write( (aBoundary+1), bufHi ) ); |
|
1694 |
TEST_FOR_ERROR( TheMmcDrive.Read( 0, 512, bufRead ) ); |
|
1695 |
test( bufRead == bufLo ); |
|
1696 |
||
1697 |
test.Printf( _L("Test write which ends at boundary\n") ); |
|
1698 |
bufHi.Fill( 0x33, 512 ); |
|
1699 |
TEST_FOR_ERROR( TheMmcDrive.Write( aBoundary, bufHi ) ); |
|
1700 |
TEST_FOR_ERROR( TheMmcDrive.Read( aBoundary, 512, bufRead ) ); |
|
1701 |
test( bufRead == bufHi ); |
|
1702 |
||
1703 |
bufHi.Fill( 0x44, 512 ); |
|
1704 |
TEST_FOR_ERROR( TheMmcDrive.Write( aBoundary - 512, bufHi ) ); |
|
1705 |
TEST_FOR_ERROR( TheMmcDrive.Read( aBoundary - 512, 512, bufRead ) ); |
|
1706 |
test( bufRead == bufHi ); |
|
1707 |
||
1708 |
TEST_FOR_ERROR( TheMmcDrive.Read( 0, 512, bufRead ) ); |
|
1709 |
test( bufRead == bufLo ); |
|
1710 |
||
1711 |
bufHi.Fill( 0x33, 512 ); |
|
1712 |
TEST_FOR_ERROR( TheMmcDrive.Read( aBoundary, 512, bufRead ) ); |
|
1713 |
test( bufRead == bufHi ); |
|
1714 |
||
1715 |
test.Printf( _L("Test read-modify-write across boundary\n") ); |
|
1716 |
TBuf8<512> rmw; |
|
1717 |
TBuf8<8192> data; |
|
1718 |
rmw.Fill( 0x66, 512 ); |
|
1719 |
data.Fill( 0x11, 8192 ); |
|
1720 |
||
1721 |
for( TInt i = 1; i < 511; ++i ) |
|
1722 |
{ |
|
1723 |
ProgressBar(i, 511, 11); |
|
1724 |
||
1725 |
// Create initial data block |
|
1726 |
TEST_FOR_ERROR( TheMmcDrive.Write( aBoundary - 512, data ) ); |
|
1727 |
||
1728 |
// Read-modify-write some data |
|
1729 |
TEST_FOR_ERROR( TheMmcDrive.Write( aBoundary - 512 + i, rmw ) ); |
|
1730 |
||
1731 |
// Modify buffer to what we expect |
|
1732 |
data.MidTPtr( i, 512 ) = rmw; |
|
1733 |
||
1734 |
// Read it back and check it matches |
|
1735 |
TEST_FOR_ERROR( TheMmcDrive.Read( aBoundary - 512, 8192, bufRead ) ); |
|
1736 |
test( CompareBuffers( bufRead, data ) ); |
|
1737 |
} |
|
1738 |
test.Printf(_L("\n")); |
|
1739 |
} |
|
1740 |
||
1741 |
||
1742 |
/** |
|
1743 |
@SYMTestCaseID PBASE-T_MMCDRV-0167 |
|
1744 |
@SYMTestCaseDesc Test that the boundary >2GB doesn't produce aliases or errors |
|
1745 |
@SYMTestPriority High |
|
1746 |
||
1747 |
@SYMTestActions |
|
1748 |
a. Test that writing at the 2G boundary does not produce aliases. |
|
1749 |
b. Test writes that end at the 2G boundary. |
|
1750 |
c. Test read/modify/write across the 2G boundary. |
|
1751 |
||
1752 |
@SYMTestExpectedResults All tests must pass |
|
1753 |
||
1754 |
@SYMPREQ1389 CR0795 Support for >2G SD Cards |
|
1755 |
*/ |
|
1756 |
void TestBoundaries() |
|
1757 |
{ |
|
1758 |
||
1759 |
if( TheMmcDrive.Size() < 0x80008000 ) |
|
1760 |
{ |
|
1761 |
test.Printf( _L("Drive not large enough for 2GB boundary test... skipped\n") ); |
|
1762 |
return; |
|
1763 |
} |
|
1764 |
||
1765 |
// Test that the boundary 2GB doesn't produce aliases or errors |
|
1766 |
// >2Gb cards change addressing scheme from byte to block base |
|
1767 |
test.Next( _L("Test 2GB boundary") ); |
|
1768 |
WriteAcrossBoundaries(0x80000000); |
|
1769 |
||
1770 |
// N.B. Commented Out for now due to compiler warnings |
|
1771 |
// if( TheMmcDrive.Size() < 0x100008000ll ) |
|
1772 |
// { |
|
1773 |
// test.Printf( _L("Drive not large enough for 4GB boundary test... skipped\n") ); |
|
1774 |
// return; |
|
1775 |
// } |
|
1776 |
// // Test that the boundary 4GB doesn't produce aliases or errors |
|
1777 |
// // >4GB cards change addressing scheme from 32bit to 64bit addresses |
|
1778 |
// test.Next( _L("Test 4GB boundary") ); |
|
1779 |
// WriteAcrossBoundaries(0x100000000ll); |
|
1780 |
} |
|
1781 |
||
1782 |
||
1783 |
/** |
|
1784 |
@SYMTestCaseID PBASE-T_MMCDRV-0512 |
|
1785 |
@SYMTestCaseDesc Test Media Change/Capabilities Reporting |
|
1786 |
@SYMTestPriority High |
|
1787 |
||
1788 |
@SYMTestActions |
|
1789 |
a.) Test Media Change flag after Media Change |
|
1790 |
b.) Test Capabilities reporting for Out Of Memory Conditions |
|
1791 |
c.) Test Media Change flag after Machine power-off |
|
1792 |
d.) Test Capabilities reporting after Machine power-off |
|
1793 |
e.) Test Multiple Media Change flags after Media Change |
|
1794 |
||
1795 |
@SYMTestExpectedResults All tests must pass |
|
1796 |
*/ |
|
1797 |
void TestMediaChange() |
|
1798 |
{ |
|
1799 |
test.Next(_L("MMC drive: Media change")); |
|
1800 |
#if defined (__WINS__) |
|
1801 |
test.Printf( _L("<<<Hit F5 - then any other key>>>\r\n")); |
|
1802 |
#else |
|
1803 |
test.Printf( _L("<<<Generate Media change - then hit a key>>>\r\n")); |
|
1804 |
#endif |
|
1805 |
test.Getch(); |
|
1806 |
User::After(300000); // Allow 0.3s after power down for controller to detect door closed. |
|
1807 |
test(ChangeFlag!=EFalse); |
|
1808 |
||
1809 |
test.Next(_L("MMC drive: Caps following media change")); |
|
1810 |
||
1811 |
TLocalDriveCapsV4 info; |
|
1812 |
TPckg<TLocalDriveCapsV4> infoPckg(info); |
|
1813 |
||
1814 |
test(TheMmcDrive.Caps(infoPckg)==KErrNone); |
|
1815 |
test(info.iType==EMediaHardDisk); |
|
1816 |
||
1817 |
test.Next(_L("MMC drive: Caps while OOM")); |
|
1818 |
TInt err; |
|
1819 |
test.Printf(_L("Mount returns:")); |
|
1820 |
for (TInt j=1;j<16;j++) |
|
1821 |
{ |
|
1822 |
__KHEAP_SETFAIL(RHeap::EDeterministic,j); |
|
1823 |
err=TheMmcDrive.Caps(infoPckg); |
|
1824 |
test.Printf(_L("(%d)"),err); |
|
1825 |
__KHEAP_RESET; |
|
1826 |
} |
|
1827 |
test.Printf(_L("\r\n")); |
|
1828 |
||
1829 |
test.Next(_L("MMC drive: Machine power-off.")); |
|
1830 |
ChangeFlag=EFalse; |
|
1831 |
RTimer timer; |
|
1832 |
TRequestStatus trs; |
|
1833 |
test(timer.CreateLocal()==KErrNone); |
|
1834 |
TTime tim; |
|
1835 |
tim.HomeTime(); |
|
1836 |
tim+=TTimeIntervalSeconds(8); |
|
1837 |
timer.At(trs,tim); |
|
1838 |
UserHal::SwitchOff(); |
|
1839 |
User::WaitForRequest(trs); |
|
1840 |
test(trs.Int()==KErrNone); |
|
1841 |
test(ChangeFlag==EFalse); // ie machine power off hasn't updated it |
|
1842 |
||
1843 |
test.Next(_L("MMC drive: Caps following power off")); |
|
1844 |
TInt r=TheMmcDrive.Caps(infoPckg); |
|
1845 |
test(r==KErrNone); |
|
1846 |
test(info.iType==EMediaHardDisk); |
|
1847 |
||
1848 |
test.Next(_L("Starting 2nd thread")); |
|
1849 |
SecThreadChangeFlag=EFalse; |
|
1850 |
RThread thread; |
|
1851 |
TRequestStatus stat; |
|
1852 |
test(thread.Create(_L("Thread"),dontDisconnectThread,KDefaultStackSize,KHeapSize,KHeapSize,NULL)==KErrNone); |
|
1853 |
thread.Logon(stat); |
|
1854 |
thread.Resume(); |
|
1855 |
User::WaitForRequest(stat); |
|
1856 |
test(stat==KErrNone); |
|
1857 |
thread.Close(); |
|
1858 |
||
1859 |
test.Next(_L("MMC drive: 2nd media change")); |
|
1860 |
// UserSvr::ForceRemountMedia(ERemovableMedia0); // Generate media change |
|
1861 |
test(ChangeFlag!=EFalse); |
|
1862 |
test(SecThreadChangeFlag==EFalse); // Closed 2nd thread so shouldn't have been updated |
|
1863 |
} |
|
1864 |
||
287 | 1865 |
// Helper function for eMMC partition switching test - writes test data |
1866 |
TInt EMmcPartitionWriteTestData(const TInt aDriveNumber, const TChar aDataPattern) |
|
1867 |
{ |
|
1868 |
TBusLocalDrive drv; |
|
1869 |
TBool chg(EFalse); |
|
1870 |
||
1871 |
TInt r = drv.Connect(aDriveNumber, chg); |
|
1872 |
test(r == KErrNone); |
|
1873 |
||
1874 |
TBuf8<KDiskSectorSize> buffer; |
|
1875 |
||
1876 |
// write pattern to sector 0 |
|
1877 |
buffer.Fill(aDataPattern, KDiskSectorSize); |
|
1878 |
r = drv.Write((TInt64) 0, buffer); |
|
1879 |
||
1880 |
return r; |
|
1881 |
} |
|
1882 |
||
1883 |
// Helper function for eMMC partition switching test - reads test data |
|
1884 |
TInt EMmcPartitionReadTestData(const TInt aDriveNumber, TDes8& aData) |
|
1885 |
{ |
|
1886 |
// read pattern from sector 0 |
|
1887 |
TBusLocalDrive drv; |
|
1888 |
TBool chg(EFalse); |
|
1889 |
||
1890 |
TInt r = drv.Connect(aDriveNumber, chg); |
|
1891 |
test(r == KErrNone); |
|
1892 |
||
1893 |
aData.Fill(0x00, aData.MaxSize()); |
|
1894 |
r = drv.Read((TInt64) 0, aData.MaxSize(), aData); |
|
1895 |
||
1896 |
drv.Disconnect(); |
|
1897 |
return r; |
|
1898 |
} |
|
1899 |
||
1900 |
// Helper function for eMMC partition switching test - compares data to expected pattern |
|
1901 |
TInt EMmcPartitionReadAndCompareTestData(const TInt aDriveNumber, const TChar aExpectedPattern) |
|
1902 |
{ |
|
1903 |
TBuf8<KDiskSectorSize> actual; |
|
1904 |
TBuf8<KDiskSectorSize> expected; |
|
1905 |
TInt r = EMmcPartitionReadTestData(aDriveNumber, actual); |
|
1906 |
test(r == KErrNone); |
|
1907 |
||
1908 |
expected.Fill(aExpectedPattern, KDiskSectorSize); |
|
1909 |
||
1910 |
if(expected.Compare(actual) != 0) |
|
1911 |
{ |
|
1912 |
test.Printf(_L("ERROR: Comparison failed. Expected:\n")); |
|
1913 |
DumpBuffer(expected); |
|
1914 |
test.Printf(_L("\nActual:\n")); |
|
1915 |
DumpBuffer(actual); |
|
1916 |
r = KErrGeneral; |
|
1917 |
} |
|
1918 |
||
1919 |
return r; |
|
1920 |
} |
|
1921 |
||
1922 |
||
1923 |
||
1924 |
/** |
|
1925 |
@SYMTestCaseID 0514 (taken from spare test case IDs) |
|
1926 |
@SYMTestCaseDesc Test low-level partition switching capability |
|
1927 |
@SYMTestPriority normal |
|
1928 |
||
1929 |
@SYMTestActions |
|
1930 |
a) Precondition: Valid partitions have been flashed to BOOT 1 and BOOT 2, |
|
1931 |
these have to be mapped correctly in variantmediadef.h |
|
1932 |
b) Write Data Pattern 1 to BOOT 1 |
|
1933 |
c) Write Data Pattern 2 to BOOT 2 |
|
1934 |
d) Read data from BOOT 1 and compare to DP1 - test passes if data matches |
|
1935 |
e) Write Data Pattern 3 to BOOT 1, at the same offset as in b) |
|
1936 |
f) Read data from BOOT 2 and compare to DP2 - test passes if data matches |
|
1937 |
||
1938 |
@SYMTestExpectedResults All tests must pass |
|
1939 |
*/ |
|
1940 |
void TestPartitionSwitching() |
|
1941 |
{ |
|
1942 |
const TInt KDriveBoot1 = 4; // see variantmediadef.h |
|
1943 |
const TInt KDriveBoot2 = 5; |
|
1944 |
const TChar KDataPattern1 = 0xD1; |
|
1945 |
const TChar KDataPattern2 = 0xD2; |
|
1946 |
const TChar KDataPattern3 = 0xD3; |
|
1947 |
||
1948 |
test.Start(_L("eMMC partition switching")); |
|
1949 |
||
1950 |
// Write data data pattern 1 to boot1 |
|
1951 |
test.Printf(_L("Writing Data Pattern 1 to BOOT 1\n")); |
|
1952 |
TInt r = EMmcPartitionWriteTestData(KDriveBoot1, KDataPattern1); |
|
1953 |
test(r == KErrNone); |
|
1954 |
||
1955 |
// Write data data pattern 2 to boot2 |
|
1956 |
test.Printf(_L("Writing Data Pattern 2 to BOOT 2\n")); |
|
1957 |
r = EMmcPartitionWriteTestData(KDriveBoot2, KDataPattern2); |
|
1958 |
test(r == KErrNone); |
|
1959 |
||
1960 |
// Read back data from boot 1 and compare it to previously written pattern |
|
1961 |
test.Printf(_L("Reading from BOOT 1\n")); |
|
1962 |
r = EMmcPartitionReadAndCompareTestData(KDriveBoot1, KDataPattern1); |
|
1963 |
test(r == KErrNone); |
|
1964 |
||
1965 |
// Write data data pattern 3 to boot1 |
|
1966 |
test.Printf(_L("Writing Data Pattern 3 to BOOT 1\n")); |
|
1967 |
r = EMmcPartitionWriteTestData(KDriveBoot1, KDataPattern3); |
|
1968 |
test(r == KErrNone); |
|
1969 |
||
1970 |
// Read back data from boot 2 and compare it to previously written pattern |
|
1971 |
test.Printf(_L("Reading from BOOT 2\n")); |
|
1972 |
r = EMmcPartitionReadAndCompareTestData(KDriveBoot2, KDataPattern2); |
|
1973 |
test(r == KErrNone); |
|
1974 |
||
1975 |
test.End(); |
|
1976 |
} |
|
0 | 1977 |
|
1978 |
//// End of Test |
|
287 | 1979 |
|
1980 |
||
0 | 1981 |
void Format() |
1982 |
// |
|
1983 |
// Format current drive |
|
1984 |
// |
|
1985 |
{ |
|
1986 |
RFs TheFs; |
|
1987 |
test(TheFs.Connect() == KErrNone); |
|
1988 |
||
1989 |
test.Next(_L("Format")); |
|
1990 |
TBuf<4> driveBuf=_L("?:\\"); |
|
1991 |
driveBuf[0]=(TText)(RFsDNum+'A'); |
|
1992 |
||
1993 |
RFormat format; |
|
1994 |
TInt count; |
|
1995 |
TInt r=format.Open(TheFs,driveBuf,EQuickFormat,count); |
|
1996 |
test(r==KErrNone); |
|
1997 |
while(count) |
|
1998 |
{ |
|
1999 |
TInt r=format.Next(count); |
|
2000 |
test(r==KErrNone); |
|
2001 |
} |
|
2002 |
format.Close(); |
|
2003 |
} |
|
2004 |
||
2005 |
void AllocateBuffers() |
|
2006 |
{ |
|
2007 |
test.Next(_L("Allocate Buffers")); |
|
2008 |
||
2009 |
//HBufC8* wrBufH = NULL; |
|
2010 |
//HBufC8* rdBufH = NULL; |
|
2011 |
||
2012 |
wrBufH = HBufC8::New(KVeryLongRdWrBufLen); |
|
2013 |
test(wrBufH != NULL); |
|
2014 |
||
2015 |
rdBufH = HBufC8::New(KVeryLongRdWrBufLen); |
|
2016 |
if(rdBufH == NULL) delete wrBufH; |
|
2017 |
test(rdBufH != NULL); |
|
2018 |
||
2019 |
wrBuf.Set(wrBufH->Des()); |
|
2020 |
rdBuf.Set(rdBufH->Des()); |
|
2021 |
} |
|
2022 |
||
2023 |
void AllocateSharedBuffers(TBool Fragmented, TBool Caching) |
|
2024 |
{ |
|
2025 |
// Setup SharedMemory Buffers |
|
2026 |
test.Next(_L("Allocate Shared Memory\n")); |
|
2027 |
||
2028 |
RLoader l; |
|
2029 |
test(l.Connect()==KErrNone); |
|
2030 |
test(l.CancelLazyDllUnload()==KErrNone); |
|
2031 |
l.Close(); |
|
2032 |
||
2033 |
test.Printf(_L("Initialise\n")); |
|
2034 |
TInt r = UserHal::PageSizeInBytes(PageSize); |
|
2035 |
test(r==KErrNone); |
|
2036 |
||
2037 |
test.Printf(_L("Loading test driver\n")); |
|
2038 |
r = User::LoadLogicalDevice(KSharedChunkLddName); |
|
2039 |
test(r==KErrNone || r==KErrAlreadyExists); |
|
2040 |
||
2041 |
test.Printf(_L("Opening channel\n")); |
|
2042 |
r = Ldd.Open(); |
|
2043 |
test(r==KErrNone); |
|
2044 |
||
2045 |
test.Printf(_L("Create chunk\n")); |
|
2046 |
||
2047 |
TUint aCreateFlags = EMultiple|EOwnsMemory; |
|
2048 |
||
2049 |
if (Caching) |
|
2050 |
{ |
|
2051 |
test.Printf(_L("Chunk Type:Caching\n")); |
|
2052 |
aCreateFlags |= ECached; |
|
2053 |
} |
|
2054 |
else |
|
2055 |
test.Printf(_L("Chunk Type:Fully Blocking\n")); |
|
2056 |
||
2057 |
TCommitType aCommitType = EContiguous; |
|
2058 |
||
2059 |
TUint TotalChunkSize = ChunkSize; // rounded to nearest Page Size |
|
2060 |
||
2061 |
TUint ChunkAttribs = TotalChunkSize|aCreateFlags; |
|
2062 |
r = Ldd.CreateChunk(ChunkAttribs); |
|
2063 |
test(r==KErrNone); |
|
2064 |
||
2065 |
if(Fragmented) |
|
2066 |
{ |
|
2067 |
test.Printf(_L("Commit Fragmented Memory\n")); |
|
2068 |
||
2069 |
// Allocate Pages in reverse order to maximise memory fragmentation |
|
2070 |
TUint i = ChunkSize; |
|
2071 |
do |
|
2072 |
{ |
|
2073 |
i-=PageSize; |
|
2074 |
test.Printf(_L("Commit %d\n"), i); |
|
2075 |
r = Ldd.CommitMemory(aCommitType|i,PageSize); |
|
2076 |
test(r==KErrNone); |
|
2077 |
}while (i>0); |
|
2078 |
} |
|
2079 |
else |
|
2080 |
{ |
|
2081 |
test.Printf(_L("Commit Contigouos Memory\n")); |
|
2082 |
r = Ldd.CommitMemory(aCommitType,TotalChunkSize); |
|
2083 |
test(r==KErrNone); |
|
2084 |
} |
|
2085 |
||
2086 |
test.Printf(_L("Open user handle\n")); |
|
2087 |
r = Ldd.GetChunkHandle(TheChunk); |
|
2088 |
test(r==KErrNone); |
|
2089 |
||
2090 |
} |
|
2091 |
||
2092 |
||
2093 |
void DeAllocateBuffers() |
|
2094 |
{ |
|
2095 |
delete rdBufH; |
|
2096 |
delete wrBufH; |
|
2097 |
} |
|
2098 |
||
2099 |
void DeAllocareSharedMemory() |
|
2100 |
{ |
|
2101 |
// destory chunk |
|
2102 |
test.Printf(_L("Shared Memory\n")); |
|
2103 |
test.Printf(_L("Close user chunk handle\n")); |
|
2104 |
TheChunk.Close(); |
|
2105 |
||
2106 |
test.Printf(_L("Close kernel chunk handle\n")); |
|
2107 |
TInt r = Ldd.CloseChunk(); // 1==DObject::EObjectDeleted |
|
2108 |
test(r==1); |
|
2109 |
||
2110 |
test.Printf(_L("Check chunk is destroyed\n")); |
|
2111 |
r = Ldd.IsDestroyed(); |
|
2112 |
test(r==1); |
|
2113 |
||
2114 |
test.Printf(_L("Close test driver\n")); |
|
2115 |
Ldd.Close(); |
|
2116 |
} |
|
2117 |
||
2118 |
||
2119 |
TBool SetupDrivesForPlatform(TInt& aDrive, TInt &aRFsDriveNum) |
|
2120 |
/** |
|
2121 |
* Finds a MMC/SD suitable drive for testing |
|
2122 |
* |
|
2123 |
* @param aDrive The number of the local drive to test |
|
2124 |
* @return TBool ETrue if a suitable drive is found, EFalse otherwise. |
|
2125 |
*/ |
|
2126 |
{ |
|
2127 |
||
2128 |
TDriveInfoV1Buf diBuf; |
|
2129 |
UserHal::DriveInfo(diBuf); |
|
2130 |
TDriveInfoV1 &di=diBuf(); |
|
2131 |
||
2132 |
test.Printf(_L(" iRegisteredDriveBitmask 0x%08X"), di.iRegisteredDriveBitmask); |
|
2133 |
||
2134 |
aDrive = -1; |
|
2135 |
||
2136 |
TLocalDriveCapsV5Buf capsBuf; |
|
2137 |
TBusLocalDrive TBLD; |
|
2138 |
TLocalDriveCapsV5& caps = capsBuf(); |
|
2139 |
TPtrC8 localSerialNum; |
|
2140 |
TInt registeredDriveNum = 0; |
|
2141 |
for(aDrive=0; aDrive < KMaxLocalDrives; aDrive++) |
|
2142 |
{ |
|
2143 |
TInt driveNumberMask = 1 << aDrive; |
|
2144 |
if ((di.iRegisteredDriveBitmask & driveNumberMask) == 0) |
|
2145 |
continue; |
|
2146 |
||
2147 |
test.Printf(_L(" Drive %d - %S\r\n"), aDrive, &di.iDriveName[registeredDriveNum]); |
|
2148 |
||
2149 |
// check that the card is readable (so we can ignore for empty card slots) |
|
2150 |
if ((di.iDriveName[registeredDriveNum].MatchF(_L("MultiMediaCard0")) == KErrNone) || |
|
2151 |
(di.iDriveName[registeredDriveNum].MatchF(_L("SDIOCard0")) == KErrNone)) |
|
2152 |
{ |
|
2153 |
||
2154 |
TBool TBLDChangedFlag; |
|
2155 |
TInt r = TBLD.Connect(aDrive, TBLDChangedFlag); |
|
2156 |
//test.Printf(_L(" Connect returned %d\n"), r); |
|
2157 |
if (r == KErrNone) |
|
2158 |
{ |
|
2159 |
r = TBLD.Caps(capsBuf); |
|
2160 |
localSerialNum.Set(caps.iSerialNum, caps.iSerialNumLength); |
|
2161 |
const TInt KSectSize = 512; |
|
2162 |
TBuf8<KSectSize> sect; |
|
2163 |
r = TBLD.Read(0, KSectSize, sect); |
|
2164 |
//test.Printf(_L(" Read returned %d\n"), r); |
|
2165 |
||
2166 |
TBLD.Disconnect(); |
|
2167 |
if (r == KErrNone) |
|
2168 |
break; |
|
2169 |
} |
|
2170 |
} |
|
2171 |
registeredDriveNum++; |
|
2172 |
} |
|
2173 |
||
2174 |
if(aDrive == KMaxLocalDrives) |
|
2175 |
{ |
|
2176 |
test.Printf(_L(" MMC Drive Not Found\r\n")); |
|
2177 |
return EFalse; |
|
2178 |
} |
|
2179 |
||
2180 |
// Work out the file server drive number (which isn't necessarily the same |
|
2181 |
// as the TBusLocalDrive drive number) |
|
2182 |
RFs theFs; |
|
2183 |
test(theFs.Connect() == KErrNone); |
|
2184 |
||
2185 |
TInt i; |
|
2186 |
for (i = EDriveA; i < EDriveZ; i++) |
|
2187 |
{ |
|
2188 |
TMediaSerialNumber serialNum; |
|
2189 |
TInt r = theFs.GetMediaSerialNumber(serialNum, i); |
|
2190 |
TInt len = serialNum.Length(); |
|
2191 |
TInt n; |
|
2192 |
for (n=0; n<len; n+=16) |
|
2193 |
{ |
|
2194 |
TBuf16<16*3 +1> buf; |
|
2195 |
for (TInt m=n; m<n+16; m++) |
|
2196 |
{ |
|
2197 |
TBuf16<3> hexBuf; |
|
2198 |
hexBuf.Format(_L("%02X "),serialNum[m]); |
|
2199 |
buf.Append(hexBuf); |
|
2200 |
} |
|
2201 |
buf.Append(_L("\n")); |
|
2202 |
test.Printf(buf); |
|
2203 |
} |
|
2204 |
if (serialNum.Compare(localSerialNum) == 0) |
|
2205 |
{ |
|
2206 |
TVolumeInfo vi; |
|
2207 |
r = theFs.Volume(vi, i); |
|
2208 |
TBool sizeMatch = (vi.iSize < caps.iSize); |
|
2209 |
if (sizeMatch) |
|
2210 |
{ |
|
2211 |
aRFsDriveNum = i; |
|
2212 |
break; |
|
2213 |
} |
|
2214 |
} |
|
2215 |
||
2216 |
} |
|
2217 |
if (i == EDriveZ) |
|
2218 |
{ |
|
2219 |
test.Printf(_L(" RFs MMC Drive Not Found\r\n")); |
|
2220 |
return EFalse; |
|
2221 |
} |
|
2222 |
||
2223 |
theFs.Close(); |
|
2224 |
||
2225 |
return ETrue; |
|
2226 |
} |
|
2227 |
||
2228 |
||
2229 |
LOCAL_D TBool ParseCommandLineArgs() |
|
2230 |
{ |
|
2231 |
||
2232 |
TBuf<0x100> cmd; |
|
2233 |
User::CommandLine(cmd); |
|
2234 |
TLex lex(cmd); |
|
2235 |
||
2236 |
for (TPtrC token=lex.NextToken(); token.Length() != 0;token.Set(lex.NextToken())) |
|
2237 |
{ |
|
2238 |
if (token.CompareF(_L("-m"))== 0) |
|
2239 |
{ |
|
2240 |
ManualMode = ETrue; |
|
2241 |
continue; |
|
2242 |
} |
|
2243 |
} |
|
2244 |
||
2245 |
if (ManualMode) |
|
2246 |
{ |
|
2247 |
// Get the list of drives |
|
2248 |
TDriveInfoV1Buf diBuf; |
|
2249 |
UserHal::DriveInfo(diBuf); |
|
2250 |
TDriveInfoV1 &di=diBuf(); |
|
2251 |
TInt driveCount = di.iTotalSupportedDrives; |
|
2252 |
||
2253 |
//Print the list of usable drives |
|
2254 |
test.Printf(_L("\nDRIVES USED AT PRESENT :\r\n")); |
|
2255 |
||
2256 |
for (TInt i=0; i < driveCount; i++) |
|
2257 |
{ |
|
2258 |
TBool flag=EFalse; |
|
2259 |
RLocalDrive d; |
|
2260 |
TInt r=d.Connect(i,flag); |
|
2261 |
//Not all the drives are used at present |
|
2262 |
if (r == KErrNotSupported) |
|
2263 |
continue; |
|
2264 |
||
2265 |
test.Printf(_L("%d : DRIVE NAME :%- 16S\r\n"), i, &di.iDriveName[i]); |
|
2266 |
} |
|
2267 |
||
2268 |
test.Printf(_L("\r\nWarning - all data on removable drive will be lost.\r\n")); |
|
2269 |
test.Printf(_L("<<<Hit mmc drive number to continue>>>\r\n")); |
|
2270 |
||
2271 |
TChar driveToTest; |
|
2272 |
driveToTest=(TUint)test.Getch(); |
|
2273 |
DriveNumber=((TUint)driveToTest) - '0'; |
|
2274 |
test(DriveNumber >= 1 && DriveNumber < di.iTotalSupportedDrives); |
|
2275 |
||
2276 |
return ETrue; |
|
2277 |
} |
|
2278 |
else |
|
2279 |
{ |
|
2280 |
//Auto Mode |
|
2281 |
//Lets find an MMC Drive to Test with.... |
|
2282 |
return SetupDrivesForPlatform(DriveNumber, RFsDNum); |
|
2283 |
} |
|
2284 |
} |
|
2285 |
||
2286 |
||
2287 |
GLDEF_C TInt E32Main() |
|
2288 |
{ |
|
2289 |
test.Title(); |
|
2290 |
test.Start(_L("Test the MultiMediaCard (MMC) media driver")); |
|
2291 |
||
2292 |
if (!ParseCommandLineArgs()) |
|
2293 |
{ |
|
2294 |
test.Printf(_L("MMC Drive Not Found - Skipping test\r\n")); |
|
2295 |
test.End(); |
|
2296 |
return(0); |
|
2297 |
} |
|
2298 |
||
2299 |
AllocateBuffers(); |
|
2300 |
||
2301 |
test.Printf(_L("Connect to local drive (%d)\n"),DriveNumber); |
|
2302 |
||
2303 |
ChangeFlag=EFalse; |
|
2304 |
test(TheMmcDrive.Connect(DriveNumber,ChangeFlag)==KErrNone); |
|
2305 |
||
2306 |
TTime startTime; |
|
2307 |
startTime.HomeTime(); |
|
2308 |
||
2309 |
IsReadOnly = TestDriveInfo(); |
|
2310 |
||
2311 |
// The following line causes t_mmcdrv to jump to the tests that check if the |
|
2312 |
// mmc driver will carry on reading when the door is opened, but abort with |
|
2313 |
// KErrGeneral when it is not. Enabling the goto here is useful because it |
|
2314 |
// allows the tester to skip the long read and write tests, which can take several |
|
2315 |
// minutes on a 16Mb card, and longer if tracing is enabled. It also stops the test |
|
2316 |
// from returning when !mediaChangeSupported and not getting to the door opening tests. |
|
2317 |
||
2318 |
#if TEST_DOOR_CLOSE |
|
2319 |
goto doorTest; |
|
2320 |
#endif |
|
2321 |
||
287 | 2322 |
if(ManualMode) |
2323 |
{ |
|
2324 |
// Only test in manual mode, as the rom needs special prep anyway (drive registration |
|
2325 |
// in variantmediadef.h and flashing of BB5 partition info structures using mmcloader) |
|
2326 |
// It is possible that as a result of the changes to variantmediadef.h the |
|
2327 |
// drive-number-to-letter mapping in the appropriate estart.txt may have to be adjusted |
|
2328 |
// as well |
|
2329 |
TestPartitionSwitching(); |
|
2330 |
} |
|
2331 |
||
0 | 2332 |
for(TInt pass = 0; pass < TMMCDrive::EMaxTestModes; pass++) |
2333 |
{ |
|
2334 |
TInt r = KErrNone; |
|
287 | 2335 |
|
0 | 2336 |
switch (pass) |
2337 |
{ |
|
287 | 2338 |
case TMMCDrive::ETestPartition : |
2339 |
r = TheMmcDrive.SetTestMode(TMMCDrive::ETestPartition); |
|
2340 |
break; |
|
2341 |
||
2342 |
case TMMCDrive::ETestWholeMedia : |
|
0 | 2343 |
// don't trash partition table in automated mode because... |
2344 |
// cards in test rigs have often got deliberately small partition sizes to testing (!) |
|
2345 |
if (!ManualMode) |
|
2346 |
continue; |
|
2347 |
r = TheMmcDrive.SetTestMode(TMMCDrive::ETestWholeMedia); |
|
2348 |
break; |
|
287 | 2349 |
|
2350 |
case TMMCDrive::ETestSharedMemory : |
|
2351 |
r = TheMmcDrive.SetTestMode(TMMCDrive::ETestSharedMemory); |
|
2352 |
AllocateSharedBuffers(EFalse,EFalse); |
|
2353 |
break; |
|
2354 |
||
2355 |
case TMMCDrive::ETestSharedMemoryCache : |
|
2356 |
r = TheMmcDrive.SetTestMode(TMMCDrive::ETestSharedMemoryCache); |
|
2357 |
AllocateSharedBuffers(EFalse, ETrue); |
|
2358 |
break; |
|
2359 |
||
2360 |
case TMMCDrive::ETestSharedMemoryFrag : |
|
2361 |
r = TheMmcDrive.SetTestMode(TMMCDrive::ETestSharedMemoryFrag); |
|
2362 |
AllocateSharedBuffers(ETrue, EFalse); |
|
2363 |
break; |
|
2364 |
||
2365 |
default: |
|
2366 |
r = TheMmcDrive.SetTestMode(TMMCDrive::ETestSharedMemoryFragCache); |
|
2367 |
AllocateSharedBuffers(ETrue, ETrue); |
|
2368 |
break; |
|
0 | 2369 |
} |
2370 |
||
2371 |
||
2372 |
if(r == KErrNone) |
|
2373 |
{ |
|
2374 |
TestRead(); |
|
2375 |
TestCapacity(); |
|
2376 |
||
2377 |
if(IsReadOnly == EFalse) |
|
2378 |
{ |
|
2379 |
TestMultipleBlockReads(); |
|
2380 |
TestSectorReadWrite(); |
|
2381 |
TestWrite(); |
|
2382 |
TestBoundaries(); |
|
2383 |
TestFormat(); |
|
2384 |
} |
|
2385 |
} |
|
2386 |
||
2387 |
if (pass > 1) |
|
2388 |
{ |
|
2389 |
// Shared memory Test Mode in use |
|
2390 |
DeAllocareSharedMemory(); |
|
2391 |
} |
|
2392 |
} |
|
2393 |
||
2394 |
if (mediaChangeSupported) |
|
2395 |
{ |
|
2396 |
// Remainder of tests involve media change |
|
2397 |
TestMediaChange(); |
|
2398 |
||
2399 |
#if TEST_DOOR_CLOSE |
|
2400 |
doorTest: |
|
2401 |
#endif |
|
2402 |
test.Next(_L("Launching 1.0Mb Read to interrupt with media change.\n")); |
|
2403 |
TestHugeReadWrite(ETrue, 512 * 1024); |
|
2404 |
||
2405 |
test.Next(_L("Launching 1.0Mb Write to interrupt with media change.\n")); |
|
2406 |
TestHugeReadWrite(EFalse, 512 * 1024); |
|
2407 |
} |
|
2408 |
||
2409 |
TTime endTime; |
|
2410 |
endTime.HomeTime(); |
|
2411 |
TTimeIntervalMicroSeconds elapsed=endTime.MicroSecondsFrom(startTime); |
|
2412 |
test.Printf(_L("\n\r (Elapsed time: %dmS)\r\n"),(elapsed.Int64()/1000)); |
|
2413 |
||
2414 |
test.Printf(_L("Disconnect from local drive (%d)"),DriveNumber); |
|
2415 |
TheMmcDrive.Disconnect(); |
|
2416 |
||
2417 |
DeAllocateBuffers(); |
|
2418 |
||
2419 |
// Format card with a File System i.e. FAT |
|
2420 |
// Such that it is re-usable by next test |
|
2421 |
Format(); |
|
2422 |
||
2423 |
test.End(); |
|
2424 |
||
2425 |
return(0); |
|
2426 |
} |
|
2427 |