diff -r c1f20ce4abcf -r 3e88ff8f41d5 kerneltest/e32test/usbho/t_usbdi/src/TestPolicy.cpp --- a/kerneltest/e32test/usbho/t_usbdi/src/TestPolicy.cpp Tue Aug 31 16:34:26 2010 +0300 +++ b/kerneltest/e32test/usbho/t_usbdi/src/TestPolicy.cpp Wed Sep 01 12:34:56 2010 +0100 @@ -1,4 +1,4 @@ -// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2007-2009 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,22 +21,16 @@ #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; } @@ -44,31 +38,26 @@ CBasicTestPolicy::CBasicTestPolicy() : CActive(EPriorityStandard) { - OstTraceFunctionEntry1( CBASICTESTPOLICY_CBASICTESTPOLICY_ENTRY, this ); CActiveScheduler::Add(this); - OstTraceFunctionExit1( CBASICTESTPOLICY_CBASICTESTPOLICY_EXIT, this ); } CBasicTestPolicy::~CBasicTestPolicy() { - OstTraceFunctionEntry1( CBASICTESTPOLICY_CBASICTESTPOLICY_ENTRY_DUP01, this ); + LOG_FUNC 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) { - OstTraceFunctionEntryExt( CBASICTESTPOLICY_RUNTESTCASEL_ENTRY, this ); + LOG_FUNC iNotifierStatus = &aNotifierStatus; @@ -82,13 +71,12 @@ *iNotifierStatus = iStatus = KRequestPending; SetActive(); - OstTraceFunctionExit1( CBASICTESTPOLICY_RUNTESTCASEL_EXIT, this ); } void CBasicTestPolicy::DoCancel() { - OstTraceFunctionEntry1( CBASICTESTPOLICY_DOCANCEL_ENTRY, this ); + LOG_FUNC // Cancel running the test cases @@ -97,26 +85,24 @@ // 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) { - OstTraceFunctionEntryExt( CBASICTESTPOLICY_SIGNALTESTCOMPLETE_ENTRY, this ); + LOG_FUNC // 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() { - OstTraceFunctionEntry1( CBASICTESTPOLICY_RUNL_ENTRY, this ); + LOG_FUNC // Complete the request of the notifier with the test case // completion code @@ -126,62 +112,52 @@ // Destroy the test case delete iTestCase; - OstTraceFunctionExit1( CBASICTESTPOLICY_RUNL_EXIT, this ); } TInt CBasicTestPolicy::RunError(TInt aError) { - OstTraceFunctionEntryExt( CBASICTESTPOLICY_RUNERROR_ENTRY, this ); + LOG_FUNC 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) { - OstTraceFunctionEntryExt( CTHREADTESTPOLICY_RUNTESTCASEL_ENTRY, this ); + LOG_FUNC iNotifierStatus = &aNotifierStatus; - OstTraceExt1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL, "Creating thread for test case '%S'",aTestCaseId); + RDebug::Printf("Creating thread for test case '%S'",&aTestCaseId); if(iTestCaseId) { @@ -197,61 +173,58 @@ if(err != KErrNone) { - OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL_DUP01, "Test thread creation unsuccessful: %d",err); + RDebug::Printf("Test thread creation unsuccessful: %d",err); User::Leave(err); } - OstTraceExt1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL_DUP02, "Test thread '%S' created",aTestCaseId); + RDebug::Printf("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) { - OstTraceFunctionEntryExt( CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_ENTRY, this ); + LOG_FUNC if(aCompletionCode == KErrNone) { - OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_SIGNALTESTCOMPLETE, "CActiveScheduler::Stop CThreadTestPolicy::SignalTestComplete"); + RDebug::Printf("CActiveScheduler::Stop CThreadTestPolicy::SignalTestComplete"); CActiveScheduler::Stop(); } else { - OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_DUP01, "Killing thread with: %d",aCompletionCode); + RDebug::Printf("Killing thread with: %d",aCompletionCode); iTestThread.Kill(aCompletionCode); } - OstTraceFunctionExit1( CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_EXIT, this ); } void CThreadTestPolicy::DoCancel() { - OstTraceFunctionEntry1( CTHREADTESTPOLICY_DOCANCEL_ENTRY, this ); + LOG_FUNC iTestCase->Cancel(); - OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL, ">> Debug point: 1"); + LOG_POINT(1) TInt err(iTestThread.LogonCancel(iStatus)); if(err != KErrNone) { - OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP01, "Unable to cancel thread logon: %d",err); + RDebug::Printf("Unable to cancel thread logon: %d",err); } - OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP02, ">> Debug point: 2"); + LOG_POINT(2) TRequestStatus cancelStatus; iTestThread.Logon(cancelStatus); - OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP03, ">> Debug point: 3"); + LOG_POINT(3) iTestThread.Kill(KErrCancel); - OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP04, ">> Debug point: 4"); + LOG_POINT(4) User::RequestComplete(iNotifierStatus,cancelStatus.Int()); - OstTraceFunctionExit1( CTHREADTESTPOLICY_DOCANCEL_EXIT, this ); } TInt CThreadTestPolicy::ThreadFunction(TAny* aThreadParameter) { - OstTraceFunctionEntry0( CTHREADTESTPOLICY_THREADFUNCTION_ENTRY); + LOG_CFUNC TInt err(KErrNone); TInt leaveCode(KErrNone); @@ -262,26 +235,24 @@ CTrapCleanup* cleanup = CTrapCleanup::New(); if(cleanup == NULL) { - OstTraceFunctionExitExt( CTHREADTESTPOLICY_THREADFUNCTION_EXIT, 0, KErrNoMemory ); return KErrNoMemory; } TRAP(leaveCode,err = CThreadTestPolicy::DoTestL(*testCaseId)); if(leaveCode != KErrNone) { - OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_THREADFUNCTION, " Thread '%S' DoTest",leaveCode, *testCaseId); + RDebug::Printf(" Thread '%S' DoTest",leaveCode,&testCaseId); err = leaveCode; } delete cleanup; - OstTraceFunctionExitExt( CTHREADTESTPOLICY_THREADFUNCTION_EXIT_DUP01, 0, err ); return err; } TInt CThreadTestPolicy::DoTestL(const TDesC& aTestCaseId) { - OstTraceFunctionEntryExt( CTHREADTESTPOLICY_DOTESTL_ENTRY, 0 ); + LOG_CFUNC TInt err(KErrNone); // Create a new active scheduler for this thread @@ -298,7 +269,7 @@ if(!testCase->IsHostOnly()) { // Loop for active objects - OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOTESTL, "CActiveScheduler::Start in CThreadTestPolicy::DoTestL"); + RDebug::Printf("CActiveScheduler::Start in CThreadTestPolicy::DoTestL"); CActiveScheduler::Start(); } // Get the test case execution result @@ -310,19 +281,18 @@ // Destroy the active scheduler CleanupStack::PopAndDestroy(sched); - OstTraceFunctionExitExt( CTHREADTESTPOLICY_DOTESTL_EXIT, 0, err ); return err; } void CThreadTestPolicy::RunL() { - OstTraceFunctionEntry1( CTHREADTESTPOLICY_RUNL_ENTRY, this ); + LOG_FUNC TInt completionCode(iStatus.Int()); TExitType exitType(iTestThread.ExitType()); TExitCategoryName exitName(iTestThread.ExitCategory()); TInt exitReason(iTestThread.ExitReason()); - OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL, "Test thread '%S' completed with completion code %d",iTestThread.Name(),completionCode); + RDebug::Printf("Test thread '%S' completed with completion code %d",&iTestThread.Name(),completionCode); switch(exitType) { @@ -330,8 +300,8 @@ // This will occur if test API panics or RTest expression is false (i.e. test case fails) case EExitPanic: { - OstTraceExt3(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP01, "Test thread '%S' has panicked with category '%S' reason %d", - iTestThread.Name(),exitName,exitReason); + RDebug::Printf("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; @@ -341,8 +311,8 @@ // The thread has been terminated case EExitTerminate: { - OstTraceExt3(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP02, "Test thread '%S' terminated with category %s reason %d", - iTestThread.Name(),exitName,exitReason); + RDebug::Printf("Test thread '%S' terminated with category %s reason %d", + &iTestThread.Name(),&exitName,exitReason); } break; @@ -350,7 +320,7 @@ // This will occur when the test thread executes normally or is cancelled case EExitKill: { - OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP03, "Test thread '%S' has been killed with reason %d",iTestThread.Name(),exitReason); + RDebug::Printf("Test thread '%S' has been killed with reason %d",&iTestThread.Name(),exitReason); } break; @@ -366,14 +336,11 @@ // Complete the notifier's request status User::RequestComplete(iNotifierStatus,completionCode); - OstTraceFunctionExit1( CTHREADTESTPOLICY_RUNL_EXIT, this ); } TInt CThreadTestPolicy::RunError(TInt aError) { - OstTraceFunctionEntryExt( CTHREADTESTPOLICY_RUNERROR_ENTRY, this ); - OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNERROR, " RunError",aError); - OstTraceFunctionExitExt( CTHREADTESTPOLICY_RUNERROR_EXIT, this, KErrNone ); + RDebug::Printf(" RunError",aError); return KErrNone; }