Update contrib.
1 // Copyright (c) 2006-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\demandpaging\t_clamp.cpp
15 // Test suite for file clamping, file clamping is used to prevent files
16 // (exes or dlls) from being deleted whilst in use.
17 // 002 GetDriveLetters()
18 // 003 Test1() Basic clamp operation
19 // 004 Test2() Invalid clamp requests
20 // 005 Test3() Denied FS requests when file(s) are clamped
21 // 006 Test3Operations() Test other RFile, RFs operations
22 // 007 Test3Operations() Increase number of clamps to MY_N
23 // 008 Test3Operations() Decrease number of clamps by MY_M
24 // 009 Test3Operations() Increase number of clamps by MY_M
25 // 010 TestDeferredDismount() Open and clamp file, register for dismount
26 // notification, then issue dismount instruction.
27 // 011 Test4() Clamp tests for non-writable file system
28 // 012 Test5() Clamp requests on non-clamping file systems
32 //! @SYMTestCaseID KBASE-T_CLAMP-0328
35 //! @SYMTestCaseDesc Demand Paging File Clamp tests
36 //! @SYMTestActions 001 Starting T_CLAMP
37 //! @SYMTestExpectedResults All tests should pass.
38 //! @SYMTestPriority High
39 //! @SYMTestStatus Implemented
41 #define __E32TEST_EXTENSION__
44 RTest test(_L("T_CLAMP"));
46 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
50 #include <e32ldr_private.h>
54 //_LIT(KFAT32Name,"FAT32");
55 _LIT(KROFSName,"ROFS");
56 _LIT(KLFFSName,"LFFS");
57 _LIT(KCOMPName,"COMPOSITE"); // Z: name if Composite File System
59 //_LIT(KROMName,"WIN32"); // Clamping is not supported for non-composite filing system on Z:
61 _LIT(KROMName,"ROM"); // Z: name if ROMFS (on hardware, not emulator)
72 // Basic clamp operation
73 test.Next(_L("T_Clamp - Test1()"));
76 TBuf<256> buf(_L("buffer for file used"));
78 fileName = _L("clampFile.tst");
80 TInt r=testFile.Replace(TheFs,fileName,EFileWrite);
82 TPtrC8 pBuf((TUint8*)&buf);
88 r=handle.Clamp(testFile);
90 TInt64 storedCookie_0=handle.iCookie[0];
91 TInt64 storedCookie_1=handle.iCookie[1];
93 // Try to clamp previously-clamped file
95 r=handle1.Clamp(testFile);
99 r=handle.Close(TheFs);
101 // Check cookie content has been re-initialised
102 test((0==handle.iCookie[0])&&(0==handle.iCookie[1]));
104 // Try to unclamp a file that is not clamped
105 handle.iCookie[0]=storedCookie_0;
106 handle.iCookie[1]=storedCookie_1;
107 r=handle.Close(TheFs);
108 test (r==KErrNotFound);
110 // Check that attempting to unclamp with a zero-content cookie
114 r=handle.Close(TheFs);
117 // Clamp the file (again)
118 r=handle.Clamp(testFile);
121 // Create and clamp a second file ...
122 fileName = _L("clampFile2.tst");
124 r=testFile2.Replace(TheFs,fileName,EFileWrite);
126 buf=_L("buffer for file 2");
127 testFile2.Write(pBuf);
130 r=handle2.Clamp(testFile2);
133 // Create and clamp a third file ...
135 fileName = _L("clampFile3.tst");
137 r=testFile3.Replace(TheFs,fileName,EFileWrite);
139 buf=_L("buffer for file 3");
140 testFile3.Write(pBuf);
142 r=handle3.Clamp(testFile3);
145 // Test can unclamp then reclamp first file
146 // then repeat for the third file
147 r=handle.Close(TheFs);
149 r=handle.Clamp(testFile);
151 r=handle3.Close(TheFs);
153 r=handle3.Clamp(testFile3);
157 r=handle.Close(TheFs);
159 r=handle1.Close(TheFs);
162 r=TheFs.Delete(_L("clampFile.tst"));
165 r=handle2.Close(TheFs);
168 r=TheFs.Delete(_L("clampFile2.tst"));
171 r=handle3.Close(TheFs);
174 r=TheFs.Delete(_L("clampFile3.tst"));
181 // Invalid clamp requests
182 test.Next(_L("T_Clamp - Test2()"));
184 // Test attempt to clamp empty file is rejected
187 file4Name = _L("clampFile4.tst");
189 TInt r=testFile4.Replace(TheFs,file4Name,EFileWrite);
191 r=handle4.Clamp(testFile4);
194 // Preparation for next test - create a valid clamp handle
195 TBuf<256> buf4(_L("buffer for file 4"));
196 TPtrC8 pBuf4((TUint8*)&buf4);
197 testFile4.Write(pBuf4);
199 r=handle4.Clamp(testFile4);
202 // Try to unclamp non-existant file
204 memcpy((TAny*)&handle5,(TAny*)&handle4,sizeof(RFileClamp));
205 handle5.iCookie[0] = MAKE_TINT64(-1,-1); // iCookie[0] holds the unique ID
206 r=handle5.Close(TheFs);
207 test (r==KErrNotFound);
210 r=handle4.Close(TheFs);
213 r=TheFs.Delete(_L("clampFile4.tst"));
219 LOCAL_C void TestDeferredDismount(TDesC& aRoot, TDesC& aFileName, RFileClamp* handlePtr)
221 // Open and clamp file, register for dismount notification, then issue
222 // dismount instruction.
223 // Since there are no other clients registered for dismount notification,
224 // this would normally lead too dismount being instigated. However, since
225 // the file is clamped, dismount should be deferred
226 test.Next(_L("T_Clamp - TestDeferredDismount()"));
228 // File system details required for clean-up
229 const TInt KMaxFileSystemNameLength=100; // Arbitrary length
230 const TInt KMaxFileSystemExtNameLength=100; // Arbitrary length
231 TBuf<KMaxFileSystemNameLength> fsName;
232 TBuf<KMaxFileSystemExtNameLength> fsExtName_0;
233 TBuf<KMaxFileSystemExtNameLength> fsExtName_1;
234 TBool fsExt0Present=EFalse;
235 TBool fsExt1Present=EFalse;
237 r=TheFs.CharToDrive(aRoot[0], driveNo);
239 r=TheFs.FileSystemName(fsName, driveNo);
241 r=TheFs.ExtensionName(fsExtName_0,driveNo,0);
244 r=TheFs.ExtensionName(fsExtName_1,driveNo,1);
248 // Create a file & write to it so that we can test whether dismounting works correctly with dirty data
249 TDriveInfo driveInfo;
250 test(TheFs.Drive(driveInfo, driveNo) == KErrNone);
251 TFileName dirtyFileName(_L("dirtyFile.tst"));
253 if (!(driveInfo.iMediaAtt & KMediaAttWriteProtected))
255 r=dirtyFile.Replace(TheFs, dirtyFileName, EFileWrite);
257 r=dirtyFile.Write(_L8("My name is Michael Caine"));
263 r=testFile.Open(TheFs,aFileName,EFileRead);
265 r=handlePtr->Clamp(testFile);
269 TRequestStatus clientNotify=KErrNone;
270 TRequestStatus clientDismount=KErrNone;
271 TheFs.NotifyDismount(driveNo, clientNotify); // Register for notification
272 test(clientNotify == KRequestPending);
274 TheFs.NotifyDismount(driveNo, clientDismount, EFsDismountNotifyClients);
275 test(clientDismount == KRequestPending);
276 User::WaitForRequest(clientNotify);
277 test(clientNotify == KErrNone);
279 r=TheFs.AllowDismount(driveNo); // Respond to dismount notification
281 test(clientDismount == KRequestPending); // Dismount is deferred
284 // Now unclamp the file, and check that the deferred dismount is performed.
285 r=handlePtr->Close(TheFs);
287 User::WaitForRequest(clientDismount);
288 test(clientDismount == KErrNone);
290 // Try to write to the opened file: this should return KErrNotReady as there is no drive thread
291 if (!(driveInfo.iMediaAtt & KMediaAttWriteProtected))
293 r=dirtyFile.Write(_L8("My name isn't really Michael Caine"));
294 test(r==KErrNotReady);
297 // Re-mount the file system
300 r=TheFs.MountFileSystem(fsName,fsExtName_0,driveNo);
303 else if(fsExt1Present) // untested !
305 r=TheFs.MountFileSystem(fsName,fsExtName_1,driveNo);
310 r=TheFs.MountFileSystem(fsName,driveNo);
314 // create some more dirty data to verify that the file server can cope with the drive thread
315 // having gone & come back again
316 if (!(driveInfo.iMediaAtt & KMediaAttWriteProtected))
318 r=dirtyFile.Write(_L8("My name is Michael Phelps and I'm a fish."));
319 test(r==KErrDisMounted);
322 r = TheFs.Delete(dirtyFileName);
326 // Issue a EFsDismountNotifyClients with no clients but with files clamped
327 // & verify that the dismount request completes when clamps are removed
328 r=testFile.Open(TheFs,aFileName,EFileRead);
330 r=handlePtr->Clamp(testFile);
333 TheFs.NotifyDismount(driveNo, clientDismount, EFsDismountNotifyClients);
335 test(clientDismount == KRequestPending);
336 r=handlePtr->Close(TheFs);
338 User::WaitForRequest(clientDismount);
339 test(clientDismount == KErrNone);
340 // Re-mount the file system again
343 r=TheFs.MountFileSystem(fsName,fsExtName_0,driveNo);
346 else if(fsExt1Present) // untested !
348 r=TheFs.MountFileSystem(fsName,fsExtName_1,driveNo);
353 r=TheFs.MountFileSystem(fsName,driveNo);
358 // Issue a EFsDismountForceDismount with no clients but with files clamped
359 // & verify that the dismount request completes when clamps are removed
360 r=testFile.Open(TheFs,aFileName,EFileRead);
362 r=handlePtr->Clamp(testFile);
365 TheFs.NotifyDismount(driveNo, clientDismount, EFsDismountForceDismount);
367 test(clientDismount == KRequestPending);
368 r=handlePtr->Close(TheFs);
370 User::WaitForRequest(clientDismount);
371 test(clientDismount == KErrNone);
372 // Re-mount the file system again
375 r=TheFs.MountFileSystem(fsName,fsExtName_0,driveNo);
378 else if(fsExt1Present) // untested !
380 r=TheFs.MountFileSystem(fsName,fsExtName_1,driveNo);
385 r=TheFs.MountFileSystem(fsName,driveNo);
393 LOCAL_C void Test3Operations(TDesC& aRoot, TDesC& aFileName)
395 test.Next(_L("T_Clamp - Test3Operations()"));
398 if (User::UpperCase(aRoot[0]) != 'C')
401 TBuf<4> driveBuf=_L("?:\\");
402 driveBuf[0] = aRoot[0];
405 TInt r=format.Open(TheFs,driveBuf,EFullFormat,count);
410 // Dismount: synchronous requests
411 // RFs::DismountFileSystem, RFs::SwapFileSystem
412 const TInt KMaxFileSystemNameLength=100; // Arbitrary length
413 TBuf<KMaxFileSystemNameLength> fileSysName;
415 r=TheFs.CharToDrive(aRoot[0], driveNo);
417 r=TheFs.FileSystemName(fileSysName,driveNo);
420 r=TheFs.DismountFileSystem(fileSysName,driveNo);
423 r=TheFs.SwapFileSystem(fileSysName,fileSysName,driveNo);
426 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
427 // The cancellation of deferred dismounts requires controlIO
428 // functionality available in debug versions of the code.
430 // Dismount: asynchronous requests
431 // RFs::NotifyDismount, RFs::AllowDismount
432 const TInt KNumClients = 5;
433 RFs clientFs[KNumClients];
434 TRequestStatus clientNotify[KNumClients];
435 TRequestStatus clientComplete;
437 for(i=0; i< KNumClients; i++)
439 r=clientFs[i].Connect();
442 // Cancel any deferred dismount in preparation for the next test
443 r=TheFs.ControlIo(driveNo,KControlIoCancelDeferredDismount);
446 // Use case 1: Orderly dismount
447 // All clients register for dismount notification
448 for(i=0; i< KNumClients; i++)
450 clientNotify[i] = KErrNone;
451 clientFs[i].NotifyDismount(driveNo, clientNotify[i]);
452 test(clientNotify[i] == KRequestPending);
454 // First client notifies intent to dismount
455 clientComplete = KErrNone;
456 clientFs[0].NotifyDismount(driveNo, clientComplete, EFsDismountNotifyClients);
457 test(clientComplete == KRequestPending);
458 // Check all clients have received the notification
459 for(i=0; i< KNumClients; i++)
461 test(clientNotify[i] == KErrNone);
463 // All clients invoke AllowDismount
464 for(i=0; i< KNumClients; i++)
466 r=clientFs[i].AllowDismount(driveNo);
469 // Dismount is deferred
470 test(clientComplete == KRequestPending);
473 // Cancel the deferred dismount in preparation for the next test
474 clientFs[0].NotifyDismountCancel(clientComplete);
475 test(clientComplete == KErrCancel);
476 r=TheFs.ControlIo(driveNo,KControlIoCancelDeferredDismount);
478 clientComplete=KErrNone; // Re-initialise the TRequestStatus
481 // Use case 2: Forced dismount
482 // All clients register for dismount notification
483 for(i=0; i< KNumClients; i++)
485 clientFs[i].NotifyDismount(driveNo, clientNotify[i]);
486 test(clientNotify[i] == KRequestPending);
488 // First client notifies intent to dismount
489 clientFs[0].NotifyDismount(driveNo, clientComplete, EFsDismountNotifyClients);
490 test(clientComplete == KRequestPending);
491 // Check all clients have received the notification
492 for(i=0; i< KNumClients; i++)
494 test(clientNotify[i] == KErrNone);
496 // Not all other clients invoke AllowDismount
497 for(i=0; i< KNumClients-1; i++)
499 clientFs[i].AllowDismount(driveNo);
501 // First client attempts forced dismount
502 test(clientComplete == KRequestPending);
503 clientFs[0].NotifyDismount(driveNo, clientComplete, EFsDismountForceDismount);
504 // Dismount is deferred
505 test(clientComplete == KRequestPending);
507 // Cancel the deferred dismount in preparation for the next test
508 // Also cancel the 'un-Allowed' notification request
509 clientFs[0].NotifyDismountCancel(clientComplete);
510 test(clientComplete == KErrCancel);
511 r=TheFs.ControlIo(driveNo,KControlIoCancelDeferredDismount);
513 clientComplete=KErrNone; // Re-initialise the TRequestStatus
516 // RFile::Open with EFileWrite
518 r=testFile.Open(TheFs,aFileName,EFileWrite|EFileShareReadersOrWriters);
523 r=testFile2.Replace(TheFs,aFileName,EFileRead);
527 // RFile::Set - this should not be prevented by clamping
528 r=testFile.Open(TheFs,aFileName,EFileRead|EFileShareAny);
533 r=testFile.Att(origAtt);
535 r=testFile.Modified(origTime);
538 TTime time; // Arbitrary value
539 TUint setMask=0xA5A5&~KEntryAttReadOnly; // Not read-only, otherwise arbitrary value
540 TUint clearMask=0x5A5A & KEntryAttReadOnly; // Not read-only, otherwise arbitrary value
541 r=testFile.Set(time,setMask,clearMask);
544 r=testFile.Set(origTime,origAtt,~origAtt); // restore original values
548 // RFs::Rename - this should not be prevented by clamping
549 r=TheFs.Rename(aFileName,_L("aDummyName"));
551 r=TheFs.Rename(_L("aDummyName"),aFileName); // restore original name
555 r=TheFs.Replace(aFileName,_L("aDummyName"));
558 // RFs::SetEntry - this should not be prevented by clamping
559 r=TheFs.SetEntry(aFileName,time,setMask,clearMask);
561 r=TheFs.SetEntry(aFileName,origTime,origAtt,~origAtt); // restore original values
565 r=TheFs.Delete(aFileName);
568 // RRawDisk::Open (*** no longer required ***)
571 LOCAL_C void Test3(TDesC& aRoot)
573 // Denied FS requests when file(s) are clamped.
574 test.Next(_L("T_Clamp - Test3()"));
576 // Clamping is reference counted, so we need a test to check that
577 // a file clamped N times cannot be modified until it has been unclamped N times.
580 // - Unclamp M times (M<N)
587 // Create a file for use
589 TBuf<256> buf(_L("buffer for file used"));
590 fileName = _L("clampFile.tst");
592 TInt r=testFile.Replace(TheFs,fileName,EFileWrite);
594 TPtrC8 pBuf((TUint8*)&buf);
595 testFile.Write(pBuf);
597 // Close file,then re-open (to support clamping) in sharable mode
598 // (to allow testing of RFile::Open with EFileWrite)
600 r=testFile.Open(TheFs,fileName,EFileWrite|EFileShareReadersOrWriters);
602 // Show, prior to clamping, that the file can be opened with EFileWrite
604 r=testFile2.Open(TheFs,fileName,EFileWrite|EFileShareReadersOrWriters);
606 // Close the second RFile instance
609 // Clamp and unclamp a number of times, and invoke the
610 // operations to test
611 RFileClamp myHandles[MY_N];
612 RFileClamp *handlePtr = myHandles;
616 r=handlePtr->Clamp(testFile);
620 // RFile::SetAtt - this should not be prevented by clamping
623 r=testFile.Att(origAtt);
625 r=testFile.Modified(origTime);
627 TTime time; // Arbitrary value
628 TUint setMask=0xA5A5&~KEntryAttReadOnly; // Not read-only, otherwise arbitrary value
629 TUint clearMask=0x5A5A & KEntryAttReadOnly; // Not read-only, otherwise arbitrary value
630 r=testFile.Att(origAtt);
632 r=testFile.SetAtt(setMask,clearMask);
634 r=testFile.Set(origTime,origAtt,~origAtt); // restore original values
637 // RFile::SetModified - this should not be prevented by clamping
638 r=testFile.Modified(origTime);
640 r=testFile.SetModified(time);
642 r=testFile.SetModified(origTime); // restore original value
645 // RFile::Rename - this should not be prevented by clamping
646 // Need file to be opened in EFileShareExclusive sharing mode,
647 // so close, unclamp, re-open appropriately and re-clamp
649 r=handlePtr->Close(TheFs);
652 r=testFile.Open(TheFs,fileName,EFileWrite|EFileShareExclusive);
654 r=handlePtr->Clamp(testFile);
657 r=testFile.Rename(_L("aDummyName"));
659 r=testFile.Rename(fileName);
663 r=testFile.SetSize(1000); // Arbitrary value
666 // Test other RFile, RFs operations
668 Test3Operations(aRoot,fileName);
670 // Increase number of clamps to MY_N
671 r=testFile.Open(TheFs,fileName,EFileRead);
676 r=handlePtr->Clamp(testFile);
680 Test3Operations(aRoot,fileName);
682 // Decrease number of clamps by MY_M
683 for(;i > (MY_N - MY_M); i--)
685 r=handlePtr->Close(TheFs);
687 if(handlePtr!=myHandles)
692 Test3Operations(aRoot,fileName);
694 // Increase number of clamps by MY_M
695 r=testFile.Open(TheFs,fileName,EFileRead);
701 r=handlePtr->Clamp(testFile);
706 Test3Operations(aRoot,fileName);
708 // Decrease number of clamps by MY_N
711 r=handlePtr->Close(TheFs);
713 if(handlePtr!=myHandles)
719 // Test deferred dismount - use next free handle
720 TestDeferredDismount(aRoot,fileName,handlePtr);
722 // Re-create the test directory
723 r=TheFs.MkDirAll(aRoot);
724 test(r==KErrNone || r== KErrAlreadyExists);
725 TheFs.SetSessionPath(aRoot);
727 // No clamps remain - prove RFile::Open with EFileWrite
728 r=testFile2.Open(TheFs,fileName,EFileWrite|EFileShareReadersOrWriters);
732 // No clamps remain - prove that file can now be deleted
733 r=TheFs.Delete(_L("clampFile.tst"));
738 LOCAL_C void Test4(TDesC& aRoot)
740 // Clamp tests for non-writable file system
741 test.Next(_L("T_Clamp - Test4()"));
743 // Tests are limited to clamp, unclamp and denied requests
744 // when clamps are present.
747 if((aRoot[0]=='Z')||(aRoot[0]=='z'))
748 pathName=_L("clean.txt");
750 pathName=_L("root.txt");
752 if((aRoot[0]=='Z')||(aRoot[0]=='z'))
753 pathName=_L("UnicodeData.txt");
755 pathName=_L("\\Test\\clamp.txt"); // For (non-composite) ROFS drive
758 TInt r=testFile.Open(TheFs, pathName, EFileRead);
763 r=handle.Clamp(testFile);
765 TInt64 storedCookie_0=handle.iCookie[0];
766 TInt64 storedCookie_1=handle.iCookie[1];
768 // Try to clamp previously-clamped file
770 r=handle1.Clamp(testFile);
774 r=handle.Close(TheFs);
776 // Check cookie content has been re-initialised
777 test((0==handle.iCookie[0])&&(0==handle.iCookie[1]));
779 // Try to unclamp a file that is not clamped
780 handle.iCookie[0]=storedCookie_0;
781 handle.iCookie[1]=storedCookie_1;
782 r=handle.Close(TheFs);
783 test (r==KErrNotFound);
784 // Remove remaining clamp
785 r=handle1.Close(TheFs);
790 if((aRoot[0]!='Z')&&(aRoot[0]!='z')) // Can not dismount Z:
791 TestDeferredDismount(aRoot,pathName,&handle);
797 // Clamp requests on non-clamping file systems
798 test.Next(_L("T_Clamp - Test5()"));
800 TBuf<256> unsuppFile;
801 unsuppFile = _L("unsuppFile.tst");
803 TInt r=testFile.Replace(TheFs,unsuppFile,EFileWrite);
806 // Try to clamp a file on a file system that does
807 // not support clamping
809 r=handle.Clamp(testFile);
810 test(r==KErrNotSupported);
814 r=TheFs.Delete(_L("unsuppFile.tst"));
819 LOCAL_C void GetDriveLetters()
821 // Assign the first drive that matches the required criteria
822 test.Next(_L("T_Clamp - GetDriveLetters()"));
824 TDriveList driveList;
825 TDriveInfo driveInfo;
826 TInt r=TheFs.DriveList(driveList);
829 TBool drivesFound = EFalse;
830 for(drvNum=0; (drvNum<KMaxDrives) && !drivesFound; drvNum++)
833 TFileName fileSystem;
834 if(!driveList[drvNum])
836 test(TheFs.Drive(driveInfo, drvNum) == KErrNone);
837 test(TheFs.DriveToChar(drvNum,drvLetter) == KErrNone);
838 r=TheFs.FileSystemName(fileSystem,drvNum);
839 fileSystem.UpperCase();
840 test((r==KErrNone)||(r==KErrNotFound));
841 if (!(driveInfo.iDriveAtt & KDriveAttInternal))
843 // Check for FAT on NAND
846 if((driveInfo.iType==EMediaNANDFlash) && (fileSystem.Compare(KFATName)==0))
847 NandFatDrv=drvLetter;
852 if((driveInfo.iType==EMediaNANDFlash) && (fileSystem.Compare(KROFSName)==0))
858 if((driveInfo.iType==EMediaFlash) && (fileSystem.Compare(KLFFSName)==0))
861 // Check for CompFSys
864 if((driveInfo.iType==EMediaRom) && ((fileSystem.Compare(KROMName)==0)||(fileSystem.Compare(KCOMPName)==0)))
867 drivesFound=((NandFatDrv!='?')&&(RofsDrv!='?')&&(LffsDrv!='?')&&(CompDrv!='?'));
870 test((NandFatDrv!=RofsDrv)&&(NandFatDrv!=LffsDrv)&&(NandFatDrv!=CompDrv));
872 test((RofsDrv!=LffsDrv)&&(RofsDrv!=CompDrv));
874 test(LffsDrv!=CompDrv);
876 RDebug::Printf("T_CLAMP: FAT drive=%C, ROFS drive=%C, LFFS drive=%C, ROM-COMP drive=%C \n",(TText)NandFatDrv,(TText)RofsDrv,(TText)LffsDrv,(TText)CompDrv);
889 test.Start(_L("Starting T_CLAMP ..."));
890 test(TheFs.Connect()==KErrNone);
895 //************************************************************************
897 // Test on FAT (writable file system)
899 //************************************************************************
902 pathName=_L("?:\\CLAMP-TST\\"); // FAT on NAND
903 pathName[0]=(TText)NandFatDrv;
904 r=TheFs.MkDirAll(pathName);
905 test(r==KErrNone || r== KErrAlreadyExists);
906 TheFs.SetSessionPath(pathName);
907 test.Printf( _L("T_CLAMP: testing FAT drive on %C\n"),(TText)NandFatDrv);
909 Test1(); // Basic clamp operation
910 Test2(); // Invalid clamp requests
911 Test3(pathName);// Denied FS requests when files are clamped
913 r=TheFs.RmDir(pathName);
917 test.Printf( _L("T_CLAMP: FAT drive not tested\n"));
919 //************************************************************************
921 // Test on ROFS (non-writable file system)
923 //************************************************************************
927 pathName[0]=(TText)RofsDrv;
928 TheFs.SetSessionPath(pathName);
929 test.Printf( _L("T_CLAMP: testing ROFS drive on %C\n"),(TText)RofsDrv);
931 Test4(pathName); // Clamp tests for non-writable file system
934 test.Printf( _L("T_CLAMP: ROFS drive not tested\n"));
936 //************************************************************************
938 // Test on Z: - Composite File System, or ROMFS (non-writable file system)
940 //************************************************************************
943 pathName=_L("?:\\TEST\\");
944 pathName[0]=(TText)CompDrv;
945 TheFs.SetSessionPath(pathName);
946 test.Printf( _L("T_CLAMP: testing Z drive (on %C)\n"),(TText)CompDrv);
948 Test4(pathName); // Clamp tests for non-writable file system
951 test.Printf( _L("T_CLAMP: Z drive not tested\n"));
953 //************************************************************************
955 // Test on LFFS (non-clampable file system)
957 //************************************************************************
960 TBuf<256> unsuppPath;
961 unsuppPath=_L("?:\\CLAMP-TST\\");
962 unsuppPath[0]=(TText)LffsDrv;
963 r=TheFs.MkDirAll(unsuppPath);
964 test(r==KErrNone || r== KErrAlreadyExists);
965 TheFs.SetSessionPath(unsuppPath);
966 test.Printf( _L("T_CLAMP: testing LFFS drive on %C\n"),(TText)LffsDrv);
968 Test5(); // Clamp requests on non-clamping file systems
971 test.Printf( _L("T_CLAMP: LFFS drive not tested\n"));
982 test.Start(_L("Test does not run on UREL builds."));