27 #include "debugmacros.h" |
27 #include "debugmacros.h" |
28 #include "TestEngine.h" |
28 #include "TestEngine.h" |
29 #include "TestCaseController.h" |
29 #include "TestCaseController.h" |
30 #include "TestCaseFactory.h" |
30 #include "TestCaseFactory.h" |
31 #include "TestCaseRoot.h" |
31 #include "TestCaseRoot.h" |
32 #include "OstTraceDefinitions.h" |
|
33 #ifdef OST_TRACE_COMPILER_IN_USE |
|
34 #include "testengineTraces.h" |
|
35 #endif |
|
36 |
32 |
37 // Console application parameter options |
33 // Console application parameter options |
38 _LIT(KArgAllTestCases,"/ALL"); // see default test-list below |
34 _LIT(KArgAllTestCases,"/ALL"); // see default test-list below |
39 _LIT(KArgGoTestCase, "/G:"); |
35 _LIT(KArgGoTestCase, "/G:"); |
40 _LIT(KArgAutomatedTest, "/AUTO"); // removes "press any key to continue" prompts |
36 _LIT(KArgAutomatedTest, "/AUTO"); // removes "press any key to continue" prompts |
99 } |
92 } |
100 |
93 |
101 |
94 |
102 void CTestEngine::ConstructL() |
95 void CTestEngine::ConstructL() |
103 { |
96 { |
104 if(gVerboseOutput) |
97 LOG_FUNC |
105 { |
|
106 OstTraceFunctionEntry0(CTESTENGINE_CONSTRUCTL); |
|
107 } |
|
108 TInt menuSelection(0); |
98 TInt menuSelection(0); |
109 |
99 |
110 // Display information |
100 // Display information |
111 test.Title(); |
101 test.Title(); |
112 test.Start(_L("Test Engine Initiation v2.00 ")); |
102 test.Start(_L("Test Engine Initiation v2.00 ")); |
113 test.Printf(_L(">>\n")); |
103 test.Printf(_L(">>\n")); |
114 OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP01, ">>\n"); |
|
115 test.Printf(_L(">> T E S T R U N \n")); |
104 test.Printf(_L(">> T E S T R U N \n")); |
116 OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP02, ">> T E S T R U N \n"); |
|
117 test.Printf(_L(">>\n")); |
105 test.Printf(_L(">>\n")); |
118 OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP03, ">>\n"); |
|
119 |
106 |
120 |
107 |
121 // Process the command line parameters for batch/etc |
108 // Process the command line parameters for batch/etc |
122 TRAPD(err, ProcessCommandLineL()); |
109 TRAPD(err, ProcessCommandLineL()); |
123 if (err != KErrNone) |
110 if (err != KErrNone) |
142 |
129 |
143 iTestCaseIndex = 0; // be sure we go back to beginning of the collection! |
130 iTestCaseIndex = 0; // be sure we go back to beginning of the collection! |
144 iTestCasesIdentities.ResetAndDestroy(); |
131 iTestCasesIdentities.ResetAndDestroy(); |
145 |
132 |
146 test.Printf(_L("Please select 0 to %d\n"), RTestFactory::TestCaseCount()-1); |
133 test.Printf(_L("Please select 0 to %d\n"), RTestFactory::TestCaseCount()-1); |
147 OstTrace1(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP04, "Please select 0 to %d\n", RTestFactory::TestCaseCount()-1); |
|
148 test.Printf(_L("or 99<ENTER> to exit\n")); |
134 test.Printf(_L("or 99<ENTER> to exit\n")); |
149 OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP05, "or 99<ENTER> to exit\n"); |
|
150 GetNumericInput(menuSelection); |
135 GetNumericInput(menuSelection); |
151 if ((menuSelection >=0) &&(menuSelection < RTestFactory::TestCaseCount())) |
136 if ((menuSelection >=0) &&(menuSelection < RTestFactory::TestCaseCount())) |
152 { |
137 { |
153 // add it to the list,and we can go |
138 // add it to the list,and we can go |
154 TBuf<KTestCaseIdLength> aSelectionID; |
139 TBuf<KTestCaseIdLength> aSelectionID; |
166 |
151 |
167 if ((menuSelection < RTestFactory::TestCaseCount()) && (menuSelection>=0)) |
152 if ((menuSelection < RTestFactory::TestCaseCount()) && (menuSelection>=0)) |
168 { |
153 { |
169 // Create the test case controller |
154 // Create the test case controller |
170 test.Printf(_L("Creating the test controller\n")); |
155 test.Printf(_L("Creating the test controller\n")); |
171 OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP06, "Creating the test controller\n"); |
|
172 iTestCaseController = CTestCaseController::NewL(*this, ETrue); |
156 iTestCaseController = CTestCaseController::NewL(*this, ETrue); |
173 |
157 |
174 // Test-engine is non CActive class |
158 // Test-engine is non CActive class |
175 } |
159 } |
176 else |
160 else |
177 { |
161 { |
178 // nothing to do, exit. USER aborted |
162 // nothing to do, exit. USER aborted |
179 test.Printf(_L("Test run stopped by user, nothing to do.\n")); |
163 test.Printf(_L("Test run stopped by user, nothing to do.\n")); |
180 OstTrace0(TRACE_NORMAL, CTESTENGINE_CONSTRUCTL_DUP07, "Test run stopped by user, nothing to do.\n"); |
|
181 User::Leave(-2); |
164 User::Leave(-2); |
182 } |
165 } |
183 } |
166 } |
184 |
167 |
185 |
168 |
186 /* Displayed if used supplied no parameters, garbage, or a ? in the parameters |
169 /* Displayed if used supplied no parameters, garbage, or a ? in the parameters |
187 */ |
170 */ |
188 void CTestEngine::PrintUsage() |
171 void CTestEngine::PrintUsage() |
189 { |
172 { |
190 test.Printf(_L("OTGDI Unit Test Suite.\n")); |
173 test.Printf(_L("OTGDI Unit Test Suite.\n")); |
191 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE, "OTGDI Unit Test Suite.\n"); |
|
192 test.Printf(_L("Usage : t_otgdi.exe [/option] /G:<TESTNUM1>\n")); |
174 test.Printf(_L("Usage : t_otgdi.exe [/option] /G:<TESTNUM1>\n")); |
193 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP01, "Usage : t_otgdi.exe [/option] /G:<TESTNUM1>\n"); |
|
194 test.Printf(_L(" /ALL = add default test subset to List\n")); |
175 test.Printf(_L(" /ALL = add default test subset to List\n")); |
195 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP02, " /ALL = add default test subset to List\n"); |
|
196 test.Printf(_L(" /G:<TESTNUM> where <testname> is the test# to add \n")); |
176 test.Printf(_L(" /G:<TESTNUM> where <testname> is the test# to add \n")); |
197 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP03, " /G:<TESTNUM> where <testname> is the test# to add \n"); |
|
198 test.Printf(_L(" /AUTO = largely unattended operation\n")); |
177 test.Printf(_L(" /AUTO = largely unattended operation\n")); |
199 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP04, " /AUTO = largely unattended operation\n"); |
|
200 test.Printf(_L(" /VERBOSE = test debugging info\n")); |
178 test.Printf(_L(" /VERBOSE = test debugging info\n")); |
201 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP05, " /VERBOSE = test debugging info\n"); |
|
202 test.Printf(_L(" /LOOPO:<n> = Open/close repeat counter<n>\n")); |
179 test.Printf(_L(" /LOOPO:<n> = Open/close repeat counter<n>\n")); |
203 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP06, " /LOOPO:<n> = Open/close repeat counter<n>\n"); |
|
204 test.Printf(_L(" /LOOPM:<n> = OOM HEAP_ALLOCS counter<n>\n")); |
180 test.Printf(_L(" /LOOPM:<n> = OOM HEAP_ALLOCS counter<n>\n")); |
205 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP07, " /LOOPM:<n> = OOM HEAP_ALLOCS counter<n>\n"); |
|
206 test.Printf(_L(" /SLAVE = Test-peer server mode\n")); |
181 test.Printf(_L(" /SLAVE = Test-peer server mode\n")); |
207 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP08, " /SLAVE = Test-peer server mode\n"); |
|
208 test.Printf(_L(" /PID:<n> = USB VID/PID in hex eg 2670\n")); |
182 test.Printf(_L(" /PID:<n> = USB VID/PID in hex eg 2670\n")); |
209 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP09, " /PID:<n> = USB VID/PID in hex eg 2670\n"); |
|
210 test.Printf(_L("Valid test ID range 0456...0469\n")); |
183 test.Printf(_L("Valid test ID range 0456...0469\n")); |
211 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP10, "Valid test ID range 0456...0469\n"); |
|
212 test.Printf(_L("and 0675...0684 .\n")); |
184 test.Printf(_L("and 0675...0684 .\n")); |
213 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP11, "and 0675...0684 .\n"); |
|
214 test.Printf(_L("\n")); |
185 test.Printf(_L("\n")); |
215 OstTrace0(TRACE_NORMAL, CTESTENGINE_PRINTUSAGE_DUP12, "\n"); |
|
216 } |
186 } |
217 |
187 |
218 /** process the command-line, ; arguments appear in any order |
188 /** process the command-line, ; arguments appear in any order |
219 IN : User::CommandLine() |
189 IN : User::CommandLine() |
220 OUT : iTestCasesIdentities |
190 OUT : iTestCasesIdentities |
279 { |
248 { |
280 HBufC* tcPart = HBufC::NewLC(KTestCaseIdLength); |
249 HBufC* tcPart = HBufC::NewLC(KTestCaseIdLength); |
281 TPtrC testID = tc->Right(tc->Length() - pos - KArgGoTestCase().Length()); |
250 TPtrC testID = tc->Right(tc->Length() - pos - KArgGoTestCase().Length()); |
282 |
251 |
283 LOG_VERBOSE2(_L("Parameter found:'%S'\n"), &testID); |
252 LOG_VERBOSE2(_L("Parameter found:'%S'\n"), &testID); |
284 if(gVerboseOutput) |
|
285 { |
|
286 OstTraceExt1(TRACE_VERBOSE, CTESTENGINE_PROCESSCOMMANDLINEL_DUP01, "Parameter found:'%S'\n", testID); |
|
287 } |
|
288 |
253 |
289 // Check if it is a test we know of in our suite, users may provide the full |
254 // 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 |
255 // name "PBASE-USB_OTGDI-0466", or just the last 4 digits "0466", in such cases, fetch the full name |
291 if (!RTestFactory::TestCaseExists(testID)) |
256 if (!RTestFactory::TestCaseExists(testID)) |
292 { // try use just the test#part |
257 { // try use just the test#part |
472 key = test.Getch(); |
428 key = test.Getch(); |
473 |
429 |
474 if ( ( key >= '0' ) && ( key <= '9' ) ) |
430 if ( ( key >= '0' ) && ( key <= '9' ) ) |
475 { |
431 { |
476 test.Printf(_L("%c"),key); |
432 test.Printf(_L("%c"),key); |
477 OstTraceExt1(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT, "%c",key); |
|
478 |
433 |
479 value = ( 10 * value ) + ( key - '0' ); |
434 value = ( 10 * value ) + ( key - '0' ); |
480 digits++; |
435 digits++; |
481 } else |
436 } else |
482 { // very basic keyboard processing, backspace |
437 { // very basic keyboard processing, backspace |
483 if (key == EKeyBackspace) |
438 if (key == EKeyBackspace) |
484 { |
439 { |
485 value = value/10; |
440 value = value/10; |
486 digits--; |
441 digits--; |
487 test.Printf(_L("\r \r%d"), value); |
442 test.Printf(_L("\r \r%d"), value); |
488 OstTrace1(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT_DUP01, "\r \r%d", value); |
|
489 } |
443 } |
490 } |
444 } |
491 } |
445 } |
492 |
446 |
493 if (digits > 0) |
447 if (digits > 0) |
494 { |
448 { |
495 aNumber = value; |
449 aNumber = value; |
496 } |
450 } |
497 test.Printf(_L("\n")); |
451 test.Printf(_L("\n")); |
498 OstTrace0(TRACE_NORMAL, CTESTENGINE_GETNUMERICINPUT_DUP02, "\n"); |
|
499 } |
452 } |
500 |
453 |
501 |
454 |
502 /** Print a report at the end of a test run of all PASSED tests, Note: If a |
455 /** 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 */ |
456 test fails, the framework gets Panic'd */ |
504 void CTestEngine::Report() |
457 void CTestEngine::Report() |
505 { |
458 { |
506 TBuf<KTestCaseIdLength> aTestCaseId; |
459 TBuf<KTestCaseIdLength> aTestCaseId; |
507 test.Printf(_L("============================\n")); |
460 test.Printf(_L("============================\n")); |
508 OstTrace0(TRACE_NORMAL, CTESTENGINE_REPORT, "============================\n"); |
|
509 test.Printf(_L("PASSED TESTS:\n")); |
461 test.Printf(_L("PASSED TESTS:\n")); |
510 OstTrace0(TRACE_NORMAL, CTESTENGINE_REPORT_DUP01, "PASSED TESTS:\n"); |
|
511 // itterate our list of tests to perform |
462 // itterate our list of tests to perform |
512 ResetTestCaseIndex(); |
463 ResetTestCaseIndex(); |
513 while (KErrNone == NextTestCaseId(aTestCaseId)) |
464 while (KErrNone == NextTestCaseId(aTestCaseId)) |
514 { |
465 { |
515 test.Printf(_L("%S\n"), &aTestCaseId); |
466 test.Printf(_L("%S\n"), &aTestCaseId); |
516 OstTraceExt1(TRACE_NORMAL, CTESTENGINE_REPORT_DUP02, "%S\n", aTestCaseId); |
|
517 } |
467 } |
518 } |
468 } |
519 |
469 |
520 |
470 |
521 void CTestEngine::DoCancel() |
471 void CTestEngine::DoCancel() |
522 { |
472 { |
523 if(gVerboseOutput) |
473 LOG_FUNC |
524 { |
|
525 OstTraceFunctionEntry0(CTESTENGINE_DOCANCEL); |
|
526 } |
|
527 test.Console()->ReadCancel(); |
474 test.Console()->ReadCancel(); |
528 } |
475 } |
529 |
476 |
530 |
477 |
531 TInt CTestEngine::RunError(TInt aError) |
478 TInt CTestEngine::RunError(TInt aError) |