First public contribution.
1 // Copyright (c) 1995-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.
16 #define __E32TEST_EXTENSION__
25 #include "f32_test_utils.h"
27 using namespace F32_Test_Utils;
29 RTest test(_L("T_FILE"));
31 TBool gShortFileNamesSupported = EFalse;
33 static TBuf8<1500> gBuf;
37 static void testShare()
43 test.Start(_L("Test exclusive sharing"));
44 MakeFile(_L("TESTER"));
47 Extra code to answer a question about a potential WINS bug. WINS Elocal returns
48 KErrAccessDenied to the write operation but EFat returns
52 TInt r=f1.Open(TheFs,_L("TESTER"),EFileRead|EFileShareAny);
55 r=f2.Open(TheFs,_L("TESTER"),EFileWrite|EFileShareAny);
59 test.Printf(_L("returned %d"),r);
64 r=TheFs.Delete(_L("TESTER"));
69 TInt r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
72 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
74 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
76 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
79 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileWrite|EFileShareExclusive);
83 test.Next(_L("Test readers only sharing"));
84 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileWrite|EFileShareReadersOnly);
85 test(r==KErrArgument);
86 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
88 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
90 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
92 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileWrite|EFileShareReadersOnly);
93 test(r==KErrArgument);
94 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
99 test.Next(_L("Test any sharing"));
100 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileWrite|EFileShareAny);
102 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
104 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
106 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
114 static void testChangeMode()
116 // Test changing the share mode of a file between EFileShareReadersOnly <-> EFileShareExclusive
120 test.Start(_L("Test change mode"));
123 TInt r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
124 test(r==KErrNone); // Opened exclusive
125 r=f1.ChangeMode(EFileShareReadersOnly);
126 test(r==KErrNone); // Change to readers only
127 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
128 test(r==KErrNone); // Open as reader
129 r=f1.ChangeMode(EFileShareExclusive);
130 test(r==KErrAccessDenied); // Change back to exclusive fails
131 r=f2.ChangeMode(EFileShareExclusive);
132 test(r==KErrAccessDenied); // Change to exclusive fails
133 f1.Close(); // Close other reader
134 r=f2.ChangeMode(EFileShareExclusive);
135 test(r==KErrNone); // Change to exclusive succeeds.
138 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
139 test(r==KErrNone); // Opened readers only
140 r=f1.ChangeMode(EFileShareExclusive);
141 test(r==KErrNone); // Change to exclusive
142 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
143 test(r==KErrInUse); // Open as reader fails
144 r=f1.ChangeMode(EFileShareReadersOnly);
145 test(r==KErrNone); // Change to readers only
146 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
147 test(r==KErrNone); // Open as reader
148 r=f1.ChangeMode(EFileShareExclusive);
149 test(r==KErrAccessDenied); // Change back to exclusive fails
150 r=f2.ChangeMode(EFileShareExclusive);
151 test(r==KErrAccessDenied); // Change to exclusive fails
152 f1.Close(); // Close other reader
153 r=f2.ChangeMode(EFileShareExclusive);
154 test(r==KErrNone); // Change to exclusive succeeds.
157 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileWrite|EFileShareExclusive);
158 test(r==KErrNone); // Opened exclusive for writing
159 r=f1.ChangeMode(EFileShareReadersOnly);
160 test(r==KErrAccessDenied); // Change to readers fails
161 r=f1.ChangeMode(EFileShareExclusive);
162 test(r==KErrNone); // No change ok
163 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
164 test(r==KErrInUse); // Open as reader fails
167 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
168 test(r==KErrNone); // Opened share any
169 r=f1.ChangeMode(EFileShareExclusive);
170 test(r==KErrAccessDenied); // Change to exclusive fails
171 r=f1.ChangeMode(EFileShareReadersOnly);
172 test(r==KErrAccessDenied); // Change to readers only fails
175 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
176 test(r==KErrNone); // Opened exclusive
177 r=f1.ChangeMode(EFileShareAny);
178 test(r==KErrArgument); // Change to share any fails KErrArgument
179 r=f1.ChangeMode((TFileMode)42);
180 test(r==KErrArgument); // Change to random value fails
185 static void testReadFile()
187 // Test read file handling.
191 test.Start(_L("Test read file"));
193 TInt r=f.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText);
195 TFileName fn = _L("Z:\\TEST\\T_FILE.CPP");
196 fn[0] = gExeFileName[0];
197 r=ZFile.Open(TheFs,fn,EFileStreamText);
200 test.Next(_L("Read file"));
209 if (b.Length()<b.MaxLength())
219 test.Next(_L("Read way beyond the end of the file"));
220 r=f.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText);
222 r=f.Read(3000000,gBuf);
226 test.Next(_L("Write way beyond the end of the file"));
227 r=f.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileWrite);
230 r=f.Write(3000000,gBuf);
236 static void testMultipleReadFile()
238 // Test multiple read file handling.
242 test.Start(_L("Test multiple read file"));
244 TInt r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
247 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
250 test.Next(_L("Read file"));
260 if (b1.Length()<b1.MaxLength())
264 test.Next(_L("Close file"));
271 static void testWriteFile()
273 // Test write file handling.
276 test.Start(_L("Test write file"));
278 TFileName fn = _L("File.File");
279 TBuf8<16> testData=_L8("testData");
282 TInt r=file.Replace(TheFs,fn,EFileStreamText);
285 test.Next(_L("Write file"));
287 r=file.Write(testData);
293 // test writing with EFileRead
294 r=file.Open(TheFs,fn,EFileStreamText|EFileRead);
297 test.Next(_L("Write file"));
298 r=file.Write(testData);
299 test(r==KErrAccessDenied);
302 // test writing with EFileWrite
303 r=file.Open(TheFs,fn,EFileStreamText|EFileWrite);
306 test.Next(_L("Write file"));
307 r=file.Write(testData);
311 // test writing with share mode EFileShareExclusive
312 r=file.Open(TheFs,fn,EFileStreamText|EFileWrite|EFileShareExclusive);
315 test.Next(_L("Write file"));
316 r=file.Write(testData);
320 // test writing with share mode EFileShareReadersOnly (fails with KErrArgument)
321 r=file.Open(TheFs,fn,EFileStreamText|EFileWrite|EFileShareReadersOnly);
322 test(r==KErrArgument);
324 // test writing with share mode EFileShareReadersOrWriters
325 r=file.Open(TheFs,fn,EFileStreamText|EFileWrite|EFileShareReadersOrWriters);
328 test.Next(_L("Write file"));
329 r=file.Write(testData);
333 // test writing with share mode EFileShareAny
334 r=file.Open(TheFs,fn,EFileStreamText|EFileWrite|EFileShareAny);
337 test.Next(_L("Write file"));
338 r=file.Write(testData);
349 static void CopyFileToTestDirectory()
351 // Make a copy of the file in ram
355 TFileName fn = _L("Z:\\TEST\\T_FILE.CPP");
356 fn[0] = gExeFileName[0];
362 r=TheFs.Parse(f.NameAndExt(),fCopy);
366 r=f1.Open(TheFs,f.FullName(),EFileStreamText|EFileShareReadersOnly);
369 r=f2.Replace(TheFs,fCopy.FullName(),EFileWrite);
378 TInt s=Min(rem,copyBuf.MaxSize());
379 r=f1.Read(pos,copyBuf,s);
381 test(copyBuf.Length()==s);
382 r=f2.Write(pos,copyBuf,s);
391 static void testFileText()
393 // Test TFileText class methods
397 test.Next(_L("Test file text"));
399 record[0].Set(_L("First record"));
400 record[1].Set(_L("Second record"));
401 record[2].Set(_L("Third record"));
402 record[3].Set(_L("Fourth record"));
403 record[4].Set(_L("Fifth record"));
406 TInt r=f.Replace(TheFs,_L("TEXTFILE.TXT"),0);
413 r=textFile.Write(record[i]);
416 r=textFile.Seek(ESeekStart);
421 r=textFile.Read(recBuf);
423 test(recBuf==record[i]);
425 r=textFile.Read(recBuf);
427 test(recBuf.Length()==0);
430 test.Next(_L("Test dosfile terminator"));
432 TPtrC tTextrecord[7];
433 tTextrecord[0].Set(_L("First record\r\n"));
434 tTextrecord[1].Set(_L("Second record\r\n"));
435 tTextrecord[2].Set(_L("Third record\r\n"));
436 tTextrecord[3].Set(_L("Fourth record\r\n"));
437 tTextrecord[4].Set(_L("Fifth record\r\n"));
438 tTextrecord[5].Set(_L("Sixth record\n\r"));
439 tTextrecord[6].Set(_L("Seventh record\n"));
440 trecord[0].Set((TUint8*)tTextrecord[0].Ptr(),tTextrecord[0].Length()*sizeof(TText));
441 trecord[1].Set((TUint8*)tTextrecord[1].Ptr(),tTextrecord[1].Length()*sizeof(TText));
442 trecord[2].Set((TUint8*)tTextrecord[2].Ptr(),tTextrecord[2].Length()*sizeof(TText));
443 trecord[3].Set((TUint8*)tTextrecord[3].Ptr(),tTextrecord[3].Length()*sizeof(TText));
444 trecord[4].Set((TUint8*)tTextrecord[4].Ptr(),tTextrecord[4].Length()*sizeof(TText));
445 trecord[5].Set((TUint8*)tTextrecord[5].Ptr(),tTextrecord[5].Length()*sizeof(TText));
446 trecord[6].Set((TUint8*)tTextrecord[6].Ptr(),tTextrecord[6].Length()*sizeof(TText));
447 r=f.Replace(TheFs,_L("TEXTFILE.TXT"),0);
452 buf.Copy(trecord[i]);
457 textFile.Seek(ESeekStart);
460 r=textFile.Read(recBuf);
462 test(recBuf==record[i]);
464 r=textFile.Read(recBuf);
466 test(recBuf==_L("Sixth record"));
467 r=textFile.Read(recBuf);
469 test(recBuf==_L("\rSeventh record"));
470 r=textFile.Read(recBuf);
472 test(recBuf.Length()==0);
475 test.Next(_L("Test read with bufferSize == dataSize"));
476 r=f.Replace(TheFs,_L("TEXTFILE.TXT"),0);
478 record[0].Set(_L("1234567890123456"));
479 // trecord[0].Set(_L8("1234567890123456\r\n"));
480 // trecord[1].Set(_L8("1234567890123456\n"));
483 tmpTextrecord.Set(_L("1234567890123456\r\n"));
484 trecord[0].Set((TUint8*)tmpTextrecord.Ptr(),tmpTextrecord.Length()*sizeof(TText));
486 tmpTextrecord.Set(_L("1234567890123456\n"));
487 trecord[1].Set((TUint8*)tmpTextrecord.Ptr(),tmpTextrecord.Length()*sizeof(TText));
491 r=f.Write(trecord[i]);
495 textFile.Seek(ESeekStart);
498 r=textFile.Read(recBuf);
500 test(recBuf==record[0]);
502 r=textFile.Read(recBuf);
504 test(recBuf.Length()==0);
507 test.Next(_L("Read into a buffer < recordSize"));
509 r=f.Open(TheFs,_L("TEXTFILE.txt"),0);
514 r=textFile.Read(smallBuf);
516 test(smallBuf==_L("12345678"));
520 test.Next(_L("Nasty cases: 1) \\r \\n split over buffer boundary"));
521 r=f.Replace(TheFs,_L("TEXTFILE.txt"),0);
523 HBufC* largeRecord=HBufC::NewL(600);
524 largeRecord->Des().SetLength(250);
525 largeRecord->Des().Fill('A');
526 largeRecord->Des()[249]='\n';
528 bufPtr.Set((TUint8*)largeRecord->Ptr(),largeRecord->Size()); // Size() returns length in bytes
531 TBuf<16> boundaryBuf=_L("12345\r\n");
532 bufPtr.Set((TUint8*)boundaryBuf.Ptr(),boundaryBuf.Size());
535 r=f.Write(trecord[0]);
539 textFile.Seek(ESeekStart);
540 r=textFile.Read(recBuf);
542 test(recBuf==_L("AAAAAAAAAAAAAAAA"));
543 r=textFile.Read(recBuf);
545 test(recBuf==_L("12345"));
546 r=textFile.Read(recBuf);
548 test(recBuf==record[0]);
551 test.Next(_L("Nasty cases: 2) \\r on buffer boundary"));
552 r=f.Replace(TheFs,_L("TEXTFILE.txt"),0);
554 largeRecord->Des().SetLength(250);
555 largeRecord->Des().Fill('A');
556 largeRecord->Des()[249]='\n';
557 bufPtr.Set((TUint8*)largeRecord->Ptr(),largeRecord->Size());
560 boundaryBuf=_L("12345\rxyz\n");
561 bufPtr.Set((TUint8*)boundaryBuf.Ptr(),boundaryBuf.Size());
564 r=f.Write(trecord[0]);
568 textFile.Seek(ESeekStart);
569 r=textFile.Read(recBuf);
571 test(recBuf==_L("AAAAAAAAAAAAAAAA"));
572 r=textFile.Read(recBuf);
574 test(recBuf==_L("12345\rxyz"));
575 r=textFile.Read(recBuf);
577 test(recBuf==record[0]);
580 test.Next(_L("Nasty cases: 3) record size > buffer size"));
581 r=f.Replace(TheFs,_L("TEXTFILE.txt"),0);
583 largeRecord->Des().SetLength(600);
584 largeRecord->Des().Fill('Z');
585 largeRecord->Des()[511]='\r';
586 largeRecord->Des()[599]='\n';
587 bufPtr.Set((TUint8*)largeRecord->Ptr(),largeRecord->Size());
590 boundaryBuf=_L("12345\rxyz\n");
591 bufPtr.Set((TUint8*)boundaryBuf.Ptr(),boundaryBuf.Size());
594 r=f.Write(trecord[0]);
598 textFile.Seek(ESeekStart);
599 r=textFile.Read(recBuf);
601 test(recBuf==_L("ZZZZZZZZZZZZZZZZ"));
602 r=textFile.Read(recBuf);
604 test(recBuf==_L("12345\rxyz"));
605 r=textFile.Read(recBuf);
607 test(recBuf==record[0]);
610 TPtrC largePtr((TText*)largeRecord->Ptr(),(largeRecord->Length()-1));
611 textFile.Seek(ESeekStart);
612 r=textFile.Read(bigBuf);
614 test(bigBuf==largePtr);
615 r=textFile.Read(recBuf);
617 test(recBuf==_L("12345\rxyz"));
618 r=textFile.Read(recBuf);
620 test(recBuf==record[0]);
623 User::Free(largeRecord);
626 static void testFileTextEndRecord()
628 // Test terminating record
632 test.Next(_L("Test FileText last record has no terminator"));
634 TInt r=f.Replace(TheFs,_L("TextFile"),0);
637 TBuf<16>boundaryBuf=_L("Record1\n");
638 bufPtr.Set((TUint8*)boundaryBuf.Ptr(),boundaryBuf.Size());
641 boundaryBuf=_L("Record2\n");
642 bufPtr.Set((TUint8*)boundaryBuf.Ptr(),boundaryBuf.Size());
645 boundaryBuf=_L("Record3\n");
646 bufPtr.Set((TUint8*)boundaryBuf.Ptr(),boundaryBuf.Size());
652 r=fText.Seek(ESeekStart);
655 r=fText.Read(recBuf);
657 test(recBuf.MatchF(_L("record1"))!=KErrNotFound);
658 r=fText.Read(recBuf);
660 test(recBuf.MatchF(_L("record2"))!=KErrNotFound);
661 r=fText.Read(recBuf);
663 test(recBuf.MatchF(_L("record3"))!=KErrNotFound);
664 r=fText.Read(recBuf);
666 test(recBuf.Length()==0);
669 TBuf<0x100> bigBuf(0x100);
671 r=f.Replace(TheFs,_L("TextFile"),0);
674 bufPtr.Set((TUint8*)bigBuf.Ptr(),bigBuf.Size());
679 r=fText.Seek(ESeekStart);
682 r=fText.Read(bigBuf);
683 test.Printf(_L("fText.Read returns %d\n"),r);
685 test.Printf(_L("BigBuf.Length()==%d\n"),bigBuf.Length());
686 test(bigBuf.Length()==0x100);
687 r=fText.Read(bigBuf);
689 test(bigBuf.Length()==0);
693 static void testFileNames()
699 test.Next(_L("Test temp filenames specify drive"));
700 TFileName tempFileName;
702 TInt r=f.Temp(TheFs,_L(""),tempFileName,EFileRead);
705 p.Set(tempFileName,NULL,NULL);
706 test(p.DrivePresent());
707 test(p.PathPresent());
708 test(p.NamePresent());
709 test(p.ExtPresent());
712 r=f.Replace(TheFs,_L("WELCOMETO"),EFileWrite);
715 r=f.Replace(TheFs,_L("WELCOMETO.WRD"),EFileWrite);
720 // Nasty hack - mask attributes returned by RFile::Att() with this.
721 // File server used to do this but that stopped the XIP attribute on the ROM file system
722 // from being returned. It should really be up to the file system to return only
723 // the attributes which it supports rather than having the file server unilaterally
724 // mask off any attributes which don't exist on FAT.
725 #define ATT_MASK 0x3f
726 static void testFileAttributes()
728 // Test the archive attribute gets set
732 test.Next(_L("Archive att is set after creation"));
734 TInt r=TheFs.Delete(_L("FILEATT.ARC"));
735 test(r==KErrNone || r==KErrNotFound);
736 r=f.Create(TheFs,_L("FILEATT.ARC"),EFileRead);
741 test((atts&ATT_MASK)==KEntryAttArchive);
743 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
745 test(fileAtt.iAtt==KEntryAttArchive);
747 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
749 test(fileAtt.iAtt==KEntryAttArchive);
751 test.Next(_L("Archive att is set after a write"));
752 TheFs.SetAtt(_L("FILEATT.ARC"),0,KEntryAttArchive);
753 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
755 test(fileAtt.iAtt==0);
756 r=f.Open(TheFs,_L("FILEATT.ARC"),EFileWrite);
758 r=f.Write(_L8("Hello World"));
762 test((atts&ATT_MASK)==KEntryAttArchive);
763 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
765 test(fileAtt.iAtt==KEntryAttArchive);
767 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
769 test(fileAtt.iAtt==KEntryAttArchive);
771 test.Next(_L("Archive att is set after setsize"));
772 TheFs.SetAtt(_L("FILEATT.ARC"),0,KEntryAttArchive);
773 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
775 test(fileAtt.iAtt==0);
776 r=f.Open(TheFs,_L("FILEATT.ARC"),EFileWrite);
786 test((atts&ATT_MASK)==KEntryAttArchive);
787 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
789 test(fileAtt.iAtt==KEntryAttArchive);
791 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
793 test(fileAtt.iAtt==KEntryAttArchive);
795 test.Next(_L("Archive att is not set after open"));
796 r=TheFs.SetAtt(_L("FILEATT.ARC"),0,KEntryAttArchive);
798 r=f.Open(TheFs,_L("FILEATT.ARC"),EFileWrite);
802 test((atts&ATT_MASK)==0);
803 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
805 test(fileAtt.iAtt==0);
807 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
809 test(fileAtt.iAtt==0);
811 test.Next(_L("Archive att is not set after a read"));
812 TheFs.SetAtt(_L("FILEATT.ARC"),0,KEntryAttArchive);
813 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
815 test(fileAtt.iAtt==0);
816 r=f.Open(TheFs,_L("FILEATT.ARC"),EFileWrite);
823 test((atts&ATT_MASK)==0);
824 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
826 test(fileAtt.iAtt==0);
828 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
830 test(fileAtt.iAtt==0);
832 test.Next(_L("Archive att is set after replace"));
833 r=f.Replace(TheFs,_L("FILEATT.ARC"),EFileWrite);
837 test((atts&ATT_MASK)==KEntryAttArchive);
838 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
840 test(fileAtt.iAtt==KEntryAttArchive);
842 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
844 test(fileAtt.iAtt==KEntryAttArchive);
846 test.Next(_L("Read only bit can be unset"));
847 r=TheFs.SetAtt(_L("FILEATT.ARC"),KEntryAttReadOnly|KEntryAttHidden,0);
849 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
851 test(fileAtt.iAtt==(KEntryAttReadOnly|KEntryAttHidden|KEntryAttArchive));
853 r=TheFs.SetAtt(_L("FILEATT.ARC"),0,KEntryAttHidden);
855 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
857 test(fileAtt.iAtt==(KEntryAttReadOnly|KEntryAttArchive));
859 r=TheFs.SetAtt(_L("FILEATT.ARC"),0,KEntryAttReadOnly);
861 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
863 test(fileAtt.iAtt==(KEntryAttArchive));
865 r=TheFs.SetAtt(_L("FILEATT.ARC"),KEntryAttReadOnly|KEntryAttHidden,0);
867 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
869 test(fileAtt.iAtt==(KEntryAttReadOnly|KEntryAttHidden|KEntryAttArchive));
871 r=TheFs.SetAtt(_L("FILEATT.ARC"),0,KEntryAttReadOnly);
873 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
875 test(fileAtt.iAtt==(KEntryAttHidden|KEntryAttArchive));
877 r=TheFs.SetAtt(_L("FILEATT.ARC"),0,KEntryAttHidden);
879 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
881 test(fileAtt.iAtt==(KEntryAttArchive));
884 r=TheFs.SetEntry(_L("FILEATT.ARC"),time,KEntryAttReadOnly|KEntryAttHidden,0);
886 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
888 test(fileAtt.iAtt==(KEntryAttReadOnly|KEntryAttHidden|KEntryAttArchive));
890 r=TheFs.SetEntry(_L("FILEATT.ARC"),time,0,KEntryAttHidden);
892 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
894 test(fileAtt.iAtt==(KEntryAttReadOnly|KEntryAttArchive));
896 r=TheFs.SetEntry(_L("FILEATT.ARC"),time,0,KEntryAttReadOnly);
898 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
900 test(fileAtt.iAtt==(KEntryAttArchive));
902 r=TheFs.SetEntry(_L("FILEATT.ARC"),time,KEntryAttReadOnly|KEntryAttHidden,0);
904 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
906 test(fileAtt.iAtt==(KEntryAttReadOnly|KEntryAttHidden|KEntryAttArchive));
908 r=TheFs.SetEntry(_L("FILEATT.ARC"),time,0,KEntryAttReadOnly);
910 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
912 test(fileAtt.iAtt==(KEntryAttHidden|KEntryAttArchive));
914 r=TheFs.SetEntry(_L("FILEATT.ARC"),time,0,KEntryAttHidden);
916 r=TheFs.Entry(_L("FILEATT.ARC"),fileAtt);
918 test(fileAtt.iAtt==(KEntryAttArchive));
920 test.Next(_L("Cashing the 'read-only' attribute"));
921 const TDesC& fname = _L("TEST.RO");
923 // Test RO attribute after creating a file
924 r=f.Create(TheFs,fname,EFileWrite);
926 r=f.SetAtt(KEntryAttReadOnly,0);
928 r=f.Write(_L8("Hello World"));
929 test(r==KErrNone); // <-- here!
932 // Test we can't open for write or delete a RO file
933 r=f.Open(TheFs,fname,EFileWrite);
934 test(r==KErrAccessDenied);
935 r=TheFs.Delete(fname);
936 test(r==KErrAccessDenied);
938 // Tidy up and re-create test file
939 r=TheFs.SetAtt(fname,0,KEntryAttReadOnly);
941 r=TheFs.Delete(fname);
943 r=f.Create(TheFs,fname,EFileWrite);
947 // Test RO attribute after opening a file
948 r=f.Open(TheFs,fname,EFileWrite);
950 r=f.SetAtt(KEntryAttReadOnly,0);
952 r=f.Write(_L8("Hello World"));
957 r=TheFs.SetAtt(fname,0,KEntryAttReadOnly);
959 r=TheFs.Delete(fname);
963 static void testShortNameAccessorFunctions()
965 // Test RFs::GetShortName(...)
968 test.Next(_L("Test short name accessor functions"));
970 if(!gShortFileNamesSupported)
972 test.Printf(_L("Short Names are not supported!. Skipping..."));
977 TBuf<64> sessionPath;
978 TInt r=TheFs.SessionPath(sessionPath);
981 r=TheFs.MkDirAll(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\RANDOM.ENDBIT"));
982 test(r==KErrNone || r==KErrAlreadyExists);
983 r=f.Replace(TheFs,_L("LONGFILENAME.LONGEXT"),EFileWrite);
986 r=f.Replace(TheFs,_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\LONGFILENAME.LONGEXT"),EFileWrite);
989 r=f.Replace(TheFs,_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\BAD CHAR"),EFileWrite);
992 r=f.Replace(TheFs,_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\GoodCHAR.TXT"),EFileWrite);
1000 r=TheFs.GetShortName(_L("LONGFILENAME.LONGEXT"),shortName1);
1002 r=TheFs.GetShortName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\LONGFILENAME.LONGEXT"),shortName2);
1004 r=TheFs.GetShortName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\BAD CHAR"),shortName3);
1006 r=TheFs.GetShortName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\GOODCHAR.TXT"),shortName4);
1008 r=TheFs.GetShortName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY"),shortName5);
1011 if(Is_Win32(TheFs, gDriveNum))
1013 test(shortName1==_L("LONGFI~1.LON"));
1014 test(shortName2==_L("LONGFI~1.LON"));
1015 test(shortName3==_L("BADCHA~1"));
1016 test(shortName4.FindF(_L("GOODCHAR.TXT"))>=0);
1017 test(shortName5==_L("MIDDLE~1"));
1019 else if(!IsTestingLFFS())
1021 // LFFS short names not the same as VFAT ones
1022 test(shortName1==_L("LONGFI~1.LON"));
1023 test(shortName2==_L("LONGFI~1.LON"));
1024 test(shortName3==_L("BAD_CHAR"));
1025 test(shortName4.FindF(_L("GOODCHAR.TXT"))>=0);
1026 test(shortName5==_L("MIDDLE~1"));
1029 TFileName longName1;
1030 TFileName longName2;
1031 TFileName longName3;
1032 TFileName longName4;
1033 TFileName longName5;
1035 if (Is_Win32(TheFs, gDriveNum))
1037 r=TheFs.GetLongName(_L("LONGFI~1.LON"),longName1);
1039 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\LONGFI~1.LON"),longName2);
1041 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\BADCHA~1"),longName3);
1043 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\GOODCHAR.TXT"),longName4);
1045 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE~1"),longName5);
1048 else if (!IsTestingLFFS())
1050 r=TheFs.GetLongName(_L("LONGFI~1.LON"),longName1);
1052 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\LONGFI~1.LON"),longName2);
1054 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\BAD_CHAR"),longName3);
1056 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\GOODCHAR.TXT"),longName4);
1058 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE~1"),longName5);
1063 // LFFS longname tests
1064 r=TheFs.GetLongName(shortName1,longName1);
1066 r=TheFs.SetSessionPath(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-DIRECTORY\\LASTDIR\\"));
1068 r=TheFs.GetLongName(shortName2,longName2);
1070 r=TheFs.GetLongName(shortName3,longName3);
1072 r=TheFs.GetLongName(shortName4,longName4);
1074 r=TheFs.SetSessionPath(_L("\\F32-TST\\TFILE\\TOPLEVEL\\"));
1076 r=TheFs.GetLongName(shortName5,longName5);
1078 r=TheFs.SetSessionPath(sessionPath);
1082 test(longName1==_L("LONGFILENAME.LONGEXT"));
1083 test(longName2==_L("LONGFILENAME.LONGEXT"));
1084 test(longName3==_L("BAD CHAR"));
1085 test(longName4.FindF(_L("GOODCHAR.TXT"))>=0);
1086 test(longName5==_L("MIDDLE-DIRECTORY"));
1088 r=TheFs.GetShortName(_L("XXX.YYY"),shortName1);
1089 test(r==KErrNotFound);
1090 r=TheFs.GetShortName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-YROTCERID\\LASTDIR\\BAD-CHAR"),shortName1);
1091 test(r==KErrPathNotFound);
1092 r=TheFs.GetLongName(_L("XXX.YYY"),longName1);
1093 test(r==KErrNotFound);
1094 r=TheFs.GetLongName(_L("\\F32-TST\\TFILE\\TOPLEVEL\\MIDDLE-YROTCERID\\LASTDIR\\BAD-CHAR"),longName1);
1095 test(r==KErrPathNotFound);
1097 r=TheFs.Delete(_L("LONGFILENAME.LONGEXT"));
1101 r=TheFs.Entry(_L("Z:\\System"),romEntry);
1102 if (r==KErrNotReady)
1104 test.Printf(_L("ERROR: No rom filesystem present"));
1109 TBuf<64> romFileName=_L("Z:\\");
1110 romFileName.Append(romEntry.iName);
1111 r=TheFs.GetShortName(romFileName,shortName1);
1112 test(r==KErrNotSupported);
1113 r=TheFs.GetLongName(_L("Z:\\system"),longName1);
1114 test(r==KErrNotSupported);
1117 static void RmDir(const TDesC& aDirName)
1119 // Remove a directory
1122 CFileMan* fMan=CFileMan::NewL(TheFs);
1124 TInt r=TheFs.SessionPath(gSessionPath);
1126 r=TheFs.CheckDisk(gSessionPath);
1127 if (r!=KErrNone && r!=KErrNotSupported)
1128 ReportCheckDiskFailure(r);
1130 TFileName removeDirName = gSessionPath;
1131 removeDirName.Append(aDirName);
1133 fMan->Attribs(removeDirName, 0, KEntryAttReadOnly, 0, CFileMan::ERecurse);
1134 r=fMan->RmDir(removeDirName);
1135 test(r==KErrNone || r==KErrNotFound || r==KErrPathNotFound);
1139 //---------------------------------------------
1140 //! @SYMTestCaseID PBASE-T_TFILE-0659
1142 //! @SYMREQ INC112803
1143 //! @SYMTestCaseDesc Tests that RFs::GetShortName() considers the file extension while generating
1144 //! shortname from longname and applies ~num if applicable.
1145 //! @SYMTestActions 1. Generates the shortname for the given filename.
1146 //! 2. Validates the generated shortname against the original filename.
1147 //! @SYMTestExpectedResults The operation completes with no error. Valid shortname is generated.
1148 //! @SYMTestPriority High
1149 //! @SYMTestStatus Implemented
1150 //---------------------------------------------
1151 static void TestINC112803()
1154 if(!gShortFileNamesSupported)
1156 test.Printf(_L("TestINC112803 : Short names are not supported!\n"));
1162 _LIT(KOrigFileName,"\\F32-TST\\TFILE\\INC112803\\Private2\\101f875a\\2222.JARX");
1163 _LIT(KOrigFileShortName,"\\F32-TST\\TFILE\\INC112803\\Private2\\101f875a\\2222~1.JAR");
1164 _LIT(KDestinationFileName,"\\F32-TST\\TFILE\\INC112803\\Private2\\101f875a\\2222.JAR");
1166 // Make sure the file does not already exist
1167 RmDir(_L("INC112803\\"));
1169 // Create directories and the file
1170 MakeDir(_L("\\F32-TST\\TFILE\\INC112803\\Private2\\101f875a\\"));
1171 MakeFile(KOrigFileName,_L8("FILE PATH : \\F32-TST\\TFILE\\INC112803\\Private2\\101f875a\\"));
1173 // Check the generated shortname of the original file
1175 err = TheFs.GetShortName(KOrigFileName, shortName);
1176 test(err==KErrNone);
1178 // Validate the generated shorname against the original filename.
1179 if (Is_Win32(TheFs, gDriveNum))
1181 test(shortName==_L("2222~1.JAR"));
1183 else if(!IsTestingLFFS())
1185 // LFFS short names not the same as VFAT ones
1186 test(shortName==_L("2222~1.JAR"));
1189 // Validate that the file "2222~1.JAR" can not be created as this is the shortname for "2222.JARX".
1190 MakeFile(KOrigFileShortName,_L8("FILE PATH : \\F32-TST\\TFILE\\INC112803\\Private2\\101f875a\\"));
1191 CheckFileExists(KOrigFileShortName, KErrNone, EFalse);
1193 err = TheFs.Rename(KOrigFileName,KDestinationFileName);
1194 test(err==KErrNone);
1196 // Clean up before leaving
1197 RmDir(_L("INC112803\\"));
1200 static void testIsFileOpen()
1202 // Test the IsFileOpen method
1206 test.Next(_L("Test IsFileOpen"));
1208 TInt r=TheFs.IsFileOpen(_L("OPEN.FILE"),answer);
1209 test(r==KErrNotFound || (r==KErrNone && answer==EFalse));
1211 r=f.Replace(TheFs,_L("OPEN.FILE"),EFileWrite);
1213 r=TheFs.IsFileOpen(_L("OPEN.FILE"),answer);
1215 test(answer!=EFalse);
1217 r=TheFs.IsFileOpen(_L("OPEN.FILE"),answer);
1219 test(answer==EFalse);
1220 r=TheFs.Delete(_L("OPEN.FILE"));
1224 r=f2.Replace(TheFs,_L("AnotherOpen.File"),EFileWrite);
1226 r=TheFs.IsFileOpen(_L("AnotherOpen.File"),answer);
1228 test(answer!=EFalse);
1229 r=f.Replace(TheFs,_L("OPEN.FILE"),EFileWrite);
1231 r=TheFs.IsFileOpen(_L("OPEN.FILE"),answer);
1233 test(answer!=EFalse);
1235 r=TheFs.IsFileOpen(_L("OPEN.FILE"),answer);
1237 test(answer!=EFalse);
1239 r=TheFs.IsFileOpen(_L("OPEN.FILE"),answer);
1241 test(answer==EFalse);
1242 r=TheFs.Delete(_L("AnotherOpen.File"));
1244 r=TheFs.Delete(_L("OPEN.FILE"));
1248 static void testDeleteOpenFiles()
1250 // Test opened files cannot be deleted
1254 test.Next(_L("Test opened files cannot be deleted"));
1257 TInt r=f.Replace(TheFs,_L("Open.File"),EFileWrite);
1259 r=TheFs.Delete(_L("OPEN.FILE"));
1264 r=TheFs.Delete(_L("Open.FILe"));
1268 r=f.Temp(TheFs,_L(""),fileName,EFileWrite);
1270 r=TheFs.Delete(fileName);
1273 r=TheFs.Delete(fileName);
1276 MakeFile(_L("\\Documents\\TEstfile.txt"));
1277 r=f.Open(TheFs,_L("\\Documents\\TEstfile.txt"),EFileWrite);
1279 r=TheFs.Delete(_L("\\Documents\\TEstfile.txt"));
1281 r=TheFs.Delete(_L("\\documents\\TEstfile.txt"));
1283 r=TheFs.Delete(_L("\\Documents.\\TEstfile.txt"));
1284 test(r==KErrBadName);
1285 r=TheFs.Delete(_L("\\documents.\\TEstfile.txt"));
1286 test(r==KErrBadName);
1287 r=TheFs.Delete(_L("\\Documents\\Testfile.txt"));
1289 r=TheFs.Delete(_L("\\documents\\testfile.txt"));
1291 r=TheFs.Delete(_L("\\Documents.\\TEstfile.TXT"));
1292 test(r==KErrBadName);
1293 r=TheFs.Delete(_L("\\docUMENTS.\\TESTFILE.TXT"));
1294 test(r==KErrBadName);
1296 r=TheFs.Delete(_L("\\Documents\\TEstfile.TXT"));
1299 MakeFile(_L("\\Documents\\Documents\\TEstfile.txt"));
1300 r=f.Open(TheFs,_L("\\Documents\\Documents\\TEstfile.txt"),EFileWrite);
1302 r=TheFs.Delete(_L("\\Documents\\documents.\\TEstfile.txt"));
1303 test(r==KErrBadName);
1304 r=TheFs.Delete(_L("\\documents\\Documents.\\TEstfile.txt"));
1305 test(r==KErrBadName);
1306 r=TheFs.Delete(_L("\\Documents.\\documents\\TEstfile.txt"));
1307 test(r==KErrBadName);
1308 r=TheFs.Delete(_L("\\documents.\\Documents\\TEstfile.txt"));
1309 test(r==KErrBadName);
1310 r=TheFs.Delete(_L("\\Documents\\Documents\\Testfile.txt"));
1312 r=TheFs.Delete(_L("\\documents\\documents\\testfile.txt"));
1314 r=TheFs.Delete(_L("\\Documents.\\Documents.\\TEstfile.TXT"));
1315 test(r==KErrBadName);
1316 r=TheFs.Delete(_L("\\docUMENTS.\\docUMENTS.\\TESTFILE.TXT"));
1317 test(r==KErrBadName);
1320 r=TheFs.RmDir(_L("\\Documents\\"));
1322 r=TheFs.RmDir(_L("\\documents\\"));
1324 r=TheFs.RmDir(_L("\\Documents.\\"));
1325 test(r==KErrBadName);
1326 r=TheFs.RmDir(_L("\\documents.\\"));
1327 test(r==KErrBadName);
1328 r=TheFs.RmDir(_L("\\Documents\\documents\\"));
1330 r=TheFs.RmDir(_L("\\documents\\documents.\\"));
1331 test(r==KErrBadName);
1332 r=TheFs.RmDir(_L("\\Documents.\\Documents\\"));
1333 test(r==KErrBadName);
1334 r=TheFs.RmDir(_L("\\documents.\\Documents.\\"));
1335 test(r==KErrBadName);
1336 r=TheFs.RmDir(_L("\\Documents\\TestFile.TXT"));
1338 r=TheFs.RmDir(_L("\\documents\\TestFile"));
1340 r=TheFs.RmDir(_L("\\Documents.\\Testfile."));
1341 test(r==KErrBadName);
1342 r=TheFs.RmDir(_L("\\documents.\\t"));
1343 test(r==KErrBadName);
1345 r=TheFs.Delete(_L("\\Documents\\documents\\TEstfile.TXT"));
1347 r=TheFs.RmDir(_L("\\Documents\\documents.\\"));
1348 test(r==KErrBadName);
1349 r=TheFs.RmDir(_L("\\Documents.\\"));
1350 test(r==KErrBadName);
1353 static void testFileSeek()
1358 test.Next(_L("Test file seek"));
1360 TInt r=f.Open(TheFs,_L("T_File.cpp"),EFileWrite);
1363 TBuf8<20> text1;TInt pos1=0;
1364 TBuf8<20> text2;TInt pos2=510;
1365 TBuf8<20> text3;TInt pos3=900;
1366 TBuf8<20> text4;TInt pos4=2010;
1367 TBuf8<20> text5;TInt pos5=4999;
1369 r=f.Read(pos1,text1);
1371 r=f.Read(pos2,text2);
1373 r=f.Read(pos3,text3);
1375 r=f.Read(pos4,text4);
1377 r=f.Read(pos5,text5);
1382 r=f.Read(pos3,testBuf);
1384 test(testBuf==text3);
1386 r=f.Read(pos1,testBuf);
1388 test(testBuf==text1);
1390 r=f.Read(pos4,testBuf);
1392 test(testBuf==text4);
1394 r=f.Read(pos2,testBuf);
1396 test(testBuf==text2);
1398 r=f.Read(pos5,testBuf);
1400 test(testBuf==text5);
1402 r=f.Read(pos2,testBuf);
1404 test(testBuf==text2);
1407 r=f.Read(pos2,testBuf);
1409 test(testBuf==text2);
1412 r=f.Read(pos1,testBuf);
1414 test(testBuf==text1);
1415 r=f.Read(pos2,testBuf);
1417 test(testBuf==text2);
1419 r=f.Read(pos1,testBuf);
1421 test(testBuf==text1);
1424 r=f.Read(pos1,testBuf);
1426 test(testBuf==text1);
1429 r=f.Read(pos1,testBuf);
1431 test(testBuf==text1);
1435 static void testMoreFileSeek()
1437 // Further test of RFile::Seek()
1440 // Create a zero length file
1442 TInt r=file.Replace(TheFs,_L("\\F32-TST\\TFILE\\seektest"),EFileRead|EFileWrite);
1446 // Seek beyond the length of the file
1448 seekPos = 80; // Pick a likely offset
1449 TInt err = file.Seek(ESeekEnd, seekPos); // and go there
1450 test(err==KErrNone);
1451 test(seekPos==20); // Somewhat non-intuitive?
1453 r=file.Write(_L8("A Devil's Haircut"));
1456 r=file.Size(newFileSize);
1460 err = file.Seek(ESeekCurrent, seekPos); // Find out where we ended up?
1461 test(err==KErrNone);
1466 err=file.Seek(ESeekStart, seekPos);
1467 test(err==KErrNone);
1470 err=file.Seek(ESeekEnd, seekPos);
1471 test(err==KErrNone);
1475 err=file.Seek(ESeekEnd, seekPos);
1476 test(err==KErrNone);
1480 err=file.Seek(ESeekEnd, seekPos);
1481 test(err==KErrNone);
1485 err=file.Seek(ESeekStart,seekPos);
1486 test(err==KErrArgument);
1490 err=file.Seek(ESeekEnd,seekPos);
1491 test(err==KErrNone);
1495 r=TheFs.Delete(_L("\\F32-TST\\TFILE\\seektest"));
1499 static void testSetSize()
1505 test.Next(_L("Test SetSize"));
1508 TInt r=f1.Replace(TheFs,_L("File.File"),EFileWrite);
1515 gBuf.SetLength(1334);
1516 for(i=64;i<1334+64;i++)
1517 gBuf[i-64]=(TUint8)i;
1518 r=f1.Write(30,gBuf);
1519 r=f1.Read(30,gBuf,1000);
1526 test.Next(_L("Open a large file"));
1527 r=f1.Replace(TheFs,_L("File.File"),EFileWrite);
1530 r=f1.SetSize(131072); // 128K
1532 TBuf8<16> testData=_L8("testData");
1533 r=f1.Write(131060,testData);
1536 r=f1.Open(TheFs,_L("File.File"),EFileRead);
1542 TBuf8<16> testData2;
1543 r=f1.Read(131060,testData2,8);
1545 test(testData==testData2);
1547 TheFs.Delete(_L("File.file"));
1551 static void testIsRomAddress()
1554 TInt r=f.Open(TheFs, PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)?_L("Z:\\Sys\\Bin\\eshell.exe"):_L("Z:\\System\\Bin\\eshell.exe"), EFileRead);
1557 r=f.Seek(ESeekAddress, anAddress);
1559 #if !defined(__WINS__)
1560 test(RFs::IsRomAddress((TAny *)anAddress)); // Always returns EFalse if WINS
1562 test(RFs::IsRomAddress(NULL)==FALSE);
1566 #include "../../../userlibandfileserver/fileserver/inc/message.h"
1567 #include <f32plugin.h>
1569 static void testMiscellaneousReportedBugs()
1571 // Test bug reports, real or imaginary
1575 test.Next(_L("Miscellaneous tests"));
1578 TInt r=f1.Replace(TheFs,_L("File.File"),EFileWrite);
1584 TPtrC8 buf((TText8*)&data,1);
1586 // r=f1.Write(_L("\0"));
1592 r=f1.Seek(ESeekStart,temp);
1601 class RHackFile : public RFile
1604 inline TInt SendReceive(TInt aFunction, const TIpcArgs& aArgs) const
1605 { return RSubSessionBase::SendReceive(aFunction, aArgs); }
1609 f2.Open(TheFs, _L("File.File"), EFileRead);
1610 test(r == KErrNone);
1611 r = f2.SendReceive(/*47*/ EFsFileChangeMode, TIpcArgs(EFileRead | EFileWrite)); // <- must fail!
1612 test(r == KErrArgument);
1613 r = f2.Write(_L8("Hacked!")); // <- must fail!
1614 test(r == KErrAccessDenied);
1617 r=TheFs.Delete(_L("File.FIle"));
1621 static void testFileRename()
1627 test.Next(_L("Test rename"));
1628 TBuf<64> name1=_L("asdfasdfasdfasfd.qwer");
1629 TBuf<64> name2=_L("File.xyz");
1630 TBuf<64> name3=_L("ASdfasdFasdfasfd.qwer");
1636 //-- test renaming a file to a non-existing directory
1637 r = TheFs.MkDir(_L("\\temp\\"));
1638 test(r==KErrNone || r==KErrAlreadyExists);
1640 r = f1.Replace(TheFs, _L("\\temp\\file1"), 0);
1643 r = f1.Rename(_L("\\temp\\temp\\file1"));
1644 test(r == KErrPathNotFound);
1649 r=f1.Replace(TheFs,name2,EFileWrite);
1651 r=f1.Write(_L8("1234"));
1653 TInt len=CheckFileExists(name2,KErrNone);
1658 r=f1.Read(0,contents);
1660 test(contents==_L8("1234"));
1661 r=f1.Write(4,_L8("5678"));
1664 len=CheckFileExists(name1,KErrNone);
1666 CheckFileExists(name2,KErrNotFound);
1667 r=f1.Write(8,_L8("90"));
1670 len=CheckFileExists(name1,KErrNone);
1673 test.Next(_L("Test can change case using rename"));
1674 r=f1.Open(TheFs,name1,EFileRead|EFileWrite);
1678 CheckFileExists(name1,KErrNone,EFalse);
1679 len=CheckFileExists(name3,KErrNone);
1682 CheckFileExists(name1,KErrNone,EFalse);
1683 len=CheckFileExists(name3,KErrNone);
1686 test.Next(_L("Test can rename to an identical filename"));
1687 r=f1.Open(TheFs,name3,EFileRead|EFileWrite);
1691 len=CheckFileExists(name3,KErrNone);
1694 len=CheckFileExists(name3,KErrNone);
1697 test.Next(_L("Test rename to a name containing a wildcard is rejected"));
1698 r=f1.Open(TheFs,name3,EFileRead|EFileWrite);
1700 r=f1.Rename(_L("asdf*ASDF"));
1701 test(r==KErrBadName);
1702 r=f1.Rename(_L("asdf?AF"));
1703 test(r==KErrBadName);
1706 r=f1.Open(TheFs,name3,EFileRead);
1708 r=f1.Read(contents);
1710 test(contents==_L8("1234567890"));
1711 r=f1.Read(contents);
1713 test(contents.Length()==0);
1716 test.Next(_L("Check file date is retained"));
1717 TDateTime dateTime(1995,(TMonth)10,19,23,0,0,0);
1718 TTime oldTime(dateTime);
1719 r=TheFs.SetEntry(name3,oldTime,0,0);
1721 r=f1.Open(TheFs,name3,EFileRead|EFileWrite);
1724 r=f1.Modified(check);
1726 test(check==oldTime);
1728 r=f1.Rename(_L("OldFile.Old"));
1731 r=f1.Modified(check);
1733 test(check==oldTime);
1734 r=TheFs.Modified(_L("oldfile.old"),check);
1736 test(check==oldTime);
1738 r=TheFs.Modified(_L("oldfile.old"),check);
1740 test(check==oldTime);
1743 static void TestFileUids()
1745 // Test uids in files
1749 test.Next(_L("Uids in files"));
1750 TUidType uidData(TUid::Uid(1),TUid::Uid(1),TUid::Uid(1));
1751 MakeFile(_L("Tmp04005.$$$"),uidData,_L8("Some other data"));
1752 TUidType uidData1(TUid::Uid(2),TUid::Uid(2),TUid::Uid(2));
1753 MakeFile(_L("Sketch(01)"),uidData1,_L8("A different sketch"));
1756 TInt r=TheFs.Entry(_L("Tmp04005.$$$"),e);
1758 test(uidData==e.iType);
1759 r=TheFs.Entry(_L("Sketch(01)"),e);
1761 test(uidData1==e.iType);
1763 test.Next(_L("Test replace preserves UIDs"));
1764 r=TheFs.Replace(_L("Tmp04005.$$$"),_L("Sketch(01)"));
1767 r=TheFs.Entry(_L("Tmp04005.$$$"),e);
1768 test(r==KErrNotFound);
1769 r=TheFs.Entry(_L("Sketch(01)"),e);
1771 test(uidData==e.iType);
1775 static void TestMaxLengthFilenames()
1777 // Test max length filenames can be created/deleted
1781 #if defined(__WINS__)
1782 if (gSessionPath[0]=='C')
1786 test.Next(_L("Test max length filenames"));
1788 CreateLongName(bigName,gSeed,255);
1791 TInt r=f.Create(TheFs,bigName,EFileRead);
1792 test(r==KErrBadName);
1793 bigName.SetLength(254);
1794 r=f.Create(TheFs,bigName,EFileRead);
1799 TFileName countedBigName=bigName;
1800 // This loop may not reach the '\' character, or we will get a bad path.
1801 for (count=0;count<('Z'-'A');count++)
1803 countedBigName[2]=(TText)('A'+count);
1804 r=f.Create(TheFs,countedBigName,EFileRead);
1807 r=TheFs.Delete(countedBigName);
1808 test(r==KErrNotFound);
1812 test.Printf(_L("File create failed:%d"),r);
1818 countedBigName[2]=(TText)('A'+count);
1819 r=TheFs.Delete(countedBigName);
1823 r=TheFs.Delete(bigName);
1826 TFileName subDirFileName=_L("\\F32-TST\\TFILE");
1827 bigName.SetLength(241);
1828 subDirFileName.Append(bigName);
1829 r=f.Create(TheFs,subDirFileName,EFileRead);
1830 test(r==KErrBadName);
1831 subDirFileName.SetLength(254);
1832 r=f.Create(TheFs,subDirFileName,EFileRead);
1835 r=TheFs.Delete(subDirFileName);
1842 static void testReadersWriters()
1844 // Test EFileShareReadersOrWriters file sharing.
1848 test.Start(_L("Test EFileShareReadersOrWriters sharing"));
1849 MakeFile(_L("TESTER"));
1851 // Open a file in EFileShareReadersOnly mode
1853 TInt r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
1856 // Opening a share in EFileShareReadersOnly mode should succeed
1858 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
1862 // Opening a share in EFileShareReadersOrWriters mode with EFileRead access should succeed
1863 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead);
1867 // Opening a share in EFileShareReadersOrWriters mode with EFileWrite access should succeed
1868 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileWrite);
1871 // Opening a share in EFileShareReadersOrWriters mode with EFileRead|EFileWrite access should succeed
1872 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead|EFileWrite);
1875 // Opening a share in EShareAny mode should fail
1876 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
1881 //////////////////////
1883 // Open a file in EFileShareReadersOrWriters mode for reading
1884 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead);
1887 // Opening a share in EFileShareExclusive mode should fail
1888 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
1891 // Opening a share in EFileShareReadersOnly mode should succeed
1892 // (the share doesn't care if the file is opened for reading or writing)
1893 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
1897 // Opening a share in EFileShareReadersOnly mode with EFileRead accesss should succeed
1898 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead);
1902 // Opening a share in EFileShareReadersOnly mode with EFileWrite accesss should succeed
1903 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileWrite);
1907 // Opening a share in EFileShareReadersOnly mode with EFileRead|EFileWrite accesss should succeed
1908 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead|EFileWrite);
1912 // Opening a share in EFileShareAny mode should succeed
1913 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
1919 //////////////////////
1921 // Open a file in EFileShareReadersOrWriters mode for writing
1922 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileWrite);
1925 // Opening a share in EFileShareExclusive mode should fail
1926 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
1929 // Opening a share in EFileShareReadersOnly mode should fail
1930 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
1933 // Opening a share in EFileShareReadersOrWriters mode with EFileRead access should succeed
1934 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead);
1938 // Opening a share in EFileShareReadersOrWriters mode with EFileWrite access should succeed
1939 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileWrite);
1943 // Opening a share in EFileShareReadersOrWriters mode with EFileRead|EFileWrite access should succeed
1944 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead|EFileWrite);
1948 // Opening a share in EFileShareAny mode should succeed
1949 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
1955 //////////////////////////
1957 // Open a file in EFileShareAny mode
1958 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
1961 // Opening a share in EFileShareExclusive mode should fail
1962 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareExclusive);
1965 // Opening a share in EFileShareReadersOnly mode should fail
1966 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
1969 // Opening a share in EFileShareReadersOrWriters mode with EFileRead access should succeed
1970 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead);
1974 // Opening a share in EFileShareReadersOrWriters mode with EFileWrite access should succeed
1975 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileWrite);
1979 // Opening a share in EFileShareReadersOrWriters mode with EFileRead|EFileWrite access should succeed
1980 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead|EFileWrite);
1984 // Opening a share in EFileShareAny mode with should succeed
1985 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
1991 //////////////////////
1993 // Open a file in EFileShareReadersOrWriters mode for reading
1994 r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead);
1997 // Opening a share in EFileShareReadersOnly mode should succeed
1998 // - The share should now be promoted to EFileShareReadersOnly mode
1999 r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
2006 // Opening a share in EFileShareReadersOnly mode with EFileRead accesss should succeed
2007 r=f3.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead);
2011 // Opening a share in EFileShareReadersOnly mode with EFileWrite accesss should fail
2012 r=f3.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileWrite);
2015 // The share is promoted - should obey EFileShareReadersOnly rules
2020 // The share is demoted - should obey EFileShareReadersOrWriters rules
2025 // Opening a share in EFileShareReadersOnly mode with EFileRead|EFileWrite accesss should fail
2026 r=f3.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOrWriters|EFileRead|EFileWrite);
2029 // The share is promoted - should obey EFileShareReadersOnly rules
2034 // The share is demoted - should obey EFileShareReadersOrWriters rules
2039 // Opening a share in EFileShareAny mode should fails
2040 r=f3.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareAny);
2043 // The share is promoted - should obey EFileShareReadersOnly rules
2049 // The share is demoted - should obey EFileShareReadersOrWriters rules
2061 static void testINC070455()
2063 // INC070455 - RFile.ChangeMode() panics
2066 _LIT(KTestName, "Test INC070455 - RFile.ChangeMode() panics");
2067 test.Start(KTestName);
2070 // To reproduce this defect, we need a filename of less than 10 characters.
2071 // We cannot use the directories used by the rest of this test harness.
2072 _LIT(KShortName, "C:\\file.txt");
2075 test.Next(_L("Create file..."));
2077 TInt r = TheFile.Create(TheFs, KShortName, EFileWrite);
2078 test((KErrNone == r) || (KErrAlreadyExists == r));
2082 test.Next(_L("Re-open the file..."));
2083 r = TheFile.Open(TheFs, KShortName, EFileRead | EFileShareExclusive);
2084 test (KErrNone == r);
2087 test.Next(_L("Change the file\'s mode..."));
2088 r = TheFile.ChangeMode(EFileShareReadersOnly);
2089 test (KErrNone == r);
2093 test.Next(_L("Tidy up"));
2094 r = TheFs.Delete(KShortName);
2095 test (KErrNone == r);
2101 LOCAL_D TBuf8<0x80000> gLongBuf;
2102 _LIT(KFileName, "\\zerolengthsourcedescriptortest.txt");
2104 static void zeroSrcDesc()
2109 static void setSrcDescLen()
2111 gLongBuf.SetLength(0x80000);
2114 static void createTestFile(RFile& aFile)
2116 TInt r = aFile.Create(TheFs, KFileName, EFileWrite);
2117 test((KErrNone == r) || (KErrAlreadyExists == r));
2120 static void removeTestFile(RFile& aFile)
2123 TInt r = TheFs.Delete(KFileName);
2124 test (KErrNone == r);
2128 static TInt testWritePanic(TAny* aPtr)
2130 RFile * ptr = (RFile *)aPtr;
2131 TInt r=ptr->Write(gLongBuf,0x80000);
2132 test (KErrNone == r);
2136 static void testNegativeLengthToWrite()
2138 // DEF091545 - Tests added to check the write function behaviour with Negative length
2141 test.Start(_L("Test RFile::Write variants with Negative Length parameter"));
2143 LOCAL_D TBuf8<0x100> gBuf;
2146 TRequestStatus status1(KRequestPending);
2147 TRequestStatus status2(KRequestPending);
2149 // EXPORT_C TInt RFile::Write(const TDesC8& aDes,TInt aLength)
2150 createTestFile(TheFile);
2152 r=TheFile.Write(gBuf, -1);
2153 test(r==KErrArgument);
2155 removeTestFile(TheFile);
2157 // EXPORT_C void RFile::Write(const TDesC8& aDes,TInt aLength, TRequestStatus& aStatus)
2158 createTestFile(TheFile);
2159 TheFile.Write(gBuf,-1, status1);
2160 User::WaitForRequest(status1);
2161 test ( status1.Int() == KErrArgument);
2163 removeTestFile(TheFile);
2167 // EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes,TInt aLength)
2168 createTestFile(TheFile);
2169 r = TheFile.Write(0,gBuf,-1);
2170 test(r==KErrArgument);
2171 removeTestFile(TheFile);
2174 // EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus)
2175 createTestFile(TheFile);
2176 TheFile.Write(0, gBuf,-1, status2);
2177 User::WaitForRequest(status2);
2178 test ( status2.Int() == KErrArgument);
2179 removeTestFile(TheFile);
2187 static TInt testLockPanic(TAny* aPtr)
2191 RFile * ptr = (RFile *)aPtr;
2192 TInt r=ptr->Lock(aPos, aLen);
2193 test (KErrNone == r);
2197 static TInt testUnLockPanic(TAny* aPtr)
2201 RFile * ptr = (RFile *)aPtr;
2202 TInt r=ptr->UnLock(aPos, aLen);
2203 test (KErrNone == r);
2207 static TInt testSetSizePanic(TAny* aPtr)
2210 RFile * ptr = (RFile *)aPtr;
2211 TInt r=ptr->SetSize(aSize);
2212 test (KErrNone == r);
2216 static void testNegativeLength()
2218 test.Start(_L("Test RFile::Lock, RFile::Unlock and RFile::SetSize with Negative Length parameter"));
2220 test(TheFs.ShareProtected() == KErrNone);
2223 createTestFile(TheFile);
2224 TRequestStatus status = KRequestPending;
2226 // launch call on separate thread as expected to panic
2227 // Test Lock with a negative length
2228 User::SetJustInTime(EFalse);
2230 test(t.Create(_L("testLockPanic"), testLockPanic, KDefaultStackSize, 0x2000, 0x2000, &TheFile) == KErrNone);
2233 User::WaitForRequest(status);
2234 User::SetJustInTime(ETrue);
2235 test(t.ExitType() == EExitPanic);
2236 test(t.ExitReason() == 17);
2240 // Test Unlock with a negative length
2241 User::SetJustInTime(EFalse);
2242 status = KRequestPending;
2243 test(t.Create(_L("testUnLockPanic"), testUnLockPanic, KDefaultStackSize, 0x2000, 0x2000, &TheFile) == KErrNone);
2246 User::WaitForRequest(status);
2247 test(t.ExitType() == EExitPanic);
2248 test(t.ExitReason() == 18);
2250 User::SetJustInTime(ETrue);
2252 // Test SetSize with a negative length
2253 User::SetJustInTime(EFalse);
2254 status = KRequestPending;
2255 test(t.Create(_L("testSetSizePanic"), testSetSizePanic, KDefaultStackSize, 0x2000, 0x2000, &TheFile) == KErrNone);
2258 User::WaitForRequest(status);
2259 test(t.ExitType() == EExitPanic);
2260 test(t.ExitReason() == 20);
2262 User::SetJustInTime(ETrue);
2264 removeTestFile(TheFile);
2268 static void testZeroLengthDescriptors()
2270 // INC088416 - NAND thread crash when doing async writes to internal memory
2272 // Test each variant of RFile::Write against zero length source descriptor arguements
2274 test.Start(_L("Test RFile::Write variants with Zero Length Source Descriptor"));
2277 TRequestStatus status(KRequestPending);
2280 // EXPORT_C TInt RFile::Write(const TDesC8& aDes) PASS ZERO length descriptor
2282 createTestFile(TheFile);
2286 test.Next(_L("Execute sync call RFile::Write(const TDesC8& aDes) with zero length aDes"));
2287 TInt r=TheFile.Write(gLongBuf);
2290 test.Printf(_L("Test case passed\n"));
2292 removeTestFile(TheFile);
2295 // EXPORT_C void RFile::Write(const TDesC8& aDes,TRequestStatus& aStatus) PASS ZERO length descriptor
2297 createTestFile(TheFile);
2299 status = KRequestPending;
2302 test.Next(_L("Start async call RFile::Write(const TDesC8& aDes,TRequestStatus& aStatus) with zero length sDes"));
2303 TheFile.Write(gLongBuf,status);
2304 User::WaitForRequest(status);
2305 test(status.Int()==KErrNone);
2307 test.Printf(_L("Test case passed\n"));
2309 removeTestFile(TheFile);
2312 // EXPORT_C void RFile::Write(const TDesC8& aDes,TRequestStatus& aStatus) SCROBBLE descriptor to ZERO length during async write
2314 createTestFile(TheFile);
2316 status = KRequestPending;
2319 test.Next(_L("Start async call RFile::Write(const TDesC8& aDes,TRequestStatus& aStatus)"));
2320 TheFile.Write(gLongBuf,status);
2321 test.Printf(_L("Zero source descriptor during async write\n"));
2323 User::WaitForRequest(status);
2324 test(status.Int()==KErrNone);
2326 test.Printf(_L("Test case passed\n"));
2328 removeTestFile(TheFile);
2331 // EXPORT_C TInt RFile::Write(const TDesC8& aDes,TInt aLength) PASS ZERO length descriptor
2333 createTestFile(TheFile);
2335 status = KRequestPending;
2338 test.Next(_L("Execute sync call RFile::Write(const TDesC8& aDes,TInt aLength) with zero length aDes"));
2340 // launch call on separate thread as expected to panic
2341 User::SetJustInTime(EFalse);
2342 status = KRequestPending;
2344 test(t.Create(_L("testWritePanic"), testWritePanic, KDefaultStackSize, 0x2000, 0x2000, &TheFile) == KErrNone);
2347 User::WaitForRequest(status);
2348 test(t.ExitType() == EExitPanic);
2349 test(t.ExitReason() == 27);
2351 User::SetJustInTime(ETrue);
2354 r=TheFile.Write(gLongBuf, 0x80000);
2358 test.Printf(_L("Test case passed\n"));
2360 removeTestFile(TheFile);
2363 // EXPORT_C void RFile::Write(const TDesC8& aDes,TInt aLength, TRequestStatus& aStatus) PASS ZERO length descriptor
2365 createTestFile(TheFile);
2367 status = KRequestPending;
2370 test.Next(_L("Start async call RFile::Write(const TDesC8& aDes, TInt aLength,TRequestStatus& aStatus) with zero length sDes"));
2371 TheFile.Write(gLongBuf, 0x80000, status); ;
2372 User::WaitForRequest(status);
2373 test(status.Int()==KErrNone);
2375 test.Printf(_L("Test case passed\n"));
2377 removeTestFile(TheFile);
2380 // EXPORT_C void RFile::Write(const TDesC8& aDes,TInt aLength, TRequestStatus& aStatus) SCROBBLE descriptor to ZERO length during async write
2382 createTestFile(TheFile);
2384 status = KRequestPending;
2387 test.Next(_L("Start async call RFile::Write(const TDesC8& aDes, Int aLength,TRequestStatus& aStatus)"));
2388 TheFile.Write(gLongBuf,0x80000, status);
2389 test.Printf(_L("Zero source descriptor during async write\n"));
2391 User::WaitForRequest(status);
2392 test(status.Int()==KErrNone);
2394 test.Printf(_L("Test case passed\n"));
2396 removeTestFile(TheFile);
2399 // EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes) PASS ZERO length descriptor
2401 createTestFile(TheFile);
2405 test.Next(_L("Execute sync call RFile::Write(TInt aPos, const TDesC8& aDes) with zero length aDes"));
2406 r=TheFile.Write(0, gLongBuf);
2409 test.Printf(_L("Test case passed\n"));
2411 removeTestFile(TheFile);
2414 // EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes,TRequestStatus& aStatus) PASS ZERO length descriptor
2416 createTestFile(TheFile);
2418 status = KRequestPending;
2421 test.Next(_L("Start async call RFile::Write(TInt aPos, const TDesC8& aDes, TRequestStatus& aStatus) with zero length sDes"));
2422 TheFile.Write(0, gLongBuf, status);
2423 User::WaitForRequest(status);
2424 test(status.Int()==KErrNone);
2426 test.Printf(_L("Test case passed\n"));
2428 removeTestFile(TheFile);
2431 // EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes,TRequestStatus& aStatus) SCROBBLE descriptor to ZERO length during async write
2433 createTestFile(TheFile);
2435 status = KRequestPending;
2438 test.Next(_L("Start async call RFile::Write(TInt aPos, const TDesC8& aDes, TRequestStatus& aStatus)"));
2439 TheFile.Write(0, gLongBuf, status);
2440 test.Printf(_L("Zero source descriptor during async write\n"));
2442 User::WaitForRequest(status);
2443 test(status.Int()==KErrNone);
2445 test.Printf(_L("Test case passed\n"));
2447 removeTestFile(TheFile);
2450 // EXPORT_C TInt RFile::Write(TInt aPos,const TDesC8& aDes,TInt aLength) PASS ZERO length descriptor
2452 createTestFile(TheFile);
2456 test.Next(_L("Execute sync call RFile::Write(TInt aPos, const TDesC8& aDes, TInt aLength) with zero length aDes"));
2457 r=TheFile.Write(0, gLongBuf, 0x80000);
2460 test.Printf(_L("Test case passed\n"));
2462 removeTestFile(TheFile);
2465 // EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus) PASS ZERO length descriptor
2467 createTestFile(TheFile);
2469 status = KRequestPending;
2472 test.Next(_L("Start async call RFile::Write(TInt aPos, const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus) with zero length sDes"));
2473 TheFile.Write(0, gLongBuf, 0x80000, status);
2474 User::WaitForRequest(status);
2475 test(status.Int()==KErrNone);
2477 test.Printf(_L("Test case passed\n"));
2479 removeTestFile(TheFile);
2482 // EXPORT_C void RFile::Write(TInt aPos,const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus) SCROBBLE descriptor to ZERO length during async write
2484 createTestFile(TheFile);
2486 status = KRequestPending;
2489 test.Next(_L("Start async call RFile::Write(TInt aPos, const TDesC8& aDes, TInt aLength, TRequestStatus& aStatus"));
2490 TheFile.Write(0, gLongBuf, 0x80000, status);
2491 test.Printf(_L("Zero source descriptor during async write\n"));
2493 User::WaitForRequest(status);
2494 test(status.Int()==KErrNone);
2496 test.Printf(_L("Test case passed\n"));
2498 removeTestFile(TheFile);
2504 static void testReadBufferOverflow()
2506 // Test each variant of RFile::Read when the specified extent to read is
2507 // greater than the available buffer space
2510 test.Start(_L("Test RFile::Read for oversized requests"));
2513 TInt r = file.Create(TheFs, KFileName, EFileRead);
2514 test((KErrNone == r) || (KErrAlreadyExists == r));
2516 TInt err = KErrNone;
2517 TRequestStatus status(KRequestPending);
2520 // EXPORT_C TInt RFile::Read(TDes8& aDes,TInt aLength) const
2521 err = file.Read(buf8,5);
2522 test(err==KErrOverflow);
2525 // EXPORT_C void RFile::Read(TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const
2526 file.Read(buf8,5,status);
2527 test(status.Int()==KErrOverflow);
2528 status = KRequestPending;
2530 // EXPORT_C TInt RFile::Read(TInt aPos,TDes8& aDes,TInt aLength) const
2531 err = file.Read(0,buf8,5);
2532 test(err==KErrOverflow);
2534 // EXPORT_C void RFile::Read(TInt aPos,TDes8& aDes,TInt aLength,TRequestStatus& aStatus) const
2535 file.Read(0,buf8,5,status);
2536 test(status.Int()==KErrOverflow);
2538 removeTestFile(file);
2542 RSemaphore gSleepThread;
2543 TFileName gLastTempFileName;
2550 static TInt DeleteOnCloseClientThread(TAny* aMode)
2552 TTestDoCMode testMode = *(TTestDoCMode*)&aMode;
2553 TUint fileMode=EFileRead;
2557 TInt r=fs.Connect();
2559 r=fs.SetSessionPath(gSessionPath);
2561 if (testMode & EDoCDeleteOnClose)
2562 fileMode|=EDeleteOnClose;
2563 r=file.Temp(fs,_L(""),gLastTempFileName,fileMode);
2565 // Signal controlling thread and pause for panic where requested
2567 if (testMode & EDoCPanic)
2569 gSleepThread.Signal();
2570 User::After(10000000);
2573 if (!(testMode & EDoCPanic))
2574 gSleepThread.Signal();
2579 static void TestDeleteOnClose()
2581 // Test RFile::Temp delete on close behaviour
2584 test.Start(_L("RFile::Temp default file close behaviour"));
2586 gSleepThread.CreateLocal(0);
2587 RThread clientThread;
2590 TFileName filename =_L("DoCFile.tst");
2594 //---------------------------------------------------------------------------------------------------------------------
2595 //! @SYMTestCaseID PBASE-t_file-0804
2597 //! @SYMTestCaseDesc Verifying the original behaviour of RFile::Temp()
2599 //! @SYMTestPriority High
2601 //! 1. Test thread creates a file with DeleteOnClose flag unset and
2603 //! The main test body attempts to delete the resulting temporary
2606 //! @SYMTestExpectedResults
2607 //! 1. The temporary file is successfully created and deleted.
2608 //---------------------------------------------------------------------------------------------------------------------
2609 r=clientThread.Create(_L("DeleteOnCloseClientThread 1"),DeleteOnCloseClientThread,KDefaultStackSize,0x2000,0x2000,(TAny*)0);
2611 clientThread.Resume();
2612 gSleepThread.Wait();
2613 r=TheFs.Delete(gLastTempFileName);
2615 clientThread.Close();
2618 //---------------------------------------------------------------------------------------------------------------------
2619 //! @SYMTestCaseID PBASE-t_file-0805
2621 //! @SYMTestCaseDesc Verifying the Delete on Close behaviour of RFile::Temp()
2623 //! @SYMTestPriority High
2625 //! 1. Test thread creates a file with DeleteOnClose flag set and
2627 //! The main test body attempts to delete the resulting temporary
2630 //! @SYMTestExpectedResults
2631 //! 1. The temporary file is successfully created and automatically
2632 //! deleted upon close. The subsequent attempted file deletion
2633 //! by the main test body should fail with KErrNotFound.
2634 //---------------------------------------------------------------------------------------------------------------------
2635 test.Next(_L("RFile::Temp EDeleteOnClose behaviour"));
2636 r=clientThread.Create(_L("DeleteOnCloseClientThread 2"),DeleteOnCloseClientThread,KDefaultStackSize,0x2000,0x2000,(TAny*)EDoCDeleteOnClose);
2638 clientThread.Resume();
2639 gSleepThread.Wait();
2640 r=TheFs.Delete(gLastTempFileName);
2641 test(r==KErrNotFound);
2642 clientThread.Close();
2645 //---------------------------------------------------------------------------------------------------------------------
2646 //! @SYMTestCaseID PBASE-t_file-0806
2648 //! @SYMTestCaseDesc Verifying the original, panic behaviour of RFile::Temp()
2650 //! @SYMTestPriority High
2652 //! 1. Test thread creates a file with DeleteOnClose flag unset and
2653 //! is paniced by the main test body.
2654 //! The main test body attempts to delete the resulting temporary
2657 //! @SYMTestExpectedResults
2658 //! 1. The temporary file is successfully created and deleted.
2659 //---------------------------------------------------------------------------------------------------------------------
2660 test.Next(_L("RFile::Temp default panic behaviour"));
2661 r=clientThread.Create(_L("DeleteOnCloseClientThread 3"),DeleteOnCloseClientThread,KDefaultStackSize,0x2000,0x2000,(TAny*)EDoCPanic);
2663 clientThread.Resume();
2664 gSleepThread.Wait();
2665 User::SetJustInTime(EFalse);
2666 clientThread.Panic(_L("Panic temp file thread #3"),KErrGeneral);
2667 User::SetJustInTime(ETrue);
2668 CLOSE_AND_WAIT(clientThread);
2670 r=TheFs.Delete(gLastTempFileName);
2674 //---------------------------------------------------------------------------------------------------------------------
2675 //! @SYMTestCaseID PBASE-t_file-0807
2677 //! @SYMTestCaseDesc Verifying the Delete on Close, panic behaviour of RFile::Temp()
2679 //! @SYMTestPriority High
2681 //! 1. Test thread creates a file with DeleteOnClose flag set and
2682 //! is paniced by the main test body.
2683 //! The main test body attempts to delete the resulting temporary
2686 //! @SYMTestExpectedResults
2687 //! 1. The temporary file is successfully created and automatically
2688 //! deleted upon close. The subsequent attempted file deletion
2689 //! by the main test body should fail with KErrNotFound.
2690 //---------------------------------------------------------------------------------------------------------------------
2691 test.Next(_L("RFile::Temp EDeleteOnClose panic behaviour"));
2692 r=clientThread.Create(_L("DeleteOnCloseClientThread 4"),DeleteOnCloseClientThread,KDefaultStackSize,0x2000,0x2000,(TAny*)(EDoCPanic|EDoCDeleteOnClose));
2694 clientThread.Resume();
2695 gSleepThread.Wait();
2696 User::SetJustInTime(EFalse);
2697 clientThread.Panic(_L("Panic temp file thread #4"),KErrGeneral);
2698 User::SetJustInTime(ETrue);
2699 CLOSE_AND_WAIT(clientThread);
2701 r=TheFs.Delete(gLastTempFileName);
2702 test(r==KErrNotFound);
2705 //---------------------------------------------------------------------------------------------------------------------
2706 //! @SYMTestCaseID PBASE-t_file-0808
2708 //! @SYMTestCaseDesc Verifying RFile::Create() supports Delete On Close.
2710 //! @SYMTestPriority High
2712 //! 1. Test creates a file with DeleteOnClose flag set and
2713 //! then closes the file.
2714 //! 2. Test attempts to delete the file.
2716 //! @SYMTestExpectedResults
2717 //! 1. The file creation should succeed.
2718 //! 2. The file deletion should fail with KErrNotFound.
2719 //---------------------------------------------------------------------------------------------------------------------
2720 test.Next(_L("RFile::Create EDeleteOnClose behaviour"));
2721 r=file.Create(TheFs,_L("DoC5"),EFileRead|EFileWrite|EDeleteOnClose);
2724 r=TheFs.Delete(filename);
2725 test(r==KErrNotFound);
2728 //---------------------------------------------------------------------------------------------------------------------
2729 //! @SYMTestCaseID PBASE-t_file-0809
2731 //! @SYMTestCaseDesc Verifying Delete On Close with multiple subsessions.
2733 //! @SYMTestPriority High
2735 //! 1. Test creates a file with DeleteOnClose and FileShareAny flags
2736 //! set, opens the file a second time with the FileShareAny flag set
2737 //! and then closes the first file handle.
2738 //! 2. Test attempts to delete the file.
2739 //! 3. The second file handle is closed and the test attempts to delete
2742 //! @SYMTestExpectedResults
2743 //! 1. The file create and file open should succeed.
2744 //! 2. The file deletion should fail with KErrInUse.
2745 //! 3. The file deletion should fail with KErrNotFound.
2746 //---------------------------------------------------------------------------------------------------------------------
2747 test.Next(_L("DoC 6 - Multiple subsessions"));
2748 r=file.Create(TheFs,filename,EFileShareAny|EFileRead|EFileWrite|EDeleteOnClose);
2750 r=file2.Open(TheFs,filename,EFileShareAny|EFileRead|EFileWrite);
2754 r=TheFs.Delete(filename);
2757 r=TheFs.Delete(filename);
2758 test(r==KErrNotFound);
2761 //---------------------------------------------------------------------------------------------------------------------
2762 //! @SYMTestCaseID PBASE-t_file-0810
2764 //! @SYMTestCaseDesc Verifying Delete On Close with preexisting file.
2766 //! @SYMTestPriority High
2768 //! 1. Test creates and closes a file, then attempts to create the same
2769 //! file with Delete on Close set.
2771 //! @SYMTestExpectedResults
2772 //! 1. The second create should fail with KErrAlreadyExists.
2773 //---------------------------------------------------------------------------------------------------------------------
2774 test.Next(_L("RFile::Create existing file behaviour"));
2775 r=file.Create(TheFs,filename,EFileRead|EFileWrite);
2778 r=file.Create(TheFs,filename,EFileRead|EFileWrite|EDeleteOnClose);
2779 test(r==KErrAlreadyExists);
2782 //---------------------------------------------------------------------------------------------------------------------
2783 //! @SYMTestCaseID PBASE-t_file-0811
2785 //! @SYMTestCaseDesc Verifying existing file cannot be opened with delete on close set.
2787 //! @SYMTestPriority High
2789 //! 1. Test attempts to open an existing file with delete on close set.
2791 //! @SYMTestExpectedResults
2792 //! 1. The open should fail with KErrArgument.
2793 //---------------------------------------------------------------------------------------------------------------------
2794 test.Next(_L("RFile::Open EDeleteOnClose flag validation"));
2795 r=file.Open(TheFs,filename,EFileRead|EFileWrite|EDeleteOnClose);
2796 test(r==KErrArgument);
2797 r=TheFs.Delete(filename);
2800 gSleepThread.Close();
2804 //--------------------------------------------------------------
2806 Test that flushing dirty file cache does not affect file attributes and time.
2807 This test shall pass disregarding if there is file cache or not.
2810 void TestFileAttributesAndCacheFlushing()
2812 test.Next(_L("Test that file cache flushing does not affect the file attributes."));
2813 if(Is_Win32(TheFs, gDriveNum))
2815 test.Printf(_L("This test doesn't work on Win32 FS, skipping!\n"));
2819 _LIT(KFile, "\\file1");
2823 TheFs.Delete(KFile);
2825 //-- 1. create test file
2826 nRes = CreateEmptyFile(TheFs, KFile, 33);
2827 test(nRes == KErrNone);
2829 //-- 2. open it for write
2831 nRes = file.Open(TheFs, KFile, EFileWrite);
2832 test(nRes == KErrNone);
2834 //-- 3. write a couple of bytes there. This must cause 'Archive' attribute set
2835 nRes = file.Write(0, _L8("a"));
2836 test(nRes == KErrNone);
2837 nRes = file.Write(10, _L8("b"));
2838 test(nRes == KErrNone);
2840 nRes = TheFs.Entry(KFile, entry);
2841 test(nRes == KErrNone);
2843 test(entry.IsArchive()); //-- 'A' attribute must be set.
2845 //-- the file cache (if present) is dirty now. Dirty data timer starts to tick.
2846 //-- 4. set new file attributes (w/o 'A') and creation time
2847 const TUint newAtt = KEntryAttSystem ;
2848 nRes = file.SetAtt(newAtt, ~newAtt & KEntryAttMaskSupported);
2849 test(nRes == KErrNone);
2852 nRes = newTime.Set(_L("19970310:101809.000000"));
2853 test(nRes == KErrNone);
2854 nRes = file.SetModified(newTime);
2855 test(nRes == KErrNone);
2857 //-- 5. wait 5 seconds. file server shall flush dirty data during this period.
2858 User::After(5*K1Sec);
2860 //-- 6. check that attributes haven't chanded because of flush
2861 nRes = file.Flush(); //-- this will flush attributes to the media
2862 test(nRes == KErrNone);
2864 nRes = TheFs.Entry(KFile, entry);
2865 test(nRes == KErrNone);
2867 test(entry.iAtt == newAtt);
2868 test(entry.iModified.DateTime().Year() == 1997);
2869 test(entry.iModified.DateTime().Month() == 3);
2870 test(entry.iModified.DateTime().Day() == 10);
2872 //-- 7. write some data and ensure that 'A' attribute is set now and 'modified' time updated
2873 nRes = file.Write(12, _L8("c"));
2874 test(nRes == KErrNone);
2876 file.Close(); //-- this will flush attributes to the media
2878 nRes = TheFs.Entry(KFile, entry);
2879 test(nRes == KErrNone);
2880 test(entry.iAtt == (newAtt | KEntryAttArchive));
2881 test(entry.iModified.DateTime().Year() != 1997);
2888 Testing access to the very last bytes in the maximal (for FAT32) file size.
2889 This test must pass regardless of write caching configuration.
2891 void TestMaxFileSize()
2893 test.Next(_L("test maximal file size on FAT32\n"));
2895 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
2897 if(!Is_Fat32(TheFs, gDriveNum))
2899 test.Printf(_L("This test requires FAT32! skipping.\n"));
2905 //-- check disk space, it shall be > 4G
2906 TVolumeInfo volInfo;
2907 nRes = TheFs.Volume(volInfo, gDriveNum);
2908 test(nRes == KErrNone);
2910 const TUint32 KMaxFAT32FileSize = 0xFFFFFFFF; // 4GB-1
2912 if(volInfo.iFree <= KMaxFAT32FileSize)
2914 test.Printf(_L("Not enough space for 4GB file! skipping.\n"));
2918 _LIT(KFileName, "\\huge_file");
2922 //-- 1. create 4GB-1 file
2923 //-- this file has enabled write caching by default
2924 test.Printf(_L("creating maximal length file, size = 0x%x\n"),KMaxFAT32FileSize);
2925 nRes = file64.Replace(TheFs, KFileName, EFileWrite);
2926 test(nRes == KErrNone);
2928 const TInt64 fileSize = KMaxFAT32FileSize;
2930 nRes = file64.SetSize(fileSize);
2931 test(nRes == KErrNone);
2933 test.Printf(_L("seeking to the file end...\n"));
2935 nRes = file64.Seek(ESeekEnd, filePos);
2936 test(nRes == KErrNone);
2939 test.Printf(_L("test writing to the last bytes of the file (rel pos addressing) \n"));
2941 //-- 1. writing using relative position
2943 nRes = file64.Seek(ESeekEnd, filePos);
2944 test(nRes == KErrNone);
2945 test(filePos == fileSize-1);
2947 nRes = file64.Write(_L8("z")); //-- write 1 byte a pos 0xFFFFFFFE, this is the last allowed position of the FAT32 file
2948 test(nRes == KErrNone);
2950 nRes = file64.Write(_L8("x")); //-- write 1 byte a pos 0xFFFFFFFF, beyond the max. allowed file size, this shall fail
2951 test(nRes == KErrNotSupported);
2953 nRes = file64.Flush();
2954 test(nRes == KErrNone);
2956 //-- 1.1 check the result by reading data using rel. pos
2958 nRes = file64.Seek(ESeekEnd, filePos);
2959 test(nRes == KErrNone);
2960 test(filePos == fileSize-1);
2962 test.Printf(_L("reading 1 byte at pos: 0x%x\n"), filePos);
2963 nRes = file64.Read(buf, 1); //-- read 1 byte a pos 0xFFFFFFFE, this is the last allowed position of the FAT32 file
2964 test(nRes == KErrNone);
2965 test(buf.Length() == 1 && buf[0]=='z');
2967 nRes = file64.Read(buf, 1); //-- read 1 byte a pos 0xFFFFFFFF, beyond the max. allowed file size, this shall fail
2968 test(nRes == KErrNone);
2969 test(buf.Length() == 0);
2973 test.Printf(_L("test writing to the last bytes of the file (absolute pos addressing) \n"));
2974 //-- 2. writing using absolute position
2975 nRes = file64.Open(TheFs, KFileName, EFileWrite);
2976 test(nRes == KErrNone);
2978 filePos = fileSize-1;
2980 nRes = file64.Write(filePos-2, _L8("0"), 1); //-- write 1 byte a pos 0xFFFFFFFC
2981 test(nRes == KErrNone);
2983 nRes = file64.Write(filePos, _L8("a"), 1); //-- write 1 byte a pos 0xFFFFFFFE, this is the last allowed position of the FAT32 file
2984 test(nRes == KErrNone);
2986 nRes = file64.Write(filePos+1, _L8("b"), 1); //-- write 1 byte a pos 0xFFFFFFFF, beyond the max. allowed file size, this shall fail
2987 test(nRes == KErrNotSupported);
2989 nRes = file64.Flush();
2990 test(nRes == KErrNone);
2992 //-- 1.1 check the result by reading data absolute rel. position
2994 nRes = file64.Read(filePos-2, buf, 1); //-- read 1 byte a pos 0xFFFFFFFD
2995 test(nRes == KErrNone);
2996 test(buf.Length() == 1 && buf[0]=='0');
2998 nRes = file64.Read(filePos, buf, 1); //-- read 1 byte a pos 0xFFFFFFFE, this is the last allowed position of the FAT32 file
2999 test(nRes == KErrNone);
3000 test(buf.Length() == 1 && buf[0]=='a');
3002 nRes = file64.Read(filePos+1, buf, 1); //-- read 1 byte a pos 0xFFFFFFFF, beyond the max. allowed file size
3003 test(nRes == KErrNone);
3004 test(buf.Length() == 0);
3006 nRes = file64.Read(filePos+2, buf, 1); //buf.Len must be 0
3007 test(nRes == KErrNone);
3008 test(buf.Length() == 0);
3012 test.Printf(_L("deleting the huge file.\n"));
3013 nRes = TheFs.Delete(KFileName);
3014 test(nRes == KErrNone);
3018 test.Printf(_L("RFile64 is not supported! Skipping.\n"));
3020 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
3025 //--------------------------------------------------------------
3030 //-- set up console output
3031 F32_Test_Utils::SetConsole(test.Console());
3033 TInt nRes=TheFs.CharToDrive(gDriveToTest, gDriveNum);
3034 test(nRes==KErrNone);
3036 PrintDrvInfo(TheFs, gDriveNum);
3038 //-- FAT Supports short file names
3039 if(Is_Fat(TheFs, gDriveNum))
3040 gShortFileNamesSupported = ETrue;
3042 if(Is_Win32(TheFs, gDriveNum))
3043 {//-- find out if this is NTFS and if it supports short names (this feature can be switched OFF)
3045 _LIT(KLongFN, "\\this is a long file name");
3046 nRes = CreateEmptyFile(TheFs, KLongFN, 10);
3047 test(nRes==KErrNone);
3050 nRes = TheFs.GetShortName(KLongFN, shortName);
3051 gShortFileNamesSupported = (nRes == KErrNone);
3053 nRes = TheFs.Delete(KLongFN);
3054 test(nRes==KErrNone);
3056 DeleteTestDirectory();
3060 nRes = FormatDrive(TheFs, gDriveNum, ETrue);
3061 test(nRes==KErrNone);
3064 CreateTestDirectory(_L("\\F32-TST\\TFILE\\"));
3068 CopyFileToTestDirectory();
3071 CopyFileToTestDirectory();
3073 testFileTextEndRecord();
3074 testDeleteOpenFiles();
3075 testFileAttributes();
3078 testReadersWriters();
3080 testMultipleReadFile();
3083 testShortNameAccessorFunctions();
3085 testMiscellaneousReportedBugs();
3088 TestMaxLengthFilenames();
3091 testZeroLengthDescriptors();
3092 testNegativeLengthToWrite();
3093 testNegativeLength();
3094 testReadBufferOverflow();
3095 TestDeleteOnClose();
3096 TestFileAttributesAndCacheFlushing();
3099 DeleteTestDirectory();