kerneltest/f32test/server/t_filecache.cpp
changeset 176 af6ec97d9189
parent 134 95847726fe57
child 297 b2826f67641f
equal deleted inserted replaced
175:5af6c74cd793 176:af6ec97d9189
   319 	pos-= KSegmentSize;
   319 	pos-= KSegmentSize;
   320 	writePtr.Set(gBufPtr.MidTPtr(pos, KWriteLen));
   320 	writePtr.Set(gBufPtr.MidTPtr(pos, KWriteLen));
   321 
   321 
   322 	test.Printf(_L("Writing to file..."));
   322 	test.Printf(_L("Writing to file..."));
   323 
   323 
   324 	r = f.Write(pos, writePtr);
   324 	// now we have gobbled all or most of memory, the next write can fail
   325 	test_KErrNone(r);
   325 	// if it does keep decommitting memory until it succeeds and then test that the file size is correct
       
   326 	commitEnd = 0;
       
   327 	do {
       
   328 
       
   329 		r = f.Write(pos, writePtr);
       
   330 		test_Value(r, r == KErrNoMemory || r == KErrNone);
       
   331 		if (r == KErrNoMemory)
       
   332 			{
       
   333 			chunk.Decommit(commitEnd,KPageSize);
       
   334 			commitEnd += KPageSize;
       
   335 			}
       
   336 		}
       
   337 	while (r == KErrNoMemory);
       
   338 
   326 	pos+= writePtr.Length();
   339 	pos+= writePtr.Length();
   327 
   340 
   328 	test.Printf(_L("Setting size of file ..."));
   341 	test.Printf(_L("Gsetting size of file ..."));
   329 	r = f.Size(fileSize);
   342 	r = f.Size(fileSize);
   330 	test_KErrNone(r);
   343 	test_KErrNone(r);
   331 	test_Equal(fileSize,pos);
   344 	test_Equal(fileSize,pos);
   332 
   345 
   333 	test.Printf(_L("Closing file ..."));
   346 	test.Printf(_L("Closing file ..."));
   545 	test.Printf(_L("Flushing close queue to empty cache...\n"));
   558 	test.Printf(_L("Flushing close queue to empty cache...\n"));
   546 	r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles);
   559 	r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles);
   547 	test_KErrNone(r);
   560 	test_KErrNone(r);
   548 
   561 
   549 	r = f.Replace(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered);
   562 	r = f.Replace(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered);
       
   563 	test_KErrNone(r);
       
   564 
       
   565 	r = f.SetSize(gFileCacheConfig.iCacheSize);
   550 	test_KErrNone(r);
   566 	test_KErrNone(r);
   551 
   567 
   552 	RTimer timer;
   568 	RTimer timer;
   553 	timer.CreateLocal();
   569 	timer.CreateLocal();
   554 	TRequestStatus reqStat;
   570 	TRequestStatus reqStat;
  1886 			Format(gDrive);
  1902 			Format(gDrive);
  1887 
  1903 
  1888 //TheFs.SetDebugRegister(KCACHE);
  1904 //TheFs.SetDebugRegister(KCACHE);
  1889 			DoTests(gDrive);
  1905 			DoTests(gDrive);
  1890 //TheFs.SetDebugRegister(0);
  1906 //TheFs.SetDebugRegister(0);
       
  1907 
       
  1908 		if ((gVolInfo.iDrive.iMediaAtt & KMediaAttFormattable))
       
  1909 			Format(gDrive);
       
  1910 
  1891 			test.End();
  1911 			test.End();
  1892 //			}
  1912 //			}
  1893 		}
  1913 		}
  1894 
  1914 
  1895 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1915 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)