traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_performance/src/te_perfresultscollector.cpp
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // Ost Performance Tests Results Collector.
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 /**
       
    20  @file te_perfresultscollector.cpp
       
    21  @internalTechnology
       
    22  @prototype
       
    23 */
       
    24 
       
    25 #include "te_perfresultscollector.h"
       
    26 #include "te_perfcsvgenerator.h"
       
    27 #include "te_lightlogger.h"
       
    28 #include "uloggerclient.h"
       
    29 using namespace Ulogger; //CA:added so can use old ulogger api
       
    30 CUptResults::CUptResults()
       
    31 	{
       
    32 	/*Constructor*/
       
    33 	}
       
    34 
       
    35 CUptResults::~CUptResults()
       
    36 	{
       
    37 	/*Destructor*/
       
    38 	iPluginTest.Reset();
       
    39 	iApiTest.Reset();
       
    40 	}
       
    41 
       
    42 /** This user-side method uses take an API test object as an argument and stores it as an element in the
       
    43 private data member iApiTest, an array of API test objects.
       
    44 @param aApiTest is a reference to a CUptApiTest object
       
    45 @return KErrNone if command was prepared correctly and system wide error code otherwise.
       
    46  */
       
    47 void CUptResults::StoreApiResultsL(const TApiTestResult& aApiTest)
       
    48 	{
       
    49 	//store the apitest result object at the end of the list
       
    50 	iApiTest.InsertL(&aApiTest, iApiTest.Count());
       
    51 	__TEST_LOG("API Store");
       
    52 	__TEST_LOGNUM(iApiTest.Count())
       
    53 	}
       
    54 	
       
    55 /** This user-side method uses take an OutputPlugin test object as an argument and stores it as an element in the
       
    56 private data member iOutputPluginTest, an array of output plugin test objects.
       
    57 @param aOutputPluginTest is a reference to a CUptOutputPluginTest object
       
    58 @return KErrNone if command was prepared correctly and system wide error code otherwise.
       
    59  */
       
    60 void CUptResults::StorePluginResultsL(const CPluginTestResult& aPluginTest)
       
    61 	{
       
    62 	//store the plugin test result object at the end of the list
       
    63 	iPluginTest.InsertL(&aPluginTest, iPluginTest.Count());
       
    64 	__TEST_LOG("Plugin Store");
       
    65 	__TEST_LOGNUM(iPluginTest.Count())
       
    66 	}
       
    67 	
       
    68 /** This method user-side method uses takes a filepath, whether the relevant file should be appended or overwritten and the testtype as arguments
       
    69 uses these to store the contents of results of the relevant test type (exposed by accessing the relevant private data member)
       
    70 to the specified file.
       
    71 @param aFileName is the file path where the results are to be stored, passed as a TDesC
       
    72 @param aAppend is a TBool specifying whether to append or overwrite the file
       
    73 				ETrue=Append, EFalse=EFalse
       
    74 @param aTestType is an enum specifying which test type the user wants to write to the file.
       
    75 @return KErrNone if command was prepared correctly and system wide error code otherwise.
       
    76  */
       
    77 void CUptResults::WriteUptResultsL(const TDesC& aFileName, const TBool& aAppend, const TInt& aTestType)
       
    78 	{	
       
    79 	//create an RArray object for writing the results to csv
       
    80 
       
    81 	RArray <TInt64> testdataarray;
       
    82 	CleanupClosePushL(testdataarray); 
       
    83 	RArray <TPtrC8> initialpluginarray;
       
    84 	CleanupClosePushL(initialpluginarray);
       
    85 	
       
    86 	//create a csvgenerator class
       
    87 	CUptCsvGenerator csvgenerator;
       
    88 	csvgenerator.Open(aFileName,aAppend); 
       
    89 	
       
    90 	//call writeheader to write the relevent test column header for the csv file, 
       
    91 	csvgenerator.WriteHeader(aTestType);
       
    92 	
       
    93 	if(aTestType==0)
       
    94 		{
       
    95 		//loop over each element of the RPointerapitestobject (i.e. each of the test runs carried out)
       
    96 		__TEST_LOG("about to insert array");
       
    97 		
       
    98 		testdataarray.InsertL((iApiTest[0]->iRunConfigs.iApiId), testdataarray.Count()); 
       
    99 		testdataarray.InsertL((iApiTest[0]->iApiSize), testdataarray.Count()); 
       
   100 		testdataarray.InsertL((iApiTest[0]->iRunConfigs.iSizeOfUptData), testdataarray.Count()); //dont really need this as we already have the trace point size - check!
       
   101 		testdataarray.InsertL((iApiTest[0]->iRunConfigs.iHasContext), testdataarray.Count());
       
   102 		testdataarray.InsertL((iApiTest[0]->iRunConfigs.iHasProgramCounter), testdataarray.Count()); 
       
   103 		//test run config
       
   104 		testdataarray.InsertL((iApiTest[0]->iRunConfigs.iDoTestClassificationFiltering), testdataarray.Count()); 
       
   105 		testdataarray.InsertL((iApiTest[0]->iRunConfigs.iDoTestModuleIdFiltering), testdataarray.Count()); 
       
   106 		testdataarray.InsertL((iApiTest[0]->iRunConfigs.iDoTestClassificationFilterMatch), testdataarray.Count()); 
       
   107 		testdataarray.InsertL((iApiTest[0]->iRunConfigs.iDoTestModuleIdFilterMatch), testdataarray.Count()); 
       
   108 		testdataarray.InsertL((iApiTest[0]->iRunResults.iTraceEnabled), testdataarray.Count()); 
       
   109 		//test results
       
   110 		testdataarray.InsertL((iApiTest[0]->iMinimumExecutionTime), testdataarray.Count()); 
       
   111 		testdataarray.InsertL((iApiTest[0]->iTypicalExecutionTime), testdataarray.Count()); 
       
   112 		testdataarray.InsertL((iApiTest[0]->iRunResults.iApiStackUsage), testdataarray.Count()); 
       
   113 		testdataarray.InsertL((iApiTest[0]->iRunResults.iApiHeapUsage), testdataarray.Count()); 
       
   114 		__TEST_LOG("array inserted, about to write array");
       
   115 		
       
   116 		
       
   117 		//write the API Name to the file
       
   118 		csvgenerator.WriteApiNameL(iApiTest[0]->iRunConfigs.iApiId);
       
   119 		//call writetocsv routine to write this test run to a csv file with the name aFileName
       
   120 		csvgenerator.WriteL(testdataarray);
       
   121 		__TEST_LOG("array written");
       
   122 		
       
   123 		//	__TEST_LOG("Write");
       
   124 		///	__TEST_LOGNUM(i);
       
   125 		//	__TEST_LOGNUM(iApiTest.Count());
       
   126 
       
   127 		//call write newline to write a new line in preparation for the next test object
       
   128 		csvgenerator.WriteNewLine();
       
   129 		
       
   130 		//clear out the RArray object in preparation for the next test result object
       
   131 		testdataarray.Reset(); 
       
   132 		}
       
   133 	
       
   134 	if(aTestType==1||aTestType==2)
       
   135 		{
       
   136 		//loop over each element of the RPointeroutputplugintestobject (i.e. each of the test runs carried out)
       
   137 		__TEST_LOG("about to insert plugin text array");
       
   138 		
       
   139 		initialpluginarray.InsertL((iPluginTest[0]->iPluginName), initialpluginarray.Count());
       
   140 		initialpluginarray.InsertL(iPluginTest[0]->iPluginKey, initialpluginarray.Count());
       
   141 		initialpluginarray.InsertL(iPluginTest[0]->iPluginValue, initialpluginarray.Count());
       
   142 		initialpluginarray.InsertL(iPluginTest[0]->iTestType, initialpluginarray.Count());
       
   143 		
       
   144 		__TEST_LOG("array inserted, about to write plugin text array");
       
   145 		
       
   146 		csvgenerator.WriteL(initialpluginarray);
       
   147 		__TEST_LOG("output plugin text array written");
       
   148 		
       
   149 		__TEST_LOG("about to insert plugin number array");
       
   150 		testdataarray.InsertL((iPluginTest[0]->iDataSize), testdataarray.Count());
       
   151 		testdataarray.InsertL((iPluginTest[0]->iIteration), testdataarray.Count());
       
   152 		//testdataarray.InsertL((iOutputPluginTest[0]->iThroughput), testdataarray.Count());
       
   153 		testdataarray.InsertL((iPluginTest[0]->iLatency), testdataarray.Count()); //dont really need this as we already have the trace point size - check!
       
   154 	
       
   155 		__TEST_LOG("array inserted, about to write plugin number array");
       
   156 		
       
   157 		//call writetocsv routine to write this test run to a csv file with the name aFileName
       
   158 		csvgenerator.WriteL(testdataarray);
       
   159 		__TEST_LOG("plugin number array written");
       
   160 		
       
   161 		
       
   162 
       
   163 		//call write newline to write a new line in preparation for the next test object
       
   164 		csvgenerator.WriteNewLine();
       
   165 		
       
   166 		//clear out the RArray objects in preparation for the next test result object
       
   167 		initialpluginarray.Reset();
       
   168 		testdataarray.Reset(); 
       
   169 		}
       
   170 
       
   171 	//close the csv file and close and cleanup any heap ojects
       
   172 	csvgenerator.Close();
       
   173 	
       
   174 //	testdataarray.Close();
       
   175 //	initialpluginarray.Close();
       
   176 	CleanupStack::PopAndDestroy(&initialpluginarray);
       
   177 	CleanupStack::PopAndDestroy(&testdataarray);	
       
   178 
       
   179 
       
   180 	}
       
   181 
       
   182 /** This sanity test method is executed at the start of the test run to verify that UPT methods in
       
   183 this class are stable before any of the performance tests are carried out 
       
   184 @return KErrNone if command was prepared correctly and system wide error code otherwise.
       
   185  */
       
   186 TInt CUptResults::Test()
       
   187 	{
       
   188 	return KErrNone;
       
   189 	}
       
   190