author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 14 May 2010 17:13:29 +0300 | |
changeset 109 | b3a1d9898418 |
parent 0 | a41df078684a |
child 257 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 1998-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 |
// f32test\fsstress\t_rmain.cpp |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#if !defined(__F32FILE_H__) |
|
19 |
#include <f32file.h> |
|
20 |
#endif |
|
21 |
#if !defined(__E32TEST_H__) |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
22 |
#define __E32TEST_EXTENSION__ |
0 | 23 |
#include <e32test.h> |
24 |
#endif |
|
25 |
#if !defined(__E32HAL_H__) |
|
26 |
#include <e32hal.h> |
|
27 |
#endif |
|
28 |
#if !defined(__E32MATH_H__) |
|
29 |
#include <e32math.h> |
|
30 |
#endif |
|
31 |
#if !defined(__F32DBG_H__) |
|
32 |
#include <f32dbg.h> |
|
33 |
#endif |
|
34 |
#include "t_std.h" |
|
35 |
||
36 |
||
37 |
GLDEF_D RFs TheFs; |
|
38 |
GLDEF_D TFileName gSessionPath; |
|
39 |
GLDEF_D TInt gAllocFailOff=KAllocFailureOff; |
|
40 |
GLDEF_D TInt gAllocFailOn=KAllocFailureOff; |
|
41 |
GLDEF_D TInt64 gSeed=51703; |
|
42 |
const TInt KHeapSize=0x2000; |
|
43 |
||
44 |
||
45 |
||
46 |
GLDEF_C void TurnAllocFailureOff() |
|
47 |
// |
|
48 |
// Switch off all allocFailure |
|
49 |
// |
|
50 |
{ |
|
51 |
||
52 |
test.Printf(_L("Disable Alloc Failure\n")); |
|
53 |
TheFs.SetAllocFailure(gAllocFailOff); |
|
54 |
gAllocFailOn=KAllocFailureOff; |
|
55 |
} |
|
56 |
||
57 |
GLDEF_C void TurnAllocFailureOn() |
|
58 |
// |
|
59 |
// Switch off all allocFailure |
|
60 |
// |
|
61 |
{ |
|
62 |
||
63 |
test.Printf(_L("Enable Alloc Failure\n")); |
|
64 |
gAllocFailOn=KAllocFailureOn; |
|
65 |
TheFs.SetAllocFailure(gAllocFailOn); |
|
66 |
} |
|
67 |
||
68 |
||
69 |
GLDEF_C void Format(TInt aDrive) |
|
70 |
// |
|
71 |
// Format current drive |
|
72 |
// |
|
73 |
{ |
|
74 |
||
75 |
test.Next(_L("Format")); |
|
76 |
TBuf<4> driveBuf=_L("?:\\"); |
|
77 |
driveBuf[0]=(TText)(aDrive+'A'); |
|
78 |
RFormat format; |
|
79 |
TInt count; |
|
80 |
TInt r=format.Open(TheFs,driveBuf,EHighDensity,count); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
81 |
test_KErrNone(r); |
0 | 82 |
while(count) |
83 |
{ |
|
84 |
TInt r=format.Next(count); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
85 |
test_KErrNone(r); |
0 | 86 |
} |
87 |
format.Close(); |
|
88 |
} |
|
89 |
||
90 |
LOCAL_C void PushLotsL() |
|
91 |
// |
|
92 |
// Expand the cleanup stack |
|
93 |
// |
|
94 |
{ |
|
95 |
TInt i; |
|
96 |
for(i=0;i<1000;i++) |
|
97 |
CleanupStack::PushL((CBase*)NULL); |
|
98 |
CleanupStack::Pop(1000); |
|
99 |
} |
|
100 |
||
101 |
||
102 |
LOCAL_C void DoTests(TInt aDrive) |
|
103 |
// |
|
104 |
// Do testing on aDrive |
|
105 |
// |
|
106 |
{ |
|
107 |
||
108 |
gSessionPath=_L("?:\\F32-TST\\"); |
|
109 |
TChar driveLetter; |
|
110 |
TInt r=TheFs.DriveToChar(aDrive,driveLetter); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
111 |
test_KErrNone(r); |
0 | 112 |
gSessionPath[0]=(TText)driveLetter; |
113 |
r=TheFs.SetSessionPath(gSessionPath); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
test_KErrNone(r); |
0 | 115 |
r=TheFs.MkDirAll(gSessionPath); |
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
test_Value(r, r == KErrNone || r==KErrAlreadyExists); |
0 | 117 |
TheFs.ResourceCountMarkStart(); |
118 |
||
119 |
switch(aDrive) |
|
120 |
{ |
|
121 |
#if defined (__MARM__) |
|
122 |
case EDriveC: |
|
123 |
TRAP(r,CallTestsYL(aDrive)); |
|
124 |
break; |
|
125 |
case EDriveD: |
|
126 |
TRAP(r,CallTestsXL(aDrive)); |
|
127 |
break; |
|
128 |
#else |
|
129 |
case EDriveX: |
|
130 |
TRAP(r,CallTestsXL(aDrive)); |
|
131 |
break; |
|
132 |
case EDriveY: |
|
133 |
TRAP(r,CallTestsYL(aDrive)); |
|
134 |
break; |
|
135 |
#endif |
|
136 |
case EDriveQ: |
|
137 |
TRAP(r,CallTestsQL(aDrive)); |
|
138 |
break; |
|
139 |
default: |
|
140 |
TRAP(r,CallTestsDefaultL(aDrive)); |
|
141 |
break; |
|
142 |
} |
|
143 |
||
144 |
if (r==KErrNone) |
|
145 |
TheFs.ResourceCountMarkEnd(); |
|
146 |
else |
|
147 |
{ |
|
148 |
test.Printf(_L("Error: Leave %d\n"),r); |
|
149 |
test.Getch(); |
|
150 |
} |
|
151 |
} |
|
152 |
||
153 |
||
154 |
LOCAL_C TInt TestXDrive(TAny * /*anArg*/) |
|
155 |
// |
|
156 |
// MARM CF card drive testing (WINS emulates CF card on X) |
|
157 |
// |
|
158 |
{ |
|
159 |
CTrapCleanup* cleanup; |
|
160 |
cleanup=CTrapCleanup::New(); |
|
161 |
||
162 |
testx.Title(); |
|
163 |
||
164 |
TInt r=TheFs.Connect(); |
|
165 |
testx(r==KErrNone); |
|
166 |
// TheFs.SetAllocFailure(gAllocFailOn); |
|
167 |
||
168 |
#if defined (__WINS__) |
|
169 |
||
170 |
// Run tests on WINS drive X: |
|
171 |
testx.Start(_L("Starting tests on drive X:")); |
|
172 |
DoTests(EDriveX); |
|
173 |
||
174 |
#elif defined (__MARM__) |
|
175 |
// Run tests on MARM drive D: |
|
176 |
testx.Start(_L("Starting tests on drive D:")); |
|
177 |
DoTests(EDriveD); |
|
178 |
#endif |
|
179 |
||
180 |
// TheFs.SetAllocFailure(gAllocFailOff); |
|
181 |
delete cleanup; |
|
182 |
testx.End(); |
|
183 |
||
184 |
return KErrNone; |
|
185 |
} |
|
186 |
||
187 |
||
188 |
LOCAL_C TInt TestYDrive(TAny * /*anArg*/) |
|
189 |
// |
|
190 |
// MARM RAM drive testing (WINS emulates FAT filesystem on Y) |
|
191 |
// |
|
192 |
{ |
|
193 |
CTrapCleanup* cleanup; |
|
194 |
cleanup=CTrapCleanup::New(); |
|
195 |
||
196 |
testy.Title(); |
|
197 |
TInt r=TheFs.Connect(); |
|
198 |
testy(r==KErrNone); |
|
199 |
||
200 |
// TheFs.SetAllocFailure(gAllocFailOn); |
|
201 |
||
202 |
#if defined (__WINS__) |
|
203 |
||
204 |
// Run tests on WINS drive Y: |
|
205 |
testy.Start(_L("Starting tests on drive Y:")); |
|
206 |
DoTests(EDriveY); |
|
207 |
||
208 |
#elif defined (__MARM__) |
|
209 |
||
210 |
// Run tests on MARM drive C: |
|
211 |
testy.Start(_L("Starting tests on drive C:")); |
|
212 |
DoTests(EDriveC); |
|
213 |
#endif |
|
214 |
||
215 |
// TheFs.SetAllocFailure(gAllocFailOff); |
|
216 |
delete cleanup; |
|
217 |
testy.End(); |
|
218 |
return KErrNone; |
|
219 |
} |
|
220 |
||
221 |
||
222 |
LOCAL_C TInt TestRemoteDrive(TAny * /*anArg*/) |
|
223 |
// |
|
224 |
// Run tests on remote drive Q: |
|
225 |
// |
|
226 |
{ |
|
227 |
CTrapCleanup* cleanup; |
|
228 |
cleanup=CTrapCleanup::New(); |
|
229 |
||
230 |
testq.Title(); |
|
231 |
testq.Start(_L("Starting async tests...")); |
|
232 |
||
233 |
TInt r=TheFs.Connect(); |
|
234 |
testq(r==KErrNone); |
|
235 |
// TheFs.SetAllocFailure(gAllocFailOn); |
|
236 |
||
237 |
testq.Next(_L("Mount Remote Drive simulator on Q:")); |
|
238 |
||
239 |
r=TheFs.AddFileSystem(_L("T_REMFSY")); |
|
240 |
testq.Next(_L("Add remote file system")); |
|
241 |
testq.Printf(_L("AddFileSystem returned %d\n"),r); |
|
242 |
// testq(r==KErrNone || r==KErrAlreadyExists); |
|
243 |
||
244 |
r=TheFs.MountFileSystem(_L("T_REMFSY"),EDriveQ); |
|
245 |
testq.Next(_L("Mount remote file system")); |
|
246 |
testq.Printf(_L("MountFileSystem returned %d\n"),r); |
|
247 |
testq(r==KErrNone || r==KErrCorrupt || r==KErrNotReady || r==KErrAlreadyExists); |
|
248 |
if (r==KErrCorrupt || r==KErrNotReady) |
|
249 |
Format(EDriveQ); |
|
250 |
||
251 |
DoTests(EDriveQ); |
|
252 |
// TheFs.SetAllocFailure(gAllocFailOff); |
|
253 |
||
254 |
delete cleanup; |
|
255 |
testq.End(); |
|
256 |
return KErrNone; |
|
257 |
} |
|
258 |
||
259 |
||
260 |
GLDEF_C TInt E32Main() |
|
261 |
// |
|
262 |
// Test with drive nearly full |
|
263 |
// |
|
264 |
{ |
|
265 |
CTrapCleanup* cleanup; |
|
266 |
cleanup=CTrapCleanup::New(); |
|
267 |
TRAPD(r,PushLotsL()); |
|
268 |
__UHEAP_MARK; |
|
269 |
||
270 |
test.Title(); |
|
271 |
test.Start(_L("Starting tests...")); |
|
272 |
r=TheFs.Connect(); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
273 |
test_KErrNone(r); |
0 | 274 |
// TheFs.SetAllocFailure(gAllocFailOn); |
275 |
||
276 |
// Default drive testing |
|
277 |
DoTests(KDefaultDrive); |
|
278 |
||
279 |
// Remote drive testing |
|
280 |
RThread clientThreadQ; |
|
281 |
r=clientThreadQ.Create(_L("TestRemoteDrive"), TestRemoteDrive, KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
282 |
test_KErrNone(r); |
0 | 283 |
TRequestStatus statq; |
284 |
clientThreadQ.Logon(statq); |
|
285 |
test.Next(_L("Resume clientThreadQ")); |
|
286 |
clientThreadQ.Resume(); |
|
287 |
||
288 |
// MARM CF card drive testing (WINS emulates CF card on X) |
|
289 |
RThread clientThreadX; |
|
290 |
r=clientThreadX.Create(_L("TestXDrive"), TestXDrive, KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
test_KErrNone(r); |
0 | 292 |
TRequestStatus statx; |
293 |
clientThreadX.Logon(statx); |
|
294 |
test.Next(_L("Resume clientThreadX")); |
|
295 |
clientThreadX.Resume(); |
|
296 |
||
297 |
// MARM RAM drive testing (WINS emulates FAT filesystem on Y) |
|
298 |
RThread clientThreadY; |
|
299 |
r=clientThreadY.Create(_L("TestYDrive"), TestYDrive, KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
109
b3a1d9898418
Revision: 201019
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
test_KErrNone(r); |
0 | 301 |
TRequestStatus staty; |
302 |
clientThreadY.Logon(staty); |
|
303 |
test.Next(_L("Resume clientThreadY")); |
|
304 |
clientThreadY.Resume(); |
|
305 |
||
306 |
User::WaitForRequest(statx); |
|
307 |
User::WaitForRequest(staty); |
|
308 |
User::WaitForRequest(statq); |
|
309 |
||
310 |
clientThreadQ.Close(); |
|
311 |
clientThreadX.Close(); |
|
312 |
clientThreadY.Close(); |
|
313 |
||
314 |
// TheFs.SetAllocFailure(gAllocFailOff); |
|
315 |
TheFs.Close(); |
|
316 |
||
317 |
test.End(); |
|
318 |
test.Close(); |
|
319 |
__UHEAP_MARKEND; |
|
320 |
delete cleanup; |
|
321 |
return(KErrNone); |
|
322 |
} |