kerneltest/f32test/server/t_fsched.cpp
changeset 247 d8d70de2bd36
parent 200 73ea206103e6
child 259 57b9594f5772
equal deleted inserted replaced
201:43365a9b78a3 247:d8d70de2bd36
    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"
    32 #include "f32_test_utils.h"
    34 #include "f32_test_utils.h"
    33 
       
    34 using namespace F32_Test_Utils;
    35 using namespace F32_Test_Utils;
       
    36 
    35 
    37 
    36 //----------------------------------------------------------------------------------------------
    38 //----------------------------------------------------------------------------------------------
    37 //! @SYMTestCaseID      PBASE-T_FSCHED-0191
    39 //! @SYMTestCaseID      PBASE-T_FSCHED-0191
    38 //! @SYMTestType        CIT
    40 //! @SYMTestType        CIT
    39 //! @SYMPREQ            PREQ914
    41 //! @SYMPREQ            PREQ914
   115 HBufC8* gBuf = NULL;
   117 HBufC8* gBuf = NULL;
   116 TPtr8 gBufReadPtr(NULL, 0);	
   118 TPtr8 gBufReadPtr(NULL, 0);	
   117 HBufC8* gBufSec = NULL;
   119 HBufC8* gBufSec = NULL;
   118 TPtr8 gBufWritePtr(NULL, 0);	
   120 TPtr8 gBufWritePtr(NULL, 0);	
   119 
   121 
   120 const TInt KuStomS = 1000;
       
   121 const TInt KOneK = 1024;
   122 const TInt KOneK = 1024;
   122 const TInt KOneMeg = KOneK * 1024;
   123 const TInt KOneMeg = KOneK * 1024;
   123 const TInt KBigBlockSize = KOneMeg ; 
   124 const TInt KBigBlockSize = KOneMeg ; 
   124 const TInt KBlockSize = KOneK * 129 ; 
   125 const TInt KBlockSize = KOneK * 129 ; 
   125 const TInt KWaitRequestsTableSize = 70;
   126 const TInt KWaitRequestsTableSize = 70;
   132 
   133 
   133 TTimeIntervalMicroSeconds32 gTimeTakenBigFile(0);
   134 TTimeIntervalMicroSeconds32 gTimeTakenBigFile(0);
   134 TTimeIntervalMicroSeconds32 gTimeTakenBigBlock(0);
   135 TTimeIntervalMicroSeconds32 gTimeTakenBigBlock(0);
   135 TBuf16<45> gSmallFile, gBigFile;
   136 TBuf16<45> gSmallFile, gBigFile;
   136 TInt gNextFile=0;
   137 TInt gNextFile=0;
   137 TTime gTime1;
   138 
   138 TTime gTime2;
   139 TF32TestTimer gTestTimer;
   139 
   140 
   140 RSemaphore gSync;
   141 RSemaphore gSync;
   141 
   142 
   142 // Concurrent Threads
   143 // Concurrent Threads
   143 RThread gBig;
   144 RThread gBig;
   151 	{
   152 	{
   152 	EThreadWait,
   153 	EThreadWait,
   153 	EThreadSignal,
   154 	EThreadSignal,
   154 	ENoThreads	
   155 	ENoThreads	
   155 	};
   156 	};
       
   157 
       
   158 
       
   159 
   156 
   160 
   157 /** 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)
   158 
   162 
   159 	@param aBuffer The filename will be returned here
   163 	@param aBuffer The filename will be returned here
   160 	@param aLong   Defines the longitude of the file name 
   164 	@param aLong   Defines the longitude of the file name 
   611 	r = aFs.Delete(fileName2);
   615 	r = aFs.Delete(fileName2);
   612 	TEST(r == KErrNone);
   616 	TEST(r == KErrNone);
   613 	}
   617 	}
   614 
   618 
   615 
   619 
   616 
       
   617 /** 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
   618 */
   621 */
   619 void TimeTakenToWriteBigBlock() 
   622 void TimeTakenToWriteBigBlock() 
   620 {
   623 {
   621 	TTime startTime;
       
   622 	TTime endTime;
       
   623 	RFile fileWrite;
   624 	RFile fileWrite;
   624 	
   625 	
   625 	TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO);
   626 	TInt r = fileWrite.Replace(TheFs,gBigFile,EFileShareAny|EFileWrite|EFileWriteDirectIO);
   626 	TESTERROR(r);
   627 	TESTERROR(r);
   627 
   628 
   628 	// 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
   629 	startTime.HomeTime();
   630     TF32TestTimer timer;
       
   631 	timer.Start();
   630 	
   632 	
   631 	r = fileWrite.Write(gBufWritePtr, KBigBlockSize); 
   633 	r = fileWrite.Write(gBufWritePtr, KBigBlockSize); 
   632 	
   634 
   633 	endTime.HomeTime();
   635     timer.Stop();
   634 	
   636 
   635 	fileWrite.Close();
   637 	fileWrite.Close();
   636 
   638 
   637 	TESTERROR(r);
   639 	TESTERROR(r);
   638 	
   640 	
   639 	gTimeTakenBigBlock = I64LOW(endTime.MicroSecondsFrom(startTime).Int64()/3);
   641 	gTimeTakenBigBlock = timer.TimeInMicroSeconds()/3;
   640 
   642         
   641 	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));
   642 }
   644 }
   643 	
   645 	
   644 
   646 
   645 /** Measure the time taken for this file to be written synchronously
   647 /** Measure the time taken for this file to be written synchronously
   646 */
   648 */
   647 void TimeTakenToWriteBigFile(TInt aPos) 
   649 void TimeTakenToWriteBigFile(TInt aPos) 
   648 {
   650 {
   649 	TTime startTime;
       
   650 	TTime endTime;
       
   651 	
       
   652 	test((aPos >= 0) && (aPos <= 1));
   651 	test((aPos >= 0) && (aPos <= 1));
   653 	startTime.HomeTime();
   652     TF32TestTimer timer;
   654 	
   653     timer.Start();
       
   654 
   655 	WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads);
   655 	WriteFile(TheFs,gBigFile, gBigFileSize, KBigBlockSize, ENoThreads);
   656 	
   656 	
   657 	endTime.HomeTime();
   657 	timer.Stop();
   658 
   658 
   659 	gTimeTakenBigFile = I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
   659 	gTimeTakenBigFile = timer.Time32();
   660 	
   660 		
   661 	
   661 	test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile));
   662 	test.Printf(_L("\nTime spent to write the big file in isolation: %d ms\n"), gTimeTakenBigFile.Int() / KuStomS);
   662 	
   663 	
   663 	gTotalTimeSync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeSync[aPos]) ;
   664 	gTotalTimeSync[aPos] = Max((gTimeTakenBigFile.Int()/KuStomS), gTotalTimeSync[aPos]) ;
       
   665 }
   664 }
   666 
   665 
   667 /** Measure the time taken for this file to be written asynchronously
   666 /** Measure the time taken for this file to be written asynchronously
   668 */
   667 */
   669 void TimeTakenToWriteBigFileAsync(TInt aPos) 
   668 void TimeTakenToWriteBigFileAsync(TInt aPos) 
   670 {
   669 {
   671 	TTime startTime;
       
   672 	TTime endTime;
       
   673 	TTime endTime2;
       
   674 	TRequestStatus status[KWaitRequestsTableSize];
   670 	TRequestStatus status[KWaitRequestsTableSize];
   675 	RFile bigFile;
   671 	RFile bigFile;
   676 	
   672 	
   677 	test((aPos >= 0) && (aPos <= 1));
   673 	test((aPos >= 0) && (aPos <= 1));
   678 	
   674 
   679 	startTime.HomeTime();
   675     TF32TestTimer2 timer;
       
   676 	timer.Start();
   680 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); 
   677 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,KBigBlockSize,status); 
   681 	endTime.HomeTime();
   678 	timer.Stop();
   682 
       
   683 	
   679 	
   684 	WaitForAll(status, gBigFileSize, KBigBlockSize);	
   680 	WaitForAll(status, gBigFileSize, KBigBlockSize);	
   685 	
   681 	timer.Stop2();
   686 	endTime2.HomeTime();
   682 	
   687 	
   683 	gTimeTakenBigFile = timer.Time32();        
   688 	gTimeTakenBigFile=I64LOW(endTime.MicroSecondsFrom(startTime).Int64());
       
   689 	bigFile.Close();
   684 	bigFile.Close();
   690 	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());
   691 	gTimeTakenBigFile=I64LOW(endTime2.MicroSecondsFrom(startTime).Int64());
   686 	gTimeTakenBigFile = timer.Time2();
   692 	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));
   693 	gTotalTimeAsync[aPos] = Max((gTimeTakenBigFile.Int() / KuStomS), gTotalTimeAsync[aPos]) ; 
   688 	gTotalTimeAsync[aPos] = Max(TF32TestTimer::TimeInMilliSeconds(gTimeTakenBigFile), gTotalTimeAsync[aPos]) ; 
   694 }
   689 }
   695 
   690 
   696 /**  Delete content of directory
   691 /**  Delete content of directory
   697 
   692 
   698 	@param aDir	Target directory
   693 	@param aDir	Target directory
   726 
   721 
   727 	r = fs.SetSessionPath(gSessionPath);
   722 	r = fs.SetSessionPath(gSessionPath);
   728 	TESTERROR(r);
   723 	TESTERROR(r);
   729 	
   724 	
   730 	ReadFile(fs,gSmallFile,KBlockSize, EThreadWait);
   725 	ReadFile(fs,gSmallFile,KBlockSize, EThreadWait);
   731 	gTime2.HomeTime();
   726 	gTestTimer.Start();
   732 	
   727 	
   733 	client.Signal();
   728 	client.Signal();
   734 	
   729 	
   735 	fs.Close();
   730 	fs.Close();
   736 	test.Close();
   731 	test.Close();
   751 
   746 
   752 	r=fs.SetSessionPath(gSessionPath);
   747 	r=fs.SetSessionPath(gSessionPath);
   753 	TESTERROR(r);
   748 	TESTERROR(r);
   754 	
   749 	
   755 	ReadFile(fs,gBigFile,KBlockSize, EThreadWait);
   750 	ReadFile(fs,gBigFile,KBlockSize, EThreadWait);
   756 	gTime2.HomeTime();
   751 	gTestTimer.Stop();
   757 	
   752 	
   758 	client.Signal();
   753 	client.Signal();
   759 		
   754 		
   760 	fs.Close();
   755 	fs.Close();
   761 	test.Close();
   756 	test.Close();
   776 
   771 
   777 	r=fs.SetSessionPath(gSessionPath);
   772 	r=fs.SetSessionPath(gSessionPath);
   778 	TESTERROR(r);
   773 	TESTERROR(r);
   779 	
   774 	
   780 	WriteFile(fs,gSmallFile,gSmallFileSize, KBlockSize, EThreadWait);
   775 	WriteFile(fs,gSmallFile,gSmallFileSize, KBlockSize, EThreadWait);
   781 	gTime2.HomeTime();
   776 	gTestTimer.Start();
   782 	
   777 	
   783 	client.Signal();
   778 	client.Signal();
   784 	
   779 	
   785 	fs.Close();
   780 	fs.Close();
   786 	test.Close();
   781 	test.Close();
   801 
   796 
   802 	r=fs.SetSessionPath(gSessionPath);
   797 	r=fs.SetSessionPath(gSessionPath);
   803 	TESTERROR(r);
   798 	TESTERROR(r);
   804 	
   799 	
   805 	WriteFile(fs, gBigFile, gBigFileSize, KBigBlockSize, EThreadSignal); 
   800 	WriteFile(fs, gBigFile, gBigFileSize, KBigBlockSize, EThreadSignal); 
   806 	gTime1.HomeTime();
   801 	gTestTimer.Stop();
   807 	
   802 	
   808 	client.Signal();
   803 	client.Signal();
   809 	
   804 	
   810 	fs.Close();
   805 	fs.Close();
   811 	test.Close();
   806 	test.Close();
   826 
   821 
   827 	r = fs.SetSessionPath(gSessionPath);
   822 	r = fs.SetSessionPath(gSessionPath);
   828 	TESTERROR(r);
   823 	TESTERROR(r);
   829 	
   824 	
   830 	WriteFile(fs, gSmallFile, gBigFileSize, KBigBlockSize, EThreadWait); 
   825 	WriteFile(fs, gSmallFile, gBigFileSize, KBigBlockSize, EThreadWait); 
   831 	gTime2.HomeTime();
   826 	gTestTimer.Stop();
   832 	
   827 	
   833 	client.Signal();
   828 	client.Signal();
   834 	
   829 	
   835 	fs.Close();
   830 	fs.Close();
   836 	test.Close();
   831 	test.Close();
   898 
   893 
   899 /**  Reads a small file while writing a big one
   894 /**  Reads a small file while writing a big one
   900 
   895 
   901 */
   896 */
   902 void TestReadingWhileWriting() 
   897 void TestReadingWhileWriting() 
   903 {
   898 {	
   904 	TInt r = 0;
       
   905 	TTime time1;
       
   906 	TTime time2;
       
   907 
       
   908 	time1.HomeTime();
       
   909 	
       
   910 	// Write the small file and take the appropriate measures
   899 	// Write the small file and take the appropriate measures
   911 	WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads);
   900 	WriteFile(TheFs,gSmallFile,KBlockSize, KBlockSize, ENoThreads);
   912 
   901 
   913 	// Sync test
   902 	// Sync test
   914 	TBuf<20> buf=_L("Big Write");
   903 	TBuf<20> buf=_L("Big Write");
   915 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   904 	TInt r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   916 	TEST(r == KErrNone);
   905 	TEST(r == KErrNone);
   917 
   906 
   918 	buf = _L("Small Read");
   907 	buf = _L("Small Read");
   919 	r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   908 	r = gSmall.Create(buf, ReadSmallFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   920 	TEST(r == KErrNone);
   909 	TEST(r == KErrNone);
   926 	CLIENTWAIT();
   915 	CLIENTWAIT();
   927 	
   916 	
   928 	gBig.Close();
   917 	gBig.Close();
   929 	gSmall.Close();
   918 	gSmall.Close();
   930 	
   919 	
   931 	
   920 	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
   932 	TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2);
   921 	test.Printf(_L("\nSync read done %d ms before the write ended\n"), TF32TestTimer::TimeInMilliSeconds(timeTaken));
   933 	test.Printf(_L("\nSync read done %d ms before the write ended\n"),I64LOW(timeTaken.Int64() / KuStomS));
       
   934 	TReal time=I64LOW(timeTaken.Int64() / KuStomS); 
       
   935 	#if !defined(__WINS__)
   922 	#if !defined(__WINS__)
   936 		// If this condition fails, it 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 
   937 		test.Printf(_L("time: %f\n"), time);
   924         // fairscheduling a small sync read takes too long. Reading small file
   938 		// test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) );  
   925         // should complete first.
   939 		test(time > 0);
   926 		test(timeTaken > 0);
   940 	#endif 
   927 	#endif 
   941 	
   928 	
   942 	// Async test 
   929 	// Async test 
   943 	TRequestStatus status[KWaitRequestsTableSize];
   930 	TRequestStatus status[KWaitRequestsTableSize];
   944 	TRequestStatus status2[2];
   931 	TRequestStatus status2[2];
   946 
   933 
   947 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,  KBigBlockSize ,status); 
   934 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize,  KBigBlockSize ,status); 
   948 	ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 );
   935 	ReadFileAsync(TheFs, smallFile, gSmallFile, KBlockSize, status2 );
   949 
   936 
   950 	WaitForAll(status2,KBlockSize , KBlockSize );
   937 	WaitForAll(status2,KBlockSize , KBlockSize );
   951 	time1.HomeTime(); 
   938 
       
   939     TF32TestTimer timer;
       
   940 	timer.Start();
   952 
   941 
   953 	WaitForAll(status,gBigFileSize, KBigBlockSize);
   942 	WaitForAll(status,gBigFileSize, KBigBlockSize);
   954 
   943 
   955 	time2.HomeTime();
   944 	timer.Stop();
   956 	bigFile.Close();
   945 	bigFile.Close();
   957 	smallFile.Close();
   946 	smallFile.Close();
   958 	
   947 	
   959 	timeTaken = time2.MicroSecondsFrom(time1);
   948 	timeTaken = timer.Time();
   960 	
   949 	
   961 	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());
   962 	time = I64LOW(timeTaken.Int64() / KuStomS); 
       
   963 
   951 
   964 	#if !defined(__WINS__)
   952 	#if !defined(__WINS__)
   965 	if (!Is_HVFS(TheFs, gDrive))
   953 	if (!Is_HVFS(TheFs, gDrive))
   966 		{
   954 		{
   967 		// If this condition fails, it means that writing the async file while fairscheduling a small async read takes too long
   955 		// If this condition fails, it means that writing the async file while fairscheduling a small async read takes too long
   968 		test.Printf(_L("time: %f\n"), time);
       
   969 		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] );
   970 		// test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) );
   957 		test(timeTaken > 0);
   971 		test(time > 0);
       
   972 		}
   958 		}
   973 	#endif
   959 	#endif
   974 }
   960 }
   975 
   961 
   976 /** Writes a small file while writing a big one
   962 /** Writes a small file while writing a big one
   977 
   963 
   978 */
   964 */
   979 void TestWritingWhileWriting() 
   965 void TestWritingWhileWriting() 
   980 {
   966 {
   981 	TInt r = 0;
   967 	TInt r = 0;
   982 	TTime time1;
       
   983 	TTime time2;
       
   984 
   968 
   985 	// Sync test
   969 	// Sync test
   986 	TBuf<20> buf = _L("Big Write II");
   970 	TBuf<20> buf = _L("Big Write II");
   987 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   971 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
   988 	TEST(r == KErrNone);
   972 	TEST(r == KErrNone);
   998 	CLIENTWAIT();
   982 	CLIENTWAIT();
   999 	
   983 	
  1000 	gBig.Close();
   984 	gBig.Close();
  1001 	gSmall.Close();
   985 	gSmall.Close();
  1002 	
   986 	
  1003 	TTimeIntervalMicroSeconds timeTaken = gTime1.MicroSecondsFrom(gTime2);
   987 	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
  1004 	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());
  1005 	TReal time=I64LOW(timeTaken.Int64() / KuStomS); 
       
  1006 	#if !defined(__WINS__)
   989 	#if !defined(__WINS__)
  1007 		// If this condition fails, it 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 
  1008 		test.Printf(_L("time: %f\n"), time);
   991         // fairscheduling a small sync write takes too long		
  1009 		// test((time > 0) && (((gTotalTimeSync[0]-time)>0) || ((gTotalTimeSync[1]-time)>0)) ); 
   992 		test(timeTaken > 0);
  1010 		test(time > 0);
       
  1011 	#endif 
   993 	#endif 
  1012 
   994 
  1013 	// Async test 
   995 	// Async test 
  1014 	TRequestStatus status[KWaitRequestsTableSize];
   996 	TRequestStatus status[KWaitRequestsTableSize];
  1015 	TRequestStatus status2[1];
   997 	TRequestStatus status2[1];
  1016 	RFile bigFile, smallFile;
   998 	RFile bigFile, smallFile;
  1017 
   999 
  1018 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
  1000 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
  1019 	WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2);
  1001 	WriteFileAsync(TheFs,smallFile, gSmallFile,gSmallFileSize,KBlockSize,status2);
  1020 	WaitForAll(status2,gSmallFileSize, KBlockSize);
  1002 	WaitForAll(status2,gSmallFileSize, KBlockSize);
  1021 	time1.HomeTime();
  1003     TF32TestTimer timer;
       
  1004 	timer.Start();
  1022 	WaitForAll(status, gBigFileSize, KBigBlockSize);
  1005 	WaitForAll(status, gBigFileSize, KBigBlockSize);
  1023 	time2.HomeTime();
  1006 	timer.Stop();
  1024 	
  1007 	
  1025 	timeTaken = time2.MicroSecondsFrom(time1);
  1008 	timeTaken = timer.Time();
  1026 	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());
  1027 	time=I64LOW(timeTaken.Int64() / KuStomS);
       
  1028 	#if !defined(__WINS__)
  1010 	#if !defined(__WINS__)
  1029 	if (!Is_HVFS(TheFs, gDrive))
  1011 	if (!Is_HVFS(TheFs, gDrive))
  1030 		{
  1012 		{
  1031 		// If this condition fails, it means that writing the async file while fairscheduling a small async write takes too long
  1013 		// If this condition fails, it means that writing the async file while fairscheduling a small async write takes too long
  1032 		test.Printf(_L("time: %f\n"), time);
       
  1033 		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] );
  1034 		// test((time > 0) && (((gTotalTimeAsync[0]-time)>0) || ((gTotalTimeAsync[1]-time)>0)) );
  1015 		test(timeTaken > 0);
  1035 		test(time > 0);
       
  1036 		}
  1016 		}
  1037 	#endif
  1017 	#endif
  1038 	bigFile.Close();
  1018 	bigFile.Close();
  1039 	smallFile.Close();	
  1019 	smallFile.Close();	
  1040 }
  1020 }
  1043 
  1023 
  1044 */
  1024 */
  1045 void TestTwoBigOnes()
  1025 void TestTwoBigOnes()
  1046 {
  1026 {
  1047 	TInt r = 0;
  1027 	TInt r = 0;
  1048 	TTime time1;
       
  1049 	TTime time2;
       
  1050 
  1028 
  1051 	// Sync test
  1029 	// Sync test
  1052 	TBuf<20> buf = _L("Big Write IIII");
  1030 	TBuf<20> buf = _L("Big Write IIII");
  1053 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
  1031 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
  1054 	TEST(r == KErrNone);
  1032 	TEST(r == KErrNone);
  1064 	CLIENTWAIT();
  1042 	CLIENTWAIT();
  1065 	
  1043 	
  1066 	gBig.Close();
  1044 	gBig.Close();
  1067 	gSmall.Close();
  1045 	gSmall.Close();
  1068 	
  1046 	
  1069 	TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1);
  1047 	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
  1070 	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));
  1071 
  1049 
  1072 	// Async test 
  1050 	// Async test 
  1073 	TRequestStatus status[KWaitRequestsTableSize];
  1051 	TRequestStatus status[KWaitRequestsTableSize];
  1074 	TRequestStatus status2[KWaitRequestsTableSize];
  1052 	TRequestStatus status2[KWaitRequestsTableSize];
  1075 	RFile bigFile, bigFile2;
  1053 	RFile bigFile, bigFile2;
  1076 
  1054 
  1077 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
  1055 	WriteFileAsync(TheFs, bigFile, gBigFile, gBigFileSize, KBigBlockSize, status); 
  1078 	WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2);
  1056 	WriteFileAsync(TheFs, bigFile2, gSmallFile, gBigFileSize, KBigBlockSize, status2);
  1079 	WaitForAll(status, gBigFileSize, KBigBlockSize);
  1057 	WaitForAll(status, gBigFileSize, KBigBlockSize);
  1080 	time1.HomeTime();
  1058     TF32TestTimer timer;
       
  1059 	timer.Start();
  1081 	WaitForAll(status2, gBigFileSize, KBigBlockSize);
  1060 	WaitForAll(status2, gBigFileSize, KBigBlockSize);
  1082 	time2.HomeTime();
  1061 	timer.Stop();
  1083 	
  1062 	
  1084 	timeTaken = time2.MicroSecondsFrom(time1);
  1063 	timeTaken = timer.Time();
  1085 	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));
  1086 	bigFile.Close();
  1065 	bigFile.Close();
  1087 	bigFile2.Close();	
  1066 	bigFile2.Close();	
  1088 }
  1067 }
  1089 
  1068 
  1090 /**  Reads the file that is being written
  1069 /**  Reads the file that is being written
  1091 
  1070 
  1092 */
  1071 */
  1093 void TestReadingWhileWritingSameFile() 
  1072 void TestReadingWhileWritingSameFile() 
  1094 {
  1073 {
  1095 	TInt r = 0;
  1074 	TInt r = 0;
  1096 	TTime time1;
  1075 	TF32TestTimer timer;
  1097 	
  1076 	
  1098 	time1.HomeTime();
  1077 	timer.Start();
  1099 	
  1078 	
  1100 	// Sync test
  1079 	// Sync test
  1101 	TBuf<20> buf = _L("Big Write IV");
  1080 	TBuf<20> buf = _L("Big Write IV");
  1102 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
  1081 	r = gBig.Create(buf, WriteBigFile, KDefaultStackSize, KHeapSize, KMaxHeapSize, NULL);
  1103 	TEST(r == KErrNone);
  1082 	TEST(r == KErrNone);
  1113 	CLIENTWAIT();
  1092 	CLIENTWAIT();
  1114 	
  1093 	
  1115 	CLOSE_AND_WAIT(gBig);
  1094 	CLOSE_AND_WAIT(gBig);
  1116 	CLOSE_AND_WAIT(gSmall);
  1095 	CLOSE_AND_WAIT(gSmall);
  1117 	
  1096 	
  1118 	TTimeIntervalMicroSeconds timeTaken = gTime2.MicroSecondsFrom(gTime1);
  1097 	TTimeIntervalMicroSeconds timeTaken = gTestTimer.Time();
  1119 	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));
  1120 	
  1099 	
  1121 }
  1100 }
  1122 
  1101 
  1123 /** Client dying uncleanly before the operation is finished
  1102 /** Client dying uncleanly before the operation is finished
  1124 
  1103