author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1 |
// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 2 |
// All rights reserved. |
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// @internalComponent |
|
15 |
// |
|
16 |
// |
|
17 |
||
18 |
#include <e32std.h> |
|
19 |
#include <e32std_private.h> |
|
20 |
#include <u32std.h> // unicode builds |
|
21 |
#include <e32base.h> |
|
22 |
#include <e32base_private.h> |
|
23 |
#include <e32cons.h> |
|
24 |
#include <e32Test.h> // RTest headder |
|
25 |
#include <e32def.h> |
|
26 |
#include <e32def_private.h> |
|
27 |
#include "debugmacros.h" |
|
28 |
#include "TestEngine.h" |
|
29 |
#include "TestCaseController.h" |
|
30 |
#include "TestCaseFactory.h" |
|
31 |
#include "TestCaseRoot.h" |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
32 |
#include "OstTraceDefinitions.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
33 |
#ifdef OST_TRACE_COMPILER_IN_USE |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
34 |
#include "testengineTraces.h" |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
35 |
#endif |
0 | 36 |
|
37 |
// Console application parameter options |
|
38 |
_LIT(KArgAllTestCases,"/ALL"); // see default test-list below |
|
39 |
_LIT(KArgGoTestCase, "/G:"); |
|
40 |
_LIT(KArgAutomatedTest, "/AUTO"); // removes "press any key to continue" prompts |
|
41 |
_LIT(KArgVerboseOutput, "/VERBOSE"); // also turns on RDebug logging of all test output (to serial) |
|
42 |
_LIT(KArgSetOpenIterations, "/LOOPO:"); // Open/Close test loop count |
|
43 |
_LIT(KArgSetOOMIterations, "/LOOPM:"); // OOM test set #allocs |
|
44 |
_LIT(KArgSetRoleMaster, "/MASTER"); // this is the default |
|
45 |
_LIT(KArgSetRoleSlave, "/SLAVE"); // slave - Runs a dual-role test's Slave steps instead of Master |
|
46 |
_LIT(KArgOverrideVidPid, "/PID:"); // vendor, product ID XXXX 4 hex digits /PID:0670 |
|
47 |
||
48 |
_LIT(KidFormatter,"PBASE-USB_OTGDI-%04d"); |
|
49 |
_LIT(KidFormatterS,"PBASE-USB_OTGDI-%S"); |
|
50 |
||
51 |
// '/ALL' tests grouping |
|
52 |
const TInt KAllDefaultTestIDs[6] = |
|
53 |
{ |
|
54 |
456, // (a) PBASE-USB_OTG-0456 open/close 'A' |
|
55 |
457, // (a) PBASE-USB_OTG-0457 open/close disconnected |
|
56 |
459, // (m) PBASE-USB_OTG-0459 detect 'A' |
|
57 |
460, // (m) PBASE-USB_OTG-0460 detect 'A' removal |
|
58 |
464, // (m) PBASE-USB_OTG-0464 raise |
|
59 |
465 // (m) PBASE-USB_OTG-0465 lower |
|
60 |
}; |
|
61 |
||
62 |
||
63 |
||
64 |
// |
|
65 |
// CTestEngine implementation |
|
66 |
// |
|
67 |
CTestEngine* CTestEngine::NewL() |
|
68 |
{ |
|
69 |
CTestEngine* self = new (ELeave) CTestEngine; |
|
70 |
CleanupStack::PushL(self); |
|
71 |
self->ConstructL(); |
|
72 |
CleanupStack::Pop(self); |
|
73 |
return self; |
|
74 |
} |
|
75 |
||
76 |
||
77 |
CTestEngine::CTestEngine(): |
|
78 |
iTestCaseIndex(0), |
|
79 |
iHelpRequested(EFalse) |
|
80 |
{ |
|
81 |
||
82 |
} |
|
83 |
||
84 |
||
85 |
CTestEngine::~CTestEngine() |
|
86 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
87 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
88 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
89 |
OstTraceFunctionEntry0(CTESTENGINE_DCTESTENGINE); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
90 |
} |
0 | 91 |
// Destroy the test case controller |
92 |
if (iTestCaseController) |
|
93 |
{ |
|
94 |
delete iTestCaseController; |
|
95 |
} |
|
96 |
// Destroy the test identity array and its contents |
|
97 |
iTestCasesIdentities.ResetAndDestroy(); |
|
98 |
||
99 |
} |
|
100 |
||
101 |
||
102 |
void CTestEngine::ConstructL() |
|
103 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
104 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
OstTraceFunctionEntry0(CTESTENGINE_CONSTRUCTL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
107 |
} |
0 | 108 |
TInt menuSelection(0); |
109 |
||
110 |
// Display information |
|
111 |
test.Title(); |
|
112 |
test.Start(_L("Test Engine Initiation v2.00 ")); |
|
113 |
test.Printf(_L(">>\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
114 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP01, ">>\n"); |
0 | 115 |
test.Printf(_L(">> T E S T R U N \n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
116 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP02, ">> T E S T R U N \n"); |
0 | 117 |
test.Printf(_L(">>\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
118 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP03, ">>\n"); |
0 | 119 |
|
120 |
||
121 |
// Process the command line parameters for batch/etc |
|
122 |
TRAPD(err, ProcessCommandLineL()); |
|
123 |
if (err != KErrNone) |
|
124 |
{ |
|
125 |
User::Panic(_L("Test F/W Err"), KErrNoMemory); |
|
126 |
} |
|
127 |
||
128 |
if (iHelpRequested) |
|
129 |
{ |
|
130 |
PrintUsage(); |
|
131 |
User::Leave(-2); // nothing to do! |
|
132 |
} |
|
133 |
||
134 |
// if no command-line, we use a menu UI |
|
135 |
if (!iTestCasesIdentities.Count()) |
|
136 |
{ |
|
137 |
RPointerArray<HBufC> testCaseNames; |
|
138 |
// no tests added, select ONE to run from the menu |
|
139 |
||
140 |
// list test cases (PRINT MENU) - in numeric order |
|
141 |
RTestFactory::ListRegisteredTestCases(testCaseNames); |
|
142 |
||
143 |
iTestCaseIndex = 0; // be sure we go back to beginning of the collection! |
|
144 |
iTestCasesIdentities.ResetAndDestroy(); |
|
145 |
||
146 |
test.Printf(_L("Please select 0 to %d\n"), RTestFactory::TestCaseCount()-1); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
OstTrace1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP04, "Please select 0 to %d\n", RTestFactory::TestCaseCount()-1); |
0 | 148 |
test.Printf(_L("or 99<ENTER> to exit\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
149 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP05, "or 99<ENTER> to exit\n"); |
0 | 150 |
GetNumericInput(menuSelection); |
151 |
if ((menuSelection >=0) &&(menuSelection < RTestFactory::TestCaseCount())) |
|
152 |
{ |
|
153 |
// add it to the list,and we can go |
|
154 |
TBuf<KTestCaseIdLength> aSelectionID; |
|
155 |
HBufC* tc = HBufC::NewLC(KTestCaseIdLength); |
|
156 |
||
157 |
// get name from index |
|
158 |
*tc = aSelectionID; |
|
159 |
*tc = *testCaseNames[menuSelection]; |
|
160 |
||
161 |
iTestCasesIdentities.Append(tc); |
|
162 |
CleanupStack::Pop(tc); |
|
163 |
} |
|
164 |
testCaseNames.ResetAndDestroy(); |
|
165 |
} |
|
166 |
||
167 |
if ((menuSelection < RTestFactory::TestCaseCount()) && (menuSelection>=0)) |
|
168 |
{ |
|
169 |
// Create the test case controller |
|
170 |
test.Printf(_L("Creating the test controller\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
171 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP06, "Creating the test controller\n"); |
0 | 172 |
iTestCaseController = CTestCaseController::NewL(*this, ETrue); |
173 |
||
174 |
// Test-engine is non CActive class |
|
175 |
} |
|
176 |
else |
|
177 |
{ |
|
178 |
// nothing to do, exit. USER aborted |
|
179 |
test.Printf(_L("Test run stopped by user, nothing to do.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
180 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP07, "Test run stopped by user, nothing to do.\n"); |
0 | 181 |
User::Leave(-2); |
182 |
} |
|
183 |
} |
|
184 |
||
185 |
||
186 |
/* Displayed if used supplied no parameters, garbage, or a ? in the parameters |
|
187 |
*/ |
|
188 |
void CTestEngine::PrintUsage() |
|
189 |
{ |
|
190 |
test.Printf(_L("OTGDI Unit Test Suite.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
191 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE, "OTGDI Unit Test Suite.\n"); |
0 | 192 |
test.Printf(_L("Usage : t_otgdi.exe [/option] /G:<TESTNUM1>\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
193 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP01, "Usage : t_otgdi.exe [/option] /G:<TESTNUM1>\n"); |
0 | 194 |
test.Printf(_L(" /ALL = add default test subset to List\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
195 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP02, " /ALL = add default test subset to List\n"); |
0 | 196 |
test.Printf(_L(" /G:<TESTNUM> where <testname> is the test# to add \n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
197 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP03, " /G:<TESTNUM> where <testname> is the test# to add \n"); |
0 | 198 |
test.Printf(_L(" /AUTO = largely unattended operation\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
199 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP04, " /AUTO = largely unattended operation\n"); |
0 | 200 |
test.Printf(_L(" /VERBOSE = test debugging info\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
201 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP05, " /VERBOSE = test debugging info\n"); |
0 | 202 |
test.Printf(_L(" /LOOPO:<n> = Open/close repeat counter<n>\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
203 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP06, " /LOOPO:<n> = Open/close repeat counter<n>\n"); |
0 | 204 |
test.Printf(_L(" /LOOPM:<n> = OOM HEAP_ALLOCS counter<n>\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
205 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP07, " /LOOPM:<n> = OOM HEAP_ALLOCS counter<n>\n"); |
0 | 206 |
test.Printf(_L(" /SLAVE = Test-peer server mode\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
207 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP08, " /SLAVE = Test-peer server mode\n"); |
0 | 208 |
test.Printf(_L(" /PID:<n> = USB VID/PID in hex eg 2670\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
209 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP09, " /PID:<n> = USB VID/PID in hex eg 2670\n"); |
0 | 210 |
test.Printf(_L("Valid test ID range 0456...0469\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
211 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP10, "Valid test ID range 0456...0469\n"); |
0 | 212 |
test.Printf(_L("and 0675...0684 .\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
213 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP11, "and 0675...0684 .\n"); |
0 | 214 |
test.Printf(_L("\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
215 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP12, "\n"); |
0 | 216 |
} |
217 |
||
218 |
/** process the command-line, ; arguments appear in any order |
|
219 |
IN : User::CommandLine() |
|
220 |
OUT : iTestCasesIdentities |
|
221 |
iHelpRequested |
|
222 |
gSemiAutomated |
|
223 |
gVerboseOutput |
|
224 |
gOpenIterations |
|
225 |
gOOMIterations |
|
226 |
gTestRoleMaster |
|
227 |
gUSBVidPid |
|
228 |
*/ |
|
229 |
void CTestEngine::ProcessCommandLineL() |
|
230 |
{ |
|
231 |
// example t_otgdi.exe /ALL /G:0468 /VERBOSE |
|
232 |
TInt cmdLineLength(User::CommandLineLength()); |
|
233 |
HBufC* cmdLine = HBufC::NewMaxLC(cmdLineLength); |
|
234 |
TPtr cmdLinePtr = cmdLine->Des(); |
|
235 |
User::CommandLine(cmdLinePtr); |
|
236 |
TBool tokenParsed(EFalse); |
|
237 |
||
238 |
TLex args(*cmdLine); |
|
239 |
args.SkipSpace(); // args are separated by spaces |
|
240 |
||
241 |
// first arg is the exe name, skip it |
|
242 |
TPtrC cmdToken = args.NextToken(); |
|
243 |
HBufC* tc = HBufC::NewLC(KParameterTextLenMax); |
|
244 |
*tc = cmdToken; |
|
245 |
while (tc->Length()) |
|
246 |
{ |
|
247 |
tokenParsed = EFalse; |
|
248 |
||
249 |
// '/?' help wanted flag '?' or /? parameter |
|
250 |
TInt pos(0); |
|
251 |
if ((0== tc->FindF(_L("?"))) || (0==tc->FindF(_L("/?")))) |
|
252 |
{ |
|
253 |
iHelpRequested = ETrue; |
|
254 |
tokenParsed = ETrue; |
|
255 |
} |
|
256 |
||
257 |
// '/ALL' parameter |
|
258 |
pos = tc->FindF(KArgAllTestCases); |
|
259 |
if (pos != KErrNotFound) |
|
260 |
{ |
|
261 |
AddAllDefaultTests(); |
|
262 |
tokenParsed = ETrue; |
|
263 |
} |
|
264 |
||
265 |
// '/AUTO' |
|
266 |
pos = tc->FindF(KArgAutomatedTest); |
|
267 |
if (pos != KErrNotFound) |
|
268 |
{ |
|
269 |
// skip some of the press-any key things |
|
270 |
test.Printf(_L("Test semi-automated mode.\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
271 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL, "Test semi-automated mode.\n"); |
0 | 272 |
gSemiAutomated = ETrue; |
273 |
tokenParsed = ETrue; |
|
274 |
} |
|
275 |
||
276 |
// '/G:TESTNAME' |
|
277 |
pos = tc->FindF(KArgGoTestCase); |
|
278 |
if (pos != KErrNotFound) |
|
279 |
{ |
|
280 |
HBufC* tcPart = HBufC::NewLC(KTestCaseIdLength); |
|
281 |
TPtrC testID = tc->Right(tc->Length() - pos - KArgGoTestCase().Length()); |
|
282 |
||
283 |
LOG_VERBOSE2(_L("Parameter found:'%S'\n"), &testID); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
284 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
285 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
286 |
OstTraceExt1(TRACE_VERBOSE, CTESTENGINE_PROCESSCOMMANDLINEL_DUP01, "Parameter found:'%S'\n", testID); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
} |
0 | 288 |
|
289 |
// Check if it is a test we know of in our suite, users may provide the full |
|
290 |
// name "PBASE-USB_OTGDI-0466", or just the last 4 digits "0466", in such cases, fetch the full name |
|
291 |
if (!RTestFactory::TestCaseExists(testID)) |
|
292 |
{ // try use just the test#part |
|
293 |
TPtr tcDes = tcPart->Des(); |
|
294 |
||
295 |
// build and add the full name |
|
296 |
tcDes.Format(KidFormatterS, &testID); |
|
297 |
if (!RTestFactory::TestCaseExists(tcDes)) |
|
298 |
{ |
|
299 |
||
300 |
test.Printf(_L("Test case does NOT Exist: '%lS'\n"), &testID); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
OstTraceExt1(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL_DUP02, "Test case does NOT Exist: '%lS'\n", testID); |
0 | 302 |
} |
303 |
else |
|
304 |
{ // only the number was supplied, copy the full name |
|
305 |
testID.Set(tcDes); |
|
306 |
} |
|
307 |
} |
|
308 |
// check that it's valid before adding it to the run-list |
|
309 |
if (RTestFactory::TestCaseExists(testID)) |
|
310 |
{ |
|
311 |
HBufC* testIdentity = HBufC::NewLC(KTestCaseIdLength); |
|
312 |
*testIdentity = testID; |
|
313 |
test.Printf(_L("Test case specified: %lS\n"), testIdentity); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
314 |
OstTraceExt1(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL_DUP03, "Test case specified: %lS\n", *testIdentity); |
0 | 315 |
|
316 |
iTestCasesIdentities.Append(testIdentity); |
|
317 |
CleanupStack::Pop(testIdentity); |
|
318 |
} |
|
319 |
CleanupStack::PopAndDestroy(tcPart); |
|
320 |
tokenParsed = ETrue; |
|
321 |
} |
|
322 |
||
323 |
// '/VERBOSE' option |
|
324 |
pos = tc->FindF(KArgVerboseOutput); |
|
325 |
if (pos != KErrNotFound) |
|
326 |
{ |
|
327 |
gVerboseOutput = ETrue; |
|
328 |
tokenParsed = ETrue; |
|
329 |
||
330 |
// turn on logging of test Printf() output to serial debug/log at the same time |
|
331 |
test.SetLogged(ETrue); |
|
332 |
||
333 |
} |
|
334 |
||
335 |
// '/LOOPO:n' option (Set #times to run open/close tests amongst others) |
|
336 |
pos = tc->FindF(KArgSetOpenIterations); |
|
337 |
if (pos != KErrNotFound) |
|
338 |
{ |
|
339 |
TPtrC iterationStr = tc->Right(tc->Length() - pos - KArgSetOpenIterations().Length()); |
|
340 |
TLex lex(iterationStr); |
|
341 |
lex.Val(gOpenIterations); |
|
342 |
MINMAX_CLAMPVALUE(gOpenIterations, OPEN_MINREPEATS, OPEN_MAXREPEATS); |
|
343 |
tokenParsed = ETrue; |
|
344 |
} |
|
345 |
||
346 |
// '/LOOPM:n' option (Set # of allocs to start at for OOM test) |
|
347 |
pos = tc->FindF(KArgSetOOMIterations); |
|
348 |
if (pos != KErrNotFound) |
|
349 |
{ |
|
350 |
TPtrC iterationStr = tc->Right(tc->Length() - pos - KArgSetOOMIterations().Length()); |
|
351 |
TLex lex(iterationStr); |
|
352 |
lex.Val(gOOMIterations); |
|
353 |
MINMAX_CLAMPVALUE(gOOMIterations, OOM_MINREPEATS, OOM_MAXREPEATS); |
|
354 |
tokenParsed = ETrue; |
|
355 |
} |
|
356 |
||
357 |
||
358 |
// '/VID:nnnn' option (Set Symbian or other VID-Pid example /VID:0670) |
|
359 |
pos = tc->FindF(KArgOverrideVidPid); |
|
360 |
if (pos != KErrNotFound) |
|
361 |
{ |
|
362 |
TPtrC vidpidStr = tc->Right(tc->Length() - pos - KArgOverrideVidPid().Length()); |
|
363 |
TUint16 prodID; |
|
364 |
TLex lex(vidpidStr); |
|
365 |
||
366 |
if (KErrNone == lex.Val(prodID, EHex)) |
|
367 |
{ |
|
368 |
if (prodID> 0xFFFF) |
|
369 |
prodID = 0xFFFF; |
|
370 |
tokenParsed = ETrue; |
|
371 |
LOG_VERBOSE2(_L(" accept param %04X \n\n"), prodID); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
372 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
373 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
374 |
OstTrace1(TRACE_VERBOSE, CTESTENGINE_PROCESSCOMMANDLINEL_DUP05, " accept param %04X \n\n", prodID); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
375 |
} |
0 | 376 |
gUSBVidPid = prodID; // replace the vid-pid with the user-supplied one |
377 |
} |
|
378 |
else |
|
379 |
{ |
|
380 |
// print error |
|
381 |
test.Printf(_L("Warning: VID+PID '%lS' not parsed .\n"), tc); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
382 |
OstTraceExt1(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL_DUP06, "Warning: VID+PID '%lS' not parsed .\n", *tc); |
0 | 383 |
} |
384 |
} |
|
385 |
||
386 |
// '/SLAVE' (peer) |
|
387 |
pos = tc->FindF(KArgSetRoleSlave); |
|
388 |
if (pos != KErrNotFound) |
|
389 |
{ |
|
390 |
gTestRoleMaster = EFalse; |
|
391 |
tokenParsed = ETrue; |
|
392 |
} |
|
393 |
// '/MASTER' - default role |
|
394 |
pos = tc->FindF(KArgSetRoleMaster); // note that master is the default role, so this parameter is optional |
|
395 |
if (pos != KErrNotFound) |
|
396 |
{ |
|
397 |
gTestRoleMaster = ETrue; |
|
398 |
tokenParsed = ETrue; |
|
399 |
} |
|
400 |
||
401 |
if (!tokenParsed) |
|
402 |
{ |
|
403 |
// warn about unparsed parameter |
|
404 |
test.Printf(_L("Warning: '%lS'??? not parsed\n"), tc); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
405 |
OstTraceExt1(TRACE_NORMAL, CTESTENGINE_PROCESSCOMMANDLINEL_DUP07, "Warning: '%lS'??? not parsed\n", *tc); |
0 | 406 |
iHelpRequested = ETrue; |
407 |
} |
|
408 |
||
409 |
// next parameter |
|
410 |
*tc = args.NextToken(); |
|
411 |
} |
|
412 |
CleanupStack::PopAndDestroy(tc); |
|
413 |
CleanupStack::PopAndDestroy(cmdLine); |
|
414 |
} |
|
415 |
||
416 |
||
417 |
/** Add all default tests to the front of the test-list so we run them all in sequence |
|
418 |
*/ |
|
419 |
void CTestEngine::AddAllDefaultTests() |
|
420 |
{ |
|
421 |
test.Printf(_L("Adding default set test cases\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
422 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_ADDALLDEFAULTTESTS, "Adding default set test cases\n"); |
0 | 423 |
// |
424 |
TInt index(0); |
|
425 |
while (index < sizeof(KAllDefaultTestIDs)/sizeof(KAllDefaultTestIDs[0])) |
|
426 |
{ |
|
427 |
// allocate heap string |
|
428 |
HBufC* tc(NULL); |
|
429 |
TRAPD(err, tc = HBufC::NewL(KTestCaseIdLength)) |
|
430 |
if (err != KErrNone) |
|
431 |
{ |
|
432 |
User::Panic(_L("Test F/W Err"), KErrNoMemory); |
|
433 |
} |
|
434 |
TPtr tcDes = tc->Des(); |
|
435 |
||
436 |
// build and add it |
|
437 |
tcDes.Format(KidFormatter, KAllDefaultTestIDs[index]); |
|
438 |
iTestCasesIdentities.Append(tc); |
|
439 |
index++; |
|
440 |
} |
|
441 |
} |
|
442 |
||
443 |
||
444 |
/* Return subsequent test case IDs from the test run-list KerrNotFound = end of list. |
|
445 |
*/ |
|
446 |
TInt CTestEngine::NextTestCaseId(TDes& aTestCaseId) |
|
447 |
{ |
|
448 |
if (iTestCaseIndex < iTestCasesIdentities.Count()) |
|
449 |
{ |
|
450 |
aTestCaseId = *iTestCasesIdentities[iTestCaseIndex++]; |
|
451 |
return KErrNone; |
|
452 |
} |
|
453 |
else |
|
454 |
{ |
|
455 |
return KErrNotFound; |
|
456 |
} |
|
457 |
} |
|
458 |
||
459 |
///////////////////////////////////////////////////////////////////////////// |
|
460 |
// utility functions |
|
461 |
||
462 |
||
463 |
void CTestEngine::GetNumericInput(TInt &aNumber) |
|
464 |
{ |
|
465 |
TUint value(0); |
|
466 |
TUint digits(0); |
|
467 |
TKeyCode key = (TKeyCode) 0; |
|
468 |
||
469 |
aNumber = -1; |
|
470 |
while ( key != EKeyEnter ) |
|
471 |
{ |
|
472 |
key = test.Getch(); |
|
473 |
||
474 |
if ( ( key >= '0' ) && ( key <= '9' ) ) |
|
475 |
{ |
|
476 |
test.Printf(_L("%c"),key); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
477 |
OstTraceExt1(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT, "%c",key); |
0 | 478 |
|
479 |
value = ( 10 * value ) + ( key - '0' ); |
|
480 |
digits++; |
|
481 |
} else |
|
482 |
{ // very basic keyboard processing, backspace |
|
483 |
if (key == EKeyBackspace) |
|
484 |
{ |
|
485 |
value = value/10; |
|
486 |
digits--; |
|
487 |
test.Printf(_L("\r \r%d"), value); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
488 |
OstTrace1(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT_DUP01, "\r \r%d", value); |
0 | 489 |
} |
490 |
} |
|
491 |
} |
|
492 |
||
493 |
if (digits > 0) |
|
494 |
{ |
|
495 |
aNumber = value; |
|
496 |
} |
|
497 |
test.Printf(_L("\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
498 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT_DUP02, "\n"); |
0 | 499 |
} |
500 |
||
501 |
||
502 |
/** Print a report at the end of a test run of all PASSED tests, Note: If a |
|
503 |
test fails, the framework gets Panic'd */ |
|
504 |
void CTestEngine::Report() |
|
505 |
{ |
|
506 |
TBuf<KTestCaseIdLength> aTestCaseId; |
|
507 |
test.Printf(_L("============================\n")); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
508 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_REPORT, "============================\n"); |
0 | 509 |
test.Printf(_L("PASSED TESTS:\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
510 |
OstTrace0(TRACE_NORMAL, CTESTENGINE_REPORT_DUP01, "PASSED TESTS:\n"); |
0 | 511 |
// itterate our list of tests to perform |
512 |
ResetTestCaseIndex(); |
|
513 |
while (KErrNone == NextTestCaseId(aTestCaseId)) |
|
514 |
{ |
|
515 |
test.Printf(_L("%S\n"), &aTestCaseId); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
516 |
OstTraceExt1(TRACE_NORMAL, CTESTENGINE_REPORT_DUP02, "%S\n", aTestCaseId); |
0 | 517 |
} |
518 |
} |
|
519 |
||
520 |
||
521 |
void CTestEngine::DoCancel() |
|
522 |
{ |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
523 |
if(gVerboseOutput) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
524 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
525 |
OstTraceFunctionEntry0(CTESTENGINE_DOCANCEL); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
526 |
} |
0 | 527 |
test.Console()->ReadCancel(); |
528 |
} |
|
529 |
||
530 |
||
531 |
TInt CTestEngine::RunError(TInt aError) |
|
532 |
{ |
|
533 |
return aError; |
|
534 |
} |
|
535 |