|
1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Ensure the File System complies with the SD specification |
|
15 // |
|
16 // |
|
17 |
|
18 #include "sdfieldcheck.h" |
|
19 |
|
20 const TUint32 KSectorSize = 512; |
|
21 |
|
22 /* |
|
23 Class constructor |
|
24 |
|
25 @param None |
|
26 @return None |
|
27 */ |
|
28 CBaseTestSDFieldCheck::CBaseTestSDFieldCheck(CBaseTestSDServer& aOurServer) : iServer(aOurServer) |
|
29 { |
|
30 SetTestStepName(KTestStepFieldCheck); |
|
31 } |
|
32 |
|
33 /* |
|
34 Test Step Preamble |
|
35 - Load device driver for direct disk access |
|
36 |
|
37 @param None |
|
38 @return EPass if successful or EFail if not |
|
39 @see TVerdict |
|
40 */ |
|
41 TVerdict CBaseTestSDFieldCheck::doTestStepPreambleL() |
|
42 { |
|
43 SetTestStepResult(EFail); |
|
44 |
|
45 if (!InitDeviceDriver()) |
|
46 return TestStepResult(); |
|
47 |
|
48 SetTestStepResult(EPass); |
|
49 return TestStepResult(); |
|
50 } |
|
51 |
|
52 /* |
|
53 Test step |
|
54 |
|
55 @param None |
|
56 @return EPass if successful or EFail if not |
|
57 @see TVerdict |
|
58 */ |
|
59 TVerdict CBaseTestSDFieldCheck::doTestStepL() |
|
60 { |
|
61 if (TestStepResult() == EPass) |
|
62 { |
|
63 TInt checktype = 0; |
|
64 _LIT(KFieldCheckType, "FieldCheckType"); |
|
65 if (!GetIntFromConfig(ConfigSection(), KFieldCheckType, checktype)) |
|
66 { |
|
67 ERR_PRINTF1(_L("INI file read error")); |
|
68 SetTestStepResult(EFail); |
|
69 return TestStepResult(); |
|
70 } |
|
71 switch (checktype) |
|
72 { |
|
73 case 1: |
|
74 FS1(); |
|
75 break; |
|
76 case 2: |
|
77 if (iServer.iSharedData.iFsType < 0x0b) |
|
78 // FAT12/16 |
|
79 { |
|
80 FS2(); |
|
81 } |
|
82 else |
|
83 // FAT32 |
|
84 { |
|
85 FS2Fat32(); |
|
86 } |
|
87 break; |
|
88 case 3: |
|
89 if (iServer.iSharedData.iFsType < 0x0b) |
|
90 { |
|
91 FS3(); |
|
92 } |
|
93 else |
|
94 { |
|
95 INFO_PRINTF1(_L("Test step skipped: not a FAT12/16 partition")); |
|
96 } |
|
97 break; |
|
98 case 4: |
|
99 if (iServer.iSharedData.iFsType < 0x0b) |
|
100 { |
|
101 FS4(); |
|
102 } |
|
103 else |
|
104 { |
|
105 INFO_PRINTF1(_L("Test step skipped: not a FAT12/16 partition")); |
|
106 } |
|
107 break; |
|
108 case 5: |
|
109 if (iServer.iSharedData.iFsType < 0x0b) |
|
110 { |
|
111 FS5(); |
|
112 } |
|
113 else |
|
114 { |
|
115 INFO_PRINTF1(_L("Test step skipped: not a FAT12/16 partition")); |
|
116 } |
|
117 break; |
|
118 case 6: |
|
119 if (iServer.iSharedData.iFsType >= 0x0b) |
|
120 { |
|
121 FSInfo(); |
|
122 } |
|
123 else |
|
124 { |
|
125 INFO_PRINTF1(_L("Test step skipped: not a FAT32 partition")); |
|
126 } |
|
127 break; |
|
128 case 7: |
|
129 if (iServer.iSharedData.iFsType >= 0x0b) |
|
130 { |
|
131 FSBackupSectors(); |
|
132 } |
|
133 else |
|
134 { |
|
135 INFO_PRINTF1(_L("Test step skipped: not a FAT32 partition")); |
|
136 } |
|
137 break; |
|
138 default: |
|
139 ERR_PRINTF2(_L("Invalid check type value: %d"), checktype); |
|
140 SetTestStepResult(EFail); |
|
141 return TestStepResult(); |
|
142 } |
|
143 } |
|
144 else |
|
145 { |
|
146 INFO_PRINTF1(_L("Test preamble did not complete succesfully - Test Step skipped")); |
|
147 } |
|
148 return TestStepResult(); |
|
149 } |
|
150 |
|
151 |
|
152 /* |
|
153 Field Check of MBR and Partition Table |
|
154 |
|
155 @param None |
|
156 @return None |
|
157 */ |
|
158 void CBaseTestSDFieldCheck::FS1() |
|
159 { |
|
160 INFO_PRINTF1(_L("FS1 - Field Check of MBR and Partition Table")); |
|
161 TBuf8<KSectorSize> sector; |
|
162 |
|
163 if (ReadSector(0, sector) != KErrNone) |
|
164 { |
|
165 SetTestStepResult(EFail); |
|
166 return; |
|
167 } |
|
168 |
|
169 // See section 3.1.3. Arrangement of the Partition Area (FAT12/16) |
|
170 // and section 4.1.3. Arrangement of the Partition Area (FAT32) |
|
171 // of the SD Specification for details |
|
172 |
|
173 // Also see SD Test Specification for File Systems |
|
174 |
|
175 TInt relativeSector = SYMBIAN_TEST_LE4(sector[446 + 8], sector[446 + 9], sector[446 + 10], sector[446 + 11]); |
|
176 |
|
177 // Save values for later use |
|
178 iServer.iSharedData.iTotalSector = SYMBIAN_TEST_LE4(sector[446 + 12], sector[446 + 13], sector[446 + 14], sector[446 + 15]); |
|
179 iServer.iSharedData.iPartitionBootSector = relativeSector; |
|
180 |
|
181 TInt noHeads = 0; |
|
182 if (iCardSizeInSectors <= 32768) { noHeads = 2; } // <=16MB |
|
183 else if (iCardSizeInSectors <= 65536) { noHeads = 4; } // <=32MB |
|
184 else if (iCardSizeInSectors <= 262144) { noHeads = 8; } // <=128MB |
|
185 else if (iCardSizeInSectors <= 1032192) { noHeads = 16; } // <=504MB |
|
186 else if (iCardSizeInSectors <= 2064384) { noHeads = 32; } // <=1008MB |
|
187 else if (iCardSizeInSectors <= 4128768) { noHeads = 64; } // <=2016MB |
|
188 else if (iCardSizeInSectors <= 8257536) { noHeads = 128; } // <=4032GB |
|
189 else { noHeads = 255; } |
|
190 |
|
191 TInt sectorsPerTrack = 0; |
|
192 if (iCardSizeInSectors <= 4096) { sectorsPerTrack = 16; } // <=2MB |
|
193 else if (iCardSizeInSectors <= 524288) { sectorsPerTrack = 32; } // <=256MB |
|
194 else { sectorsPerTrack = 63; } |
|
195 |
|
196 TInt expected; |
|
197 |
|
198 // FS1-1 |
|
199 INFO_PRINTF2(_L("FS 1-1 Boot Indicator: %02xh"), sector[446]); |
|
200 SYMBIAN_TEST_TESTNOPANIC(sector[446] == 0x00 || sector[446] == 0x80); |
|
201 |
|
202 // FS1-2 |
|
203 if (relativeSector <= 16450560) // FAT12/16 |
|
204 { |
|
205 expected = (relativeSector % (noHeads * sectorsPerTrack)) / sectorsPerTrack; |
|
206 } |
|
207 else |
|
208 { |
|
209 expected = 0xfe; |
|
210 } |
|
211 INFO_PRINTF3(_L("FS 1-2 Starting Head: %02xh (expected: %02xh)"), sector[446 + 1], expected); |
|
212 SYMBIAN_TEST_TESTNOPANIC(sector[446 + 1] == expected); |
|
213 |
|
214 // FS1-3 |
|
215 if (relativeSector <= 16450560) // FAT12/16 |
|
216 { |
|
217 expected = relativeSector % sectorsPerTrack + 1; |
|
218 } |
|
219 else |
|
220 { |
|
221 expected = 0x3f; |
|
222 } |
|
223 INFO_PRINTF3(_L("FS 1-3 Starting Sector: %02xh (expected %02xh)"), sector[446 + 2] & 0x3f, expected); |
|
224 SYMBIAN_TEST_TESTNOPANIC((sector[446 + 2] & 0x3f) == expected); |
|
225 |
|
226 // FS1-4 |
|
227 if (relativeSector <= 16450560) // FAT12/16 |
|
228 { |
|
229 expected = relativeSector / (noHeads * sectorsPerTrack); |
|
230 } |
|
231 else |
|
232 { |
|
233 expected = 0x3ff; |
|
234 } |
|
235 INFO_PRINTF3(_L("FS 1-4 Starting Cylinder: %03xh (expected %03xh) "), ((sector[446 + 2] & 0xc0) << 2) + sector[446 + 3], expected); |
|
236 SYMBIAN_TEST_TESTNOPANIC(((sector[446 + 2] & 0xc0) << 2) + sector[446 + 3] == expected); |
|
237 |
|
238 // FS1-5 |
|
239 INFO_PRINTF2(_L("FS 1-5 System ID: %02xh"), sector[446 + 4]); |
|
240 if (iServer.iSharedData.iTotalSector < 32680) |
|
241 { |
|
242 SYMBIAN_TEST_TESTNOPANIC(sector[446 + 4] == 0x01); |
|
243 } |
|
244 else if (iServer.iSharedData.iTotalSector < 65536) |
|
245 { |
|
246 SYMBIAN_TEST_TESTNOPANIC(sector[446 + 4] == 0x04); |
|
247 } |
|
248 else if (iServer.iSharedData.iTotalSector <= 4194304) // FAT16 (<=2048MB) |
|
249 { |
|
250 SYMBIAN_TEST_TESTNOPANIC(sector[446 + 4] == 0x06); |
|
251 } |
|
252 else if (iServer.iSharedData.iTotalSector + relativeSector <= 16450560) // FAT32 and ending location of partition doesn't exceed 8032.5MB |
|
253 { |
|
254 SYMBIAN_TEST_TESTNOPANIC(sector[446 + 4] == 0x0b); |
|
255 } |
|
256 else |
|
257 { |
|
258 SYMBIAN_TEST_TESTNOPANIC(sector[446 + 4] == 0x0c); |
|
259 } |
|
260 iServer.iSharedData.iFsType = sector[446 + 4]; |
|
261 |
|
262 // FS1-6 |
|
263 if (iServer.iSharedData.iTotalSector + relativeSector <= 16450560) // FAT12/16 |
|
264 { |
|
265 expected = ((relativeSector + iServer.iSharedData.iTotalSector - 1) % (noHeads * sectorsPerTrack)) / sectorsPerTrack; |
|
266 } |
|
267 else |
|
268 { |
|
269 expected = 0xfe; |
|
270 } |
|
271 INFO_PRINTF3(_L("FS 1-6 Ending Head: %02xh (expected: %02xh)"), sector[446 + 5], expected); |
|
272 SYMBIAN_TEST_TESTNOPANIC(sector[446 + 5] == expected); |
|
273 |
|
274 // FS1-7 |
|
275 if (iServer.iSharedData.iTotalSector + relativeSector <= 16450560) // FAT12/16 |
|
276 { |
|
277 expected = (relativeSector + iServer.iSharedData.iTotalSector - 1) % sectorsPerTrack + 1; |
|
278 } |
|
279 else |
|
280 { |
|
281 expected = 0x3f; |
|
282 } |
|
283 INFO_PRINTF3(_L("FS 1-7 Ending Sector: %02xh (expected %02xh)"), sector[446 + 6] & 0x3f, expected); |
|
284 SYMBIAN_TEST_TESTNOPANIC((sector[446 + 6] & 0x3f) == expected); |
|
285 |
|
286 // FS1-8 |
|
287 if (iServer.iSharedData.iTotalSector + relativeSector <= 16450560) // FAT12/16 |
|
288 { |
|
289 expected = (relativeSector + iServer.iSharedData.iTotalSector - 1) / (noHeads * sectorsPerTrack); |
|
290 } |
|
291 else |
|
292 { |
|
293 expected = 0x3ff; |
|
294 } |
|
295 INFO_PRINTF3(_L("FS 1-8 Ending Cylinder: %03xh (expected %03xh)"), ((sector[446 + 6] & 0xc0) << 2) + sector[446 + 7], expected); |
|
296 SYMBIAN_TEST_TESTNOPANIC(((sector[446 + 6] & 0xc0) << 2) + sector[446 + 7] == expected); |
|
297 |
|
298 // FS1-9 |
|
299 INFO_PRINTF2(_L("FS 1-9 Relative Sector: %08xh"), relativeSector); |
|
300 SYMBIAN_TEST_TESTNOPANIC(relativeSector < iCardSizeInSectors); |
|
301 |
|
302 // FS1-10 |
|
303 INFO_PRINTF2(_L("FS 1-10 Total Sector: %08xh"), iServer.iSharedData.iTotalSector); |
|
304 SYMBIAN_TEST_TESTNOPANIC(iServer.iSharedData.iTotalSector <= iCardSizeInSectors); |
|
305 |
|
306 // FS1-11 |
|
307 INFO_PRINTF1(_L("FS 1-11 Partition Table 2")); |
|
308 for (TInt i = 0; i < 16; i++) |
|
309 { |
|
310 SYMBIAN_TEST_TESTNOPANIC(sector[462 + i] == 0); |
|
311 } |
|
312 |
|
313 // FS1-12 |
|
314 INFO_PRINTF1(_L("FS 1-12 Partition Table 3")); |
|
315 for (TInt i = 0; i < 16; i++) |
|
316 { |
|
317 SYMBIAN_TEST_TESTNOPANIC(sector[478 + i] == 0); |
|
318 } |
|
319 |
|
320 // FS1-13 |
|
321 INFO_PRINTF1(_L("FS 1-13 Partition Table 4")); |
|
322 for (TInt i = 0; i < 16; i++) |
|
323 { |
|
324 SYMBIAN_TEST_TESTNOPANIC(sector[494 + i] == 0); |
|
325 } |
|
326 |
|
327 // FS1-15 |
|
328 INFO_PRINTF3(_L("FS 1-14 Signature Word %02xh %02xh"), sector[510], sector[511]); |
|
329 SYMBIAN_TEST_TESTNOPANIC(sector[510] == 0x55); |
|
330 SYMBIAN_TEST_TESTNOPANIC(sector[511] == 0xaa); |
|
331 |
|
332 for (TInt i = 0; i < KSectorSize / 16; i++) |
|
333 { |
|
334 TBuf<60> buffer; |
|
335 buffer.Format(_L("%08x:"), i * 16); |
|
336 for (TInt j = 0; j < 16; j++) |
|
337 { |
|
338 buffer.AppendFormat(_L(" %02x"), sector[i * 16 + j]); |
|
339 } |
|
340 INFO_PRINTF2(_L("%S"), &buffer); |
|
341 } |
|
342 } |
|
343 |
|
344 /* |
|
345 Field Check of Partition Boot Sector (FAT12/16) |
|
346 |
|
347 @param None |
|
348 @return None |
|
349 */ |
|
350 void CBaseTestSDFieldCheck::FS2() |
|
351 { |
|
352 INFO_PRINTF1(_L("FS2 - Field Check of Partition Boot Sector")); |
|
353 // See section 3.2.1. Partition Boot Sector (FAT12/16) |
|
354 // of the SD Specification for details |
|
355 |
|
356 // Also see SD Test Specification for File Systems |
|
357 TBuf8<KSectorSize> sector; |
|
358 |
|
359 if (ReadSector(iServer.iSharedData.iPartitionBootSector, sector) != KErrNone) |
|
360 { |
|
361 SetTestStepResult(EFail); |
|
362 return; |
|
363 } |
|
364 |
|
365 TInt sectorsPerCluster = 0; |
|
366 if (iCardSizeInSectors <= 16384) { sectorsPerCluster = 16; } // <=8MB |
|
367 else if (iCardSizeInSectors <= 2097152) { sectorsPerCluster = 32; } // <=1024MB |
|
368 else { sectorsPerCluster = 64; } |
|
369 |
|
370 iServer.iSharedData.iNumberOfClusters = (iServer.iSharedData.iTotalSector - (1 + SYMBIAN_TEST_LE2(sector[22], sector[23]) * 2 + (KSectorSize * 32 / KSectorSize))) / sectorsPerCluster; |
|
371 |
|
372 if (sector[38] != 0x29) // FDC |
|
373 { |
|
374 // FS2-1 |
|
375 INFO_PRINTF4(_L("FS 2-1 Jump Command: %02xh %02xh %02xh"), sector[0], sector[1], sector[2]); |
|
376 SYMBIAN_TEST_TESTNOPANIC((sector[0] == 0xe9) || |
|
377 ((sector[0] == 0xeb) && (sector[2] == 0x90))); |
|
378 |
|
379 // FS2-2 |
|
380 INFO_PRINTF2(_L("FS 2-2 Sector Size: %04xh"), SYMBIAN_TEST_LE2(sector[11], sector[12])); |
|
381 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[11], sector[12]) == KSectorSize); |
|
382 |
|
383 // FS2-3 |
|
384 INFO_PRINTF3(_L("FS 2-3 Sectors per Cluster: %02xh (expected %02xh)"), sector[13], sectorsPerCluster); |
|
385 SYMBIAN_TEST_TESTNOPANIC(sector[13] == sectorsPerCluster); |
|
386 |
|
387 // FS2-4 |
|
388 INFO_PRINTF2(_L("FS 2-4 Reserved Sector Count: %04xh"), SYMBIAN_TEST_LE2(sector[14], sector[15])); |
|
389 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[14], sector[15]) == 1); |
|
390 iServer.iSharedData.iReservedSectorCount = SYMBIAN_TEST_LE2(sector[14], sector[15]); |
|
391 |
|
392 // FS2-5 |
|
393 INFO_PRINTF2(_L("FS 2-5 Number of FATs: %02xh"), sector[16]); |
|
394 SYMBIAN_TEST_TESTNOPANIC(sector[16] == 2); |
|
395 |
|
396 // FS2-6 |
|
397 INFO_PRINTF2(_L("FS 2-6 Number of Root Directory entries: %04xh"), SYMBIAN_TEST_LE2(sector[17], sector[18])); |
|
398 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[17], sector[18]) == KSectorSize); |
|
399 |
|
400 // FS2-7 |
|
401 INFO_PRINTF2(_L("FS 2-7 Total Sectors: %04xh"), SYMBIAN_TEST_LE2(sector[19], sector[20])); |
|
402 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[19], sector[20]) <= 65535); |
|
403 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[19], sector[20]) == iServer.iSharedData.iTotalSector); |
|
404 |
|
405 // FS2-8 |
|
406 INFO_PRINTF2(_L("FS 2-8 Medium Identifier: %02xh"), sector[21]); |
|
407 SYMBIAN_TEST_TESTNOPANIC(sector[21] == 0xf8); |
|
408 |
|
409 // FS2-9 |
|
410 if (iServer.iSharedData.iNumberOfClusters < 4085) |
|
411 { |
|
412 iServer.iSharedData.iSectorsPerFat = 1 + (1 + ((iServer.iSharedData.iNumberOfClusters + 2) * 3 / 2)) / KSectorSize; |
|
413 } |
|
414 else |
|
415 { |
|
416 iServer.iSharedData.iSectorsPerFat = 1 + ((iServer.iSharedData.iNumberOfClusters + 2) * 2) / KSectorSize; |
|
417 } |
|
418 INFO_PRINTF3(_L("FS 2-9 Sector per FAT: %04xh (expected %04xh)"), SYMBIAN_TEST_LE2(sector[22], sector[23]), iServer.iSharedData.iSectorsPerFat); |
|
419 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[22], sector[23]) == iServer.iSharedData.iSectorsPerFat); |
|
420 |
|
421 // FS2-10 |
|
422 INFO_PRINTF2(_L("FS 2-10 Sectors per Track: %04xh"), SYMBIAN_TEST_LE2(sector[24], sector[25])); |
|
423 if (iCardSizeInSectors <= 4096) |
|
424 { |
|
425 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[24], sector[25]) == 16); // <=2MB |
|
426 } |
|
427 else if (iCardSizeInSectors <= 524288) |
|
428 { |
|
429 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[24], sector[25]) == 32); // <=256MB |
|
430 } |
|
431 else |
|
432 { |
|
433 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[24], sector[25]) == 63); |
|
434 } |
|
435 |
|
436 // FS2-11 |
|
437 INFO_PRINTF2(_L("FS 2-11 Number of Sides: %04xh"), SYMBIAN_TEST_LE2(sector[26], sector[27])); |
|
438 if (iCardSizeInSectors <= 32768) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 2); } // <=16MB |
|
439 else if (iCardSizeInSectors <= 65536) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 4); } // <=32MB |
|
440 else if (iCardSizeInSectors <= 262144) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 8); } // <=128MB |
|
441 else if (iCardSizeInSectors <= 1032192) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 16); } // <=504MB |
|
442 else if (iCardSizeInSectors <= 2064384) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 32); } // <=1008MB |
|
443 else if (iCardSizeInSectors <= 4128768) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 64); } // <=2016MB |
|
444 else { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 128); } |
|
445 |
|
446 // FS2-12 |
|
447 INFO_PRINTF3(_L("FS 2-12 Reserved for future standardisation: %02x %02x"), sector[28], sector[29]); |
|
448 SYMBIAN_TEST_TESTNOPANIC(sector[28] == 0 && sector[29] == 0); |
|
449 |
|
450 // FS2-13 |
|
451 INFO_PRINTF3(_L("FS 2-12 Signature Word: %02xh %02xh"), sector[510], sector[511]); |
|
452 SYMBIAN_TEST_TESTNOPANIC(sector[510] == 0x55 && sector[511] == 0xaa); |
|
453 } |
|
454 else // Extended FDC |
|
455 { |
|
456 // FS2-14 |
|
457 INFO_PRINTF4(_L("FS 2-14 Jump Command: %02xh %02xh %02xh"), sector[0], sector[1], sector[2]); |
|
458 SYMBIAN_TEST_TESTNOPANIC((sector[0] == 0xe9) || |
|
459 ((sector[0] == 0xeb) && (sector[2] == 0x90))); |
|
460 |
|
461 // FS2-15 |
|
462 INFO_PRINTF2(_L("FS 2-15 Sector Size: %04xh"), SYMBIAN_TEST_LE2(sector[11], sector[12])); |
|
463 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[11], sector[12]) == KSectorSize); |
|
464 |
|
465 // FS2-16 |
|
466 INFO_PRINTF3(_L("FS 2-16 Sectors per Cluster: %02xh (expected %02xh)"), sector[13], sectorsPerCluster); |
|
467 SYMBIAN_TEST_TESTNOPANIC(sector[13] == sectorsPerCluster); |
|
468 |
|
469 // FS2-17 |
|
470 INFO_PRINTF2(_L("FS 2-17 Reserved Sector Count: %04xh"), SYMBIAN_TEST_LE2(sector[14], sector[15])); |
|
471 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[14], sector[15]) == 1); |
|
472 |
|
473 // FS2-18 |
|
474 INFO_PRINTF2(_L("FS 2-18 Number of FATs: %02xh"), sector[16]); |
|
475 SYMBIAN_TEST_TESTNOPANIC(sector[16] == 2); |
|
476 |
|
477 // FS2-19 |
|
478 INFO_PRINTF2(_L("FS 2-19 Number of Root Directory entries: %04xh"), SYMBIAN_TEST_LE2(sector[17], sector[18])); |
|
479 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[17], sector[18]) == KSectorSize); |
|
480 |
|
481 // FS2-20 |
|
482 INFO_PRINTF2(_L("FS 2-20 Total Sectors: %04xh"), SYMBIAN_TEST_LE2(sector[19], sector[20])); |
|
483 if (iServer.iSharedData.iTotalSector <= 65535) |
|
484 { |
|
485 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[19], sector[20]) == iServer.iSharedData.iTotalSector); |
|
486 } |
|
487 else |
|
488 { |
|
489 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[19], sector[20]) == 0); |
|
490 } |
|
491 |
|
492 // FS2-21 |
|
493 INFO_PRINTF2(_L("FS 2-21 Medium Identifier: %02xh"), sector[21]); |
|
494 SYMBIAN_TEST_TESTNOPANIC(sector[21] == 0xf8); |
|
495 |
|
496 // FS2-22 |
|
497 if (iServer.iSharedData.iNumberOfClusters < 4085) |
|
498 { |
|
499 iServer.iSharedData.iSectorsPerFat = 1 + (1 + ((iServer.iSharedData.iNumberOfClusters + 2) * 3 / 2)) / KSectorSize; |
|
500 } |
|
501 else |
|
502 { |
|
503 iServer.iSharedData.iSectorsPerFat = 1 + ((iServer.iSharedData.iNumberOfClusters + 2) * 2) / KSectorSize; |
|
504 } |
|
505 INFO_PRINTF3(_L("FS 2-22 Sector per FAT: %04xh (expected %04xh)"), SYMBIAN_TEST_LE2(sector[22], sector[23]), iServer.iSharedData.iSectorsPerFat); |
|
506 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[22], sector[23]) == iServer.iSharedData.iSectorsPerFat); |
|
507 |
|
508 // FS2-23 |
|
509 INFO_PRINTF2(_L("FS 2-23 Sectors per Track: %04xh"), SYMBIAN_TEST_LE2(sector[24], sector[25])); |
|
510 if (iCardSizeInSectors <= 4096) |
|
511 { |
|
512 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[24], sector[25]) == 16); // <=2MB |
|
513 } |
|
514 else if (iCardSizeInSectors <= 524288) |
|
515 { |
|
516 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[24], sector[25]) == 32); // <=256MB |
|
517 } |
|
518 else |
|
519 { |
|
520 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[24], sector[25]) == 63); |
|
521 } |
|
522 |
|
523 // FS2-24 |
|
524 INFO_PRINTF2(_L("FS 2-24 Number of Sides: %04xh"), SYMBIAN_TEST_LE2(sector[26], sector[27])); |
|
525 if (iCardSizeInSectors <= 32768) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 2); } // <=16MB |
|
526 else if (iCardSizeInSectors <= 65536) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 4); } // <=32MB |
|
527 else if (iCardSizeInSectors <= 262144) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 8); } // <=128MB |
|
528 else if (iCardSizeInSectors <= 1032192) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 16); } // <=504MB |
|
529 else if (iCardSizeInSectors <= 2064384) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 32); } // <=1008MB |
|
530 else if (iCardSizeInSectors <= 4128768) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 64); } // <=2016MB |
|
531 else { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 128); } |
|
532 |
|
533 // FS2-25 |
|
534 INFO_PRINTF2(_L("FS 2-25 Number of Hidden Sectors %08xh"), SYMBIAN_TEST_LE4(sector[28], sector[29], sector[30], sector[31])); |
|
535 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE4(sector[28], sector[29], sector[30], sector[31]) == iServer.iSharedData.iPartitionBootSector); |
|
536 |
|
537 // FS2-26 |
|
538 INFO_PRINTF2(_L("FS 2-26 Total Sectors %08xh"), SYMBIAN_TEST_LE4(sector[32], sector[33], sector[34], sector[35])); |
|
539 if (iServer.iSharedData.iTotalSector <= 65535) |
|
540 { |
|
541 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE4(sector[32], sector[33], sector[34], sector[35]) == 0); |
|
542 } |
|
543 else |
|
544 { |
|
545 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE4(sector[32], sector[33], sector[34], sector[35]) == iServer.iSharedData.iTotalSector); |
|
546 } |
|
547 |
|
548 // FS2-27 |
|
549 INFO_PRINTF2(_L("FS 2-27 Physical Disk Number: %02xh"), sector[36]); |
|
550 SYMBIAN_TEST_TESTNOPANIC(sector[36] == 0x80); |
|
551 |
|
552 // FS2-28 |
|
553 INFO_PRINTF2(_L("FS 2-28 Reserved: %02xh"), sector[37]); |
|
554 SYMBIAN_TEST_TESTNOPANIC(sector[37] == 0); |
|
555 |
|
556 // FS2-29 |
|
557 INFO_PRINTF9(_L("FS 2-29 File System Type: '%c%c%c%c%c%c%c%c'"), sector[54], sector[55], sector[56], sector[57], sector[58], sector[59], sector[60], sector[61]); |
|
558 SYMBIAN_TEST_TESTNOPANIC((sector[54] == 'F') && (sector[55] == 'A') && (sector[56] == 'T') && (sector[57] == '1') && (sector[59] == ' ') && (sector[60] == ' ') && (sector[61] == ' ')); |
|
559 if (iServer.iSharedData.iNumberOfClusters < 4085) |
|
560 { |
|
561 SYMBIAN_TEST_TESTNOPANIC(sector[58] == '2'); |
|
562 } |
|
563 else |
|
564 { |
|
565 SYMBIAN_TEST_TESTNOPANIC(sector[58] == '6'); |
|
566 } |
|
567 |
|
568 // FS2-30 |
|
569 INFO_PRINTF3(_L("FS 2-30 Signature Word: %02xh %02xh"), sector[510], sector[511]); |
|
570 SYMBIAN_TEST_TESTNOPANIC(sector[510] == 0x55 && sector[511] == 0xaa); |
|
571 } |
|
572 |
|
573 for (TInt i = 0; i < KSectorSize / 16; i++) |
|
574 { |
|
575 TBuf<60> buffer; |
|
576 buffer.Format(_L("%08x:"), i * 16 + iServer.iSharedData.iPartitionBootSector); |
|
577 for (TInt j = 0; j < 16; j++) |
|
578 { |
|
579 buffer.AppendFormat(_L(" %02x"), sector[i * 16 + j]); |
|
580 } |
|
581 INFO_PRINTF2(_L("%S"), &buffer); |
|
582 } |
|
583 } |
|
584 |
|
585 /* |
|
586 Field Check of Partition Boot Sector (FAT32) |
|
587 |
|
588 @param None |
|
589 @return None |
|
590 */ |
|
591 void CBaseTestSDFieldCheck::FS2Fat32() |
|
592 { |
|
593 INFO_PRINTF1(_L("FS2 - Field Check of Partition Boot Sector")); |
|
594 // See section 4.2.1. Partition Boot Sector (FAT32) |
|
595 // of the SD Specification for details |
|
596 |
|
597 TBuf8<KSectorSize> sector; |
|
598 |
|
599 if (ReadSector(iServer.iSharedData.iPartitionBootSector, sector) != KErrNone) |
|
600 { |
|
601 SetTestStepResult(EFail); |
|
602 return; |
|
603 } |
|
604 |
|
605 TInt sectorsPerCluster = 0; |
|
606 if (iCardSizeInSectors <= 16384) { sectorsPerCluster = 16; } // <=8MB |
|
607 else if (iCardSizeInSectors <= 2097152) { sectorsPerCluster = 32; } // <=1024MB |
|
608 else { sectorsPerCluster = 64; } |
|
609 |
|
610 iServer.iSharedData.iNumberOfClusters = (iServer.iSharedData.iTotalSector - (1 + SYMBIAN_TEST_LE2(sector[22], sector[23]) * 2 + (KSectorSize * 32 / KSectorSize))) / sectorsPerCluster; |
|
611 |
|
612 // Calculations (SD Spec, Annex c.2.4) |
|
613 TUint32 KBoundaryUnit = 8192; |
|
614 TUint32 KSectorsPerCluster = 64; |
|
615 TUint32 KFatBits = 32; |
|
616 TUint32 KSectorsInMBR = KBoundaryUnit; |
|
617 |
|
618 // Caclculate number of sectors per FAT according to section C.2.4 |
|
619 TUint32 sf = SYMBIAN_TEST_CEIL(KFatBits * iCardSizeInSectors / KSectorsPerCluster, KSectorSize * 8); |
|
620 TUint32 sfp; |
|
621 TUint32 rsc; |
|
622 TBool cond13 = ETrue; |
|
623 do |
|
624 { |
|
625 TUint32 n = 0; |
|
626 while (KBoundaryUnit * n < 2 * sf + 9) |
|
627 { |
|
628 n++; |
|
629 } |
|
630 rsc = KBoundaryUnit * n - 2 * sf; |
|
631 TInt ssa = rsc + 2 * sf; |
|
632 do { |
|
633 TInt max = SYMBIAN_TEST_IP(iCardSizeInSectors - KSectorsInMBR - ssa, KSectorsPerCluster) + 1; |
|
634 sfp = SYMBIAN_TEST_CEIL((2 + (max - 1)) * KFatBits, KSectorSize * 8); |
|
635 if (sfp > sf) |
|
636 { |
|
637 ssa += KBoundaryUnit; |
|
638 rsc += KBoundaryUnit; |
|
639 } |
|
640 } while (sfp > sf); |
|
641 if (sf != sfp) |
|
642 { |
|
643 sf--; |
|
644 cond13 = EFalse; |
|
645 } |
|
646 else |
|
647 { |
|
648 cond13 = ETrue; |
|
649 } |
|
650 } while (!cond13); |
|
651 |
|
652 // FS2-31 |
|
653 INFO_PRINTF4(_L("FS 2-31 Jump Command: %02xh %02xh %02xh"), sector[0], sector[1], sector[2]); |
|
654 SYMBIAN_TEST_TESTNOPANIC((sector[0] == 0xe9) || |
|
655 ((sector[0] == 0xeb) && (sector[2] == 0x90))); |
|
656 |
|
657 // FS2-32 |
|
658 INFO_PRINTF3(_L("FS 2-32 Sector Size: %04xh (expected %04xh)"), SYMBIAN_TEST_LE2(sector[11], sector[12]), KSectorSize); |
|
659 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[11], sector[12]) == KSectorSize); |
|
660 |
|
661 // FS2-33 |
|
662 INFO_PRINTF3(_L("FS 2-33 Sectors per Cluster: %02xh (expected %02xh)"), sector[13], KSectorsPerCluster); |
|
663 SYMBIAN_TEST_TESTNOPANIC(sector[13] == KSectorsPerCluster); |
|
664 |
|
665 // FS2-34 |
|
666 INFO_PRINTF3(_L("FS 2-34 Reserved Sector Count: %04xh (expected %04xh)"), SYMBIAN_TEST_LE2(sector[14], sector[15]), rsc); |
|
667 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[14], sector[15]) == rsc); |
|
668 |
|
669 // FS2-35 |
|
670 INFO_PRINTF2(_L("FS 2-35 Number of FATs: %02xh"), sector[16]); |
|
671 SYMBIAN_TEST_TESTNOPANIC(sector[16] == 2); |
|
672 |
|
673 // FS2-36 |
|
674 INFO_PRINTF2(_L("FS 2-36 Number of Root Directory entries: %04xh"), SYMBIAN_TEST_LE2(sector[17], sector[18])); |
|
675 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[17], sector[18]) == 0); // FAT32 No max root dir entries |
|
676 |
|
677 // FS2-37 |
|
678 INFO_PRINTF2(_L("FS 2-37 Total Sectors: %04xh"), SYMBIAN_TEST_LE2(sector[19], sector[20])); |
|
679 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[19], sector[20]) == 0); |
|
680 |
|
681 // FS2-38 |
|
682 INFO_PRINTF2(_L("FS 2-38 Medium Identifier: %02xh"), sector[21]); |
|
683 SYMBIAN_TEST_TESTNOPANIC(sector[21] == 0xf8); |
|
684 |
|
685 // FS2-39 |
|
686 INFO_PRINTF2(_L("FS 2-39 Sector per FAT: %04xh"), SYMBIAN_TEST_LE2(sector[22], sector[23])); |
|
687 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[22], sector[23]) == 0); // This field not used in the FAT32 spec |
|
688 |
|
689 // FS2-40 |
|
690 INFO_PRINTF2(_L("FS 2-40 Sectors per Track: %04xh"), SYMBIAN_TEST_LE2(sector[24], sector[25])); |
|
691 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[24], sector[25]) == 63); |
|
692 |
|
693 // FS2-41 |
|
694 INFO_PRINTF2(_L("FS 2-41 Number of Sides: %04xh"), SYMBIAN_TEST_LE2(sector[26], sector[27])); |
|
695 if (iCardSizeInSectors <= 8257536) { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 128); } // <=4032MB |
|
696 else { SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[26], sector[27]) == 255); } |
|
697 |
|
698 // FS2-42 |
|
699 INFO_PRINTF2(_L("FS 2-42 Number of Hidden Sectors %08xh"), SYMBIAN_TEST_LE4(sector[28], sector[29], sector[30], sector[31])); |
|
700 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE4(sector[28], sector[29], sector[30], sector[31]) == iServer.iSharedData.iPartitionBootSector); |
|
701 |
|
702 // FS2-43 |
|
703 INFO_PRINTF2(_L("FS 2-43 Total Sectors %08xh"), SYMBIAN_TEST_LE4(sector[32], sector[33], sector[34], sector[35])); |
|
704 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE4(sector[32], sector[33], sector[34], sector[35]) == iServer.iSharedData.iTotalSector); |
|
705 |
|
706 // FS2-44 |
|
707 INFO_PRINTF3(_L("FS 2-44 Sectors per FAT for FAT32 %08xh (expected: %08xh)"), SYMBIAN_TEST_LE4(sector[36], sector[37], sector[38], sector[39]), sf); |
|
708 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE4(sector[36], sector[37], sector[38], sector[39]) == sf); |
|
709 |
|
710 // FS2-45 |
|
711 INFO_PRINTF2(_L("FS 2-45 Extension Flag %04xh"), SYMBIAN_TEST_LE2(sector[40], sector[41])); |
|
712 |
|
713 // FS2-46 |
|
714 INFO_PRINTF2(_L("FS 2-46 FS Version %04xh"), SYMBIAN_TEST_LE2(sector[42], sector[43])); |
|
715 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[42], sector[43]) == 0); |
|
716 |
|
717 // FS2-47 |
|
718 INFO_PRINTF2(_L("FS 2-47 Root Cluster %08xh"), SYMBIAN_TEST_LE4(sector[44], sector[45], sector[46], sector[47])); |
|
719 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE4(sector[44], sector[45], sector[46], sector[47]) >= 2); |
|
720 |
|
721 // FS2-48 |
|
722 INFO_PRINTF2(_L("FS 2-48 FS Info %04xh"), SYMBIAN_TEST_LE2(sector[48], sector[49])); |
|
723 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[48], sector[49]) == 1); |
|
724 |
|
725 // FS2-49 |
|
726 INFO_PRINTF2(_L("FS 2-49 Backup Boot Sector %04xh"), SYMBIAN_TEST_LE2(sector[50], sector[51])); |
|
727 SYMBIAN_TEST_TESTNOPANIC(SYMBIAN_TEST_LE2(sector[50], sector[51]) == 6); |
|
728 |
|
729 // FS2-50 |
|
730 INFO_PRINTF2(_L("FS 2-50 Physical Disk Number: %02xh"), sector[64]); |
|
731 SYMBIAN_TEST_TESTNOPANIC(sector[64] == 0x80); |
|
732 |
|
733 // FS2-51 |
|
734 INFO_PRINTF2(_L("FS 2-51 Extended Boot Record Signature: %02xh"), sector[66]); |
|
735 SYMBIAN_TEST_TESTNOPANIC(sector[66] == 0x29); |
|
736 |
|
737 // FS2-52 |
|
738 INFO_PRINTF9(_L("FS 2-52 File System Type: '%c%c%c%c%c%c%c%c'"), sector[82], sector[83], sector[84], sector[85], sector[86], sector[87], sector[88], sector[89]); |
|
739 SYMBIAN_TEST_TESTNOPANIC((sector[82] == 'F') && (sector[83] == 'A') && (sector[84] == 'T') && (sector[85] == '3') && (sector[86] == '2')&& (sector[87] == ' ') && (sector[88] == ' ') && (sector[89] == ' ')); |
|
740 |
|
741 // FS2-53 |
|
742 INFO_PRINTF3(_L("FS 2-30 Signature Word: %02xh %02xh"), sector[510], sector[511]); |
|
743 SYMBIAN_TEST_TESTNOPANIC(sector[510] == 0x55 && sector[511] == 0xaa); |
|
744 |
|
745 for (TInt i = 0; i < KSectorSize / 16; i++) |
|
746 { |
|
747 TBuf<60> buffer; |
|
748 buffer.Format(_L("%08x:"), i * 16 + iServer.iSharedData.iPartitionBootSector); |
|
749 for (TInt j = 0; j < 16; j++) |
|
750 { |
|
751 buffer.AppendFormat(_L(" %02x"), sector[i * 16 + j]); |
|
752 } |
|
753 INFO_PRINTF2(_L("%S"), &buffer); |
|
754 } |
|
755 } |
|
756 |
|
757 /* |
|
758 Field Check of FAT32 FS Info Sector |
|
759 |
|
760 @param None |
|
761 @return None |
|
762 */ |
|
763 void CBaseTestSDFieldCheck::FSInfo() |
|
764 { |
|
765 // See section 4.2.2. FS Info Sector |
|
766 // of the SD Specification for details |
|
767 |
|
768 INFO_PRINTF1(_L("FSx - Field Check of FAT32's FS Info Sector")); |
|
769 TBuf8<KSectorSize> sector; |
|
770 |
|
771 if (ReadSector(iServer.iSharedData.iPartitionBootSector + 1, sector) != KErrNone) |
|
772 { |
|
773 SetTestStepResult(EFail); |
|
774 return; |
|
775 } |
|
776 |
|
777 // |
|
778 INFO_PRINTF5(_L("- Lead Signature: %02xh %02xh %02xh %02xh"), sector[0], sector[1], sector[2], sector[3]); |
|
779 SYMBIAN_TEST_TESTNOPANIC(sector[0] == 0x52); |
|
780 SYMBIAN_TEST_TESTNOPANIC(sector[1] == 0x52); |
|
781 SYMBIAN_TEST_TESTNOPANIC(sector[2] == 0x61); |
|
782 SYMBIAN_TEST_TESTNOPANIC(sector[3] == 0x41); |
|
783 |
|
784 // |
|
785 for (TInt i = 4; i < 484; i++) |
|
786 { |
|
787 SYMBIAN_TEST_TESTNOPANIC(sector[i] == 0); |
|
788 } |
|
789 |
|
790 // |
|
791 INFO_PRINTF5(_L("- Structure Signature: %02xh %02xh %02xh %02xh"), sector[484], sector[485], sector[486], sector[487]); |
|
792 SYMBIAN_TEST_TESTNOPANIC(sector[484] == 0x72); |
|
793 SYMBIAN_TEST_TESTNOPANIC(sector[485] == 0x72); |
|
794 SYMBIAN_TEST_TESTNOPANIC(sector[486] == 0x41); |
|
795 SYMBIAN_TEST_TESTNOPANIC(sector[487] == 0x61); |
|
796 |
|
797 // |
|
798 INFO_PRINTF2(_L("- Free Cluster Count: %08xh"), SYMBIAN_TEST_LE4(sector[488], sector[489], sector[490], sector[491])); |
|
799 INFO_PRINTF2(_L("- Next Free Cluster: %08xh"), SYMBIAN_TEST_LE4(sector[492], sector[493], sector[494], sector[495])); |
|
800 |
|
801 INFO_PRINTF5(_L("- Trail Signature: %02xh %02xh %02xh %02xh"), sector[508], sector[509], sector[510], sector[511]); |
|
802 SYMBIAN_TEST_TESTNOPANIC(sector[508] == 0); |
|
803 SYMBIAN_TEST_TESTNOPANIC(sector[509] == 0); |
|
804 SYMBIAN_TEST_TESTNOPANIC(sector[510] == 0x55); |
|
805 SYMBIAN_TEST_TESTNOPANIC(sector[511] == 0xaa); |
|
806 |
|
807 for (TInt i = 0; i < KSectorSize / 16; i++) |
|
808 { |
|
809 TBuf<60> buffer; |
|
810 buffer.Format(_L("%08x:"), i * 16 + iServer.iSharedData.iPartitionBootSector + 1); |
|
811 for (TInt j = 0; j < 16; j++) |
|
812 { |
|
813 buffer.AppendFormat(_L(" %02x"), sector[i * 16 + j]); |
|
814 } |
|
815 INFO_PRINTF2(_L("%S"), &buffer); |
|
816 } |
|
817 } |
|
818 |
|
819 /* |
|
820 Field Check of the File Allocation Table |
|
821 |
|
822 @param None |
|
823 @return None |
|
824 */ |
|
825 void CBaseTestSDFieldCheck::FS3() |
|
826 { |
|
827 INFO_PRINTF1(_L("FS3 - Field Check of File Allocation Table")); |
|
828 // See section 3.2.2. File Allocation Table |
|
829 // of the SD Specification for details |
|
830 |
|
831 // Also see SD Test Specification for File Systems |
|
832 TBuf8<KSectorSize> sector; |
|
833 |
|
834 if (ReadSector(iServer.iSharedData.iPartitionBootSector + 1, sector) != KErrNone) |
|
835 { |
|
836 SetTestStepResult(EFail); |
|
837 return; |
|
838 } |
|
839 |
|
840 // FS3-1 |
|
841 if (iServer.iSharedData.iNumberOfClusters < 4085) |
|
842 { |
|
843 INFO_PRINTF4(_L("FS 3-1 Head 3 bytes of First FAT: %02xh %02xh %02xh"), sector[0], sector[1], sector[2]); |
|
844 SYMBIAN_TEST_TESTNOPANIC((sector[0] == 0xf8) && (sector[1] == 0xff) && (sector[2] == 0xff)); |
|
845 } |
|
846 else |
|
847 { |
|
848 INFO_PRINTF5(_L("FS 3-1 Head 4 bytes of First FAT: %02xh %02xh %02xh %02xh"), sector[0], sector[1], sector[2], sector[3]); |
|
849 SYMBIAN_TEST_TESTNOPANIC((sector[0] == 0xf8) && (sector[1] == 0xff) && (sector[2] == 0xff) && (sector[3] == 0xff)); |
|
850 } |
|
851 |
|
852 // FS3-2 |
|
853 INFO_PRINTF1(_L("FS 3-2 Read First FAT")); |
|
854 for (TInt i = 0; i < iServer.iSharedData.iSectorsPerFat; i++) |
|
855 { |
|
856 if (ReadSector(iServer.iSharedData.iPartitionBootSector + 1 + i, sector) != KErrNone) |
|
857 { |
|
858 SetTestStepResult(EFail); |
|
859 return; |
|
860 } |
|
861 for (TInt j = 0; j < KSectorSize; j++) |
|
862 { |
|
863 if ((i > 0) || ((i == 0) && (j > 3)) || ((i == 0) && (j == 3) && (iServer.iSharedData.iNumberOfClusters < 4085))) |
|
864 { |
|
865 SYMBIAN_TEST_TESTNOPANIC(sector[j] == 0); |
|
866 } |
|
867 } |
|
868 } |
|
869 |
|
870 if (ReadSector(iServer.iSharedData.iPartitionBootSector + 1 + iServer.iSharedData.iSectorsPerFat, sector) != KErrNone) |
|
871 { |
|
872 SetTestStepResult(EFail); |
|
873 return; |
|
874 } |
|
875 |
|
876 // FS3-3 |
|
877 if (iServer.iSharedData.iNumberOfClusters < 4085) |
|
878 { |
|
879 INFO_PRINTF4(_L("FS 3-3 Head 3 bytes of Second FAT: %02xh %02xh %02xh"), sector[0], sector[1], sector[2]); |
|
880 SYMBIAN_TEST_TESTNOPANIC((sector[0] == 0xf8) && (sector[1] == 0xff) && (sector[2] == 0xff)); |
|
881 } |
|
882 else |
|
883 { |
|
884 INFO_PRINTF5(_L("FS 3-3 Head 4 bytes of Second FAT: %02xh %02xh %02xh"), sector[0], sector[1], sector[2], sector[3]); |
|
885 SYMBIAN_TEST_TESTNOPANIC((sector[0] == 0xf8) && (sector[1] == 0xff) && (sector[2] == 0xff) && (sector[3] == 0xff)); |
|
886 } |
|
887 |
|
888 // FS3-4 |
|
889 INFO_PRINTF1(_L("FS 3-4 Read Second FAT")); |
|
890 for (TInt i = 0; i < iServer.iSharedData.iSectorsPerFat; i++) |
|
891 { |
|
892 if (ReadSector(iServer.iSharedData.iPartitionBootSector + 1 + iServer.iSharedData.iSectorsPerFat + i, sector) != KErrNone) |
|
893 { |
|
894 SetTestStepResult(EFail); |
|
895 return; |
|
896 } |
|
897 for (TInt j = 0; j < KSectorSize; j++) |
|
898 { |
|
899 TInt sec = 0; |
|
900 if ((i > 0) || ((i == 0) && (j > 3)) || ((i == 0) && (j == 3) && (iServer.iSharedData.iNumberOfClusters < 4085))) |
|
901 { |
|
902 sec = sec | sector[j]; |
|
903 } |
|
904 SYMBIAN_TEST_TESTNOPANIC(sec == 0); |
|
905 } |
|
906 } |
|
907 } |
|
908 |
|
909 /* |
|
910 Field Check of Root Directory |
|
911 |
|
912 @param None |
|
913 @return None |
|
914 */ |
|
915 void CBaseTestSDFieldCheck::FS4() |
|
916 { |
|
917 INFO_PRINTF1(_L("FS4 - Field Check of Root Directory")); |
|
918 // See SD Test Specification for File Systems for details |
|
919 TBuf8<KSectorSize> sector; |
|
920 |
|
921 INFO_PRINTF1(_L("FS 4-1 Read Root Directory")); |
|
922 for (TInt i = 0; i < KSectorSize / 16; i++) |
|
923 { |
|
924 TInt sec = 0; |
|
925 if (ReadSector(iServer.iSharedData.iPartitionBootSector + 1 + i + iServer.iSharedData.iSectorsPerFat * 2, sector) != KErrNone) |
|
926 { |
|
927 SetTestStepResult(EFail); |
|
928 return; |
|
929 } |
|
930 for (TInt j = 0; j < KSectorSize; j++) |
|
931 { |
|
932 sec = sec | sector[j]; |
|
933 } |
|
934 SYMBIAN_TEST_TESTNOPANIC(sec == 0); |
|
935 } |
|
936 } |
|
937 |
|
938 /* |
|
939 File Systen Layout Check |
|
940 |
|
941 @param None |
|
942 @return None |
|
943 */ |
|
944 void CBaseTestSDFieldCheck::FS5() |
|
945 { |
|
946 INFO_PRINTF1(_L("FS5 - File System Layout Check")); |
|
947 // See SD Test Specification for File Systems for details |
|
948 |
|
949 TInt boundaryUnit = 0; |
|
950 if (iCardSizeInSectors <= 16384) { boundaryUnit = 16; } // <= 8MB |
|
951 else if (iCardSizeInSectors <= 131072) { boundaryUnit = 32; } // <= 64MB |
|
952 else if (iCardSizeInSectors <= 1048576) { boundaryUnit = 64; } // <= 256MB |
|
953 else { boundaryUnit = 128; } |
|
954 |
|
955 INFO_PRINTF2(_L("Boundary Unit: %d"), boundaryUnit); |
|
956 INFO_PRINTF2(_L("Relative Sector: %d"), iServer.iSharedData.iPartitionBootSector); |
|
957 INFO_PRINTF2(_L("Reserved Sector Count: %d"), iServer.iSharedData.iReservedSectorCount); |
|
958 INFO_PRINTF2(_L("Sectors per FAT: %d"), iServer.iSharedData.iSectorsPerFat); |
|
959 SYMBIAN_TEST_TESTNOPANIC((iServer.iSharedData.iPartitionBootSector + iServer.iSharedData.iReservedSectorCount + iServer.iSharedData.iSectorsPerFat * 2 + 33) % boundaryUnit == 0); |
|
960 SYMBIAN_TEST_TESTNOPANIC(iServer.iSharedData.iPartitionBootSector >= boundaryUnit); |
|
961 } |
|
962 |
|
963 /* |
|
964 Compare Boot Sectors and Backup Boot Sectors |
|
965 |
|
966 @param None |
|
967 @return None |
|
968 */ |
|
969 void CBaseTestSDFieldCheck::FSBackupSectors() |
|
970 { |
|
971 INFO_PRINTF1(_L("FSx - Compare Boot Sectors and Backup Boot Sectors")); |
|
972 // Backup sectors must start on sector 6 (relative) |
|
973 TBuf8<KSectorSize> originalsector; |
|
974 TBuf8<KSectorSize> backupsector; |
|
975 |
|
976 for (TInt i = 0; i < 3; i++) |
|
977 { |
|
978 INFO_PRINTF2(_L("Boot sector comparison %d/3"), i + 1); |
|
979 if (ReadSector(iServer.iSharedData.iPartitionBootSector + i, originalsector) != KErrNone) |
|
980 { |
|
981 SetTestStepResult(EFail); |
|
982 return; |
|
983 } |
|
984 if (ReadSector(iServer.iSharedData.iPartitionBootSector + i + 6, backupsector) != KErrNone) |
|
985 { |
|
986 SetTestStepResult(EFail); |
|
987 return; |
|
988 } |
|
989 TBool areIdentical = ETrue; |
|
990 for (TInt j = 0; j < KSectorSize; j++) |
|
991 { |
|
992 if (originalsector[j] != backupsector[j]) |
|
993 { |
|
994 areIdentical = EFalse; |
|
995 } |
|
996 } |
|
997 if (areIdentical) |
|
998 { |
|
999 INFO_PRINTF1(_L("Sectors are identical")); |
|
1000 } |
|
1001 else |
|
1002 { |
|
1003 ERR_PRINTF1(_L("Sectors are not identical")); |
|
1004 SetTestStepResult(EFail); |
|
1005 } |
|
1006 } |
|
1007 } |