sl@0
|
1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\demandpaging\t_tbus_datapaging.cpp
|
sl@0
|
15 |
// Functional tests for data paging.
|
sl@0
|
16 |
// 002 ???
|
sl@0
|
17 |
// 003 ???
|
sl@0
|
18 |
//
|
sl@0
|
19 |
|
sl@0
|
20 |
//! @SYMTestCaseID KBASE-T_TBUS_DATAPAGING
|
sl@0
|
21 |
//! @SYMTestType UT
|
sl@0
|
22 |
//! @SYMPREQ ???
|
sl@0
|
23 |
//! @SYMTestCaseDesc Data Paging functional tests with TBusLocalDrive.
|
sl@0
|
24 |
//! @SYMTestActions 001 ???
|
sl@0
|
25 |
//! @SYMTestExpectedResults All tests should pass.
|
sl@0
|
26 |
//! @SYMTestPriority High
|
sl@0
|
27 |
//! @SYMTestStatus Implementation on-going
|
sl@0
|
28 |
|
sl@0
|
29 |
#define __E32TEST_EXTENSION__
|
sl@0
|
30 |
#include <e32test.h>
|
sl@0
|
31 |
#include <dptest.h>
|
sl@0
|
32 |
#include <e32hal.h>
|
sl@0
|
33 |
#include <u32exec.h>
|
sl@0
|
34 |
#include <e32svr.h>
|
sl@0
|
35 |
#include <e32panic.h>
|
sl@0
|
36 |
#include "u32std.h"
|
sl@0
|
37 |
|
sl@0
|
38 |
#include <f32file.h>
|
sl@0
|
39 |
#include <f32dbg.h>
|
sl@0
|
40 |
#include <f32fsys.h>
|
sl@0
|
41 |
|
sl@0
|
42 |
#include "t_dpcmn.h"
|
sl@0
|
43 |
#include "../secure/d_sldd.h"
|
sl@0
|
44 |
#include "../mmu/mmudetect.h"
|
sl@0
|
45 |
|
sl@0
|
46 |
const TInt KMaxLengthOfStoreMapping = 16 + sizeof(TInt32) + KMaxMediaPassword;
|
sl@0
|
47 |
const TInt KMaxPersistentStore(TPasswordStore::EMaxPasswordLength+KMaxLengthOfStoreMapping);
|
sl@0
|
48 |
typedef TBuf8<KMaxPersistentStore> TPersistentStore;
|
sl@0
|
49 |
|
sl@0
|
50 |
RChunk gMyChunk;
|
sl@0
|
51 |
TUint gOffset = 0;
|
sl@0
|
52 |
TUint8* gData = NULL;
|
sl@0
|
53 |
const TUint8 KClearValue = 0xed;
|
sl@0
|
54 |
const TUint KChunkSizeInPages = 64; // 64 * 4096 = 256K
|
sl@0
|
55 |
const TInt KTestBufLen=256;
|
sl@0
|
56 |
|
sl@0
|
57 |
|
sl@0
|
58 |
#define __DECLARE_VAR_IN_CHUNK(type, varRef) \
|
sl@0
|
59 |
type varRef = *(type*) (gData+gOffset); \
|
sl@0
|
60 |
gOffset += Max(gPageSize, sizeof(type)); \
|
sl@0
|
61 |
test(gOffset <= gPageSize * KChunkSizeInPages);
|
sl@0
|
62 |
|
sl@0
|
63 |
#define __DECLARE_AND_INIT_VAR_IN_CHUNK(type, var) \
|
sl@0
|
64 |
type &var = *(type*) (gData+gOffset); \
|
sl@0
|
65 |
var = type(); \
|
sl@0
|
66 |
gOffset += Max(gPageSize, sizeof(type)); \
|
sl@0
|
67 |
test(gOffset <= gPageSize * KChunkSizeInPages);
|
sl@0
|
68 |
|
sl@0
|
69 |
|
sl@0
|
70 |
#define __DECLARE_ARRAY_IN_CHUNK(type, var, size) \
|
sl@0
|
71 |
type *var = (type*) (gData+gOffset); \
|
sl@0
|
72 |
gOffset += Max(gPageSize, (sizeof(type) * size)); \
|
sl@0
|
73 |
test(gOffset <= gPageSize * KChunkSizeInPages);
|
sl@0
|
74 |
|
sl@0
|
75 |
#define __FLUSH_AND_CALL_API_METHOD(return, function) \
|
sl@0
|
76 |
DPTest::FlushCache(); \
|
sl@0
|
77 |
return = function;
|
sl@0
|
78 |
|
sl@0
|
79 |
|
sl@0
|
80 |
LOCAL_D RFs TheFs;
|
sl@0
|
81 |
TInt gFsDriveNumber = -1;
|
sl@0
|
82 |
|
sl@0
|
83 |
RTest test(_L("T_TBUS_DATAPAGING"));
|
sl@0
|
84 |
_LIT(KChunkName, "t_datapaging chunk");
|
sl@0
|
85 |
|
sl@0
|
86 |
const TUint KDriveAttMask = KDriveAttLocal | KDriveAttRom | KDriveAttRemote;
|
sl@0
|
87 |
const TUint KMediaAttMask = KMediaAttVariableSize | KMediaAttDualDensity | KMediaAttLockable | KMediaAttLocked | KMediaAttHasPassword | KMediaAttReadWhileWrite;
|
sl@0
|
88 |
|
sl@0
|
89 |
void CreatePagedChunk(TInt aSizeInPages, TInt aWipeByte = -1)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
test_Equal(0,gMyChunk.Handle());
|
sl@0
|
92 |
|
sl@0
|
93 |
TChunkCreateInfo createInfo;
|
sl@0
|
94 |
TInt size = aSizeInPages * gPageSize;
|
sl@0
|
95 |
createInfo.SetNormal(size, size);
|
sl@0
|
96 |
createInfo.SetPaging(TChunkCreateInfo::EPaged);
|
sl@0
|
97 |
createInfo.SetOwner(EOwnerProcess);
|
sl@0
|
98 |
createInfo.SetGlobal(KChunkName);
|
sl@0
|
99 |
if (aWipeByte != -1)
|
sl@0
|
100 |
createInfo.SetClearByte(aWipeByte);
|
sl@0
|
101 |
test_KErrNone(gMyChunk.Create(createInfo));
|
sl@0
|
102 |
test(gMyChunk.IsPaged()); // this is only ever called if data paging is supported
|
sl@0
|
103 |
|
sl@0
|
104 |
gData = gMyChunk.Base();
|
sl@0
|
105 |
}
|
sl@0
|
106 |
|
sl@0
|
107 |
TInt TestDriveConnectAndCaps(TBusLocalDrive &aDrive, TInt &aLocalDriveNumber)
|
sl@0
|
108 |
{
|
sl@0
|
109 |
|
sl@0
|
110 |
test.Next(_L("Test Drive Connect And Caps"));
|
sl@0
|
111 |
|
sl@0
|
112 |
__DECLARE_VAR_IN_CHUNK(TInt, &r);
|
sl@0
|
113 |
|
sl@0
|
114 |
test.Printf(_L("changeFlag...\n"));
|
sl@0
|
115 |
__DECLARE_VAR_IN_CHUNK(TBool, &changeFlag);
|
sl@0
|
116 |
changeFlag = EFalse;
|
sl@0
|
117 |
|
sl@0
|
118 |
test.Printf(_L("call aDrive.Connect()...\n"));
|
sl@0
|
119 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.Connect(aLocalDriveNumber,changeFlag));
|
sl@0
|
120 |
|
sl@0
|
121 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
122 |
test_Equal(KErrNone, r);
|
sl@0
|
123 |
|
sl@0
|
124 |
test.Printf(_L("call aDrive.Caps()...\n"));
|
sl@0
|
125 |
__DECLARE_VAR_IN_CHUNK(TLocalDriveCapsV5, &driveCaps);
|
sl@0
|
126 |
|
sl@0
|
127 |
TPckg<TLocalDriveCapsV5> capsPckg(driveCaps);
|
sl@0
|
128 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.Caps(capsPckg));
|
sl@0
|
129 |
|
sl@0
|
130 |
test_Equal(KErrNone, r);
|
sl@0
|
131 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
132 |
test.Printf(_L("driveCaps.iDriveAtt :0x%08x\n"), driveCaps.iDriveAtt);
|
sl@0
|
133 |
test.Printf(_L("driveCaps.iSize :%ld\n"), driveCaps.iSize);
|
sl@0
|
134 |
test.Printf(_L("driveCaps.iSerialNumLength :%d\n"), driveCaps.iSerialNumLength);
|
sl@0
|
135 |
|
sl@0
|
136 |
return I64LOW(driveCaps.iSize);
|
sl@0
|
137 |
}
|
sl@0
|
138 |
|
sl@0
|
139 |
void TestDriveSizeRelatedMethods(TBusLocalDrive &aDrive, TInt aNewSize, TInt aOldSize)
|
sl@0
|
140 |
{
|
sl@0
|
141 |
TInt r;
|
sl@0
|
142 |
|
sl@0
|
143 |
test.Next(_L("Test Drive Size Related Methods"));
|
sl@0
|
144 |
test.Printf(_L("newDriveSize...\n"));
|
sl@0
|
145 |
__DECLARE_VAR_IN_CHUNK(TInt, &newDriveSize);
|
sl@0
|
146 |
newDriveSize = aNewSize;
|
sl@0
|
147 |
|
sl@0
|
148 |
test.Printf(_L("call aDrive.Enlarge()...\n"));
|
sl@0
|
149 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.Enlarge(newDriveSize));
|
sl@0
|
150 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
151 |
test((KErrNone == r) || (KErrNotSupported == r) || (KErrNotReady == r));
|
sl@0
|
152 |
if(r != KErrNone )
|
sl@0
|
153 |
{
|
sl@0
|
154 |
test.Printf(_L("errInfo...\n"));
|
sl@0
|
155 |
__DECLARE_ARRAY_IN_CHUNK(TUint8, errInfo, KTestBufLen);
|
sl@0
|
156 |
|
sl@0
|
157 |
TPtr8 pErrInfoBuff(errInfo, KTestBufLen);
|
sl@0
|
158 |
|
sl@0
|
159 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.GetLastErrorInfo(pErrInfoBuff));
|
sl@0
|
160 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
161 |
test((KErrNone == r) || (KErrNotSupported == r));
|
sl@0
|
162 |
}
|
sl@0
|
163 |
|
sl@0
|
164 |
|
sl@0
|
165 |
test.Printf(_L("call aDrive.ReduceSize()...\n"));
|
sl@0
|
166 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.ReduceSize(0, aOldSize));
|
sl@0
|
167 |
test((KErrNone == r) || (KErrNotSupported == r) || (KErrNotReady == r));
|
sl@0
|
168 |
|
sl@0
|
169 |
}
|
sl@0
|
170 |
|
sl@0
|
171 |
void TestWriteReadRelatedMethods(TBusLocalDrive &aDrive)
|
sl@0
|
172 |
{
|
sl@0
|
173 |
|
sl@0
|
174 |
test.Next(_L("Test Write & Read Related Methods"));
|
sl@0
|
175 |
|
sl@0
|
176 |
__DECLARE_VAR_IN_CHUNK(TInt, &r);
|
sl@0
|
177 |
|
sl@0
|
178 |
test.Printf(_L("msgHandle...\n"));
|
sl@0
|
179 |
__DECLARE_VAR_IN_CHUNK(TInt, &msgHandle);
|
sl@0
|
180 |
msgHandle = KLocalMessageHandle;
|
sl@0
|
181 |
|
sl@0
|
182 |
|
sl@0
|
183 |
__DECLARE_VAR_IN_CHUNK(TUint, &i);
|
sl@0
|
184 |
test.Printf(_L("wrBuf...\n"));
|
sl@0
|
185 |
TBuf8<KTestBufLen> wrBuf(KTestBufLen);
|
sl@0
|
186 |
for (i=0 ; i<(TUint)KTestBufLen ; i++)
|
sl@0
|
187 |
wrBuf[i]=(TUint8)i;
|
sl@0
|
188 |
|
sl@0
|
189 |
|
sl@0
|
190 |
test.Printf(_L("wrBuf2...\n"));
|
sl@0
|
191 |
__DECLARE_ARRAY_IN_CHUNK(TUint8, wrBuf2, KTestBufLen);
|
sl@0
|
192 |
|
sl@0
|
193 |
test.Printf(_L("fill wrBuf2...\n"));
|
sl@0
|
194 |
for (i=0 ; i<(TUint)KTestBufLen ; i++)
|
sl@0
|
195 |
wrBuf2[i]=(TUint8)i;
|
sl@0
|
196 |
|
sl@0
|
197 |
TPtr8 pWrBuf2(wrBuf2, KTestBufLen, KTestBufLen);
|
sl@0
|
198 |
|
sl@0
|
199 |
test.Printf(_L("rdBuf...\n"));
|
sl@0
|
200 |
TBuf8<KTestBufLen> rdBuf(KTestBufLen);
|
sl@0
|
201 |
|
sl@0
|
202 |
|
sl@0
|
203 |
test.Printf(_L("rdBuf2...\n"));
|
sl@0
|
204 |
__DECLARE_ARRAY_IN_CHUNK(TUint8, rdBuf2, KTestBufLen);
|
sl@0
|
205 |
|
sl@0
|
206 |
TPtr8 pRdBuf2(rdBuf2, KTestBufLen);
|
sl@0
|
207 |
|
sl@0
|
208 |
test.Printf(_L("call aDrive.Write()...\n"));
|
sl@0
|
209 |
rdBuf.Fill(0,KTestBufLen);
|
sl@0
|
210 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.Write(0,KTestBufLen,&wrBuf,msgHandle,0));
|
sl@0
|
211 |
test_Equal(KErrNone, r);
|
sl@0
|
212 |
|
sl@0
|
213 |
|
sl@0
|
214 |
test.Printf(_L("call aDrive.Read()...\n"));
|
sl@0
|
215 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.Read(0,KTestBufLen,&rdBuf,msgHandle,0));
|
sl@0
|
216 |
test_Equal(KErrNone, r);
|
sl@0
|
217 |
|
sl@0
|
218 |
for (i=0 ; i<(TUint)KTestBufLen ; i++)
|
sl@0
|
219 |
test_Equal(wrBuf[i], rdBuf[i]);
|
sl@0
|
220 |
|
sl@0
|
221 |
test.Printf(_L("call aDrive.Write()...\n"));
|
sl@0
|
222 |
pRdBuf2.Fill(0,KTestBufLen);
|
sl@0
|
223 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.Write(0,pWrBuf2));
|
sl@0
|
224 |
test_Equal(KErrNone, r);
|
sl@0
|
225 |
|
sl@0
|
226 |
|
sl@0
|
227 |
test.Printf(_L("call aDrive.Read()...\n"));
|
sl@0
|
228 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.Read(0,KTestBufLen, pRdBuf2));
|
sl@0
|
229 |
test_Equal(KErrNone, r);
|
sl@0
|
230 |
|
sl@0
|
231 |
for (i=0 ; i<(TUint)KTestBufLen ; i++)
|
sl@0
|
232 |
test_Equal(wrBuf2[i], rdBuf2[i]);
|
sl@0
|
233 |
|
sl@0
|
234 |
}
|
sl@0
|
235 |
|
sl@0
|
236 |
void TestPasswordRelatedMethods(TBusLocalDrive &aDrive)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
TInt r;
|
sl@0
|
239 |
|
sl@0
|
240 |
test.Next(_L("Test Password Related Methods"));
|
sl@0
|
241 |
//__DECLARE_VAR_IN_CHUNK(TPersistentStore, &wStore);
|
sl@0
|
242 |
|
sl@0
|
243 |
TPersistentStore* pstoreAB;
|
sl@0
|
244 |
test((pstoreAB = new TPersistentStore) != 0);
|
sl@0
|
245 |
TPersistentStore& wStore = *pstoreAB;
|
sl@0
|
246 |
|
sl@0
|
247 |
//__DECLARE_AND_INIT_VAR_IN_CHUNK(TPersistentStore, wStore);
|
sl@0
|
248 |
|
sl@0
|
249 |
// Password related API methods call
|
sl@0
|
250 |
test.Printf(_L("call aDrive.WritePasswordData() to clear passwords...\n"));
|
sl@0
|
251 |
__DECLARE_VAR_IN_CHUNK(TInt, &passwordStoreLength);
|
sl@0
|
252 |
|
sl@0
|
253 |
TBuf8<1> nulSt;
|
sl@0
|
254 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(nulSt));
|
sl@0
|
255 |
test( r == KErrNone);// empty
|
sl@0
|
256 |
|
sl@0
|
257 |
test.Printf(_L("call aDrive.PasswordStoreLengthInBytes()...\n"));
|
sl@0
|
258 |
__FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
|
sl@0
|
259 |
|
sl@0
|
260 |
test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
|
sl@0
|
261 |
test_Equal(0, passwordStoreLength);
|
sl@0
|
262 |
|
sl@0
|
263 |
|
sl@0
|
264 |
test.Printf(_L("call aDrive.ErasePassword()...\n"));
|
sl@0
|
265 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.ErasePassword());
|
sl@0
|
266 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
267 |
|
sl@0
|
268 |
|
sl@0
|
269 |
test.Printf(_L("wStore.Size():%d\n"),wStore.Size());
|
sl@0
|
270 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore));
|
sl@0
|
271 |
|
sl@0
|
272 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
273 |
test((KErrNone == r)); // || (KErrCorrupt == r)); // TO-DO Why Corrupt???
|
sl@0
|
274 |
|
sl@0
|
275 |
__FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
|
sl@0
|
276 |
|
sl@0
|
277 |
test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
|
sl@0
|
278 |
test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
|
sl@0
|
279 |
|
sl@0
|
280 |
|
sl@0
|
281 |
|
sl@0
|
282 |
test.Printf(_L("Set and store a password...\n"));
|
sl@0
|
283 |
TDes8 &st = wStore;
|
sl@0
|
284 |
TMediaPassword a((const TUint8*) "CID0ccccccccccc#");
|
sl@0
|
285 |
TUint8 passLen[sizeof(TInt32)];
|
sl@0
|
286 |
passLen[0] = 0;
|
sl@0
|
287 |
passLen[1] = 0;
|
sl@0
|
288 |
passLen[2] = 0;
|
sl@0
|
289 |
passLen[3] = 16;
|
sl@0
|
290 |
|
sl@0
|
291 |
//test.Printf(_L("Password3:'%S'\n"), &a);
|
sl@0
|
292 |
|
sl@0
|
293 |
st.Append(a);
|
sl@0
|
294 |
st.Append(passLen, sizeof(TInt32));
|
sl@0
|
295 |
st.Append(a);
|
sl@0
|
296 |
|
sl@0
|
297 |
test.Printf(_L("wStore.Size():%d\n"),wStore.Size());
|
sl@0
|
298 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore));
|
sl@0
|
299 |
|
sl@0
|
300 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
301 |
test((KErrNone == r));
|
sl@0
|
302 |
|
sl@0
|
303 |
__FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
|
sl@0
|
304 |
|
sl@0
|
305 |
test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
|
sl@0
|
306 |
test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
|
sl@0
|
307 |
|
sl@0
|
308 |
test.Printf(_L("call aDrive.ErasePassword()...\n"));
|
sl@0
|
309 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.ErasePassword());
|
sl@0
|
310 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
311 |
|
sl@0
|
312 |
test.Printf(_L("call aDrive.WritePasswordData() to set password again...\n"));
|
sl@0
|
313 |
test.Printf(_L("wStore.Size():%d\n"),wStore.Size());
|
sl@0
|
314 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore));
|
sl@0
|
315 |
|
sl@0
|
316 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
317 |
test((KErrNone == r));
|
sl@0
|
318 |
|
sl@0
|
319 |
__FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
|
sl@0
|
320 |
|
sl@0
|
321 |
test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
|
sl@0
|
322 |
test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
|
sl@0
|
323 |
|
sl@0
|
324 |
|
sl@0
|
325 |
// Finally erase password
|
sl@0
|
326 |
test.Printf(_L("call aDrive.WritePasswordData() to erase password...\n"));
|
sl@0
|
327 |
wStore.Zero(); // empty password store
|
sl@0
|
328 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore))
|
sl@0
|
329 |
test( r == KErrNone);// Clear
|
sl@0
|
330 |
|
sl@0
|
331 |
__FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
|
sl@0
|
332 |
|
sl@0
|
333 |
test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
|
sl@0
|
334 |
test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
|
sl@0
|
335 |
|
sl@0
|
336 |
|
sl@0
|
337 |
|
sl@0
|
338 |
// Test SetPassword
|
sl@0
|
339 |
TMediaPassword nul(nulSt);
|
sl@0
|
340 |
|
sl@0
|
341 |
test.Printf(_L("call aDrive.SetPassword()...\n"));
|
sl@0
|
342 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.SetPassword(nul, a, EFalse));
|
sl@0
|
343 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
344 |
test_Equal(KErrNone, r);
|
sl@0
|
345 |
|
sl@0
|
346 |
// Erase Password
|
sl@0
|
347 |
test.Printf(_L("call aDrive.ErasePassword()...\n"));
|
sl@0
|
348 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.ErasePassword());
|
sl@0
|
349 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
350 |
|
sl@0
|
351 |
|
sl@0
|
352 |
test.Printf(_L("call aDrive.SetPassword()...\n"));
|
sl@0
|
353 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.SetPassword(nul, a, EFalse));
|
sl@0
|
354 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
355 |
test_Equal(KErrNone, r);
|
sl@0
|
356 |
|
sl@0
|
357 |
// Erase Clear
|
sl@0
|
358 |
test.Printf(_L("call aDrive.Clear()...\n"));
|
sl@0
|
359 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.Clear(a));
|
sl@0
|
360 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
361 |
|
sl@0
|
362 |
|
sl@0
|
363 |
test.Printf(_L("call aDrive.SetPassword() to clear again...\n"));
|
sl@0
|
364 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.SetPassword(a, nul, EFalse));
|
sl@0
|
365 |
test.Printf(_L("r:%d\n"),r);
|
sl@0
|
366 |
test_Equal(KErrAccessDenied, r);
|
sl@0
|
367 |
|
sl@0
|
368 |
|
sl@0
|
369 |
// Finally erase password
|
sl@0
|
370 |
test.Printf(_L("call aDrive.WritePasswordData() to erase password...\n"));
|
sl@0
|
371 |
wStore.Zero(); // empty password store
|
sl@0
|
372 |
__FLUSH_AND_CALL_API_METHOD(r, aDrive.WritePasswordData(wStore))
|
sl@0
|
373 |
test( r == KErrNone);// Clear
|
sl@0
|
374 |
|
sl@0
|
375 |
__FLUSH_AND_CALL_API_METHOD(passwordStoreLength, aDrive.PasswordStoreLengthInBytes());
|
sl@0
|
376 |
|
sl@0
|
377 |
test.Printf(_L("passwordStoreLength:%d\n"), passwordStoreLength);
|
sl@0
|
378 |
test((r == KErrNone ? (wStore.Size() == passwordStoreLength) : (0 == passwordStoreLength) ));
|
sl@0
|
379 |
|
sl@0
|
380 |
}
|
sl@0
|
381 |
|
sl@0
|
382 |
void TestFormatRelatedMethods(TBusLocalDrive &aDrive, TInt aSize )
|
sl@0
|
383 |
{
|
sl@0
|
384 |
test.Next(_L("Test Format Related Methods"));
|
sl@0
|
385 |
|
sl@0
|
386 |
test.Printf(_L("call aDrive.Format(TFormatInfo)...\n"));
|
sl@0
|
387 |
__DECLARE_AND_INIT_VAR_IN_CHUNK(TFormatInfo, fi);
|
sl@0
|
388 |
__DECLARE_VAR_IN_CHUNK(TInt, &ret);
|
sl@0
|
389 |
__DECLARE_VAR_IN_CHUNK(TInt, &attempt);
|
sl@0
|
390 |
|
sl@0
|
391 |
__FLUSH_AND_CALL_API_METHOD(ret, aDrive.Format(fi));
|
sl@0
|
392 |
test.Printf(_L("ret:%d\n"),ret);
|
sl@0
|
393 |
while(ret!=KErrEof)
|
sl@0
|
394 |
{
|
sl@0
|
395 |
if( ret == KErrNotReady )
|
sl@0
|
396 |
{
|
sl@0
|
397 |
attempt = 100;
|
sl@0
|
398 |
while( (ret= aDrive.Format(fi)) == KErrNotReady && --attempt)
|
sl@0
|
399 |
{
|
sl@0
|
400 |
test.Printf(_L("attempt:%d\n"),attempt);
|
sl@0
|
401 |
User::After(1000000);
|
sl@0
|
402 |
}
|
sl@0
|
403 |
test(attempt);
|
sl@0
|
404 |
}
|
sl@0
|
405 |
else
|
sl@0
|
406 |
{
|
sl@0
|
407 |
test(ret==KErrNone);
|
sl@0
|
408 |
ret= aDrive.Format(fi);
|
sl@0
|
409 |
}
|
sl@0
|
410 |
}
|
sl@0
|
411 |
|
sl@0
|
412 |
|
sl@0
|
413 |
test.Printf(_L("call aDrive.Format(pos, length)...\n"));
|
sl@0
|
414 |
User::After(1000000);
|
sl@0
|
415 |
|
sl@0
|
416 |
__DECLARE_VAR_IN_CHUNK(TInt64, &pos);
|
sl@0
|
417 |
pos = 0;
|
sl@0
|
418 |
__DECLARE_VAR_IN_CHUNK(TInt, &length);
|
sl@0
|
419 |
length = aSize;
|
sl@0
|
420 |
|
sl@0
|
421 |
attempt = 100;
|
sl@0
|
422 |
__FLUSH_AND_CALL_API_METHOD(ret, aDrive.Format(pos, length));
|
sl@0
|
423 |
while( ret == KErrNotReady && --attempt)
|
sl@0
|
424 |
{
|
sl@0
|
425 |
User::After(1000000);
|
sl@0
|
426 |
ret= aDrive.Format(pos, length);
|
sl@0
|
427 |
}
|
sl@0
|
428 |
test(attempt);
|
sl@0
|
429 |
test_Equal(KErrNone, ret);
|
sl@0
|
430 |
|
sl@0
|
431 |
test.Printf(_L("End of TestFormatRelatedMethods)...\n"));
|
sl@0
|
432 |
}
|
sl@0
|
433 |
|
sl@0
|
434 |
void RestoreDriveState(void)
|
sl@0
|
435 |
{
|
sl@0
|
436 |
TBuf<3> bfDrv;
|
sl@0
|
437 |
|
sl@0
|
438 |
const TText KDrvLtr = 'A' + gFsDriveNumber;
|
sl@0
|
439 |
|
sl@0
|
440 |
bfDrv.Append(KDrvLtr);
|
sl@0
|
441 |
_LIT(KBP, ":\\");
|
sl@0
|
442 |
bfDrv.Append(KBP);
|
sl@0
|
443 |
|
sl@0
|
444 |
|
sl@0
|
445 |
TheFs.Connect();
|
sl@0
|
446 |
RFormat fmt;
|
sl@0
|
447 |
TInt count;
|
sl@0
|
448 |
|
sl@0
|
449 |
test(fmt.Open(TheFs, bfDrv, EHighDensity, count) == KErrNone);
|
sl@0
|
450 |
while (count > 0)
|
sl@0
|
451 |
{
|
sl@0
|
452 |
test.Printf(_L("\rfmt:%d "), count);
|
sl@0
|
453 |
test(fmt.Next(count) == KErrNone);
|
sl@0
|
454 |
}
|
sl@0
|
455 |
test.Printf(_L("\n"));
|
sl@0
|
456 |
fmt.Close();
|
sl@0
|
457 |
|
sl@0
|
458 |
TheFs.Close();
|
sl@0
|
459 |
}
|
sl@0
|
460 |
|
sl@0
|
461 |
|
sl@0
|
462 |
TInt FindDataPagingDrive()
|
sl@0
|
463 |
/**
|
sl@0
|
464 |
Find the drive containing a swap partition.
|
sl@0
|
465 |
|
sl@0
|
466 |
@return Local drive identifier.
|
sl@0
|
467 |
*/
|
sl@0
|
468 |
{
|
sl@0
|
469 |
TInt drive = KErrNotFound;
|
sl@0
|
470 |
|
sl@0
|
471 |
test.Printf(_L("Searching for data paging drive:\n"));
|
sl@0
|
472 |
|
sl@0
|
473 |
for(TInt i = 0; i < KMaxLocalDrives && drive < 0; ++i)
|
sl@0
|
474 |
{
|
sl@0
|
475 |
RLocalDrive d;
|
sl@0
|
476 |
TBool change = EFalse;
|
sl@0
|
477 |
|
sl@0
|
478 |
if(d.Connect(i, change) == KErrNone)
|
sl@0
|
479 |
{
|
sl@0
|
480 |
TLocalDriveCapsV4 dc;
|
sl@0
|
481 |
TPckg<TLocalDriveCapsV4> capsPack(dc);
|
sl@0
|
482 |
|
sl@0
|
483 |
if(d.Caps(capsPack) == KErrNone)
|
sl@0
|
484 |
{
|
sl@0
|
485 |
if ((dc.iMediaAtt & KMediaAttPageable) &&
|
sl@0
|
486 |
(dc.iPartitionType == KPartitionTypePagedData))
|
sl@0
|
487 |
{
|
sl@0
|
488 |
test.Printf(_L("Found swap partition on local drive %d\n"), i);
|
sl@0
|
489 |
drive = i;
|
sl@0
|
490 |
|
sl@0
|
491 |
TPageDeviceInfo pageDeviceInfo;
|
sl@0
|
492 |
|
sl@0
|
493 |
TPtr8 pageDeviceInfoBuf((TUint8*) &pageDeviceInfo, sizeof(pageDeviceInfo));
|
sl@0
|
494 |
pageDeviceInfoBuf.FillZ();
|
sl@0
|
495 |
|
sl@0
|
496 |
TInt r = d.QueryDevice(RLocalDrive::EQueryPageDeviceInfo, pageDeviceInfoBuf);
|
sl@0
|
497 |
|
sl@0
|
498 |
test.Printf(_L("EQueryPageDeviceInfo on local drive %d returned %d\n"), i, r);
|
sl@0
|
499 |
}
|
sl@0
|
500 |
}
|
sl@0
|
501 |
d.Close();
|
sl@0
|
502 |
}
|
sl@0
|
503 |
}
|
sl@0
|
504 |
return drive;
|
sl@0
|
505 |
}
|
sl@0
|
506 |
|
sl@0
|
507 |
TDes& GetSerialNumber(TLocalDriveCapsV5& aCaps)
|
sl@0
|
508 |
{
|
sl@0
|
509 |
static TBuf16<80> serialNumBuf;
|
sl@0
|
510 |
|
sl@0
|
511 |
serialNumBuf.SetLength(0);
|
sl@0
|
512 |
|
sl@0
|
513 |
for (TUint n=0; n<aCaps.iSerialNumLength; n+=16)
|
sl@0
|
514 |
{
|
sl@0
|
515 |
for (TUint m=n; m<n+16; m++)
|
sl@0
|
516 |
{
|
sl@0
|
517 |
TBuf16<3> hexBuf;
|
sl@0
|
518 |
hexBuf.Format(_L("%02X "), aCaps.iSerialNum[m]);
|
sl@0
|
519 |
serialNumBuf.Append(hexBuf);
|
sl@0
|
520 |
}
|
sl@0
|
521 |
}
|
sl@0
|
522 |
|
sl@0
|
523 |
return serialNumBuf;
|
sl@0
|
524 |
}
|
sl@0
|
525 |
|
sl@0
|
526 |
TDes& GetSerialNumber(TMediaSerialNumber& aSerialNum)
|
sl@0
|
527 |
{
|
sl@0
|
528 |
static TBuf16<80> serialNumBuf;
|
sl@0
|
529 |
|
sl@0
|
530 |
serialNumBuf.SetLength(0);
|
sl@0
|
531 |
|
sl@0
|
532 |
TInt len = aSerialNum.Length();
|
sl@0
|
533 |
for (TInt n=0; n<len; n+=16)
|
sl@0
|
534 |
{
|
sl@0
|
535 |
for (TInt m=n; m<n+16; m++)
|
sl@0
|
536 |
{
|
sl@0
|
537 |
TBuf16<3> hexBuf;
|
sl@0
|
538 |
hexBuf.Format(_L("%02X "), aSerialNum[m]);
|
sl@0
|
539 |
serialNumBuf.Append(hexBuf);
|
sl@0
|
540 |
}
|
sl@0
|
541 |
}
|
sl@0
|
542 |
|
sl@0
|
543 |
return serialNumBuf;
|
sl@0
|
544 |
}
|
sl@0
|
545 |
|
sl@0
|
546 |
TPtrC GetMediaType(TMediaType aType)
|
sl@0
|
547 |
{
|
sl@0
|
548 |
switch(aType)
|
sl@0
|
549 |
{
|
sl@0
|
550 |
case EMediaNotPresent: return _L("NotPresent");
|
sl@0
|
551 |
case EMediaUnknown: return _L("Unknown");
|
sl@0
|
552 |
case EMediaFloppy: return _L("Floppy");
|
sl@0
|
553 |
case EMediaHardDisk: return _L("HardDisk");
|
sl@0
|
554 |
case EMediaCdRom: return _L("CdRom");
|
sl@0
|
555 |
case EMediaRam: return _L("Ram");
|
sl@0
|
556 |
case EMediaFlash: return _L("Flash");
|
sl@0
|
557 |
case EMediaRom: return _L("Rom");
|
sl@0
|
558 |
case EMediaRemote: return _L("Remote");
|
sl@0
|
559 |
case EMediaNANDFlash: return _L("NANDFlash");
|
sl@0
|
560 |
case EMediaRotatingMedia : return _L("RotatingMedia ");
|
sl@0
|
561 |
default:return _L("Unrecognised");
|
sl@0
|
562 |
}
|
sl@0
|
563 |
}
|
sl@0
|
564 |
|
sl@0
|
565 |
TPtrC GetFileSystemId(TUint aFileSystemId)
|
sl@0
|
566 |
{
|
sl@0
|
567 |
switch(aFileSystemId)
|
sl@0
|
568 |
{
|
sl@0
|
569 |
case KDriveFileSysFAT: return _L("FAT");
|
sl@0
|
570 |
case KDriveFileSysROM: return _L("ROM");
|
sl@0
|
571 |
case KDriveFileSysLFFS: return _L("LFFS");
|
sl@0
|
572 |
case KDriveFileSysROFS: return _L("ROFS");
|
sl@0
|
573 |
case KDriveFileNone: return _L("None");
|
sl@0
|
574 |
default:return _L("Unrecognised");
|
sl@0
|
575 |
}
|
sl@0
|
576 |
}
|
sl@0
|
577 |
|
sl@0
|
578 |
|
sl@0
|
579 |
|
sl@0
|
580 |
// Find a drive which contains the swap partition; if this succeeds, find and return the FAT drive on the same media.
|
sl@0
|
581 |
// This isn't fool-proof as it works by comparing media types/drive attributes/media attributes/serial numbers
|
sl@0
|
582 |
TInt FindFatDriveOnDataPagingMedia()
|
sl@0
|
583 |
{
|
sl@0
|
584 |
TInt dataPagingDrive = FindDataPagingDrive();
|
sl@0
|
585 |
if (dataPagingDrive == KErrNotFound)
|
sl@0
|
586 |
return KErrNotFound;
|
sl@0
|
587 |
|
sl@0
|
588 |
TInt fatDriveNumber = KErrNotFound;
|
sl@0
|
589 |
|
sl@0
|
590 |
test.Printf(_L("Finding Fat drive on datapaging media...\n"));
|
sl@0
|
591 |
|
sl@0
|
592 |
RLocalDrive dpDrive;
|
sl@0
|
593 |
TBool change = EFalse;
|
sl@0
|
594 |
|
sl@0
|
595 |
TInt r = dpDrive.Connect(dataPagingDrive, change);
|
sl@0
|
596 |
test(r == KErrNone);
|
sl@0
|
597 |
TLocalDriveCapsV5 dpDriveCaps;
|
sl@0
|
598 |
TPckg<TLocalDriveCapsV5> capsPack(dpDriveCaps);
|
sl@0
|
599 |
r = dpDrive.Caps(capsPack);
|
sl@0
|
600 |
test(r == KErrNone);
|
sl@0
|
601 |
TPtrC8 dpDriveSerialNum(dpDriveCaps.iSerialNum, dpDriveCaps.iSerialNumLength);
|
sl@0
|
602 |
dpDrive.Close();
|
sl@0
|
603 |
|
sl@0
|
604 |
TPtrC mediaType = GetMediaType(dpDriveCaps.iType);
|
sl@0
|
605 |
TPtrC fileSystemId = GetFileSystemId(dpDriveCaps.iFileSystemId);
|
sl@0
|
606 |
test.Printf(_L("Swap Drive %2d Type %S DriveAtt 0x%x MediaAtt 0x%x FileSysId %S SerialNum %S\n"),
|
sl@0
|
607 |
dataPagingDrive, &mediaType, dpDriveCaps.iDriveAtt, dpDriveCaps.iMediaAtt, &fileSystemId, &GetSerialNumber(dpDriveCaps));
|
sl@0
|
608 |
|
sl@0
|
609 |
// swap partition should be hidden
|
sl@0
|
610 |
test (dpDriveCaps.iDriveAtt & KDriveAttHidden);
|
sl@0
|
611 |
|
sl@0
|
612 |
// search for a FAT drive on the same media by searching for a drive which has
|
sl@0
|
613 |
// 'similar' drive & media attributes as the the swap drive
|
sl@0
|
614 |
|
sl@0
|
615 |
dpDriveCaps.iDriveAtt&= KDriveAttMask;
|
sl@0
|
616 |
dpDriveCaps.iMediaAtt&= KMediaAttMask;
|
sl@0
|
617 |
|
sl@0
|
618 |
for (TInt i = 0; i < KMaxLocalDrives /*&& fatDriveNumber == KErrNotFound*/; ++i)
|
sl@0
|
619 |
{
|
sl@0
|
620 |
RLocalDrive d;
|
sl@0
|
621 |
TBool change = EFalse;
|
sl@0
|
622 |
|
sl@0
|
623 |
if(d.Connect(i, change) == KErrNone)
|
sl@0
|
624 |
{
|
sl@0
|
625 |
TLocalDriveCapsV5 caps;
|
sl@0
|
626 |
TPckg<TLocalDriveCapsV5> capsPack(caps);
|
sl@0
|
627 |
|
sl@0
|
628 |
r = d.Caps(capsPack);
|
sl@0
|
629 |
if (r != KErrNone)
|
sl@0
|
630 |
continue;
|
sl@0
|
631 |
|
sl@0
|
632 |
TPtrC8 localSerialNum(caps.iSerialNum, caps.iSerialNumLength);
|
sl@0
|
633 |
TPtrC mediaType = GetMediaType(caps.iType);
|
sl@0
|
634 |
TPtrC fileSystemId = GetFileSystemId(caps.iFileSystemId);
|
sl@0
|
635 |
test.Printf(_L("Drive %2d Type %S DriveAtt 0x%x MediaAtt 0x%x FileSysId %S SerialNum %S\n"),
|
sl@0
|
636 |
i, &mediaType, caps.iDriveAtt, caps.iMediaAtt, &fileSystemId, &GetSerialNumber(caps));
|
sl@0
|
637 |
|
sl@0
|
638 |
// Turn off bits which may be different
|
sl@0
|
639 |
caps.iDriveAtt&= KDriveAttMask;
|
sl@0
|
640 |
caps.iMediaAtt&= KMediaAttMask;
|
sl@0
|
641 |
|
sl@0
|
642 |
if ((caps.iType == dpDriveCaps.iType) &&
|
sl@0
|
643 |
(caps.iDriveAtt == dpDriveCaps.iDriveAtt) &&
|
sl@0
|
644 |
(caps.iMediaAtt == dpDriveCaps.iMediaAtt) &&
|
sl@0
|
645 |
(localSerialNum.Compare(dpDriveSerialNum) == 0) &&
|
sl@0
|
646 |
(caps.iFileSystemId == KDriveFileSysFAT))
|
sl@0
|
647 |
{
|
sl@0
|
648 |
if (fatDriveNumber == KErrNotFound)
|
sl@0
|
649 |
fatDriveNumber = i;
|
sl@0
|
650 |
}
|
sl@0
|
651 |
d.Close();
|
sl@0
|
652 |
}
|
sl@0
|
653 |
}
|
sl@0
|
654 |
|
sl@0
|
655 |
|
sl@0
|
656 |
return fatDriveNumber;
|
sl@0
|
657 |
}
|
sl@0
|
658 |
|
sl@0
|
659 |
|
sl@0
|
660 |
// Find and return the File Server drive number (0-25) corresponing to the passed local drive number
|
sl@0
|
661 |
// This isn't fool-proof as it works by comparing media types/drive attributes/media attributes/serial numbers
|
sl@0
|
662 |
TInt FindFsDriveNumber(TInt aLocalDriveNumber)
|
sl@0
|
663 |
{
|
sl@0
|
664 |
TInt fsDriveNumber = KErrNotFound;
|
sl@0
|
665 |
|
sl@0
|
666 |
RLocalDrive dpDrive;
|
sl@0
|
667 |
TBool change = EFalse;
|
sl@0
|
668 |
|
sl@0
|
669 |
TInt r = dpDrive.Connect(aLocalDriveNumber, change);
|
sl@0
|
670 |
test(r == KErrNone);
|
sl@0
|
671 |
TLocalDriveCapsV5 dpDriveCaps;
|
sl@0
|
672 |
TPckg<TLocalDriveCapsV5> capsPack(dpDriveCaps);
|
sl@0
|
673 |
r = dpDrive.Caps(capsPack);
|
sl@0
|
674 |
test(r == KErrNone);
|
sl@0
|
675 |
TPtrC8 dpDriveSerialNum(dpDriveCaps.iSerialNum, dpDriveCaps.iSerialNumLength);
|
sl@0
|
676 |
dpDrive.Close();
|
sl@0
|
677 |
|
sl@0
|
678 |
dpDriveCaps.iDriveAtt&= KDriveAttMask;
|
sl@0
|
679 |
dpDriveCaps.iMediaAtt&= KMediaAttMask;
|
sl@0
|
680 |
|
sl@0
|
681 |
RFs fs;
|
sl@0
|
682 |
r = fs.Connect();
|
sl@0
|
683 |
test(r == KErrNone);
|
sl@0
|
684 |
|
sl@0
|
685 |
TDriveInfo di;
|
sl@0
|
686 |
|
sl@0
|
687 |
for (TInt n=0; n<KMaxDrives /* && fsDriveNumber == KErrNotFound*/; n++)
|
sl@0
|
688 |
{
|
sl@0
|
689 |
r = fs.Drive(di, n);
|
sl@0
|
690 |
|
sl@0
|
691 |
TMediaSerialNumber serialNum;
|
sl@0
|
692 |
fs.GetMediaSerialNumber(serialNum, n);
|
sl@0
|
693 |
|
sl@0
|
694 |
TFSName fsName;
|
sl@0
|
695 |
fs.FileSystemName(fsName, n);
|
sl@0
|
696 |
|
sl@0
|
697 |
if (r != KErrNone )
|
sl@0
|
698 |
continue;
|
sl@0
|
699 |
|
sl@0
|
700 |
TPtrC mediaType = GetMediaType(di.iType);
|
sl@0
|
701 |
test.Printf(_L("Drive %C Type %S DriveAtt 0x%x MediaAtt 0x%x FileSysId %S SerialNum %S\n"),
|
sl@0
|
702 |
'A' + n, &mediaType, di.iDriveAtt, di.iMediaAtt, &fsName, &GetSerialNumber(serialNum));
|
sl@0
|
703 |
|
sl@0
|
704 |
di.iDriveAtt&= KDriveAttMask;
|
sl@0
|
705 |
di.iMediaAtt&= KMediaAttMask;
|
sl@0
|
706 |
|
sl@0
|
707 |
if ((di.iType == dpDriveCaps.iType) &&
|
sl@0
|
708 |
(di.iDriveAtt == dpDriveCaps.iDriveAtt) &&
|
sl@0
|
709 |
(di.iMediaAtt == dpDriveCaps.iMediaAtt) &&
|
sl@0
|
710 |
(serialNum.Compare(dpDriveSerialNum) == 0))
|
sl@0
|
711 |
{
|
sl@0
|
712 |
if (fsDriveNumber == KErrNotFound)
|
sl@0
|
713 |
fsDriveNumber = n;
|
sl@0
|
714 |
}
|
sl@0
|
715 |
}
|
sl@0
|
716 |
|
sl@0
|
717 |
fs.Close();
|
sl@0
|
718 |
|
sl@0
|
719 |
return fsDriveNumber;
|
sl@0
|
720 |
}
|
sl@0
|
721 |
|
sl@0
|
722 |
TInt E32Main()
|
sl@0
|
723 |
{
|
sl@0
|
724 |
|
sl@0
|
725 |
// To use in command line
|
sl@0
|
726 |
TBool callPasswordRelated = EFalse;
|
sl@0
|
727 |
|
sl@0
|
728 |
TBuf<256> cmdline;
|
sl@0
|
729 |
User::CommandLine(cmdline);
|
sl@0
|
730 |
TLex lex(cmdline);
|
sl@0
|
731 |
|
sl@0
|
732 |
FOREVER
|
sl@0
|
733 |
{
|
sl@0
|
734 |
TPtrC token=lex.NextToken();
|
sl@0
|
735 |
if(token.Length() != 0)
|
sl@0
|
736 |
{
|
sl@0
|
737 |
if (token == _L("-p"))
|
sl@0
|
738 |
{
|
sl@0
|
739 |
callPasswordRelated = ETrue;
|
sl@0
|
740 |
}
|
sl@0
|
741 |
else
|
sl@0
|
742 |
test.Printf(_L("Unknown argument '%S' was ignored.\n"), &token);
|
sl@0
|
743 |
}
|
sl@0
|
744 |
else
|
sl@0
|
745 |
break;
|
sl@0
|
746 |
|
sl@0
|
747 |
}
|
sl@0
|
748 |
|
sl@0
|
749 |
test.Title();
|
sl@0
|
750 |
TInt r;
|
sl@0
|
751 |
|
sl@0
|
752 |
test.Start(_L("Verify the global and this process's data paging attributes"));
|
sl@0
|
753 |
test_KErrNone(GetGlobalPolicies());
|
sl@0
|
754 |
|
sl@0
|
755 |
if (IsDataPagingSupported())
|
sl@0
|
756 |
{
|
sl@0
|
757 |
test.Printf(_L("Data paging supported\n"));
|
sl@0
|
758 |
}
|
sl@0
|
759 |
else
|
sl@0
|
760 |
{// The system doesn't support data paging so this process shouldn't be
|
sl@0
|
761 |
// data paged.
|
sl@0
|
762 |
test.Printf(_L("Data paging not supported\n"));
|
sl@0
|
763 |
test_Equal(EFalse, gProcessPaged);
|
sl@0
|
764 |
test.End();
|
sl@0
|
765 |
return 0;
|
sl@0
|
766 |
}
|
sl@0
|
767 |
|
sl@0
|
768 |
r = UserHal::PageSizeInBytes(gPageSize);
|
sl@0
|
769 |
test_KErrNone(r);
|
sl@0
|
770 |
|
sl@0
|
771 |
TInt fatDriveNumber = FindFatDriveOnDataPagingMedia();
|
sl@0
|
772 |
if (fatDriveNumber == KErrNotFound)
|
sl@0
|
773 |
{
|
sl@0
|
774 |
test.Printf(_L("Could not find FAT partition on data paging media\n"));
|
sl@0
|
775 |
test(0);
|
sl@0
|
776 |
}
|
sl@0
|
777 |
gFsDriveNumber = FindFsDriveNumber(fatDriveNumber);
|
sl@0
|
778 |
if (gFsDriveNumber == KErrNotFound)
|
sl@0
|
779 |
{
|
sl@0
|
780 |
test.Printf(_L("Could not File Server drive\n"));
|
sl@0
|
781 |
test(0);
|
sl@0
|
782 |
}
|
sl@0
|
783 |
|
sl@0
|
784 |
test.Printf(_L("Found FAT drive on %C: (local drive #%d) on data paging media\n"), 'A'+gFsDriveNumber, fatDriveNumber);
|
sl@0
|
785 |
|
sl@0
|
786 |
// User::SetDebugMask(0x10000000); //KMMU2
|
sl@0
|
787 |
// User::SetDebugMask(0x40000000, 1); //KPAGING
|
sl@0
|
788 |
|
sl@0
|
789 |
test.Next(_L("Create a paged chunk"));
|
sl@0
|
790 |
CreatePagedChunk(KChunkSizeInPages, KClearValue);
|
sl@0
|
791 |
|
sl@0
|
792 |
test.Next(_L("Chunk created, declare variables"));
|
sl@0
|
793 |
|
sl@0
|
794 |
__DECLARE_VAR_IN_CHUNK(TBusLocalDrive, &drive)
|
sl@0
|
795 |
TInt driveSize = TestDriveConnectAndCaps(drive, fatDriveNumber);
|
sl@0
|
796 |
|
sl@0
|
797 |
TestDriveSizeRelatedMethods(drive, 0x00001000, driveSize);
|
sl@0
|
798 |
|
sl@0
|
799 |
TestWriteReadRelatedMethods(drive);
|
sl@0
|
800 |
|
sl@0
|
801 |
TestFormatRelatedMethods(drive, driveSize);
|
sl@0
|
802 |
|
sl@0
|
803 |
if(callPasswordRelated)
|
sl@0
|
804 |
{
|
sl@0
|
805 |
TestPasswordRelatedMethods(drive);
|
sl@0
|
806 |
}
|
sl@0
|
807 |
|
sl@0
|
808 |
//Disconnect drive
|
sl@0
|
809 |
test.Next(_L("call aDrive.Disconnect()..."));
|
sl@0
|
810 |
DPTest::FlushCache();
|
sl@0
|
811 |
drive.Disconnect();
|
sl@0
|
812 |
|
sl@0
|
813 |
gMyChunk.Close();
|
sl@0
|
814 |
|
sl@0
|
815 |
RestoreDriveState();
|
sl@0
|
816 |
|
sl@0
|
817 |
test.End();
|
sl@0
|
818 |
|
sl@0
|
819 |
User::SetDebugMask(0x00000000); // No debug info
|
sl@0
|
820 |
User::SetDebugMask(0x00000000, 1); //No KPAGING
|
sl@0
|
821 |
return 0;
|
sl@0
|
822 |
}
|