Update contrib.
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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // f32test\fsstress\t_rmain.cpp
18 #if !defined(__F32FILE_H__)
21 #if !defined(__E32TEST_H__)
24 #if !defined(__E32HAL_H__)
27 #if !defined(__E32MATH_H__)
30 #if !defined(__F32DBG_H__)
37 GLDEF_D TFileName gSessionPath;
38 GLDEF_D TInt gAllocFailOff=KAllocFailureOff;
39 GLDEF_D TInt gAllocFailOn=KAllocFailureOff;
40 GLDEF_D TInt64 gSeed=51703;
41 const TInt KHeapSize=0x2000;
45 GLDEF_C void TurnAllocFailureOff()
47 // Switch off all allocFailure
51 test.Printf(_L("Disable Alloc Failure\n"));
52 TheFs.SetAllocFailure(gAllocFailOff);
53 gAllocFailOn=KAllocFailureOff;
56 GLDEF_C void TurnAllocFailureOn()
58 // Switch off all allocFailure
62 test.Printf(_L("Enable Alloc Failure\n"));
63 gAllocFailOn=KAllocFailureOn;
64 TheFs.SetAllocFailure(gAllocFailOn);
68 GLDEF_C void Format(TInt aDrive)
70 // Format current drive
74 test.Next(_L("Format"));
75 TBuf<4> driveBuf=_L("?:\\");
76 driveBuf[0]=(TText)(aDrive+'A');
79 TInt r=format.Open(TheFs,driveBuf,EHighDensity,count);
83 TInt r=format.Next(count);
89 LOCAL_C void PushLotsL()
91 // Expand the cleanup stack
96 CleanupStack::PushL((CBase*)NULL);
97 CleanupStack::Pop(1000);
101 LOCAL_C void DoTests(TInt aDrive)
103 // Do testing on aDrive
107 gSessionPath=_L("?:\\F32-TST\\");
109 TInt r=TheFs.DriveToChar(aDrive,driveLetter);
111 gSessionPath[0]=(TText)driveLetter;
112 r=TheFs.SetSessionPath(gSessionPath);
114 r=TheFs.MkDirAll(gSessionPath);
115 test(r==KErrNone || r==KErrAlreadyExists);
116 TheFs.ResourceCountMarkStart();
120 #if defined (__MARM__)
122 TRAP(r,CallTestsYL(aDrive));
125 TRAP(r,CallTestsXL(aDrive));
129 TRAP(r,CallTestsXL(aDrive));
132 TRAP(r,CallTestsYL(aDrive));
136 TRAP(r,CallTestsQL(aDrive));
139 TRAP(r,CallTestsDefaultL(aDrive));
144 TheFs.ResourceCountMarkEnd();
147 test.Printf(_L("Error: Leave %d\n"),r);
153 LOCAL_C TInt TestXDrive(TAny * /*anArg*/)
155 // MARM CF card drive testing (WINS emulates CF card on X)
158 CTrapCleanup* cleanup;
159 cleanup=CTrapCleanup::New();
163 TInt r=TheFs.Connect();
165 // TheFs.SetAllocFailure(gAllocFailOn);
167 #if defined (__WINS__)
169 // Run tests on WINS drive X:
170 testx.Start(_L("Starting tests on drive X:"));
173 #elif defined (__MARM__)
174 // Run tests on MARM drive D:
175 testx.Start(_L("Starting tests on drive D:"));
179 // TheFs.SetAllocFailure(gAllocFailOff);
187 LOCAL_C TInt TestYDrive(TAny * /*anArg*/)
189 // MARM RAM drive testing (WINS emulates FAT filesystem on Y)
192 CTrapCleanup* cleanup;
193 cleanup=CTrapCleanup::New();
196 TInt r=TheFs.Connect();
199 // TheFs.SetAllocFailure(gAllocFailOn);
201 #if defined (__WINS__)
203 // Run tests on WINS drive Y:
204 testy.Start(_L("Starting tests on drive Y:"));
207 #elif defined (__MARM__)
209 // Run tests on MARM drive C:
210 testy.Start(_L("Starting tests on drive C:"));
214 // TheFs.SetAllocFailure(gAllocFailOff);
221 LOCAL_C TInt TestRemoteDrive(TAny * /*anArg*/)
223 // Run tests on remote drive Q:
226 CTrapCleanup* cleanup;
227 cleanup=CTrapCleanup::New();
230 testq.Start(_L("Starting async tests..."));
232 TInt r=TheFs.Connect();
234 // TheFs.SetAllocFailure(gAllocFailOn);
236 testq.Next(_L("Mount Remote Drive simulator on Q:"));
238 r=TheFs.AddFileSystem(_L("T_REMFSY"));
239 testq.Next(_L("Add remote file system"));
240 testq.Printf(_L("AddFileSystem returned %d\n"),r);
241 // testq(r==KErrNone || r==KErrAlreadyExists);
243 r=TheFs.MountFileSystem(_L("T_REMFSY"),EDriveQ);
244 testq.Next(_L("Mount remote file system"));
245 testq.Printf(_L("MountFileSystem returned %d\n"),r);
246 testq(r==KErrNone || r==KErrCorrupt || r==KErrNotReady || r==KErrAlreadyExists);
247 if (r==KErrCorrupt || r==KErrNotReady)
251 // TheFs.SetAllocFailure(gAllocFailOff);
259 GLDEF_C TInt E32Main()
261 // Test with drive nearly full
264 CTrapCleanup* cleanup;
265 cleanup=CTrapCleanup::New();
266 TRAPD(r,PushLotsL());
270 test.Start(_L("Starting tests..."));
273 // TheFs.SetAllocFailure(gAllocFailOn);
275 // Default drive testing
276 DoTests(KDefaultDrive);
278 // Remote drive testing
279 RThread clientThreadQ;
280 r=clientThreadQ.Create(_L("TestRemoteDrive"), TestRemoteDrive, KDefaultStackSize,KHeapSize,KHeapSize,NULL);
282 TRequestStatus statq;
283 clientThreadQ.Logon(statq);
284 test.Next(_L("Resume clientThreadQ"));
285 clientThreadQ.Resume();
287 // MARM CF card drive testing (WINS emulates CF card on X)
288 RThread clientThreadX;
289 r=clientThreadX.Create(_L("TestXDrive"), TestXDrive, KDefaultStackSize,KHeapSize,KHeapSize,NULL);
291 TRequestStatus statx;
292 clientThreadX.Logon(statx);
293 test.Next(_L("Resume clientThreadX"));
294 clientThreadX.Resume();
296 // MARM RAM drive testing (WINS emulates FAT filesystem on Y)
297 RThread clientThreadY;
298 r=clientThreadY.Create(_L("TestYDrive"), TestYDrive, KDefaultStackSize,KHeapSize,KHeapSize,NULL);
300 TRequestStatus staty;
301 clientThreadY.Logon(staty);
302 test.Next(_L("Resume clientThreadY"));
303 clientThreadY.Resume();
305 User::WaitForRequest(statx);
306 User::WaitForRequest(staty);
307 User::WaitForRequest(statq);
309 clientThreadQ.Close();
310 clientThreadX.Close();
311 clientThreadY.Close();
313 // TheFs.SetAllocFailure(gAllocFailOff);