persistentstorage/sql/TEST/t_sqlcmdlineutil.cpp
changeset 55 44f437012c90
parent 28 7a522c0700d3
equal deleted inserted replaced
51:7d4490026038 55:44f437012c90
    19 	{
    19 	{
    20 	User::CommandLine(aCmdLine);
    20 	User::CommandLine(aCmdLine);
    21 	aCmdLine.TrimAll();
    21 	aCmdLine.TrimAll();
    22 	if(aCmdLine.Length() == 0)
    22 	if(aCmdLine.Length() == 0)
    23 		{
    23 		{
    24 		aTest.Printf(_L("Usage: %S [ [/enc=<16/8>] /drv=<drive letter>:] [/page=<512/1024/2048/4096/8192/16384/32768>] ] [/cache=<number>] [/hlimit=<Kb>]\r\n"), &aTestName);
    24 		aTest.Printf(_L("Usage: %S [ [/enc=<16/8>] /drv=<drive letter>:] [/page=<512/1024/2048/4096/8192/16384/32768>] ] [/cache=<number>] [/hlimit=<Kb>] [/logfile=<log file name>]\r\n"), &aTestName);
    25 		return;
    25 		return;
    26 		}
    26 		}
    27 	aCmdLine.Append(TChar('/'));
    27 	aCmdLine.Append(TChar('/'));
    28 	}
    28 	}
    29 
    29 
   147 			if(err == KErrNone && (softHeapLimit >= 0 && softHeapLimit < 1000000000))
   147 			if(err == KErrNone && (softHeapLimit >= 0 && softHeapLimit < 1000000000))
   148 				{
   148 				{
   149 				aCmdLineParams.iSoftHeapLimitKb = softHeapLimit;
   149 				aCmdLineParams.iSoftHeapLimitKb = softHeapLimit;
   150 				}
   150 				}
   151 			}
   151 			}
       
   152 		else if(aPrmNames[i].CompareF(_L("logfile")) == 0)
       
   153 			{
       
   154 			aCmdLineParams.iLogFileName.Copy(aPrmValues[i]);
       
   155 			}
   152 		}
   156 		}
   153 	}
   157 	}
   154 
   158 
   155 static void PrepareSqlConfigString(RTest& aTest, const TCmdLineParams& aCmdLineParams, TDes8& aConfigStr)
   159 static void PrepareSqlConfigString(RTest& aTest, const TCmdLineParams& aCmdLineParams, TDes8& aConfigStr)
   156 	{
   160 	{
   184 		aTest.Printf(_L("--PRM--Soft heap limit: %d Kb\r\n"), aCmdLineParams.iSoftHeapLimitKb);
   188 		aTest.Printf(_L("--PRM--Soft heap limit: %d Kb\r\n"), aCmdLineParams.iSoftHeapLimitKb);
   185 		}
   189 		}
   186 	else
   190 	else
   187 		{
   191 		{
   188 		aTest.Printf(_L("--PRM--Soft heap limit: default\r\n"));
   192 		aTest.Printf(_L("--PRM--Soft heap limit: default\r\n"));
       
   193 		}
       
   194 	
       
   195 	if(aCmdLineParams.iLogFileName.Length() > 0)
       
   196 		{
       
   197 		aTest.Printf(_L("--PRM--Log file name: %S\r\n"), &aCmdLineParams.iLogFileName);
       
   198 		}
       
   199 	else
       
   200 		{
       
   201 		aTest.Printf(_L("--PRM--Test output: to screen only\r\n"));
   189 		}
   202 		}
   190 	}
   203 	}
   191 
   204 
   192 #ifdef SQL_SOFT_HEAP_LIMIT_TEST	
   205 #ifdef SQL_SOFT_HEAP_LIMIT_TEST	
   193 
   206 
   284 	parse.Set(aDriveName, &aDeafultDbName, 0);
   297 	parse.Set(aDriveName, &aDeafultDbName, 0);
   285 	const TDesC& dbFilePath = parse.FullName();
   298 	const TDesC& dbFilePath = parse.FullName();
   286 	aDbName.Copy(dbFilePath);
   299 	aDbName.Copy(dbFilePath);
   287 	}
   300 	}
   288 
   301 
   289 void SetSoftHeapLimit(TInt aSoftHeapLimit)
   302 void SetSoftHeapLimit(RTest& aTest, TInt aSoftHeapLimit)
   290 	{
   303 	{
   291 	if(aSoftHeapLimit > 0)
   304 	if(aSoftHeapLimit > 0)
   292 		{
   305 		{
   293 #ifdef SQL_SOFT_HEAP_LIMIT_TEST	
   306 #ifdef SQL_SOFT_HEAP_LIMIT_TEST	
   294 		TBuf<50> configBuf;
   307 		TBuf<50> configBuf;
   295 		configBuf.Format(_L("soft_heap_limit_kb=%d"), aSoftHeapLimit);
   308 		configBuf.Format(_L("soft_heap_limit_kb=%d"), aSoftHeapLimit);
   296 		ReplaceConfigFile(configBuf);
   309 		ReplaceConfigFile(configBuf);
   297 #else
   310 #else
   298 		RDebug::Print(_L("The soft heap limit cannot be set if \"SQL_SOFT_HEAP_LIMIT_TEST\" macro is not defined!\r\n"));
   311 		aTest.Printf(_L("The soft heap limit cannot be set if \"SQL_SOFT_HEAP_LIMIT_TEST\" macro is not defined!\r\n"));
   299 #endif
   312 #endif
   300 		}
   313 		}
   301 	else if(aSoftHeapLimit < 0)
   314 	else if(aSoftHeapLimit < 0)
   302 		{
   315 		{
   303 		RDebug::Print(_L("Soft heap limit of %d Kb cannot be set!\r\n"), aSoftHeapLimit);
   316 		aTest.Printf(_L("Soft heap limit of %d Kb cannot be set!\r\n"), aSoftHeapLimit);
   304 		}
   317 		}
   305 	}
   318 	}
   306 
   319 
   307 void ResetSoftHeapLimit()
   320 void ResetSoftHeapLimit()
   308 	{
   321 	{
   309 #ifdef SQL_SOFT_HEAP_LIMIT_TEST	
   322 #ifdef SQL_SOFT_HEAP_LIMIT_TEST	
   310 	DeleteConfigFile();
   323 	DeleteConfigFile();
   311 #endif
   324 #endif
   312 	}
   325 	}
   313 
   326 
       
   327 void LogConfig(RFile& aLogFile, const TCmdLineParams& aCmdLineParams)
       
   328 	{
       
   329 	TBuf8<100> buf;
       
   330 	if(aCmdLineParams.iDbEncoding == TCmdLineParams::EDbUtf8)
       
   331 		{
       
   332 		buf.Copy(_L8("Database Encoding:UTF8\r\n"));
       
   333 		}
       
   334 	else
       
   335 		{
       
   336 		buf.Copy(_L8("Database Encoding:UTF16\r\n"));
       
   337 		}
       
   338 	(void)aLogFile.Write(buf);
       
   339 	
       
   340 	buf.Format(_L8("Database page size:%d\r\n"), aCmdLineParams.iPageSize);
       
   341 	(void)aLogFile.Write(buf);
       
   342 	
       
   343 	buf.Format(_L8("Database cache size:%d\r\n"), aCmdLineParams.iCacheSize);
       
   344 	(void)aLogFile.Write(buf);
       
   345 	
       
   346 	buf.Format(_L8("Database drive:%S\r\n"), &aCmdLineParams.iDriveName);
       
   347 	(void)aLogFile.Write(buf);
       
   348 
       
   349 	if(aCmdLineParams.iSoftHeapLimitKb > 0)
       
   350 		{
       
   351 		buf.Format(_L8("Soft heap limit:%d Kb\r\n"), aCmdLineParams.iSoftHeapLimitKb);
       
   352 		}
       
   353 	else
       
   354 		{
       
   355 		buf.Format(_L8("Soft heap limit: default\r\n"));
       
   356 		}
       
   357 	(void)aLogFile.Write(buf);
       
   358 	buf.Format(_L8("\r\n\r\n"));
       
   359 	(void)aLogFile.Write(buf);
       
   360 	}