traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_functional/src/te_buffersizing.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_buffersizing.cpp
       
    21  @internalTechnology
       
    22 */
       
    23 #include "te_buffersizing.h"
       
    24 
       
    25 #include <e32cons.h>
       
    26 #include <e32def.h>
       
    27 #include "te_dataparameters.h"
       
    28 
       
    29 using namespace Ulogger; //CA:added so can use old ulogger api
       
    30 
       
    31 CTCMBufferSizingWrapper::~CTCMBufferSizingWrapper()
       
    32 /**
       
    33  * Destructor
       
    34  */
       
    35 	{
       
    36 	}
       
    37 
       
    38 CTCMBufferSizingWrapper::CTCMBufferSizingWrapper()
       
    39 /**
       
    40  * Constructor
       
    41  */
       
    42 	{
       
    43 	}
       
    44 
       
    45 void CTCMBufferSizingWrapper::writeToBuffer(const TPtrC aLit, TInt aTraceNumber,RULogger* aLogger)
       
    46 	{
       
    47 		_LIT8(KTextmedia,"uloggerfileplugin");
       
    48 		TPtrC8 mediaptr(KTextmedia);
       
    49 		_LIT(KTextsetting, "output_path");
       
    50 		// test setting the plugin settings
       
    51 		TPluginConfiguration setPluginConfigs;
       
    52 		setPluginConfigs.SetKey(KTextsetting);
       
    53 		setPluginConfigs.SetValue(aLit);
       
    54 		aLogger->SetPluginConfigurations( mediaptr, setPluginConfigs);
       
    55 
       
    56 		TBool OstStatus=0;
       
    57 
       
    58 #ifdef TE_UPT_TRACE_ENABLED
       
    59 		OstStatus = 1;
       
    60 		INFO_PRINTF1(_L("TRACING HAS BEEN ENABLED!"));
       
    61 #else
       
    62 		OstStatus = 0;
       
    63 		INFO_PRINTF1(_L("TRACING HAS BEEN DISABLED! All Log files should be empty/not exist"));
       
    64 #endif
       
    65 		if (OstStatus)
       
    66 			EmptyFile(aLit);
       
    67 
       
    68 		aLogger->Start();//C.A. previously:aLogger->StartOutputting();
       
    69 		for(TInt i=0; i!=aTraceNumber; i++)
       
    70 		{
       
    71 			TBool ret=1;
       
    72 			//need to change KPcNotIncluded to KPc so program counter can be included in tests
       
    73 			TTraceContext attrs(KComponentId+i+1, KGroupId, KContextId, KPcNotIncluded);
       
    74 			ret = OstTrace(attrs, KInitialClientFormat, KAny16);
       
    75 			if (ret == 0&&OstStatus==1)
       
    76 			{
       
    77 				INFO_PRINTF2(_L("Trace %d not logged"), aTraceNumber);
       
    78 				SetBlockResult(EFail);
       
    79 			}
       
    80 		}
       
    81 		aLogger->Stop();//C.A. previously:aLogger->StopOutputting();
       
    82 
       
    83 	}
       
    84 
       
    85 
       
    86 
       
    87 CTCMBufferSizingWrapper* CTCMBufferSizingWrapper::NewLC()
       
    88 	{
       
    89 	CTCMBufferSizingWrapper* self = new (ELeave)CTCMBufferSizingWrapper();
       
    90 	CleanupStack::PushL(self);
       
    91 	self->ConstructL();
       
    92 	return self;
       
    93 	}
       
    94 
       
    95 CTCMBufferSizingWrapper* CTCMBufferSizingWrapper::NewL()
       
    96 	{
       
    97 	CTCMBufferSizingWrapper* self=CTCMBufferSizingWrapper::NewLC();
       
    98 	CleanupStack::Pop(); // self;
       
    99 	return self;
       
   100 	}
       
   101 
       
   102 void CTCMBufferSizingWrapper::ConstructL()
       
   103 	{
       
   104 	}
       
   105 
       
   106 TAny* CTCMBufferSizingWrapper::GetObject()
       
   107 	{
       
   108 	return NULL;
       
   109 	}
       
   110 
       
   111 TBool CTCMBufferSizingWrapper::DoCommandL(	const TTEFFunction& /*aCommand*/,
       
   112 					const TTEFSectionName& /*aSection*/, 
       
   113 					const TInt /*aAsyncErrorIndex*/)
       
   114 	{if (BlockResult()==EPass)
       
   115 		{
       
   116 		//AddOutputPlugin
       
   117 		//  ************** Delete the Block, the block start ****************
       
   118 
       
   119 			INFO_PRINTF1(_L("About to test buffer sizing"));  //Block start
       
   120 			RULogger logger;
       
   121 			TInt result=0;
       
   122 			result=logger.Connect();
       
   123         	INFO_PRINTF2(_L("Connection to Ulogger: %d, attempt: 1"), result);
       
   124             if (result!=KErrNone)
       
   125            		{
       
   126             	INFO_PRINTF1(_L("Connection to Ulogger failed. Will try to connect max. 10 times"));
       
   127             	for (TInt i=2; i<12;i++)
       
   128                		{
       
   129                		User::After(1000);
       
   130                		result = logger.Connect();
       
   131                		INFO_PRINTF3(_L("Connection to Ulogger: %d, attempt: %d"), result, i);
       
   132                		if (result==KErrNone)
       
   133                     	{
       
   134                     	break;
       
   135                     	}
       
   136                		}
       
   137             	}
       
   138 			CClearConfig configIni;
       
   139 			configIni.Clear(logger);
       
   140 			logger.SetSecondaryFilteringEnabled(EFalse);//C.A. previously:logger.DisableModuleUidFiltering();
       
   141 			CArrayFixFlat<TUint8> *setprimfilter = new (ELeave)CArrayFixFlat<TUint8>(1);
       
   142 			setprimfilter->AppendL(KGroupId);
       
   143 			RArray<TUint32> setsecondfilter;
       
   144 			setsecondfilter.Append((TUint32) KComponentId);
       
   145 			logger.SetPrimaryFiltersEnabled(*setprimfilter,ETrue);//C.A. previously:logger.EnableClassifications(*setprimfilter);
       
   146 //			logger.SetSecondaryFiltersEnabled(setsecondfilter,ETrue);//C.A. previously:logger.EnableModuleUids(setsecondfilter);
       
   147 			SetBlockResult(EPass);
       
   148 			INFO_PRINTF1(_L("File plugin added"));
       
   149 			_LIT8(KTextmedia,"uloggerfileplugin");
       
   150 			TPtrC8 mediaptr(KTextmedia);
       
   151 			logger.ActivateOutputPlugin(mediaptr);//C.A. previously:logger.SetActiveOutputPlugin(mediaptr);
       
   152 			// write to an average buffer size with a smaller dns as many bytes
       
   153 			// as the buffer can hold
       
   154 			logger.SetBufferSize(1024);
       
   155 			logger.SetNotificationSize(64);
       
   156 			_LIT(KTextvalue1, "C:\\logs\\ULoggerBufferAverage.utf");
       
   157 			const TPtrC valueptr1(KTextvalue1);
       
   158 
       
   159 			INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),1024,64);
       
   160 
       
   161 			writeToBuffer(valueptr1, 64, &logger);
       
   162 			// write to an average buffer size with a smaller dns more bytes
       
   163 			// than the buffer can hold
       
   164 			_LIT(KTextvalue2, "C:\\logs\\ULoggerBufferAverageOverflow.utf");
       
   165 			const TPtrC valueptr2(KTextvalue2);
       
   166 
       
   167 			INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),1024,64);
       
   168 
       
   169 			writeToBuffer(valueptr2, 65, &logger);
       
   170 			// write to a small buffer size with a smaller dns as many bytes
       
   171 			// as the buffer can hold
       
   172 			logger.SetBufferSize(64);
       
   173 			logger.SetNotificationSize(16);
       
   174 			_LIT(KTextvalue5, "C:\\logs\\ULoggerBufferSmall.utf");
       
   175 			const TPtrC valueptr5(KTextvalue5);
       
   176 
       
   177 			INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),64,16);
       
   178 
       
   179 			writeToBuffer(valueptr5, 4, &logger);
       
   180 			// write to a small buffer size with a smaller dns more bytes
       
   181 			// than the buffer can hold
       
   182 			_LIT(KTextvalue6, "C:\\logs\\ULoggerBufferSmallOverflow.utf");
       
   183 			const TPtrC valueptr6(KTextvalue6);
       
   184 
       
   185 			INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),64,16);
       
   186 
       
   187 			writeToBuffer(valueptr6, 5, &logger);
       
   188 			// write to a large buffer size with a smaller dns as many bytes
       
   189 			// as the buffer can hold
       
   190 			logger.SetBufferSize(65535);
       
   191 			logger.SetNotificationSize(1024);
       
   192 			_LIT(KTextvalue9, "C:\\logs\\ULoggerBufferBig.utf");
       
   193 			const TPtrC valueptr9(KTextvalue9);
       
   194 
       
   195 			INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),65535,1024);
       
   196 
       
   197 			writeToBuffer(valueptr9, 4095, &logger);
       
   198 			// write to a large buffer size with a smaller dns more bytes
       
   199 			// than the buffer can hold
       
   200 			_LIT(KTextvalue10, "C:\\logs\\ULoggerBufferBigOverflow.utf");
       
   201 			const TPtrC valueptr10(KTextvalue10);
       
   202 
       
   203 			INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),65535,1024);
       
   204 
       
   205 			writeToBuffer(valueptr10, 4097, &logger);
       
   206 			// write to a larg buffer size with an equal dns as many bytes
       
   207 			// as the buffer can hold
       
   208 			logger.SetNotificationSize(4900);
       
   209 			logger.SetBufferSize(5000);
       
   210 			_LIT(KTextvalue11, "C:\\logs\\ULoggerBufferOverflow.utf");
       
   211 			const TPtrC valueptr11(KTextvalue11);
       
   212 
       
   213 			INFO_PRINTF3(_L("Writing to buffer... Buffer size: %d, DNS: %d"),4900,5000);
       
   214 
       
   215 			writeToBuffer(valueptr11, 1000, &logger);
       
   216 			logger.Close();
       
   217 			INFO_PRINTF1(_L("Buffer Sizing tests complete!"));
       
   218 
       
   219 		//  **************   Block end ****************
       
   220 		}
       
   221 	  return ETrue;
       
   222 	}
       
   223