traceservices/tracefw/integ_test/ost/TEF/te_ostv2integsuite_functional/src/te_ostv2tracetestwrapper.cpp
branchRCL_3
changeset 24 cc28652e0254
parent 23 26645d81f48d
equal deleted inserted replaced
23:26645d81f48d 24:cc28652e0254
     1 // Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 // All rights reserved.
     2 // All rights reserved.
     3 // This component and the accompanying materials are made available
     3 // This component and the accompanying materials are made available
     4 // under the terms of "Eclipse Public License v1.0"
     4 // under the terms of "Eclipse Public License v1.0"
     5 // which accompanies this distribution, and is available
     5 // which accompanies this distribution, and is available
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
    32 const TUint32 KTestTInt2 = 0x456;
    32 const TUint32 KTestTInt2 = 0x456;
    33 _LIT(KTestDuplicates, "TestDuplicates");
    33 _LIT(KTestDuplicates, "TestDuplicates");
    34 
    34 
    35 _LIT(KTestOstDebugOnlyWrap, "TestOstDebugOnlyWrap");
    35 _LIT(KTestOstDebugOnlyWrap, "TestOstDebugOnlyWrap");
    36 
    36 
    37 _LIT(KTestOstCompileTimeMacro, "TestOstCompileTimeMacro");
       
    38 
       
    39 //macro wrapper that works only in _DEBUG mode
    37 //macro wrapper that works only in _DEBUG mode
    40 #ifndef OST_DEBUG_ONLY
    38 #ifndef OST_DEBUG_ONLY
    41 #ifdef _DEBUG
    39 #ifdef _DEBUG
    42 #define OST_DEBUG_ONLY(x) x
    40 #define OST_DEBUG_ONLY(x) x
    43 #else
    41 #else
    94         TestDuplicatesL();
    92         TestDuplicatesL();
    95         }
    93         }
    96     else if (aCommand == KTestOstDebugOnlyWrap())
    94     else if (aCommand == KTestOstDebugOnlyWrap())
    97         {
    95         {
    98         TestOstDebugOnlyWrapL();
    96         TestOstDebugOnlyWrapL();
    99         }
       
   100     else if (aCommand == KTestOstCompileTimeMacro())
       
   101         {
       
   102         TestOstCompileTimeMacroL();
       
   103         }
    97         }
   104     else
    98     else
   105         {
    99         {
   106         ret = EFalse;
   100         ret = EFalse;
   107         }
   101         }
   148 
   142 
   149     
   143     
   150     User::LeaveIfError(OpenUlogger(logger));
   144     User::LeaveIfError(OpenUlogger(logger));
   151     // clear the config file
   145     // clear the config file
   152     CClearConfig configIni;
   146     CClearConfig configIni;
   153     configIni.ClearL(logger);
   147     configIni.Clear(logger);
   154 
   148 
   155     // extract the user ids from the values generated by tracecompiler
   149     // extract the user ids from the values generated by tracecompiler
   156     const TUint8 USER_DEFINED_GID_1 = TEST_OSTTRACEWRAPPER7 >> 16;
   150     const TUint8 USER_DEFINED_GID_1 = TEST_OSTTRACEWRAPPER7 >> 16;
   157     const TUint8 USER_DEFINED_GID_2 = TEST_OSTTRACEWRAPPER8 >> 16;
   151     const TUint8 USER_DEFINED_GID_2 = TEST_OSTTRACEWRAPPER8 >> 16;
   158 
   152 
   267     }
   261     }
   268 
   262 
   269 
   263 
   270 void CTOstv2TraceTestWrapper::TestOstDebugOnlyWrapL()
   264 void CTOstv2TraceTestWrapper::TestOstDebugOnlyWrapL()
   271     {
   265     {
   272     INFO_PRINTF1(_L("CTOstv2TraceTestWrapper::TestOstDebugOnlyWrap"));
   266     INFO_PRINTF1(_L("CTOstv2TraceTestWrapper::TestDuplicates"));
   273 
   267 
   274     RULogger logger;
   268     RULogger logger;
   275 
   269 
   276     
   270     
   277     User::LeaveIfError(OpenUlogger(logger));
   271     User::LeaveIfError(OpenUlogger(logger));
   278     // clear the config file
   272     // clear the config file
   279     CClearConfig configIni;
   273     CClearConfig configIni;
   280     configIni.ClearL(logger);
   274     configIni.Clear(logger);
   281 
   275 
   282     // extract the user ids from the values generated by tracecompiler
   276     // extract the user ids from the values generated by tracecompiler
   283     const TUint8 USER_DEFINED_GID_1w = TEST_OSTTRACEWRAPPER7w >> 16;
   277     const TUint8 USER_DEFINED_GID_1w = TEST_OSTTRACEWRAPPER7w >> 16;
   284     const TUint8 USER_DEFINED_GID_2w = TEST_OSTTRACEWRAPPER8w >> 16;
   278     const TUint8 USER_DEFINED_GID_2w = TEST_OSTTRACEWRAPPER8w >> 16;
   285 
   279 
   392         INFO_PRINTF2(_L("add file as output plugin failed with err %d"), result);
   386         INFO_PRINTF2(_L("add file as output plugin failed with err %d"), result);
   393         }
   387         }
   394     }
   388     }
   395 
   389 
   396 
   390 
   397 void CTOstv2TraceTestWrapper::TestOstCompileTimeMacroL()
       
   398     {
       
   399     INFO_PRINTF1(_L("CTOstv2TraceTestWrapper::TestOstCompileTimeMacro"));
       
   400 
       
   401     RULogger logger;
       
   402 
       
   403     
       
   404     User::LeaveIfError(OpenUlogger(logger));
       
   405     // clear the config file
       
   406     CClearConfig configIni;
       
   407     configIni.ClearL(logger);
       
   408 
       
   409     // switch on primary filtering mechanism
       
   410     CArrayFixFlat<TUint8> *setprimfilter =
       
   411             new (ELeave) CArrayFixFlat<TUint8> (22);
       
   412     setprimfilter->AppendL(KGroupId);
       
   413     setprimfilter->AppendL(TRACE_NORMAL);
       
   414     TInt result = logger.SetPrimaryFiltersEnabled(*setprimfilter, ETrue);
       
   415 
       
   416     if (result != KErrNone)
       
   417         {
       
   418         ERR_PRINTF2(_L("Failed to set Ulogger primary filters result(%d"), result);
       
   419         SetBlockResult(EFail);
       
   420         }
       
   421 
       
   422     // switch off secondary filtering
       
   423     result = logger.SetSecondaryFilteringEnabled(EFalse);
       
   424     if (result != KErrNone)
       
   425         {
       
   426         ERR_PRINTF2(_L("Failed to set Ulogger secondary filters result(%d"), result);
       
   427         SetBlockResult(EFail);
       
   428         }
       
   429 
       
   430     delete setprimfilter;
       
   431     setprimfilter = NULL;
       
   432     // setup output file
       
   433     _LIT(KLogFilename, "C:\\logs\\macro_trace_test.utf");
       
   434     EmptyFile(KLogFilename);
       
   435     // setup ulogger to write to the file using its output plugin
       
   436     _LIT8(KTextmedia,"uloggerfileplugin");
       
   437     TPtrC8 mediaptr(KTextmedia);
       
   438     result = logger.ActivateOutputPlugin(mediaptr);
       
   439     if (result == KErrNone)
       
   440         {
       
   441         INFO_PRINTF1(_L("file set as active output plugin ok"));
       
   442         TPluginConfiguration pluginConfig;
       
   443         _LIT(KTextsetting, "output_path");
       
   444         pluginConfig.SetKey(KTextsetting);
       
   445         pluginConfig.SetValue(KLogFilename());
       
   446         result = logger.SetPluginConfigurations(mediaptr, pluginConfig);
       
   447         if (result == KErrNone)
       
   448             {
       
   449             INFO_PRINTF1(_L("output plugin settings set ok"));
       
   450 
       
   451             result = logger.Start();
       
   452             if (result == KErrNone)
       
   453                 {
       
   454                 // now try some traces with compile time Macros
       
   455                 //OST_TRACE_CATEGORY_DEBUG
       
   456                 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_DEBUG)
       
   457                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER1m, 0); // should be in UDEB only
       
   458                 #endif
       
   459                 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TEST_OSTTRACEWRAPPER1m, "Foo");
       
   460                 
       
   461                 #ifdef _DEBUG
       
   462                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER2m, 0);
       
   463                 #endif
       
   464                 OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TEST_OSTTRACEWRAPPER2m, "Foo"); // should be in UBED only
       
   465                 
       
   466                 
       
   467                 //OST_TRACE_CATEGORY_PRODUCTION
       
   468                 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_PRODUCTION)
       
   469                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER3m, 0);
       
   470                 #endif
       
   471                 OstTraceDef0(OST_TRACE_CATEGORY_PRODUCTION, TRACE_NORMAL, TEST_OSTTRACEWRAPPER3m, "Foo"); // should be in UREL and UDEB
       
   472                 
       
   473                 //OST_TRACE_CATEGORY_RND
       
   474                 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_RND)
       
   475                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER4m, 0);
       
   476                 #endif
       
   477                 OstTraceDef0(OST_TRACE_CATEGORY_RND, TRACE_NORMAL, TEST_OSTTRACEWRAPPER4m, "Foo"); // should be in UREL and UDEB
       
   478                 
       
   479                 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_PERFORMANCE_MEASUREMENT)
       
   480                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER5m, 0);
       
   481                 #endif
       
   482                 OstTraceDef0(OST_TRACE_CATEGORY_PERFORMANCE_MEASUREMENT, TRACE_NORMAL, TEST_OSTTRACEWRAPPER5m, "Foo"); // should be in neither UREL nor UDEB
       
   483                              
       
   484                 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_NONE)
       
   485                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER6m, 0);
       
   486                 #endif            
       
   487                 OstTraceDef0(OST_TRACE_CATEGORY_NONE, TRACE_NORMAL, TEST_OSTTRACEWRAPPER6m, "Foo"); // should be in neither UREL nor UDEB
       
   488                 
       
   489                 #if (OST_TRACE_CATEGORY & OST_TRACE_CATEGORY_ALL)
       
   490                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER7m, 0);
       
   491                 #endif
       
   492                 OstTraceDef0(OST_TRACE_CATEGORY_ALL, TRACE_NORMAL, TEST_OSTTRACEWRAPPER7m, "Foo"); // should be in UREL and UDEB
       
   493                 
       
   494                 #if (OST_TRACE_CATEGORY & (OST_TRACE_CATEGORY_PRODUCTION | OST_TRACE_CATEGORY_DEBUG))
       
   495                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER8m, 0);
       
   496                 #endif
       
   497                 OstTraceDef0(OST_TRACE_CATEGORY_PRODUCTION | OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TEST_OSTTRACEWRAPPER8m, "Foo"); // should be in UREL and UDEB
       
   498 
       
   499                 #if (OST_TRACE_CATEGORY & (OST_TRACE_CATEGORY_PRODUCTION)) || defined (_DEBUG)
       
   500                 AddTraceHelper((TGroupId) TRACE_NORMAL, (TTraceId) TEST_OSTTRACEWRAPPER9m, 0);
       
   501                 #endif
       
   502                 OstTraceDef0(OST_TRACE_CATEGORY_PRODUCTION | OST_TRACE_CATEGORY_DEBUG, TRACE_NORMAL, TEST_OSTTRACEWRAPPER9m, "Foo"); // should be in UREL and UDEB
       
   503               
       
   504                                 
       
   505                 result = logger.Stop();
       
   506 
       
   507                 if (result == KErrNone)
       
   508                     {
       
   509                     SetBlockResult(
       
   510                             CheckResults(KLogFilename()) == KErrNone
       
   511                                                                      ? EPass
       
   512                                                                         : EFail);
       
   513                     }
       
   514                 }
       
   515             else
       
   516                 {
       
   517                 INFO_PRINTF2(_L("ulogger start returns error %d"), result);
       
   518                 }
       
   519             }
       
   520         else
       
   521             {
       
   522             INFO_PRINTF2(_L("setting output plugin settings failed with err %d"), result);
       
   523             }
       
   524         }
       
   525     else
       
   526         {
       
   527         INFO_PRINTF2(_L("add file as output plugin failed with err %d"), result);
       
   528         }
       
   529     }
       
   530 
       
   531 
       
   532 TInt CTOstv2TraceTestWrapper::CheckResults(const TDesC& aLogFilename)
   391 TInt CTOstv2TraceTestWrapper::CheckResults(const TDesC& aLogFilename)
   533     {
   392     {
   534     // read the logged traces from the log file	
   393     // read the logged traces from the log file	
   535     TInt err = ReadFromLogFile(aLogFilename);
   394     TInt err = ReadFromLogFile(aLogFilename);
   536     if (err == KErrNone)
   395     if (err == KErrNone)