kerneltest/f32test/server/t_filecache.cpp
branchRCL_3
changeset 44 3e88ff8f41d5
parent 43 c1f20ce4abcf
equal deleted inserted replaced
43:c1f20ce4abcf 44:3e88ff8f41d5
    20 #include <e32svr.h> 
    20 #include <e32svr.h> 
    21 #include <f32dbg.h>
    21 #include <f32dbg.h>
    22 #include "t_server.h"
    22 #include "t_server.h"
    23 #include <e32twin.h>
    23 #include <e32twin.h>
    24 #include <e32rom.h>
    24 #include <e32rom.h>
    25 #include <u32hal.h>
       
    26 
    25 
    27 
    26 
    28 //----------------------------------------------------------------------------------------------
    27 //----------------------------------------------------------------------------------------------
    29 //! @SYMTestCaseID      PBASE-T_FILECACHE-0189
    28 //! @SYMTestCaseID      PBASE-T_FILECACHE-0189
    30 //! @SYMTestType        UT
    29 //! @SYMTestType        UT
   113 	}
   112 	}
   114 
   113 
   115 void PrintFileCacheConfig(TFileCacheConfig& aFileCacheConfig, TBool aDisplay = ETrue)
   114 void PrintFileCacheConfig(TFileCacheConfig& aFileCacheConfig, TBool aDisplay = ETrue)
   116 	{
   115 	{
   117 	TInt r = controlIo(TheFs,gDrive, KControlIoFileCacheConfig, aFileCacheConfig);
   116 	TInt r = controlIo(TheFs,gDrive, KControlIoFileCacheConfig, aFileCacheConfig);
   118 	test_KErrNone(r);
   117 	test (r == KErrNone);
   119 	if (!aDisplay)
   118 	if (!aDisplay)
   120 		return;
   119 		return;
   121 	
   120 	
   122 	test.Printf(_L("File cache:\nDrive %c\nFlags %08X\nFileCacheReadAsync %d\nFairSchedulingLen %d\nCacheSize %d\nMaxReadAheadLen %d\nClosedFileKeepAliveTime %d\nDirtyDataFlushTime %d"), 
   121 	test.Printf(_L("File cache:\nDrive %c\nFlags %08X\nFileCacheReadAsync %d\nFairSchedulingLen %d\nCacheSize %d\nMaxReadAheadLen %d\nClosedFileKeepAliveTime %d\nDirtyDataFlushTime %d"), 
   123 		aFileCacheConfig.iDrive + 'A',
   122 		aFileCacheConfig.iDrive + 'A',
   249 				TestBufferFail(aBuffer, pos, aLength);
   248 				TestBufferFail(aBuffer, pos, aLength);
   250 			}
   249 			}
   251 		}
   250 		}
   252 	}
   251 	}
   253 
   252 
   254 TInt FreeRam()
       
   255 	{
       
   256 	// wait for any async cleanup in the supervisor to finish first...
       
   257 	UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
       
   258 
       
   259 	TMemoryInfoV1Buf meminfo;
       
   260 	UserHal::MemoryInfo(meminfo);
       
   261 	return meminfo().iFreeRamInBytes;
       
   262 	}
       
   263 
       
   264 void LowMemoryTest()
       
   265 	{
       
   266 	TInt fileSize = 0;
       
   267 	
       
   268 	const TInt KWriteLen = 128*1024;
       
   269 	test.Next(_L("Test appending to a file with low memory"));
       
   270 	gBufPtr.SetLength(KBufSize);
       
   271 
       
   272 	RFile f;
       
   273 	TFileName testFile   = _L("TEST.BIN");
       
   274 
       
   275 	TInt r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteBuffered);
       
   276 	test_KErrNone(r);
       
   277 
       
   278 	TInt pos = 0;
       
   279 
       
   280 	TPtrC8 writePtr;
       
   281 	writePtr.Set(gBufPtr.MidTPtr(pos, KWriteLen));
       
   282 
       
   283 	r = f.Write(pos, writePtr);
       
   284 	test_KErrNone(r);
       
   285 	pos+= writePtr.Length();
       
   286 
       
   287 	r = f.Size(fileSize);
       
   288 	test_KErrNone(r);
       
   289 	test_Equal(fileSize,pos);
       
   290 
       
   291 
       
   292 
       
   293 	TUint freeRam = FreeRam();
       
   294 	const TInt KPageSize=4096;
       
   295 	freeRam = (freeRam + KPageSize -1) & ~(KPageSize-1);
       
   296 	test.Printf(_L("FreeRam = %d"), freeRam);
       
   297 
       
   298 	RChunk chunk;
       
   299 	TChunkCreateInfo chunkInfo;
       
   300 	chunkInfo.SetDisconnected(0, 0, freeRam);
       
   301 	chunkInfo.SetPaging(TChunkCreateInfo::EUnpaged);
       
   302 	test_KErrNone(chunk.Create(chunkInfo));
       
   303 
       
   304 	test.Printf(_L("Gobbling all of memory..."));
       
   305 	
       
   306 	TUint commitEnd;
       
   307 	for (commitEnd = 0; commitEnd < freeRam; commitEnd += KPageSize) 
       
   308 		{
       
   309 		r = chunk.Commit(commitEnd,KPageSize);
       
   310 		if (r != KErrNone)
       
   311 			break;
       
   312 		
       
   313 		}
       
   314 	test.Printf(_L("commitEnd %d, r %d"), commitEnd, r);
       
   315 	test_Value(r, r == KErrNoMemory || r == KErrNone);
       
   316 
       
   317 	test.Printf(_L("FreeRam = %d"), FreeRam());
       
   318 
       
   319 	pos-= KSegmentSize;
       
   320 	writePtr.Set(gBufPtr.MidTPtr(pos, KWriteLen));
       
   321 
       
   322 	test.Printf(_L("Writing to file..."));
       
   323 
       
   324 	// now we have gobbled all or most of memory, the next write can fail
       
   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 
       
   339 	pos+= writePtr.Length();
       
   340 
       
   341 	test.Printf(_L("Gsetting size of file ..."));
       
   342 	r = f.Size(fileSize);
       
   343 	test_KErrNone(r);
       
   344 	test_Equal(fileSize,pos);
       
   345 
       
   346 	test.Printf(_L("Closing file ..."));
       
   347 	f.Close();
       
   348 
       
   349 	test.Printf(_L("Closing chunk ..."));
       
   350 	chunk.Close();
       
   351 
       
   352 	test.Printf(_L("FreeRam = %d"), FreeRam());
       
   353 	}
       
   354 
       
   355 
       
   356 
   253 
   357 LOCAL_C void UnitTests()
   254 LOCAL_C void UnitTests()
   358 //
   255 //
   359 // Test read file handling.
   256 // Test read file handling.
   360 //
   257 //
   372 
   269 
   373 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   270 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   374 	TBool simulatelockFailureMode;
   271 	TBool simulatelockFailureMode;
   375 	TFileCacheStats fileCacheStats;
   272 	TFileCacheStats fileCacheStats;
   376 	r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   273 	r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   377 	test_KErrNone(r);
   274 	test (r == KErrNone);
   378 	test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   275 	test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   379 	test(fileCacheStats.iFilesOnClosedQueue == 0);
   276 	test(fileCacheStats.iFilesOnClosedQueue == 0);
   380 #endif
   277 #endif
   381 
   278 
   382 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   279 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   383 	// turn OFF lock failure mode 
   280 	// turn OFF lock failure mode 
   384 	simulatelockFailureMode = EFalse;
   281 	simulatelockFailureMode = EFalse;
   385 	r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
   282 	r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
   386 	test_KErrNone(r);
   283 	test (r == KErrNone);
   387 #endif
   284 #endif
   388 
   285 
   389 	TFileName testFile   = _L("TEST.BIN");
   286 	TFileName testFile   = _L("TEST.BIN");
   390 
   287 
   391 	//**********************************
   288 	//**********************************
   400 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   297 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   401 	TInt uncachedBytesRead;
   298 	TInt uncachedBytesRead;
   402 	TInt uncachedPacketsRead;
   299 	TInt uncachedPacketsRead;
   403 #endif
   300 #endif
   404 
   301 
   405 	LowMemoryTest();
       
   406 
       
   407 	// create an empty file, so that any writes overlapping segemt boundaries
   302 	// create an empty file, so that any writes overlapping segemt boundaries
   408 	// need a read first
   303 	// need a read first
   409 	// create a test file using directIO and then re-open it in buffered mode, 
   304 	// create a test file using directIO and then re-open it in buffered mode, 
   410 	// so that any writes overlapping segemt boundaries need a read first
   305 	// so that any writes overlapping segemt boundaries need a read first
   411 	r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteDirectIO);
   306 	r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteDirectIO);
   558 	test.Printf(_L("Flushing close queue to empty cache...\n"));
   453 	test.Printf(_L("Flushing close queue to empty cache...\n"));
   559 	r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles);
   454 	r = TheFs.ControlIo(gDrive, KControlIoFlushClosedFiles);
   560 	test_KErrNone(r);
   455 	test_KErrNone(r);
   561 
   456 
   562 	r = f.Replace(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered);
   457 	r = f.Replace(TheFs, testFile, EFileReadBuffered | EFileWrite | EFileWriteBuffered);
   563 	test_KErrNone(r);
       
   564 
       
   565 	r = f.SetSize(gFileCacheConfig.iCacheSize);
       
   566 	test_KErrNone(r);
   458 	test_KErrNone(r);
   567 
   459 
   568 	RTimer timer;
   460 	RTimer timer;
   569 	timer.CreateLocal();
   461 	timer.CreateLocal();
   570 	TRequestStatus reqStat;
   462 	TRequestStatus reqStat;
   724 	r = f.Open(TheFs, testFile, EFileRead | EFileReadBuffered | EFileWrite);
   616 	r = f.Open(TheFs, testFile, EFileRead | EFileReadBuffered | EFileWrite);
   725 	test_KErrNone(r);
   617 	test_KErrNone(r);
   726 
   618 
   727 	TInt size;
   619 	TInt size;
   728 	r = f.Size(size);
   620 	r = f.Size(size);
   729 	test_KErrNone(r);
   621 	test (r == KErrNone);
   730 	test (size = KBufSize);
   622 	test (size = KBufSize);
   731 
   623 
   732 	readPtr.Set(gBuf->Des());
   624 	readPtr.Set(gBuf->Des());
   733 
   625 
   734 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   626 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   735 	// Allocate full cachelines - so we can enable hole testing
   627 	// Allocate full cachelines - so we can enable hole testing
   736 	TBool allocateAllSegmentsInCacheLine = ETrue;
   628 	TBool allocateAllSegmentsInCacheLine = ETrue;
   737 	r = controlIo(TheFs, gDrive, KControlIoAllocateMaxSegments, allocateAllSegmentsInCacheLine);
   629 	r = controlIo(TheFs, gDrive, KControlIoAllocateMaxSegments, allocateAllSegmentsInCacheLine);
   738 	test_KErrNone(r);
   630 	test (r == KErrNone);
   739 	PrintFileCacheStats(fileCacheStats, EFalse);
   631 	PrintFileCacheStats(fileCacheStats, EFalse);
   740 	TInt holesDetected = fileCacheStats.iHoleCount;
   632 	TInt holesDetected = fileCacheStats.iHoleCount;
   741 	TInt lockFailures = fileCacheStats.iCommitFailureCount + fileCacheStats.iLockFailureCount;
   633 	TInt lockFailures = fileCacheStats.iCommitFailureCount + fileCacheStats.iLockFailureCount;
   742 #endif
   634 #endif
   743 
   635 
   818 		test(fileCacheStats.iHoleCount > holesDetected);
   710 		test(fileCacheStats.iHoleCount > holesDetected);
   819 		}
   711 		}
   820 	// Don't allocate full cachelines any more
   712 	// Don't allocate full cachelines any more
   821 	allocateAllSegmentsInCacheLine = EFalse;
   713 	allocateAllSegmentsInCacheLine = EFalse;
   822 	r = controlIo(TheFs, gDrive, KControlIoAllocateMaxSegments, allocateAllSegmentsInCacheLine);
   714 	r = controlIo(TheFs, gDrive, KControlIoAllocateMaxSegments, allocateAllSegmentsInCacheLine);
   823 	test_KErrNone(r);
   715 	test (r == KErrNone);
   824 #endif
   716 #endif
   825 
   717 
   826 
   718 
   827 
   719 
   828 	gBufPtr.FillZ();
   720 	gBufPtr.FillZ();
   918 	f.Close();
   810 	f.Close();
   919 
   811 
   920 
   812 
   921 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   813 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   922 	r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   814 	r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   923 	test_KErrNone(r);
   815 	test (r == KErrNone);
   924 	test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   816 	test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   925 	test(fileCacheStats.iFilesOnClosedQueue == 1);
   817 	test(fileCacheStats.iFilesOnClosedQueue == 1);
   926 #endif
   818 #endif
   927 	//
   819 	//
   928 
   820 
   952 		TestBuffer(gBufPtr, pos, len);
   844 		TestBuffer(gBufPtr, pos, len);
   953 		test_KErrNone(r);
   845 		test_KErrNone(r);
   954 
   846 
   955 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   847 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   956 		r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   848 		r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   957 		test_KErrNone(r);
   849 		test (r == KErrNone);
   958 		test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   850 		test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   959 		test(fileCacheStats.iFilesOnClosedQueue == 0);
   851 		test(fileCacheStats.iFilesOnClosedQueue == 0);
   960 #endif
   852 #endif
   961 		f.Close();
   853 		f.Close();
   962 
   854 
   963 		test.Next(_L("close & verify file is back on close queue"));
   855 		test.Next(_L("close & verify file is back on close queue"));
   964 
   856 
   965 
   857 
   966 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   858 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   967 		r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   859 		r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   968 		test_KErrNone(r);
   860 		test (r == KErrNone);
   969 		test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   861 		test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   970 		test(fileCacheStats.iFilesOnClosedQueue == 1);
   862 		test(fileCacheStats.iFilesOnClosedQueue == 1);
   971 #endif
   863 #endif
   972 
   864 
   973 		if (testNum == ETestCloseQueueEmptyAfterDelete)
   865 		if (testNum == ETestCloseQueueEmptyAfterDelete)
   992 			f.Close();
   884 			f.Close();
   993 			}
   885 			}
   994 
   886 
   995 	#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   887 	#if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   996 		r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   888 		r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   997 		test_KErrNone(r);
   889 		test (r == KErrNone);
   998 		test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   890 		test.Printf(_L("Number of files on closed queue=%d\n"),fileCacheStats.iFilesOnClosedQueue);
   999 		test(fileCacheStats.iFilesOnClosedQueue == 0);
   891 		test(fileCacheStats.iFilesOnClosedQueue == 0);
  1000 	#endif
   892 	#endif
  1001 		}
   893 		}
  1002 
   894 
  1003 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   895 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1004 	// turn lock failure mode back ON (if enabled)
   896 	// turn lock failure mode back ON (if enabled)
  1005 	simulatelockFailureMode = ETrue;
   897 	simulatelockFailureMode = ETrue;
  1006 	r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
   898 	r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1007 	test_KErrNone(r);
   899 	test (r == KErrNone);
  1008 #endif
   900 #endif
  1009 
   901 
  1010 	//**************************************************************
   902 	//**************************************************************
  1011 	// Test opening a file with a silly open mode flags combinations 
   903 	// Test opening a file with a silly open mode flags combinations 
  1012 	//**************************************************************
   904 	//**************************************************************
  1028 	const TInt KWriteLen = KSegmentSize+1;
   920 	const TInt KWriteLen = KSegmentSize+1;
  1029 	writePtr.Set(gBuf->Des().Ptr(), KWriteLen);
   921 	writePtr.Set(gBuf->Des().Ptr(), KWriteLen);
  1030 
   922 
  1031 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   923 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1032 	r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   924 	r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
  1033 	test_KErrNone(r);
   925 	test (r == KErrNone);
  1034 	test.Printf(_L("Number of Write-throughs with dirty data=%d\n"),fileCacheStats.iWriteThroughWithDirtyDataCount);
   926 	test.Printf(_L("Number of Write-throughs with dirty data=%d\n"),fileCacheStats.iWriteThroughWithDirtyDataCount);
  1035 	TInt writeThroughWithDirtyDataCountOld = fileCacheStats.iWriteThroughWithDirtyDataCount;
   927 	TInt writeThroughWithDirtyDataCountOld = fileCacheStats.iWriteThroughWithDirtyDataCount;
  1036 	TInt writeThroughWithDirtyDataCountNew = writeThroughWithDirtyDataCountOld;
   928 	TInt writeThroughWithDirtyDataCountNew = writeThroughWithDirtyDataCountOld;
  1037 #endif
   929 #endif
  1038 
   930 
  1039 	TInt fileSize = 0;
   931 	TInt fileSize = 0;
  1040 	for (TInt i=0; i<4; i++)
   932 	for (TInt i=0; i<4; i++)
  1041 		{
   933 		{
  1042 		fileSize = 0;
   934 		fileSize = 0;
  1043 		r = f.SetSize(fileSize);
   935 		r = f.SetSize(fileSize);
  1044 		test_KErrNone(r);
   936 		test (r == KErrNone);
  1045 		for (pos = 0; pos < KMaxFileSize; )
   937 		for (pos = 0; pos < KMaxFileSize; )
  1046 			{
   938 			{
  1047 			r = f.Write(pos, writePtr);
   939 			r = f.Write(pos, writePtr);
  1048 			if (r != KErrNone)
   940 			if (r != KErrNone)
  1049 				{
   941 				{
  1050 				test.Printf(_L("Iter #%d, write pos %d size %d, Write() returned %d"), i, pos, fileSize, r);
   942 				test.Printf(_L("Iter #%d, write pos %d size %d, Write() returned %d"), i, pos, fileSize, r);
  1051 				r = f.Flush();
   943 				r = f.Flush();
  1052 				test.Printf(_L("Flush returned %d"), r);
   944 				test.Printf(_L("Flush returned %d"), r);
  1053 				test(0);
   945 				test(0);
  1054 				}
   946 				}
  1055 			test_KErrNone(r);
   947 			test(r == KErrNone);
  1056 			pos+= writePtr.Length();
   948 			pos+= writePtr.Length();
  1057 
   949 
  1058 			r = f.Size(fileSize);
   950 			r = f.Size(fileSize);
  1059 			test_KErrNone(r);
   951 			test (r == KErrNone);
  1060 			if (fileSize != pos)
   952 			if (fileSize != pos)
  1061 				{
   953 				{
  1062 				test.Printf(_L("Iter #%d, write pos %d != size %d"), i, pos, fileSize);
   954 				test.Printf(_L("Iter #%d, write pos %d != size %d"), i, pos, fileSize);
  1063 				r = f.Flush();
   955 				r = f.Flush();
  1064 				test.Printf(_L("Flush returned %d"), r);
   956 				test.Printf(_L("Flush returned %d"), r);
  1066 				}
   958 				}
  1067 			test (fileSize == pos);
   959 			test (fileSize == pos);
  1068 
   960 
  1069 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
   961 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1070 			r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
   962 			r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
  1071 			test_KErrNone(r);
   963 			test (r == KErrNone);
  1072 			writeThroughWithDirtyDataCountNew = fileCacheStats.iWriteThroughWithDirtyDataCount;
   964 			writeThroughWithDirtyDataCountNew = fileCacheStats.iWriteThroughWithDirtyDataCount;
  1073 			if (writeThroughWithDirtyDataCountNew > writeThroughWithDirtyDataCountOld)
   965 			if (writeThroughWithDirtyDataCountNew > writeThroughWithDirtyDataCountOld)
  1074 				{
   966 				{
  1075 				test.Printf(_L("Iter #%d, write pos %d size %d"), i, pos, fileSize);
   967 				test.Printf(_L("Iter #%d, write pos %d size %d"), i, pos, fileSize);
  1076 				test.Printf(_L("Number of Write-throughs with dirty data=%d\n"),fileCacheStats.iWriteThroughWithDirtyDataCount);
   968 				test.Printf(_L("Number of Write-throughs with dirty data=%d\n"),fileCacheStats.iWriteThroughWithDirtyDataCount);
  1104 	
   996 	
  1105 	TDesC& fileName = *(TDesC*) aFileName;
   997 	TDesC& fileName = *(TDesC*) aFileName;
  1106 
   998 
  1107 	RFs fs;
   999 	RFs fs;
  1108 	TInt r = fs.Connect();
  1000 	TInt r = fs.Connect();
  1109 	test_KErrNone(r);
  1001 	test (r==KErrNone);
  1110 	r = fs.SetSessionPath(gSessionPath);
  1002 	r = fs.SetSessionPath(gSessionPath);
  1111 	test_KErrNone(r);
  1003 	test (r==KErrNone);
  1112 
  1004 
  1113 
  1005 
  1114 	RFile file;
  1006 	RFile file;
  1115 	r = file.Open(fs, fileName, EFileRead | EFileReadBuffered | EFileShareReadersOrWriters);
  1007 	r = file.Open(fs, fileName, EFileRead | EFileReadBuffered | EFileShareReadersOrWriters);
  1116 	test_KErrNone(r);
  1008 	test_KErrNone(r);
  1342 	TInt maxWriteCount=KMaxFileSize/aWriteBlockSize;
  1234 	TInt maxWriteCount=KMaxFileSize/aWriteBlockSize;
  1343 	TInt loopCount=0;
  1235 	TInt loopCount=0;
  1344 
  1236 
  1345 	RFile file;
  1237 	RFile file;
  1346 	TInt r = file.Replace(TheFs,_L("WRITETST"),EFileStream | aFileMode);
  1238 	TInt r = file.Replace(TheFs,_L("WRITETST"),EFileStream | aFileMode);
  1347 	test_KErrNone(r);
  1239 	test (r == KErrNone);
  1348 
  1240 
  1349 	TTime startTime;
  1241 	TTime startTime;
  1350 	TTime endTime;
  1242 	TTime endTime;
  1351 
  1243 
  1352 	RTimer timer;
  1244 	RTimer timer;
  1706 	{
  1598 	{
  1707 	TestsInit();
  1599 	TestsInit();
  1708 
  1600 
  1709 	TVolumeInfo volInfo;
  1601 	TVolumeInfo volInfo;
  1710 	TInt r = TheFs.Volume(volInfo, gDrive);
  1602 	TInt r = TheFs.Volume(volInfo, gDrive);
  1711 	test_KErrNone(r);
  1603 	test (r == KErrNone);
  1712 
  1604 
  1713 	TFullName extName;
  1605 	TFullName extName;
  1714 	r = TheFs.ExtensionName(extName,gDrive, 0);
  1606 	r = TheFs.ExtensionName(extName,gDrive, 0);
  1715 	if (r == KErrNone)
  1607 	if (r == KErrNone)
  1716 		{
  1608 		{
  1741 		{
  1633 		{
  1742 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1634 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1743 		// turn OFF lock failure mode
  1635 		// turn OFF lock failure mode
  1744 		TBool simulatelockFailureMode = EFalse;
  1636 		TBool simulatelockFailureMode = EFalse;
  1745 		r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1637 		r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1746 		test_KErrNone(r);
  1638 		test (r == KErrNone);
  1747 #endif
  1639 #endif
  1748 
  1640 
  1749 		TestFileRead(EFileReadDirectIO);
  1641 		TestFileRead(EFileReadDirectIO);
  1750 		if (gDriveCacheFlags & (EFileCacheReadEnabled | EFileCacheReadOn))
  1642 		if (gDriveCacheFlags & (EFileCacheReadEnabled | EFileCacheReadOn))
  1751 			{
  1643 			{
  1761 
  1653 
  1762 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1654 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1763 		// turn lock failure mode back ON (if enabled)
  1655 		// turn lock failure mode back ON (if enabled)
  1764 		simulatelockFailureMode = ETrue;
  1656 		simulatelockFailureMode = ETrue;
  1765 		r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1657 		r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1766 		test_KErrNone(r);
  1658 		test (r == KErrNone);
  1767 #endif
  1659 #endif
  1768 		}	// if (gRunPerformanceTests)
  1660 		}	// if (gRunPerformanceTests)
  1769 
  1661 
  1770 	TestsEnd();
  1662 	TestsEnd();
  1771 	}
  1663 	}
  1885 
  1777 
  1886 	if (gWriteCacheFlags)
  1778 	if (gWriteCacheFlags)
  1887 		{
  1779 		{
  1888 		test.Printf(_L("Writing DriveCacheFlags for drive %C = %08X\n"), (TInt) gDriveToTest, gDriveCacheFlags);
  1780 		test.Printf(_L("Writing DriveCacheFlags for drive %C = %08X\n"), (TInt) gDriveToTest, gDriveCacheFlags);
  1889 		r = controlIo(TheFs,gDrive, KControlIoFileCacheFlagsWrite, gDriveCacheFlags);
  1781 		r = controlIo(TheFs,gDrive, KControlIoFileCacheFlagsWrite, gDriveCacheFlags);
  1890 		test_KErrNone(r);
  1782 		test (r == KErrNone);
  1891 		}
  1783 		}
  1892 #endif
  1784 #endif
  1893 
  1785 
  1894 	if (gRunTests)
  1786 	if (gRunTests)
  1895 		{
  1787 		{