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