persistentstorage/sql/TEST/t_sqlload.cpp
branchRCL_3
changeset 56 839ea9debada
parent 42 28839de615b4
equal deleted inserted replaced
50:8dc8494f1e0e 56:839ea9debada
    58 //Max allowed alive RSqlStatement objects per thread
    58 //Max allowed alive RSqlStatement objects per thread
    59 const TInt KMaxStatementPerThread = 30;
    59 const TInt KMaxStatementPerThread = 30;
    60 //Binary data length
    60 //Binary data length
    61 const TInt KBinDataLen = 2003;
    61 const TInt KBinDataLen = 2003;
    62 
    62 
    63 //StatementMaxNumberTest() time limit in seconds.
       
    64 const TInt KTestTimeLimit = 60;//seconds
       
    65 
       
    66 ///////////////////////////////////////////////////////////////////////////////////////
    63 ///////////////////////////////////////////////////////////////////////////////////////
    67 
    64 
    68 void DeleteTestFiles()
    65 void DeleteTestFiles()
    69 	{
    66 	{
    70 	RSqlDatabase::Delete(KTestDbName3);
    67 	RSqlDatabase::Delete(KTestDbName3);
   125 #define TTEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__, ETrue)
   122 #define TTEST2(aValue, aExpected) ::Check2(aValue, aExpected, __LINE__, ETrue)
   126 
   123 
   127 ///////////////////////////////////////////////////////////////////////////////////////
   124 ///////////////////////////////////////////////////////////////////////////////////////
   128 
   125 
   129 //StatementMaxNumberTest() timeouts in WDP builds.
   126 //StatementMaxNumberTest() timeouts in WDP builds.
   130 //This function is used return the seconds passed from the start of the test case.
   127 //This function is used to check whether the time limit is reaqched or not.
   131 TTimeIntervalSeconds ExecutionTimeSeconds()
   128 TBool IsTimeLimitReached()
   132 	{
   129 	{
   133 	struct TStartTime
   130 	struct TStartTime
   134 		{
   131 		{
   135 		TStartTime()
   132 		TStartTime()
   136 			{
   133 			{
   138 			}
   135 			}
   139 		TTime iTime;
   136 		TTime iTime;
   140 		};
   137 		};
   141 	
   138 	
   142 	static TStartTime startTime; 
   139 	static TStartTime startTime; 
       
   140 	const TInt KTestTimeLimit = 150;//seconds
   143 	
   141 	
   144 	TTime currTime;
   142 	TTime currTime;
   145 	currTime.HomeTime();
   143 	currTime.HomeTime();
   146 	
   144 	
   147 	TTimeIntervalSeconds s;
   145 	TTimeIntervalSeconds s;
   148 	TInt err = currTime.SecondsFrom(startTime.iTime, s);
   146 	TInt err = currTime.SecondsFrom(startTime.iTime, s);
   149 	TEST2(err, KErrNone);
   147 	TEST2(err, KErrNone);
   150 	return s;
   148 	return s.Int() > KTestTimeLimit;
   151 	}
   149 	}
   152 
   150 
   153 void CreateTestDir()
   151 void CreateTestDir()
   154     {
   152     {
   155     RFs fs;
   153     RFs fs;
   614 			break;
   612 			break;
   615 			}
   613 			}
   616 		if((idx % 100) == 0)
   614 		if((idx % 100) == 0)
   617 			{
   615 			{
   618 			GetHomeTimeAsString(time);
   616 			GetHomeTimeAsString(time);
   619 			TTimeIntervalSeconds s = ExecutionTimeSeconds();
   617 			TheTest.Printf(_L("=== %S: Create % 5d statements\r\n"), &time, idx + 1);
   620 			TheTest.Printf(_L("=== %S: Create % 5d statements. %d seconds.\r\n"), &time, idx + 1, s.Int());
   618 			if(IsTimeLimitReached())
   621 			if(s.Int() > KTestTimeLimit)
       
   622 				{
   619 				{
   623 				TheTest.Printf(_L("=== %S: The time limit reached.\r\n"), &time);
   620 				TheTest.Printf(_L("=== %S: The time limit reached.\r\n"), &time);
   624 				++idx;//The idx-th statement is valid, the statement count is idx + 1.
   621 				++idx;//The idx-th statement is valid, the statement count is idx + 1.
   625 				break;
   622 				break;
   626 				}
   623 				}
   650 		TEST2(err, KSqlAtRow);
   647 		TEST2(err, KSqlAtRow);
   651 		err = stmt[idx].Next();
   648 		err = stmt[idx].Next();
   652 		TEST2(err, KSqlAtRow);
   649 		TEST2(err, KSqlAtRow);
   653 		err = stmt[idx].Next();
   650 		err = stmt[idx].Next();
   654 		TEST2(err, KSqlAtEnd);
   651 		TEST2(err, KSqlAtEnd);
   655 		GetHomeTimeAsString(time);
       
   656 		TTimeIntervalSeconds s = ExecutionTimeSeconds();
       
   657 		if((j % 100) == 0)
   652 		if((j % 100) == 0)
   658 			{
   653 			{
   659 			TheTest.Printf(_L("=== %S: % 5d statements processed. %d seconds.\r\n"), &time, j + 1, s.Int());
   654 			GetHomeTimeAsString(time);
   660 			}
   655 			TheTest.Printf(_L("=== %S: % 5d statements processed\r\n"), &time, j + 1);
   661 		if(s.Int() > KTestTimeLimit)
   656 			}
       
   657 		if(IsTimeLimitReached())
   662 			{
   658 			{
   663 			TheTest.Printf(_L("=== %S: The time limit reached.\r\n"), &time);
   659 			TheTest.Printf(_L("=== %S: The time limit reached.\r\n"), &time);
   664 			break;
   660 			break;
   665 			}
   661 			}
   666 		}
   662 		}