kerneltest/f32test/server/t_fsched.cpp
branchRCL_3
changeset 256 c1f20ce4abcf
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
249:a179b74831c9 256:c1f20ce4abcf
    27 #include <e32svr.h>
    27 #include <e32svr.h>
    28 #include <f32dbg.h>
    28 #include <f32dbg.h>
    29 #include "t_server.h"
    29 #include "t_server.h"
    30 #include <e32twin.h>
    30 #include <e32twin.h>
    31 #include <e32cmn.h>
    31 #include <e32cmn.h>
       
    32 #include <hal.h>
       
    33 #include "tf32testtimer.h"
       
    34 #include "f32_test_utils.h"
       
    35 using namespace F32_Test_Utils;
       
    36 
    32 
    37 
    33 //----------------------------------------------------------------------------------------------
    38 //----------------------------------------------------------------------------------------------
    34 //! @SYMTestCaseID      PBASE-T_FSCHED-0191
    39 //! @SYMTestCaseID      PBASE-T_FSCHED-0191
    35 //! @SYMTestType        CIT
    40 //! @SYMTestType        CIT
    36 //! @SYMPREQ            PREQ914
    41 //! @SYMPREQ            PREQ914
   112 HBufC8* gBuf = NULL;
   117 HBufC8* gBuf = NULL;
   113 TPtr8 gBufReadPtr(NULL, 0);	
   118 TPtr8 gBufReadPtr(NULL, 0);	
   114 HBufC8* gBufSec = NULL;
   119 HBufC8* gBufSec = NULL;
   115 TPtr8 gBufWritePtr(NULL, 0);	
   120 TPtr8 gBufWritePtr(NULL, 0);	
   116 
   121 
   117 const TInt KuStomS = 1000;
       
   118 const TInt KOneK = 1024;
   122 const TInt KOneK = 1024;
   119 const TInt KOneMeg = KOneK * 1024;
   123 const TInt KOneMeg = KOneK * 1024;
   120 const TInt KBigBlockSize = KOneMeg ; 
   124 const TInt KBigBlockSize = KOneMeg ; 
   121 const TInt KBlockSize = KOneK * 129 ; 
   125 const TInt KBlockSize = KOneK * 129 ; 
   122 const TInt KWaitRequestsTableSize = 70;
   126 const TInt KWaitRequestsTableSize = 70;
   129 
   133 
   130 TTimeIntervalMicroSeconds32 gTimeTakenBigFile(0);
   134 TTimeIntervalMicroSeconds32 gTimeTakenBigFile(0);
   131 TTimeIntervalMicroSeconds32 gTimeTakenBigBlock(0);
   135 TTimeIntervalMicroSeconds32 gTimeTakenBigBlock(0);
   132 TBuf16<45> gSmallFile, gBigFile;
   136 TBuf16<45> gSmallFile, gBigFile;
   133 TInt gNextFile=0;
   137 TInt gNextFile=0;
   134 TTime gTime1;
   138 
   135 TTime gTime2;
   139 TF32TestTimer gTestTimer;
   136 
   140 
   137 RSemaphore gSync;
   141 RSemaphore gSync;
   138 
   142 
   139 // Concurrent Threads
   143 // Concurrent Threads
   140 RThread gBig;
   144 RThread gBig;
   148 	{
   152 	{
   149 	EThreadWait,
   153 	EThreadWait,
   150 	EThreadSignal,
   154 	EThreadSignal,
   151 	ENoThreads	
   155 	ENoThreads	
   152 	};
   156 	};
       
   157 
       
   158 
       
   159 
   153 
   160 
   154 /** Generates a file name of the form FFFFF*<aPos>.TXT (aLong.3)
   161 /** Generates a file name of the form FFFFF*<aPos>.TXT (aLong.3)
   155 
   162 
   156 	@param aBuffer The filename will be returned here
   163 	@param aBuffer The filename will be returned here
   157 	@param aLong   Defines the longitude of the file name 
   164 	@param aLong   Defines the longitude of the file name 
   608 	r = aFs.Delete(fileName2);
   615 	r = aFs.Delete(fileName2);
   609 	TEST(r == KErrNone);
   616 	TEST(r == KErrNone);
   610 	}
   617 	}
   611 
   618 
   612 
   619 
   613 
       
   614 /** Measure the time taken for a big block to be written synchronously
   620 /** Measure the time taken for a big block to be written synchronously
   615 */
   621 */
   616 void TimeTakenToWriteBigBlock() 
   622 void TimeTakenToWriteBigBlock() 
   617 {
   623 {
   618 	TTime startTime;
       
   619 	TTime endTime;
       
   620 	RFile fileWrite;
   624 	RFile fileWrite;
   621 	
   625 	
   622 	TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO);
   626 	TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO);
   623 	TESTERROR(r);
   627 	TESTERROR(r);
   624 
   628 
   625 	// Calculate how long it takes to write a big block to be able to issue at the right time the concurrent writes
   629 	// Calculate how long it takes to write a big block to be able to issue at the right time the concurrent writes
   626 	startTime.HomeTime();
   630     TF32TestTimer timer;
       
   631 	timer.Start();
   627 	
   632 	
   628 	r = fileWrite.Write(gBufWritePtr, KBigBlockSize); 
   633 	r = fileWrite.Write(gBufWritePtr, KBigBlockSize); 
   629 	
   634 
   630 	endTime.HomeTime();
   635     timer.Stop();
   631 	
   636 
   632 	fileWrite.Close();
   637 	fileWrite.Close();
   633 
   638 
   634 	TESTERROR(r);
   639 	TESTERROR(r);
   635 	
   640 	
   636 	gTimeTakenBigBlock = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()/3);
   641 	gTimeTakenBigBlock = timer.TimeInMicroSeconds()/3;
   637 
   642         
   638 	test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), gTimeTakenBigBlock.Int() / KuStomS);
   643 	test.Printf(_L("\nTime spent to write the big block in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigBlock));
   639 }
   644 }
   640 	
   645 	
   641 
   646 
   642 /** Measure the time taken for this file to be written synchronously
   647 /** Measure the time taken for this file to be written synchronously
   643 */
   648 */
   644 void TimeTakenToWriteBigFile(TInt aPos) 
   649 void TimeTakenToWriteBigFile(TInt aPos) 
   645 {
   650 {
   646 	TTime startTime;
       
   647 	TTime endTime;
       
   648 	
       
   649 	test((aPos >= 0) && (aPos <= 1));
   651 	test((aPos >= 0) && (aPos <= 1));
   650 	startTime.HomeTime();
   652     TF32TestTimer timer;
   651 	
   653     timer.Start();
       
   654 
   652 	WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads);
   655 	WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads);
   653 	
   656 	
   654 	endTime.HomeTime();
   657 	timer.Stop();
   655 
   658 
   656 	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
   659 	gTimeTakenBigFile = timer.Time32();
   657 	
   660 		
   658 	
   661 	test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile));
   659 	test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), gTimeTakenBigFile.Int() / KuStomS);
   662 	
   660 	
   663 	gTotalTimeSync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeSync[aPos]) ;
   661 	gTotalTimeSync[aPos] = Max((gTimeTakenBigFile.Int()/KuStomS), gTotalTimeSync[aPos]) ;
       
   662 }
   664 }
   663 
   665 
   664 /** Measure the time taken for this file to be written asynchronously
   666 /** Measure the time taken for this file to be written asynchronously
   665 */
   667 */
   666 void TimeTakenToWriteBigFileAsync(TInt aPos) 
   668 void TimeTakenToWriteBigFileAsync(TInt aPos) 
   667 {
   669 {
   668 	TTime startTime;
       
   669 	TTime endTime;
       
   670 	TTime endTime2;
       
   671 	TRequestStatus status[KWaitRequestsTableSize];
   670 	TRequestStatus status[KWaitRequestsTableSize];
   672 	RFile bigFile;
   671 	RFile bigFile;
   673 	
   672 	
   674 	test((aPos >= 0) && (aPos <= 1));
   673 	test((aPos >= 0) && (aPos <= 1));
   675 	
   674 
   676 	startTime.HomeTime();
   675     TF32TestTimer2 timer;
       
   676 	timer.Start();
   677 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); 
   677 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); 
   678 	endTime.HomeTime();
   678 	timer.Stop();
   679 
       
   680 	
   679 	
   681 	WaitForAll(status, gBigFileSize, KBigBlockSize);	
   680 	WaitForAll(status, gBigFileSize, KBigBlockSize);	
   682 	
   681 	timer.Stop2();
   683 	endTime2.HomeTime();
   682 	
   684 	
   683 	gTimeTakenBigFile = timer.Time32();        
   685 	gTimeTakenBigFile=I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
       
   686 	bigFile.Close();
   684 	bigFile.Close();
   687 	test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), gTimeTakenBigFile.Int() / KuStomS);
   685 	test.Printf(_L("\nTime to queue the blocks in isolation asynchronously: %d ms, "), timer.TimeInMilliSeconds());
   688 	gTimeTakenBigFile=I64LOW(endTime2.MicroSecondsFrom(startTime).Int64());
   686 	gTimeTakenBigFile = timer.Time2();
   689 	test.Printf(_L("to actually write it: %d ms\n"),gTimeTakenBigFile.Int() / KuStomS);
   687 	test.Printf(_L("to actually write it: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile));
   690 	gTotalTimeAsync[aPos] = Max((gTimeTakenBigFile.Int() / KuStomS), gTotalTimeAsync[aPos]) ; 
   688 	gTotalTimeAsync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeAsync[aPos]) ; 
   691 }
   689 }
   692 
   690 
   693 /**  Delete content of directory
   691 /**  Delete content of directory
   694 
   692 
   695 	@param aDir	Target directory
   693 	@param aDir	Target directory
   723 
   721 
   724 	r = fs.SetSessionPath(gSessionPath);
   722 	r = fs.SetSessionPath(gSessionPath);
   725 	TESTERROR(r);
   723 	TESTERROR(r);
   726 	
   724 	
   727 	ReadFile(fs,gSmallFile,KBlockSize, EThreadWait);
   725 	ReadFile(fs,gSmallFile,KBlockSize, EThreadWait);
   728 	gTime2.HomeTime();
   726 	gTestTimer.Start();
   729 	
   727 	
   730 	client.Signal();
   728 	client.Signal();
   731 	
   729 	
   732 	fs.Close();
   730 	fs.Close();
   733 	test.Close();
   731 	test.Close();
   748 
   746 
   749 	r=fs.SetSessionPath(gSessionPath);
   747 	r=fs.SetSessionPath(gSessionPath);
   750 	TESTERROR(r);
   748 	TESTERROR(r);
   751 	
   749 	
   752 	ReadFile(fs,gBigFile,KBlockSize, EThreadWait);
   750 	ReadFile(fs,gBigFile,KBlockSize, EThreadWait);
   753 	gTime2.HomeTime();
   751 	gTestTimer.Stop();
   754 	
   752 	
   755 	client.Signal();
   753 	client.Signal();
   756 		
   754 		
   757 	fs.Close();
   755 	fs.Close();
   758 	test.Close();
   756 	test.Close();
   773 
   771 
   774 	r=fs.SetSessionPath(gSessionPath);
   772 	r=fs.SetSessionPath(gSessionPath);
   775 	TESTERROR(r);
   773 	TESTERROR(r);
   776 	
   774 	
   777 	WriteFile(fs,gSmallFile,gSmallFileSize, KBlockSize, EThreadWait);
   775 	WriteFile(fs,gSmallFile,gSmallFileSize, KBlockSize, EThreadWait);
   778 	gTime2.HomeTime();
   776 	gTestTimer.Start();
   779 	
   777 	
   780 	client.Signal();
   778 	client.Signal();
   781 	
   779 	
   782 	fs.Close();
   780 	fs.Close();
   783 	test.Close();
   781 	test.Close();
   798 
   796 
   799 	r=fs.SetSessionPath(gSessionPath);
   797 	r=fs.SetSessionPath(gSessionPath);
   800 	TESTERROR(r);
   798 	TESTERROR(r);
   801 	
   799 	
   802 	WriteFile(fs, gBigFile, gBigFileSize, KBigBlockSize, EThreadSignal); 
   800 	WriteFile(fs, gBigFile, gBigFileSize, KBigBlockSize, EThreadSignal); 
   803 	gTime1.HomeTime();
   801 	gTestTimer.Stop();
   804 	
   802 	
   805 	client.Signal();
   803 	client.Signal();
   806 	
   804 	
   807 	fs.Close();
   805 	fs.Close();
   808 	test.Close();
   806 	test.Close();
   823 
   821 
   824 	r = fs.SetSessionPath(gSessionPath);
   822 	r = fs.SetSessionPath(gSessionPath);
   825 	TESTERROR(r);
   823 	TESTERROR(r);
   826 	
   824 	
   827 	WriteFile(fs, gSmallFile, gBigFileSize, KBigBlockSize, EThreadWait); 
   825 	WriteFile(fs, gSmallFile, gBigFileSize, KBigBlockSize, EThreadWait); 
   828 	gTime2.HomeTime();
   826 	gTestTimer.Stop();
   829 	
   827 	
   830 	client.Signal();
   828 	client.Signal();
   831 	
   829 	
   832 	fs.Close();
   830 	fs.Close();
   833 	test.Close();
   831 	test.Close();
   895 
   893 
   896 /**  Reads a small file while writing a big one
   894 /**  Reads a small file while writing a big one
   897 
   895 
   898 */
   896 */
   899 void TestReadingWhileWriting() 
   897 void TestReadingWhileWriting() 
   900 {
   898 {	
   901 	TInt r = 0;
       
   902 	TTime time1;
       
   903 	TTime time2;
       
   904 
       
   905 	time1.HomeTime();
       
   906 	
       
   907 	// Write the small file and take the appropriate measures
   899 	// Write the small file and take the appropriate measures
   908 	WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads);
   900 	WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads);
   909 
   901 
   910 	// Sync test
   902 	// Sync test
   911 	TBuf<20> buf=_L("Big Write");
   903 	TBuf<20> buf=_L("Big Write");
   912 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   904 	TInt r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   913 	TEST(r == KErrNone);
   905 	TEST(r == KErrNone);
   914 
   906 
   915 	buf = _L("Small Read");
   907 	buf = _L("Small Read");
   916 	r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   908 	r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   917 	TEST(r == KErrNone);
   909 	TEST(r == KErrNone);
   923 	CLIENTWAIT();
   915 	CLIENTWAIT();
   924 	
   916 	
   925 	gBig.Close();
   917 	gBig.Close();
   926 	gSmall.Close();
   918 	gSmall.Close();
   927 	
   919 	
   928 	
   920 	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
   929 	TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2);
   921 	test.Printf(_L("\nSync read done %d ms before the write ended\n"), TF32TestTimer::TimeInMilliSeconds(timeTaken));
   930 	test.Printf(_L("\nSync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
       
   931 	TReal time=I64LOW(timeTaken.Int64() / KuStomS); 
       
   932 	#if !defined(__WINS__)
   922 	#if !defined(__WINS__)
   933 	// If this condition fails, means that writing the sync file while fairscheduling a small sync read takes too long
   923 		// If this condition fails, it means that writing the sync file while 
   934 		test.Printf(_L("time: %f\n"), time);
   924         // fairscheduling a small sync read takes too long. Reading small file
   935 //		test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) );  
   925         // should complete first.
   936 		test(time > 0);
   926 		test(timeTaken > 0);
   937 	#endif 
   927 	#endif 
   938 	
   928 	
   939 	// Async test 
   929 	// Async test 
   940 	TRequestStatus status[KWaitRequestsTableSize];
   930 	TRequestStatus status[KWaitRequestsTableSize];
   941 	TRequestStatus status2[2];
   931 	TRequestStatus status2[2];
   943 
   933 
   944 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,  KBigBlockSize ,status); 
   934 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,  KBigBlockSize ,status); 
   945 	ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 );
   935 	ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 );
   946 
   936 
   947 	WaitForAll(status2,KBlockSize , KBlockSize );
   937 	WaitForAll(status2,KBlockSize , KBlockSize );
   948 	time1.HomeTime(); 
   938 
       
   939     TF32TestTimer timer;
       
   940 	timer.Start();
   949 
   941 
   950 	WaitForAll(status,gBigFileSize, KBigBlockSize);
   942 	WaitForAll(status,gBigFileSize, KBigBlockSize);
   951 
   943 
   952 	time2.HomeTime();
   944 	timer.Stop();
   953 	bigFile.Close();
   945 	bigFile.Close();
   954 	smallFile.Close();
   946 	smallFile.Close();
   955 	
   947 	
   956 	timeTaken = time2.MicroSecondsFrom(time1);
   948 	timeTaken = timer.Time();
   957 	
   949 	
   958 	test.Printf(_L("\nAsync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
   950 	test.Printf(_L("\nAsync read done %d ms before the write ended\n"), timer.TimeInMilliSeconds());
   959 	time = I64LOW(timeTaken.Int64() / KuStomS); 
       
   960 
   951 
   961 	#if !defined(__WINS__)
   952 	#if !defined(__WINS__)
   962 	// If this condition fails, means that writing the async file while fairscheduling a small async read takes too long
   953 	if (!Is_HVFS(TheFs, gDrive))
   963 		test.Printf(_L("time: %f\n"), time);
   954 		{
       
   955 		// If this condition fails, it means that writing the async file while fairscheduling a small async read takes too long
   964 		test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] );
   956 		test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] );
   965 //		test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) );
   957 		test(timeTaken > 0);
   966 		test(time > 0);
   958 		}
   967 	#endif
   959 	#endif
   968 }
   960 }
   969 
   961 
   970 /** Writes a small file while writing a big one
   962 /** Writes a small file while writing a big one
   971 
   963 
   972 */
   964 */
   973 void TestWritingWhileWriting() 
   965 void TestWritingWhileWriting() 
   974 {
   966 {
   975 	TInt r = 0;
   967 	TInt r = 0;
   976 	TTime time1;
       
   977 	TTime time2;
       
   978 
   968 
   979 	// Sync test
   969 	// Sync test
   980 	TBuf<20> buf = _L("Big Write II");
   970 	TBuf<20> buf = _L("Big Write II");
   981 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   971 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   982 	TEST(r == KErrNone);
   972 	TEST(r == KErrNone);
   992 	CLIENTWAIT();
   982 	CLIENTWAIT();
   993 	
   983 	
   994 	gBig.Close();
   984 	gBig.Close();
   995 	gSmall.Close();
   985 	gSmall.Close();
   996 	
   986 	
   997 	TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2);
   987 	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
   998 	test.Printf(_L("\nSync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
   988 	test.Printf(_L("\nSync write done %d ms before the big write ended\n"), gTestTimer.TimeInMilliSeconds());
   999 	TReal time=I64LOW(timeTaken.Int64() / KuStomS); 
       
  1000 	#if !defined(__WINS__)
   989 	#if !defined(__WINS__)
  1001 	// If this condition fails, means that writing the sync file while fairscheduling a small sync write takes too long
   990 		// If this condition fails, it means that writing the sync file while 
  1002 		test.Printf(_L("time: %f\n"), time);
   991         // fairscheduling a small sync write takes too long		
  1003 // 		test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); 
   992 		test(timeTaken > 0);
  1004 		test(time > 0);
       
  1005 	#endif 
   993 	#endif 
  1006 
   994 
  1007 	// Async test 
   995 	// Async test 
  1008 	TRequestStatus status[KWaitRequestsTableSize];
   996 	TRequestStatus status[KWaitRequestsTableSize];
  1009 	TRequestStatus status2[1];
   997 	TRequestStatus status2[1];
  1010 	RFile bigFile, smallFile;
   998 	RFile bigFile, smallFile;
  1011 
   999 
  1012 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
  1000 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
  1013 	WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2);
  1001 	WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2);
  1014 	WaitForAll(status2,gSmallFileSize, KBlockSize);
  1002 	WaitForAll(status2,gSmallFileSize, KBlockSize);
  1015 	time1.HomeTime();
  1003     TF32TestTimer timer;
       
  1004 	timer.Start();
  1016 	WaitForAll(status, gBigFileSize, KBigBlockSize);
  1005 	WaitForAll(status, gBigFileSize, KBigBlockSize);
  1017 	time2.HomeTime();
  1006 	timer.Stop();
  1018 	
  1007 	
  1019 	timeTaken = time2.MicroSecondsFrom(time1);
  1008 	timeTaken = timer.Time();
  1020 	test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
  1009 	test.Printf(_L("\nAsync write done %d ms before the big write ended\n"),timer.TimeInMilliSeconds());
  1021 	time=I64LOW(timeTaken.Int64() / KuStomS); 
       
  1022 	#if !defined(__WINS__)
  1010 	#if !defined(__WINS__)
  1023 	// If this condition fails, means that writing the async file while fairscheduling a small async write takes too long
  1011 	if (!Is_HVFS(TheFs, gDrive))
  1024 		test.Printf(_L("time: %f\n"), time);
  1012 		{
       
  1013 		// If this condition fails, it means that writing the async file while fairscheduling a small async write takes too long
  1025 		test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] );
  1014 		test.Printf(_L("gTotalTimeAsync[0] = %d , gTotalTimeAsync[1] = %d\n"),gTotalTimeAsync[0],gTotalTimeAsync[1] );
  1026 //		test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) ); 
  1015 		test(timeTaken > 0);
  1027 		test(time > 0);
  1016 		}
  1028 	#endif
  1017 	#endif
  1029 	bigFile.Close();
  1018 	bigFile.Close();
  1030 	smallFile.Close();	
  1019 	smallFile.Close();	
  1031 }
  1020 }
  1032 
  1021 
  1034 
  1023 
  1035 */
  1024 */
  1036 void TestTwoBigOnes()
  1025 void TestTwoBigOnes()
  1037 {
  1026 {
  1038 	TInt r = 0;
  1027 	TInt r = 0;
  1039 	TTime time1;
       
  1040 	TTime time2;
       
  1041 
  1028 
  1042 	// Sync test
  1029 	// Sync test
  1043 	TBuf<20> buf = _L("Big Write IIII");
  1030 	TBuf<20> buf = _L("Big Write IIII");
  1044 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
  1031 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
  1045 	TEST(r == KErrNone);
  1032 	TEST(r == KErrNone);
  1055 	CLIENTWAIT();
  1042 	CLIENTWAIT();
  1056 	
  1043 	
  1057 	gBig.Close();
  1044 	gBig.Close();
  1058 	gSmall.Close();
  1045 	gSmall.Close();
  1059 	
  1046 	
  1060 	TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1);
  1047 	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
  1061 	test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS));
  1048 	test.Printf(_L("\nSync first write ended %d ms before the second write ended (same file size)\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken));
  1062 
  1049 
  1063 	// Async test 
  1050 	// Async test 
  1064 	TRequestStatus status[KWaitRequestsTableSize];
  1051 	TRequestStatus status[KWaitRequestsTableSize];
  1065 	TRequestStatus status2[KWaitRequestsTableSize];
  1052 	TRequestStatus status2[KWaitRequestsTableSize];
  1066 	RFile bigFile, bigFile2;
  1053 	RFile bigFile, bigFile2;
  1067 
  1054 
  1068 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
  1055 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
  1069 	WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2);
  1056 	WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2);
  1070 	WaitForAll(status, gBigFileSize, KBigBlockSize);
  1057 	WaitForAll(status, gBigFileSize, KBigBlockSize);
  1071 	time1.HomeTime();
  1058     TF32TestTimer timer;
       
  1059 	timer.Start();
  1072 	WaitForAll(status2, gBigFileSize, KBigBlockSize);
  1060 	WaitForAll(status2, gBigFileSize, KBigBlockSize);
  1073 	time2.HomeTime();
  1061 	timer.Stop();
  1074 	
  1062 	
  1075 	timeTaken = time2.MicroSecondsFrom(time1);
  1063 	timeTaken = timer.Time();
  1076 	test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),I64LOW(timeTaken.Int64() / KuStomS));
  1064 	test.Printf(_L("\nAsync first write ended %d ms before the second write ended (same file size)\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken));
  1077 	bigFile.Close();
  1065 	bigFile.Close();
  1078 	bigFile2.Close();	
  1066 	bigFile2.Close();	
  1079 }
  1067 }
  1080 
  1068 
  1081 /**  Reads the file that is being written
  1069 /**  Reads the file that is being written
  1082 
  1070 
  1083 */
  1071 */
  1084 void TestReadingWhileWritingSameFile() 
  1072 void TestReadingWhileWritingSameFile() 
  1085 {
  1073 {
  1086 	TInt r = 0;
  1074 	TInt r = 0;
  1087 	TTime time1;
  1075 	TF32TestTimer timer;
  1088 	
  1076 	
  1089 	time1.HomeTime();
  1077 	timer.Start();
  1090 	
  1078 	
  1091 	// Sync test
  1079 	// Sync test
  1092 	TBuf<20> buf = _L("Big Write IV");
  1080 	TBuf<20> buf = _L("Big Write IV");
  1093 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
  1081 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
  1094 	TEST(r == KErrNone);
  1082 	TEST(r == KErrNone);
  1104 	CLIENTWAIT();
  1092 	CLIENTWAIT();
  1105 	
  1093 	
  1106 	CLOSE_AND_WAIT(gBig);
  1094 	CLOSE_AND_WAIT(gBig);
  1107 	CLOSE_AND_WAIT(gSmall);
  1095 	CLOSE_AND_WAIT(gSmall);
  1108 	
  1096 	
  1109 	TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1);
  1097 	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
  1110 	test.Printf(_L("\nSync write finished %d ms before the read ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
  1098 	test.Printf(_L("\nSync write finished %d ms before the read ended\n"),TF32TestTimer::TimeInMilliSeconds(timeTaken));
  1111 	
  1099 	
  1112 }
  1100 }
  1113 
  1101 
  1114 /** Client dying uncleanly before the operation is finished
  1102 /** Client dying uncleanly before the operation is finished
  1115 
  1103 
  1275 	test.Printf(_L("Disabling Lock Fail simulation ...\n"));
  1263 	test.Printf(_L("Disabling Lock Fail simulation ...\n"));
  1276 	// turn OFF lock failure mode (if cache is enabled)
  1264 	// turn OFF lock failure mode (if cache is enabled)
  1277 	
  1265 	
  1278 	TBool simulatelockFailureMode = EFalse;
  1266 	TBool simulatelockFailureMode = EFalse;
  1279 	r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1267 	r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1280 	test (r == KErrNone  ||  r == KErrNotSupported);
  1268 	test_Value(r, r == KErrNone  ||  r == KErrNotSupported);
  1281 #endif
  1269 #endif
  1282 
  1270 
  1283 	// FileNames/File generation
  1271 	// FileNames/File generation
  1284 	test.Start(_L("Preparing the environment\n"));
  1272 	test.Start(_L("Preparing the environment\n"));
  1285 	
  1273 	
  1334 
  1322 
  1335   	test.Next(_L("Ensure write order is preserved\n"));
  1323   	test.Next(_L("Ensure write order is preserved\n"));
  1336 	TestWriteOrder();
  1324 	TestWriteOrder();
  1337 	
  1325 	
  1338 	// Format the drive to make sure no blocks are left to be erased in LFFS
  1326 	// Format the drive to make sure no blocks are left to be erased in LFFS
  1339 	#if !defined(__WINS__)
  1327 	if (!Is_Win32(TheFs, gDrive))
  1340 		Format(gDrive);	
  1328 		Format(gDrive);	
  1341 	#endif
  1329 	
  1342 	r = TheFs.MkDirAll(gSessionPath);
  1330 	r = TheFs.MkDirAll(gSessionPath);
  1343 	
  1331 	
  1344 	TimeTakenToWriteBigFile(1);  
  1332 	TimeTakenToWriteBigFile(1);  
  1345 	TimeTakenToWriteBigFileAsync(1);
  1333 	TimeTakenToWriteBigFileAsync(1);
  1346 
  1334 
  1364 	
  1352 	
  1365 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1353 #if defined(_DEBUG) || defined(_DEBUG_RELEASE)
  1366 	// turn lock failure mode back ON (if cache is enabled)
  1354 	// turn lock failure mode back ON (if cache is enabled)
  1367 	simulatelockFailureMode = ETrue;
  1355 	simulatelockFailureMode = ETrue;
  1368 	r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1356 	r = controlIo(TheFs, gDrive, KControlIoSimulateLockFailureMode, simulatelockFailureMode);
  1369     test (r == KErrNone  ||  r == KErrNotSupported);
  1357     test_Value(r, r == KErrNone  ||  r == KErrNotSupported);
  1370 #endif
  1358 #endif
  1371 
  1359 
  1372 	test.End();
  1360 	test.End();
  1373 	}
  1361 	}
  1374 
  1362 
  1409 {
  1397 {
  1410 	TVolumeInfo volInfo;
  1398 	TVolumeInfo volInfo;
  1411 	TInt r = TheFs.Volume(volInfo, gDrive);
  1399 	TInt r = TheFs.Volume(volInfo, gDrive);
  1412 	TESTERROR(r);
  1400 	TESTERROR(r);
  1413 	
  1401 	
  1414 	gMediaSize = volInfo.iSize;
  1402 	gMediaSize = volInfo.iFree;
  1415 	gSmallFileSize = KBlockSize;
  1403 	gSmallFileSize = KBlockSize;
  1416 	gBigFileSize = KBlockSize*20;
  1404 	gBigFileSize = KBlockSize*20;
  1417 	
  1405 	
  1418 	while(((2*gBigFileSize)+KOneMeg) > gMediaSize ) 
  1406 	while(((2*gBigFileSize)+KOneMeg) > gMediaSize ) 
  1419 		{
  1407 		{
  1503 	else if (r == KErrCorrupt)
  1491 	else if (r == KErrCorrupt)
  1504 		{
  1492 		{
  1505 		test.Printf(_L("%c: Media corruption; previous test may have aborted; else, check hardware\n"), (TUint)gDrive + 'A');
  1493 		test.Printf(_L("%c: Media corruption; previous test may have aborted; else, check hardware\n"), (TUint)gDrive + 'A');
  1506 		}
  1494 		}
  1507 	TESTERROR(r);
  1495 	TESTERROR(r);
  1508 #if !defined(__WINS__)
  1496 	
  1509 	if ((volInfo.iDrive.iMediaAtt & KMediaAttFormattable))
  1497 	if (!Is_Win32(TheFs, gDrive) && (volInfo.iDrive.iMediaAtt & KMediaAttFormattable))
  1510 		Format(gDrive);
  1498 		Format(gDrive);
  1511 #endif
       
  1512 
  1499 
  1513 	if(CheckForDiskSize())
  1500 	if(CheckForDiskSize())
  1514 		{
  1501 		{
  1515 		DoTests();
  1502 		DoTests();
  1516 		}
  1503 		}