traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_functional/src/te_tracecollectorclient.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_tracecollectorclient.h"
       
    24 #include "te_ostv2integsuite_defs.h"
       
    25 
       
    26 
       
    27 using namespace Ulogger; //CA:added so can use old ulogger api
       
    28 /*******************************************************************************/
       
    29 /*********************************Primary Filter Test***************************/
       
    30 /*******************************************************************************/
       
    31 _LIT(KTextsetting, "output_path");
       
    32 
       
    33 CTCMGroupIDFilteringWrapper::~CTCMGroupIDFilteringWrapper()
       
    34 /**
       
    35  * Destructor
       
    36  */
       
    37 	{
       
    38 	}
       
    39 
       
    40 CTCMGroupIDFilteringWrapper::CTCMGroupIDFilteringWrapper()
       
    41 /**
       
    42  * Constructor
       
    43  */
       
    44 	{
       
    45 	}
       
    46 
       
    47 
       
    48 CTCMGroupIDFilteringWrapper* CTCMGroupIDFilteringWrapper::NewLC()
       
    49 	{
       
    50 	CTCMGroupIDFilteringWrapper* self = new (ELeave)CTCMGroupIDFilteringWrapper();
       
    51 	CleanupStack::PushL(self);
       
    52 	self->ConstructL();
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 CTCMGroupIDFilteringWrapper* CTCMGroupIDFilteringWrapper::NewL()
       
    57 	{
       
    58 	CTCMGroupIDFilteringWrapper* self=CTCMGroupIDFilteringWrapper::NewLC();
       
    59 	CleanupStack::Pop(); // self;
       
    60 	return self;
       
    61 	}
       
    62 
       
    63 void CTCMGroupIDFilteringWrapper::ConstructL()
       
    64 	{
       
    65 	}
       
    66 
       
    67 TAny* CTCMGroupIDFilteringWrapper::GetObject()
       
    68 	{
       
    69 	return NULL;
       
    70 	}
       
    71 TBool CTCMGroupIDFilteringWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
    72 					const TTEFSectionName& /*aSection*/, 
       
    73 					const TInt /*aAsyncErrorIndex*/)
       
    74 	{
       
    75 	  if (BlockResult()==EPass)
       
    76 		{
       
    77 		//  ************** Delete the Block, the block start ****************
       
    78 
       
    79 		TInt result=0;
       
    80 		RULogger logger;
       
    81 		CArrayFixFlat<TUint8> *setfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
    82 		setfilter->AppendL(KGroupId);
       
    83 		CArrayFixFlat<TUint8> *getfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
    84 		CArrayFixFlat<TUint8> *removefilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
    85 		removefilter->AppendL(setfilter->At(0));
       
    86 
       
    87 		/**************First set primary filter*************/
       
    88 
       
    89 		result = logger.Connect();
       
    90 		INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
    91 		 	if (result!=KErrNone)
       
    92  		    {
       
    93             INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
    94             for (TInt i=2; i<12;i++)
       
    95                {
       
    96                User::After(1000);
       
    97                result = logger.Connect();
       
    98                INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
    99                if (result==KErrNone)
       
   100                     {
       
   101                     break;
       
   102                     }
       
   103                }
       
   104  		    }
       
   105 		CClearConfig configIni;
       
   106 		configIni.Clear(logger);
       
   107 		INFO_PRINTF2(_L("connect err %d"), result);
       
   108 		result=logger.SetPrimaryFiltersEnabled(*setfilter,ETrue);//C.A. previously:result=logger.EnableClassifications(*setfilter);
       
   109 
       
   110 		if(result==KErrNone)
       
   111 			INFO_PRINTF2(_L("Primary filter has been set with single filter, %d, check log"), setfilter->At(0));
       
   112 		else
       
   113 			INFO_PRINTF2(_L("Primary filter was not set, error returned, %d"), result);
       
   114 
       
   115 		/**************Now get the GroupId filter set above************/
       
   116 
       
   117 		logger.GetPrimaryFiltersEnabled(*getfilter);//C.A. previously:logger.GetEnabledClassifications(*getfilter);
       
   118 		INFO_PRINTF1(_L("Get Primary filter returns the following filters"));
       
   119 		for(TInt i=0;i!=getfilter->Count();i++)
       
   120 		{
       
   121 			INFO_PRINTF2(_L("get filter returns %d "),getfilter->At(i));
       
   122 		}
       
   123 		if(getfilter->At(0)==setfilter->At(0))
       
   124 		{
       
   125 			result=0;
       
   126 			INFO_PRINTF1(_L("Get primary filter successful"));
       
   127 		}
       
   128 		else
       
   129 		{
       
   130 			INFO_PRINTF1(_L("Get primary filter failed"));
       
   131 			result=1;
       
   132 		}
       
   133 		getfilter->Reset();
       
   134 		/*****************Now remove the above set filter***************/
       
   135 
       
   136 		if(result==0)
       
   137 		{
       
   138 			result=logger.SetPrimaryFiltersEnabled(*removefilter,EFalse);//C.A. previously:result=logger.DisableClassifications(*removefilter);
       
   139 			INFO_PRINTF2(_L("Remove GroupId filters single filter, 0 if succesful: %d"), result);
       
   140 			logger.GetPrimaryFiltersEnabled(*getfilter);//C.A. previously:logger.GetEnabledClassifications(*getfilter);
       
   141 
       
   142 			if(getfilter->Count()==0&&result==KErrNone)
       
   143 			{
       
   144 				INFO_PRINTF1(_L("Remove primary filter successful"));
       
   145 				result=0;
       
   146 			}
       
   147 			else
       
   148 			{
       
   149 				if(result!=KErrNone)
       
   150 					INFO_PRINTF1(_L("Remove primary filter failed, as filter has not been set in the config file"));
       
   151 				else
       
   152 					INFO_PRINTF1(_L("Remove primary filter failed, as able to pass same filter option to RemovePrimaryFilter"));
       
   153 				result=1;
       
   154 			}
       
   155 		}
       
   156 		getfilter->Reset();
       
   157 
       
   158 		/****Now if the above steps have passed proceed to testing multiple filters***/
       
   159 
       
   160 		if(result==1)
       
   161 			SetBlockResult(EFail);
       
   162 		else
       
   163 		{
       
   164 			CArrayFixFlat<TUint8> *setfilters = new (ELeave)CArrayFixFlat<TUint8>(10);
       
   165 			CArrayFixFlat<TUint8> *getfilters = new (ELeave)CArrayFixFlat<TUint8>(10);
       
   166 			for(TInt i=0;i!=KMaxNumberOfGroupIds;i++)
       
   167 			{
       
   168 				setfilters->AppendL((TUint8)(i));
       
   169 			}
       
   170 
       
   171 			/**************First set  multiple primary filter*************/
       
   172 
       
   173 			result=logger.SetPrimaryFiltersEnabled(*setfilters,ETrue);//C.A. previously:result=logger.EnableClassifications(*setfilters);
       
   174 			if(result==KErrNone)
       
   175 				INFO_PRINTF1(_L("Primary filter has been set with multiple filters,from 0 to 255"));
       
   176 			else
       
   177 				INFO_PRINTF2(_L("Multiple primary filters have not been set succesfully, error code %d"), result);
       
   178 
       
   179 			/**************Now get the GroupId filter set above************/
       
   180 			result = logger.Connect();
       
   181 
       
   182 			INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
   183 		 	if (result!=KErrNone)
       
   184 		 	    {
       
   185      			INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
   186             	for (TInt i=2; i<12;i++)
       
   187                    {
       
   188                    User::After(1000);
       
   189                    result = logger.Connect();
       
   190                    INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
   191                    if (result==KErrNone)
       
   192 						{
       
   193                        	break;
       
   194 						}
       
   195                    }
       
   196 		 	    }
       
   197 
       
   198 			logger.GetPrimaryFiltersEnabled(*getfilters);//C.A. previously:logger.GetEnabledClassifications(*getfilters);
       
   199 			if(getfilters->Count()==setfilters->Count())
       
   200 				INFO_PRINTF1(_L("setfilter and getfilter have the same count"));
       
   201 			else
       
   202 			{
       
   203 				INFO_PRINTF1(_L("setfilter and getfilter have different counts"));
       
   204 				INFO_PRINTF2(_L("setfilter has %d"), setfilters->Count());
       
   205 				INFO_PRINTF2(_L("getfilter has %d"), getfilters->Count());
       
   206 				result=1;
       
   207 			}
       
   208 			if(result==0)
       
   209 			{
       
   210 				for(TInt i=0;i!=getfilters->Count() && result==0;i++)
       
   211 				{
       
   212 					for(TInt j=0;j!=setfilters->Count() && result!=0;j++)
       
   213 					{
       
   214 						if(getfilters->At(i)==setfilters->At(j))
       
   215 							result=0;
       
   216 						else
       
   217 							result=1;
       
   218 					}
       
   219 				}
       
   220 			}
       
   221 			if(result==0)
       
   222 				INFO_PRINTF1(_L("Get multiple primary filters successful"));
       
   223 			else
       
   224 				INFO_PRINTF1(_L("Get multiple primary filters failed"));
       
   225 			INFO_PRINTF1(_L("Get Primary filters returns multiple filters"));
       
   226 		//	for(int i=0;i!=KMaxNumberOfGroupIds;i++)
       
   227 		//		INFO_PRINTF2(_L(" %d"), getfilters->operator[](i));	//uncomment to verify get filters test correct
       
   228 			getfilters->Reset();
       
   229 
       
   230 			/*****************Given this is successful, now remove the above set filter***************/
       
   231 
       
   232 			if(result==0)
       
   233 			{
       
   234 				logger.Connect();
       
   235 				logger.SetPrimaryFiltersEnabled(*removefilter,EFalse);//C.A. previously:logger.DisableClassifications(*removefilter);
       
   236 			//	getfilter.Append(removefilter);
       
   237 			//	logger.EnableClassifications(getfilter);//uncomment these to negative test the test suite
       
   238 				logger.GetPrimaryFiltersEnabled(*getfilters);//C.A. previously:logger.GetEnabledClassifications(*getfilters);
       
   239 				for(TInt i=0; i!=getfilters->Count() && result==0;i++)
       
   240 				{
       
   241 					if(getfilters->At(i)==removefilter->At(0))
       
   242 					{
       
   243 						INFO_PRINTF1(_L("Remove primary filter in multiple test failed"));
       
   244 						result=1;
       
   245 					}
       
   246 					else
       
   247 						result=0;
       
   248 				}
       
   249 				if(result==0)
       
   250 					INFO_PRINTF1(_L("Remove primary filter in multiple test successful"));
       
   251 				else
       
   252 					INFO_PRINTF1(_L("Remove primary filter in multiple test failed"));
       
   253 			}
       
   254 			INFO_PRINTF1(_L("Now, given that the above tests have passed, negative test the primary filter options"));
       
   255 			INFO_PRINTF1(_L("First reset the removed filter, then proceed"));
       
   256 			setfilter->At(0)=removefilter->At(0);
       
   257 			logger.SetPrimaryFiltersEnabled(*setfilter,ETrue);//C.A. previously:logger.EnableClassifications(*setfilter);
       
   258 			if(result==0)
       
   259 			{
       
   260 				INFO_PRINTF1(_L("Removed filter has been reset"));
       
   261 
       
   262 				/************Now try to set a primary filter value greater than that allowed***/
       
   263 
       
   264 				setfilter->At(0)=((TGroupId)(KMaxNumberOfGroupIds));
       
   265 				INFO_PRINTF2(_L("setfilter is %d"), setfilter->At(0));
       
   266 				TInt r=logger.SetPrimaryFiltersEnabled(*setfilter,ETrue);//C.A. previously:TInt r=logger.EnableClassifications(*setfilter);
       
   267 				if((r==KErrNone)&&(setfilter->At(0)==KMaxNumberOfGroupIds-256))
       
   268 				{
       
   269 					INFO_PRINTF3(_L("Primary filter has been set with filter %d,corresponding to the passed value %d, this is allowed as duplicate! Passed"), setfilter->At(0),KMaxNumberOfGroupIds );
       
   270 					result=0;
       
   271 				}
       
   272 				else if((r==KErrNone)&&(setfilter->At(0)!=KMaxNumberOfGroupIds-256))
       
   273 				{
       
   274 					INFO_PRINTF3(_L("Primary filter has been set with filter %d,corresponding to the passed value %d, this is not allowed as not duplicate! Failed"), setfilter->At(0),KMaxNumberOfGroupIds );
       
   275 					result=1;
       
   276 				}
       
   277 				else
       
   278 				{
       
   279 					INFO_PRINTF3(_L("Primary filter has not been set with filter %d, corresponding to the passed value %d. Passed"), setfilter->At(0), KMaxNumberOfGroupIds);
       
   280 					result=0;
       
   281 				}
       
   282 
       
   283 				/************Now try to set more primary filter values greater than available***/
       
   284 
       
   285 				{
       
   286 					INFO_PRINTF1(_L("Now try to set more filter than available using a duplicate"));
       
   287 					if(result==0)
       
   288 					{
       
   289 						setfilter->At(0)=((TGroupId)(KMaxNumberOfGroupIds-1));
       
   290 						result=logger.SetPrimaryFiltersEnabled(*setfilter,ETrue);//C.A. previously:result=logger.EnableClassifications(*setfilter);
       
   291 						if((result==KErrNone)&&(setfilter->At(0)!=KMaxNumberOfGroupIds-1))
       
   292 						{
       
   293 							INFO_PRINTF1(_L("More primary filters than available can be set. Failed"));
       
   294 							result=1;
       
   295 						}
       
   296 						else
       
   297 						{
       
   298 							INFO_PRINTF1(_L("More primary filters than available cannot be set OR the filter being set is a duplicate. Passed"));
       
   299 							result=0;
       
   300 						}
       
   301 					}
       
   302 				}
       
   303 			}
       
   304 			if(result==1)
       
   305 				SetBlockResult(EFail);
       
   306 			else
       
   307 				SetBlockResult(EPass);
       
   308 			if(setfilters)
       
   309 			{
       
   310 				delete setfilters;
       
   311 				setfilters=NULL;
       
   312 			}
       
   313 			setfilter->Reset();
       
   314 			if(getfilters)
       
   315 			{
       
   316 				delete getfilters;
       
   317 				getfilters=NULL;
       
   318 			}
       
   319 		}
       
   320 
       
   321 		//  **************   Block end ****************
       
   322 
       
   323 		configIni.Clear(logger);
       
   324 		logger.Close();
       
   325 		if(setfilter)
       
   326 			delete setfilter;
       
   327 		if(getfilter)
       
   328 			delete getfilter;
       
   329 		}
       
   330 	  return ETrue;
       
   331 	}
       
   332 
       
   333 
       
   334 
       
   335 /*******************************************************************************/
       
   336 /*********************************Secondary Filter Test***************************/
       
   337 /*******************************************************************************/
       
   338 
       
   339 
       
   340 CTCMComponentIDFilteringWrapper::~CTCMComponentIDFilteringWrapper()
       
   341 /**
       
   342  * Destructor
       
   343  */
       
   344 	{
       
   345 	}
       
   346 
       
   347 CTCMComponentIDFilteringWrapper::CTCMComponentIDFilteringWrapper()
       
   348 /**
       
   349  * Constructor
       
   350  */
       
   351 	{
       
   352 	}
       
   353 
       
   354 
       
   355 CTCMComponentIDFilteringWrapper* CTCMComponentIDFilteringWrapper::NewLC()
       
   356 	{
       
   357 	CTCMComponentIDFilteringWrapper* self = new (ELeave)CTCMComponentIDFilteringWrapper();
       
   358 	CleanupStack::PushL(self);
       
   359 	self->ConstructL();
       
   360 	return self;
       
   361 	}
       
   362 
       
   363 CTCMComponentIDFilteringWrapper* CTCMComponentIDFilteringWrapper::NewL()
       
   364 	{
       
   365 	CTCMComponentIDFilteringWrapper* self=CTCMComponentIDFilteringWrapper::NewLC();
       
   366 	CleanupStack::Pop(); // self;
       
   367 	return self;
       
   368 	}
       
   369 
       
   370 void CTCMComponentIDFilteringWrapper::ConstructL()
       
   371 	{
       
   372 	}
       
   373 
       
   374 TAny* CTCMComponentIDFilteringWrapper::GetObject()
       
   375 	{
       
   376 	return NULL;
       
   377 	}
       
   378 
       
   379 TBool CTCMComponentIDFilteringWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
   380 					const TTEFSectionName& /*aSection*/, 
       
   381 					const TInt /*aAsyncErrorIndex*/)
       
   382 	{
       
   383 	  if (BlockResult()==EPass)
       
   384 		{
       
   385 		//  ************** Delete the Block, the block start ****************
       
   386             INFO_PRINTF1(_L("do stepL"));
       
   387 			TInt result=0;
       
   388 			RULogger logger;
       
   389 			RArray<TUint32> setfilter;
       
   390 			setfilter.Append((TUint32) KComponentId);
       
   391 			RArray<TUint32> dupfilter;
       
   392 			RArray<TUint32> getfilter;
       
   393 			RArray<TUint32> removefilter;
       
   394 			removefilter.Append(setfilter[0]);
       
   395 		//	removefilter=32; //uncomment to negative test the remove filter option
       
   396 
       
   397 			/**************First set Secondary filter*************/
       
   398 
       
   399 			result = logger.Connect();
       
   400 			INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
   401 		 	if (result!=KErrNone)
       
   402 		 	    {
       
   403      			INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
   404             	for (TInt i=2; i<12;i++)
       
   405                    {
       
   406                    User::After(1000);
       
   407                    result = logger.Connect();
       
   408                    INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
   409                    if (result==KErrNone)
       
   410 						{
       
   411                        	break;
       
   412 						}
       
   413                    }
       
   414 		 	    }
       
   415 
       
   416 			CClearConfig configIni;
       
   417 			configIni.Clear(logger);
       
   418 			result = logger.SetSecondaryFiltersEnabled(setfilter,ETrue);//C.A. previously:result = logger.EnableModuleUids(setfilter);
       
   419 			INFO_PRINTF2(_L("Secondary filter has been set with single filter, %d, check log"), setfilter[0]);
       
   420 			INFO_PRINTF2(_L("code: %d"), result);
       
   421 
       
   422 
       
   423 			/**************Now get the Secondary filter set above************/
       
   424 
       
   425 			result = logger.GetSecondaryFiltersEnabled(getfilter);//C.A. previously:result = logger.GetEnabledModuleUids(getfilter);
       
   426 			INFO_PRINTF1(_L("Get Secondary filter returns the following filters"));
       
   427 			INFO_PRINTF2(_L("code: %d"), result);
       
   428 			for(TInt i=0;i!=getfilter.Count();i++)
       
   429 			{
       
   430 				INFO_PRINTF2(_L("%d "),getfilter[i]);
       
   431 			}
       
   432 			if(getfilter[0]==setfilter[0])
       
   433 			{
       
   434 				result=0;
       
   435 				INFO_PRINTF1(_L("Get Secondary filter successful"));
       
   436 			}
       
   437 			else
       
   438 			{
       
   439 				INFO_PRINTF1(_L("Get Secondary filter failed"));
       
   440 				result=1;
       
   441 			}
       
   442 			for(TInt i=0;i!=getfilter.Count();)//i++)
       
   443 			{
       
   444 				getfilter.Remove(0);
       
   445 			}
       
   446 
       
   447 			/*****************Now remove the above set filter***************/
       
   448 
       
   449 			if(result==0)
       
   450 			{
       
   451 				result=logger.SetSecondaryFiltersEnabled(removefilter,EFalse);//C.A. previously:result=logger.DisableModuleUids(removefilter);
       
   452 				INFO_PRINTF2(_L("Remove Module Uid filters single filter, 0 if succesful, -1 if failed: %d"), result);//logger.RemoveSingleSecondary);
       
   453 				logger.GetSecondaryFiltersEnabled(getfilter);//C.A. previously:logger.GetEnabledModuleUids(getfilter);
       
   454 				if(getfilter.Count()==0)
       
   455 				{
       
   456 					INFO_PRINTF1(_L("Remove ModuleUid filter successful"));
       
   457 					result=0;
       
   458 				}
       
   459 				else
       
   460 				{
       
   461 					if(result!=0)
       
   462 						INFO_PRINTF1(_L("Remove ModuleUid filter failed, as filter has not been set in the config file"));
       
   463 					else
       
   464 						INFO_PRINTF1(_L("Remove ModuleUid filter failed, as able to pass same filter option to RemoveSecondaryFilter"));
       
   465 					result=1;
       
   466 				}
       
   467 			}
       
   468 
       
   469 			/****Now if the above steps have passed proceed to testing multiple filters***/
       
   470 
       
   471 			if(result==1)
       
   472 				SetBlockResult(EFail);
       
   473 			else
       
   474 			{
       
   475 				RArray<TUint32> setfilters;
       
   476 				RArray<TUint32> getfilters;
       
   477 				INFO_PRINTF2(_L("maxsecondary %d"),KMaxNumberOfComponentIds);
       
   478 				for(TInt i=0;i<KMaxNumberOfComponentIds;i++)
       
   479 				{
       
   480 					setfilters.Append((TUint32)(i));
       
   481 				}
       
   482 				INFO_PRINTF1(_L("initialising values for multiple secondary filters ok, now set the filters etc"));
       
   483 
       
   484 				/**************First set  multiple Secondary filter*************/
       
   485 
       
   486 				result=logger.SetSecondaryFiltersEnabled(setfilters,ETrue);//C.A. previously:result=logger.EnableModuleUids(setfilters);
       
   487 				if(result==KErrNone)
       
   488 				INFO_PRINTF2(_L("Secondary filter has been set with multiple filters,from 0 to %d"), KMaxNumberOfComponentIds);
       
   489 				else
       
   490 					INFO_PRINTF2(_L("Multiple secondary filters have not been set succesfully, error code %d"), result);
       
   491 
       
   492 				/**************Now get the Secondary filter set above************/
       
   493 
       
   494 				INFO_PRINTF2(_L("before get, getfilter has %d"), getfilters.Count());
       
   495 				logger.GetSecondaryFiltersEnabled(getfilters);//C.A. previously:logger.GetEnabledModuleUids(getfilters);
       
   496 				if(getfilters.Count()==setfilters.Count())
       
   497 				{
       
   498 					INFO_PRINTF1(_L("setfilter and getfilter have the same count"));
       
   499 					INFO_PRINTF2(_L("setfilter has %d"), setfilters.Count());
       
   500 					INFO_PRINTF2(_L("getfilter has %d"), getfilters.Count());
       
   501 				}
       
   502 				else
       
   503 				{
       
   504 					INFO_PRINTF1(_L("setfilter and getfilter have different counts"));
       
   505 					result=1;
       
   506 						INFO_PRINTF2(_L("setfilter has %d"), setfilters.Count());
       
   507 						INFO_PRINTF2(_L("getfilter has %d"), getfilters.Count());
       
   508 				}
       
   509 				for(TInt i=0;i!=getfilters.Count() && result==0;i++)
       
   510 				{
       
   511 					for(TInt j=0;j!=getfilters.Count() && result!=0;j++)
       
   512 					{
       
   513 						if(getfilters[i]==setfilters[j])
       
   514 							result=0;
       
   515 						else
       
   516 							result=1;
       
   517 					}
       
   518 				}
       
   519 				if(result==0)
       
   520 					INFO_PRINTF1(_L("Get multiple Secondary filters successful"));
       
   521 				else
       
   522 					INFO_PRINTF1(_L("Get multiple Secondary filters failed"));
       
   523 				INFO_PRINTF1(_L("Get Secondary filters returns multiple filters"));
       
   524 			//	for(int i=0;i!=getfilters.Count();i++)//KMaxNumberOfComponentIds;i++)
       
   525 			//		INFO_PRINTF2(_L(" %d"), getfilters[i]);	//uncomment to verify get filters test correct - WARNING-loadsa data if use true maximum for secondary filters-will break TEF!!
       
   526 				for(TInt i=0;i<getfilters.Count();)//i++)
       
   527 				{
       
   528 					getfilters.Remove(0);
       
   529 				}
       
   530 
       
   531 				/*****************Given this is successful, now remove the above set filter***************/
       
   532 
       
   533 				if(result==0)
       
   534 				{
       
   535 					logger.SetSecondaryFiltersEnabled(removefilter,EFalse);//C.A. previously:logger.DisableModuleUids(removefilter);
       
   536 				//	getfilter.Append(removefilter);
       
   537 				//	logger.EnableModuleUids(getfilter);//uncomment these to negative test the test suite
       
   538 					logger.GetSecondaryFiltersEnabled(getfilters);//C.A. previously:logger.GetEnabledModuleUids(getfilters);
       
   539 					for(TInt i=0; i!=getfilters.Count() && result==0;i++)
       
   540 					{
       
   541 						if(getfilters[i]==removefilter[0])
       
   542 						{
       
   543 							INFO_PRINTF1(_L("Remove Secondary filter in multiple test failed"));
       
   544 							result=1;
       
   545 						}
       
   546 						else
       
   547 							result=0;
       
   548 					}
       
   549 					if(result==0)
       
   550 						INFO_PRINTF1(_L("Remove Secondary filter in multiple test successful"));
       
   551 					else
       
   552 					INFO_PRINTF1(_L("Remove Secondary filter in multiple test failed"));
       
   553 				}
       
   554 				INFO_PRINTF1(_L("Now, given that the above tests have passed, negative test the secondary filter options"));
       
   555 				INFO_PRINTF1(_L("First reset the removed filter, then proceed"));
       
   556 				setfilter[0]=removefilter[0];
       
   557 				logger.SetSecondaryFiltersEnabled(setfilter,ETrue);//C.A. previously:logger.EnableModuleUids(setfilter);
       
   558 				if(result==0)
       
   559 				{
       
   560 					INFO_PRINTF1(_L("Removed filter has been reset"));
       
   561 
       
   562 					/************Now try to set a secondary filter value greater than that allowed***/
       
   563 
       
   564 					setfilter[0]=((TComponentId)(KMaxNumberOfComponentIds-1));
       
   565 					INFO_PRINTF2(_L("setfilter is %d"), setfilter[0]);
       
   566 					TInt r= logger.SetSecondaryFiltersEnabled(setfilter,ETrue);//C.A. previously:TInt r= logger.EnableModuleUids(setfilter);
       
   567 					if((r==KErrNone)&&(setfilter[0]==KMaxNumberOfComponentIds-1))
       
   568 					{
       
   569 						INFO_PRINTF3(_L("Secondary filter has been set with filter %d,corresponding to the passed value %d, this is allowed as is duplicate. Passed"), setfilter[0],KMaxNumberOfComponentIds-1 );
       
   570 						result=0;
       
   571 					}
       
   572 					if((r==KErrNone)&&(setfilter[0]!=KMaxNumberOfComponentIds-1))
       
   573 					{
       
   574 						INFO_PRINTF3(_L("Secondary filter has been set with filter %d,corresponding to the passed value %d, this is not allowed. Failed"), setfilter[0],KMaxNumberOfComponentIds-1 );
       
   575 						result=1;
       
   576 					}
       
   577 					else
       
   578 
       
   579 					{
       
   580 						INFO_PRINTF3(_L("Secondary filter has not been set with filter %d, corresponding to the passed value %d , this is as expected as otherwise duplicate. Passed"), setfilter[0], KMaxNumberOfComponentIds-1);
       
   581 						result=0;
       
   582 					}
       
   583 					/************Now try to set more secodndary filter values greater than available***/
       
   584 
       
   585 					INFO_PRINTF1(_L("Now try to set more filter than available"));
       
   586 					if(result==0)
       
   587 					{
       
   588 						setfilter[0]=((TComponentId)(KMaxNumberOfComponentIds+3));
       
   589 						result=logger.SetSecondaryFiltersEnabled(setfilter,ETrue);//C.A. previously:result=logger.EnableModuleUids(setfilter);
       
   590 						if(result==KErrNone)
       
   591 						{
       
   592 							INFO_PRINTF1(_L("More secondary filters than available can be set. Failed"));
       
   593 							result=1;
       
   594 						}
       
   595 						else
       
   596 						{
       
   597 							INFO_PRINTF1(_L("More secondary filters than available cannot be set. Passed"));
       
   598 							result=0;
       
   599 						}
       
   600 					}
       
   601 				}
       
   602 				INFO_PRINTF1(_L("Now call clear config to check removing multiple second filters performance"));
       
   603 				configIni.Clear(logger);
       
   604 				INFO_PRINTF1(_L("after clear config- multiple second filters performance"));
       
   605 
       
   606 				if(result==1)
       
   607 					SetBlockResult(EFail);
       
   608 				else
       
   609 					SetBlockResult(EPass);
       
   610 			}
       
   611 			logger.Close();
       
   612 			//  **************   Block end ****************
       
   613 		}
       
   614 	  return ETrue;
       
   615 	}
       
   616 
       
   617 
       
   618 /*******************************************************************************/
       
   619 /*********************************Logging Start/Stop Test***********************/
       
   620 /*******************************************************************************/
       
   621 
       
   622 CTCMLoggingWrapper::~CTCMLoggingWrapper()
       
   623 /**
       
   624  * Destructor
       
   625  */
       
   626 	{
       
   627 	}
       
   628 
       
   629 CTCMLoggingWrapper::CTCMLoggingWrapper()
       
   630 /**
       
   631  * Constructor
       
   632  */
       
   633 	{
       
   634 	}
       
   635 
       
   636 
       
   637 
       
   638 CTCMLoggingWrapper* CTCMLoggingWrapper::NewLC()
       
   639 	{
       
   640 	CTCMLoggingWrapper* self = new (ELeave)CTCMLoggingWrapper();
       
   641 	CleanupStack::PushL(self);
       
   642 	self->ConstructL();
       
   643 	return self;
       
   644 	}
       
   645 
       
   646 CTCMLoggingWrapper* CTCMLoggingWrapper::NewL()
       
   647 	{
       
   648 	CTCMLoggingWrapper* self=CTCMLoggingWrapper::NewLC();
       
   649 	CleanupStack::Pop(); // self;
       
   650 	return self;
       
   651 	}
       
   652 
       
   653 void CTCMLoggingWrapper::ConstructL()
       
   654 	{
       
   655 	}
       
   656 
       
   657 TAny* CTCMLoggingWrapper::GetObject()
       
   658 	{
       
   659 	return NULL;
       
   660 	}
       
   661 TBool CTCMLoggingWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
   662 					const TTEFSectionName& /*aSection*/, 
       
   663 					const TInt /*aAsyncErrorIndex*/)
       
   664 	{
       
   665 		TBool OstStatus=0;
       
   666 	  if (BlockResult()==EPass)
       
   667 		{
       
   668 		//  ************** Delete the Block, the block start ****************
       
   669 
       
   670 			INFO_PRINTF1(_L("About to test ulogger start with one primary and one secondary"));  //Block start
       
   671 			TInt result=0;
       
   672 			RULogger logger;
       
   673 			result=logger.Connect();
       
   674       		  INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
   675         	    if (result!=KErrNone)
       
   676          	  	 {
       
   677          	   		INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
   678           	  		for (TInt i=2; i<12;i++)
       
   679               		 {
       
   680                		User::After(1000);
       
   681                		result = logger.Connect();
       
   682                		INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
   683                		if (result==KErrNone)
       
   684                     	{
       
   685                     	break;
       
   686                     	}
       
   687                		}
       
   688             	}
       
   689 #ifdef SysStartTest
       
   690 			TInt SysStartResult=logger.StartOutputting();
       
   691 			if(SysStartResult!=KErrInUse)
       
   692 				INFO_PRINTF2(_L("Logger start returning incorrect error code of %d when already started by SysStart, should be KErrInUse (-14)"), SysStartResult);
       
   693 			logger.StopOutputting();
       
   694 #endif
       
   695 #ifndef SysStartTest
       
   696 			CClearConfig configIni;
       
   697 			configIni.Clear(logger);
       
   698 #endif
       
   699 			CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(22);
       
   700 			setprimfilter->AppendL(KGroupId);
       
   701 			setprimfilter->AppendL(TRACE_PERFORMANCE); 
       
   702 			setprimfilter->AppendL(TRACE_STATE);
       
   703 			setprimfilter->AppendL(TRACE_FLOW);
       
   704 			/**REMOVE THIS SECTION WHEN TRACE COMPILER WORK FOR CORRECT GIDS IS DONE**/
       
   705 			setprimfilter->AppendL(TRACE_NORMAL);
       
   706 			/*************************************************************************/
       
   707 			RArray<TUint32> setsecondfilter;
       
   708 			setsecondfilter.Append((TUint32) KComponentId);
       
   709 			logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*setprimfilter);
       
   710 			logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(setsecondfilter);
       
   711 			INFO_PRINTF1(_L("about to set file as output plugin"));
       
   712 			//NB: this of course assumes that the plugin functionality works which is tested more rigorously in the plugin test step
       
   713 #ifndef SysStartTest
       
   714 
       
   715 			_LIT(KTextvalue, "C:\\logs\\ULoggerLoggingTest.utf");
       
   716 #ifdef TE_UPT_TRACE_ENABLED
       
   717 			EmptyFile(KTextvalue);
       
   718 #endif
       
   719 			if(result==0)
       
   720 			{
       
   721 				INFO_PRINTF1(_L("file set as output plugin ok"));
       
   722 				_LIT8(KTextmedia,"uloggerfileplugin");
       
   723 				TPtrC8 mediaptr(KTextmedia);
       
   724 				result=logger.ActivateOutputPlugin(mediaptr);//C.A. previously:result=logger.SetActiveOutputPlugin(mediaptr);
       
   725 				INFO_PRINTF1(_L("file set as active output plugin ok"));
       
   726 				TPluginConfiguration pluginConfig;
       
   727 				pluginConfig.SetKey(KTextsetting);
       
   728 				pluginConfig.SetValue(KTextvalue);
       
   729 				result=logger.SetPluginConfigurations(mediaptr, pluginConfig);
       
   730 				if(result==0)
       
   731 					INFO_PRINTF1(_L("output plugin settings set ok"));
       
   732 				else
       
   733 					INFO_PRINTF2(_L("setting output plugin settings failed with err %d"), result);
       
   734 			}
       
   735 			else
       
   736 				INFO_PRINTF2(_L("add file as output plugin failed with err %d"), result);
       
   737 #endif
       
   738 			if(result==0)
       
   739 			{
       
   740 			/************** Start Logging to File****************/
       
   741 
       
   742 			result=logger.Start();//C.A. previously:result=logger.StartOutputting();
       
   743 			INFO_PRINTF2(_L("ulogger start returns error %d"), result);
       
   744 			INFO_PRINTF1(_L("now step over some Ost statements"));
       
   745 			int tracetag =0;
       
   746 			TBool ret=KErrNone;
       
   747 			iApiRunConfig.iDoStack=EFalse;
       
   748 
       
   749 			#ifdef TE_UPT_TRACE_ENABLED
       
   750 			OstStatus = 1;
       
   751 			INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
   752   			#else
       
   753 			OstStatus = 0;
       
   754 			INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
   755   			#endif
       
   756 
       
   757 			/*************Now test the static method************************/
       
   758 
       
   759 			INFO_PRINTF1(_L("******Testing STATIC Trace Methods******"));
       
   760 
       
   761 			iApiRunConfig.iDoStack=EFalse;
       
   762 			ret=KErrNone;
       
   763 			/*Comment out this line to switch off tracing as a negative test*/
       
   764 			for(tracetag=EUptTrace; tracetag!=(EOstTraceEventStop+1)&&ret==KErrNone;tracetag++)
       
   765 			{
       
   766                 iApiRunConfig.iApiId = tracetag;
       
   767                 ret = 1;
       
   768                 TApiRunResults apiRunResults;
       
   769                 TRunConfigurer::Init(apiRunResults);
       
   770                 ret = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
   771                 INFO_PRINTF3(_L("Ost macro %d has executed with error %d"), tracetag, ret);
       
   772 
       
   773                 if(ret==KErrNone&&OstStatus)
       
   774                     {
       
   775                     StoreTraceInfo(ETrue,(TUPTApiUsed)tracetag,0, 0,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
   776                     }
       
   777 			}
       
   778 
       
   779 			if((ret==KErrNone&&OstStatus)||(ret!=KErrNone&&!OstStatus&&tracetag!=EUptIsTraceActive))
       
   780 			{
       
   781 				result=0;
       
   782 				INFO_PRINTF1(_L("Tracing carried out succesfully for static method"));
       
   783 				if(ret==KErrNone)
       
   784 					{
       
   785 					INFO_PRINTF1(_L("logfile should contain appropriate tracing"));
       
   786 					}
       
   787 				else
       
   788 					INFO_PRINTF1(_L("logfile should be empty of trace statements"));
       
   789 
       
   790 			}
       
   791 			else
       
   792 			{
       
   793 				result=1;
       
   794 				INFO_PRINTF2(_L("Tracing Failed on Ost macro  %d for static method"), tracetag);
       
   795 			}
       
   796 
       
   797 			/************** Stop Logging to File****************/
       
   798 
       
   799 			result=logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
   800 			if(result==KErrNone&&OstStatus)
       
   801 				{
       
   802 				if(!ReadFromLogFile(KTextvalue))
       
   803 					{
       
   804 					result=CompareTraces();
       
   805 					if(result)
       
   806 						INFO_PRINTF2(_L("ERROR: Error when comparing traces, error %i"), result);
       
   807 					//prob set the test step result here
       
   808 					}
       
   809 				}
       
   810 
       
   811 			if(result==0)
       
   812 			{
       
   813 			iApiRunConfig.iApiId = EUptTrace;
       
   814 			ret = 0;
       
   815 			TApiRunResults apiRunResults;
       
   816 			TRunConfigurer::Init(apiRunResults);
       
   817 			ret = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
   818 			INFO_PRINTF1(_L("logfile should contain appropriate tracing without an extra Ost(0) trace at the end, if it is present ULogger.StopOutputting() has failed in functionality"));
       
   819 			if(!ret)
       
   820 				{
       
   821 				result=CompareTraces();
       
   822 				if(result)
       
   823 					INFO_PRINTF2(_L("ERROR: Error when comparing traces, extra trace might have been added at the end %i"), result);
       
   824 				}
       
   825 			}
       
   826 			else
       
   827 			{
       
   828 				INFO_PRINTF2(_L("Call to Ulogger.StopOutputting() has failed with err %d"), result);
       
   829 			}
       
   830 		}
       
   831 		else
       
   832 			INFO_PRINTF1(_L("adding file as output plugin failed"));
       
   833 		if(result==0)
       
   834 				SetBlockResult(EPass);
       
   835 		else
       
   836 				SetBlockResult(EFail);
       
   837 		INFO_PRINTF1(_L("Simple logging to file has been tested - check output log"));
       
   838 
       
   839 		/***************************negative test***********************/
       
   840 		_LIT(KnegTextvalue, "C:\\logs\\ULoggerNegativeLoggingTest.utf");
       
   841 #ifdef TE_UPT_TRACE_ENABLED
       
   842 		EmptyFile(KnegTextvalue);
       
   843 #endif
       
   844 		if(BlockResult()==EPass)
       
   845 		{
       
   846 			INFO_PRINTF1(_L("Now do some negative logging testing."));
       
   847 			if(result==KErrNone)
       
   848 			{
       
   849 				INFO_PRINTF1(_L("file set as output plugin ok"));
       
   850 				_LIT8(KTextmedia,"uloggerfileplugin");
       
   851 				TPtrC8 mediaptr(KTextmedia);
       
   852 				if(result==0)
       
   853 				{	INFO_PRINTF1(_L("file set as active output plugin ok"));
       
   854 					TPluginConfiguration negPluginConfig;
       
   855 					negPluginConfig.SetKey(KTextsetting);
       
   856 					negPluginConfig.SetValue(KnegTextvalue);
       
   857 					result=logger.SetPluginConfigurations(mediaptr, negPluginConfig);
       
   858 					if(result==0)
       
   859 						INFO_PRINTF1(_L("output plugin settings set ok"));
       
   860 					else
       
   861 						INFO_PRINTF1(_L("setting output plugin settings failed"));
       
   862 				}
       
   863 				else
       
   864 					INFO_PRINTF1(_L("file not set as active output plugin - failed"));
       
   865 				INFO_PRINTF1(_L("Log over traces with different filters set - there should only be one line in logfile corrseponding to the set filters."));
       
   866 				if(result==0)
       
   867 				{
       
   868 				logger.Start();//C.A. previously:logger.StartOutputting();
       
   869 
       
   870 					/*****do the tracing**************/
       
   871 
       
   872 				bool ret = 1;
       
   873 				TTraceContext header(KComponentId, KGroupId, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
   874 				ret = OstTrace(header, KTraceId);
       
   875 
       
   876 				iLoggedTraces.Reset();
       
   877 				iSentTraces.Reset();
       
   878 				if (ret)
       
   879 					{
       
   880 					//create trace information object
       
   881 					StoreTraceInfo(EFalse,(TUPTApiUsed)0,KComponentId, KGroupId,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
   882 					}
       
   883 
       
   884 				INFO_PRINTF2(_L("tracing ret %d"), ret);
       
   885 				TTraceContext attr1(KComponentId+1, KGroupId+1, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
   886 				ret = OstTrace(attr1, KTraceId);
       
   887 
       
   888 				INFO_PRINTF2(_L("tracing ret %d"), ret);
       
   889 
       
   890 				/************** Stop Logging to File****************/
       
   891 
       
   892 				result=logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
   893 				if(result!=0)
       
   894 					{
       
   895 					INFO_PRINTF2(_L("Call to Ulogger.StopOutputting() has failed with err %d"), result);
       
   896 					}
       
   897 					INFO_PRINTF1(_L("Set some more filters and remove the original set in ulogger, then trace over the original types of traces - there should be no extra lines in logfile above"));
       
   898 
       
   899 				/**************Now Change the filter settings********/
       
   900 				CArrayFixFlat<TUint8> *removeprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
   901 				removeprimfilter->AppendL(setprimfilter->At(0));
       
   902 				RArray<TUint32> removesecondfilter;
       
   903 				removesecondfilter.Append(setsecondfilter[0]);
       
   904 				result=logger.SetPrimaryFiltersEnabled(*removeprimfilter,EFalse);//C.A. previously:result=logger.DisableClassifications(*removeprimfilter);
       
   905 				if(result==0)
       
   906 				{
       
   907 					INFO_PRINTF1(_L("Call to removeprimary has passed"));
       
   908 				}
       
   909 				result=logger.SetSecondaryFiltersEnabled(removesecondfilter,EFalse);//C.A. previously:result=logger.DisableModuleUids(removesecondfilter);
       
   910 				if(result==0)
       
   911 				{
       
   912 						INFO_PRINTF1(_L("Call to removesecondary has passed"));
       
   913 				}
       
   914 					CArrayFixFlat<TUint8> *newsetprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
   915 					newsetprimfilter->AppendL((TUint8)(KGroupId+2));
       
   916 					RArray<TUint32> newsetsecondfilter;
       
   917 					newsetsecondfilter.Append((TUint32) (KComponentId+2));
       
   918 					logger.SetPrimaryFiltersEnabled(*newsetprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*newsetprimfilter);
       
   919 					logger.SetSecondaryFiltersEnabled(newsetsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(newsetsecondfilter);
       
   920 					ret=1;
       
   921 					logger.Start();//C.A. previously:logger.StartOutputting();
       
   922 
       
   923 					/*****do the tracing**************/
       
   924 
       
   925 					/*Comment out this line to switch off tracing as a negative test*/
       
   926 					int tracetag=0;
       
   927 					for(tracetag=EUptTrace; tracetag!=EUptIsTraceActive&&ret==KErrNone;tracetag++)
       
   928 					{
       
   929 					iApiRunConfig.iApiId = tracetag;
       
   930 					ret = 1;
       
   931 					TApiRunResults apiRunResults;
       
   932 					TRunConfigurer::Init(apiRunResults);
       
   933 					ret = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
   934 					INFO_PRINTF3(_L("Ost macro %d has been executed with error %d"), tracetag, ret);
       
   935 					}
       
   936 					if(ret==KErrNone)
       
   937 					{
       
   938 						SetBlockResult(EFail);
       
   939 						INFO_PRINTF1(_L("BTrace filters are not being reset with StartOutputting()/StopOutputting(), so logging over filters that have been unset is occuring. Fail"));
       
   940 					}
       
   941 					TTraceContext attr2(KComponentId+2, KGroupId+2, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
   942 					ret = OstTrace(attr2, KTraceId);
       
   943 					if (ret)
       
   944 						{
       
   945 						//create trace information object
       
   946 						StoreTraceInfo(EFalse,(TUPTApiUsed)0,KComponentId+2, KGroupId+2,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
   947 						}
       
   948 
       
   949 					INFO_PRINTF2(_L("tracing ret %d"), ret);
       
   950 
       
   951 					/************** Stop Logging to File****************/
       
   952 
       
   953 					logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
   954 
       
   955 					if(result!=0)
       
   956 					{
       
   957 					INFO_PRINTF2(_L("Call to Ulogger.StopOutputting() has failed with err %d"), result);
       
   958 					}
       
   959 
       
   960 					else if(result==KErrNone&&OstStatus)
       
   961 						{
       
   962 						if(!ReadFromLogFile(KnegTextvalue))
       
   963 							{
       
   964 							result=CompareTraces();
       
   965 							if(result)
       
   966 								INFO_PRINTF2(_L("ERROR: Error when comparing traces, error %i"), result);
       
   967 							//prob set the test step result here
       
   968 							}
       
   969 						}
       
   970 					if(newsetprimfilter)
       
   971 					{
       
   972 						delete(newsetprimfilter);
       
   973 						newsetprimfilter=NULL;
       
   974 					}
       
   975 				}
       
   976 			}
       
   977 			else
       
   978 				INFO_PRINTF1(_L("Incorrect error code when trying to add file as a plug-in when it already exists"));
       
   979 			if(result==0&&BlockResult()==EPass)
       
   980 					SetBlockResult(EPass);
       
   981 			else
       
   982 					SetBlockResult(EFail);
       
   983 			INFO_PRINTF1(_L("Simple negative logging to file has been tested - check output log"));
       
   984 		}
       
   985 
       
   986 		/***************************multiple type test***********************/
       
   987    		 // From negative test: primary has been set to KClassification+2 and secondary to KComponentId+2
       
   988 		_LIT(KmultTextvalue, "C:\\logs\\ULoggerMultipleLoggingTest.utf");
       
   989 #ifdef TE_UPT_TRACE_ENABLED
       
   990 		EmptyFile(KmultTextvalue);
       
   991 #endif
       
   992 		if(BlockResult()==EPass)
       
   993 		{
       
   994 			INFO_PRINTF1(_L("Now do some multiple type logging testing."));
       
   995 			//CClearConfig configIni;
       
   996 			//configIni.Clear(logger);
       
   997 
       
   998 			if(result==0)
       
   999 			{
       
  1000 				INFO_PRINTF1(_L("file set as output plugin ok"));
       
  1001 				_LIT8(KTextmedia,"uloggerfileplugin");
       
  1002 				TPtrC8 mediaptr(KTextmedia);
       
  1003 				if(result==0)
       
  1004 				{
       
  1005 					INFO_PRINTF1(_L("file set as active output plugin ok"));
       
  1006 					TPluginConfiguration pluginConfig;
       
  1007 					pluginConfig.SetKey(KTextsetting);
       
  1008 					pluginConfig.SetValue(KmultTextvalue);
       
  1009 					result=logger.SetPluginConfigurations(mediaptr, pluginConfig);
       
  1010 					if(result==0)
       
  1011 						INFO_PRINTF1(_L("output plugin settings set ok"));
       
  1012 					else
       
  1013 						INFO_PRINTF1(_L("setting output plugin settings failed"));
       
  1014 				}
       
  1015 				else
       
  1016 					INFO_PRINTF1(_L("file not set as active output plugin - failed"));
       
  1017 				if(result==0)
       
  1018 				{
       
  1019 					TInt i;
       
  1020 					CArrayFixFlat<TUint8> *multsetprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
  1021 					multsetprimfilter->AppendL(KGroupId);
       
  1022 					RArray<TUint32> multsetsecondfilter;
       
  1023 					multsetsecondfilter.Append((TUint32) (KComponentId));
       
  1024 					logger.SetPrimaryFiltersEnabled(*multsetprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*multsetprimfilter);
       
  1025 					TInt errCode = logger.SetSecondaryFiltersEnabled(multsetsecondfilter,ETrue);//C.A. previously:TInt errCode = logger.EnableModuleUids(multsetsecondfilter);
       
  1026 
       
  1027 					if(errCode != KErrNone)
       
  1028 						INFO_PRINTF2(_L("Setting secondary filters failed: %d"), errCode);
       
  1029 					INFO_PRINTF1(_L("checking !!! secondary filters"));
       
  1030 					for(i=0; i<multsetsecondfilter.Count(); ++i)
       
  1031 						{
       
  1032 						TBuf<16> buf;
       
  1033 						buf.AppendFormat(_L("%d"), multsetsecondfilter[i]);
       
  1034 						INFO_PRINTF1(buf);
       
  1035 						}
       
  1036 
       
  1037 					INFO_PRINTF1(_L("Now given the two sets of set filters, step over traces of each type, some with matching primary but not secondary and vice versa"));
       
  1038 
       
  1039 					INFO_PRINTF1(_L("Primary Filetrs:"));
       
  1040 					CArrayFixFlat<TUint8>* primFilters = new (ELeave) CArrayFixFlat<TUint8>(1);
       
  1041 					CleanupStack::PushL(primFilters);
       
  1042 					logger.GetPrimaryFiltersEnabled(*primFilters);//C.A. previously:logger.GetEnabledClassifications(*primFilters);
       
  1043 
       
  1044 					for(i=0; i<primFilters->Count(); ++i)
       
  1045 						{
       
  1046 						TBuf<16> buf;
       
  1047 						buf.AppendFormat(_L("%d "), primFilters->At(i));
       
  1048 						INFO_PRINTF1(buf);
       
  1049 						}
       
  1050 					CleanupStack::PopAndDestroy(); //primFiletrs
       
  1051 
       
  1052 					INFO_PRINTF1(_L("ModuleUids:"));
       
  1053 					RArray<TUint32> secFilters;
       
  1054 					errCode = logger.GetSecondaryFiltersEnabled(secFilters);//C.A. previously:errCode = logger.GetEnabledModuleUids(secFilters);
       
  1055 					if(errCode != KErrNone)
       
  1056 						INFO_PRINTF2(_L("Getting ModuleUids failed: %d"), errCode);
       
  1057 
       
  1058 					for(i=0; i<secFilters.Count(); ++i)
       
  1059 						{
       
  1060 						TBuf<16> buf;
       
  1061 						buf.AppendFormat(_L("%d"), secFilters[i]);
       
  1062 						INFO_PRINTF1(buf);
       
  1063 						}
       
  1064 					secFilters.Close();
       
  1065 
       
  1066 					INFO_PRINTF1(_L("Secondary Filetring is:"));
       
  1067 					TBool secF = EFalse;
       
  1068 					logger.GetSecondaryFilteringEnabled(secF);//C.A. previously:logger.IsModuleUidFilteringEnabled(secF);
       
  1069 					if(secF)
       
  1070 						INFO_PRINTF1(_L("ENABLED"));
       
  1071 					else
       
  1072 						INFO_PRINTF1(_L("DISABLED"));
       
  1073 
       
  1074 					result=logger.Start();//C.A. previously:result=logger.StartOutputting();
       
  1075 					if(result!=KErrNone)
       
  1076 						INFO_PRINTF2(_L("ulogger server didn't start, with error %d"), result);
       
  1077 
       
  1078 					/*****do the tracing**************/
       
  1079 
       
  1080 #ifdef TE_UPT_TRACE_ENABLED
       
  1081 		OstStatus = 1;
       
  1082 		INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
  1083 #else
       
  1084 		OstStatus = 0;
       
  1085 		INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
  1086 #endif
       
  1087 					iLoggedTraces.Reset();
       
  1088 					iSentTraces.Reset();
       
  1089 					bool ret=0;
       
  1090 					TTraceContext attributes(KComponentId, KGroupId, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1091 					ret = OstTrace(attributes, KTraceId);
       
  1092 
       
  1093 					if(ret==0&&OstStatus)
       
  1094 						{
       
  1095 						SetBlockResult(EFail);
       
  1096 						INFO_PRINTF1(_L("logging over filters that have been set (both sec and prim) is not occuring. Fail"));
       
  1097 						}
       
  1098 					else
       
  1099 						{
       
  1100 						if (ret==1&&OstStatus)
       
  1101 							{
       
  1102 							//create trace information object
       
  1103 							StoreTraceInfo(EFalse,(TUPTApiUsed)0,KComponentId, KGroupId,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1104 							}
       
  1105 						}
       
  1106 
       
  1107 					TTraceContext attr1(KComponentId + 1, KGroupId + 1, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1108 					ret = OstTrace(attr1, KTraceId);
       
  1109 					if(ret==1)
       
  1110 					{
       
  1111 						SetBlockResult(EFail);
       
  1112 						INFO_PRINTF1(_L("logging over filters that have not been set is occuring. Fail"));
       
  1113 					}
       
  1114 					TTraceContext attr2(KComponentId + 2, KGroupId, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1115 					ret = OstTrace(attr2, KTraceId);
       
  1116 					if(ret==0&&OstStatus)
       
  1117 					{
       
  1118 						SetBlockResult(EFail);
       
  1119 						INFO_PRINTF1(_L("logging over filters that have been set (both sec+2 and prim) is not occuring. Fail"));
       
  1120 					}
       
  1121 					else
       
  1122 						{
       
  1123 						if (ret==1&&OstStatus)
       
  1124 							{
       
  1125 							//create trace information object
       
  1126 							StoreTraceInfo(EFalse,(TUPTApiUsed)0,KComponentId+2, KGroupId,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1127 							}
       
  1128 						}
       
  1129 
       
  1130 					TTraceContext attr3(KComponentId, KGroupId + 2, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1131 					ret = OstTrace(attr3, KTraceId);
       
  1132 					if(ret==0&&OstStatus)
       
  1133 					{
       
  1134 						SetBlockResult(EFail);
       
  1135 						INFO_PRINTF1(_L("logging over filters that have been set (both sec and prim+2) is not occuring. Fail"));
       
  1136 					}
       
  1137 
       
  1138 					else
       
  1139 						{
       
  1140 						if (ret==1&&OstStatus)
       
  1141 							{
       
  1142 							//create trace information object
       
  1143 							StoreTraceInfo(EFalse,(TUPTApiUsed)0,KComponentId, KGroupId+2,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1144 							}
       
  1145 						}
       
  1146 
       
  1147 					TTraceContext attr4(KComponentId + 2, KGroupId + 2, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1148 					ret = OstTrace(attr4, KTraceId);
       
  1149 					if(ret==0&&OstStatus)
       
  1150 					{
       
  1151 						SetBlockResult(EFail);
       
  1152 						INFO_PRINTF1(_L("logging over filters that have been set (both sec+2 and prim+2) is not occuring. Fail"));
       
  1153 					}
       
  1154 					else
       
  1155 						{
       
  1156 						if (ret==1&&OstStatus)
       
  1157 							{
       
  1158 							//create trace information object
       
  1159 							StoreTraceInfo(EFalse,(TUPTApiUsed)0,KComponentId+2, KGroupId+2,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1160 							}
       
  1161 						}
       
  1162 
       
  1163 					INFO_PRINTF1(_L("checking KGroupId i KComponentId"));
       
  1164 					TBuf<32> b;
       
  1165 					b.AppendFormat(_L("%d and %d"), KGroupId+2, KComponentId+1);
       
  1166 					INFO_PRINTF1(b);
       
  1167 					TTraceContext attr5(KComponentId + 1, KGroupId + 2, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1168 					ret = OstTrace(attr5, KTraceId);
       
  1169 					if(ret==1)
       
  1170 					{
       
  1171 						SetBlockResult(EFail);
       
  1172 						INFO_PRINTF1(_L("logging over filters that have not been set (the sec) is occuring. Fail"));
       
  1173 					}
       
  1174 					TTraceContext attr6(KComponentId, KGroupId + 1, iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1175 					ret = OstTrace(attr6, KTraceId);
       
  1176 					if(ret==1)
       
  1177 					{
       
  1178 						SetBlockResult(EFail);
       
  1179 						INFO_PRINTF1(_L("logging over filters that have not been set (the prim) is occuring. Fail"));
       
  1180 					}
       
  1181 
       
  1182 
       
  1183 					/************** Stop Logging to File****************/
       
  1184 
       
  1185 					result=logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
  1186 					if(result!=KErrNone)
       
  1187 					{
       
  1188 						INFO_PRINTF2(_L("Call to Ulogger.StopOutputting() has failed with error %d"), result);
       
  1189 					}
       
  1190 					else
       
  1191 						if(OstStatus)
       
  1192 						{
       
  1193 						if(!ReadFromLogFile(KmultTextvalue))
       
  1194 							{
       
  1195 							result=CompareTraces();
       
  1196 							if(result)
       
  1197 								INFO_PRINTF2(_L("ERROR: Error when comparing traces, error %i"), result);
       
  1198 								//prob set the test step result here
       
  1199 							}
       
  1200 						}
       
  1201 
       
  1202 					if(multsetprimfilter)
       
  1203 					{
       
  1204 						delete(multsetprimfilter);
       
  1205 						multsetprimfilter=NULL;
       
  1206 					}
       
  1207 				}
       
  1208 			configIni.Clear(logger);
       
  1209 			}
       
  1210 			else
       
  1211 				INFO_PRINTF1(_L("adding file as output plugin failed"));
       
  1212 			if(result==0&&BlockResult()==EPass)
       
  1213 					SetBlockResult(EPass);
       
  1214 			else
       
  1215 					SetBlockResult(EFail);
       
  1216 			INFO_PRINTF1(_L("Multiple logging to file with user side tracing has been tested - check output log. It should contain four lines of tracing of type, (sec,prim), (sec+2, prim), (sec, prim+2), (sec+2, prim+2)"));
       
  1217 		}
       
  1218 		if(setprimfilter)
       
  1219 		{
       
  1220 			delete(setprimfilter);
       
  1221 			setprimfilter=NULL;
       
  1222 		}
       
  1223 		INFO_PRINTF1(_L("Now shutdown the ulogger server session"));
       
  1224 	    logger.Close();
       
  1225 
       
  1226 		iLoggedTraces.Reset();
       
  1227 		iSentTraces.Reset();
       
  1228 #ifdef SysStartTest
       
  1229 		if(SysStartResult!=KErrInUse)
       
  1230 			SetBlockResult(EFail);
       
  1231 #endif
       
  1232 		//  **************   Block end ****************
       
  1233 		}
       
  1234 	  return ETrue;
       
  1235 	}
       
  1236 
       
  1237 /*******************************************************************************/
       
  1238 /*********************************Kernel Side Logging Test**********************/
       
  1239 /*******************************************************************************/
       
  1240 
       
  1241 CTCMKernelLoggingWrapper::~CTCMKernelLoggingWrapper()
       
  1242 /**
       
  1243  * Destructor
       
  1244  */
       
  1245 	{
       
  1246 	}
       
  1247 
       
  1248 CTCMKernelLoggingWrapper::CTCMKernelLoggingWrapper()
       
  1249 /**
       
  1250  * Constructor
       
  1251  */
       
  1252 	{
       
  1253 	}
       
  1254 
       
  1255 
       
  1256 
       
  1257 CTCMKernelLoggingWrapper* CTCMKernelLoggingWrapper::NewLC()
       
  1258 	{
       
  1259 	CTCMKernelLoggingWrapper* self = new (ELeave)CTCMKernelLoggingWrapper();
       
  1260 	CleanupStack::PushL(self);
       
  1261 	self->ConstructL();
       
  1262 	return self;
       
  1263 	}
       
  1264 
       
  1265 CTCMKernelLoggingWrapper* CTCMKernelLoggingWrapper::NewL()
       
  1266 	{
       
  1267 	CTCMKernelLoggingWrapper* self=CTCMKernelLoggingWrapper::NewLC();
       
  1268 	CleanupStack::Pop(); // self;
       
  1269 	return self;
       
  1270 	}
       
  1271 
       
  1272 void CTCMKernelLoggingWrapper::ConstructL()
       
  1273 	{
       
  1274 	}
       
  1275 
       
  1276 TAny* CTCMKernelLoggingWrapper::GetObject()
       
  1277 	{
       
  1278 	return NULL;
       
  1279 	}
       
  1280 
       
  1281 TBool CTCMKernelLoggingWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
  1282 					const TTEFSectionName& /*aSection*/, 
       
  1283 					const TInt /*aAsyncErrorIndex*/)
       
  1284 	{
       
  1285 
       
  1286 	  if (BlockResult()==EPass)
       
  1287 		{
       
  1288 		TApiRunResults apiRunResults;
       
  1289 		TRunConfigurer::Init(apiRunResults);
       
  1290 
       
  1291 		//  ************** Delete the Block, the block start ****************
       
  1292 
       
  1293 			INFO_PRINTF1(_L("About to test ulogger start with one primary and one secondary, kernel side"));  //Block start
       
  1294 			TInt result=0;
       
  1295 			RULogger logger;
       
  1296 			result=logger.Connect();
       
  1297         	INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
  1298             if (result!=KErrNone)
       
  1299             {
       
  1300             INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
  1301             for (TInt i=2; i<12;i++)
       
  1302                {
       
  1303                User::After(1000);
       
  1304                result = logger.Connect();
       
  1305                INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
  1306                if (result==KErrNone)
       
  1307                     {
       
  1308                     break;
       
  1309                     }
       
  1310                }
       
  1311             }
       
  1312 			CClearConfig configIni;
       
  1313 			configIni.Clear(logger);
       
  1314 			CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
  1315 			setprimfilter->AppendL(KGroupId);
       
  1316 			RArray<TUint32> setsecondfilter;
       
  1317 			setsecondfilter.Append((TUint32) KComponentId);
       
  1318 			logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*setprimfilter);
       
  1319 			logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(setsecondfilter);
       
  1320 			INFO_PRINTF1(_L("about to set file as output plugin"));
       
  1321 			//NB: this of course assumes that the plugin functionality works which is tested more rigorously in the plugin test step
       
  1322 
       
  1323 			_LIT(KTextvalue, "C:\\logs\\ULoggerKernelLoggingTest.utf");
       
  1324 #ifdef TE_UPT_TRACE_ENABLED
       
  1325 			EmptyFile(KTextvalue);
       
  1326 #endif
       
  1327 			if(result==0)
       
  1328 			{
       
  1329 				INFO_PRINTF1(_L("file set as output plugin ok"));
       
  1330 				_LIT8(KTextmedia,"uloggerfileplugin");
       
  1331 				TPtrC8 mediaptr(KTextmedia);
       
  1332 				result=logger.ActivateOutputPlugin(mediaptr);//C.A. previously:result=logger.SetActiveOutputPlugin(mediaptr);
       
  1333 				if(result==0||result==-11)
       
  1334 				{	INFO_PRINTF1(_L("file set as active output plugin ok"));
       
  1335 					TPluginConfiguration setPluginConfigs;
       
  1336 					setPluginConfigs.SetKey(KTextsetting);
       
  1337 					setPluginConfigs.SetValue(KTextvalue);
       
  1338 					result=logger.SetPluginConfigurations(mediaptr, setPluginConfigs);
       
  1339 					if(result==0)
       
  1340 						INFO_PRINTF1(_L("output plugin settings set ok"));
       
  1341 					else
       
  1342 						INFO_PRINTF1(_L("setting output plugin settings failed"));
       
  1343 				}
       
  1344 				else
       
  1345 					INFO_PRINTF1(_L("file not set as active output plugin - failed"));
       
  1346 			}
       
  1347 			else
       
  1348 				INFO_PRINTF1(_L("add file as output plugin failed"));
       
  1349 
       
  1350 			if(result==0)
       
  1351 			{
       
  1352 				/************** Start Logging to File****************/
       
  1353 				iLoggedTraces.Reset();
       
  1354 				iSentTraces.Reset();
       
  1355 				TInt ret=KErrNone;
       
  1356 				logger.Start();//C.A. previously:logger.StartOutputting();
       
  1357 				/*test kernel side nonstatic*/
       
  1358 				TInt tracetag=0;
       
  1359 				INFO_PRINTF1(_L("Test kernel side nonstatic Ost methods"));
       
  1360 				for(tracetag=EUptKernelTrace; tracetag!=EUptKernelIsTraceActive&&ret==KErrNone;tracetag++)
       
  1361 				{
       
  1362 				//to remove the big traces (>80 bytes) for now.
       
  1363 				//if((tracetag!=EUptKernelTraceTAnyBigStruct)&&(tracetag!=EUptKernelTraceTAnyHugeStruct)&&(tracetag!=EUptKernelTraceTemplatedBigStruct)&&(tracetag!=EUptKernelTraceTemplatedHugeStruct))
       
  1364 					{
       
  1365 					iApiRunConfig.iApiId = tracetag;
       
  1366 					ret = 1;
       
  1367 					ret = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
  1368 					INFO_PRINTF3(_L("Ost kernel macro %d has been executed with return value %d"), tracetag, ret);
       
  1369 
       
  1370 					//storing trace information for checking later
       
  1371 					if(ret==KErrNone)
       
  1372 						{
       
  1373 						StoreTraceInfo(ETrue,(TUPTApiUsed)tracetag,0, 0,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1374 						}
       
  1375 					}
       
  1376 				}
       
  1377 
       
  1378 				ret=KErrNone;
       
  1379 				/*test kernel side static*/
       
  1380 				INFO_PRINTF1(_L("Test kernel side static Ost methods"));
       
  1381 				for(tracetag=EUptKernelTrace; tracetag!=EUptKernelIsTraceActive&&ret==KErrNone;tracetag++)
       
  1382 				{
       
  1383 				//to remove the big traces (>80 bytes) for now.
       
  1384 				//if((tracetag!=EUptKernelTraceTAnyBigStruct)&&(tracetag!=EUptKernelTraceTAnyHugeStruct)&&(tracetag!=EUptKernelTraceTemplatedBigStruct)&&(tracetag!=EUptKernelTraceTemplatedHugeStruct))
       
  1385 					{
       
  1386 					iApiRunConfig.iApiId = tracetag;
       
  1387 					ret = 1;
       
  1388 					ret = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
  1389 					INFO_PRINTF3(_L("Ost kernel macro %d has been executed with return value %d"), tracetag, ret);
       
  1390 
       
  1391 					//storing trace information for checking later
       
  1392 					if(ret==KErrNone)
       
  1393 						{
       
  1394 						StoreTraceInfo(ETrue,(TUPTApiUsed)tracetag,0, 0,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1395 						}
       
  1396 					}
       
  1397 
       
  1398 				}
       
  1399 
       
  1400 				ret=KErrNone;
       
  1401 
       
  1402 
       
  1403 
       
  1404 #ifdef SYMBIAN_TRACE_ENABLE
       
  1405 		INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
  1406 #else
       
  1407 		INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
  1408 #endif
       
  1409 				/************** Stop Logging to File****************/
       
  1410 
       
  1411 				result=logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
  1412 				if(result!=KErrNone)
       
  1413 					INFO_PRINTF2(_L("Call to Ulogger.StopOutputting() has failed with err %d"), result);
       
  1414 			}
       
  1415 			else
       
  1416 				INFO_PRINTF1(_L("adding file as output plugin failed"));
       
  1417 			if(result==0)
       
  1418 				{
       
  1419 				SetBlockResult(EPass);
       
  1420 				//check trace content here
       
  1421 				if(!ReadFromLogFile(KTextvalue))
       
  1422 					{
       
  1423 					result=CompareTraces();
       
  1424 					if(result!=KErrNone)
       
  1425 						{
       
  1426 						INFO_PRINTF2(_L("ERROR: Error when comparing traces, error %i"), result);
       
  1427 						SetBlockResult(EFail);
       
  1428 						}
       
  1429 					else
       
  1430 						SetBlockResult(EPass);
       
  1431 					//prob set the test step result here
       
  1432 					}
       
  1433 				}
       
  1434 			else
       
  1435 					SetBlockResult(EFail);
       
  1436 			INFO_PRINTF1(_L("Simple logging to file has been tested with kernel side tracing- check output log"));
       
  1437 
       
  1438 			/***************************negative test***********************/
       
  1439 			_LIT(KnegTextvalue, "C:\\logs\\ULoggerKernelNegativeLoggingTest.utf");
       
  1440 #ifdef TE_UPT_TRACE_ENABLED
       
  1441 			EmptyFile(KnegTextvalue);
       
  1442 #endif
       
  1443 			//empty out arrays of previously sent and logged traces
       
  1444 			iLoggedTraces.Reset();
       
  1445 			iSentTraces.Reset();
       
  1446 
       
  1447 			if(BlockResult()==EPass)
       
  1448 			{
       
  1449 				INFO_PRINTF1(_L("Now do some negative logging testing."));
       
  1450 				if(result==KErrNone)
       
  1451 				{
       
  1452 					INFO_PRINTF1(_L("file set as output plugin ok"));
       
  1453 					_LIT8(KTextmedia,"uloggerfileplugin");
       
  1454 					TPtrC8 mediaptr(KTextmedia);
       
  1455 					if(result==0)
       
  1456 					{
       
  1457 						INFO_PRINTF1(_L("file set as active output plugin ok"));
       
  1458 						TPluginConfiguration negSetPluginConfigs;
       
  1459 						negSetPluginConfigs.SetKey(KTextsetting);
       
  1460 						negSetPluginConfigs.SetValue(KnegTextvalue);
       
  1461 						result=logger.SetPluginConfigurations(mediaptr, negSetPluginConfigs);
       
  1462 						if(result==0)
       
  1463 							INFO_PRINTF1(_L("output plugin settings set ok"));
       
  1464 						else
       
  1465 							INFO_PRINTF1(_L("setting output plugin settings failed"));
       
  1466 					}
       
  1467 					else
       
  1468 						INFO_PRINTF1(_L("file not set as active output plugin - failed"));
       
  1469 
       
  1470 					/**************Now Change the filter settings********/
       
  1471 
       
  1472 					CArrayFixFlat<TUint8> *removeprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
  1473 					removeprimfilter->AppendL(setprimfilter->At(0));
       
  1474 					RArray<TUint32> removesecondfilter;
       
  1475 					removesecondfilter.Append(setsecondfilter[0]);
       
  1476 					result=logger.SetPrimaryFiltersEnabled(*removeprimfilter,EFalse);//C.A. previously:result=logger.DisableClassifications(*removeprimfilter);
       
  1477 					if(result==0)
       
  1478 					{
       
  1479 						INFO_PRINTF1(_L("Call to removeprimary has passed"));
       
  1480 					}
       
  1481 					result=logger.SetSecondaryFiltersEnabled(removesecondfilter,EFalse);//C.A. previously:result=logger.DisableModuleUids(removesecondfilter);
       
  1482 					if(result==0)
       
  1483 					{
       
  1484 						INFO_PRINTF1(_L("Call to removesecondary has passed"));
       
  1485 					}
       
  1486 					CArrayFixFlat<TUint8> *newsetprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
  1487 					newsetprimfilter->AppendL((TUint8)(KGroupId+2));
       
  1488 					RArray<TUint32> newsetsecondfilter;
       
  1489 					newsetsecondfilter.Append((TUint32)(KComponentId+2));
       
  1490 					logger.SetPrimaryFiltersEnabled(*newsetprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*newsetprimfilter);
       
  1491 					logger.SetSecondaryFiltersEnabled(newsetsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(newsetsecondfilter);
       
  1492 					if(result==0)
       
  1493 					{
       
  1494 						logger.Start();//C.A. previously:logger.StartOutputting();
       
  1495 						INFO_PRINTF1(_L("now step over some Ost statements for negative testing on the kernel side"));
       
  1496 						iApiRunConfig.iApiId = UPTKernelNegativeFunctionalityTest;
       
  1497 						result = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
  1498 					}
       
  1499 					result=logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
  1500 					if(result!=0)
       
  1501 					{
       
  1502 						INFO_PRINTF1(_L("Call to Ulogger.StopOutputting() has failed"));
       
  1503 					}
       
  1504 					if(newsetprimfilter)
       
  1505 					{
       
  1506 						delete(newsetprimfilter);
       
  1507 						newsetprimfilter=NULL;
       
  1508 					}
       
  1509 				}
       
  1510 				else
       
  1511 					INFO_PRINTF1(_L("Incorrect error code when trying to add file as a plug-in when it already exists"));
       
  1512 				if(result==0&&BlockResult()==EPass)
       
  1513 						SetBlockResult(EPass);
       
  1514 				else
       
  1515 						SetBlockResult(EFail);
       
  1516 				INFO_PRINTF1(_L("Simple negative logging to file has been tested - check output log"));
       
  1517 		}
       
  1518 
       
  1519 		/***************************multiple type test***********************/
       
  1520 	   	 // From negative test: primary has been set to KClassification+2 and secondary to KComponentId+2
       
  1521 
       
  1522 		_LIT(KmultTextvalue, "C:\\logs\\ULoggerKernelMultipleLoggingTest.utf");
       
  1523 #ifdef TE_UPT_TRACE_ENABLED
       
  1524 		EmptyFile(KmultTextvalue);
       
  1525 #endif
       
  1526 		if(BlockResult()==EPass)
       
  1527 		{
       
  1528 			INFO_PRINTF1(_L("Now do some multiple type logging testing."));
       
  1529 			if(result==0)
       
  1530 			{
       
  1531 				INFO_PRINTF1(_L("file set as output plugin ok"));
       
  1532 				_LIT8(KTextmedia,"uloggerfileplugin");
       
  1533 				TPtrC8 mediaptr(KTextmedia);
       
  1534 				if(result==0)
       
  1535 				{	INFO_PRINTF1(_L("file set as active output plugin ok"));
       
  1536 					TPluginConfiguration setPluginConfigs;
       
  1537 					setPluginConfigs.SetKey(KTextsetting);
       
  1538 					setPluginConfigs.SetValue(KmultTextvalue);
       
  1539 					result=logger.SetPluginConfigurations(mediaptr, setPluginConfigs);
       
  1540 					if(result==0)
       
  1541 						INFO_PRINTF1(_L("output plugin settings set ok"));
       
  1542 					else
       
  1543 						INFO_PRINTF1(_L("setting output plugin settings failed"));
       
  1544 				}
       
  1545 				else
       
  1546 					INFO_PRINTF1(_L("file not set as active output plugin - failed"));
       
  1547 				if(result==0)
       
  1548 				{
       
  1549 				/******************reset filters and change call for multiple logging*****/
       
  1550 
       
  1551 					CArrayFixFlat<TUint8> *multsetprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
  1552 					multsetprimfilter->AppendL(KGroupId);
       
  1553 					RArray<TUint32> multsetsecondfilter;
       
  1554 					multsetsecondfilter.Append((TUint32) (KComponentId));
       
  1555 					logger.SetPrimaryFiltersEnabled(*multsetprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*multsetprimfilter);
       
  1556 					logger.SetSecondaryFiltersEnabled(multsetsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(multsetsecondfilter);
       
  1557 					INFO_PRINTF1(_L("Now given the two sets of set filters, step over traces of each type, some with matching primary but not secondary and vice versa"));
       
  1558 					result=logger.Start();//C.A. previously:result=logger.StartOutputting();
       
  1559 					if(result!=KErrNone)
       
  1560 						INFO_PRINTF2(_L("ulogger server didn't start, with error %d"), result);
       
  1561 					/*****do the tracing**************/
       
  1562 					iApiRunConfig.iApiId = UPTKernelMultipleFunctionalityTest;
       
  1563 					result = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
  1564 					result=logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
  1565 					if(result!=KErrNone)
       
  1566 					{
       
  1567 						INFO_PRINTF2(_L("Call to Ulogger.StopOutputting() has failed with error %d"), result);
       
  1568 					}
       
  1569 					if(multsetprimfilter)
       
  1570 					{
       
  1571 						delete(multsetprimfilter);
       
  1572 						multsetprimfilter=NULL;
       
  1573 					}
       
  1574 				}
       
  1575 			}
       
  1576 			else
       
  1577 				INFO_PRINTF1(_L("adding file as output plugin failed"));
       
  1578 			if(result==0&&BlockResult()==EPass)
       
  1579 					SetBlockResult(EPass);
       
  1580 			else
       
  1581 					SetBlockResult(EFail);
       
  1582 			INFO_PRINTF1(_L("Multiple logging to file with kernel side tracing has been tested - check output log. It should contain four lines of tracing of type, (sec,prim), (sec+2, prim), (sec, prim+2), (sec+2, prim+2)"));
       
  1583 			configIni.Clear(logger);
       
  1584 		}
       
  1585 		if(setprimfilter)
       
  1586 		{
       
  1587 			delete(setprimfilter);
       
  1588 			setprimfilter=NULL;
       
  1589 		}
       
  1590 		INFO_PRINTF1(_L("Now shutdown the ulogger server session"));
       
  1591 	    logger.Close();
       
  1592 		//  **************   Block end ****************
       
  1593 		}
       
  1594 	  return ETrue;
       
  1595 	}
       
  1596 
       
  1597 
       
  1598 
       
  1599 /*******************************************************************************/
       
  1600 /*********************************Printf Test***************************/
       
  1601 /*******************************************************************************/
       
  1602 
       
  1603 CTCMPrintfLoggingWrapper::~CTCMPrintfLoggingWrapper()
       
  1604 /**
       
  1605  * Destructor
       
  1606  */
       
  1607 	{
       
  1608 	}
       
  1609 
       
  1610 CTCMPrintfLoggingWrapper::CTCMPrintfLoggingWrapper()
       
  1611 /**
       
  1612  * Constructor
       
  1613  */
       
  1614 	{
       
  1615 	}
       
  1616 
       
  1617 
       
  1618 CTCMPrintfLoggingWrapper* CTCMPrintfLoggingWrapper::NewLC()
       
  1619 	{
       
  1620 	CTCMPrintfLoggingWrapper* self = new (ELeave)CTCMPrintfLoggingWrapper();
       
  1621 	CleanupStack::PushL(self);
       
  1622 	self->ConstructL();
       
  1623 	return self;
       
  1624 	}
       
  1625 
       
  1626 CTCMPrintfLoggingWrapper* CTCMPrintfLoggingWrapper::NewL()
       
  1627 	{
       
  1628 	CTCMPrintfLoggingWrapper* self=CTCMPrintfLoggingWrapper::NewLC();
       
  1629 	CleanupStack::Pop(); // self;
       
  1630 	return self;
       
  1631 	}
       
  1632 
       
  1633 void CTCMPrintfLoggingWrapper::ConstructL()
       
  1634 	{
       
  1635 	}
       
  1636 
       
  1637 TAny* CTCMPrintfLoggingWrapper::GetObject()
       
  1638 	{
       
  1639 	return NULL;
       
  1640 	}
       
  1641 TBool CTCMPrintfLoggingWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
  1642 					const TTEFSectionName& /*aSection*/, 
       
  1643 					const TInt /*aAsyncErrorIndex*/)
       
  1644 	{
       
  1645 	  if (BlockResult()==EPass)
       
  1646 		{
       
  1647 		TApiRunResults apiRunResults;
       
  1648 		TRunConfigurer::Init(apiRunResults);
       
  1649 		User::After(1000);
       
  1650 		//  ************** Delete the Block, the block start ****************
       
  1651 			INFO_PRINTF1(_L("About to test ulogger printf tracing with one primary and one secondary"));  //Block start
       
  1652 			TInt result=0;
       
  1653 			RULogger logger;
       
  1654 			result = logger.Connect();
       
  1655 			INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
  1656 		 	if (result!=KErrNone)
       
  1657 		 	    {
       
  1658      			INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
  1659             	for (TInt i=2; i<12;i++)
       
  1660                    {
       
  1661                    User::After(1000);
       
  1662                    result = logger.Connect();
       
  1663                    INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
  1664                    if (result==KErrNone)
       
  1665 						{
       
  1666                        	break;
       
  1667 						}
       
  1668                    }
       
  1669 		 	    }
       
  1670 			CClearConfig configIni;
       
  1671 			configIni.Clear(logger);
       
  1672 			CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
  1673 			setprimfilter->AppendL(KGroupId);
       
  1674 			RArray<TUint32> setsecondfilter;
       
  1675 			setsecondfilter.Append((TUint32) KComponentId);
       
  1676 			result = logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*setprimfilter);
       
  1677 			INFO_PRINTF2(_L("Settting primary filter %d"), result);
       
  1678 			result = logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(setsecondfilter);
       
  1679 			result =0;
       
  1680 			INFO_PRINTF2(_L("Settting secondary filter %d"), result);
       
  1681 			INFO_PRINTF1(_L("about to set file as output plugin"));
       
  1682 			//NB: this of course assumes that the plugin functionality works which is tested more rigorously in the plugin test step
       
  1683 
       
  1684 			_LIT(KTextsetting, "output_path");
       
  1685 			_LIT(KTextvalue, "C:\\logs\\ULoggerPrintfTest.utf");
       
  1686 #ifdef TE_UPT_TRACE_ENABLED
       
  1687 			EmptyFile(KTextvalue);
       
  1688 #endif
       
  1689 			if(result==0)
       
  1690 			{
       
  1691 				INFO_PRINTF1(_L("file set as output plugin ok"));
       
  1692 				_LIT8(KTextmedia,"uloggerfileplugin");
       
  1693 				TPtrC8 mediaptr(KTextmedia);
       
  1694 				result=logger.ActivateOutputPlugin(mediaptr);//C.A. previously:result=logger.SetActiveOutputPlugin(mediaptr);
       
  1695 				if(result==0||result==-11)
       
  1696 				{	INFO_PRINTF1(_L("file set as active output plugin ok"));
       
  1697 					TPluginConfiguration pluginConfig;
       
  1698 					pluginConfig.SetKey(KTextsetting);
       
  1699 					pluginConfig.SetValue(KTextvalue);
       
  1700 					result=logger.SetPluginConfigurations(mediaptr, pluginConfig);
       
  1701 					if(result==0)
       
  1702 						INFO_PRINTF1(_L("output plugin settings set ok"));
       
  1703 					else
       
  1704 						INFO_PRINTF1(_L("setting output plugin settings failed"));
       
  1705 				}
       
  1706 				else
       
  1707 					INFO_PRINTF1(_L("file not set as active output plugin - failed"));
       
  1708 			}
       
  1709 			else
       
  1710 				INFO_PRINTF1(_L("add file as output plugin failed"));
       
  1711 			if(result==0)
       
  1712 			{
       
  1713 				/************** Start Logging to File****************/
       
  1714 				/************* Testing NONSTATIC printf methods**********************/
       
  1715 
       
  1716 				result=logger.Start();//C.A. previously:result=logger.StartOutputting();
       
  1717 				INFO_PRINTF2(_L("ulogger start returns error %d"), result);
       
  1718 				INFO_PRINTF1(_L("now step over some Ost printf statements"));
       
  1719 				int tracetag =0;
       
  1720 				TBool ret=1;
       
  1721 
       
  1722 				INFO_PRINTF1(_L("******Testing user side NONSTATIC Trace Printf Methods******"));
       
  1723 
       
  1724 				ret=KErrNone;
       
  1725 
       
  1726 				bool OstStatus=0;
       
  1727 #ifdef TE_UPT_TRACE_ENABLED
       
  1728 		OstStatus = 1;
       
  1729 		INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
  1730 #else
       
  1731 		OstStatus = 0;
       
  1732 		INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
  1733 #endif
       
  1734 
       
  1735 //				if((ret&&OstStatus)||(!ret&&!OstStatus))
       
  1736 //				{
       
  1737 //					result=0;
       
  1738 //					INFO_PRINTF1(_L("Tracing printfs carried out succesfully"));
       
  1739 //					if(ret==1)
       
  1740 //						INFO_PRINTF1(_L("logfile should contain appropriate printf tracing"));
       
  1741 //					else
       
  1742 //						INFO_PRINTF1(_L("logfile should be empty of printf trace statements"));
       
  1743 //				}
       
  1744 //				else
       
  1745 //				{
       
  1746 //					result=1;
       
  1747 //					INFO_PRINTF2(_L("Tracing Failed on Ost printf macro %d"), tracetag);
       
  1748 //				}
       
  1749 
       
  1750 				/************* Now Test STATIC printf methods**********************/
       
  1751 
       
  1752 				INFO_PRINTF1(_L("******Testing user side STATIC Trace Printf Methods******"));
       
  1753 
       
  1754 				ret=KErrNone;
       
  1755 				/*test user side static printf's*/
       
  1756 				for(tracetag=EUptPrintTDesC8_big; tracetag!=EUptPrintfTRefByValueTDesC16+1&&ret==KErrNone;tracetag++)
       
  1757 				{
       
  1758 				iApiRunConfig.iApiId = tracetag;
       
  1759 				ret = 1;
       
  1760 				ret = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
  1761 				INFO_PRINTF3(_L("Ost printf function %d has been executed with return value %d"), tracetag, ret);
       
  1762 
       
  1763 				if(ret==KErrNone&&OstStatus)
       
  1764 					{
       
  1765 					StoreTraceInfo(ETrue,(TUPTApiUsed)tracetag,0, 0,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1766 					}
       
  1767 				}
       
  1768 
       
  1769 #ifdef TE_UPT_TRACE_ENABLED
       
  1770 		OstStatus = 1;
       
  1771 		INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
  1772 #else
       
  1773 		OstStatus = 0;
       
  1774 		INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
  1775 #endif
       
  1776 
       
  1777 		result=logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
  1778 		if (result!=KErrNone)
       
  1779 			INFO_PRINTF1(_L("Ulogger has not been stopped succesfully"));
       
  1780 
       
  1781 				if((!ret&&OstStatus)||(!ret&&!OstStatus))
       
  1782 				{
       
  1783 					result=0;
       
  1784 					INFO_PRINTF1(_L("Tracing printfs carried out succesfully"));
       
  1785 					if(ret==0)
       
  1786 						{
       
  1787 						INFO_PRINTF1(_L("logfile should contain appropriate printf tracing"));
       
  1788 						if(OstStatus)
       
  1789 						    {
       
  1790                             if(!ReadFromLogFile(KTextvalue))
       
  1791                                 {
       
  1792                                 result=CompareTraces();
       
  1793                                 if(result)
       
  1794                                     INFO_PRINTF2(_L("ERROR: Error when comparing traces, error %i"), result);
       
  1795                                 //prob set the test step result here
       
  1796                                 }
       
  1797 						    }
       
  1798 						}
       
  1799 					else
       
  1800 						INFO_PRINTF1(_L("logfile should be empty of printf trace statements"));
       
  1801 				}
       
  1802 				else
       
  1803 				{
       
  1804 					result=1;
       
  1805 					INFO_PRINTF2(_L("Tracing Failed on Ost printf macro %d"), tracetag);
       
  1806 				}
       
  1807 			}
       
  1808 			if (!result)
       
  1809 			    SetBlockResult(EPass);
       
  1810 			else
       
  1811 			    SetBlockResult(EFail);
       
  1812 		}
       
  1813 	  return ETrue;
       
  1814 	}
       
  1815 
       
  1816 
       
  1817 
       
  1818 /******************************************************************************/
       
  1819 /*********************************Kernel Side Printf Test***************************/
       
  1820 /*******************************************************************************/
       
  1821 
       
  1822 CTCMKernelPrintfLoggingWrapper::~CTCMKernelPrintfLoggingWrapper()
       
  1823 /**
       
  1824  * Destructor
       
  1825  */
       
  1826 	{
       
  1827 	}
       
  1828 
       
  1829 CTCMKernelPrintfLoggingWrapper::CTCMKernelPrintfLoggingWrapper()
       
  1830 /**
       
  1831  * Constructor
       
  1832  */
       
  1833 	{
       
  1834 	}
       
  1835 
       
  1836 
       
  1837 CTCMKernelPrintfLoggingWrapper* CTCMKernelPrintfLoggingWrapper::NewLC()
       
  1838 	{
       
  1839 	CTCMKernelPrintfLoggingWrapper* self = new (ELeave)CTCMKernelPrintfLoggingWrapper();
       
  1840 	CleanupStack::PushL(self);
       
  1841 	self->ConstructL();
       
  1842 	return self;
       
  1843 	}
       
  1844 
       
  1845 CTCMKernelPrintfLoggingWrapper* CTCMKernelPrintfLoggingWrapper::NewL()
       
  1846 	{
       
  1847 	CTCMKernelPrintfLoggingWrapper* self=CTCMKernelPrintfLoggingWrapper::NewLC();
       
  1848 	CleanupStack::Pop(); // self;
       
  1849 	return self;
       
  1850 	}
       
  1851 
       
  1852 void CTCMKernelPrintfLoggingWrapper::ConstructL()
       
  1853 	{
       
  1854 	}
       
  1855 
       
  1856 TAny* CTCMKernelPrintfLoggingWrapper::GetObject()
       
  1857 	{
       
  1858 	return NULL;
       
  1859 	}
       
  1860 TBool CTCMKernelPrintfLoggingWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
  1861 					const TTEFSectionName& /*aSection*/, 
       
  1862 					const TInt /*aAsyncErrorIndex*/)
       
  1863 	{
       
  1864 	  if (BlockResult()==EPass)
       
  1865 		{
       
  1866 		//  ************** Delete the Block, the block start ****************
       
  1867 		INFO_PRINTF1(_L("About to test ulogger start with one primary and one secondary, kernel side printf logging"));  //Block start
       
  1868 		TInt result=0;
       
  1869 		RULogger logger;
       
  1870 		result = logger.Connect();
       
  1871 		CClearConfig configIni;
       
  1872 		INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
  1873 		if (result!=KErrNone)
       
  1874 		    {
       
  1875      		INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
  1876            	for (TInt i=2; i<12;i++)
       
  1877                {
       
  1878                User::After(1000);
       
  1879                result = logger.Connect();
       
  1880                INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
  1881                if (result==KErrNone)
       
  1882 					{
       
  1883                    	break;
       
  1884 					}
       
  1885                }
       
  1886 		    }
       
  1887 
       
  1888 		configIni.Clear(logger);
       
  1889 		CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
  1890 		setprimfilter->AppendL(KGroupId);
       
  1891 		RArray<TUint32> setsecondfilter;
       
  1892 		setsecondfilter.Append((TUint32) KComponentId);
       
  1893 		logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*setprimfilter);
       
  1894 		logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(setsecondfilter);
       
  1895 		INFO_PRINTF1(_L("about to set file as output plugin"));
       
  1896 		//NB: this of course assumes that the plugin functionality works which is tested more rigorously in the plugin test step
       
  1897 		_LIT(KTextvalue, "C:\\logs\\ULoggerKernelPrintfTest.utf");
       
  1898 #ifdef TE_UPT_TRACE_ENABLED
       
  1899 		EmptyFile(KTextvalue);
       
  1900 #endif
       
  1901 		//result=logger.AddOutputPlugin(KTextplugin);
       
  1902 		if(result==0)
       
  1903 			{
       
  1904 			INFO_PRINTF1(_L("file set as output plugin ok"));
       
  1905 			_LIT8(KTextmedia,"uloggerfileplugin");
       
  1906 			TPtrC8 mediaptr(KTextmedia);
       
  1907 			result=logger.ActivateOutputPlugin(mediaptr);//C.A. previously:result=logger.SetActiveOutputPlugin(mediaptr);
       
  1908 			if(result==0||result==-11)
       
  1909 				{
       
  1910 				INFO_PRINTF1(_L("file set as active output plugin ok"));
       
  1911 				TPluginConfiguration setPluginConfigs;
       
  1912 				setPluginConfigs.SetKey(KTextsetting);
       
  1913 				setPluginConfigs.SetValue(KTextvalue);
       
  1914 				result=logger.SetPluginConfigurations(mediaptr, setPluginConfigs);
       
  1915 				if(result==0)
       
  1916 					INFO_PRINTF1(_L("output plugin settings set ok"));
       
  1917 				else
       
  1918 					INFO_PRINTF1(_L("setting output plugin settings failed"));
       
  1919 				}
       
  1920 			else
       
  1921 				INFO_PRINTF1(_L("file not set as active output plugin - failed"));
       
  1922 			}
       
  1923 		else
       
  1924 			INFO_PRINTF1(_L("add file as output plugin failed"));
       
  1925 		//TInt r = KErrNone;
       
  1926 
       
  1927 		if(result==0)
       
  1928 			{
       
  1929 			TApiRunResults apiRunResults;
       
  1930 			TRunConfigurer::Init(apiRunResults);
       
  1931 
       
  1932 			/************** Start Logging to File****************/
       
  1933 
       
  1934 			logger.Start();//C.A. previously:logger.StartOutputting();
       
  1935 			TInt ret=KErrNone;
       
  1936 			INFO_PRINTF1(_L("******Testing kernel side STATIC Trace Printf Methods******"));
       
  1937 			/*test kernel side non static printf's*/
       
  1938 			TInt tracetag = EUptKernelPrintfchar;
       
  1939 			iApiRunConfig.iApiId = tracetag;
       
  1940 			ret = 1;
       
  1941 			ret = iTestTracer.SendTraceL(iApiRunConfig, apiRunResults);
       
  1942 			INFO_PRINTF3(_L("Ost kernel macro %d has been executed with return value %d"), tracetag, ret);
       
  1943 			//empty out array of previously sent and logged traces
       
  1944 			iLoggedTraces.Reset();
       
  1945 			iSentTraces.Reset();
       
  1946 			if (ret==KErrNone)
       
  1947 				{
       
  1948 				StoreTraceInfo(ETrue,(TUPTApiUsed)tracetag,0, 0,iApiRunConfig.iHasContext, iApiRunConfig.iHasProgramCounter);
       
  1949 				}
       
  1950 
       
  1951 #ifdef TE_UPT_TRACE_ENABLED
       
  1952 		INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
  1953 #else
       
  1954 		INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
  1955 #endif
       
  1956 			/************** Stop Logging to File****************/
       
  1957 
       
  1958 			result=logger.Stop();//C.A. previously:result=logger.StopOutputting();
       
  1959 			if(result!=KErrNone)
       
  1960 				INFO_PRINTF2(_L("Call to Ulogger.StopOutputting() has failed with err %d"), result);
       
  1961 
       
  1962 #ifdef TE_UPT_TRACE_ENABLED
       
  1963 			if(!ReadFromLogFile(KTextvalue))
       
  1964 					{
       
  1965 					result=CompareTraces();
       
  1966 					if(result)
       
  1967 						INFO_PRINTF2(_L("ERROR: Error when comparing traces, error %i"), result);
       
  1968 						//prob set the test step result here
       
  1969 					}
       
  1970 #endif
       
  1971 			}
       
  1972 		else
       
  1973 			INFO_PRINTF1(_L("adding file as output plugin failed"));
       
  1974 		if(result==0)
       
  1975 			SetBlockResult(EPass);
       
  1976 		else
       
  1977 			SetBlockResult(EFail);
       
  1978 		INFO_PRINTF1(_L("Simple printf logging to file has been tested with kernel side tracing- check output log"));
       
  1979 
       
  1980 		configIni.Clear(logger);
       
  1981 
       
  1982 		if(setprimfilter)
       
  1983 			{
       
  1984 			delete(setprimfilter);
       
  1985 			setprimfilter=NULL;
       
  1986 			}
       
  1987 		INFO_PRINTF1(_L("Now shutdown the ulogger server session"));
       
  1988 		logger.Close();
       
  1989 		}
       
  1990 
       
  1991 
       
  1992 	//  **************   Block end ****************
       
  1993 
       
  1994 	return ETrue;
       
  1995 	}
       
  1996