diff -r a179b74831c9 -r c1f20ce4abcf kerneltest/e32test/usbho/t_usbdi/src/TestPolicy.cpp --- a/kerneltest/e32test/usbho/t_usbdi/src/TestPolicy.cpp Thu Aug 19 11:14:22 2010 +0300 +++ b/kerneltest/e32test/usbho/t_usbdi/src/TestPolicy.cpp Tue Aug 31 16:34:26 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of the License "Eclipse Public License v1.0" @@ -21,16 +21,22 @@ #include "BaseTestCase.h" #include "TestCaseFactory.h" #include "testdebug.h" +#include "OstTraceDefinitions.h" +#ifdef OST_TRACE_COMPILER_IN_USE +#include "TestPolicyTraces.h" +#endif namespace NUnitTesting_USBDI { CBasicTestPolicy* CBasicTestPolicy::NewL() { + OstTraceFunctionEntry0( CBASICTESTPOLICY_NEWL_ENTRY ); CBasicTestPolicy* self = new (ELeave) CBasicTestPolicy; CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); + OstTraceFunctionExit1( CBASICTESTPOLICY_NEWL_EXIT, ( TUint )( self ) ); return self; } @@ -38,26 +44,31 @@ CBasicTestPolicy::CBasicTestPolicy() : CActive(EPriorityStandard) { + OstTraceFunctionEntry1( CBASICTESTPOLICY_CBASICTESTPOLICY_ENTRY, this ); CActiveScheduler::Add(this); + OstTraceFunctionExit1( CBASICTESTPOLICY_CBASICTESTPOLICY_EXIT, this ); } CBasicTestPolicy::~CBasicTestPolicy() { - LOG_FUNC + OstTraceFunctionEntry1( CBASICTESTPOLICY_CBASICTESTPOLICY_ENTRY_DUP01, this ); Cancel(); + OstTraceFunctionExit1( CBASICTESTPOLICY_CBASICTESTPOLICY_EXIT_DUP01, this ); } void CBasicTestPolicy::ConstructL() { + OstTraceFunctionEntry1( CBASICTESTPOLICY_CONSTRUCTL_ENTRY, this ); + OstTraceFunctionExit1( CBASICTESTPOLICY_CONSTRUCTL_EXIT, this ); } void CBasicTestPolicy::RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aNotifierStatus) { - LOG_FUNC + OstTraceFunctionEntryExt( CBASICTESTPOLICY_RUNTESTCASEL_ENTRY, this ); iNotifierStatus = &aNotifierStatus; @@ -71,12 +82,13 @@ *iNotifierStatus = iStatus = KRequestPending; SetActive(); + OstTraceFunctionExit1( CBASICTESTPOLICY_RUNTESTCASEL_EXIT, this ); } void CBasicTestPolicy::DoCancel() { - LOG_FUNC + OstTraceFunctionEntry1( CBASICTESTPOLICY_DOCANCEL_ENTRY, this ); // Cancel running the test cases @@ -85,24 +97,26 @@ // Notify the test case controller that test case execution was cancelled User::RequestComplete(iNotifierStatus,KErrCancel); + OstTraceFunctionExit1( CBASICTESTPOLICY_DOCANCEL_EXIT, this ); } void CBasicTestPolicy::SignalTestComplete(TInt aCompletionCode) { - LOG_FUNC + OstTraceFunctionEntryExt( CBASICTESTPOLICY_SIGNALTESTCOMPLETE_ENTRY, this ); // Complete the test policy request with the test case completion code // (Basically self completion) TRequestStatus* s = &iStatus; User::RequestComplete(s,aCompletionCode); + OstTraceFunctionExit1( CBASICTESTPOLICY_SIGNALTESTCOMPLETE_EXIT, this ); } void CBasicTestPolicy::RunL() { - LOG_FUNC + OstTraceFunctionEntry1( CBASICTESTPOLICY_RUNL_ENTRY, this ); // Complete the request of the notifier with the test case // completion code @@ -112,52 +126,62 @@ // Destroy the test case delete iTestCase; + OstTraceFunctionExit1( CBASICTESTPOLICY_RUNL_EXIT, this ); } TInt CBasicTestPolicy::RunError(TInt aError) { - LOG_FUNC + OstTraceFunctionEntryExt( CBASICTESTPOLICY_RUNERROR_ENTRY, this ); aError = KErrNone; + OstTraceFunctionExitExt( CBASICTESTPOLICY_RUNERROR_EXIT, this, aError ); return aError; } CThreadTestPolicy* CThreadTestPolicy::NewL() { + OstTraceFunctionEntry0( CTHREADTESTPOLICY_NEWL_ENTRY ); CThreadTestPolicy* self = new (ELeave) CThreadTestPolicy; CleanupStack::PushL(self); self->ConstructL(); CleanupStack::Pop(self); + OstTraceFunctionExit1( CTHREADTESTPOLICY_NEWL_EXIT, ( TUint )( self ) ); return self; } CThreadTestPolicy::CThreadTestPolicy() { + OstTraceFunctionEntry1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_ENTRY, this ); + OstTraceFunctionExit1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_EXIT, this ); } CThreadTestPolicy::~CThreadTestPolicy() { + OstTraceFunctionEntry1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_ENTRY_DUP01, this ); iTestThread.Close(); if(iTestCaseId) { delete iTestCaseId; iTestCaseId = NULL; } + OstTraceFunctionExit1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_EXIT_DUP01, this ); } void CThreadTestPolicy::ConstructL() { + OstTraceFunctionEntry1( CTHREADTESTPOLICY_CONSTRUCTL_ENTRY, this ); + OstTraceFunctionExit1( CTHREADTESTPOLICY_CONSTRUCTL_EXIT, this ); } void CThreadTestPolicy::RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aNotifierStatus) { - LOG_FUNC + OstTraceFunctionEntryExt( CTHREADTESTPOLICY_RUNTESTCASEL_ENTRY, this ); iNotifierStatus = &aNotifierStatus; - RDebug::Printf("Creating thread for test case '%S'",&aTestCaseId); + OstTraceExt1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL, "Creating thread for test case '%S'",aTestCaseId); if(iTestCaseId) { @@ -173,58 +197,61 @@ if(err != KErrNone) { - RDebug::Printf("Test thread creation unsuccessful: %d",err); + OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL_DUP01, "Test thread creation unsuccessful: %d",err); User::Leave(err); } - RDebug::Printf("Test thread '%S' created",&aTestCaseId); + OstTraceExt1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL_DUP02, "Test thread '%S' created",aTestCaseId); // Start the test case in the thread iTestThread.Logon(iStatus); SetActive(); iTestThread.Resume(); *iNotifierStatus = KRequestPending; + OstTraceFunctionExit1( CTHREADTESTPOLICY_RUNTESTCASEL_EXIT, this ); } void CThreadTestPolicy::SignalTestComplete(TInt aCompletionCode) { - LOG_FUNC + OstTraceFunctionEntryExt( CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_ENTRY, this ); if(aCompletionCode == KErrNone) { - RDebug::Printf("CActiveScheduler::Stop CThreadTestPolicy::SignalTestComplete"); + OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_SIGNALTESTCOMPLETE, "CActiveScheduler::Stop CThreadTestPolicy::SignalTestComplete"); CActiveScheduler::Stop(); } else { - RDebug::Printf("Killing thread with: %d",aCompletionCode); + OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_DUP01, "Killing thread with: %d",aCompletionCode); iTestThread.Kill(aCompletionCode); } + OstTraceFunctionExit1( CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_EXIT, this ); } void CThreadTestPolicy::DoCancel() { - LOG_FUNC + OstTraceFunctionEntry1( CTHREADTESTPOLICY_DOCANCEL_ENTRY, this ); iTestCase->Cancel(); - LOG_POINT(1) + OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL, ">> Debug point: 1"); TInt err(iTestThread.LogonCancel(iStatus)); if(err != KErrNone) { - RDebug::Printf("Unable to cancel thread logon: %d",err); + OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP01, "Unable to cancel thread logon: %d",err); } - LOG_POINT(2) + OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP02, ">> Debug point: 2"); TRequestStatus cancelStatus; iTestThread.Logon(cancelStatus); - LOG_POINT(3) + OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP03, ">> Debug point: 3"); iTestThread.Kill(KErrCancel); - LOG_POINT(4) + OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP04, ">> Debug point: 4"); User::RequestComplete(iNotifierStatus,cancelStatus.Int()); + OstTraceFunctionExit1( CTHREADTESTPOLICY_DOCANCEL_EXIT, this ); } TInt CThreadTestPolicy::ThreadFunction(TAny* aThreadParameter) { - LOG_CFUNC + OstTraceFunctionEntry0( CTHREADTESTPOLICY_THREADFUNCTION_ENTRY); TInt err(KErrNone); TInt leaveCode(KErrNone); @@ -235,24 +262,26 @@ CTrapCleanup* cleanup = CTrapCleanup::New(); if(cleanup == NULL) { + OstTraceFunctionExitExt( CTHREADTESTPOLICY_THREADFUNCTION_EXIT, 0, KErrNoMemory ); return KErrNoMemory; } TRAP(leaveCode,err = CThreadTestPolicy::DoTestL(*testCaseId)); if(leaveCode != KErrNone) { - RDebug::Printf(" Thread '%S' DoTest",leaveCode,&testCaseId); + OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_THREADFUNCTION, " Thread '%S' DoTest",leaveCode, *testCaseId); err = leaveCode; } delete cleanup; + OstTraceFunctionExitExt( CTHREADTESTPOLICY_THREADFUNCTION_EXIT_DUP01, 0, err ); return err; } TInt CThreadTestPolicy::DoTestL(const TDesC& aTestCaseId) { - LOG_CFUNC + OstTraceFunctionEntryExt( CTHREADTESTPOLICY_DOTESTL_ENTRY, 0 ); TInt err(KErrNone); // Create a new active scheduler for this thread @@ -269,7 +298,7 @@ if(!testCase->IsHostOnly()) { // Loop for active objects - RDebug::Printf("CActiveScheduler::Start in CThreadTestPolicy::DoTestL"); + OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOTESTL, "CActiveScheduler::Start in CThreadTestPolicy::DoTestL"); CActiveScheduler::Start(); } // Get the test case execution result @@ -281,18 +310,19 @@ // Destroy the active scheduler CleanupStack::PopAndDestroy(sched); + OstTraceFunctionExitExt( CTHREADTESTPOLICY_DOTESTL_EXIT, 0, err ); return err; } void CThreadTestPolicy::RunL() { - LOG_FUNC + OstTraceFunctionEntry1( CTHREADTESTPOLICY_RUNL_ENTRY, this ); TInt completionCode(iStatus.Int()); TExitType exitType(iTestThread.ExitType()); TExitCategoryName exitName(iTestThread.ExitCategory()); TInt exitReason(iTestThread.ExitReason()); - RDebug::Printf("Test thread '%S' completed with completion code %d",&iTestThread.Name(),completionCode); + OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL, "Test thread '%S' completed with completion code %d",iTestThread.Name(),completionCode); switch(exitType) { @@ -300,8 +330,8 @@ // This will occur if test API panics or RTest expression is false (i.e. test case fails) case EExitPanic: { - RDebug::Printf("Test thread '%S' has panicked with category '%S' reason %d", - &iTestThread.Name(),&exitName,exitReason); + OstTraceExt3(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP01, "Test thread '%S' has panicked with category '%S' reason %d", + iTestThread.Name(),exitName,exitReason); // May require to stop and start host/client USB depending on what panic category it is // can no longer trust RUsbHubDriver/RDevUsbcClient to be in good state completionCode = KErrAbort; @@ -311,8 +341,8 @@ // The thread has been terminated case EExitTerminate: { - RDebug::Printf("Test thread '%S' terminated with category %s reason %d", - &iTestThread.Name(),&exitName,exitReason); + OstTraceExt3(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP02, "Test thread '%S' terminated with category %s reason %d", + iTestThread.Name(),exitName,exitReason); } break; @@ -320,7 +350,7 @@ // This will occur when the test thread executes normally or is cancelled case EExitKill: { - RDebug::Printf("Test thread '%S' has been killed with reason %d",&iTestThread.Name(),exitReason); + OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP03, "Test thread '%S' has been killed with reason %d",iTestThread.Name(),exitReason); } break; @@ -336,11 +366,14 @@ // Complete the notifier's request status User::RequestComplete(iNotifierStatus,completionCode); + OstTraceFunctionExit1( CTHREADTESTPOLICY_RUNL_EXIT, this ); } TInt CThreadTestPolicy::RunError(TInt aError) { - RDebug::Printf(" RunError",aError); + OstTraceFunctionEntryExt( CTHREADTESTPOLICY_RUNERROR_ENTRY, this ); + OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNERROR, " RunError",aError); + OstTraceFunctionExitExt( CTHREADTESTPOLICY_RUNERROR_EXIT, this, KErrNone ); return KErrNone; }