traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_functional/src/te_configfile.cpp
changeset 0 08ec8eefde2f
child 23 26645d81f48d
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 #include "te_configfile.h"
       
     2 
       
     3 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 // All rights reserved.
       
     5 // This component and the accompanying materials are made available
       
     6 // under the terms of "Eclipse Public License v1.0"
       
     7 // which accompanies this distribution, and is available
       
     8 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     9 //
       
    10 // Initial Contributors:
       
    11 // Nokia Corporation - initial contribution.
       
    12 //
       
    13 // Contributors:
       
    14 //
       
    15 // Description:
       
    16 // Example CWrapper derived implementation
       
    17 //
       
    18 
       
    19 
       
    20 
       
    21 /**
       
    22  @file te_configfile.cpp
       
    23  @internalTechnology
       
    24 */
       
    25 #include <uloggerclient.h>
       
    26 #include <opensystemtrace.h>
       
    27 #include "te_configfile.h"
       
    28 #include "te_ostv2integsuite_defs.h"
       
    29 #include "te_dataparameters.h"
       
    30 
       
    31 using namespace Ulogger; //CA:added so can use old ulogger api
       
    32 /*******************************************************************************/
       
    33 /*********************************Public File Test***************************/
       
    34 /*******************************************************************************/
       
    35 
       
    36 TInt CPublicConfigFileWrapper::aTestCount=0;
       
    37 
       
    38 CPublicConfigFileWrapper::~CPublicConfigFileWrapper()
       
    39 /**
       
    40  * Destructor
       
    41  */
       
    42 	{
       
    43 	}
       
    44 
       
    45 CPublicConfigFileWrapper::CPublicConfigFileWrapper()
       
    46 /**
       
    47  * Constructor
       
    48  */
       
    49 	{
       
    50 	aTestCount++;
       
    51 	}
       
    52 
       
    53 
       
    54 CPublicConfigFileWrapper* CPublicConfigFileWrapper::NewLC()
       
    55 	{
       
    56 	CPublicConfigFileWrapper* self = new (ELeave)CPublicConfigFileWrapper();
       
    57 	CleanupStack::PushL(self);
       
    58 	self->ConstructL();
       
    59 	return self;
       
    60 	}
       
    61 
       
    62 CPublicConfigFileWrapper* CPublicConfigFileWrapper::NewL()
       
    63 	{
       
    64 	CPublicConfigFileWrapper* self=CPublicConfigFileWrapper::NewLC();
       
    65 	CleanupStack::Pop(); // self;
       
    66 	return self;
       
    67 	}
       
    68 
       
    69 void CPublicConfigFileWrapper::ConstructL()
       
    70 	{
       
    71 	}
       
    72 
       
    73 TAny* CPublicConfigFileWrapper::GetObject()
       
    74 	{
       
    75 	return NULL;
       
    76 	}
       
    77 
       
    78 TBool CPublicConfigFileWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
    79 					const TTEFSectionName& /*aSection*/, 
       
    80 					const TInt /*aAsyncErrorIndex*/)
       
    81 	{
       
    82 	 if (BlockResult()==EPass)
       
    83 		 {
       
    84 		//  ************** Delete the Block, the block start ****************
       
    85 		TInt Result=0;
       
    86 		RULogger logger;
       
    87 		Result=logger.Connect();
       
    88 		INFO_PRINTF2(_L("connect err %d"), Result);
       
    89 
       
    90 		/**************First get primary filter*************/
       
    91 
       
    92 		CArrayFixFlat<TUint8> *getprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
    93 		logger.GetPrimaryFiltersEnabled(*getprimfilter);//C.A. previously:logger.GetEnabledClassifications(*getprimfilter);
       
    94 		INFO_PRINTF2(_L("getprimfilter->Count() %d"), getprimfilter->Count());
       
    95 		if(getprimfilter->At(0)==(TGroupId)255&&getprimfilter->Count()==1)
       
    96 			{
       
    97 			INFO_PRINTF1(_L("Get primary filter successful, correctly picked up from public file with correct count"));
       
    98 			SetBlockResult(EPass);
       
    99 			}
       
   100 		else
       
   101 			{
       
   102 			INFO_PRINTF1(_L("Get primary filter failed, returned filter(s):"));
       
   103 			for(TInt i=0;i!=getprimfilter->Count();i++)
       
   104 				{
       
   105 				INFO_PRINTF2(_L("%d "),getprimfilter->At(i));
       
   106 				}
       
   107 			SetBlockResult(EFail);
       
   108 			}
       
   109 		/**************Now get secondary filter, if this has been successful*************/
       
   110 
       
   111 		if(BlockResult()==EPass)
       
   112 		{
       
   113 			RArray<TUint32> getsecondfilter;
       
   114 			logger.GetSecondaryFiltersEnabled(getsecondfilter);//C.A. previously:logger.GetEnabledModuleUids(getsecondfilter);
       
   115 			if(getsecondfilter[0]==(TComponentId)333&&getsecondfilter.Count()==1)
       
   116 			{
       
   117 				INFO_PRINTF1(_L("Get Secondary filter successful, correctly picked up from public file with correct count"));
       
   118 				SetBlockResult(EPass);
       
   119 
       
   120 			}
       
   121 			else
       
   122 			{
       
   123 				INFO_PRINTF1(_L("Get Secondary filter failed, returned filter(s):"));
       
   124 				for(TInt i=0;i!=getsecondfilter.Count();i++)
       
   125 				{
       
   126 					INFO_PRINTF2(_L("%d "),getsecondfilter[i]);
       
   127 				}
       
   128 				SetBlockResult(EFail);
       
   129 			}
       
   130 			/**************Now do some tracing, if this has been successful*************/
       
   131 
       
   132 			if(BlockResult()==EPass)
       
   133 			{
       
   134 				logger.Start();//C.A. previously:logger.StartOutputting();
       
   135 
       
   136 				TTraceContext attrs((TComponentId)333, (TGroupId)255, KContextId, KPc);
       
   137 				Result = OstTrace(attrs, KInitialClientFormat, KAny16);
       
   138 				if(Result==1)
       
   139 					{
       
   140 					INFO_PRINTF2(_L("Tracing successful, check outputlog PublicConfigULogger%d.utf has first trace statement, primary filter=255 and secondary filter=333"), aTestCount);
       
   141 					//if standard tracing has passed - try setting with a single GroupId
       
   142 					RArray<TUint32> setfilterarray; //C.A. added so can use old ulogger api
       
   143 					setfilterarray.Append(KDefaultComponentId); //C.A. added so can use old ulogger api
       
   144 					Result = logger.SetSecondaryFiltersEnabled(setfilterarray,ETrue);//C.A. previously:Result = logger.EnableModuleUid(KDefaultComponentId);
       
   145 					Result = logger.Restart();//C.A. previously:Result = logger.RestartOutputting();
       
   146 					TTraceContext attrs1((TGroupId)255, KContextId, KPc);
       
   147 					Result = OstTrace(attrs1, KInitialClientFormat, KAny16);
       
   148 					logger.SetSecondaryFiltersEnabled(setfilterarray,EFalse);//C.A. previously:logger.DisableModuleUid(KDefaultComponentId);
       
   149 					setfilterarray.Reset();//C.A. close array
       
   150 					}
       
   151 				logger.Stop();//C.A. previously:logger.StopOutputting();
       
   152 				if(Result==1)
       
   153 				{
       
   154 					INFO_PRINTF2(_L("Tracing successful, check outputlog PublicConfigULogger%d.utf has second trace statement, primary filter=255 and secondary filter=UID3"), aTestCount);
       
   155 					SetBlockResult(EPass);
       
   156 				}
       
   157 				else
       
   158 				{
       
   159 					INFO_PRINTF2(_L("Tracing failed, with error return %d"), Result);
       
   160 					SetBlockResult(EFail);
       
   161 				}
       
   162 			}
       
   163 
       
   164 		}
       
   165 		//  **************   Block end ****************
       
   166 		if(getprimfilter)
       
   167 			delete getprimfilter;
       
   168 		logger.Close();
       
   169 	}
       
   170 	 return ETrue;
       
   171 	}
       
   172 
       
   173 
       
   174 
       
   175 
       
   176 
       
   177 /*******************************************************************************/
       
   178 /*********************************Private File Test***************************/
       
   179 /*******************************************************************************/
       
   180 
       
   181 
       
   182 CPrivateConfigFileWrapper::~CPrivateConfigFileWrapper()
       
   183 /**
       
   184  * Destructor
       
   185  */
       
   186 	{
       
   187 	}
       
   188 
       
   189 CPrivateConfigFileWrapper::CPrivateConfigFileWrapper()
       
   190 /**
       
   191  * Constructor
       
   192  */
       
   193 	{
       
   194 	}
       
   195 
       
   196 
       
   197 CPrivateConfigFileWrapper* CPrivateConfigFileWrapper::NewLC()
       
   198 	{
       
   199 	CPrivateConfigFileWrapper* self = new (ELeave)CPrivateConfigFileWrapper();
       
   200 	CleanupStack::PushL(self);
       
   201 	self->ConstructL();
       
   202 	return self;
       
   203 	}
       
   204 
       
   205 CPrivateConfigFileWrapper* CPrivateConfigFileWrapper::NewL()
       
   206 	{
       
   207 	CPrivateConfigFileWrapper* self=CPrivateConfigFileWrapper::NewLC();
       
   208 	CleanupStack::Pop(); // self;
       
   209 	return self;
       
   210 	}
       
   211 
       
   212 void CPrivateConfigFileWrapper::ConstructL()
       
   213 	{
       
   214 	}
       
   215 
       
   216 TAny* CPrivateConfigFileWrapper::GetObject()
       
   217 	{
       
   218 	return NULL;
       
   219 	}
       
   220 TBool CPrivateConfigFileWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
   221 					const TTEFSectionName& /*aSection*/, 
       
   222 					const TInt /*aAsyncErrorIndex*/)
       
   223 	{
       
   224 	if (BlockResult()==EPass)
       
   225 	{
       
   226 		//  ************** Delete the Block, the block start ****************
       
   227 		TInt Result=0;
       
   228 		RULogger logger;
       
   229 		Result=logger.Connect();
       
   230 		INFO_PRINTF2(_L("connect err %d"), Result);
       
   231 		CClearConfig configIni;
       
   232 		configIni.Default(logger);
       
   233 
       
   234 		/**************First get primary filter*************/
       
   235 
       
   236 		CArrayFixFlat<TUint8> *getprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
   237 		logger.GetPrimaryFiltersEnabled(*getprimfilter);//C.A. previously:logger.GetEnabledClassifications(*getprimfilter);
       
   238 		if(getprimfilter->Count()>0)
       
   239 			{
       
   240 			//if((getprimfilter->At(0)==3||getprimfilter->At(1)==3)&&(getprimfilter->At(1)==13||getprimfilter->At(1)==13)&&getprimfilter->Count()==2)
       
   241 			/*NB: The above line should be reintroduced for ulogger v2 when the default ulogger config file
       
   242 			      is updated again to include the metadata default value for the SAW viewer */			
       
   243 			if(getprimfilter->At(0)==(TGroupId)3&&getprimfilter->Count()==1)	
       
   244 				{
       
   245 					INFO_PRINTF1(_L("Get primary filter successful, correctly picked up from private file with correct count"));
       
   246 					SetBlockResult(EPass);
       
   247 				}
       
   248 				else
       
   249 				{
       
   250 					INFO_PRINTF1(_L("Get primary filter failed (default uloggerconfig.ini may have changed), returned filter(s):"));
       
   251 					for(TInt i=0;i!=getprimfilter->Count();i++)
       
   252 						{
       
   253 						INFO_PRINTF2(_L("%d "),getprimfilter->At(i));
       
   254 						}
       
   255 					SetBlockResult(EFail);
       
   256 				}
       
   257 			}
       
   258 		else
       
   259 			{
       
   260 			INFO_PRINTF1(_L("Get primary filter failed, returns a zero count array, the default filters should be returned"));
       
   261 			SetBlockResult(EFail);
       
   262 			}
       
   263 
       
   264 
       
   265 
       
   266 		/**************Now get secondary filter, if this has been successful*************/
       
   267 
       
   268 		if(BlockResult()==EPass)
       
   269 		{
       
   270 			RArray<TUint32> getsecondfilter;
       
   271 			Result=logger.GetSecondaryFiltersEnabled(getsecondfilter);//C.A. previously:Result=logger.GetEnabledModuleUids(getsecondfilter);
       
   272 			if(Result==KErrNone&&getsecondfilter.Count()==0) //i.e. return empty array
       
   273 			{
       
   274 				INFO_PRINTF1(_L("Get Secondary filter successful, correctly picked up that there were no secondary filters from private config file"));
       
   275 				SetBlockResult(EPass);
       
   276 
       
   277 			}
       
   278 			else
       
   279 			{
       
   280 				INFO_PRINTF2(_L("Get Secondary filter failed and returned error %d, returned filter(s):"), Result);
       
   281 				for(TInt i=0;i!=getsecondfilter.Count();i++)
       
   282 				{
       
   283 					INFO_PRINTF2(_L("%d "),getsecondfilter[i]);
       
   284 				}
       
   285 				SetBlockResult(EFail);
       
   286 			}
       
   287 			/**************Now do some tracing, if this has been successful*************/
       
   288 
       
   289 			if(BlockResult()==EPass)
       
   290 			{
       
   291 				RArray<TUint32> setsecondfilter;//C.A.added so can use old ulogger api
       
   292 				setsecondfilter.Append(KDefaultComponentId);//C.A.added so can use old ulogger api
       
   293 				//need to set the ComponentId filter in order for the trace to be carried out
       
   294 				//this is achieved as TTraceContext with set the ComponentId by default for the user.
       
   295 				//if you want to investigate true fast, GroupId only, tracing - use BTrace
       
   296 				Result = logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue);//C.A. previously:Result = logger.EnableModuleUid(KDefaultComponentId);
       
   297 				Result = logger.Start();//C.A. previously:Result = logger.StartOutputting();
       
   298 				TTraceContext attrs((TGroupId)3, KContextId, KPc);
       
   299 				Result = OstTrace(attrs, KInitialClientFormat, KAny16);
       
   300 
       
   301 				if(Result==1)
       
   302 				{
       
   303 					INFO_PRINTF1(_L("Tracing successful, check outputlog PrivateConfigULogger.utf has trace statements only of order primary filter=3"));
       
   304 				}
       
   305 				else
       
   306 				{
       
   307 					INFO_PRINTF2(_L("Tracing failed, with error return %d"), Result);
       
   308 					SetBlockResult(EFail);
       
   309 				}
       
   310 				//reset back to the default scenario
       
   311 				Result = logger.SetSecondaryFiltersEnabled(setsecondfilter,EFalse);//C.A. previously:Result = logger.DisableModuleUid(KDefaultComponentId);
       
   312 				Result = logger.Stop();//C.A. previously:Result = logger.StopOutputting();
       
   313 				setsecondfilter.Reset();
       
   314 			}
       
   315 
       
   316 		}
       
   317 		//  **************   Block end ****************
       
   318 
       
   319 
       
   320 		if(getprimfilter)
       
   321 			delete getprimfilter;
       
   322 		logger.Close();
       
   323 	}
       
   324 	  return ETrue;
       
   325 	}
       
   326 
       
   327 
       
   328