kerneltest/f32test/server/t_filecache.cpp
changeset 297 b2826f67641f
parent 176 af6ec97d9189
equal deleted inserted replaced
296:94f2adf59133 297:b2826f67641f
   589 			test.Printf(_L("iLockedSegmentCount %d...\n"), fileCacheStats.iLockedSegmentCount);
   589 			test.Printf(_L("iLockedSegmentCount %d...\n"), fileCacheStats.iLockedSegmentCount);
   590 
   590 
   591 		test(fileCacheStats.iLockedSegmentCount >= maxLockedSegmentCount);
   591 		test(fileCacheStats.iLockedSegmentCount >= maxLockedSegmentCount);
   592 		maxLockedSegmentCount = Max(maxLockedSegmentCount, fileCacheStats.iLockedSegmentCount);
   592 		maxLockedSegmentCount = Max(maxLockedSegmentCount, fileCacheStats.iLockedSegmentCount);
   593 		// wrap to start of file
   593 		// wrap to start of file
   594 		if (pos >= gFileCacheConfig.iCacheSize)	
   594 		if (pos >= gFileCacheConfig.iCacheSize || pos >= KBufSize)	
   595 			pos = 0;
   595 			pos = 0;
   596 		}
   596 		}
   597 	timer.Close();
   597 	timer.Close();
   598 
   598 
   599 	test(fileCacheStats.iLockedSegmentCount > 0);
   599 	test(fileCacheStats.iLockedSegmentCount > 0);
  1015 	test_Value(r, r==KErrArgument);
  1015 	test_Value(r, r==KErrArgument);
  1016 	r = f.Open(TheFs, testFile, EFileRead | EFileWriteBuffered | EFileWriteDirectIO);
  1016 	r = f.Open(TheFs, testFile, EFileRead | EFileWriteBuffered | EFileWriteDirectIO);
  1017 	test_Value(r, r==KErrArgument);
  1017 	test_Value(r, r==KErrArgument);
  1018 	//**********************************
  1018 	//**********************************
  1019 	// Test that continuously appending to a file yields the correct size...
  1019 	// Test that continuously appending to a file yields the correct size...
  1020 	// NB: Must have lock failure more ON in debug mode for this test to pass
  1020 	// NB: Must have lock failure mode ON in debug mode for this test to pass
  1021 	//**********************************
  1021 	//**********************************
  1022 	test.Next(_L("Test appending to a file & checking the file size..."));
  1022 	test.Next(_L("Test appending to a file & checking the file size..."));
  1023 	gBufPtr.SetLength(KBufSize);
  1023 	gBufPtr.SetLength(KBufSize);
  1024 
  1024 
  1025 	r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteBuffered);
       
  1026 	test_KErrNone(r);
       
  1027 
       
  1028 	const TInt KWriteLen = KSegmentSize+1;
  1025 	const TInt KWriteLen = KSegmentSize+1;
  1029 	writePtr.Set(gBuf->Des().Ptr(), KWriteLen);
  1026 	writePtr.Set(gBuf->Des().Ptr(), KWriteLen);
  1030 
  1027 
  1031 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1028 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1032 	r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
  1029 	r = controlIo(TheFs, gDrive, KControlIoFileCacheStats, fileCacheStats);
  1037 #endif
  1034 #endif
  1038 
  1035 
  1039 	TInt fileSize = 0;
  1036 	TInt fileSize = 0;
  1040 	for (TInt i=0; i<4; i++)
  1037 	for (TInt i=0; i<4; i++)
  1041 		{
  1038 		{
       
  1039 		r = f.Replace(TheFs, testFile, EFileWrite | EFileWriteBuffered);
       
  1040 		test_KErrNone(r);
       
  1041 
  1042 		fileSize = 0;
  1042 		fileSize = 0;
  1043 		r = f.SetSize(fileSize);
  1043 		r = f.SetSize(fileSize);
  1044 		test_KErrNone(r);
  1044 		test_KErrNone(r);
  1045 		for (pos = 0; pos < KMaxFileSize; )
  1045 		for (pos = 0; pos < KMaxFileSize; )
  1046 			{
  1046 			{
  1078 				break;
  1078 				break;
  1079 				}
  1079 				}
  1080 #endif
  1080 #endif
  1081 
  1081 
  1082 			}
  1082 			}
       
  1083 		// Close & delete the file after filling it - to ensure all pages are decomitted
       
  1084 		// otherwise we may never again get a simulated lock failure
       
  1085 		r = f.Flush();
       
  1086 		test_KErrNone(r);
       
  1087 		f.Close();
       
  1088 		r = TheFs.Delete(testFile);
       
  1089 		test_KErrNone(r);
  1083 		}
  1090 		}
  1084 
  1091 
  1085 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1092 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1086 	test(writeThroughWithDirtyDataCountNew > writeThroughWithDirtyDataCountOld);
  1093 	test(writeThroughWithDirtyDataCountNew > writeThroughWithDirtyDataCountOld);
  1087 #endif
  1094 #endif