traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_functional/src/te_advancedfiltering.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 // Example CTestStep derived implementation
       
    15 //
       
    16 
       
    17 
       
    18 
       
    19 /**
       
    20  @file te_tracecollectorclient.cpp
       
    21  @internalTechnology
       
    22 */
       
    23 #include "te_advancedfiltering.h"
       
    24 #include "te_ostv2integsuite_defs.h"
       
    25 #include "te_instrumentationpoints.h"
       
    26 #include "te_tracecontrolcmds.h"
       
    27 #include "te_advancedfilteringTraces.h"
       
    28 #include <opensystemtrace.h>
       
    29 #include <uloggerclient.h>
       
    30 
       
    31 using namespace Ulogger; //CA:added so can use old ulogger api
       
    32 #ifdef TE_UPT_TRACE_ENABLED
       
    33 _LIT(KTextvalue, "C:\\logs\\ULoggerStartFileTestLog.utf");
       
    34 #endif
       
    35 /*******************************************************************************/
       
    36 /*********************************Primary Filter Test***************************/
       
    37 /*******************************************************************************/
       
    38 
       
    39 CTCMAdvancedGroupIDFilteringWrapper::~CTCMAdvancedGroupIDFilteringWrapper()
       
    40 /**
       
    41  * Destructor
       
    42  */
       
    43 	{
       
    44 	}
       
    45 
       
    46 CTCMAdvancedGroupIDFilteringWrapper::CTCMAdvancedGroupIDFilteringWrapper()
       
    47 /**
       
    48  * Constructor
       
    49  */
       
    50 	{
       
    51 	}
       
    52 
       
    53 CTCMAdvancedGroupIDFilteringWrapper* CTCMAdvancedGroupIDFilteringWrapper::NewLC()
       
    54 	{
       
    55 	CTCMAdvancedGroupIDFilteringWrapper* self = new (ELeave)CTCMAdvancedGroupIDFilteringWrapper();
       
    56 	CleanupStack::PushL(self);
       
    57 	self->ConstructL();
       
    58 	return self;
       
    59 	}
       
    60 
       
    61 CTCMAdvancedGroupIDFilteringWrapper* CTCMAdvancedGroupIDFilteringWrapper::NewL()
       
    62 	{
       
    63 	CTCMAdvancedGroupIDFilteringWrapper* self=CTCMAdvancedGroupIDFilteringWrapper::NewLC();
       
    64 	CleanupStack::Pop(); // self;
       
    65 	return self;
       
    66 	}
       
    67 
       
    68 void CTCMAdvancedGroupIDFilteringWrapper::ConstructL()
       
    69 	{
       
    70 	}
       
    71 
       
    72 TAny* CTCMAdvancedGroupIDFilteringWrapper::GetObject()
       
    73 	{
       
    74 	return NULL;
       
    75 	}
       
    76 
       
    77 TBool CTCMAdvancedGroupIDFilteringWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
    78 					const TTEFSectionName& /*aSection*/,
       
    79 					const TInt /*aAsyncErrorIndex*/)
       
    80 	{
       
    81 	  if(BlockResult()==EPass)
       
    82 		{
       
    83 		//  ************** Delete the Block, the block start ****************
       
    84 		TBool OstStatus=EFalse;
       
    85 #ifdef TE_UPT_TRACE_ENABLED
       
    86 		EmptyFile(KTextvalue);
       
    87 		OstStatus=ETrue;
       
    88 #endif
       
    89 		TInt result=0;
       
    90 		RULogger logger;
       
    91 
       
    92 		/**************First set primary filter*************/
       
    93 
       
    94 		result=logger.Connect();
       
    95         INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
    96             if (result!=KErrNone)
       
    97             {
       
    98             INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
    99             for (TInt i=2; i<12;i++)
       
   100                {
       
   101                User::After(1000);
       
   102                result = logger.Connect();
       
   103                INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
   104                if (result==KErrNone)
       
   105                     {
       
   106                     break;
       
   107                     }
       
   108                }
       
   109             }
       
   110 		CClearConfig configIni;
       
   111 		configIni.Clear(logger);
       
   112 		INFO_PRINTF2(_L("connect err %d"), result);
       
   113 
       
   114 		INFO_PRINTF1(_L("Test setting a single primary filter with the filter, rather than an array"));
       
   115 
       
   116 		CArrayFixFlat<TUint8> *setfilterarray = new (ELeave)CArrayFixFlat<TUint8>(1); //CA:added so can use old ulogger api
       
   117 		CleanupStack::PushL(setfilterarray); //CA:added
       
   118 		TGroupId setfilter = KGroupId;
       
   119 		setfilterarray->AppendL(setfilter); //CA:added so can use old ulogger api
       
   120 		CArrayFixFlat<TUint8> *getfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
   121 		CleanupStack::PushL(getfilter); //CA:added
       
   122 		CArrayFixFlat<TUint8> *removefilterarray = new (ELeave)CArrayFixFlat<TUint8>(1); //CA:added so can use old ulogger api
       
   123 		CleanupStack::PushL(removefilterarray); //CA:added
       
   124 		TGroupId removefilter = setfilter;
       
   125 		removefilterarray->AppendL(removefilter); //CA:added so can use old ulogger api
       
   126 
       
   127 		result=logger.SetPrimaryFiltersEnabled(*setfilterarray,ETrue);//C.A. previously:Result=logger.EnableClassification(setfilter);
       
   128 
       
   129 		if(result==KErrNone)
       
   130 			INFO_PRINTF2(_L("Set single Primary filter has been set with single filter, %d, check log"), setfilter);
       
   131 		else
       
   132 			INFO_PRINTF2(_L("Set single Primary filter was not set, error returned, %d"), result);
       
   133 
       
   134 		//logger.EnableClassificationFiltering();//C.A.: already enabled by default in old ulogger
       
   135 
       
   136 		/**************Now get the GroupId filter set above************/
       
   137 
       
   138 		logger.GetPrimaryFiltersEnabled(*getfilter);//C.A.: previously:logger.GetEnabledClassifications(*getfilter);
       
   139 		INFO_PRINTF1(_L("Get Primary filter returns the following filters"));
       
   140 		for(TInt i=0;i!=getfilter->Count();i++)
       
   141 		{
       
   142 			INFO_PRINTF2(_L("get filter returns %d "),getfilter->At(i));
       
   143 		}
       
   144 		if(getfilter->At(0)==setfilter)
       
   145 		{
       
   146             result=0;
       
   147 			INFO_PRINTF1(_L("Get primary filter successful"));
       
   148 		}
       
   149 		else
       
   150 		{
       
   151 			INFO_PRINTF2(_L("Get primary filter failed.\n NB: getfilter->Count is %d"), getfilter->Count());
       
   152 			result=1;
       
   153 		}
       
   154 		getfilter->Reset();
       
   155 		/*****************Now remove the above set filter***************/
       
   156 
       
   157 		if(result==0)
       
   158 		{
       
   159 
       
   160 			INFO_PRINTF1(_L("Test disabling a single primary filter with the filter, rather than an array"));
       
   161 
       
   162 			result=logger.SetPrimaryFiltersEnabled(*removefilterarray,EFalse);//C.A previously:Result=logger.DisableClassification(removefilter);
       
   163 			INFO_PRINTF2(_L("Remove GroupId filters single filter with single filter not array, 0 if succesful: %d"), result);
       
   164 			logger.GetPrimaryFiltersEnabled(*getfilter);//CA previously:logger.GetEnabledClassifications(*getfilter);
       
   165 			if(getfilter->Count()==0&&result==KErrNone)
       
   166 			{
       
   167 				INFO_PRINTF1(_L("Remove primary filter successful"));
       
   168 				result=0;
       
   169 			}
       
   170 			else
       
   171 			{
       
   172 				if(result!=0)
       
   173 					INFO_PRINTF1(_L("Remove primary filter failed, as filter has not been set in the config file"));
       
   174 				else
       
   175 					INFO_PRINTF1(_L("Remove primary filter failed, as able to pass same filter option to RemovePrimaryFilter"));
       
   176 				result=1;
       
   177 			}
       
   178 		}
       
   179 		getfilter->Reset();
       
   180 
       
   181 		/****Now if the above steps have passed proceed to testing enable/disable primary filtering***/
       
   182 
       
   183 		if(result==1)
       
   184 			SetBlockResult(EFail);
       
   185 		else
       
   186 		{
       
   187 			INFO_PRINTF1(_L(" Testing GroupId filtering enabled/ disabled "));
       
   188 
       
   189 			//reset config file
       
   190 			configIni.Clear(logger);
       
   191 
       
   192 
       
   193 			/***********************************************************/
       
   194 			/***enable GroupId, enable GroupId filtering*/
       
   195 			/***********************************************************/
       
   196 
       
   197 			INFO_PRINTF1(_L("\n\n Enable test GroupId, enable GroupId filtering.\n Testing error returns and ensuring a trace statement IS carried out "));
       
   198 			SetBlockResult(TestGroupIdFiltering(logger, ETrue, ETrue));
       
   199 
       
   200 			/***********************************************************/
       
   201 			/***enable GroupId, disable GroupId filtering*/
       
   202 			/***********************************************************/
       
   203 
       
   204 			if(BlockResult()==EPass)
       
   205 				{
       
   206 				INFO_PRINTF1(_L("\n\n Enable test GroupId, disable GroupId filtering.\n Testing error returns and ensuring a trace statement IS carried out + lots of kernel traces "));
       
   207 				SetBlockResult(TestGroupIdFiltering(logger, ETrue, EFalse));
       
   208 				}
       
   209 
       
   210 			/***********************************************************/
       
   211 			/***disable GroupId, disable GroupId filtering*/
       
   212 			/***********************************************************/
       
   213 
       
   214 			if(BlockResult()==EPass)
       
   215 				{
       
   216 				INFO_PRINTF1(_L("\n\n Disable test GroupId, disable GroupId filtering.\n Testing error returns and ensuring a trace statement IS carried out + lots of kernel traces"));
       
   217 				SetBlockResult(TestGroupIdFiltering(logger, EFalse, EFalse));
       
   218 				}
       
   219 
       
   220 			/***********************************************************/
       
   221 			/***disable GroupId, enable GroupId filtering*/
       
   222 			/***********************************************************/
       
   223 
       
   224 			if(BlockResult()==EPass)
       
   225 				{
       
   226 				INFO_PRINTF1(_L("\n\n Disable test GroupId, enable GroupId filtering.\n Testing error returns and ensuring a trace statement IS NOT carried out "));
       
   227 				SetBlockResult(TestGroupIdFiltering(logger, EFalse, ETrue));
       
   228 				}
       
   229 
       
   230 		}
       
   231 
       
   232 		if (BlockResult()==EPass&&OstStatus)
       
   233 			{
       
   234 #ifdef TE_UPT_TRACE_ENABLED
       
   235 			if(!ReadFromLogFile(KTextvalue))
       
   236 				{
       
   237 				TInt err=CompareTraces();
       
   238 				if(err)
       
   239 					{
       
   240 					INFO_PRINTF2(_L("ERROR: Error when comparing traces, error %i"), err);
       
   241 					SetBlockResult(EFail);
       
   242 					}
       
   243 				else
       
   244 					SetBlockResult(EPass);
       
   245 				}
       
   246 #endif
       
   247 			}
       
   248 
       
   249 
       
   250 		//  **************   Block end ****************
       
   251 
       
   252 		configIni.Clear(logger);
       
   253 		logger.Close();
       
   254 		CleanupStack::Pop(3);
       
   255 		if(getfilter)
       
   256 			delete getfilter;
       
   257 		if(setfilterarray)
       
   258 			delete setfilterarray;
       
   259 		if(removefilterarray)
       
   260 			delete removefilterarray;
       
   261 		}
       
   262 	  return ETrue;
       
   263 	}
       
   264 
       
   265 
       
   266 TVerdict CTCMAdvancedGroupIDFilteringWrapper::TestGroupIdFiltering(RULogger& aLogger, const TBool aFilter, const TBool aFiltering)
       
   267 /**
       
   268  * @return - TVerdict code
       
   269  * standard function to test error returns and GroupId filtering
       
   270  */
       
   271 	{
       
   272  	TInt Result = 0;
       
   273 	CArrayFixFlat<TUint8> *setfilterarray = new (ELeave)CArrayFixFlat<TUint8>(256); //CA:added so can use old ulogger api
       
   274 	CleanupStack::PushL(setfilterarray); //CA:added
       
   275 	setfilterarray->AppendL(KGroupId); //CA:added so can use old ulogger api
       
   276 	//enable/disable filter
       
   277 	aLogger.SetPrimaryFiltersEnabled(*setfilterarray,aFilter);
       
   278 
       
   279 	//C.A. previously this but only need line above:
       
   280 /*	if(aFilter)
       
   281 		aLogger.EnableClassification(KGroupId);
       
   282 	else
       
   283 		aLogger.DisableClassification(KGroupId);*/
       
   284 
       
   285 
       
   286 	//enable/disabled filtering
       
   287 	if(aFiltering){}
       
   288 		//Result = aLogger.EnableClassificationFiltering();//CA:enabled by default
       
   289 	else //enable all GroupIds between 0 and 255
       
   290 		//C.A. previously just :Result = aLogger.DisableClassificationFiltering();
       
   291 		{
       
   292 		TInt i;
       
   293 		setfilterarray->Delete(0,setfilterarray->Count());
       
   294 		for (i=0;i<=255;i++)
       
   295 			{
       
   296 			setfilterarray->AppendL((TUint8)i);
       
   297 			}
       
   298 		Result = aLogger.SetPrimaryFiltersEnabled(*setfilterarray,ETrue);
       
   299 		}
       
   300 	if(Result==KErrNone)
       
   301 		SetBlockResult(EPass);
       
   302 	else
       
   303 		{
       
   304 		INFO_PRINTF2(_L("Enable/disable GroupId filtering test FAILED, returning error %d"), Result);
       
   305 		SetBlockResult(EFail);
       
   306 		}
       
   307 
       
   308 	if(BlockResult()==EPass)
       
   309 		{
       
   310 		INFO_PRINTF1(_L("Enable/disable GroupId filtering a second time to ensure correct error return"));
       
   311 		//enable/disable filtering again
       
   312 		if(aFiltering){}
       
   313 			//Result = aLogger.EnableClassificationFiltering();//CA:enabled by default
       
   314 		else //enable all GroupIds between 0 and 255
       
   315 			//C.A. previously just :Result = aLogger.DisableClassificationFiltering();
       
   316 			{
       
   317 			//setfilterarray should not have changed i.e still contains all filters between 0 and 255
       
   318 			Result = aLogger.SetPrimaryFiltersEnabled(*setfilterarray,ETrue);
       
   319 			}
       
   320 		if(Result==KErrNone)
       
   321 			SetBlockResult(EPass);
       
   322 		else
       
   323 			{
       
   324 			INFO_PRINTF2(_L("Duplicate enable/disable GroupId filtering test FAILED, returning error %d"), Result);
       
   325 			SetBlockResult(EFail);
       
   326 			}
       
   327 		}
       
   328 	if(BlockResult()==EPass)
       
   329 		{
       
   330 		//initialise filtering enabled boolean
       
   331 //		TBool enabled = EFalse;
       
   332 		INFO_PRINTF1(_L("Check IsClassificationFilteringEnabled() returns correct boolean accordingly"));
       
   333 //		CA: filtering is always enabled and besides, can't check with this api
       
   334 //		aLogger.IsClassificationFilteringEnabled(enabled);
       
   335 //		if(enabled==aFiltering)
       
   336 //			SetBlockResult(EPass);
       
   337 //		else
       
   338 //			{
       
   339 //			INFO_PRINTF2(_L("IsClassificationFilteringEnabled test FAILED, returning bool %d"), enabled);
       
   340 //			SetBlockResult(EFail);
       
   341 //			}
       
   342 		}
       
   343 	if(BlockResult()==EPass)
       
   344 		{
       
   345 		INFO_PRINTF1(_L("Now call a trace statement to confirm correct full implementation"));
       
   346 		CUptULogger loggerCommand;
       
   347 		Result=loggerCommand.StartFileL(aLogger, aFiltering, ETrue, aFilter, ETrue);
       
   348 		if(Result==KErrNone)
       
   349 			SetBlockResult(EPass);
       
   350 		else
       
   351 			{
       
   352 			INFO_PRINTF2(_L("Ulogger didnt start-> FAILED, returning error %d"), Result);
       
   353 			SetBlockResult(EFail);
       
   354 			}
       
   355 		if(BlockResult()==EPass)
       
   356 			{
       
   357 			//initialise boolean return from trace call
       
   358 			TBool ret = EFalse;
       
   359 			//create a trace
       
   360 			//need to change KPcNotIncluded to KPc so program counter can be included in tests
       
   361 			TTraceContext testtrace(KComponentId, KGroupId, KContextId, KPcNotIncluded);
       
   362 			ret = OstTrace(testtrace, KTraceId);
       
   363 			OstTrace0(TEST_GROUP, OstTesting, "EOstTraceDef0" ) ;
       
   364 			loggerCommand.Stop(aLogger);
       
   365 			TBool OstStatus=0;
       
   366 #ifdef TE_UPT_TRACE_ENABLED
       
   367 			OstStatus = 1;
       
   368 			INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
   369 #else
       
   370 			OstStatus = 0;
       
   371 			INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
   372 #endif // trace enabled
       
   373 			if(ret&&OstStatus)
       
   374 				{
       
   375 				if((aFilter&&aFiltering)||(aFilter&&!aFiltering)||(!aFilter&&!aFiltering))
       
   376 					{
       
   377 					//create trace information object
       
   378 
       
   379 					SetBlockResult(EPass);
       
   380 					//need to change KPcNotIncluded to KPc so program counter can be included in tests
       
   381 					StoreTraceInfo(EFalse,(TUPTApiUsed)0,KComponentId, KGroupId,KContextId, KPcNotIncluded);
       
   382 					}
       
   383 				else
       
   384 					{
       
   385 					INFO_PRINTF2(_L("trace call test FAILED, returning bool %d"), ret);
       
   386 					SetBlockResult(EFail);
       
   387 					}
       
   388 				}
       
   389 			else if(!ret)
       
   390 				{
       
   391 				if(!OstStatus||(!aFilter&&aFiltering))
       
   392 					SetBlockResult(EPass);
       
   393 				else
       
   394 					{
       
   395 					INFO_PRINTF2(_L("trace call test FAILED, returning bool %d"), ret);
       
   396 					SetBlockResult(EFail);
       
   397 					}
       
   398 				}
       
   399 			else
       
   400 				{
       
   401 				INFO_PRINTF2(_L("trace call test FAILED, returning bool %d"), ret);
       
   402 				SetBlockResult(EFail);
       
   403 				}
       
   404 			}
       
   405 
       
   406 		}
       
   407 	CleanupStack::Pop(); //setfilterarray
       
   408 	if(setfilterarray)
       
   409 		delete setfilterarray;
       
   410 		return BlockResult();
       
   411 	}
       
   412 
       
   413 
       
   414 
       
   415 /*******************************************************************************/
       
   416 /*********************************Secondary Filter Test***************************/
       
   417 /*******************************************************************************/
       
   418 
       
   419 
       
   420 CTCMAdvancedComponentIDFilteringWrapper::~CTCMAdvancedComponentIDFilteringWrapper()
       
   421 /**
       
   422  * Destructor
       
   423  */
       
   424 	{
       
   425 	}
       
   426 
       
   427 CTCMAdvancedComponentIDFilteringWrapper::CTCMAdvancedComponentIDFilteringWrapper()
       
   428 /**
       
   429  * Constructor
       
   430  */
       
   431 	{
       
   432 	}
       
   433 
       
   434 CTCMAdvancedComponentIDFilteringWrapper* CTCMAdvancedComponentIDFilteringWrapper::NewLC()
       
   435 	{
       
   436 	CTCMAdvancedComponentIDFilteringWrapper* self = new (ELeave)CTCMAdvancedComponentIDFilteringWrapper();
       
   437 	CleanupStack::PushL(self);
       
   438 	self->ConstructL();
       
   439 	return self;
       
   440 	}
       
   441 
       
   442 CTCMAdvancedComponentIDFilteringWrapper* CTCMAdvancedComponentIDFilteringWrapper::NewL()
       
   443 	{
       
   444 	CTCMAdvancedComponentIDFilteringWrapper* self=CTCMAdvancedComponentIDFilteringWrapper::NewLC();
       
   445 	CleanupStack::Pop(); // self;
       
   446 	return self;
       
   447 	}
       
   448 
       
   449 void CTCMAdvancedComponentIDFilteringWrapper::ConstructL()
       
   450 	{
       
   451 	}
       
   452 
       
   453 TAny* CTCMAdvancedComponentIDFilteringWrapper::GetObject()
       
   454 	{
       
   455 	return NULL;
       
   456 	}
       
   457 
       
   458 TBool CTCMAdvancedComponentIDFilteringWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
   459 					const TTEFSectionName& /*aSection*/,
       
   460 					const TInt /*aAsyncErrorIndex*/)
       
   461 	{
       
   462 	  if (BlockResult()==EPass)
       
   463 		{
       
   464 		//  ************** Delete the Block, the block start ****************
       
   465 		TBool OstStatus=EFalse;
       
   466 #ifdef TE_UPT_TRACE_ENABLED
       
   467 		EmptyFile(KTextvalue);
       
   468 		OstStatus=ETrue;
       
   469 #endif
       
   470 		TInt result=0;
       
   471 		RULogger logger;
       
   472 		TComponentId setfilter = KComponentId;
       
   473 		RArray<TUint32> dupfilter;
       
   474 		RArray<TUint32> getfilter;
       
   475 		RArray<TUint32> setfilterarray,removefilterarray; //CA added for old ulogger api
       
   476 		setfilterarray.Append(setfilter); //CA added for old ulogger api
       
   477 		TComponentId removefilter=setfilter;
       
   478 		removefilterarray.Append(removefilter);
       
   479 	//	removefilter=32; //uncomment to negative test the remove filter option
       
   480 
       
   481 		/**************First set Secondary filter*************/
       
   482 
       
   483 		result=logger.Connect();
       
   484         INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
   485             if (result!=KErrNone)
       
   486             {
       
   487             INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
   488             for (TInt i=2; i<12;i++)
       
   489                {
       
   490                User::After(1000);
       
   491                result = logger.Connect();
       
   492                INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
   493                if (result==KErrNone)
       
   494                     {
       
   495                     break;
       
   496                     }
       
   497                }
       
   498             }
       
   499 		CClearConfig configIni;
       
   500 		configIni.Clear(logger);
       
   501 		result = logger.SetSecondaryFiltersEnabled(setfilterarray,ETrue);//CA previously:Result = logger.EnableModuleUid(setfilter);
       
   502 		INFO_PRINTF2(_L("Setting single Secondary filter with filter rather than array has been set with single filter, %d, check log"), setfilter);
       
   503 		INFO_PRINTF2(_L("code: %d"), result);
       
   504 
       
   505 
       
   506 		/**************Now get the Secondary filter set above************/
       
   507 
       
   508 		result = logger.GetSecondaryFiltersEnabled(getfilter);//CA previously:Result = logger.GetEnabledModuleUids(getfilter);
       
   509 		INFO_PRINTF1(_L("Get Secondary filter returns the following filters"));
       
   510 		INFO_PRINTF2(_L("code: %d"), result);
       
   511 		for(TInt i=0;i!=getfilter.Count();i++)
       
   512 		{
       
   513 			INFO_PRINTF2(_L("%d "),getfilter[i]);
       
   514 		}
       
   515 		if(getfilter[0]==setfilter)
       
   516 		{
       
   517 			result=0;
       
   518 			INFO_PRINTF1(_L("Get single Secondary filter successful"));
       
   519 		}
       
   520 		else
       
   521 		{
       
   522 			INFO_PRINTF2(_L("Get Secondary filter failed. \n NB: getfilter.Count = %d"), getfilter.Count());
       
   523 			result=1;
       
   524 		}
       
   525 		for(TInt i=0;i!=getfilter.Count();)//i++)
       
   526 		{
       
   527 			getfilter.Remove(0);
       
   528 		}
       
   529 
       
   530 		/*****************Now remove the above set filter***************/
       
   531 
       
   532 		if(result==0)
       
   533 		{
       
   534 			result=logger.SetSecondaryFiltersEnabled(removefilterarray,EFalse);//CA previously:Result=logger.DisableModuleUid(removefilter);
       
   535 			INFO_PRINTF2(_L("Remove Module Uid filters single filter with single filter rather than array, 0 if succesful, -1 if failed: %d"), result);//logger.RemoveSingleSecondary);
       
   536 			logger.GetSecondaryFiltersEnabled(getfilter);//CA previously:logger.GetEnabledModuleUids(getfilter);
       
   537 			if(getfilter.Count()==0)
       
   538 			{
       
   539 				INFO_PRINTF1(_L("Remove ComponentId filter successful"));
       
   540 				result=0;
       
   541 			}
       
   542 			else
       
   543 			{
       
   544 				if(result!=0)
       
   545 					INFO_PRINTF1(_L("Remove ComponentId filter failed, as filter has not been set in the config file"));
       
   546 				else
       
   547 					INFO_PRINTF1(_L("Remove ComponentId filter failed, as able to pass same filter option to RemoveSecondaryFilter"));
       
   548 				result=1;
       
   549 			}
       
   550 		}
       
   551 
       
   552 		/****Now if the above steps have passed proceed to testing enable/disable ComponentId filtering***/
       
   553 
       
   554 		if(result==1)
       
   555 			SetBlockResult(EFail);
       
   556 		else
       
   557 			{
       
   558 			INFO_PRINTF1(_L(" Testing ComponentId filtering enabled/ disabled "));
       
   559 
       
   560 			//reset config file
       
   561 			configIni.Clear(logger);
       
   562 
       
   563 
       
   564 			/***********************************************************/
       
   565 			/***enable ComponentID, enable ComponentID filtering*/
       
   566 			/***********************************************************/
       
   567 
       
   568 			INFO_PRINTF1(_L("\n\n Enable test ComponentID, enable ComponentID filtering.\n Testing error returns and ensuring a trace statement IS carried out "));
       
   569 			SetBlockResult(TestComponentIdFiltering(logger, ETrue, ETrue));
       
   570 
       
   571 			/***********************************************************/
       
   572 			/***enable ComponentId, disable ComponentId filtering*/
       
   573 			/***********************************************************/
       
   574 
       
   575 			if(BlockResult()==EPass)
       
   576 				{
       
   577 				INFO_PRINTF1(_L("\n\n Enable test ComponentId, disable ComponentId filtering.\n Testing error returns and ensuring a trace statement IS carried out "));
       
   578 				SetBlockResult(TestComponentIdFiltering(logger, ETrue, EFalse));
       
   579 				}
       
   580 
       
   581 			/***********************************************************/
       
   582 			/***disable ComponentId, disable ComponentId filtering*/
       
   583 			/***********************************************************/
       
   584 
       
   585 			if(BlockResult()==EPass)
       
   586 				{
       
   587 				INFO_PRINTF1(_L("\n\n Disable test ComponentId, disable ComponentId filtering.\n Testing error returns and ensuring a trace statement IS carried out "));
       
   588 				SetBlockResult(TestComponentIdFiltering(logger, EFalse, EFalse));
       
   589 				}
       
   590 
       
   591 			/***********************************************************/
       
   592 			/***disable ComponentId, enable ComponentId filtering*/
       
   593 			/***********************************************************/
       
   594 
       
   595 			if(BlockResult()==EPass)
       
   596 				{
       
   597 				INFO_PRINTF1(_L("\n\n Disable test ComponentId, enable ComponentId filtering.\n Testing error returns and ensuring a trace statement IS NOT carried out "));
       
   598 				SetBlockResult(TestComponentIdFiltering(logger, EFalse, ETrue));
       
   599 				}
       
   600 			}
       
   601 
       
   602 		if (BlockResult()==EPass&&OstStatus)
       
   603 			{
       
   604 			if (BlockResult()==EPass)
       
   605 				{
       
   606 #ifdef TE_UPT_TRACE_ENABLED
       
   607 				if(!ReadFromLogFile(KTextvalue))
       
   608 					{
       
   609 					TInt err=CompareTraces();
       
   610 					if(err)
       
   611 						{
       
   612 						INFO_PRINTF2(_L("ERROR: Error when comparing traces, error %i"), err);
       
   613 						SetBlockResult(EFail);
       
   614 						}
       
   615 					else
       
   616 						SetBlockResult(EPass);
       
   617 					}
       
   618 #endif
       
   619 				}
       
   620 			}
       
   621 
       
   622 		//  **************   Block end ****************
       
   623 
       
   624 		configIni.Clear(logger);
       
   625 		logger.Close();
       
   626 		}
       
   627 	  return ETrue;
       
   628 	}
       
   629 
       
   630 
       
   631 
       
   632 TVerdict CTCMAdvancedComponentIDFilteringWrapper::TestComponentIdFiltering(RULogger& aLogger, const TBool aFilter, const TBool aFiltering)
       
   633 /**
       
   634  * @return - TVerdict code
       
   635  * standard function to test error returns and ComponentId filtering
       
   636  */
       
   637 	{
       
   638 	RArray<TUint32> setfilterarray; //CA added for old ulogger api
       
   639 	setfilterarray.Append(KComponentId); //CA added for old ulogger api
       
   640 	TInt Result = 0;
       
   641 
       
   642 	//enable/disable filter
       
   643 	aLogger.SetSecondaryFiltersEnabled(setfilterarray,aFilter);
       
   644 
       
   645 //	CA previously:
       
   646 /*	if(aFilter)
       
   647 		aLogger.EnableModuleUid(KComponentId);
       
   648 	else
       
   649 		aLogger.DisableModuleUid(KComponentId);*/
       
   650 
       
   651 	//enable/disabled filtering
       
   652 	Result = aLogger.SetSecondaryFilteringEnabled(aFiltering);
       
   653 //	CA previously:
       
   654 /*	if(aFiltering)
       
   655 		Result = aLogger.EnableModuleUidFiltering();
       
   656 	else
       
   657 		Result = aLogger.DisableModuleUidFiltering();*/
       
   658 
       
   659 	if(Result==KErrNone)
       
   660 		SetBlockResult(EPass);
       
   661 	else
       
   662 		{
       
   663 		INFO_PRINTF2(_L("Enable/disable ComponentId filtering test FAILED, returning error %d"), Result);
       
   664 		SetBlockResult(EFail);
       
   665 		}
       
   666 
       
   667 	if(BlockResult()==EPass)
       
   668 		{
       
   669 		INFO_PRINTF1(_L("Enable/disable ComponentId filtering a second time to ensure correct error return"));
       
   670 		//enable/disable filtering again
       
   671 		Result = aLogger.SetSecondaryFilteringEnabled(aFiltering);
       
   672 		//	CA previously:
       
   673 		/*	if(aFiltering)
       
   674 				Result = aLogger.EnableModuleUidFiltering();
       
   675 			else
       
   676 				Result = aLogger.DisableModuleUidFiltering();*/
       
   677 		if(Result==KErrNone)
       
   678 			SetBlockResult(EPass);
       
   679 		else
       
   680 			{
       
   681 			INFO_PRINTF2(_L("Duplicate enable/disable ComponentId filtering test FAILED, returning error %d"), Result);
       
   682 			SetBlockResult(EFail);
       
   683 			}
       
   684 		}
       
   685 
       
   686 	if(BlockResult()==EPass)
       
   687 		{
       
   688 		//initialise filtering enabled boolean
       
   689 		TBool enabled = EFalse;
       
   690 		INFO_PRINTF1(_L("Check IsModuleUidFilteringEnabled() returns correct boolean accordingly"));
       
   691 		aLogger.GetSecondaryFilteringEnabled(enabled);//CA previously:aLogger.IsModuleUidFilteringEnabled(enabled);
       
   692 		if(enabled==aFiltering)
       
   693 			SetBlockResult(EPass);
       
   694 		else
       
   695 			{
       
   696 			INFO_PRINTF2(_L("IsModuleUidFilteringEnabled test FAILED, returning bool %d"), enabled);
       
   697 			SetBlockResult(EFail);
       
   698 			}
       
   699 		}
       
   700 
       
   701 	if(BlockResult()==EPass)
       
   702 		{
       
   703 		CUptULogger loggerCommand;
       
   704 		INFO_PRINTF1(_L("Now call a trace statement to confirm correct full implementation with classification correctly enabled"));
       
   705 		Result=loggerCommand.StartFileL(aLogger, ETrue, aFiltering, ETrue, aFilter);
       
   706 		if(Result==KErrNone)
       
   707 			SetBlockResult(EPass);
       
   708 		else
       
   709 			{
       
   710 			INFO_PRINTF2(_L("Ulogger didnt start-> FAILED, returning error %d"), Result);
       
   711 			SetBlockResult(EFail);
       
   712 			}
       
   713 			{
       
   714             TBool OstStatus=0;
       
   715 #ifdef TE_UPT_TRACE_ENABLED
       
   716             OstStatus = 1;
       
   717             INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
   718 #else
       
   719             OstStatus = 0;
       
   720             INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
   721 #endif // trace enabled			
       
   722 			//initialise boolean return from trace call
       
   723 			TBool ret = EFalse;
       
   724 			//create a trace
       
   725 			//need to change KPcNotIncluded to KPc so program counter can be included in tests
       
   726 			TTraceContext testtrace(KComponentId, KGroupId, KContextId, KPcNotIncluded);
       
   727 			ret = OstTrace(testtrace, KTraceId);
       
   728 	         if(ret&&OstStatus)
       
   729 	                {
       
   730 	                if((aFilter&&aFiltering)||(aFilter&&!aFiltering)||(!aFilter&&!aFiltering))
       
   731 	                    {
       
   732 	                    SetBlockResult(EPass);
       
   733 	                    //need to change KPcNotIncluded to KPc so program counter can be included in tests
       
   734 	                    StoreTraceInfo(EFalse,(TUPTApiUsed)0,KComponentId, KGroupId,KContextId, KPcNotIncluded);
       
   735 	                    }
       
   736 	                else
       
   737 	                    {
       
   738 	                    INFO_PRINTF2(_L("trace call test FAILED, returning bool %d"), ret);
       
   739 	                    SetBlockResult(EFail);
       
   740 	                    }
       
   741 	                }
       
   742 	            else if(!ret)
       
   743 	                {
       
   744 	                if(!OstStatus||(!aFilter&&aFiltering))
       
   745 	                    SetBlockResult(EPass);
       
   746 	                else
       
   747 	                    {
       
   748 	                    INFO_PRINTF2(_L("trace call test FAILED, returning bool %d"), ret);
       
   749 	                    SetBlockResult(EFail);
       
   750 	                    }
       
   751 	                }
       
   752 	            else
       
   753 	                {
       
   754 	                INFO_PRINTF2(_L("trace call test FAILED, returning bool %d"), ret);
       
   755 	                SetBlockResult(EFail);
       
   756 	                }
       
   757 			
       
   758 	        //Do the same for a couple of ostv1 derived macros
       
   759             //initialise return from trace call
       
   760             TInt macroret = KErrNone;
       
   761             //create a trace
       
   762             //need to change KPcNotIncluded to KPc so program counter can be included in tests
       
   763             TInt tracetag=0;
       
   764             iApiRunConfig.iDoStack=EFalse;
       
   765             iApiRunConfig.iDoStack=EFalse;
       
   766             for(tracetag=EOstTraceDef0; ((macroret==KErrNone)&&(tracetag!=EOstTraceExt5+1)); tracetag++)
       
   767                 {
       
   768                 iApiRunConfig.iApiId = tracetag;
       
   769                 macroret = 1;
       
   770                 TApiRunResults apiRunResults;
       
   771                 TRunConfigurer::Init(apiRunResults);
       
   772                 macroret = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
   773                 INFO_PRINTF3(_L("Ost macro %d has executed with error %d"), tracetag, macroret);                
       
   774                 
       
   775                 //if tracing is enabled, store the information that should have been
       
   776                 //traced to compare later
       
   777                 if(OstStatus)
       
   778                     {
       
   779                     if((aFilter&&aFiltering)||(aFilter&&!aFiltering)||(!aFilter&&!aFiltering))
       
   780                         {
       
   781                         SetBlockResult(EPass);
       
   782                         //need to change KPcNotIncluded to KPc so program counter can be included in tests
       
   783                         StoreTraceInfo(ETrue,(TUPTApiUsed)tracetag,0, 0,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
   784                         }
       
   785                     }
       
   786                 }
       
   787             
       
   788             //stop outputting trace
       
   789 			loggerCommand.Stop(aLogger);
       
   790 			if(BlockResult()==EPass)
       
   791 				{
       
   792 				INFO_PRINTF1(_L("Now call a trace statement to confirm correct full implementation with classification not configured"));
       
   793 				Result=loggerCommand.StartFileL(aLogger, ETrue, aFiltering, EFalse, aFilter);
       
   794 				if(Result==KErrNone)
       
   795 					SetBlockResult(EPass);
       
   796 				else
       
   797 					{
       
   798 					INFO_PRINTF2(_L("Ulogger didnt start-> FAILED, returning error %d"), Result);
       
   799 					SetBlockResult(EFail);
       
   800 					}
       
   801 				if(BlockResult()==EPass)
       
   802 					{
       
   803 					//call a trace that should not be output
       
   804 					ret = OstTrace(testtrace, KTraceId);
       
   805 					loggerCommand.Stop(aLogger);
       
   806 					INFO_PRINTF2(_L("Trace call returns a value of %d"), ret);
       
   807 
       
   808 					if(!ret)
       
   809 						SetBlockResult(EPass);
       
   810 					else
       
   811 						{
       
   812 						INFO_PRINTF2(_L("trace call test FAILED as trace carried out without requisite classification, returning bool %d"), ret);
       
   813 						SetBlockResult(EFail);
       
   814 						}
       
   815 					}
       
   816 				}
       
   817 			}
       
   818 
       
   819 		}
       
   820 
       
   821 	return BlockResult();
       
   822 	}