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 // Obliterate first x sectors of a memory card (starts from sector 0 - includes MBR) |
|
15 // |
|
16 // |
|
17 |
|
18 #include "sdfillsectors.h" |
|
19 |
|
20 /* |
|
21 Class constructor |
|
22 |
|
23 @param None |
|
24 @return None |
|
25 */ |
|
26 CBaseTestSDFillSectors::CBaseTestSDFillSectors() |
|
27 { |
|
28 SetTestStepName(KTestStepFillSectors); |
|
29 } |
|
30 |
|
31 /* |
|
32 Test Step Preamble |
|
33 - Load device driver for direct disk access |
|
34 |
|
35 @param None |
|
36 @return EPass if successful or EFail if not |
|
37 @see TVerdict |
|
38 */ |
|
39 TVerdict CBaseTestSDFillSectors::doTestStepPreambleL() |
|
40 { |
|
41 SetTestStepResult(EFail); |
|
42 |
|
43 if (!InitDeviceDriver()) |
|
44 return TestStepResult(); |
|
45 |
|
46 SetTestStepResult(EPass); |
|
47 return TestStepResult(); |
|
48 } |
|
49 |
|
50 /* |
|
51 Test step |
|
52 |
|
53 @param None |
|
54 @return EPass if successful or EFail if not |
|
55 @see TVerdict |
|
56 */ |
|
57 TVerdict CBaseTestSDFillSectors::doTestStepL() |
|
58 { |
|
59 if (TestStepResult() == EPass) |
|
60 { |
|
61 TInt start; |
|
62 TInt end; |
|
63 TInt value; |
|
64 TInt r; |
|
65 |
|
66 _LIT(KFillSectorsStart, "FillSectorsStart"); |
|
67 _LIT(KFillSectorsEnd, "FillSectorsEnd"); |
|
68 _LIT(KFillSectorsHexValue, "FillSectorsHexValue"); |
|
69 if (!GetIntFromConfig(ConfigSection(), KFillSectorsStart, start)) |
|
70 { |
|
71 ERR_PRINTF1(_L("INI file read error")); |
|
72 SetTestStepResult(EFail); |
|
73 return TestStepResult(); |
|
74 } |
|
75 |
|
76 if (!GetIntFromConfig(ConfigSection(), KFillSectorsEnd, end)) |
|
77 { |
|
78 ERR_PRINTF1(_L("INI file read error")); |
|
79 SetTestStepResult(EFail); |
|
80 return TestStepResult(); |
|
81 } |
|
82 if (!GetHexFromConfig(ConfigSection(), KFillSectorsHexValue, value)) |
|
83 { |
|
84 ERR_PRINTF1(_L("INI file read error")); |
|
85 SetTestStepResult(EFail); |
|
86 return TestStepResult(); |
|
87 } |
|
88 |
|
89 TBuf8<255> sector; |
|
90 sector.Fill((TUint8) value); |
|
91 INFO_PRINTF6(_L("Filling sectors %08xh (%d) to %08xh (%d) with %02xh"), start, start, end, end, (TUint8) value); |
|
92 for (TInt i = start; i <= end; i++) |
|
93 { |
|
94 r = WriteSector(i, sector); |
|
95 if (r != KErrNone) |
|
96 { |
|
97 SetTestStepResult(EFail); |
|
98 return TestStepResult(); |
|
99 } |
|
100 } |
|
101 } |
|
102 else |
|
103 { |
|
104 INFO_PRINTF1(_L("Test preamble did not complete succesfully - Test Step skipped")); |
|
105 } |
|
106 return TestStepResult(); |
|
107 } |
|