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