traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_functional/src/te_tracecollectorserial.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_tracecollectorserial.cpp
       
    21  @internalTechnology
       
    22 */
       
    23 #include "te_tracecollectorserial.h"
       
    24 #include "te_ostv2integsuite_defs.h"
       
    25 
       
    26 using namespace Ulogger; //CA:added so can use old ulogger api
       
    27 CTCMSerialPluginWrapper::~CTCMSerialPluginWrapper()
       
    28 /**
       
    29  * Destructor
       
    30  */
       
    31 	{
       
    32 	}
       
    33 
       
    34 CTCMSerialPluginWrapper::CTCMSerialPluginWrapper()
       
    35 /**
       
    36  * Constructor
       
    37  */
       
    38 	{
       
    39 	}
       
    40 
       
    41 CTCMSerialPluginWrapper* CTCMSerialPluginWrapper::NewLC()
       
    42 	{
       
    43 	CTCMSerialPluginWrapper* self = new (ELeave)CTCMSerialPluginWrapper();
       
    44 	CleanupStack::PushL(self);
       
    45 	self->ConstructL();
       
    46 	return self;
       
    47 	}
       
    48 
       
    49 CTCMSerialPluginWrapper* CTCMSerialPluginWrapper::NewL()
       
    50 	{
       
    51 	CTCMSerialPluginWrapper* self=CTCMSerialPluginWrapper::NewLC();
       
    52 	CleanupStack::Pop(); // self;
       
    53 	return self;
       
    54 	}
       
    55 
       
    56 void CTCMSerialPluginWrapper::ConstructL()
       
    57 	{
       
    58 	}
       
    59 
       
    60 TAny* CTCMSerialPluginWrapper::GetObject()
       
    61 	{
       
    62 	return NULL;
       
    63 	}
       
    64 
       
    65 TBool CTCMSerialPluginWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
    66 					const TTEFSectionName& /*aSection*/, 
       
    67 					const TInt /*aAsyncErrorIndex*/)
       
    68 	{
       
    69 	    if (BlockResult()==EPass)
       
    70 		{		
       
    71 		//  ************** Delete the Block, the block start ****************
       
    72 		
       
    73 			TInt Result=0;
       
    74 			SetBlockResult(EPass);
       
    75 			INFO_PRINTF1(_L("About to test serial plugin"));  //Block start
       
    76 			RULogger logger;
       
    77 			Result = logger.Connect();
       
    78 			INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), Result);
       
    79                 if (Result!=KErrNone)
       
    80                 {
       
    81                 INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
    82                 for (TInt i=2; i<12;i++)
       
    83                    {
       
    84                    User::After(1000);
       
    85                    Result = logger.Connect();
       
    86                    INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), Result, i);
       
    87                    if (Result==KErrNone)
       
    88                         {
       
    89                         break;
       
    90                         }
       
    91                    }
       
    92                 }
       
    93 			CClearConfig configIni;
       
    94 			configIni.Clear(logger);
       
    95 			CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
    96 			setprimfilter->AppendL(KGroupId);
       
    97 			RArray<TUint32> setsecondfilter;
       
    98 			setsecondfilter.Append((TUint32) KComponentId);
       
    99 			logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*setprimfilter);
       
   100 			logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(setsecondfilter);
       
   101 			_LIT8(KTextmedia,"uloggerserialplugin");
       
   102 			const TPtrC8 mediaptr(KTextmedia);
       
   103 			// test the plugin can be activated
       
   104 			Result=logger.ActivateOutputPlugin(mediaptr);//C.A. previously:Result=logger.SetActiveOutputPlugin(mediaptr);	
       
   105 			if(Result==0||Result==-11)	
       
   106 			{	
       
   107 				INFO_PRINTF1(_L("Serial Plugin active"));		
       
   108 				_LIT(KTextsetting, "output_port");	
       
   109 				_LIT(KTextvalue, "3");
       
   110 				// test setting the plugin settings
       
   111 				TPluginConfiguration pluginConfig;
       
   112 				pluginConfig.SetKey(KTextsetting);
       
   113 				pluginConfig.SetValue(KTextvalue);			
       
   114 				Result=logger.SetPluginConfigurations(mediaptr,pluginConfig);
       
   115 				if(Result==KErrNone)	
       
   116 				{
       
   117 					INFO_PRINTF1(_L("Setting Serial Plugin Settings returns KErrNone but verify set correctly in next step"));
       
   118 				// test that the plugging settings can be retrieved
       
   119 				RPointerArray<TPluginConfiguration> getPluginConfigs;
       
   120 				if(Result==KErrNone)	
       
   121 				{
       
   122 					INFO_PRINTF1(_L("Getting Serial Plugin Settings returns KErrNone but verify got correctly in next step"));
       
   123 					Result=logger.GetPluginConfigurations(mediaptr, getPluginConfigs);
       
   124 					_LIT(KTextChecksetting, "output_port");
       
   125 					_LIT(KTextCheckValue, "3");
       
   126 					// test that the plugging settings retrieved are correct
       
   127 					if(getPluginConfigs.Count()>0)
       
   128 						{
       
   129 						if (!getPluginConfigs[0]->Key().Compare(KTextChecksetting) && !getPluginConfigs[0]->Value().Compare(KTextCheckValue))
       
   130 							{
       
   131 							INFO_PRINTF1(_L("Retrieved serial plugin settings are correct"));
       
   132 							}
       
   133 							else
       
   134 								{		
       
   135 								INFO_PRINTF1(_L("Retrieved serial plugin settings are incorrect"));
       
   136 								SetBlockResult(EFail);
       
   137 								}
       
   138 							Result=logger.Start();//C.A. previously:Result=logger.StartOutputting();
       
   139 							INFO_PRINTF2(_L("ulogger start returns error %d"), Result);
       
   140 							TBool OstStatus=0;
       
   141 #ifndef __WINSCW__	
       
   142 #ifdef TE_UPT_TRACE_ENABLED
       
   143 OstStatus = 1;
       
   144 INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
   145 #else
       
   146 OstStatus = 0;
       
   147 INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
   148 #endif // trace enabled
       
   149 							TTraceContext attrs(KComponentId, KGroupId, KContextId, KPc);						
       
   150 							if(!OstTrace(attrs, KInitialClientFormat, KAny16)&&OstStatus)
       
   151 								{
       
   152 								INFO_PRINTF1(_L("Ost first trace via serial plugin failed"));
       
   153 								SetBlockResult(EFail);
       
   154 								}
       
   155 							TTraceContext attrs1(KComponentId, KGroupId, KContextId, KPc);
       
   156 							if(!OstTrace(attrs1, KInitialClientFormat, KAny16)&&OstStatus)
       
   157 								{
       
   158 								INFO_PRINTF1(_L("Ost second trace writing via serial plugin failed"));
       
   159 								SetBlockResult(EFail);
       
   160 								}
       
   161 #endif	//winscw			
       
   162 							logger.Stop();//C.A. previously:logger.StopOutputting();	
       
   163 						}
       
   164 					else
       
   165 						{		
       
   166 						INFO_PRINTF1(_L("Either SetPluginConfiguration failed or GetPluginConfiguration failed as returned a zero size array"));
       
   167 						SetBlockResult(EFail);
       
   168 						}
       
   169 				}
       
   170 				else
       
   171 				{
       
   172 					INFO_PRINTF1(_L("Failed to get serial Plugin Settings"));
       
   173 					SetBlockResult(EFail);
       
   174 				}
       
   175 				getPluginConfigs.ResetAndDestroy();
       
   176 			}
       
   177 			else
       
   178 			{
       
   179 				INFO_PRINTF1(_L("Serial Plugin Settings error"));
       
   180 				SetBlockResult(EFail);
       
   181 			}					
       
   182 		}
       
   183 		else
       
   184 		{			
       
   185 			INFO_PRINTF1(_L("Serial Plugin error when activated"));
       
   186 			SetBlockResult(EFail);
       
   187 		}		
       
   188 		TBuf8<32>activeplugins;	
       
   189 		_LIT8(KTextmedia1,"uloggerserialplugin");
       
   190 		TBuf8<32> checkplugins(KTextmedia1);
       
   191 		// test the active plugin name can be retrieved
       
   192 		logger.GetActiveOutputPlugin(activeplugins);//C.A. previously:logger.ActiveOutputPlugin(activeplugins);
       
   193 		if (activeplugins.Compare(checkplugins)==0)
       
   194 			INFO_PRINTF1(_L("Got correct active serial plugin"));
       
   195 		else
       
   196 		{
       
   197 			INFO_PRINTF1(_L("Got incorrect active serial plugin"));
       
   198 			SetBlockResult(EFail);
       
   199 		}
       
   200 		// test activating the second plugin
       
   201 		_LIT8(KTextmedia2,"te_fileplugin");
       
   202 		const TPtrC8 mediaptr2(KTextmedia2);
       
   203 		Result=logger.ActivateOutputPlugin(mediaptr2);	//C.A. previously:Result=logger.SetActiveOutputPlugin(mediaptr2);	
       
   204 		if(Result==0)			
       
   205 			INFO_PRINTF1(_L("Second plugin activated correctly"));
       
   206 		else
       
   207 		{
       
   208 			INFO_PRINTF1(_L("Second plugin activation error"));
       
   209 			SetBlockResult(EFail);
       
   210 		}
       
   211 		// test the first plugin can now be removed as it is no longer the active plugin
       
   212 		Result=logger.RemovePluginConfigurations(mediaptr);
       
   213 		if(Result==0)
       
   214 		{	
       
   215 			INFO_PRINTF1(_L("Removed serial Plugin correctly"));
       
   216 		}
       
   217 		else
       
   218 		{
       
   219 			INFO_PRINTF1(_L("Failed to remove serial Plugin"));
       
   220 			SetBlockResult(EFail);
       
   221 		}
       
   222 		logger.Stop();//C.A. previously:logger.StopOutputting();
       
   223 		logger.Close();
       
   224 		INFO_PRINTF1(_L("serial plugin tests complete!"));
       
   225 		
       
   226 		//  **************   Block end ****************
       
   227 		}
       
   228 		
       
   229 	  	return ETrue;
       
   230 	}
       
   231