author | John Imhofe <john.imhofe@nokia.com> |
Mon, 21 Dec 2009 16:14:42 +0000 | |
changeset 15 | 4122176ea935 |
parent 0 | a41df078684a |
permissions | -rw-r--r-- |
0 | 1 |
/* |
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
2 |
* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
0 | 3 |
* All rights reserved. |
4 |
* This component and the accompanying materials are made available |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
5 |
* under the terms of "Eclipse Public License v1.0" |
0 | 6 |
* which accompanies this distribution, and is available |
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
* |
|
9 |
* Initial Contributors: |
|
10 |
* Nokia Corporation - initial contribution. |
|
11 |
* |
|
12 |
* Contributors: |
|
13 |
* |
|
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
14 |
* Description: |
0 | 15 |
* |
16 |
*/ |
|
17 |
||
18 |
||
15
4122176ea935
Revision: 200948 + Removing redundant base integration tests and fixing build errors
John Imhofe <john.imhofe@nokia.com>
parents:
0
diff
changeset
|
19 |
|
0 | 20 |
#include "t_fat32writeraw.h" |
21 |
||
22 |
static RRawDisk TheDisk; |
|
23 |
||
24 |
/** |
|
25 |
Class Constructor |
|
26 |
*/ |
|
27 |
CBaseTestFat32WriteRaw::CBaseTestFat32WriteRaw() |
|
28 |
{ |
|
29 |
SetTestStepName(KTestStepWriteRaw); |
|
30 |
} |
|
31 |
||
32 |
/** |
|
33 |
Class Destructor |
|
34 |
*/ |
|
35 |
CBaseTestFat32WriteRaw::~CBaseTestFat32WriteRaw() |
|
36 |
{ |
|
37 |
} |
|
38 |
||
39 |
/** |
|
40 |
This function performs the following actions: |
|
41 |
1. Get the position at which to write on the raw disk from the ini file |
|
42 |
-> if a cluster is specified, get the position from the GetCluster function |
|
43 |
2. Get the number of bytes to write from the ini file |
|
44 |
3. Obtain the values to be written to the disk from the ini file. |
|
45 |
4. Write the values to the disk byte by byte. |
|
46 |
||
47 |
@return EPass if test passes and EFail if test fails |
|
48 |
*/ |
|
49 |
TVerdict CBaseTestFat32WriteRaw::doTestStepL() |
|
50 |
{ |
|
51 |
SetTestStepResult(EFail); |
|
52 |
_LIT(KPosition,"WritePosition"); |
|
53 |
_LIT(KNumOfBytes,"NumberOfBytes"); |
|
54 |
_LIT(KCluster,"ClusterNumber"); |
|
55 |
TInt writevalues[12]; |
|
56 |
TInt position; |
|
57 |
TInt64 clusterPosition; |
|
58 |
TInt cluster; |
|
59 |
TInt numbyte; |
|
60 |
TInt r; |
|
61 |
TBool alright = GetHexFromConfig(ConfigSection(), KPosition, position); |
|
62 |
if(alright) |
|
63 |
{ |
|
64 |
if (iMedia == 1 && position >= 16384) |
|
65 |
{ |
|
66 |
INFO_PRINTF2(_L("Position = %d"), position); |
|
67 |
INFO_PRINTF2(_L("iBPB_ResvdSecCnt = %d"), iBPB_ResvdSecCnt); |
|
68 |
position = (iBPB_ResvdSecCnt * 512) + (position - 0x4000); |
|
69 |
INFO_PRINTF2(_L("New Position = %d"), position); |
|
70 |
} |
|
71 |
TBool alright2 = GetHexFromConfig(ConfigSection(), KNumOfBytes, numbyte); |
|
72 |
if (alright2) |
|
73 |
{ |
|
74 |
TBool alright2 = GetIntFromConfig(ConfigSection(), KCluster, cluster); |
|
75 |
if (alright2) |
|
76 |
{ |
|
77 |
r = GetCluster(cluster, clusterPosition); |
|
78 |
position = clusterPosition; |
|
79 |
} |
|
80 |
else |
|
81 |
{ |
|
82 |
position = position; |
|
83 |
} |
|
84 |
_LIT(KFATEntryWritePosition,"FATEntryWritePosition"); |
|
85 |
_LIT(KFATEntry0,"FATEntry0"); |
|
86 |
_LIT(KFATEntry1,"FATEntry1"); |
|
87 |
_LIT(KFATEntry2,"FATEntry2"); |
|
88 |
_LIT(KFATEntry3,"FATEntry3"); |
|
89 |
_LIT(KFATEntry4,"FATEntry4"); |
|
90 |
_LIT(KFATEntry6,"FATEntry6"); |
|
91 |
_LIT(KFATEntry18,"FATEntry18"); |
|
92 |
_LIT(KFATEntry52,"FATEntry52"); |
|
93 |
_LIT(KFATEntry78,"FATEntry78"); |
|
94 |
||
95 |
||
96 |
TPtrC fat_entry_str; |
|
97 |
if(GetStringFromConfig(ConfigSection(), KFATEntryWritePosition, fat_entry_str)) |
|
98 |
{ |
|
99 |
if(!fat_entry_str.Compare(KFATEntry0)) |
|
100 |
{ |
|
101 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec; |
|
102 |
} |
|
103 |
else if(!fat_entry_str.Compare(KFATEntry1)) |
|
104 |
{ |
|
105 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec + 4; |
|
106 |
} |
|
107 |
else if(!fat_entry_str.Compare(KFATEntry2)) |
|
108 |
{ |
|
109 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec + 4*2; |
|
110 |
} |
|
111 |
else if(!fat_entry_str.Compare(KFATEntry3)) |
|
112 |
{ |
|
113 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec + 4*3; |
|
114 |
} |
|
115 |
else if(!fat_entry_str.Compare(KFATEntry4)) |
|
116 |
{ |
|
117 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec + 4*4; |
|
118 |
} |
|
119 |
else if(!fat_entry_str.Compare(KFATEntry6)) |
|
120 |
{ |
|
121 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec + 4*6; |
|
122 |
} |
|
123 |
else if(!fat_entry_str.Compare(KFATEntry18)) |
|
124 |
{ |
|
125 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec + 4*18; |
|
126 |
} |
|
127 |
else if(!fat_entry_str.Compare(KFATEntry52)) |
|
128 |
{ |
|
129 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec + 4*52; |
|
130 |
} |
|
131 |
else if(!fat_entry_str.Compare(KFATEntry78)) |
|
132 |
{ |
|
133 |
position = iBPB_ResvdSecCnt * iBPB_BytsPerSec + 4*78; |
|
134 |
} |
|
135 |
||
136 |
} |
|
137 |
_LIT(KWritePosition, "The position on the disk being written to is %d"); |
|
138 |
INFO_PRINTF2(KWritePosition,position); |
|
139 |
r = GetWriteValue(numbyte,writevalues); |
|
140 |
TInt i; |
|
141 |
r = TheDisk.Open(iTheFs, CurrentDrive()); |
|
142 |
if (r!=KErrNone) |
|
143 |
{ |
|
144 |
_LIT(KErrorOpen, "Cannot open the raw disk - r=%d"); |
|
145 |
INFO_PRINTF2(KErrorOpen, r); |
|
146 |
} |
|
147 |
for (i=0;i<numbyte;i++) |
|
148 |
{ |
|
149 |
r = WriteRaw(position+i, writevalues[i]); |
|
150 |
if(r != KErrNone) |
|
151 |
{ |
|
152 |
_LIT(KErrorRead, "Cannot write to the raw disk at position %d with value %d"); |
|
153 |
INFO_PRINTF3(KErrorRead,position, writevalues[i]); |
|
154 |
SetTestStepResult(EFail); |
|
155 |
return TestStepResult(); |
|
156 |
} |
|
157 |
} |
|
158 |
TheDisk.Close(); |
|
159 |
} |
|
160 |
else |
|
161 |
{ |
|
162 |
_LIT(KNoIniNumByte, "Cannot read the number of bytes from the ini file"); |
|
163 |
INFO_PRINTF1(KNoIniNumByte); |
|
164 |
SetTestStepResult(EFail); |
|
165 |
return TestStepResult(); |
|
166 |
} |
|
167 |
} |
|
168 |
else |
|
169 |
{ |
|
170 |
_LIT(KNoIniPos, "Cannot read the position from the ini file"); |
|
171 |
INFO_PRINTF1(KNoIniPos); |
|
172 |
SetTestStepResult(EFail); |
|
173 |
return TestStepResult(); |
|
174 |
} |
|
175 |
||
176 |
||
177 |
SetTestStepResult(EPass); |
|
178 |
_LIT(KWritePass, "Write Passed"); |
|
179 |
INFO_PRINTF1(KWritePass); |
|
180 |
return TestStepResult(); |
|
181 |
} |
|
182 |
||
183 |
/** |
|
184 |
Writing a value to the raw disk |
|
185 |
||
186 |
@param aPos The position from which to start writing to the raw disk |
|
187 |
@param aValue The value to write to the raw disk |
|
188 |
||
189 |
@return KErrNone if successfull |
|
190 |
*/ |
|
191 |
TInt CBaseTestFat32WriteRaw::WriteRaw(TInt64 aPos,TInt aValue) |
|
192 |
{ |
|
193 |
// int val = 0; |
|
194 |
TInt r; |
|
195 |
TUint8 data[1]; |
|
196 |
TPtr8 buffer((TUint8*)&data[0],1); |
|
197 |
r = TheDisk.Read(aPos,buffer); |
|
198 |
data[0] = aValue; |
|
199 |
r = TheDisk.Write(aPos,buffer); |
|
200 |
if (r != KErrNone) |
|
201 |
{ |
|
202 |
_LIT(KErrorWrite, "Cannot write to the raw disk - r=%d"); |
|
203 |
INFO_PRINTF2(KErrorWrite,r); |
|
204 |
} |
|
205 |
return r; |
|
206 |
} |
|
207 |
||
208 |
/** |
|
209 |
Get the values that are to be written to the disk byte by byte |
|
210 |
and place into an array |
|
211 |
||
212 |
@param aNumberOfBytes the nummber of bytes to write to the raw disk |
|
213 |
@param aValueArray Array containing the values to write to the raw disk |
|
214 |
||
215 |
@return KErrNone if successfull |
|
216 |
*/ |
|
217 |
TInt CBaseTestFat32WriteRaw::GetWriteValue(TInt aNumOfBytes,TInt* aValueArray) |
|
218 |
{ |
|
219 |
TInt value; |
|
220 |
TInt i; |
|
221 |
_LIT(KWriteValues,"WriteValue%d"); |
|
222 |
for (i = 1; i < aNumOfBytes + 1; i++) |
|
223 |
{ |
|
224 |
TBuf<20> writeValue; |
|
225 |
writeValue.Format(KWriteValues, i); |
|
226 |
TBool alright3 = GetHexFromConfig(ConfigSection(), writeValue, value); |
|
227 |
if (alright3) |
|
228 |
{ |
|
229 |
aValueArray[i-1] = value; |
|
230 |
} |
|
231 |
else |
|
232 |
{ |
|
233 |
INFO_PRINTF1(_L("Cannot read WriteValue from ini file")); |
|
234 |
return KErrGeneral; |
|
235 |
} |
|
236 |
} |
|
237 |
return KErrNone; |
|
238 |
} |
|
239 |
||
240 |
/** |
|
241 |
Get the position by calulating from the entry and position in the entry |
|
242 |
specified in the ini file |
|
243 |
||
244 |
@param aClusterNumber The cluster on the disk to write to |
|
245 |
@param aPosition the position within an entry |
|
246 |
||
247 |
@return KErrNone if successfull |
|
248 |
*/ |
|
249 |
TInt CBaseTestFat32WriteRaw::GetCluster(TInt aClusterNumber,TInt64 &aPosition) |
|
250 |
{ |
|
251 |
TInt entry; |
|
252 |
_LIT(KEntry,"Entry"); |
|
253 |
TInt entryposition; |
|
254 |
_LIT(KPositionInEntry,"PositionInEntry"); |
|
255 |
TBool alright = GetIntFromConfig(ConfigSection(), KEntry, entry); |
|
256 |
if (alright) |
|
257 |
{ |
|
258 |
TBool alright2 = GetIntFromConfig(ConfigSection(), KPositionInEntry, entryposition); |
|
259 |
if (alright2) |
|
260 |
{ |
|
261 |
aPosition = (iBPB_ResvdSecCnt + (iBPB_FATSz32*2) + (iBPB_SecPerClus * (aClusterNumber - 2))) * 512; |
|
262 |
aPosition = aPosition + ((entry - 1)*96)+ entryposition;//(32 * (entry - 1)); |
|
263 |
} |
|
264 |
} |
|
265 |
return KErrNone; |
|
266 |
} |
|
267 |