kerneltest/e32test/usbho/t_usbdi/src/TestPolicy.cpp
branchRCL_3
changeset 257 3e88ff8f41d5
parent 256 c1f20ce4abcf
equal deleted inserted replaced
256:c1f20ce4abcf 257:3e88ff8f41d5
     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 the License "Eclipse Public License v1.0"
     4 // under the terms of the License "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".
    19 #include "TestPolicy.h"
    19 #include "TestPolicy.h"
    20 #include "TestCaseFactory.h"
    20 #include "TestCaseFactory.h"
    21 #include "BaseTestCase.h"
    21 #include "BaseTestCase.h"
    22 #include "TestCaseFactory.h"
    22 #include "TestCaseFactory.h"
    23 #include "testdebug.h"
    23 #include "testdebug.h"
    24 #include "OstTraceDefinitions.h"
       
    25 #ifdef OST_TRACE_COMPILER_IN_USE
       
    26 #include "TestPolicyTraces.h"
       
    27 #endif
       
    28 
    24 
    29 namespace NUnitTesting_USBDI
    25 namespace NUnitTesting_USBDI
    30 	{
    26 	{
    31 	
    27 	
    32 CBasicTestPolicy* CBasicTestPolicy::NewL()
    28 CBasicTestPolicy* CBasicTestPolicy::NewL()
    33 	{
    29 	{
    34 	OstTraceFunctionEntry0( CBASICTESTPOLICY_NEWL_ENTRY );
       
    35 	CBasicTestPolicy* self = new (ELeave) CBasicTestPolicy;
    30 	CBasicTestPolicy* self = new (ELeave) CBasicTestPolicy;
    36 	CleanupStack::PushL(self);
    31 	CleanupStack::PushL(self);
    37 	self->ConstructL();
    32 	self->ConstructL();
    38 	CleanupStack::Pop(self);
    33 	CleanupStack::Pop(self);
    39 	OstTraceFunctionExit1( CBASICTESTPOLICY_NEWL_EXIT, ( TUint )( self ) );
       
    40 	return self;
    34 	return self;
    41 	}
    35 	}
    42 
    36 
    43 	
    37 	
    44 CBasicTestPolicy::CBasicTestPolicy()
    38 CBasicTestPolicy::CBasicTestPolicy()
    45 :	CActive(EPriorityStandard)
    39 :	CActive(EPriorityStandard)
    46 	{
    40 	{
    47 	OstTraceFunctionEntry1( CBASICTESTPOLICY_CBASICTESTPOLICY_ENTRY, this );
       
    48 	CActiveScheduler::Add(this);
    41 	CActiveScheduler::Add(this);
    49 	OstTraceFunctionExit1( CBASICTESTPOLICY_CBASICTESTPOLICY_EXIT, this );
       
    50 	}
    42 	}
    51 
    43 
    52 	
    44 	
    53 CBasicTestPolicy::~CBasicTestPolicy()
    45 CBasicTestPolicy::~CBasicTestPolicy()
    54 	{
    46 	{
    55     OstTraceFunctionEntry1( CBASICTESTPOLICY_CBASICTESTPOLICY_ENTRY_DUP01, this );
    47 	LOG_FUNC
    56 
    48 
    57 	Cancel();
    49 	Cancel();
    58 	OstTraceFunctionExit1( CBASICTESTPOLICY_CBASICTESTPOLICY_EXIT_DUP01, this );
       
    59 	}
    50 	}
    60 	
    51 	
    61 
    52 
    62 void CBasicTestPolicy::ConstructL()
    53 void CBasicTestPolicy::ConstructL()
    63 	{
    54 	{
    64 	OstTraceFunctionEntry1( CBASICTESTPOLICY_CONSTRUCTL_ENTRY, this );
       
    65 	OstTraceFunctionExit1( CBASICTESTPOLICY_CONSTRUCTL_EXIT, this );
       
    66 	}
    55 	}
    67 
    56 
    68 	
    57 	
    69 void CBasicTestPolicy::RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aNotifierStatus)
    58 void CBasicTestPolicy::RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aNotifierStatus)
    70 	{
    59 	{
    71     OstTraceFunctionEntryExt( CBASICTESTPOLICY_RUNTESTCASEL_ENTRY, this );
    60 	LOG_FUNC
    72 
    61 
    73 	iNotifierStatus = &aNotifierStatus;
    62 	iNotifierStatus = &aNotifierStatus;
    74 
    63 
    75 	// Create the specified test case
    64 	// Create the specified test case
    76 
    65 
    80 
    69 
    81 	// Set the request of the notifier to pending
    70 	// Set the request of the notifier to pending
    82 	
    71 	
    83 	*iNotifierStatus = iStatus = KRequestPending;
    72 	*iNotifierStatus = iStatus = KRequestPending;
    84 	SetActive();
    73 	SetActive();
    85 	OstTraceFunctionExit1( CBASICTESTPOLICY_RUNTESTCASEL_EXIT, this );
       
    86 	}
    74 	}
    87 
    75 
    88 
    76 
    89 void CBasicTestPolicy::DoCancel()
    77 void CBasicTestPolicy::DoCancel()
    90 	{
    78 	{
    91     OstTraceFunctionEntry1( CBASICTESTPOLICY_DOCANCEL_ENTRY, this );
    79 	LOG_FUNC
    92 
    80 
    93 	// Cancel running the test cases
    81 	// Cancel running the test cases
    94 	
    82 	
    95 	iTestCase->Cancel();
    83 	iTestCase->Cancel();
    96 
    84 
    97 	// Notify the test case controller that test case execution was cancelled
    85 	// Notify the test case controller that test case execution was cancelled
    98 	
    86 	
    99 	User::RequestComplete(iNotifierStatus,KErrCancel);
    87 	User::RequestComplete(iNotifierStatus,KErrCancel);
   100 	OstTraceFunctionExit1( CBASICTESTPOLICY_DOCANCEL_EXIT, this );
       
   101 	}
    88 	}
   102 
    89 
   103 
    90 
   104 void CBasicTestPolicy::SignalTestComplete(TInt aCompletionCode)
    91 void CBasicTestPolicy::SignalTestComplete(TInt aCompletionCode)
   105 	{
    92 	{
   106 	OstTraceFunctionEntryExt( CBASICTESTPOLICY_SIGNALTESTCOMPLETE_ENTRY, this );
    93 	LOG_FUNC
   107 	
    94 	
   108 	// Complete the test policy request with the test case completion code
    95 	// Complete the test policy request with the test case completion code
   109 	// (Basically self completion)
    96 	// (Basically self completion)
   110 	
    97 	
   111 	TRequestStatus* s = &iStatus;	
    98 	TRequestStatus* s = &iStatus;	
   112 	User::RequestComplete(s,aCompletionCode);
    99 	User::RequestComplete(s,aCompletionCode);
   113 	OstTraceFunctionExit1( CBASICTESTPOLICY_SIGNALTESTCOMPLETE_EXIT, this );
       
   114 	}
   100 	}
   115 
   101 
   116 	
   102 	
   117 void CBasicTestPolicy::RunL()
   103 void CBasicTestPolicy::RunL()
   118 	{
   104 	{
   119 	OstTraceFunctionEntry1( CBASICTESTPOLICY_RUNL_ENTRY, this );
   105 	LOG_FUNC
   120 	
   106 	
   121 	// Complete the request of the notifier with the test case 
   107 	// Complete the request of the notifier with the test case 
   122 	// completion code
   108 	// completion code
   123 	
   109 	
   124 	User::RequestComplete(iNotifierStatus,iStatus.Int());
   110 	User::RequestComplete(iNotifierStatus,iStatus.Int());
   125 	
   111 	
   126 	// Destroy the test case
   112 	// Destroy the test case
   127 	
   113 	
   128 	delete iTestCase;
   114 	delete iTestCase;
   129 	OstTraceFunctionExit1( CBASICTESTPOLICY_RUNL_EXIT, this );
       
   130 	}
   115 	}
   131 
   116 
   132 
   117 
   133 TInt CBasicTestPolicy::RunError(TInt aError)
   118 TInt CBasicTestPolicy::RunError(TInt aError)
   134 	{
   119 	{
   135 	OstTraceFunctionEntryExt( CBASICTESTPOLICY_RUNERROR_ENTRY, this );
   120 	LOG_FUNC
   136 	
   121 	
   137 	aError = KErrNone;
   122 	aError = KErrNone;
   138 	OstTraceFunctionExitExt( CBASICTESTPOLICY_RUNERROR_EXIT, this, aError );
       
   139 	return aError;
   123 	return aError;
   140 	}
   124 	}
   141 	
   125 	
   142 CThreadTestPolicy* CThreadTestPolicy::NewL()
   126 CThreadTestPolicy* CThreadTestPolicy::NewL()
   143 	{
   127 	{
   144 	OstTraceFunctionEntry0( CTHREADTESTPOLICY_NEWL_ENTRY );
       
   145 	CThreadTestPolicy* self = new (ELeave) CThreadTestPolicy;
   128 	CThreadTestPolicy* self = new (ELeave) CThreadTestPolicy;
   146 	CleanupStack::PushL(self);
   129 	CleanupStack::PushL(self);
   147 	self->ConstructL();
   130 	self->ConstructL();
   148 	CleanupStack::Pop(self);
   131 	CleanupStack::Pop(self);
   149 	OstTraceFunctionExit1( CTHREADTESTPOLICY_NEWL_EXIT, ( TUint )( self ) );
       
   150 	return self;
   132 	return self;
   151 	}
   133 	}
   152 	
   134 	
   153 	
   135 	
   154 CThreadTestPolicy::CThreadTestPolicy()
   136 CThreadTestPolicy::CThreadTestPolicy()
   155 	{
   137 	{
   156 	OstTraceFunctionEntry1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_ENTRY, this );
       
   157 	OstTraceFunctionExit1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_EXIT, this );
       
   158 	}
   138 	}
   159 	
   139 	
   160 	
   140 	
   161 CThreadTestPolicy::~CThreadTestPolicy()
   141 CThreadTestPolicy::~CThreadTestPolicy()
   162 	{
   142 	{
   163 	OstTraceFunctionEntry1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_ENTRY_DUP01, this );
       
   164 	iTestThread.Close();
   143 	iTestThread.Close();
   165 	if(iTestCaseId)
   144 	if(iTestCaseId)
   166 		{
   145 		{
   167 		delete iTestCaseId;
   146 		delete iTestCaseId;
   168 		iTestCaseId = NULL;
   147 		iTestCaseId = NULL;
   169 		}
   148 		}
   170 	OstTraceFunctionExit1( CTHREADTESTPOLICY_CTHREADTESTPOLICY_EXIT_DUP01, this );
       
   171 	}
   149 	}
   172 
   150 
   173 void CThreadTestPolicy::ConstructL()
   151 void CThreadTestPolicy::ConstructL()
   174 	{
   152 	{
   175 	OstTraceFunctionEntry1( CTHREADTESTPOLICY_CONSTRUCTL_ENTRY, this );
       
   176 	OstTraceFunctionExit1( CTHREADTESTPOLICY_CONSTRUCTL_EXIT, this );
       
   177 	}
   153 	}
   178 
   154 
   179 void CThreadTestPolicy::RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aNotifierStatus)
   155 void CThreadTestPolicy::RunTestCaseL(const TDesC& aTestCaseId,TRequestStatus& aNotifierStatus)
   180 	{
   156 	{
   181     OstTraceFunctionEntryExt( CTHREADTESTPOLICY_RUNTESTCASEL_ENTRY, this );
   157 	LOG_FUNC
   182 
   158 
   183 	iNotifierStatus = &aNotifierStatus;
   159 	iNotifierStatus = &aNotifierStatus;
   184 	OstTraceExt1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL, "Creating thread for test case '%S'",aTestCaseId);
   160 	RDebug::Printf("Creating thread for test case '%S'",&aTestCaseId);
   185 		
   161 		
   186 	if(iTestCaseId)
   162 	if(iTestCaseId)
   187 		{
   163 		{
   188 		delete iTestCaseId;
   164 		delete iTestCaseId;
   189 		iTestCaseId = NULL;
   165 		iTestCaseId = NULL;
   195 	TInt err(iTestThread.Create(aTestCaseId,CThreadTestPolicy::ThreadFunction,
   171 	TInt err(iTestThread.Create(aTestCaseId,CThreadTestPolicy::ThreadFunction,
   196 			KDefaultStackSize,NULL,reinterpret_cast<TAny*>(iTestCaseId)));
   172 			KDefaultStackSize,NULL,reinterpret_cast<TAny*>(iTestCaseId)));
   197 	
   173 	
   198 	if(err != KErrNone)
   174 	if(err != KErrNone)
   199 		{
   175 		{
   200 		OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL_DUP01, "Test thread creation unsuccessful: %d",err);
   176 		RDebug::Printf("Test thread creation unsuccessful: %d",err);
   201 		User::Leave(err);
   177 		User::Leave(err);
   202 		}
   178 		}
   203 
   179 
   204 	OstTraceExt1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNTESTCASEL_DUP02, "Test thread '%S' created",aTestCaseId);
   180 	RDebug::Printf("Test thread '%S' created",&aTestCaseId);
   205 	// Start the test case in the thread
   181 	// Start the test case in the thread
   206 	iTestThread.Logon(iStatus);
   182 	iTestThread.Logon(iStatus);
   207 	SetActive();
   183 	SetActive();
   208 	iTestThread.Resume();
   184 	iTestThread.Resume();
   209 	*iNotifierStatus = KRequestPending;
   185 	*iNotifierStatus = KRequestPending;
   210 	OstTraceFunctionExit1( CTHREADTESTPOLICY_RUNTESTCASEL_EXIT, this );
       
   211 	}
   186 	}
   212 
   187 
   213 
   188 
   214 void CThreadTestPolicy::SignalTestComplete(TInt aCompletionCode)
   189 void CThreadTestPolicy::SignalTestComplete(TInt aCompletionCode)
   215 	{
   190 	{
   216     OstTraceFunctionEntryExt( CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_ENTRY, this );
   191 	LOG_FUNC
   217 
   192 
   218 	if(aCompletionCode == KErrNone)
   193 	if(aCompletionCode == KErrNone)
   219 		{
   194 		{
   220 		OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_SIGNALTESTCOMPLETE, "CActiveScheduler::Stop CThreadTestPolicy::SignalTestComplete");
   195 		RDebug::Printf("CActiveScheduler::Stop CThreadTestPolicy::SignalTestComplete");
   221 		CActiveScheduler::Stop();
   196 		CActiveScheduler::Stop();
   222 		}
   197 		}
   223 	else
   198 	else
   224 		{
   199 		{
   225 		OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_DUP01, "Killing thread with: %d",aCompletionCode);
   200 		RDebug::Printf("Killing thread with: %d",aCompletionCode);
   226 		iTestThread.Kill(aCompletionCode);
   201 		iTestThread.Kill(aCompletionCode);
   227 		}
   202 		}
   228 	OstTraceFunctionExit1( CTHREADTESTPOLICY_SIGNALTESTCOMPLETE_EXIT, this );
       
   229 	}
   203 	}
   230 
   204 
   231 void CThreadTestPolicy::DoCancel()
   205 void CThreadTestPolicy::DoCancel()
   232 	{
   206 	{
   233     OstTraceFunctionEntry1( CTHREADTESTPOLICY_DOCANCEL_ENTRY, this );
   207 	LOG_FUNC
   234 
   208 
   235 	iTestCase->Cancel();
   209 	iTestCase->Cancel();
   236 	OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL, ">> Debug point: 1");
   210 	LOG_POINT(1)
   237 	TInt err(iTestThread.LogonCancel(iStatus));
   211 	TInt err(iTestThread.LogonCancel(iStatus));
   238 	if(err != KErrNone)
   212 	if(err != KErrNone)
   239 		{
   213 		{
   240 		OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP01, "Unable to cancel thread logon: %d",err);
   214 		RDebug::Printf("Unable to cancel thread logon: %d",err);
   241 		}
   215 		}
   242 	OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP02, ">> Debug point: 2");
   216 	LOG_POINT(2)
   243 	TRequestStatus cancelStatus;
   217 	TRequestStatus cancelStatus;
   244 	iTestThread.Logon(cancelStatus);
   218 	iTestThread.Logon(cancelStatus);
   245 	OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP03, ">> Debug point: 3");
   219 	LOG_POINT(3)
   246 	iTestThread.Kill(KErrCancel);		
   220 	iTestThread.Kill(KErrCancel);		
   247 	OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOCANCEL_DUP04, ">> Debug point: 4");
   221 	LOG_POINT(4)
   248 	User::RequestComplete(iNotifierStatus,cancelStatus.Int());
   222 	User::RequestComplete(iNotifierStatus,cancelStatus.Int());
   249 	OstTraceFunctionExit1( CTHREADTESTPOLICY_DOCANCEL_EXIT, this );
       
   250 	}
   223 	}
   251 	
   224 	
   252 TInt CThreadTestPolicy::ThreadFunction(TAny* aThreadParameter)
   225 TInt CThreadTestPolicy::ThreadFunction(TAny* aThreadParameter)
   253 	{
   226 	{
   254 	OstTraceFunctionEntry0( CTHREADTESTPOLICY_THREADFUNCTION_ENTRY);
   227 	LOG_CFUNC
   255 
   228 
   256 	TInt err(KErrNone);
   229 	TInt err(KErrNone);
   257 	TInt leaveCode(KErrNone);
   230 	TInt leaveCode(KErrNone);
   258 	
   231 	
   259 	HBufC* testCaseId = reinterpret_cast<HBufC*>(aThreadParameter);
   232 	HBufC* testCaseId = reinterpret_cast<HBufC*>(aThreadParameter);
   260 	
   233 	
   261 	// Create the cleanup stack for this thread
   234 	// Create the cleanup stack for this thread
   262 	CTrapCleanup* cleanup = CTrapCleanup::New();
   235 	CTrapCleanup* cleanup = CTrapCleanup::New();
   263 	if(cleanup == NULL)
   236 	if(cleanup == NULL)
   264 		{
   237 		{
   265 		OstTraceFunctionExitExt( CTHREADTESTPOLICY_THREADFUNCTION_EXIT, 0, KErrNoMemory );
       
   266 		return KErrNoMemory;
   238 		return KErrNoMemory;
   267 		}
   239 		}
   268 		
   240 		
   269 	TRAP(leaveCode,err = CThreadTestPolicy::DoTestL(*testCaseId));
   241 	TRAP(leaveCode,err = CThreadTestPolicy::DoTestL(*testCaseId));
   270 	if(leaveCode != KErrNone)
   242 	if(leaveCode != KErrNone)
   271 		{
   243 		{
   272 		OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_THREADFUNCTION, "<Error %d> Thread '%S' DoTest",leaveCode, *testCaseId);
   244 		RDebug::Printf("<Error %d> Thread '%S' DoTest",leaveCode,&testCaseId);
   273 		err = leaveCode;
   245 		err = leaveCode;
   274 		}
   246 		}
   275 	
   247 	
   276 	delete cleanup;
   248 	delete cleanup;
   277 	OstTraceFunctionExitExt( CTHREADTESTPOLICY_THREADFUNCTION_EXIT_DUP01, 0, err );
       
   278 	return err;
   249 	return err;
   279 	}
   250 	}
   280 	
   251 	
   281 	
   252 	
   282 TInt CThreadTestPolicy::DoTestL(const TDesC& aTestCaseId)
   253 TInt CThreadTestPolicy::DoTestL(const TDesC& aTestCaseId)
   283 	{
   254 	{
   284 	OstTraceFunctionEntryExt( CTHREADTESTPOLICY_DOTESTL_ENTRY, 0 );
   255 	LOG_CFUNC
   285 	TInt err(KErrNone);
   256 	TInt err(KErrNone);
   286 	
   257 	
   287 	// Create a new active scheduler for this thread
   258 	// Create a new active scheduler for this thread
   288 	CActiveScheduler* sched = new (ELeave) CActiveScheduler;
   259 	CActiveScheduler* sched = new (ELeave) CActiveScheduler;
   289 	CleanupStack::PushL(sched);
   260 	CleanupStack::PushL(sched);
   296 	testCase->PerformTestL();
   267 	testCase->PerformTestL();
   297 	
   268 	
   298 	if(!testCase->IsHostOnly())
   269 	if(!testCase->IsHostOnly())
   299 		{
   270 		{
   300 		// Loop for active objects
   271 		// Loop for active objects
   301 		OstTrace0(TRACE_NORMAL, CTHREADTESTPOLICY_DOTESTL, "CActiveScheduler::Start in CThreadTestPolicy::DoTestL");
   272 		RDebug::Printf("CActiveScheduler::Start in CThreadTestPolicy::DoTestL");	
   302 		CActiveScheduler::Start();
   273 		CActiveScheduler::Start();
   303 		}	
   274 		}	
   304 	// Get the test case execution result 
   275 	// Get the test case execution result 
   305 	err = testCase->TestResult();
   276 	err = testCase->TestResult();
   306 	
   277 	
   308 	CleanupStack::PopAndDestroy(testCase);
   279 	CleanupStack::PopAndDestroy(testCase);
   309 	
   280 	
   310 	// Destroy the active scheduler	
   281 	// Destroy the active scheduler	
   311 	CleanupStack::PopAndDestroy(sched);
   282 	CleanupStack::PopAndDestroy(sched);
   312 	
   283 	
   313 	OstTraceFunctionExitExt( CTHREADTESTPOLICY_DOTESTL_EXIT, 0, err );
       
   314 	return err;
   284 	return err;
   315 	}
   285 	}
   316 
   286 
   317 void CThreadTestPolicy::RunL()
   287 void CThreadTestPolicy::RunL()
   318 	{
   288 	{
   319 	OstTraceFunctionEntry1( CTHREADTESTPOLICY_RUNL_ENTRY, this );
   289 	LOG_FUNC
   320 	TInt completionCode(iStatus.Int());
   290 	TInt completionCode(iStatus.Int());
   321 	
   291 	
   322 	TExitType exitType(iTestThread.ExitType());
   292 	TExitType exitType(iTestThread.ExitType());
   323 	TExitCategoryName exitName(iTestThread.ExitCategory());
   293 	TExitCategoryName exitName(iTestThread.ExitCategory());
   324 	TInt exitReason(iTestThread.ExitReason());
   294 	TInt exitReason(iTestThread.ExitReason());
   325 	OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL, "Test thread '%S' completed with completion code %d",iTestThread.Name(),completionCode);
   295 	RDebug::Printf("Test thread '%S' completed with completion code %d",&iTestThread.Name(),completionCode);
   326 		
   296 		
   327 	switch(exitType)
   297 	switch(exitType)
   328 		{
   298 		{
   329 		// The test thread has panicked
   299 		// The test thread has panicked
   330 		// This will occur if test API panics or RTest expression is false (i.e. test case fails)
   300 		// This will occur if test API panics or RTest expression is false (i.e. test case fails)
   331 		case EExitPanic:
   301 		case EExitPanic:
   332 			{
   302 			{
   333 			OstTraceExt3(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP01, "Test thread '%S' has panicked with category '%S' reason %d",
   303 			RDebug::Printf("Test thread '%S' has panicked with category '%S' reason %d",
   334 						iTestThread.Name(),exitName,exitReason);
   304 						&iTestThread.Name(),&exitName,exitReason);
   335 			// May require to stop and start host/client USB depending on what panic category it is
   305 			// May require to stop and start host/client USB depending on what panic category it is
   336 			// can no longer trust RUsbHubDriver/RDevUsbcClient to be in good state
   306 			// can no longer trust RUsbHubDriver/RDevUsbcClient to be in good state
   337 			completionCode = KErrAbort;
   307 			completionCode = KErrAbort;
   338 			}
   308 			}
   339 			break;
   309 			break;
   340 				
   310 				
   341 		// The thread has been terminated
   311 		// The thread has been terminated
   342 		case EExitTerminate:
   312 		case EExitTerminate:
   343 			{
   313 			{
   344 			OstTraceExt3(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP02, "Test thread '%S' terminated with category %s reason %d",
   314 			RDebug::Printf("Test thread '%S' terminated with category %s reason %d",
   345 				iTestThread.Name(),exitName,exitReason);
   315 				&iTestThread.Name(),&exitName,exitReason);
   346 			}
   316 			}
   347 			break;
   317 			break;
   348 				
   318 				
   349 		// The thread has been killed
   319 		// The thread has been killed
   350 		// This will occur when the test thread executes normally or is cancelled
   320 		// This will occur when the test thread executes normally or is cancelled
   351 		case EExitKill:
   321 		case EExitKill:
   352 			{
   322 			{
   353 			OstTraceExt2(TRACE_NORMAL, CTHREADTESTPOLICY_RUNL_DUP03, "Test thread '%S' has been killed with reason %d",iTestThread.Name(),exitReason);
   323 			RDebug::Printf("Test thread '%S' has been killed with reason %d",&iTestThread.Name(),exitReason);
   354 			}
   324 			}
   355 			break;
   325 			break;
   356 				
   326 				
   357 		// These cases should not occur at this stage
   327 		// These cases should not occur at this stage
   358 		case EExitPending: //follow through
   328 		case EExitPending: //follow through
   364 	// Close the just executed test thread
   334 	// Close the just executed test thread
   365 	iTestThread.Close();
   335 	iTestThread.Close();
   366 		
   336 		
   367 	// Complete the notifier's request status
   337 	// Complete the notifier's request status
   368 	User::RequestComplete(iNotifierStatus,completionCode);
   338 	User::RequestComplete(iNotifierStatus,completionCode);
   369 	OstTraceFunctionExit1( CTHREADTESTPOLICY_RUNL_EXIT, this );
       
   370 	}
   339 	}
   371 
   340 
   372 TInt CThreadTestPolicy::RunError(TInt aError)
   341 TInt CThreadTestPolicy::RunError(TInt aError)
   373 	{
   342 	{
   374 	OstTraceFunctionEntryExt( CTHREADTESTPOLICY_RUNERROR_ENTRY, this );
   343 	RDebug::Printf("<Error %d><Test Policy> RunError",aError);
   375 	OstTrace1(TRACE_NORMAL, CTHREADTESTPOLICY_RUNERROR, "<Error %d><Test Policy> RunError",aError);
       
   376 	OstTraceFunctionExitExt( CTHREADTESTPOLICY_RUNERROR_EXIT, this, KErrNone );
       
   377 	return KErrNone;
   344 	return KErrNone;
   378 	}
   345 	}
   379 	
   346 	
   380 	}
   347 	}