kerneltest/f32test/server/t_file.cpp
changeset 259 57b9594f5772
parent 200 73ea206103e6
equal deleted inserted replaced
247:d8d70de2bd36 259:57b9594f5772
   188 //
   188 //
   189 	{
   189 	{
   190 
   190 
   191 	test.Start(_L("Test read file"));
   191 	test.Start(_L("Test read file"));
   192 	RFile f,ZFile;
   192 	RFile f,ZFile;
   193 	TInt r=f.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText);
   193 	
   194 	test_KErrNone(r);
   194     TInt r=f.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText);
   195 	TFileName fn = _L("Z:\\TEST\\T_FILE.CPP");
   195 	test_KErrNone(r);
       
   196 	
       
   197     TFileName fn = _L("Z:\\TEST\\T_FILE.CPP");
   196 	fn[0] = gExeFileName[0];
   198 	fn[0] = gExeFileName[0];
   197 	r=ZFile.Open(TheFs,fn,EFileStreamText);
   199 	
   198 	test_KErrNone(r);
   200     r=ZFile.Open(TheFs,fn,EFileStreamText);
       
   201 	test_KErrNone(r);
       
   202 
       
   203 	// check the file on the Z: drive his read-only
       
   204 	TEntry fileAtt;
       
   205 	r=TheFs.Entry(fn,fileAtt);
       
   206 	test_KErrNone(r);
       
   207 	test((fileAtt.iAtt & KEntryAttReadOnly) == KEntryAttReadOnly);
       
   208 
   199 
   209 
   200 	test.Next(_L("Read file"));
   210 	test.Next(_L("Read file"));
   201 	TBuf8<0x100> a,b;
   211 	TBuf8<0x100> a,b;
   202 	FOREVER
   212 	
       
   213     for(;;)
   203 		{
   214 		{
   204 		r=f.Read(b);
   215 		r=f.Read(b);
   205 		test_KErrNone(r);
   216 		test_KErrNone(r);
   206 		r=ZFile.Read(a);
   217 		
       
   218         r=ZFile.Read(a);
   207 		test_KErrNone(r);
   219 		test_KErrNone(r);
   208 		test(a==b);
   220 		
   209 		if (b.Length()<b.MaxLength())
   221         test(CompareBuffers(a, b));
       
   222 		
       
   223         if (b.Length()<b.MaxLength())
   210 			break;
   224 			break;
   211 		}
   225 		}
       
   226 
   212 	b.SetLength(10);
   227 	b.SetLength(10);
   213 	r=f.Read(b);
   228 	r=f.Read(b);
   214 	test_KErrNone(r);
   229 	test_KErrNone(r);
   215 	test(b.Length()==0);
   230 	test(b.Length()==0);
   216 	f.Close();
   231 	f.Close();
   238 // Test multiple read file handling.
   253 // Test multiple read file handling.
   239 //
   254 //
   240 	{
   255 	{
   241 
   256 
   242 	test.Start(_L("Test multiple read file"));
   257 	test.Start(_L("Test multiple read file"));
   243 	RFile f1;
   258 	
       
   259     RFile f1;
   244 	TInt r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
   260 	TInt r=f1.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
   245 	test_KErrNone(r);
   261 	test_KErrNone(r);
   246 	RFile f2;
   262 	
       
   263     RFile f2;
   247 	r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
   264 	r=f2.Open(TheFs,_L("T_FILE.CPP"),EFileStreamText|EFileShareReadersOnly);
   248 	test_KErrNone(r);
   265 	test_KErrNone(r);
   249 
   266 
   250 	test.Next(_L("Read file"));
   267 	test.Next(_L("Read file"));
   251 	FOREVER
   268 	
       
   269     TBuf8<0x100> b1;
       
   270     TBuf8<0x100> b2;
       
   271     
       
   272     for(;;)
   252 		{
   273 		{
   253 		TBuf8<0x100> b1;
   274         r=f1.Read(b1);
   254 		r=f1.Read(b1);
       
   255 		test_KErrNone(r);
   275 		test_KErrNone(r);
   256 		TBuf8<0x100> b2;
   276         
   257 		r=f2.Read(b2);
   277 		r=f2.Read(b2);
   258 		test_KErrNone(r);
   278 		test_KErrNone(r);
   259 		test(b1==b2);
   279 		
       
   280         test(CompareBuffers(b1, b2));
       
   281 
   260 		if (b1.Length()<b1.MaxLength())
   282 		if (b1.Length()<b1.MaxLength())
   261 			break;
   283 			break;
   262 		}
   284 		}
   263 
   285 
   264 	test.Next(_L("Close file"));
   286 	test.Next(_L("Close file"));
   950 	r=f.SetAtt(KEntryAttReadOnly,0);
   972 	r=f.SetAtt(KEntryAttReadOnly,0);
   951 	test_KErrNone(r);
   973 	test_KErrNone(r);
   952 	r=f.Write(_L8("Hello World"));
   974 	r=f.Write(_L8("Hello World"));
   953 	test_KErrNone(r);
   975 	test_KErrNone(r);
   954 	f.Close();
   976 	f.Close();
       
   977 
       
   978 
       
   979 	test.Next(_L("Internal attribute can't be read"));
       
   980 
       
   981 	r=TheFs.SetAtt(fname,0,KEntryAttReadOnly);
       
   982 	test_KErrNone(r);
       
   983 
       
   984 	r=f.Open(TheFs,fname,EFileWrite);
       
   985 	test_KErrNone(r);
       
   986 
       
   987 	r=f.SetAtt(KEntryAttReadOnly, 0);	// this will set internal attribut KEntryAttModified
       
   988 	test_KErrNone(r);
       
   989 
       
   990 	// copied \sf\os\kernelhwsrv\userlibandfileserver\fileserver\inc\common.h
       
   991 	const TUint KEntryAttModified=0x20000000;	
       
   992 
       
   993 	TUint att;
       
   994 	r = f.Att(att);
       
   995 	test_KErrNone(r);
       
   996     test.Printf(_L("att %x"), att);
       
   997 	test_Value(att & KEntryAttModified, (att & KEntryAttModified) == 0);
       
   998 
       
   999 	r=f.SetAtt(att | KEntryAttModified, 0);
       
  1000 	test_KErrNone(r);
       
  1001 
       
  1002 	r = f.Att(att);
       
  1003 	test_KErrNone(r);
       
  1004     test.Printf(_L("att %x"), att);
       
  1005 	test_Value(att & KEntryAttModified, (att & KEntryAttModified) == 0);
       
  1006 
       
  1007 	test.Next(_L("file time is set"));
       
  1008 	r = f.Modified(time);
       
  1009 	test(time.Int64() != 0);
       
  1010 
       
  1011     r = f.Flush(); //-- this will flush attributes to the media
       
  1012     test_KErrNone(r);
       
  1013 	f.Close();
       
  1014 
   955 
  1015 
   956 	// Tidy up
  1016 	// Tidy up
   957 	r=TheFs.SetAtt(fname,0,KEntryAttReadOnly);
  1017 	r=TheFs.SetAtt(fname,0,KEntryAttReadOnly);
   958 	test_KErrNone(r);
  1018 	test_KErrNone(r);
   959 	r=TheFs.Delete(fname);
  1019 	r=TheFs.Delete(fname);
  2886 */
  2946 */
  2887 void TestMaxFileSize()
  2947 void TestMaxFileSize()
  2888 {
  2948 {
  2889     test.Next(_L("test maximal file size on FAT32\n"));
  2949     test.Next(_L("test maximal file size on FAT32\n"));
  2890 
  2950 
  2891 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  2892 
       
  2893     if(!Is_Fat32(TheFs, gDriveNum))
  2951     if(!Is_Fat32(TheFs, gDriveNum))
  2894     {
  2952     {
  2895         test.Printf(_L("This test requires FAT32! skipping.\n"));
  2953         test.Printf(_L("This test requires FAT32! skipping.\n"));
  2896         return;
  2954         return;
  2897     }
  2955     }
  3007 
  3065 
  3008     test.Printf(_L("deleting the huge file.\n"));
  3066     test.Printf(_L("deleting the huge file.\n"));
  3009     nRes = TheFs.Delete(KFileName);
  3067     nRes = TheFs.Delete(KFileName);
  3010     test_KErrNone(nRes);
  3068     test_KErrNone(nRes);
  3011 
  3069 
  3012 #else
       
  3013 
       
  3014     test.Printf(_L("RFile64 is not supported! Skipping.\n"));
  3070     test.Printf(_L("RFile64 is not supported! Skipping.\n"));
  3015 
  3071 
  3016 #endif //SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API
       
  3017 
  3072 
  3018 }
  3073 }
  3019 
  3074 
  3020 
  3075 
  3021 //--------------------------------------------------------------
  3076 //--------------------------------------------------------------