First public contribution.
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_remote.cpp
18 #if !defined(__F32FILE_H__)
21 #if !defined(__E32TEST_H__)
24 #if !defined(__T_STD_H__)
27 #if !defined(__T_REMFSY_H__)
31 GLDEF_D RTest test(_L("T_REMOTE - DEFAULT DRIVE"));
32 GLDEF_D RTest testx(_L("X Drive (WINS) <-> D Drive (MARM)"));
33 GLDEF_D RTest testy(_L("Y Drive (WINS) <-> C Drive (MARM)"));
34 GLDEF_D RTest testq(_L("REMOTE Q Drive"));
36 LOCAL_D TFileName gBatchFile;
37 LOCAL_D TBool gRunByBatch=EFalse;
39 GLDEF_D TFileName gExeFileName(RProcess().FileName());
42 INFORMATION - What this test is all about
44 T_REMOTE tests the asynchronous remote file system implementation, introduced in
45 F32 release 110 and refined in release 112. The test sets up and mounts four drives,
46 the default drive (usually C on WINS and MARM), a remote drive (Q) and two others, on
47 MARM these are C and D, on WINS these are X and Y. The remote filesystem is the only
48 system treated asynchronously by F32.
50 The test sets up a thread for each drive and runs a number of tests on each drive.
51 In the remote filesystem case, a dummy filesystem has been implemented, this is built
52 as T_REMFSY.fsy. The tests are designed to stress a number of fileserver API
53 functions. The test MultipleSessions() is adapted from another F32 test T_SESSION.
54 It sets up an array of fileserver connections and then uses each connection to run
55 a number of tests - alternating between connections to stress F32 as it does so. The
56 test should therefore be testing multiple fileserver connections on multiple drives -
57 the remote filesystem running concurrently with the other drives. There should be
58 no failure or confusion between fileserver sessions. Each drive has a separate test
59 console which should complete successfully.
61 NOTE: TO RUN THIS CARD SUCCESSFULLY ON MARM A CF CARD IS REQUIRED
65 LOCAL_C void Test0(RTest& aTest)
67 // Scan for open files - no sessions
70 aTest.Next(_L("Scan for open files with no sessions open"));
72 TOpenFileScan fileScan(TheFs);
76 TInt count=list->Count();
80 gBatchFile=(*list)[0].iName;
89 TEntry entry=(*list)[count];
90 aTest.Printf(_L("%d) EntryName = %S\n"),count,&entry.iName);
92 //aTest.Printf(_L("Test will fail unless files are closed.\n"));
93 //aTest.Printf(_L("Press any key ...\n"));
100 // This test is only called by default drive
104 test.Next(_L("Scan for open files - one session only"));
106 RFile file1,file2,file3;
108 fn = _L("Z:\\TEST\\T_FSRV.CPP");
109 fn[0] = gExeFileName[0];
110 TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
112 fn = _L("Z:\\TEST\\T_FILE.CPP");
113 fn[0] = gExeFileName[0];
114 r=file2.Open(TheFs,fn,EFileRead);
116 fn = _L("Z:\\TEST\\T_FSRV.CPP");
117 fn[0] = gExeFileName[0];
118 r=file3.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
122 TOpenFileScan fileScan(TheFs);
123 fileScan.NextL(list);
128 test(list->Count()==1);
129 TEntry entry=(*list)[0];
130 test(entry.iName.FindF(_L(".BAT"))>=0);
132 fileScan.NextL(list);
136 TInt count=list->Count();
138 TEntry entry=(*list)[0];
139 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
141 test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
143 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
144 TThreadId threadId=fileScan.ThreadId();
146 TThreadId currentId=current.Id();
147 test(threadId==currentId);
150 fileScan.NextL(list);
160 // Test openfilescan - empty, full, empty.
163 test.Next(_L("Scan for open files - empty sessions"));
166 TInt r=fs1.Connect();
175 RFile file1,file2,file3;
177 fn = _L("Z:\\TEST\\T_FSRV.CPP");
178 fn[0] = gExeFileName[0];
179 r=file1.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
181 fn = _L("Z:\\TEST\\T_FILE.CPP");
182 fn[0] = gExeFileName[0];
183 r=file2.Open(fs2,fn,EFileRead);
185 fn = _L("Z:\\TEST\\T_FSRV.CPP");
186 fn[0] = gExeFileName[0];
187 r=file3.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
191 TOpenFileScan fileScan(TheFs);
192 fileScan.NextL(list);
197 test(list->Count()==1);
198 TEntry entry=(*list)[0];
199 test(entry.iName.FindF(_L(".BAT"))>=0);
201 fileScan.NextL(list);
205 TInt count=list->Count();
207 TEntry entry=(*list)[0];
208 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
210 test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
212 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
213 TThreadId threadId=fileScan.ThreadId();
215 TThreadId currentId=current.Id();
216 test(threadId==currentId);
219 fileScan.NextL(list);
233 // Test openfilescan - empty, full, empty full
236 test.Next(_L("Scan for open files - multiple sessions"));
239 TInt r=fs1.Connect();
248 RFile file1,file2,file3;
250 fn = _L("Z:\\TEST\\T_FSRV.CPP");
251 fn[0] = gExeFileName[0];
252 r=file1.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
254 fn = _L("Z:\\TEST\\T_FILE.CPP");
255 fn[0] = gExeFileName[0];
256 r=file2.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
258 fn = _L("Z:\\TEST\\T_FSRV.CPP");
259 fn[0] = gExeFileName[0];
260 r=file3.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
263 r=file1.Open(fs4,fn,EFileRead|EFileShareReadersOnly);
265 fn = _L("Z:\\TEST\\T_FILE.CPP");
266 fn[0] = gExeFileName[0];
267 r=file2.Open(fs4,fn,EFileRead|EFileShareReadersOnly);
269 fn = _L("Z:\\TEST\\T_FSRV.CPP");
270 fn[0] = gExeFileName[0];
271 r=file3.Open(fs4,fn,EFileRead|EFileShareReadersOnly);
275 TOpenFileScan fileScan(TheFs);
276 fileScan.NextL(list);
281 test(list->Count()==1);
282 TEntry entry=(*list)[0];
283 test(entry.iName.FindF(_L(".BAT"))>=0);
285 fileScan.NextL(list);
289 TInt count=list->Count();
291 TEntry entry=(*list)[0];
292 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
294 test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
296 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
297 TThreadId threadId=fileScan.ThreadId();
299 TThreadId currentId=current.Id();
300 test(threadId==currentId);
303 fileScan.NextL(list);
308 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
310 test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
312 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
313 threadId=fileScan.ThreadId();
314 currentId=current.Id();
315 test(threadId==currentId);
318 fileScan.NextL(list);
332 // Test openfilescan - rdirs, empty, full, empty rdirs.
335 test.Next(_L("Scan for open files - check RDir sessions are ignored"));
339 TInt r=fs1.Connect();
348 RDir dir1,dir2,dir3,dir4;
349 fn = _L("Z:\\TEST\\*.XDE");
350 fn[0] = gExeFileName[0];
351 r=dir1.Open(TheFs,fn,KEntryAttMaskSupported);
353 r=dir2.Open(TheFs,fn,KEntryAttMaskSupported);
355 r=dir3.Open(TheFs,fn,KEntryAttMaskSupported);
357 r=dir4.Open(TheFs,fn,KEntryAttMaskSupported);
360 RFile file1,file2,file3;
361 fn = _L("Z:\\TEST\\T_FSRV.CPP");
362 fn[0] = gExeFileName[0];
363 r=file1.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
365 fn = _L("Z:\\TEST\\T_FILE.CPP");
366 fn[0] = gExeFileName[0];
367 r=file2.Open(fs2,fn,EFileRead);
369 fn = _L("Z:\\TEST\\T_FSRV.CPP");
370 fn[0] = gExeFileName[0];
371 r=file3.Open(fs2,fn,EFileRead|EFileShareReadersOnly);
374 RDir dir5,dir6,dir7,dir8;
375 fn = _L("Z:\\TEST\\*.XDE");
376 fn[0] = gExeFileName[0];
377 r=dir5.Open(fs4,fn,KEntryAttMaskSupported);
379 r=dir6.Open(fs4,fn,KEntryAttMaskSupported);
381 r=dir7.Open(fs4,fn,KEntryAttMaskSupported);
383 r=dir8.Open(fs4,fn,KEntryAttMaskSupported);
387 TOpenFileScan fileScan(TheFs);
388 fileScan.NextL(list);
393 test(list->Count()==1);
394 TEntry entry=(*list)[0];
395 test(entry.iName.FindF(_L(".BAT"))>=0);
397 fileScan.NextL(list);
401 TInt count=list->Count();
403 TEntry entry=(*list)[0];
404 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
406 test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
408 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
409 TThreadId threadId=fileScan.ThreadId();
411 TThreadId currentId=current.Id();
412 test(threadId==currentId);
415 fileScan.NextL(list);
421 dir1.Close(); dir2.Close();
422 dir3.Close(); dir4.Close();
423 dir5.Close(); dir6.Close();
424 dir7.Close(); dir8.Close();
425 fs1.Close(); fs2.Close();
426 fs3.Close(); fs4.Close();
435 test.Next(_L("Scan for open files - mixed RDirs and RFiles"));
437 RFile file1,file2,file3;
439 fn = _L("Z:\\TEST\\T_FSRV.CPP");
440 fn[0] = gExeFileName[0];
441 TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
443 fn = _L("Z:\\TEST\\T_FILE.CPP");
444 fn[0] = gExeFileName[0];
445 r=file2.Open(TheFs,fn,EFileRead);
447 fn = _L("Z:\\TEST\\T_FSRV.CPP");
448 fn[0] = gExeFileName[0];
449 r=file3.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
452 RDir dir1,dir2,dir3,dir4;
453 fn = _L("Z:\\TEST\\*.XDE");
454 fn[0] = gExeFileName[0];
455 r=dir1.Open(TheFs,fn,KEntryAttMaskSupported);
457 r=dir2.Open(TheFs,fn,KEntryAttMaskSupported);
459 r=dir3.Open(TheFs,fn,KEntryAttMaskSupported);
461 r=dir4.Open(TheFs,fn,KEntryAttMaskSupported);
465 TOpenFileScan fileScan(TheFs);
466 fileScan.NextL(list);
471 test(list->Count()==1);
472 TEntry entry=(*list)[0];
473 test(entry.iName.FindF(_L(".BAT"))>=0);
475 fileScan.NextL(list);
479 TInt count=list->Count();
481 TEntry entry=(*list)[0];
482 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
484 test(entry.iName.FindF(_L("T_FILE.CPP"))>=0);
486 test(entry.iName.FindF(_L("T_FSRV.CPP"))>=0);
487 TThreadId threadId=fileScan.ThreadId();
489 TThreadId currentId=current.Id();
490 test(threadId==currentId);
493 fileScan.NextL(list);
507 LOCAL_C void MultipleSessions(TInt aDrive, RTest& aTest)
509 // Create an array of fileserver sessions
510 // Create an array of TMultipleSessionTest objects
515 const TInt maxNumberSessions=10;
517 const TInt maxNumberSessions=20;
520 RFs session[maxNumberSessions];
521 TMultipleSessionTest testObject[maxNumberSessions];
525 for (; i<maxNumberSessions; i++)
527 r=session[i].Connect();
529 testObject[i].Initialise(session[i]);
530 testObject[i].SetSessionPath(aDrive);
531 testObject[i].RunTests(aTest); // Run the set of tests for each session
532 } // Leave each session open
535 for (i=0; i<(maxNumberSessions-1); i++)
537 // Alternate tests between open sessions
538 testObject[i].testSetVolume(aTest);
539 testObject[i+1].testInitialisation(aTest);
540 testObject[i].testSubst(aTest);
541 testObject[i+1].testInitialisation(aTest);
542 testObject[i].testInitialisation(aTest);
543 testObject[i].testDriveList(aTest);
544 testObject[i].MakeAndDeleteFiles(aTest);
545 // Close session[i] and check that session[i+1] is OK
547 testObject[i+1].testInitialisation(aTest);
548 testObject[i+1].testSetVolume(aTest);
549 testObject[i+1].testInitialisation(aTest);
550 testObject[i+1].testSubst(aTest);
551 testObject[i+1].testDriveList(aTest);
552 // Reconnect session[i]
553 r=session[i].Connect();
555 testObject[i].Initialise(session[i]);
556 testObject[i].SetSessionPath(aDrive);
557 testObject[i].testSetVolume(aTest);
558 testObject[i+1].testInitialisation(aTest);
559 testObject[i].testSubst(aTest);
560 testObject[i+1].testInitialisation(aTest);
561 testObject[i].testInitialisation(aTest);
562 testObject[i].testDriveList(aTest);
563 // Close session[i+1] and check that session[i] is OK
564 session[i+1].Close();
565 testObject[i].testInitialisation(aTest);
566 testObject[i].testSetVolume(aTest);
567 testObject[i].testInitialisation(aTest);
568 testObject[i].testSubst(aTest);
569 testObject[i].testDriveList(aTest);
570 // Reconnect session[i+1]
571 r=session[i+1].Connect();
573 testObject[i+1].Initialise(session[i+1]);
574 testObject[i+1].SetSessionPath(aDrive);
575 testObject[i].testSetVolume(aTest);
576 testObject[i+1].testInitialisation(aTest);
577 testObject[i].testSubst(aTest);
578 testObject[i+1].testInitialisation(aTest);
579 // Close session[i] and check that session[i+1] is OK
581 testObject[i+1].testInitialisation(aTest);
582 testObject[i+1].testSetVolume(aTest);
583 testObject[i+1].testInitialisation(aTest);
584 testObject[i+1].testSubst(aTest);
585 testObject[i+1].testDriveList(aTest);
587 if (i==maxNumberSessions-1) // Tidy up by closing remaining open session
589 session[i+1].Close();
594 GLDEF_C void CallTestsDefaultL(TInt aDrive)
596 // Call tests that may leave
605 MultipleSessions(aDrive,test);
608 GLDEF_C void CallTestsXL(TInt aDrive)
610 // Call tests for drive X
617 fn = _L("Z:\\TEST\\T_FSRV.CPP");
618 fn[0] = gExeFileName[0];
619 TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
622 MultipleSessions(aDrive,testx);
625 GLDEF_C void CallTestsYL(TInt aDrive)
627 // Call tests for drive Y
634 fn = _L("Z:\\TEST\\T_FSRV.CPP");
635 fn[0] = gExeFileName[0];
636 TInt r=file1.Open(TheFs,fn,EFileRead|EFileShareReadersOnly);
639 MultipleSessions(aDrive,testy);
642 GLDEF_C void CallTestsQL(TInt aDrive)
644 // Call tests for remote drive
650 testq.Printf(_L("This may take some time. Please be patient...\n"));
652 testq.Next(_L("Test remote drive with multiple sessions"));
653 MultipleSessions(aDrive,testq);
655 const TInt numberOfTests=10;
657 TPtrC record[numberOfTests];
660 for (;i<numberOfTests;i++)
663 record[i].Set(_L("Hubble_Bubble"));
665 record[i].Set(_L("Toil_and_Trouble"));
668 testq.Next(_L("Create a file 'TEXTFILE.TXT' on the remote drive"));
670 TInt r=f.Replace(TheFs,_L("TEXTFILE.TXT"),0);
675 testq.Next(_L("Write to 'TEXTFILE.TXT'"));
677 for (i=0;i<numberOfTests;i++)
679 r=textFile.Write(record[i]);
681 testq.Printf(_L("Write %d completed OK\n"),i+1);
687 r=file1.Open(TheFs,_L("Q:\\TEST\\T_FSRV.CPP"),EFileRead|EFileShareReadersOnly);