kerneltest/e32test/usbho/t_otgdi/src/testcase0463.cpp
changeset 253 d37db4dcc88d
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
252:0a40b8675b23 253:d37db4dcc88d
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
     1 // Copyright (c) 2007-2010 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".
    22 #include <e32base.h>
    22 #include <e32base.h>
    23 #include <e32base_private.h>
    23 #include <e32base_private.h>
    24 #include <e32Test.h>	// RTest headder
    24 #include <e32Test.h>	// RTest headder
    25 #include "testcaseroot.h"
    25 #include "testcaseroot.h"
    26 #include "testcase0463.h"
    26 #include "testcase0463.h"
       
    27 #include "OstTraceDefinitions.h"
       
    28 #ifdef OST_TRACE_COMPILER_IN_USE
       
    29 #include "testcase0463Traces.h"
       
    30 #endif
    27 
    31 
    28 
    32 
    29 
    33 
    30 
    34 
    31 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    35 // the name below is used to add a pointer to our construction method to a pointer MAP in 
    34 const TTestCaseFactoryReceipt<CTestCase0463> CTestCase0463::iFactoryReceipt(KTestCaseId);	
    38 const TTestCaseFactoryReceipt<CTestCase0463> CTestCase0463::iFactoryReceipt(KTestCaseId);	
    35 
    39 
    36 
    40 
    37 CTestCase0463* CTestCase0463::NewL(TBool aHost)
    41 CTestCase0463* CTestCase0463::NewL(TBool aHost)
    38 	{
    42 	{
    39 	LOG_FUNC
    43 	if(gVerboseOutput)
       
    44 	    {
       
    45 	    OstTraceFunctionEntry0(CTESTCASE0463_NEWL);
       
    46 	    }
    40 	CTestCase0463* self = new (ELeave) CTestCase0463(aHost);
    47 	CTestCase0463* self = new (ELeave) CTestCase0463(aHost);
    41 	CleanupStack::PushL(self);
    48 	CleanupStack::PushL(self);
    42 	self->ConstructL();
    49 	self->ConstructL();
    43 	CleanupStack::Pop(self);
    50 	CleanupStack::Pop(self);
    44 	return self;
    51 	return self;
    46 	
    53 	
    47 
    54 
    48 CTestCase0463::CTestCase0463(TBool aHost)
    55 CTestCase0463::CTestCase0463(TBool aHost)
    49 :	CTestCaseRoot(KTestCaseId, aHost)
    56 :	CTestCaseRoot(KTestCaseId, aHost)
    50 	{	
    57 	{	
    51 	LOG_FUNC
    58 	if(gVerboseOutput)
       
    59 	    {
       
    60 	    OstTraceFunctionEntry0(CTESTCASE0463_CTESTCASE0463);
       
    61 	    }
    52 	} 
    62 	} 
    53 
    63 
    54 
    64 
    55 /**
    65 /**
    56  ConstructL
    66  ConstructL
    57 */
    67 */
    58 void CTestCase0463::ConstructL()
    68 void CTestCase0463::ConstructL()
    59 	{
    69 	{
    60 	LOG_FUNC
    70 	if(gVerboseOutput)
       
    71 	    {
       
    72 	    OstTraceFunctionEntry0(CTESTCASE0463_CONSTRUCTL);
       
    73 	    }
    61 	iRepeats = OOMOPEN_REPEATS;
    74 	iRepeats = OOMOPEN_REPEATS;
    62 	iAllocFailNumber = OOMOPEN_REPEATS + 1; // allocs 1..11 fail
    75 	iAllocFailNumber = OOMOPEN_REPEATS + 1; // allocs 1..11 fail
    63 	
    76 	
    64 	BaseConstructL();
    77 	BaseConstructL();
    65 	}
    78 	}
    66 
    79 
    67 
    80 
    68 CTestCase0463::~CTestCase0463()
    81 CTestCase0463::~CTestCase0463()
    69 	{
    82 	{
    70 	LOG_FUNC
    83 	if(gVerboseOutput)
       
    84 	    {
       
    85 	    OstTraceFunctionEntry0(CTESTCASE0463_DCTESTCASE0463);
       
    86 	    }
    71 
    87 
    72 	Cancel();
    88 	Cancel();
    73 	}
    89 	}
    74 
    90 
    75 
    91 
    76 void CTestCase0463::ExecuteTestCaseL()
    92 void CTestCase0463::ExecuteTestCaseL()
    77 	{
    93 	{
    78 	LOG_FUNC
    94 	if(gVerboseOutput)
       
    95 	    {
       
    96 	    OstTraceFunctionEntry0(CTESTCASE0463_EXECUTETESTCASEL);
       
    97 	    }
    79 	iCaseStep = EMarkStack;
    98 	iCaseStep = EMarkStack;
    80 	CActiveScheduler::Add(this);
    99 	CActiveScheduler::Add(this);
    81 
   100 
    82 	SelfComplete();
   101 	SelfComplete();
    83 	
   102 	
    84 	}
   103 	}
    85 
   104 
    86 void CTestCase0463::DescribePreconditions()
   105 void CTestCase0463::DescribePreconditions()
    87 	{
   106 	{
    88 	test.Printf(_L("Insert A connector beforehand.\n"));
   107 	test.Printf(_L("Insert A connector beforehand.\n"));
       
   108 	OstTrace0(TRACE_NORMAL, CTESTCASE0463_DESCRIBEPRECONDITIONS, "Insert A connector beforehand.\n");
    89 	}
   109 	}
    90 
   110 
    91 	
   111 	
    92 void CTestCase0463::DoCancel()
   112 void CTestCase0463::DoCancel()
    93 	{
   113 	{
    94 	LOG_FUNC
   114 	if(gVerboseOutput)
       
   115 	    {
       
   116 	    OstTraceFunctionEntry0(CTESTCASE0463_DOCANCEL);
       
   117 	    }
    95 
   118 
    96 	// cancel our timer
   119 	// cancel our timer
    97 	iTimer.Cancel();
   120 	iTimer.Cancel();
    98 	}
   121 	}
    99 
   122 
   100 
   123 
   101 // handle event completion	
   124 // handle event completion	
   102 void CTestCase0463::RunStepL()
   125 void CTestCase0463::RunStepL()
   103 	{
   126 	{
   104 	LOG_FUNC
   127 	if(gVerboseOutput)
       
   128 	    {
       
   129 	    OstTraceFunctionEntry0(CTESTCASE0463_RUNSTEPL);
       
   130 	    }
   105 
   131 
   106 	// Obtain the completion code for this CActive obj.
   132 	// Obtain the completion code for this CActive obj.
   107 	TInt completionCode(iStatus.Int()); 
   133 	TInt completionCode(iStatus.Int()); 
   108 	
   134 	
   109 	switch(iCaseStep)
   135 	switch(iCaseStep)
   115 			
   141 			
   116 		case ELoadLdd:
   142 		case ELoadLdd:
   117 			__UHEAP_SETFAIL(RHeap::EDeterministic, iAllocFailNumber);
   143 			__UHEAP_SETFAIL(RHeap::EDeterministic, iAllocFailNumber);
   118 			__UHEAP_MARK;
   144 			__UHEAP_MARK;
   119 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS);
   145 			test.Printf(_L("Load the LDD iteration %d/%d\n"), OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS);
       
   146 			OstTraceExt2(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP01, "Load the LDD iteration %d/%d\n", OOMOPEN_REPEATS-iRepeats+1, OOMOPEN_REPEATS);
   120 			aIntegerP = new TInt;
   147 			aIntegerP = new TInt;
   121 			CleanupStack::PushL(aIntegerP);
   148 			CleanupStack::PushL(aIntegerP);
   122 			if (!StepLoadLDD())
   149 			if (!StepLoadLDD())
   123 				{
   150 				{
   124 				break;
   151 				break;
   141 		case EUnloadLdd:
   168 		case EUnloadLdd:
   142 			if (EFalse == StepUnloadLDD())
   169 			if (EFalse == StepUnloadLDD())
   143 				return TestFailed(KErrAbort,_L("Unload Ldd failure"));	
   170 				return TestFailed(KErrAbort,_L("Unload Ldd failure"));	
   144 			__UHEAP_MARKEND;
   171 			__UHEAP_MARKEND;
   145 			test.Printf(_L("Heap intact: Asize %d\n"), iAllocFailNumber);
   172 			test.Printf(_L("Heap intact: Asize %d\n"), iAllocFailNumber);
       
   173 			OstTrace1(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP03, "Heap intact: Asize %d\n", iAllocFailNumber);
   146 			iCaseStep = ELoopDecrement;
   174 			iCaseStep = ELoopDecrement;
   147 			SelfComplete();			
   175 			SelfComplete();			
   148 			break;
   176 			break;
   149 						
   177 						
   150 		case ELoopDecrement:
   178 		case ELoopDecrement:
   151 			test.Printf(_L("Repeat test\n"));
   179 			test.Printf(_L("Repeat test\n"));
       
   180 			OstTrace0(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP04, "Repeat test\n");
   152 			__UHEAP_RESET;
   181 			__UHEAP_RESET;
   153 			iAllocFailNumber--;
   182 			iAllocFailNumber--;
   154 			
   183 			
   155 			if (iRepeats--)
   184 			if (iRepeats--)
   156 				iCaseStep = ELoadLdd;
   185 				iCaseStep = ELoadLdd;
   164 			TestPolicy().SignalTestComplete(KErrNone);
   193 			TestPolicy().SignalTestComplete(KErrNone);
   165 			break;
   194 			break;
   166 			
   195 			
   167 		default:
   196 		default:
   168 			test.Printf(_L("<Error> unknown test step"));
   197 			test.Printf(_L("<Error> unknown test step"));
       
   198 			OstTrace0(TRACE_NORMAL, CTESTCASE0463_RUNSTEPL_DUP05, "<Error> unknown test step");
   169 			Cancel();
   199 			Cancel();
   170 			TestPolicy().SignalTestComplete(KErrCorrupt);
   200 			TestPolicy().SignalTestComplete(KErrCorrupt);
   171 			break;
   201 			break;
   172 		}
   202 		}
   173 	}
   203 	}