|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This module contains the implementation of |
|
15 * CTestCombiner class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <StifTestEventInterface.h> |
|
21 #include <StifLogger.h> |
|
22 #include "TestCombiner.h" |
|
23 #include "TestKeywords.h" |
|
24 #include "TestCase.h" |
|
25 #include "TestCombinerEvent.h" |
|
26 #include "Logging.h" |
|
27 //--PYTHON-- begin |
|
28 #include "StifPython.h" |
|
29 #include "StifPythonFunComb.h" |
|
30 //--PYTHON-- end |
|
31 #include "SettingServerClient.h" |
|
32 |
|
33 // EXTERNAL DATA STRUCTURES |
|
34 // None |
|
35 |
|
36 // EXTERNAL FUNCTION PROTOTYPES |
|
37 // None |
|
38 |
|
39 // CONSTANTS |
|
40 _LIT( KTestRunner, "CTestRunner" ); |
|
41 _LIT( KRemoteTimer, "CRemoteTimer" ); |
|
42 _LIT( KRemoteReceiver, "CRemoteReceiver" ); |
|
43 |
|
44 // MACROS |
|
45 #ifdef LOGGER |
|
46 #undef LOGGER |
|
47 #endif |
|
48 #define LOGGER iLog |
|
49 |
|
50 // LOCAL CONSTANTS AND MACROS |
|
51 _LIT(KTitle, "title"); |
|
52 _LIT(KTimeout, "timeout"); |
|
53 _LIT(KPriority, "priority"); |
|
54 |
|
55 //printing macros |
|
56 _LIT( KExecute, "Execute"); |
|
57 |
|
58 // MODULE DATA STRUCTURES |
|
59 // None |
|
60 |
|
61 // LOCAL FUNCTION PROTOTYPES |
|
62 // None |
|
63 |
|
64 // FORWARD DECLARATIONS |
|
65 // None |
|
66 |
|
67 // ==================== LOCAL FUNCTIONS ======================================= |
|
68 // None |
|
69 |
|
70 // ================= MEMBER FUNCTIONS ========================================= |
|
71 |
|
72 /* |
|
73 ------------------------------------------------------------------------------- |
|
74 |
|
75 Class: CTestCombiner |
|
76 |
|
77 Method: CTestCombiner |
|
78 |
|
79 Description: Default constructor |
|
80 |
|
81 C++ default constructor can NOT contain any code, that |
|
82 might leave. |
|
83 |
|
84 Parameters: None |
|
85 |
|
86 Return Values: None |
|
87 |
|
88 Errors/Exceptions: None |
|
89 |
|
90 Status: Approved |
|
91 |
|
92 ------------------------------------------------------------------------------- |
|
93 */ |
|
94 CTestCombiner::CTestCombiner(): |
|
95 iSchedulerActive( EFalse ), |
|
96 iRunningTests( 0 ), |
|
97 iResult( KErrNone ), |
|
98 iEventPckg( iEvent ), |
|
99 iRemoteTimeout( KRemoteProtocolTimeout ), |
|
100 iCancelIfError( EFalse ), |
|
101 iFailedTestCase( 0 ), |
|
102 iLoopIsUsed( EFalse ) |
|
103 { |
|
104 |
|
105 } |
|
106 |
|
107 /* |
|
108 ------------------------------------------------------------------------------- |
|
109 |
|
110 Class: CTestCombiner |
|
111 |
|
112 Method: ConstructL |
|
113 |
|
114 Description: Symbian OS second phase constructor |
|
115 |
|
116 Symbian OS default constructor can leave. |
|
117 |
|
118 Parameters: None |
|
119 |
|
120 Return Values: None |
|
121 |
|
122 Errors/Exceptions: None. |
|
123 |
|
124 Status: Approved |
|
125 |
|
126 ------------------------------------------------------------------------------- |
|
127 */ |
|
128 void CTestCombiner::ConstructL() |
|
129 { |
|
130 // TRAPed to avoid crashing if logfile creation fails, |
|
131 // so we can run test without logging to file |
|
132 TRAPD( err, iStdLog = CStifLogger::NewL( KTestCombinerLogDir, |
|
133 KTestCombinerLogFile ); |
|
134 ); |
|
135 if( err != KErrNone ) |
|
136 { |
|
137 iStdLog = NULL; |
|
138 __RDEBUG( (_L("Creating logfile failed") ) ); |
|
139 } |
|
140 iLog = iStdLog; |
|
141 |
|
142 //Read logger settings to check whether test case name is to be |
|
143 //appended to log file name. |
|
144 RSettingServer settingServer; |
|
145 TInt ret = settingServer.Connect(); |
|
146 if(ret != KErrNone) |
|
147 { |
|
148 User::Leave(ret); |
|
149 } |
|
150 // Struct to StifLogger settigs. |
|
151 TLoggerSettings loggerSettings; |
|
152 // Parse StifLogger defaults from STIF initialization file. |
|
153 ret = settingServer.GetLoggerSettings(loggerSettings); |
|
154 if(ret != KErrNone) |
|
155 { |
|
156 User::Leave(ret); |
|
157 } |
|
158 |
|
159 // Get engine settings |
|
160 TEngineSettings engineSettings; |
|
161 ret = settingServer.GetEngineSettings(engineSettings); |
|
162 if(ret != KErrNone) |
|
163 { |
|
164 __TRACE(KError, (_L("Could not retrieve engine settings from SettingServer [%d]"), ret)); |
|
165 iUITestingSupport = EFalse; |
|
166 iSeparateProcesses = EFalse; |
|
167 } |
|
168 else |
|
169 { |
|
170 iUITestingSupport = engineSettings.iUITestingSupport; |
|
171 iSeparateProcesses = engineSettings.iSeparateProcesses; |
|
172 __TRACE(KMessage, (_L("Engine settings retrieved from SettingServer. UITestingSupport [%d] SeparateProcesses [%d]"), iUITestingSupport, iSeparateProcesses)); |
|
173 } |
|
174 |
|
175 // Close Setting server session |
|
176 settingServer.Close(); |
|
177 iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle; |
|
178 |
|
179 iIndexTestModuleControllers = 1; |
|
180 |
|
181 __TRACE( KPrint, ( _L("New TestCombiner") ) ); |
|
182 |
|
183 } |
|
184 |
|
185 /* |
|
186 ------------------------------------------------------------------------------- |
|
187 |
|
188 Class: CTestCombiner |
|
189 |
|
190 Method: NewL |
|
191 |
|
192 Description: Two-phased constructor. |
|
193 |
|
194 Parameters: None |
|
195 |
|
196 Return Values: CTestCombiner*: new object |
|
197 |
|
198 Errors/Exceptions: Leaves if new or ConstructL leaves. |
|
199 |
|
200 Status: Approved |
|
201 |
|
202 ------------------------------------------------------------------------------- |
|
203 */ |
|
204 CTestCombiner* CTestCombiner::NewL() |
|
205 { |
|
206 |
|
207 CTestCombiner* self = new (ELeave) CTestCombiner(); |
|
208 |
|
209 CleanupStack::PushL( self ); |
|
210 self->ConstructL(); |
|
211 CleanupStack::Pop(); |
|
212 |
|
213 return self; |
|
214 |
|
215 } |
|
216 |
|
217 /* |
|
218 ------------------------------------------------------------------------------- |
|
219 |
|
220 Class: CTestCombiner |
|
221 |
|
222 Method: ~CTestCombiner |
|
223 |
|
224 Description: Destructor |
|
225 |
|
226 Parameters: None |
|
227 |
|
228 Return Values: None |
|
229 |
|
230 Errors/Exceptions: None |
|
231 |
|
232 Status: Approved |
|
233 |
|
234 ------------------------------------------------------------------------------- |
|
235 */ |
|
236 CTestCombiner::~CTestCombiner() |
|
237 { |
|
238 iLoopAllocationArray.Reset(); |
|
239 iLoopAllocationArray.Close(); |
|
240 iLoopIsUsed = EFalse; |
|
241 |
|
242 iTestCases.ResetAndDestroy(); |
|
243 iTestModules.ResetAndDestroy(); |
|
244 iEventArray.ResetAndDestroy(); |
|
245 iSlaveArray.ResetAndDestroy(); |
|
246 iSendReceive.ResetAndDestroy(); |
|
247 |
|
248 iTestCases.Close(); |
|
249 iTestModules.Close(); |
|
250 iEventArray.Close(); |
|
251 iSlaveArray.Close(); |
|
252 iSendReceive.Close(); |
|
253 |
|
254 // Stop all remaining measurement modules |
|
255 const TInt count_meas = iTestMeasurementArray.Count(); |
|
256 for( TInt b = 0; b < count_meas; b++ ) |
|
257 { |
|
258 iTestMeasurementArray[b]->iMeasurement->Stop(); |
|
259 } |
|
260 iTestMeasurementArray.ResetAndDestroy(); |
|
261 iTestMeasurementArray.Close(); |
|
262 |
|
263 delete iSectionParser; |
|
264 delete iRemoteReceiver; |
|
265 delete iTestRunner; |
|
266 |
|
267 iLog = NULL; |
|
268 delete iStdLog; |
|
269 iStdLog = NULL; |
|
270 delete iTCLog; |
|
271 iTCLog = NULL; |
|
272 } |
|
273 |
|
274 /* |
|
275 ------------------------------------------------------------------------------- |
|
276 |
|
277 Class: CTestCombiner |
|
278 |
|
279 Method: InitL |
|
280 |
|
281 Description: InitL is used to initialize the Test Module. |
|
282 |
|
283 Parameters: const TFileName& aIniFile: in: Initialization file |
|
284 TBool aFirstTime: in: First time flag |
|
285 |
|
286 Return Values: Symbian OS error code |
|
287 |
|
288 Errors/Exceptions: Leaves if ReadInitializationL leaves |
|
289 |
|
290 Status: Draft |
|
291 |
|
292 ------------------------------------------------------------------------------- |
|
293 */ |
|
294 TInt CTestCombiner::InitL( TFileName& aIniFile, |
|
295 TBool /*aFirstTime*/ ) |
|
296 { |
|
297 |
|
298 __TRACEFUNC(); |
|
299 |
|
300 if( aIniFile.Length() > 0 ) |
|
301 { |
|
302 // Read initialization from test case file |
|
303 ReadInitializationL( aIniFile ); |
|
304 } |
|
305 |
|
306 return KErrNone; |
|
307 |
|
308 } |
|
309 |
|
310 /* |
|
311 ------------------------------------------------------------------------------- |
|
312 |
|
313 Class: CTestCombiner |
|
314 |
|
315 Method: GetTestCases |
|
316 |
|
317 Description: GetTestCases is used to inquired test cases |
|
318 |
|
319 Parameters: const TFileName& aConfigFile: in: Config file name |
|
320 RPointerArray<RTestEngine::TTestCaseInfo>& aTestCases: out: |
|
321 Array of TestCases |
|
322 |
|
323 Return Values: KErrNone: Success |
|
324 KErrNotFound: Testcases not found |
|
325 |
|
326 Errors/Exceptions: Leaves if CStifParser::NewL leaves |
|
327 Leaves if CStifParser::SectionL leaves |
|
328 Leaves if CStifParser::NextSectionL leaves |
|
329 Leaves if memory allocation fails |
|
330 |
|
331 Status: Approved |
|
332 |
|
333 ------------------------------------------------------------------------------- |
|
334 */ |
|
335 TInt CTestCombiner::GetTestCasesL( const TFileName& aConfigFile, |
|
336 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
337 { |
|
338 __TRACEFUNC(); |
|
339 |
|
340 if( aConfigFile.Length() == 0 ) |
|
341 { |
|
342 __TRACE( KError, (_L("No test case script file given") ) ); |
|
343 __RDEBUG( (_L("No test case script file given") ) ); |
|
344 return KErrNotFound; |
|
345 } |
|
346 |
|
347 CStifParser* parser = NULL; |
|
348 TRAPD( err, parser = |
|
349 CStifParser::NewL( _L(""), aConfigFile, CStifParser::ECStyleComments ) ); |
|
350 if( err != KErrNone ) |
|
351 { |
|
352 __TRACE( KError, (_L("Test case script file not found") ) ); |
|
353 __RDEBUG( (_L("Test case script file not found") ) ); |
|
354 return KErrNotFound; |
|
355 } |
|
356 CleanupStack::PushL( parser ); |
|
357 CStifSectionParser* section; |
|
358 TPtrC tmp; |
|
359 TInt index = 0; |
|
360 TInt ret = KErrNone; |
|
361 |
|
362 section = parser->SectionL( KTestStartTag, KTestEndTag ); |
|
363 if( section == NULL ) |
|
364 { |
|
365 ret = KErrNotFound; |
|
366 } |
|
367 else |
|
368 { |
|
369 while( section ) |
|
370 { |
|
371 CleanupStack::PushL( section ); |
|
372 |
|
373 if( section->GetLine( KTitle, tmp, ENoTag ) == KErrNone ) |
|
374 { |
|
375 if( tmp.Length() > KMaxName ) |
|
376 { |
|
377 tmp.Set( tmp.Left( KMaxName ) ); |
|
378 } |
|
379 TTestCaseInfo* tc = new ( ELeave ) TTestCaseInfo(); |
|
380 CleanupStack::PushL( tc ); |
|
381 __TRACE( KVerbose, (_L("TestCase: %S"), &tmp)); |
|
382 tc->iTitle.Copy( tmp ); |
|
383 tc->iCaseNumber = ++index; |
|
384 CStifItemParser* item = section->GetItemLineL( KTimeout ); |
|
385 if( item ) |
|
386 { |
|
387 TInt timeout; // In milliseconds |
|
388 ret = item->GetInt( KTimeout, timeout ); |
|
389 if( ret != KErrNone ) |
|
390 { |
|
391 __TRACE( KError, (_L("Illegal timeout"))); |
|
392 User::Leave( ret ); |
|
393 } |
|
394 tc->iTimeout = (TInt64)timeout*1000; |
|
395 __TRACE( KMessage, (_L("Timeout: %i"), tc->iTimeout.Int64() )); |
|
396 } |
|
397 item = section->GetItemLineL( KPriority ); |
|
398 if( item ) |
|
399 { |
|
400 ret = item->GetInt( KPriority, tc->iPriority ); |
|
401 if( ret != KErrNone ) |
|
402 { |
|
403 TPtrC priority; |
|
404 ret = item->GetString( KPriority, priority ); |
|
405 if( ret != KErrNone ) |
|
406 { |
|
407 __TRACE( KError, (_L("Illegal priority"))); |
|
408 User::Leave( ret ); |
|
409 } |
|
410 switch( TTCKeywords::Parse( priority, |
|
411 TTCKeywords::Priority ) ) |
|
412 { |
|
413 case TTCKeywords::EPriHigh: |
|
414 tc->iPriority = TTestCaseInfo::EPriorityHigh; |
|
415 break; |
|
416 case TTCKeywords::EPriNormal: |
|
417 tc->iPriority = TTestCaseInfo::EPriorityNormal; |
|
418 break; |
|
419 case TTCKeywords::EPriLow: |
|
420 tc->iPriority = TTestCaseInfo::EPriorityLow; |
|
421 break; |
|
422 default: |
|
423 __TRACE( KError, (_L("Illegal priority"))); |
|
424 User::Leave( KErrArgument ); |
|
425 } |
|
426 } |
|
427 __TRACE( KMessage, (_L("Priority: %i"), tc->iPriority )); |
|
428 } |
|
429 |
|
430 aTestCases.Append(tc); |
|
431 CleanupStack::Pop( tc ); |
|
432 } |
|
433 CleanupStack::PopAndDestroy( section ); |
|
434 section = parser->NextSectionL( KTestStartTag, KTestEndTag ); |
|
435 } |
|
436 } |
|
437 |
|
438 CleanupStack::PopAndDestroy( parser ); |
|
439 |
|
440 __TRACE( KPrint, ( _L( "Configfile '%S', testcases %d" ), |
|
441 &aConfigFile, index )); |
|
442 |
|
443 return ret; |
|
444 |
|
445 } |
|
446 |
|
447 /* |
|
448 ------------------------------------------------------------------------------- |
|
449 |
|
450 Class: CTestCombiner |
|
451 |
|
452 Method: RunTestCaseL |
|
453 |
|
454 Description: Run a specified testcase. |
|
455 |
|
456 RunTestCaseL is used to run an individual test case specified |
|
457 by aTestCase. |
|
458 |
|
459 Parameters: const TInt aCaseNumber: in: Testcase number |
|
460 const TFileName& aConfig: in: Configuration file name |
|
461 TTestResult& aResult: out; test case result |
|
462 |
|
463 Return Values: KErrNone: Test case started succesfully. |
|
464 KErrNotFound: Testcase not found |
|
465 KErrUnknown: Unknown TestCombiner error |
|
466 Any other SymbianOS error |
|
467 |
|
468 Errors/Exceptions: Leaves if GetTestCaseL leaves |
|
469 Leaves if RunTestL leaves |
|
470 Leaves if memory allocation fails |
|
471 |
|
472 Status: Approved |
|
473 |
|
474 ------------------------------------------------------------------------------- |
|
475 */ |
|
476 TInt CTestCombiner::RunTestCaseL( const TInt aCaseNumber, |
|
477 const TFileName& aConfig, |
|
478 TTestResult& aResult ) |
|
479 { |
|
480 __TRACEFUNC(); |
|
481 |
|
482 __TRACE( KMessage, (_L("***Testcase started***"))); |
|
483 |
|
484 //Open new log file with test case title in file name |
|
485 if(iAddTestCaseTitleToLogName) |
|
486 { |
|
487 //Close test case log if exists |
|
488 if(iTCLog) |
|
489 { |
|
490 delete iTCLog; |
|
491 iTCLog = NULL; |
|
492 } |
|
493 TFileName logFileName; |
|
494 TName title; |
|
495 TestModuleIf().GetTestCaseTitleL(title); |
|
496 |
|
497 logFileName.Format(KTestCombinerLogFileWithTitle, &title); |
|
498 iTCLog = CStifLogger::NewL(KTestCombinerLogDir, logFileName); |
|
499 iLog = iTCLog; |
|
500 } |
|
501 |
|
502 /* |
|
503 * Allow memory leaks, because Defines are leaved untouched |
|
504 * after test case execution. Real memory leaks are detected with |
|
505 * UHEAP macros. |
|
506 */ |
|
507 TestModuleIf().SetBehavior( CTestModuleIf::ETestLeaksMem ); |
|
508 |
|
509 // Read initialization from test case file |
|
510 ReadInitializationL( aConfig ); |
|
511 |
|
512 __UHEAP_MARK; |
|
513 |
|
514 iSectionParser = GetTestCaseL( aCaseNumber, aConfig ); |
|
515 |
|
516 // Check parsing result |
|
517 if( iSectionParser == NULL ) |
|
518 { |
|
519 __TRACE( KError, (_L("***Parsing testcase failed***"))); |
|
520 __UHEAP_MARKEND; |
|
521 return KErrNotFound; |
|
522 } |
|
523 |
|
524 CActiveScheduler* activeScheduler = |
|
525 new ( ELeave ) CActiveScheduler(); |
|
526 CleanupStack::PushL( activeScheduler ); |
|
527 CActiveScheduler::Install( activeScheduler ); |
|
528 |
|
529 // Resetting these variables to normal state @js |
|
530 iFailedTestCase = 0; |
|
531 iCancelIfError = EFalse; |
|
532 iScriptFailed = KErrNone; |
|
533 iScriptFailedDescription.Copy(KNullDesC); |
|
534 |
|
535 // Run the given testcase described in iSectionParser section |
|
536 RunTestL(); |
|
537 |
|
538 CleanupStack::PopAndDestroy( activeScheduler ); |
|
539 |
|
540 delete iSectionParser; |
|
541 iSectionParser = NULL; |
|
542 |
|
543 TInt ret = KErrNone; |
|
544 // Check if test case starting failed |
|
545 if( iResult != KErrNone ) |
|
546 { |
|
547 TestModuleIf().Printf( KPrintPriHigh, _L("Result"), _L("Starting FAILED")); |
|
548 __TRACE( KError, (_L("***Starting testcase FAILED***"))); |
|
549 ret = iResult; |
|
550 aResult.iResult = -2; |
|
551 aResult.iResultDes = _L("Testcase script execution failed"); |
|
552 } |
|
553 else if(iScriptFailed != KErrNone) |
|
554 { |
|
555 TestModuleIf().Printf( KPrintPriHigh, _L("Result"), _L("Script execution FAILED")); |
|
556 __TRACE( KError, (_L("***Sscript execution FAILED***"))); |
|
557 aResult.iResult = iScriptFailed; |
|
558 if(iScriptFailedDescription != KNullDesC) |
|
559 { |
|
560 aResult.iResultDes.Copy(iScriptFailedDescription); |
|
561 } |
|
562 else |
|
563 { |
|
564 aResult.iResultDes = _L("Testcase script execution failed"); |
|
565 } |
|
566 } |
|
567 else |
|
568 { |
|
569 __TRACE( KPrint, (_L("***Testcase completed***"))); |
|
570 |
|
571 // Testcombiner succeeded to start all testcases, |
|
572 // check individual testcase results |
|
573 TInt count = iTestCases.Count(); |
|
574 TInt i = iFailedTestCase; |
|
575 // iFailedTestCase is either 0 or the number of failed test case if |
|
576 // canceliferror was given and a test case has failed |
|
577 |
|
578 for(; i < count; i++ ) |
|
579 { |
|
580 // All cases should be completed now |
|
581 if( iTestCases[i]->State() != CTCTestCase::ETestCaseCompleted ) |
|
582 { |
|
583 // This is some unknown internal TestCombiner error |
|
584 // Should not happen |
|
585 __TRACE( KError, (_L("TestCase (%S) not completed"), |
|
586 &iTestCases[i]->TestId() )); |
|
587 ret = KErrUnknown; |
|
588 break; |
|
589 } |
|
590 |
|
591 // Interpret execution result type from returned result |
|
592 TInt executionResult = TFullTestResult::ECaseExecuted; // Ok |
|
593 if( iTestCases[i]->iResult.iCaseExecutionResultType >= |
|
594 TFullTestResult::ECaseLeave ) |
|
595 { |
|
596 // Some abnormal execution result type |
|
597 executionResult = iTestCases[i]->iResult.iCaseExecutionResultType; |
|
598 } |
|
599 |
|
600 // Check expected execution result type |
|
601 if( executionResult != iTestCases[i]->ExpectedResultCategory() ) |
|
602 { |
|
603 // expected and returned result types differ |
|
604 aResult.iResult = KErrGeneral; |
|
605 aResult.iResultDes.Copy( _L("Test case completed with ") ); |
|
606 aResult.iResultDes.Append( |
|
607 TTCKeywords::ResultCategory( |
|
608 iTestCases[i]->iResult.iCaseExecutionResultType )); |
|
609 aResult.iResultDes.Append( _L(" and expected was ") ); |
|
610 aResult.iResultDes.Append( |
|
611 TTCKeywords::ResultCategory( |
|
612 iTestCases[i]->ExpectedResultCategory() )); |
|
613 AppendTestResultToResultDes(aResult.iResultDes, iTestCases[i]->iResult.iTestResult.iResultDes); |
|
614 __TRACE( KPrint, ( _L( "%S"), &aResult.iResultDes ) ); |
|
615 break; |
|
616 } |
|
617 |
|
618 // Check normal test result |
|
619 if( iTestCases[i]->ExpectedResultCategory() == |
|
620 TFullTestResult:: ECaseExecuted ) |
|
621 { |
|
622 // Normal completion, check result |
|
623 if( iTestCases[i]->iResult.iTestResult.iResult != |
|
624 iTestCases[i]->ExpectedResult() ) |
|
625 { |
|
626 __TRACE( KPrint, ( _L( "Test failed, expect(%d) != result(%d)"), |
|
627 iTestCases[i]->ExpectedResult(), |
|
628 iTestCases[i]->iResult.iTestResult.iResult )); |
|
629 // We return the first error result as aResult |
|
630 if( iTestCases[i]->iResult.iTestResult.iResult != KErrNone ) |
|
631 { |
|
632 aResult = iTestCases[i]->iResult.iTestResult; |
|
633 } |
|
634 else |
|
635 { |
|
636 aResult.iResult = KErrGeneral; |
|
637 aResult.iResultDes.Copy( _L("Test case completed with KErrNone and expected ")); |
|
638 aResult.iResultDes.AppendNum( iTestCases[i]->ExpectedResult() ); |
|
639 AppendTestResultToResultDes(aResult.iResultDes, iTestCases[i]->iResult.iTestResult.iResultDes); |
|
640 } |
|
641 break; |
|
642 } |
|
643 } |
|
644 else |
|
645 { |
|
646 // Abnormal completion, i.e. panic, leave, exception or timeout |
|
647 if( iTestCases[i]->iResult.iCaseExecutionResultCode != |
|
648 iTestCases[i]->ExpectedResult() ) |
|
649 { |
|
650 __TRACE( KPrint, ( _L( "Test failed, expect errorcode(%d) != result(%d)"), |
|
651 iTestCases[i]->ExpectedResult(), |
|
652 iTestCases[i]->iResult.iCaseExecutionResultCode ) ); |
|
653 // We return the first error result as aResult |
|
654 aResult = iTestCases[i]->iResult.iTestResult; |
|
655 // override result with real error code |
|
656 aResult.iResult = iTestCases[i]->iResult.iCaseExecutionResultCode; |
|
657 break; |
|
658 } |
|
659 } |
|
660 } |
|
661 if( i == count ) |
|
662 { |
|
663 TestModuleIf().Printf( KPrintPriHigh, _L("Result"), _L("PASSED")); |
|
664 __TRACE( KPrint, (_L("***Test case result: PASSED***"))); |
|
665 aResult.iResult = KErrNone; |
|
666 aResult.iResultDes.Copy( _L("Test case succeeded") ); |
|
667 } |
|
668 else |
|
669 { |
|
670 TestModuleIf().Printf( KPrintPriHigh, _L("Result"), _L("FAILED")); |
|
671 __TRACE( KPrint, (_L("***Test case result: FAILED***"))); |
|
672 } |
|
673 } |
|
674 |
|
675 // Release all pending event requests |
|
676 TEventIf event( TEventIf::ERelEvent ); |
|
677 TInt eventCount = iEventArray.Count(); |
|
678 for( TInt ind=0; ind < eventCount; ind++ ) |
|
679 { |
|
680 event.SetName( iEventArray[ind]->Name() ); |
|
681 TestModuleIf().Event( event ); |
|
682 } |
|
683 |
|
684 iLoopAllocationArray.Reset(); |
|
685 iLoopAllocationArray.Close(); |
|
686 iLoopIsUsed = EFalse; |
|
687 |
|
688 // Delete all completed and checked testcases |
|
689 // Do not change the deletion order of events and test cases!!! |
|
690 iEventArray.ResetAndDestroy(); |
|
691 iTestCases.ResetAndDestroy(); |
|
692 iTestModules.ResetAndDestroy(); |
|
693 iSlaveArray.ResetAndDestroy(); |
|
694 |
|
695 iSendReceive.ResetAndDestroy(); |
|
696 |
|
697 // Stop all remaining measurement modules |
|
698 const TInt count_meas = iTestMeasurementArray.Count(); |
|
699 for( TInt b = 0; b < count_meas; b++ ) |
|
700 { |
|
701 iTestMeasurementArray[b]->iMeasurement->Stop(); |
|
702 } |
|
703 iTestMeasurementArray.ResetAndDestroy(); |
|
704 iTestMeasurementArray.Close(); |
|
705 |
|
706 __UHEAP_MARKEND; |
|
707 |
|
708 //If log was replaced then restore it |
|
709 if(iAddTestCaseTitleToLogName) |
|
710 { |
|
711 iLog = iStdLog; |
|
712 delete iTCLog; |
|
713 iTCLog = NULL; |
|
714 } |
|
715 |
|
716 return ret; |
|
717 |
|
718 } |
|
719 |
|
720 /* |
|
721 ------------------------------------------------------------------------------- |
|
722 |
|
723 Class: CTestCombiner |
|
724 |
|
725 Method: GetTestCaseL |
|
726 |
|
727 Description: Get specified test case section from configfile. |
|
728 |
|
729 Parameters: const TInt aCaseNumber: in: Test case number |
|
730 const TFileName& aConfig: in: Configfile name |
|
731 |
|
732 Return Values: CSectionParser*: pointer to test case section |
|
733 |
|
734 Errors/Exceptions: Leaves if CStifParser::NewL leaves |
|
735 Leaves if CStifParser::SectionL leaves |
|
736 Leaves if memory allocation fails |
|
737 |
|
738 Status: Approved |
|
739 |
|
740 ------------------------------------------------------------------------------- |
|
741 */ |
|
742 CStifSectionParser* CTestCombiner::GetTestCaseL( const TInt aCaseNumber, |
|
743 const TFileName& aConfig ) |
|
744 { |
|
745 __TRACEFUNC(); |
|
746 CStifParser* parser = |
|
747 CStifParser::NewL( _L(""), aConfig, CStifParser::ECStyleComments ); |
|
748 CleanupStack::PushL( parser ); |
|
749 |
|
750 CStifSectionParser* section = |
|
751 parser->SectionL( KTestStartTag, KTestEndTag, aCaseNumber ); |
|
752 |
|
753 CleanupStack::PopAndDestroy( parser ); |
|
754 return section; |
|
755 } |
|
756 |
|
757 /* |
|
758 ------------------------------------------------------------------------------- |
|
759 |
|
760 Class: CTestCombiner |
|
761 |
|
762 Method: ReadInitializationL |
|
763 |
|
764 Description: Read initialization from file. |
|
765 |
|
766 Parameters: const TDesC& aIniFile: in: File that contains initialization |
|
767 |
|
768 Return Values: None |
|
769 |
|
770 Errors/Exceptions: None |
|
771 |
|
772 Status: Draft |
|
773 |
|
774 ------------------------------------------------------------------------------- |
|
775 */ |
|
776 void CTestCombiner::ReadInitializationL( const TDesC& aIniFile ) |
|
777 { |
|
778 CStifParser* parser = NULL; |
|
779 |
|
780 // Open file |
|
781 TRAPD( err, parser = |
|
782 CStifParser::NewL( _L(""), aIniFile, CStifParser::ECStyleComments ) ); |
|
783 if( ( err == KErrNone ) && parser ) |
|
784 { |
|
785 CleanupStack::PushL( parser ); |
|
786 __TRACE( KMessage, (_L("Read initialization from [%S]"), |
|
787 &aIniFile ) ); |
|
788 |
|
789 // Read initialization parameters |
|
790 CStifSectionParser* section = parser->SectionL( KInitStartTag, |
|
791 KInitEndTag ); |
|
792 if( section ) |
|
793 { |
|
794 CleanupStack::PushL( section ); |
|
795 __TRACE( KMessage, (_L("Read initializations")) ); |
|
796 |
|
797 // Read RCP timeout |
|
798 CStifItemParser* item = section->GetItemLineL( KInitRcpTimeout ); |
|
799 if( item != NULL ) |
|
800 { |
|
801 __TRACE( KMessage, (_L("Got RCP timeout definition")) ); |
|
802 CleanupStack::PushL( item ); |
|
803 |
|
804 TInt value; |
|
805 if( item->GetInt( KInitRcpTimeout, value ) |
|
806 != KErrNone ) |
|
807 { |
|
808 __TRACE( KError, (_L("No RCP timeout value given")) ); |
|
809 User::Leave( KErrGeneral ); |
|
810 } |
|
811 // Change from seconds to milliseconds |
|
812 iRemoteTimeout = value*1000*1000; |
|
813 CleanupStack::PopAndDestroy( item ); |
|
814 } |
|
815 |
|
816 CleanupStack::PopAndDestroy( section ); |
|
817 } |
|
818 |
|
819 // Read defines |
|
820 section = parser->SectionL( KDefineStartTag, KDefineEndTag ); |
|
821 while(section) |
|
822 { |
|
823 CleanupStack::PushL( section ); |
|
824 __TRACE( KMessage, (_L("Read defines")) ); |
|
825 |
|
826 TPtrC name; |
|
827 TPtrC value; |
|
828 CStifItemParser* item = section->GetItemLineL( _L("") ); |
|
829 while( item ) |
|
830 { |
|
831 CleanupStack::PushL( item ); |
|
832 |
|
833 if( item->GetString( _L(""), name ) != KErrNone ) |
|
834 { |
|
835 __TRACE( KError, (_L("No define name given")) ); |
|
836 User::Leave( KErrGeneral ); |
|
837 } |
|
838 if( item->Remainder( value ) != KErrNone ) |
|
839 { |
|
840 __TRACE( KError, (_L("No define value given")) ); |
|
841 User::Leave( KErrGeneral ); |
|
842 } |
|
843 TInt count = iDefined.Count(); |
|
844 TInt i = 0; |
|
845 for( ; i < count; i++ ) |
|
846 { |
|
847 if( iDefined[i]->Name() == name ) |
|
848 { |
|
849 __TRACE( KMessage, (_L("Update define %S:%S"), &name, &value ) ); |
|
850 // Update existing |
|
851 iDefined[i]->SetValueL( value ); |
|
852 break; |
|
853 } |
|
854 } |
|
855 if( i == count) |
|
856 { |
|
857 // New define, store it |
|
858 CDefinedValue* define = CDefinedValue::NewL( name, value ); |
|
859 CleanupStack::PushL( define ); |
|
860 User::LeaveIfError( iDefined.Append( define ) ); |
|
861 CleanupStack::Pop( define ); |
|
862 } |
|
863 |
|
864 CleanupStack::PopAndDestroy( item ); |
|
865 item = section->GetNextItemLineL(); |
|
866 } |
|
867 CleanupStack::PopAndDestroy( section ); |
|
868 section = parser->NextSectionL(KDefineStartTag, KDefineEndTag); |
|
869 } |
|
870 CleanupStack::PopAndDestroy( parser ); |
|
871 } |
|
872 } |
|
873 |
|
874 /* |
|
875 ------------------------------------------------------------------------------- |
|
876 |
|
877 Class: CTestCombiner |
|
878 |
|
879 Method: RunTestL |
|
880 |
|
881 Description: Run a testcase specified by iSectionParser. |
|
882 |
|
883 Parameters: None |
|
884 |
|
885 Return Values: None. |
|
886 |
|
887 Errors/Exceptions: Leaves if CSectionParser::GetItemLineL leaves |
|
888 Leaves if CTestRunner::NewL leaves |
|
889 Leaves if memory allocation fails |
|
890 |
|
891 Status: Approved |
|
892 |
|
893 ------------------------------------------------------------------------------- |
|
894 */ |
|
895 void CTestCombiner::RunTestL() |
|
896 { |
|
897 __TRACEFUNC(); |
|
898 iResult = KErrNone; |
|
899 |
|
900 TPtrC line; |
|
901 // "title" keyword must be in the first line |
|
902 User::LeaveIfError( iSectionParser->GetLine( KTitle, line, ENoTag ) ); |
|
903 |
|
904 iTestRunner = CTestRunner::NewL( this ); |
|
905 iRemoteReceiver = CRemoteReceiver::NewL( this ); |
|
906 iRemoteReceiver->Start(); |
|
907 |
|
908 __TRACE( KMessage, (_L("Run: %S"), &line)); |
|
909 |
|
910 TestModuleIf().Printf( KPrintPriNorm, _L("Run"), _L("%S"), &line); |
|
911 // Rest of the job is done by test runner |
|
912 iTestRunner->SetRunnerActive(); |
|
913 |
|
914 // Start activeScheduler looping testcase lines |
|
915 iSchedulerActive = ETrue; |
|
916 __TRACE( KMessage, (_L("Start CActiveScheduler"))); |
|
917 CActiveScheduler::Current()->Start(); |
|
918 |
|
919 TestModuleIf().Printf( KPrintPriNorm, _L("Executed"), _L("%S"), &line); |
|
920 __TRACE( KMessage, (_L("Executed: %S"), &line)); |
|
921 |
|
922 delete iRemoteReceiver; |
|
923 iRemoteReceiver = NULL; |
|
924 delete iTestRunner; |
|
925 iTestRunner = NULL; |
|
926 |
|
927 } |
|
928 |
|
929 /* |
|
930 ------------------------------------------------------------------------------- |
|
931 |
|
932 Class: CTestCombiner |
|
933 |
|
934 Method: GetTestModuleL |
|
935 |
|
936 Description: Load testmodule if not already loaded, otherwise return |
|
937 description of the loaded testmodule. |
|
938 |
|
939 Parameters: TDesC& aModule: in: Module name. |
|
940 TDesC& aIniFile: in: Ini file name. |
|
941 const TDesC& aConfigFile: in: Test case(config) file name. |
|
942 |
|
943 Return Values: CTCTestModule*: pointer to testmodules description |
|
944 |
|
945 Errors/Exceptions: Leaves if CTCTestModule::NewL leaves |
|
946 Leaves if RPointerArray::Append fails |
|
947 |
|
948 Status: Proposal |
|
949 |
|
950 ------------------------------------------------------------------------------- |
|
951 */ |
|
952 CTCTestModule* CTestCombiner::GetTestModuleL( TDesC& aModule, |
|
953 TDesC& aIniFile, |
|
954 const TDesC& aConfigFile ) |
|
955 { |
|
956 __TRACEFUNC(); |
|
957 TInt count = iTestModules.Count(); |
|
958 TInt i, j; |
|
959 TInt counttc; |
|
960 TInt running; |
|
961 TBool newWay = EFalse; |
|
962 |
|
963 __TRACE(KMessage, (_L("Find test module for [%S]"), &aModule)); |
|
964 |
|
965 //Name for new module controller |
|
966 TName newModuleName = aModule; |
|
967 |
|
968 //Check if it is python case or UITestingSupport or SeparateProcesses mode |
|
969 newWay = (aModule.Find(KPythonScripter) == 0) |
|
970 || (iUITestingSupport && aModule.Find(KTestScripterName) == 0) |
|
971 || (iSeparateProcesses); |
|
972 |
|
973 if(newWay) |
|
974 { |
|
975 __TRACE(KMessage, (_L("TCTestModule operating mode: exclusive"))); |
|
976 |
|
977 //Find module of given name |
|
978 __TRACE(KMessage, (_L("Looking for module [%S]"), &aModule)); |
|
979 if(iUITestingSupport && aModule.Find(KTestScripterName) == 0) |
|
980 { |
|
981 __TRACE(KMessage, (_L("UITestingSupport option is on. New module controller will be created always"))); |
|
982 } |
|
983 else |
|
984 { |
|
985 for(i = 0; i < count; i++) |
|
986 { |
|
987 TPtrC modName = iTestModules[i]->ModuleName(); |
|
988 if(modName.Find(aModule) == 0) |
|
989 { |
|
990 //Check if there is running test case |
|
991 counttc = iTestCases.Count(); |
|
992 running = 0; |
|
993 for(j = 0; j < counttc; j++) |
|
994 { |
|
995 if(iTestCases[j]->TestModule() == iTestModules[i] && iTestCases[j]->State() != CTestCase::ETestCaseCompleted) |
|
996 { |
|
997 //We have found at least one running test case. There is no reason to find any more, |
|
998 //because there shouldn't be because test module may run only one python scripter test case. |
|
999 running++; |
|
1000 __TRACE(KMessage, (_L("Module controller found [%S], but it has running test cases"), &modName)); |
|
1001 break; |
|
1002 } |
|
1003 } |
|
1004 if(running == 0) |
|
1005 { |
|
1006 __TRACE(KMessage, (_L("Free module controller has been found [%S]"), &modName)); |
|
1007 return iTestModules[i]; |
|
1008 } |
|
1009 } |
|
1010 } |
|
1011 } |
|
1012 //Update name of new module to be created |
|
1013 newModuleName.AppendFormat(_L("@%d_"), GetIndexForNewTestModuleController()); |
|
1014 newModuleName.LowerCase(); |
|
1015 } |
|
1016 else |
|
1017 { |
|
1018 __TRACE(KMessage, (_L("TCTestModule operating mode: normal"))); |
|
1019 for(i = 0; i < count; i++) |
|
1020 { |
|
1021 if(iTestModules[i]->ModuleName() == aModule) |
|
1022 { |
|
1023 // Found test module, return description |
|
1024 __TRACE(KMessage, (_L("Module controller [%S] found"), &aModule)); |
|
1025 return iTestModules[i]; |
|
1026 } |
|
1027 } |
|
1028 } |
|
1029 |
|
1030 __TRACE(KMessage, (_L("Creating new test module controller [%S] with ini [%S]"), &newModuleName, &aIniFile)); |
|
1031 CTCTestModule* module = CTCTestModule::NewL(this, newModuleName, aIniFile, aConfigFile); |
|
1032 CleanupStack::PushL(module); |
|
1033 |
|
1034 //Enumerate test cases |
|
1035 module->GetTestCasesForCombiner(aConfigFile); |
|
1036 |
|
1037 //Append new module to list |
|
1038 User::LeaveIfError(iTestModules.Append(module)); |
|
1039 CleanupStack::Pop(module); |
|
1040 |
|
1041 //Log some info |
|
1042 if(newWay) |
|
1043 { |
|
1044 __TRACE(KMessage, (_L("Module [%S] added to list. Currently there are following controllers of [%S] type:"), &newModuleName, &aModule)); |
|
1045 j = 1; |
|
1046 for(i = 0; i < iTestModules.Count(); i++) |
|
1047 { |
|
1048 if(iTestModules[i]->ModuleName().Find(aModule) == 0) |
|
1049 { |
|
1050 __TRACE(KMessage, (_L(" %d. [%S]"), j, &iTestModules[i]->ModuleName())); |
|
1051 j++; |
|
1052 } |
|
1053 } |
|
1054 } |
|
1055 |
|
1056 if( iLoopIsUsed ) |
|
1057 { |
|
1058 User::LeaveIfError( iLoopAllocationArray.Append( module ) ); |
|
1059 } |
|
1060 |
|
1061 return module; |
|
1062 } |
|
1063 |
|
1064 /* |
|
1065 ------------------------------------------------------------------------------- |
|
1066 |
|
1067 Class: CTestCombiner |
|
1068 |
|
1069 Method: GetTest |
|
1070 |
|
1071 Description: Get test case from testcase array. |
|
1072 |
|
1073 Parameters: TDesC& aTestId: in: TestId for testcase |
|
1074 |
|
1075 Return Values: CTCTestCase*: running/runned testcase |
|
1076 NULL: Testcase with aTestId not running/runned |
|
1077 |
|
1078 Errors/Exceptions: None |
|
1079 |
|
1080 Status: Approved |
|
1081 |
|
1082 ------------------------------------------------------------------------------- |
|
1083 */ |
|
1084 CTestCase* CTestCombiner::GetTest( TDesC& aTestId ) |
|
1085 { |
|
1086 __TRACEFUNC(); |
|
1087 // TestId is not mandatory, so length may be zero |
|
1088 if( aTestId.Length() == 0 ) |
|
1089 { |
|
1090 return NULL; |
|
1091 } |
|
1092 |
|
1093 TInt count = iTestCases.Count(); |
|
1094 for( TInt i=0; i < count; i++ ) |
|
1095 { |
|
1096 if( iTestCases[i]->TestId() == aTestId ) |
|
1097 { |
|
1098 // Found testcase with specified TestId |
|
1099 return iTestCases[i]; |
|
1100 } |
|
1101 } |
|
1102 // Test case with aTestId not found |
|
1103 return NULL; |
|
1104 |
|
1105 } |
|
1106 |
|
1107 /* |
|
1108 ------------------------------------------------------------------------------- |
|
1109 |
|
1110 Class: CTestCombiner |
|
1111 |
|
1112 Method: GetRunningTest |
|
1113 |
|
1114 Description: Get running test case. |
|
1115 |
|
1116 Parameters: TDesC& aTestId: in: TestId for testcase |
|
1117 |
|
1118 Return Values: CTCTestCase*: running testcase |
|
1119 NULL: Testcase with aTestId not running |
|
1120 |
|
1121 Errors/Exceptions: None |
|
1122 |
|
1123 Status: Approved |
|
1124 |
|
1125 ------------------------------------------------------------------------------- |
|
1126 */ |
|
1127 CTestCase* CTestCombiner::GetRunningTest( TDesC& aTestId ) |
|
1128 { |
|
1129 __TRACEFUNC(); |
|
1130 |
|
1131 CTestCase* test = GetTest( aTestId ); |
|
1132 if( test ) |
|
1133 { |
|
1134 if( test->State() == CTestCase::ETestCaseRunning ) |
|
1135 { |
|
1136 return test; |
|
1137 } |
|
1138 else |
|
1139 { |
|
1140 __TRACE( KMessage, (_L("GetTest: Searched task (%S) not running (%i)"), |
|
1141 &aTestId, test->State() )); |
|
1142 } |
|
1143 } |
|
1144 |
|
1145 return NULL; |
|
1146 |
|
1147 } |
|
1148 |
|
1149 /* |
|
1150 ------------------------------------------------------------------------------- |
|
1151 |
|
1152 Class: CTestCombiner |
|
1153 |
|
1154 Method: GetLocalTest |
|
1155 |
|
1156 Description: Get local test case from testcase array. |
|
1157 |
|
1158 Parameters: TDesC& aTestId: in: TestId for testcase |
|
1159 |
|
1160 Return Values: CTCTestCase*: running/runned testcase |
|
1161 NULL: Testcase with aTestId not running/runned |
|
1162 |
|
1163 Errors/Exceptions: None |
|
1164 |
|
1165 Status: Proposal |
|
1166 |
|
1167 ------------------------------------------------------------------------------- |
|
1168 */ |
|
1169 CTCTestCase* CTestCombiner::GetLocalTest( TDesC& aTestId ) |
|
1170 { |
|
1171 __TRACEFUNC(); |
|
1172 CTestCase* testCase = GetTest( aTestId ); |
|
1173 if( testCase ) |
|
1174 { |
|
1175 if( testCase->Type() != CTestCase::ECaseLocal ) |
|
1176 { |
|
1177 __TRACE( KMessage, (_L("GetLocalTest: Searched task (%S) not local"), |
|
1178 &aTestId )); |
|
1179 return NULL; |
|
1180 } |
|
1181 } |
|
1182 return ( CTCTestCase* ) testCase; |
|
1183 |
|
1184 } |
|
1185 |
|
1186 /* |
|
1187 ------------------------------------------------------------------------------- |
|
1188 |
|
1189 Class: CTestCombiner |
|
1190 |
|
1191 Method: GetLocalRunningTest |
|
1192 |
|
1193 Description: Get local running test case. |
|
1194 |
|
1195 Parameters: TDesC& aTestId: in: TestId for testcase |
|
1196 |
|
1197 Return Values: CTCTestCase*: running/runned testcase |
|
1198 NULL: Testcase with aTestId not running/runned |
|
1199 |
|
1200 Errors/Exceptions: None |
|
1201 |
|
1202 Status: Proposal |
|
1203 |
|
1204 ------------------------------------------------------------------------------- |
|
1205 */ |
|
1206 CTCTestCase* CTestCombiner::GetLocalRunningTest( TDesC& aTestId ) |
|
1207 { |
|
1208 __TRACEFUNC(); |
|
1209 CTestCase* testCase = GetRunningTest( aTestId ); |
|
1210 if( testCase ) |
|
1211 { |
|
1212 if( testCase->Type() != CTestCase::ECaseLocal ) |
|
1213 { |
|
1214 __TRACE( KMessage, (_L("GetLocalRunningTest: Searched task (%S) not local"), |
|
1215 &aTestId )); |
|
1216 return NULL; |
|
1217 } |
|
1218 } |
|
1219 |
|
1220 return ( CTCTestCase* ) testCase; |
|
1221 |
|
1222 } |
|
1223 |
|
1224 /* |
|
1225 ------------------------------------------------------------------------------- |
|
1226 |
|
1227 Class: CTestCombiner |
|
1228 |
|
1229 Method: GetRemoteTest |
|
1230 |
|
1231 Description: Get local test case from testcase array. |
|
1232 |
|
1233 Parameters: TDesC& aTestId: in: TestId for testcase |
|
1234 |
|
1235 Return Values: CTCTestCase*: running/runned testcase |
|
1236 NULL: Testcase with aTestId not running/runned |
|
1237 |
|
1238 Errors/Exceptions: None |
|
1239 |
|
1240 Status: Proposal |
|
1241 |
|
1242 ------------------------------------------------------------------------------- |
|
1243 */ |
|
1244 CRemoteTestCase* CTestCombiner::GetRemoteTest( TDesC& aTestId ) |
|
1245 { |
|
1246 __TRACEFUNC(); |
|
1247 CTestCase* testCase = GetTest( aTestId ); |
|
1248 if( testCase ) |
|
1249 { |
|
1250 if( testCase->Type() != CTestCase::ECaseRemote ) |
|
1251 { |
|
1252 __TRACE( KMessage, (_L("GetRemoteTest: Searched task (%S) not remote"), |
|
1253 &aTestId )); |
|
1254 return NULL; |
|
1255 } |
|
1256 } |
|
1257 |
|
1258 return ( CRemoteTestCase* ) testCase; |
|
1259 |
|
1260 } |
|
1261 |
|
1262 /* |
|
1263 ------------------------------------------------------------------------------- |
|
1264 |
|
1265 Class: CTestCombiner |
|
1266 |
|
1267 Method: GetRemoteTest |
|
1268 |
|
1269 Description: Get remote test case from slave array. |
|
1270 |
|
1271 Parameters: TUint32 aSlaveId: in: Slave id for testcase |
|
1272 |
|
1273 Return Values: TCaseInfo*: running/runned testcase |
|
1274 NULL: Testcase with aTestId not running/runned |
|
1275 |
|
1276 Errors/Exceptions: None |
|
1277 |
|
1278 Status: Proposal |
|
1279 |
|
1280 ------------------------------------------------------------------------------- |
|
1281 */ |
|
1282 CRemoteTestCase* CTestCombiner::GetRemoteTest( TUint32 aSlaveId ) |
|
1283 { |
|
1284 |
|
1285 __TRACEFUNC(); |
|
1286 |
|
1287 // Check all remote testcases |
|
1288 TInt caseCount = iTestCases.Count(); |
|
1289 CRemoteTestCase* testCase = NULL; |
|
1290 for( TInt caseInd = 0; caseInd < caseCount; caseInd++ ) |
|
1291 { |
|
1292 if( iTestCases[caseInd]->Type() == CTestCase::ECaseRemote ) |
|
1293 { |
|
1294 testCase = ( CRemoteTestCase* )iTestCases[caseInd]; |
|
1295 if( testCase->iSlaveId == aSlaveId ) |
|
1296 { |
|
1297 return testCase; |
|
1298 } |
|
1299 } |
|
1300 } |
|
1301 |
|
1302 return NULL; |
|
1303 |
|
1304 } |
|
1305 |
|
1306 /* |
|
1307 ------------------------------------------------------------------------------- |
|
1308 |
|
1309 Class: CTestCombiner |
|
1310 |
|
1311 Method: GetRemoteTestRunSent |
|
1312 |
|
1313 Description: Get remote test case from slave array |
|
1314 |
|
1315 Parameters: TUint32 aSlaveId: in: Slave id for testcase |
|
1316 |
|
1317 Return Values: TCaseInfo*: running/runned testcase |
|
1318 NULL: Testcase with aTestId not running/runned |
|
1319 |
|
1320 Errors/Exceptions: None |
|
1321 |
|
1322 Status: Draft @js |
|
1323 |
|
1324 ------------------------------------------------------------------------------- |
|
1325 */ |
|
1326 |
|
1327 CRemoteTestCase* CTestCombiner::GetRemoteTestRunSent( TUint32 aSlaveId ) |
|
1328 { |
|
1329 |
|
1330 __TRACEFUNC(); |
|
1331 |
|
1332 // Check all remote testcases |
|
1333 TInt caseCount = iTestCases.Count(); |
|
1334 CRemoteTestCase* testCase = NULL; |
|
1335 for( TInt caseInd = 0; caseInd < caseCount; caseInd++ ) |
|
1336 { |
|
1337 if( iTestCases[caseInd]->Type() == CTestCase::ECaseRemote ) |
|
1338 { |
|
1339 testCase = ( CRemoteTestCase* )iTestCases[caseInd]; |
|
1340 |
|
1341 if( testCase->iRemoteState != CRemoteTestCase::ECaseRunSent ) |
|
1342 { |
|
1343 continue; |
|
1344 } |
|
1345 if( testCase->iSlaveId == aSlaveId ) |
|
1346 { |
|
1347 return testCase; |
|
1348 } |
|
1349 } |
|
1350 } |
|
1351 |
|
1352 return NULL; |
|
1353 |
|
1354 } |
|
1355 |
|
1356 /* |
|
1357 ------------------------------------------------------------------------------- |
|
1358 |
|
1359 Class: CTestCombiner |
|
1360 |
|
1361 Method: GetRemoteTest |
|
1362 |
|
1363 Description: Get remote test case from slave array. |
|
1364 |
|
1365 Parameters: TUint32 aSlaveId: in: Slave id for testcase |
|
1366 |
|
1367 Return Values: TCaseInfo*: running/runned testcase |
|
1368 NULL: Testcase with aTestId not running/runned |
|
1369 |
|
1370 Errors/Exceptions: None |
|
1371 |
|
1372 Status: Proposal |
|
1373 |
|
1374 ------------------------------------------------------------------------------- |
|
1375 */ |
|
1376 CRemoteTestCase* CTestCombiner::GetRunningRemoteTest( TUint32 aSlaveId ) |
|
1377 { |
|
1378 |
|
1379 __TRACEFUNC(); |
|
1380 |
|
1381 // Check all remote testcases |
|
1382 TInt caseCount = iTestCases.Count(); |
|
1383 CRemoteTestCase* testCase = NULL; |
|
1384 for( TInt caseInd = 0; caseInd < caseCount; caseInd++ ) |
|
1385 { |
|
1386 if( ( iTestCases[caseInd]->Type() == CTestCase::ECaseRemote ) && |
|
1387 ( iTestCases[caseInd]->State() == CTestCase::ETestCaseRunning ) ) |
|
1388 { |
|
1389 testCase = ( CRemoteTestCase* )iTestCases[caseInd]; |
|
1390 |
|
1391 if( ( testCase->iRemoteState != CRemoteTestCase::ECaseRunSent ) && |
|
1392 ( testCase->iRemoteState != CRemoteTestCase::ECaseRunning ) && |
|
1393 ( testCase->iRemoteState != CRemoteTestCase::ECaseCancelled )) |
|
1394 { |
|
1395 //User::Leave( KErrGeneral ); |
|
1396 continue; |
|
1397 } |
|
1398 |
|
1399 if( testCase->iSlaveId == aSlaveId ) |
|
1400 { |
|
1401 return testCase; |
|
1402 } |
|
1403 } |
|
1404 } |
|
1405 |
|
1406 return NULL; |
|
1407 |
|
1408 } |
|
1409 |
|
1410 |
|
1411 /* |
|
1412 ------------------------------------------------------------------------------- |
|
1413 |
|
1414 Class: CTestCombiner |
|
1415 |
|
1416 Method: GetRemoteTestSlave |
|
1417 |
|
1418 Description: Get remote test case running on slave |
|
1419 |
|
1420 Parameters: TUint32 aSlaveDevId: in: Slave id for testcase |
|
1421 |
|
1422 Return Values: CRemoteTestCase*: running/runned testcase |
|
1423 NULL: Testcase with aTestId not running/runned |
|
1424 |
|
1425 Errors/Exceptions: None |
|
1426 |
|
1427 Status: Proposal |
|
1428 |
|
1429 ------------------------------------------------------------------------------- |
|
1430 */ |
|
1431 CRemoteTestCase* CTestCombiner::GetRemoteRunningTestOnSlave( |
|
1432 TUint32 aSlaveDevId ) |
|
1433 { |
|
1434 |
|
1435 __TRACEFUNC(); |
|
1436 |
|
1437 // Check all remote testcases |
|
1438 TInt caseCount = iTestCases.Count(); |
|
1439 CRemoteTestCase* testCase = NULL; |
|
1440 for( TInt caseInd = 0; caseInd < caseCount; caseInd++ ) |
|
1441 { |
|
1442 if( ( iTestCases[caseInd]->Type() == CTestCase::ECaseRemote ) && |
|
1443 ( iTestCases[caseInd]->State() == CTestCase::ETestCaseRunning ) ) |
|
1444 { |
|
1445 testCase = ( CRemoteTestCase* )iTestCases[caseInd]; |
|
1446 if( DEVID( testCase->iSlaveId ) == DEVID( aSlaveDevId ) ) |
|
1447 { |
|
1448 return testCase; |
|
1449 } |
|
1450 } |
|
1451 } |
|
1452 |
|
1453 return NULL; |
|
1454 |
|
1455 } |
|
1456 |
|
1457 /* |
|
1458 ------------------------------------------------------------------------------- |
|
1459 |
|
1460 Class: CTestCombiner |
|
1461 |
|
1462 Method: GetRemoteTestSlave |
|
1463 |
|
1464 Description: Gets a correct CRemoteSendReceive object on slave with |
|
1465 aSlaveId. |
|
1466 |
|
1467 Parameters: TUint32 aSlaveId: in: Slave id CRemoteSendReceive object |
|
1468 |
|
1469 Return Values: CRemoteSendReceive*: Current CRemoteSendReceive object. |
|
1470 NULL: CRemoteSendReceive object do not exist or found. |
|
1471 |
|
1472 Errors/Exceptions: None |
|
1473 |
|
1474 Status: Proposal |
|
1475 |
|
1476 ------------------------------------------------------------------------------- |
|
1477 */ |
|
1478 CRemoteSendReceive* CTestCombiner::GetRemoteSendReceive( TUint32 aSlaveId ) |
|
1479 { |
|
1480 __TRACEFUNC(); |
|
1481 |
|
1482 for( TInt sr = 0; sr < iSendReceive.Count(); sr++ ) |
|
1483 { |
|
1484 if( iSendReceive[sr]->iSlaveId == aSlaveId ) |
|
1485 { |
|
1486 return iSendReceive[sr]; |
|
1487 } |
|
1488 } |
|
1489 |
|
1490 return NULL; |
|
1491 |
|
1492 } |
|
1493 |
|
1494 /* |
|
1495 ------------------------------------------------------------------------------- |
|
1496 |
|
1497 Class: CTestCombiner |
|
1498 |
|
1499 Method: GetSlave |
|
1500 |
|
1501 Description: Get remote slave. |
|
1502 |
|
1503 Parameters: TUint32 aSlaveId: in: Slave id |
|
1504 |
|
1505 Return Values: CSlaveInfo*: reserved slave |
|
1506 NULL: slave with aSlaveId not reserved |
|
1507 |
|
1508 Errors/Exceptions: None |
|
1509 |
|
1510 Status: Proposal |
|
1511 |
|
1512 ------------------------------------------------------------------------------- |
|
1513 */ |
|
1514 CSlaveInfo* CTestCombiner::GetSlave( TUint32 aSlaveId ) |
|
1515 { |
|
1516 |
|
1517 __TRACEFUNC(); |
|
1518 |
|
1519 TInt count = iSlaveArray.Count(); |
|
1520 for( TInt index = 0; index < count; index++ ) |
|
1521 { |
|
1522 if( DEVID( iSlaveArray[index]->iSlaveDevId ) == DEVID( aSlaveId) ) |
|
1523 { |
|
1524 return iSlaveArray[index]; |
|
1525 } |
|
1526 } |
|
1527 |
|
1528 return NULL; |
|
1529 |
|
1530 } |
|
1531 |
|
1532 /* |
|
1533 ------------------------------------------------------------------------------- |
|
1534 |
|
1535 Class: CTestCombiner |
|
1536 |
|
1537 Method: GetSlave |
|
1538 |
|
1539 Description: Get remote slave. |
|
1540 |
|
1541 Parameters: TDesC& aSlaveName: in: Slave name |
|
1542 |
|
1543 Return Values: CSlaveInfo*: reserved slave |
|
1544 NULL: slave with aSlaveId not reserved |
|
1545 |
|
1546 Errors/Exceptions: None |
|
1547 |
|
1548 Status: Proposal |
|
1549 |
|
1550 ------------------------------------------------------------------------------- |
|
1551 */ |
|
1552 CSlaveInfo* CTestCombiner::GetSlave( TDesC& aSlaveName ) |
|
1553 { |
|
1554 |
|
1555 __TRACEFUNC(); |
|
1556 |
|
1557 TInt count = iSlaveArray.Count(); |
|
1558 for( TInt index = 0; index < count; index++ ) |
|
1559 { |
|
1560 if( iSlaveArray[index]->iName == aSlaveName ) |
|
1561 { |
|
1562 return iSlaveArray[index]; |
|
1563 } |
|
1564 } |
|
1565 |
|
1566 return NULL; |
|
1567 |
|
1568 } |
|
1569 |
|
1570 /* |
|
1571 ------------------------------------------------------------------------------- |
|
1572 |
|
1573 Class: CTestCombiner |
|
1574 |
|
1575 Method: StartTestL |
|
1576 |
|
1577 Description: Start specified test case from testmodule. |
|
1578 |
|
1579 Parameters: CStartInfo& aStartInfo: in: Test case information |
|
1580 |
|
1581 Return Values: KErrNone: Testcase started |
|
1582 KErrAlreadyExists: testcase with same aTestId is already |
|
1583 running |
|
1584 Any other SymbianOS errorcode |
|
1585 |
|
1586 Errors/Exceptions: Leaves if CTCTestCase::NewL leaves |
|
1587 Leaves if arguments are illegal |
|
1588 Leaves if GetTestModuleL leaves |
|
1589 Leaves if CTestExecution::Open fails |
|
1590 Leaves if CTCTestCase::StartL leaves |
|
1591 Leaves if RPointerArray::Append fails |
|
1592 |
|
1593 Status: Proposal |
|
1594 |
|
1595 ------------------------------------------------------------------------------- |
|
1596 */ |
|
1597 TInt CTestCombiner::StartTestL( CStartInfo& aStartInfo ) |
|
1598 { |
|
1599 __TRACEFUNC(); |
|
1600 // Check that TestId is unique. |
|
1601 if( GetTest( aStartInfo.iTestId ) != NULL ) |
|
1602 { |
|
1603 // If loop testing is ongoing, allow already defined testid. |
|
1604 if( iLoopIsUsed ) |
|
1605 { |
|
1606 __TRACE( KVerbose, ( _L("StartTestL: TestId (%S) already in use. Loop allows already defined TestId"), |
|
1607 &aStartInfo.iTestId )); |
|
1608 } |
|
1609 else |
|
1610 { |
|
1611 __TRACE( KError, ( _L("StartTestL: TestId (%S) already in use"), |
|
1612 &aStartInfo.iTestId )); |
|
1613 return KErrAlreadyExists; |
|
1614 } |
|
1615 } |
|
1616 |
|
1617 __ASSERT_ALWAYS( aStartInfo.iModule.Length() < KMaxFileName, |
|
1618 User::Leave( KErrArgument ) ); |
|
1619 __ASSERT_ALWAYS( aStartInfo.iIniFile.Length() < KMaxFileName, |
|
1620 User::Leave( KErrArgument ) ); |
|
1621 __ASSERT_ALWAYS( aStartInfo.iConfig.Length() < KMaxFileName, |
|
1622 User::Leave( KErrArgument ) ); |
|
1623 __ASSERT_ALWAYS( aStartInfo.iTestId.Length() < KMaxName, |
|
1624 User::Leave( KErrArgument ) ); |
|
1625 |
|
1626 __TRACE( KMessage, ( _L("Call GetTestModuleL") )); |
|
1627 |
|
1628 // Load Test Module |
|
1629 CTCTestModule* module = NULL; |
|
1630 if( (aStartInfo.iModule.Find( KTestScripterName ) != KErrNotFound) |
|
1631 || (aStartInfo.iModule.Find( KPythonScripter ) != KErrNotFound) |
|
1632 || (aStartInfo.iModule.Find( KTestCombinerName ) != KErrNotFound) |
|
1633 ) |
|
1634 { |
|
1635 // TestScripter in use. Give config file for parsing STIF Settings. |
|
1636 module = GetTestModuleL( aStartInfo.iModule, |
|
1637 aStartInfo.iIniFile, |
|
1638 aStartInfo.iConfig ); |
|
1639 } |
|
1640 else |
|
1641 { |
|
1642 module = GetTestModuleL( aStartInfo.iModule, |
|
1643 aStartInfo.iIniFile, |
|
1644 KNullDesC ); |
|
1645 } |
|
1646 |
|
1647 __TRACE( KMessage, ( _L("Create CTCTestCase") )); |
|
1648 |
|
1649 CTCTestCase* tc = |
|
1650 CTCTestCase::NewL( this, |
|
1651 aStartInfo.iModule, |
|
1652 aStartInfo.iTestId, |
|
1653 aStartInfo.iExpectedResult, |
|
1654 aStartInfo.iCategory, |
|
1655 aStartInfo.iTestCaseArguments, |
|
1656 module ); //--PYTHON-- |
|
1657 |
|
1658 CleanupStack::PushL( tc ); |
|
1659 |
|
1660 //If name of testcase was given, find testcase number |
|
1661 if(aStartInfo.iTitle != KNullDesC) |
|
1662 { |
|
1663 __TRACE(KMessage, (_L("Trying to find test case entitled \"%S\""), &aStartInfo.iTitle)); |
|
1664 aStartInfo.iCaseNum = -1; |
|
1665 TInt ret = module->GetCaseNumByTitle(aStartInfo.iTitle, aStartInfo.iCaseNum); |
|
1666 if(ret != KErrNone) |
|
1667 { |
|
1668 __TRACE(KError, (_L("Couldn't find test case entitled \"%S\". Error %d"), &aStartInfo.iTitle, ret)); |
|
1669 } |
|
1670 else |
|
1671 { |
|
1672 __TRACE(KMessage, (_L("Found test case entitled \"%S\". Case num %d"), &aStartInfo.iTitle, aStartInfo.iCaseNum)); |
|
1673 } |
|
1674 } |
|
1675 |
|
1676 __TRACE( KMessage, ( _L("Open TestExecution") )); |
|
1677 |
|
1678 User::LeaveIfError( tc->TestExecution().Open( module->TestServer(), |
|
1679 aStartInfo.iCaseNum, |
|
1680 aStartInfo.iConfig ) ); |
|
1681 |
|
1682 __TRACE( KMessage, ( _L("Start testcase runner") )); |
|
1683 |
|
1684 // Enable testcase control before calling RunTestCase |
|
1685 tc->StartL(); |
|
1686 |
|
1687 __TRACE( KMessage, |
|
1688 ( _L("Start: testid(%S), module(%S), ini(%S), config(%S), case(%d), expect(%d/%d), timeout(%d)"), |
|
1689 &aStartInfo.iTestId, &aStartInfo.iModule, &aStartInfo.iIniFile, |
|
1690 &aStartInfo.iConfig, aStartInfo.iCaseNum, aStartInfo.iExpectedResult, |
|
1691 aStartInfo.iCategory, aStartInfo.iTimeout )); |
|
1692 |
|
1693 TestModuleIf().Printf( KPrintPriLow, _L("Start"), |
|
1694 _L("testid(%S), module(%S), ini(%S), config(%S), case(%d), expect(%d)"), |
|
1695 &aStartInfo.iTestId, &aStartInfo.iModule, &aStartInfo.iIniFile, |
|
1696 &aStartInfo.iConfig, aStartInfo.iCaseNum, aStartInfo.iExpectedResult ); |
|
1697 |
|
1698 if ( tc->TestCaseArguments().Length() > 0 ) |
|
1699 { |
|
1700 tc->TestExecution().RunTestCase( tc->iResultPckg, tc->TestCaseArguments(), tc->iStatus ); |
|
1701 } |
|
1702 else |
|
1703 { |
|
1704 tc->TestExecution().RunTestCase( tc->iResultPckg, tc->iStatus ); |
|
1705 } |
|
1706 |
|
1707 iRunningTests++; |
|
1708 |
|
1709 User::LeaveIfError( iTestCases.Append( tc ) ); |
|
1710 if( iLoopIsUsed ) |
|
1711 { |
|
1712 User::LeaveIfError( iLoopAllocationArray.Append( tc ) ); |
|
1713 } |
|
1714 CleanupStack::Pop( tc ); |
|
1715 |
|
1716 return KErrNone; |
|
1717 |
|
1718 } |
|
1719 |
|
1720 /* |
|
1721 ------------------------------------------------------------------------------- |
|
1722 |
|
1723 Class: CTestCombiner |
|
1724 |
|
1725 Method: Complete |
|
1726 |
|
1727 Description: Handle completed test case. |
|
1728 |
|
1729 Parameters: CTCTestCase* aTestCase: in: Test case to complete |
|
1730 |
|
1731 Return Values: None. |
|
1732 |
|
1733 Errors/Exceptions: None |
|
1734 |
|
1735 Status: Approved |
|
1736 |
|
1737 ------------------------------------------------------------------------------- |
|
1738 */ |
|
1739 void CTestCombiner::Complete( CTestCase* aTestCase, TInt aError ) |
|
1740 { |
|
1741 __TRACEFUNC(); |
|
1742 |
|
1743 if( aError != KErrNone ) |
|
1744 { |
|
1745 iResult = aError; |
|
1746 } |
|
1747 |
|
1748 TInt count = iTestCases.Count(); |
|
1749 TInt i = 0; |
|
1750 for(; i < count; i++ ) |
|
1751 { |
|
1752 if( iTestCases[i] == aTestCase ) |
|
1753 { |
|
1754 // Test Case completed |
|
1755 __TRACE( KPrint, ( _L( "Complete: %S result: %d, execution result: %d, expected: %d"), |
|
1756 &aTestCase->TestId(), aTestCase->iResult.iTestResult.iResult, |
|
1757 aTestCase->iResult.iCaseExecutionResultCode, aTestCase->ExpectedResult() )); |
|
1758 TestModuleIf().Printf( KPrintPriLow, _L("Complete"), |
|
1759 _L( "%S results: test(%d) exe(%d) expect(%d)"), |
|
1760 &aTestCase->TestId(), aTestCase->iResult.iTestResult.iResult, |
|
1761 aTestCase->iResult.iCaseExecutionResultCode, aTestCase->ExpectedResult() ); |
|
1762 iRunningTests--; |
|
1763 break; |
|
1764 } |
|
1765 } |
|
1766 if( i == count ) |
|
1767 { |
|
1768 __TRACE( KError, (_L("CTestCombiner::Complete: Test case not found!!"))); |
|
1769 } |
|
1770 |
|
1771 // Check if we were waiting this case to complete |
|
1772 if( ( iWaitTestCase.Length() > 0 ) && |
|
1773 ( iWaitTestCase == aTestCase->TestId() ) ) |
|
1774 { |
|
1775 // We were waiting this case to complete |
|
1776 // Now we can proceed executing the testcase |
|
1777 __TRACE( KMessage, (_L("TestCase was waiting, set runner active"))); |
|
1778 iTestRunner->SetRunnerActive(); |
|
1779 iWaitTestCase.Zero(); |
|
1780 |
|
1781 //return; - return removed due to STIF-509 CancelIfError won't work when used together with complete command |
|
1782 |
|
1783 } |
|
1784 else if( aTestCase->Type() == CTestCase::ECaseRemote ) |
|
1785 { |
|
1786 __TRACE( KMessage, (_L("CTestCombiner::Complete: Remote case complete"))); |
|
1787 // Completed testcase was remote case, |
|
1788 // check if slave should be freed |
|
1789 CRemoteTestCase* remote = ( CRemoteTestCase* )aTestCase; |
|
1790 if( remote->iFreeSlave ) |
|
1791 { |
|
1792 CSlaveInfo* slave = GetSlave( remote->iSlaveId ); |
|
1793 if( slave ) |
|
1794 { |
|
1795 // Free slave now |
|
1796 TRAPD( err, iTestRunner->ExecuteFreeL( slave ) ); |
|
1797 // Continue if freeing fails |
|
1798 if( err == KErrNone ) |
|
1799 { |
|
1800 __TRACE( KMessage, (_L("Complete: Freeing slave"))); |
|
1801 return; |
|
1802 } |
|
1803 else |
|
1804 { |
|
1805 __TRACE( KError, (_L("Complete: Freeing slave failed"))); |
|
1806 } |
|
1807 } |
|
1808 else |
|
1809 { |
|
1810 __TRACE( KError, (_L("Complete: Slave not found"))); |
|
1811 } |
|
1812 } |
|
1813 } |
|
1814 |
|
1815 // If running test is 0, active scheduler is active and CTestRunner is |
|
1816 // ready then stop active scheduler.(Operations continue from |
|
1817 // CTestCombiner::RunTestL() after active scheduler start). |
|
1818 if( ( iRunningTests == 0 ) && |
|
1819 iSchedulerActive && |
|
1820 ( iTestRunner->iState == CTestRunner::ERunnerReady ) ) |
|
1821 { |
|
1822 // This was last running testcase, so we can stop |
|
1823 // activescheduler |
|
1824 __TRACE( KMessage, (_L("All TestCases completed, stop CActiveScheduler"))); |
|
1825 CActiveScheduler::Current()->Stop(); |
|
1826 iSchedulerActive = EFalse; |
|
1827 } |
|
1828 else |
|
1829 { |
|
1830 __TRACE( KMessage, |
|
1831 (_L("CTestCombiner::Complete: %d test cases running"), iRunningTests )); |
|
1832 __TRACE( KMessage, |
|
1833 (_L("CTestCombiner::Complete: active %d"), iSchedulerActive )); |
|
1834 if(iSchedulerActive) |
|
1835 { |
|
1836 __TRACE( KMessage, |
|
1837 (_L("CTestCombiner::Complete: state %d"), iTestRunner->iState )); |
|
1838 } |
|
1839 } |
|
1840 |
|
1841 // Checking if user wants to skip the rest of the execution in case of error @js |
|
1842 if(iCancelIfError && iSchedulerActive) |
|
1843 { |
|
1844 // Cancel event if it was waiting event |
|
1845 if(iTestRunner->iEvent.Name() != KNullDesC && iTestRunner->iEvent.Type() == TEventIf::EWaitEvent) |
|
1846 { |
|
1847 TestModuleIf().CancelEvent(iTestRunner->iEvent, &iTestRunner->iStatus); |
|
1848 } |
|
1849 |
|
1850 // Interpret execution result type from returned result |
|
1851 TInt executionResult = TFullTestResult::ECaseExecuted; // Ok |
|
1852 if( (aTestCase->iResult.iCaseExecutionResultType >= |
|
1853 TFullTestResult::ECaseLeave )) |
|
1854 { |
|
1855 __TRACE( KMessage, (_L("The test case ended with error!"))); |
|
1856 |
|
1857 // Some abnormal execution result type |
|
1858 executionResult = iTestCases[i]->iResult.iCaseExecutionResultType; |
|
1859 } |
|
1860 |
|
1861 // Check expected execution result type |
|
1862 if( executionResult != aTestCase->ExpectedResultCategory() ) |
|
1863 { |
|
1864 // expected and returned result types differ |
|
1865 __TRACE( KMessage, (_L("The test case has wrong result category!"))); |
|
1866 // There was an error and we must stop test case execution |
|
1867 iFailedTestCase = i; |
|
1868 iRunningTests--; |
|
1869 __TRACE( KMessage, (_L("Stopping the CActiveScheduler."))); |
|
1870 CActiveScheduler::Current()->Stop(); |
|
1871 iSchedulerActive = EFalse; |
|
1872 } |
|
1873 |
|
1874 // Check normal test result if activescheduler is still up & running |
|
1875 if( iSchedulerActive ) |
|
1876 { |
|
1877 if( aTestCase->ExpectedResultCategory() == |
|
1878 TFullTestResult:: ECaseExecuted) |
|
1879 { |
|
1880 // Normal completion, check result |
|
1881 if( iTestCases[i]->iResult.iTestResult.iResult != |
|
1882 iTestCases[i]->ExpectedResult() ) |
|
1883 { |
|
1884 __TRACE( KMessage, (_L("Result category is not what was expected!"))); |
|
1885 // There was an error and we must stop test case execution |
|
1886 iFailedTestCase = i; |
|
1887 iRunningTests = 0; //The whole test is stopped. Reset value of running tests. |
|
1888 //This line caused that variable value to be -1. Test could not finish. //iRunningTests--; |
|
1889 __TRACE( KMessage, (_L("Stopping the CActiveScheduler."))); |
|
1890 CActiveScheduler::Current()->Stop(); |
|
1891 iSchedulerActive = EFalse; |
|
1892 } |
|
1893 } |
|
1894 else |
|
1895 { |
|
1896 // Abnormal completion, i.e. panic, leave, exception or timeout |
|
1897 if( aTestCase->iResult.iCaseExecutionResultCode != |
|
1898 aTestCase->ExpectedResult()) |
|
1899 { |
|
1900 __TRACE( KMessage, (_L("The test case has abnormal completion!"))); |
|
1901 // There was an error and we must stop test case execution |
|
1902 iFailedTestCase = i; |
|
1903 iRunningTests--; |
|
1904 __TRACE( KMessage, (_L("Stopping the CActiveScheduler."))); |
|
1905 CActiveScheduler::Current()->Stop(); |
|
1906 iSchedulerActive = EFalse; |
|
1907 } |
|
1908 } |
|
1909 } |
|
1910 } |
|
1911 } |
|
1912 |
|
1913 /* |
|
1914 ------------------------------------------------------------------------------- |
|
1915 |
|
1916 Class: CTestCombiner |
|
1917 |
|
1918 Method: NotifyEvent |
|
1919 |
|
1920 Description: Asynchronous event command interface |
|
1921 |
|
1922 Check requested events and send unset to first requested |
|
1923 |
|
1924 Parameters: TEventIf& aEvent: in: Event command |
|
1925 TRequestStatus& aStatus: in: TRequestStatus used in |
|
1926 asynchronous command |
|
1927 |
|
1928 Return Values: ETrue: asynchronous command given |
|
1929 EFalse: asyncronous command not given |
|
1930 |
|
1931 Errors/Exceptions: None |
|
1932 |
|
1933 Status: Proposal |
|
1934 |
|
1935 ------------------------------------------------------------------------------- |
|
1936 */ |
|
1937 TBool CTestCombiner::UnsetEvent( TEventIf& aEvent, |
|
1938 TRequestStatus& aStatus ) |
|
1939 { |
|
1940 |
|
1941 __TRACE( KMessage, ( _L("CTestCombiner::NotifyEvent"))); |
|
1942 |
|
1943 // First check TestCombiner events |
|
1944 TInt eventCount = iEventArray.Count(); |
|
1945 for( TInt i = 0; i < eventCount; i++ ) |
|
1946 { |
|
1947 if( aEvent.Name() == iEventArray[i]->Name() ) |
|
1948 { |
|
1949 __TRACE( KMessage, ( |
|
1950 _L( "Set unset pending for testcombiner's %S event"), |
|
1951 &aEvent.Name() )); |
|
1952 iEventArray[i]->SetRequestStatus( &aStatus ); |
|
1953 return ETrue; |
|
1954 } |
|
1955 } |
|
1956 |
|
1957 // Check all local testcases |
|
1958 TInt caseCount = iTestCases.Count(); |
|
1959 TInt eventInd; |
|
1960 CTCTestCase* testCase = NULL; |
|
1961 for( TInt caseInd = 0; caseInd < caseCount; caseInd++ ) |
|
1962 { |
|
1963 if( iTestCases[caseInd]->Type() == CTestCase::ECaseLocal ) |
|
1964 { |
|
1965 testCase = ( CTCTestCase* )iTestCases[caseInd]; |
|
1966 eventCount = testCase->EventArray().Count(); |
|
1967 |
|
1968 // Check all requested events |
|
1969 for( eventInd = 0; eventInd < eventCount; eventInd++) |
|
1970 { |
|
1971 const TName& eventName = |
|
1972 testCase->EventArray()[eventInd]->Event().Name(); |
|
1973 if( eventName == aEvent.Name() ) |
|
1974 { |
|
1975 // Event request is pending, send control command |
|
1976 iEvent.Copy( aEvent ); |
|
1977 __TRACE( KMessage, ( |
|
1978 _L( "Set unset pending for client's %S event"), |
|
1979 &aEvent.Name() )); |
|
1980 testCase->TestExecution().NotifyEvent( iEventPckg, |
|
1981 aStatus ); |
|
1982 return ETrue; |
|
1983 } |
|
1984 } |
|
1985 } |
|
1986 } |
|
1987 |
|
1988 return EFalse; |
|
1989 |
|
1990 } |
|
1991 |
|
1992 /* |
|
1993 ------------------------------------------------------------------------------- |
|
1994 |
|
1995 Class: CTestCombiner |
|
1996 |
|
1997 Method: ReceiveResponse |
|
1998 |
|
1999 Description: Handles responce received from slave |
|
2000 |
|
2001 Parameters: None |
|
2002 |
|
2003 Return Values: None |
|
2004 |
|
2005 Errors/Exceptions: None |
|
2006 |
|
2007 Status: Draft |
|
2008 |
|
2009 ------------------------------------------------------------------------------- |
|
2010 */ |
|
2011 void CTestCombiner::ReceiveResponse( TDesC& aMsg ) |
|
2012 { |
|
2013 |
|
2014 __TRACEFUNC(); |
|
2015 |
|
2016 TBool continueTask = ETrue; |
|
2017 TRAPD( err, continueTask = iTestRunner->ReceiveResponseL( aMsg ) ); |
|
2018 |
|
2019 // We start receiver again, even in error situation |
|
2020 iRemoteReceiver->Start(); |
|
2021 |
|
2022 if( err != KErrNone ) |
|
2023 { |
|
2024 __TRACE( KError, ( _L("CTestCombiner::ReceiveResponse ERROR"))); |
|
2025 iResult = err; |
|
2026 if( iTestRunner->IsActive() ) |
|
2027 { |
|
2028 iTestRunner->Cancel(); |
|
2029 } |
|
2030 else |
|
2031 { |
|
2032 iTestRunner->CancelTestCases(); |
|
2033 } |
|
2034 return; |
|
2035 } |
|
2036 |
|
2037 if( continueTask && !iTestRunner->IsActive() ) |
|
2038 { |
|
2039 iTestRunner->SetRunnerActive(); |
|
2040 } |
|
2041 |
|
2042 } |
|
2043 |
|
2044 /* |
|
2045 ------------------------------------------------------------------------------- |
|
2046 |
|
2047 Class: CTestCombiner |
|
2048 |
|
2049 Method: RemoteTimeout |
|
2050 |
|
2051 Description: Handles timeouts. |
|
2052 |
|
2053 Parameters: None |
|
2054 |
|
2055 Return Values: None |
|
2056 |
|
2057 Errors/Exceptions: None |
|
2058 |
|
2059 Status: Draft |
|
2060 |
|
2061 ------------------------------------------------------------------------------- |
|
2062 */ |
|
2063 void CTestCombiner::RemoteTimeout() |
|
2064 { |
|
2065 |
|
2066 __TRACEFUNC(); |
|
2067 |
|
2068 iResult = KErrTimedOut; |
|
2069 if( iTestRunner->IsActive() ) |
|
2070 { |
|
2071 __TRACE( KError, (_L("Remote timeout, Cancel runner"))); |
|
2072 iTestRunner->Cancel(); |
|
2073 } |
|
2074 else |
|
2075 { |
|
2076 __TRACE( KError, (_L("Remote timeout, Cancel test cases"))); |
|
2077 iTestRunner->CancelTestCases(); |
|
2078 } |
|
2079 |
|
2080 } |
|
2081 |
|
2082 /* |
|
2083 ------------------------------------------------------------------------------- |
|
2084 |
|
2085 Class: CTestCombiner |
|
2086 |
|
2087 Method: ExecuteMeasurementL |
|
2088 |
|
2089 Description: Executes measurement script line. |
|
2090 |
|
2091 Parameters: CStifItemParser* aItem: in: parsed line |
|
2092 |
|
2093 Return Values: TBool: in no error ETrue returned |
|
2094 |
|
2095 Errors/Exceptions: None |
|
2096 |
|
2097 Status: Approved |
|
2098 |
|
2099 ------------------------------------------------------------------------------- |
|
2100 */ |
|
2101 void CTestCombiner::ExecuteMeasurementL( CStifItemParser* aItem ) |
|
2102 { |
|
2103 __TRACEFUNC(); |
|
2104 |
|
2105 __TRACEFUNC(); |
|
2106 TPtrC type; |
|
2107 TPtrC command; |
|
2108 |
|
2109 // Get command |
|
2110 if( aItem->GetNextString( command ) != KErrNone ) |
|
2111 { |
|
2112 __TRACE( KError, ( |
|
2113 _L( "Unknown argument for 'measurement' command" ) ) ); |
|
2114 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
2115 } |
|
2116 // Get name |
|
2117 if( aItem->GetNextString( type ) != KErrNone ) |
|
2118 { |
|
2119 __TRACE( KError, ( |
|
2120 _L( "Unknown argument for 'measurement' type" ) ) ); |
|
2121 User::Leave( KErrArgument ); // Error in parsing => Leave |
|
2122 } |
|
2123 |
|
2124 // Verify measurement type |
|
2125 if( !( type == KParamMeasurement01 || |
|
2126 type == KParamMeasurement02 || |
|
2127 type == KParamMeasurement03 || |
|
2128 type == KParamMeasurement04 || |
|
2129 type == KParamMeasurement05 || |
|
2130 type == KParamMeasurementBappea ) ) |
|
2131 |
|
2132 { |
|
2133 __TRACE( KError, ( |
|
2134 _L( "Unknown measurement type:[%S]" ), &type ) ); |
|
2135 User::Leave( KErrArgument ); // Error in types => Leave |
|
2136 } |
|
2137 |
|
2138 // Verify command |
|
2139 if( command == _L( "start" ) ) |
|
2140 { |
|
2141 // START measurement's process |
|
2142 __TRACE( KMessage, ( _L( "Start 'measurement' with '%S'"), &type ) ); |
|
2143 StartMeasurementL( type, aItem ); |
|
2144 } |
|
2145 else if( command == _L( "stop" ) ) |
|
2146 { |
|
2147 // STOP measurement's process |
|
2148 __TRACE( KMessage, ( _L( "'Stop 'measurement' with '%S'"), &type ) ); |
|
2149 StopMeasurementL( type ); |
|
2150 } |
|
2151 else |
|
2152 { |
|
2153 __TRACE( KError, ( |
|
2154 _L( "Unknown command for 'measurement' command:[%S] or type:[%S]" ), &command, &type ) ); |
|
2155 User::Leave( KErrArgument ); // Error in commands => Leave |
|
2156 } |
|
2157 |
|
2158 } |
|
2159 |
|
2160 /* |
|
2161 ------------------------------------------------------------------------------- |
|
2162 |
|
2163 Class: CTestCombiner |
|
2164 |
|
2165 Method: StartMeasurementL |
|
2166 |
|
2167 Description: |
|
2168 |
|
2169 Parameters: const TDesC& aType: in: Plugin type. |
|
2170 CStifItemParser* aItem: in: Item object for parsing. |
|
2171 |
|
2172 Return Values: None. |
|
2173 |
|
2174 Errors/Exceptions: Leaves is bappea start or timed operation fails. |
|
2175 |
|
2176 Status: Proposal |
|
2177 |
|
2178 ------------------------------------------------------------------------------- |
|
2179 */ |
|
2180 void CTestCombiner::StartMeasurementL( const TDesC& aType, |
|
2181 CStifItemParser* aItem ) |
|
2182 { |
|
2183 __TRACEFUNC(); |
|
2184 |
|
2185 CSTIFTestMeasurement* testMeasurement = NULL; |
|
2186 |
|
2187 // Get Measurement configuration info |
|
2188 TPtrC configurationInfo( KNullDesC() ); |
|
2189 if( aItem->Remainder( configurationInfo ) != KErrNone ) |
|
2190 { |
|
2191 __TRACE( KInit, ( |
|
2192 _L( "Using default path and file name for measurement configure" ) ) ); |
|
2193 } |
|
2194 |
|
2195 if( aType == KParamMeasurement01 ) |
|
2196 { |
|
2197 testMeasurement = CSTIFTestMeasurement::NewL( |
|
2198 this, |
|
2199 CSTIFTestMeasurement::KStifMeasurementPlugin01, |
|
2200 configurationInfo ); |
|
2201 } |
|
2202 else if( aType == KParamMeasurement02 ) |
|
2203 { |
|
2204 testMeasurement = CSTIFTestMeasurement::NewL( |
|
2205 this, |
|
2206 CSTIFTestMeasurement::KStifMeasurementPlugin02, |
|
2207 configurationInfo ); |
|
2208 } |
|
2209 else if( aType == KParamMeasurement03 ) |
|
2210 { |
|
2211 testMeasurement = CSTIFTestMeasurement::NewL( |
|
2212 this, |
|
2213 CSTIFTestMeasurement::KStifMeasurementPlugin03, |
|
2214 configurationInfo ); |
|
2215 } |
|
2216 else if( aType == KParamMeasurement04 ) |
|
2217 { |
|
2218 testMeasurement = CSTIFTestMeasurement::NewL( |
|
2219 this, |
|
2220 CSTIFTestMeasurement::KStifMeasurementPlugin04, |
|
2221 configurationInfo ); |
|
2222 } |
|
2223 else if( aType == KParamMeasurement05 ) |
|
2224 { |
|
2225 testMeasurement = CSTIFTestMeasurement::NewL( |
|
2226 this, |
|
2227 CSTIFTestMeasurement::KStifMeasurementPlugin05, |
|
2228 configurationInfo ); |
|
2229 } |
|
2230 else if( aType == KParamMeasurementBappea ) |
|
2231 { |
|
2232 testMeasurement = CSTIFTestMeasurement::NewL( |
|
2233 this, |
|
2234 CSTIFTestMeasurement::KStifMeasurementBappeaProfiler, |
|
2235 configurationInfo ); |
|
2236 } |
|
2237 else |
|
2238 { |
|
2239 __TRACE( KError, ( _L( "Unknown plugin[%S] for 'measurement'" ), &aType ) ); |
|
2240 User::Leave( KErrArgument ); |
|
2241 } |
|
2242 |
|
2243 // Start test measurement |
|
2244 TInt start_ret( KErrNone ); |
|
2245 start_ret = testMeasurement->Start(); |
|
2246 if( start_ret != KErrNone ) |
|
2247 { |
|
2248 delete testMeasurement; |
|
2249 __TRACE( KError, ( |
|
2250 _L( "CTestCombiner::StartMeasurementL(): Measurement Start() fails:[%d]" ), start_ret ) ); |
|
2251 User::Leave( start_ret ); |
|
2252 } |
|
2253 |
|
2254 TTestMeasurement* object = new (ELeave) TTestMeasurement(); |
|
2255 object->iName = aType; |
|
2256 object->iMeasurement = testMeasurement; |
|
2257 |
|
2258 // Array for handling test measurement between different objects |
|
2259 TInt ret = iTestMeasurementArray.Append( object ); |
|
2260 if( ret != KErrNone ) |
|
2261 { |
|
2262 delete object; |
|
2263 __TRACE( KError, ( |
|
2264 _L( "CTestCombiner::StartMeasurementL(): iTestMeasurementArray.Append fails:[%d]" ), ret ) ); |
|
2265 User::Leave( ret ); |
|
2266 } |
|
2267 |
|
2268 } |
|
2269 |
|
2270 /* |
|
2271 ------------------------------------------------------------------------------- |
|
2272 |
|
2273 Class: CTestCombiner |
|
2274 |
|
2275 Method: StopMeasurementL |
|
2276 |
|
2277 Description: Stops test measurement. |
|
2278 |
|
2279 Parameters: None. |
|
2280 |
|
2281 Return Values: None. |
|
2282 |
|
2283 Errors/Exceptions: None. |
|
2284 |
|
2285 Status: Proposal |
|
2286 |
|
2287 ------------------------------------------------------------------------------- |
|
2288 */ |
|
2289 void CTestCombiner::StopMeasurementL( const TDesC& aType ) |
|
2290 { |
|
2291 __TRACEFUNC(); |
|
2292 |
|
2293 TInt count = iTestMeasurementArray.Count(); |
|
2294 for( TInt i = 0; i < count; i++ ) |
|
2295 { |
|
2296 if( iTestMeasurementArray[i]->iName == aType ) |
|
2297 { |
|
2298 // Found measurement module, stop |
|
2299 iTestMeasurementArray[i]->iMeasurement->Stop(); |
|
2300 // Delete data |
|
2301 delete iTestMeasurementArray[i]; |
|
2302 // Remove pointer to deleted data(Append()) |
|
2303 iTestMeasurementArray.Remove( i ); |
|
2304 // iTestMeasurementArray can contain only one type of measurement |
|
2305 // so we can break when type is removed. |
|
2306 break; |
|
2307 } |
|
2308 } |
|
2309 |
|
2310 } |
|
2311 |
|
2312 /* |
|
2313 ------------------------------------------------------------------------------- |
|
2314 |
|
2315 Class: CTestCombiner |
|
2316 |
|
2317 Method: AppendTestResultToResultDes |
|
2318 |
|
2319 Description: Append to TC's result description (if possible due to length) |
|
2320 limitation provided text in [] brackets. |
|
2321 |
|
2322 Parameters: None. |
|
2323 |
|
2324 Return Values: None. |
|
2325 |
|
2326 Errors/Exceptions: None. |
|
2327 |
|
2328 Status: Proposal |
|
2329 |
|
2330 ------------------------------------------------------------------------------- |
|
2331 */ |
|
2332 void CTestCombiner::AppendTestResultToResultDes(TDes& aResultDescr, const TDesC& aTestCaseResultDescr) |
|
2333 { |
|
2334 if(aTestCaseResultDescr != KNullDesC) |
|
2335 { |
|
2336 _LIT(KAdditionalInfo, " [%S]"); |
|
2337 TInt len = aResultDescr.Length() + KAdditionalInfo().Length() + aTestCaseResultDescr.Length(); |
|
2338 |
|
2339 if(len > KStifMaxResultDes) |
|
2340 { |
|
2341 len = KStifMaxResultDes - aResultDescr.Length() - KAdditionalInfo().Length(); |
|
2342 if(len > 0) |
|
2343 { |
|
2344 TPtrC descr = aTestCaseResultDescr.Mid(0, len); |
|
2345 aResultDescr.AppendFormat(KAdditionalInfo, &descr); |
|
2346 } |
|
2347 } |
|
2348 else |
|
2349 { |
|
2350 aResultDescr.AppendFormat(KAdditionalInfo, &aTestCaseResultDescr); |
|
2351 } |
|
2352 } |
|
2353 } |
|
2354 |
|
2355 /* |
|
2356 ------------------------------------------------------------------------------- |
|
2357 |
|
2358 Class: CTestCombiner |
|
2359 |
|
2360 Method: GetIndexForNewTestModuleController |
|
2361 |
|
2362 Description: Returns new index for test module controller. |
|
2363 This number is appended to module controller name. |
|
2364 This method is used when option to run every test case in |
|
2365 separate process is set to on. |
|
2366 |
|
2367 Parameters: None |
|
2368 |
|
2369 Return Values: None |
|
2370 |
|
2371 Errors/Exceptions: None |
|
2372 |
|
2373 Status: Approved |
|
2374 |
|
2375 ------------------------------------------------------------------------------- |
|
2376 */ |
|
2377 TInt CTestCombiner::GetIndexForNewTestModuleController(void) |
|
2378 { |
|
2379 return iIndexTestModuleControllers++; |
|
2380 } |
|
2381 |
|
2382 /* |
|
2383 ------------------------------------------------------------------------------- |
|
2384 |
|
2385 DESCRIPTION |
|
2386 |
|
2387 This module contains the implementation of CTestRunner class |
|
2388 member functions. CTestRunner is used to execute TestCombiner testcase by |
|
2389 CTestCombiner. |
|
2390 |
|
2391 ------------------------------------------------------------------------------- |
|
2392 */ |
|
2393 // MACROS |
|
2394 #ifdef LOGGER |
|
2395 #undef LOGGER |
|
2396 #endif |
|
2397 #define LOGGER iTestCombiner->iLog |
|
2398 |
|
2399 // ================= MEMBER FUNCTIONS ========================================= |
|
2400 |
|
2401 /* |
|
2402 ------------------------------------------------------------------------------- |
|
2403 |
|
2404 Class: CTestRunner |
|
2405 |
|
2406 Method: CTestRunner |
|
2407 |
|
2408 Description: Default constructor |
|
2409 |
|
2410 C++ default constructor can NOT contain any code, that |
|
2411 might leave. |
|
2412 |
|
2413 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to CTestCombiner |
|
2414 |
|
2415 Return Values: None |
|
2416 |
|
2417 Errors/Exceptions: None |
|
2418 |
|
2419 Status: Approved |
|
2420 |
|
2421 ------------------------------------------------------------------------------- |
|
2422 */ |
|
2423 CTestRunner::CTestRunner( CTestCombiner* aTestCombiner ): |
|
2424 CActive( CActive::EPriorityLow ), // Executed with lowest priority |
|
2425 iState( ERunnerIdle ), |
|
2426 iTestCombiner( aTestCombiner ) |
|
2427 { |
|
2428 CActiveScheduler::Add( this ); |
|
2429 __TRACEFUNC(); |
|
2430 |
|
2431 } |
|
2432 |
|
2433 /* |
|
2434 ------------------------------------------------------------------------------- |
|
2435 |
|
2436 Class: CTestRunner |
|
2437 |
|
2438 Method: ConstructL |
|
2439 |
|
2440 Description: Symbian OS second phase constructor |
|
2441 |
|
2442 Symbian OS default constructor can leave. |
|
2443 |
|
2444 Parameters: None |
|
2445 |
|
2446 Return Values: None |
|
2447 |
|
2448 Errors/Exceptions: None |
|
2449 |
|
2450 Status: Approved |
|
2451 |
|
2452 ------------------------------------------------------------------------------- |
|
2453 */ |
|
2454 void CTestRunner::ConstructL() |
|
2455 { |
|
2456 TInt ret; |
|
2457 |
|
2458 ret = iPauseTimer.CreateLocal(); |
|
2459 if(ret != KErrNone) |
|
2460 { |
|
2461 __TRACE( KError, (_L("Unable to create RTimer: iPauseTimer [%d] "), ret)); |
|
2462 User::Leave(ret); |
|
2463 } |
|
2464 |
|
2465 ret = iPauseCombTimer.CreateLocal(); |
|
2466 if(ret != KErrNone) |
|
2467 { |
|
2468 __TRACE( KError, (_L("Unable to create RTimer: iPauseCombTimer [%d] "), ret)); |
|
2469 User::Leave(ret); |
|
2470 } |
|
2471 |
|
2472 iRemoteTimer = CRemoteTimer::NewL( iTestCombiner ); |
|
2473 |
|
2474 } |
|
2475 |
|
2476 /* |
|
2477 ------------------------------------------------------------------------------- |
|
2478 |
|
2479 Class: CTestRunner |
|
2480 |
|
2481 Method: NewL |
|
2482 |
|
2483 Description: Two-phased constructor. |
|
2484 |
|
2485 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to CTestCombiner |
|
2486 |
|
2487 Return Values: CTestRunner*: new object |
|
2488 |
|
2489 Errors/Exceptions: Leaves if new or ConstructL leaves |
|
2490 |
|
2491 Status: Approved |
|
2492 |
|
2493 ------------------------------------------------------------------------------- |
|
2494 */ |
|
2495 |
|
2496 CTestRunner* CTestRunner::NewL( CTestCombiner* aTestCombiner ) |
|
2497 { |
|
2498 CTestRunner* self = new (ELeave) CTestRunner( aTestCombiner ); |
|
2499 |
|
2500 CleanupStack::PushL( self ); |
|
2501 self->ConstructL(); |
|
2502 CleanupStack::Pop(); |
|
2503 |
|
2504 return self; |
|
2505 } |
|
2506 |
|
2507 /* |
|
2508 ------------------------------------------------------------------------------- |
|
2509 |
|
2510 Class: CTestRunner |
|
2511 |
|
2512 Method: ~CTestRunner |
|
2513 |
|
2514 Description: Destructor |
|
2515 |
|
2516 Parameters: None |
|
2517 |
|
2518 Return Values: None |
|
2519 |
|
2520 Errors/Exceptions: None |
|
2521 |
|
2522 Status: Approved |
|
2523 |
|
2524 ------------------------------------------------------------------------------- |
|
2525 */ |
|
2526 |
|
2527 CTestRunner::~CTestRunner() |
|
2528 { |
|
2529 __TRACEFUNC(); |
|
2530 Cancel(); |
|
2531 |
|
2532 delete iRemoteTimer; |
|
2533 iRemoteTimer = 0; |
|
2534 |
|
2535 delete iLine; |
|
2536 iLine = 0; |
|
2537 |
|
2538 iPauseTimer.Close(); |
|
2539 |
|
2540 iPauseCombTimer.Close(); |
|
2541 |
|
2542 } |
|
2543 |
|
2544 /* |
|
2545 ------------------------------------------------------------------------------- |
|
2546 |
|
2547 Class: CTestRunner |
|
2548 |
|
2549 Method: RunL |
|
2550 |
|
2551 Description: Derived from CActive, handles testcase execution. |
|
2552 |
|
2553 Parameters: None. |
|
2554 |
|
2555 Return Values: None. |
|
2556 |
|
2557 Errors/Exceptions: Leaves on error situations. |
|
2558 |
|
2559 Status: Approved |
|
2560 |
|
2561 ------------------------------------------------------------------------------- |
|
2562 */ |
|
2563 void CTestRunner::RunL() |
|
2564 { |
|
2565 __TRACEFUNC(); |
|
2566 __TRACE( KMessage, (_L("CTestRunner::RunL: [%d] "), iStatus.Int() )); |
|
2567 |
|
2568 User::LeaveIfError( iStatus.Int() ); |
|
2569 |
|
2570 if( ( iTestCombiner == NULL ) || |
|
2571 ( iTestCombiner->iSectionParser == NULL ) ) |
|
2572 { |
|
2573 User::Leave( KErrGeneral ); |
|
2574 } |
|
2575 |
|
2576 TBool continueTask = EFalse; |
|
2577 |
|
2578 // Check if there is still some time for combiner pause and we need to |
|
2579 // continue pausing |
|
2580 if(iPauseCombRemainingTime > 0) |
|
2581 { |
|
2582 // Maximum time for one RTimer::After request |
|
2583 TInt maximumTime = KMaxTInt / 1000; |
|
2584 |
|
2585 __TRACE( KMessage, (_L("CTestRunner::RunL: Going to reissue PauseCombiner request ") ) ); |
|
2586 __TRACE( KMessage, (_L("CTestRunner::RunL: iRemainingTimeValue = %d"), iPauseCombRemainingTime ) ); |
|
2587 |
|
2588 if( iPauseCombRemainingTime < maximumTime ) |
|
2589 { |
|
2590 iPauseCombTimer.After(iStatus, (iPauseCombRemainingTime * 1000)); |
|
2591 iPauseCombRemainingTime = 0; |
|
2592 } |
|
2593 else |
|
2594 { |
|
2595 iPauseCombRemainingTime -= maximumTime; |
|
2596 iPauseCombTimer.After(iStatus, (maximumTime * 1000)); |
|
2597 } |
|
2598 |
|
2599 SetActive(); |
|
2600 return; |
|
2601 } |
|
2602 |
|
2603 // Handling runner states |
|
2604 switch( iState ) |
|
2605 { |
|
2606 case ERunnerWaitTimeout: |
|
2607 { |
|
2608 __TRACE( KMessage, (_L("Resume %S"), &iPausedTestCase)); |
|
2609 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, |
|
2610 KExecute, _L("Resume %S"), &iPausedTestCase); |
|
2611 // Get running testcase identified with testid |
|
2612 CTestCase* testCase = iTestCombiner->GetRunningTest( iPausedTestCase ); |
|
2613 if( testCase == NULL ) User::Leave( KErrNotFound ); |
|
2614 iPausedTestCase.Zero(); |
|
2615 if( testCase->Type() == CTestCase::ECaseLocal ) |
|
2616 { |
|
2617 CTCTestCase* localTestCase = ( CTCTestCase* )testCase; |
|
2618 // Resume execution |
|
2619 User::LeaveIfError( localTestCase->TestExecution().Resume() ); |
|
2620 continueTask = ETrue; |
|
2621 } |
|
2622 else // ECaseRemote |
|
2623 { |
|
2624 CRemoteTestCase* remoteTestCase = ( CRemoteTestCase* )testCase; |
|
2625 // Resume execution |
|
2626 if( ExecuteRemoteTestCtlL( NULL, |
|
2627 remoteTestCase, |
|
2628 TTCKeywords::EResume ) ) |
|
2629 { |
|
2630 continueTask = ETrue; |
|
2631 } |
|
2632 } |
|
2633 } |
|
2634 break; |
|
2635 case ERunnerWaitUnset: |
|
2636 iState = ERunnerIdle; |
|
2637 |
|
2638 // Check Unset event |
|
2639 if( !CheckUnsetEvent() ) |
|
2640 { |
|
2641 // Got event and unset has not completed |
|
2642 // Should never come here |
|
2643 User::Panic( KTestRunner, KErrGeneral ); |
|
2644 } |
|
2645 break; |
|
2646 |
|
2647 case ERunnerRunning: |
|
2648 { |
|
2649 iState = ERunnerIdle; |
|
2650 |
|
2651 // Get next execution line from configuration section |
|
2652 iEndLoopStartPos = iTestCombiner->iSectionParser->GetPosition(); |
|
2653 TPtrC line; |
|
2654 if( iTestCombiner->iSectionParser->GetNextLine( line ) == KErrNone ) |
|
2655 { |
|
2656 // Got new execution line |
|
2657 __TRACE( KMessage, (_L("CTestRunner got line"))); |
|
2658 |
|
2659 CStifItemParser* item = PreprocessLineL( line ); |
|
2660 |
|
2661 if( item ) |
|
2662 { |
|
2663 // Got new execution line |
|
2664 CleanupStack::PushL( item ); |
|
2665 |
|
2666 // Execute script line |
|
2667 if( ExecuteLineL( item ) ) |
|
2668 { |
|
2669 __TRACE( KMessage, (_L("RunL: continueTask"))); |
|
2670 // Set CTestRunner active again to perform |
|
2671 // next execution line |
|
2672 // from testcase section |
|
2673 continueTask = ETrue; |
|
2674 } |
|
2675 CleanupStack::PopAndDestroy( item ); |
|
2676 } |
|
2677 } |
|
2678 else |
|
2679 { |
|
2680 // No more execution lines in testcase section |
|
2681 __TRACE( KMessage, |
|
2682 (_L("CTestRunner::RunL: Testcase script done (%d running)"), |
|
2683 iTestCombiner->iRunningTests)); |
|
2684 |
|
2685 if( ( iTestCombiner->iRunningTests == 0 ) && |
|
2686 iTestCombiner->iSchedulerActive ) |
|
2687 { |
|
2688 __TRACE( KMessage, |
|
2689 (_L("RunL: All TestCases done, stop CActiveScheduler"))); |
|
2690 CActiveScheduler::Current()->Stop(); |
|
2691 iTestCombiner->iSchedulerActive = EFalse; |
|
2692 } |
|
2693 // Now testcase section is executed, |
|
2694 // so CTestRunner has done its job and stops |
|
2695 iState = ERunnerReady; |
|
2696 |
|
2697 //If we're inside loop, then we have error |
|
2698 if(iTestCombiner->iLoopIsUsed) |
|
2699 { |
|
2700 __TRACE(KError, (_L("Endloop keyword not found. Cannot finish test case properly."))); |
|
2701 iTestCombiner->iResult = KErrGeneral; |
|
2702 } |
|
2703 } |
|
2704 } |
|
2705 break; |
|
2706 case ERunnerAllocate: |
|
2707 case ERunnerFree: |
|
2708 case ERunnerRemote: |
|
2709 default: |
|
2710 __TRACE( KError, |
|
2711 (_L("CTestRunner::RunL: Entered in illegal state(%d)"), iState )); |
|
2712 User::Panic( KTestRunner, KErrGeneral ); |
|
2713 break; |
|
2714 } |
|
2715 if( continueTask ) |
|
2716 { |
|
2717 SetRunnerActive(); |
|
2718 } |
|
2719 |
|
2720 } |
|
2721 |
|
2722 /* |
|
2723 ------------------------------------------------------------------------------- |
|
2724 |
|
2725 Class: CTestRunner |
|
2726 |
|
2727 Method: DoCancel |
|
2728 |
|
2729 Description: Derived from CActive handles the Cancel |
|
2730 |
|
2731 Parameters: None. |
|
2732 |
|
2733 Return Values: None. |
|
2734 |
|
2735 Errors/Exceptions: None. |
|
2736 |
|
2737 Status: Approved |
|
2738 |
|
2739 ------------------------------------------------------------------------------- |
|
2740 */ |
|
2741 void CTestRunner::DoCancel() |
|
2742 { |
|
2743 __TRACEFUNC(); |
|
2744 __TRACE( KMessage, (_L("CTestRunner::DoCancel"))); |
|
2745 iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), _L("DoCancel")); |
|
2746 |
|
2747 iPauseCombTimer.Cancel(); |
|
2748 |
|
2749 switch( iState ) |
|
2750 { |
|
2751 case ERunnerWaitTimeout: |
|
2752 iPauseTimer.Cancel(); |
|
2753 break; |
|
2754 case ERunnerWaitUnset: |
|
2755 break; |
|
2756 case ERunnerRunning: |
|
2757 break; |
|
2758 case ERunnerAllocate: |
|
2759 case ERunnerFree: |
|
2760 case ERunnerRemote: |
|
2761 // Cancel remote test cases |
|
2762 break; |
|
2763 default: |
|
2764 __TRACE( KError, |
|
2765 (_L("CTestRunner::DoCancel: Entered in illegal state(%d)"), iState )); |
|
2766 User::Panic( KTestRunner, KErrGeneral ); |
|
2767 break; |
|
2768 } |
|
2769 |
|
2770 // Cancel all testcases |
|
2771 CancelTestCases(); |
|
2772 |
|
2773 iState = ERunnerCancel; |
|
2774 |
|
2775 } |
|
2776 |
|
2777 /* |
|
2778 ------------------------------------------------------------------------------- |
|
2779 |
|
2780 Class: CTestRunner |
|
2781 |
|
2782 Method: RunError |
|
2783 |
|
2784 Description: Derived from CActive handles errors from active handler. |
|
2785 |
|
2786 Parameters: TInt aError: in: error from CActive |
|
2787 |
|
2788 Return Values: KErrNone: success |
|
2789 |
|
2790 Errors/Exceptions: None. |
|
2791 |
|
2792 Status: Approved |
|
2793 |
|
2794 ------------------------------------------------------------------------------- |
|
2795 */ |
|
2796 TInt CTestRunner::RunError( TInt aError ) |
|
2797 { |
|
2798 __TRACEFUNC(); |
|
2799 __TRACE( KMessage, (_L("CTestRunner::RunError %d"), aError)); |
|
2800 |
|
2801 if ( iRunErrorMessage.Length() != 0 ) |
|
2802 { |
|
2803 iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), |
|
2804 _L("RunError : %S"), &iRunErrorMessage ); |
|
2805 iRunErrorMessage = KNullDesC; |
|
2806 } |
|
2807 else |
|
2808 { |
|
2809 iTestCombiner->TestModuleIf().Printf( KPrintPriLow, _L("Runner"), |
|
2810 _L("RunError")); |
|
2811 } |
|
2812 |
|
2813 iState = ERunnerError; |
|
2814 |
|
2815 // Return error from here |
|
2816 iTestCombiner->iResult = aError; |
|
2817 |
|
2818 CancelTestCases(); |
|
2819 return KErrNone; |
|
2820 } |
|
2821 |
|
2822 /* |
|
2823 ------------------------------------------------------------------------------- |
|
2824 |
|
2825 Class: CTestRunner |
|
2826 |
|
2827 Method: PreprocessLineL |
|
2828 |
|
2829 Description: Preprocesses script line |
|
2830 |
|
2831 Parameters: TPtrC& line: in: script line |
|
2832 CStifItemParser*& aItem: out: New CStifItemParser for script |
|
2833 line. |
|
2834 |
|
2835 Return Values: HBufC* pointer if new memory that has been allocated |
|
2836 |
|
2837 Errors/Exceptions: Leaves on error situations. |
|
2838 |
|
2839 Status: Draft |
|
2840 |
|
2841 ------------------------------------------------------------------------------- |
|
2842 */ |
|
2843 CStifItemParser* CTestRunner::PreprocessLineL( TDesC& line ) |
|
2844 { |
|
2845 |
|
2846 CStifItemParser* item = NULL; |
|
2847 TPtrC tmp; |
|
2848 TInt len = 0; |
|
2849 |
|
2850 // Decide how long buffer should be allocated |
|
2851 if( line.Length() < KMaxName/2 ) |
|
2852 { |
|
2853 len = KMaxName; |
|
2854 } |
|
2855 else |
|
2856 { |
|
2857 len = line.Length() + KMaxName; |
|
2858 } |
|
2859 delete iLine; |
|
2860 iLine = 0; |
|
2861 iLine = HBufC::NewL( len ); |
|
2862 TPtr parsedLine( iLine->Des() ); |
|
2863 len = 0; |
|
2864 |
|
2865 item = CStifItemParser::NewL( line, 0, line.Length() ); |
|
2866 CleanupStack::PushL( item); |
|
2867 |
|
2868 TInt ret = item->GetString( _L(""), tmp ); |
|
2869 while( ret == KErrNone ) |
|
2870 { |
|
2871 len += CheckDefined( tmp ); |
|
2872 if( ( parsedLine.Length() + tmp.Length() + 1 ) > parsedLine.MaxLength() ) |
|
2873 { |
|
2874 // Allocate bigger buffer |
|
2875 HBufC* tmpBuf = HBufC::NewL( parsedLine.MaxLength() + KMaxName ); |
|
2876 CleanupStack::PushL( tmpBuf ); |
|
2877 TPtrC ptr( iLine->Des() ); |
|
2878 parsedLine.Set( tmpBuf->Des() ); |
|
2879 parsedLine.Copy( ptr ); |
|
2880 delete iLine; |
|
2881 iLine = tmpBuf; |
|
2882 CleanupStack::Pop( tmpBuf ); |
|
2883 } |
|
2884 parsedLine.Append( tmp ); |
|
2885 parsedLine.Append( _L(" ") ); |
|
2886 ret = item->GetNextString( tmp ); |
|
2887 } |
|
2888 |
|
2889 CleanupStack::PopAndDestroy( item ); |
|
2890 |
|
2891 item = CStifItemParser::NewL( parsedLine, 0, parsedLine.Length() ); |
|
2892 |
|
2893 return item; |
|
2894 |
|
2895 } |
|
2896 |
|
2897 /* |
|
2898 ------------------------------------------------------------------------------- |
|
2899 |
|
2900 Class: CTestRunner |
|
2901 |
|
2902 Method: CheckDefined |
|
2903 |
|
2904 Description: Check if aWord is some defined word |
|
2905 |
|
2906 Parameters: TPtrC& aWord: inout: Parsed word, defined or original returned |
|
2907 |
|
2908 Return Values: TInt: Length difference between new and old word |
|
2909 |
|
2910 Errors/Exceptions: None. |
|
2911 |
|
2912 Status: Approved |
|
2913 |
|
2914 ------------------------------------------------------------------------------- |
|
2915 */ |
|
2916 TInt CTestRunner::CheckDefined( TPtrC& aWord ) |
|
2917 { |
|
2918 TInt len = 0; |
|
2919 |
|
2920 // KLoopCounter word changing to current loop count value. |
|
2921 if( aWord == KLoopCounter ) |
|
2922 { |
|
2923 iLoopCounterDes.Zero(); |
|
2924 iLoopCounterDes.AppendNum( iLoopCounter ); |
|
2925 len = iLoopCounterDes.Length() - aWord.Length(); |
|
2926 aWord.Set( iLoopCounterDes ); |
|
2927 return len; |
|
2928 } |
|
2929 |
|
2930 TInt count = iTestCombiner->iDefined.Count(); |
|
2931 for( TInt i = 0; i < count; i++ ) |
|
2932 { |
|
2933 if( iTestCombiner->iDefined[i]->Name() == aWord ) |
|
2934 { |
|
2935 len = iTestCombiner->iDefined[i]->Value().Length() - aWord.Length(); |
|
2936 aWord.Set( iTestCombiner->iDefined[i]->Value() ); |
|
2937 break; |
|
2938 } |
|
2939 } |
|
2940 return len; |
|
2941 |
|
2942 } |
|
2943 |
|
2944 /* |
|
2945 ------------------------------------------------------------------------------- |
|
2946 |
|
2947 Class: CTestRunner |
|
2948 |
|
2949 Method: ExecuteLineL |
|
2950 |
|
2951 Description: Executes script line |
|
2952 |
|
2953 Parameters: CStifItemParser* aItem: in: script line |
|
2954 TTCKeywords::TKeywords aKeyword: in: keyword index |
|
2955 |
|
2956 Return Values: ETrue: continue script file execution |
|
2957 EFalse: stop script file execution |
|
2958 |
|
2959 Errors/Exceptions: Leaves on error situations. |
|
2960 |
|
2961 Status: Approved |
|
2962 |
|
2963 ------------------------------------------------------------------------------- |
|
2964 */ |
|
2965 TBool CTestRunner::ExecuteLineL( CStifItemParser* aItem ) |
|
2966 { |
|
2967 _LIT( KErrMsgUnknownKeyword, "Unknown or illegal keyword %S" ); |
|
2968 _LIT( KErrMsgMeasurementInvalidArgument, "Measurement : Invalid argument" ); |
|
2969 TBool continueTask = ETrue; |
|
2970 TPtrC tmp; |
|
2971 |
|
2972 TPtrC keywordItem; |
|
2973 // Get first word from line, i.e. keyword |
|
2974 User::LeaveIfError( aItem->GetString( _L(""), keywordItem ) ); |
|
2975 // Parse keyword |
|
2976 TInt keyword = TTCKeywords::Parse( keywordItem, TTCKeywords::Keyword ); |
|
2977 |
|
2978 switch( keyword ) |
|
2979 { |
|
2980 // Test case execution control cases |
|
2981 case TTCKeywords::EPauseCombiner: |
|
2982 continueTask = ExecuteCombinerPauseL( aItem ); |
|
2983 break; |
|
2984 case TTCKeywords::ERun: |
|
2985 continueTask = ExecuteRunL( aItem ); |
|
2986 break; |
|
2987 case TTCKeywords::EPause: |
|
2988 case TTCKeywords::EComplete: |
|
2989 case TTCKeywords::ECancel: |
|
2990 case TTCKeywords::EResume: |
|
2991 continueTask = ExecuteTestCtlL( aItem, (TTCKeywords::TKeywords)keyword ); |
|
2992 break; |
|
2993 |
|
2994 // Event control cases |
|
2995 case TTCKeywords::ESet: |
|
2996 continueTask = ExecuteEventSetL( aItem ); |
|
2997 break; |
|
2998 case TTCKeywords::EUnset: |
|
2999 continueTask = ExecuteEventUnsetL( aItem ); |
|
3000 break; |
|
3001 case TTCKeywords::ERequest: |
|
3002 case TTCKeywords::EWait: |
|
3003 case TTCKeywords::ERelease: |
|
3004 continueTask = ExecuteEventCtlL( aItem, (TTCKeywords::TKeywords)keyword ); |
|
3005 break; |
|
3006 case TTCKeywords::EPrint: |
|
3007 { |
|
3008 TName buf; |
|
3009 while( aItem->GetNextString( tmp ) == KErrNone ) |
|
3010 { |
|
3011 if( buf.Length() + tmp.Length() >= buf.MaxLength() ) |
|
3012 { |
|
3013 break; |
|
3014 } |
|
3015 buf.Append( tmp ); |
|
3016 buf.Append( _L(" ") ); |
|
3017 } |
|
3018 |
|
3019 __TRACE( KMessage, (_L("Test: %S"), &buf )); |
|
3020 iTestCombiner->TestModuleIf().Printf( KPrintPriHigh, |
|
3021 _L("Test"), |
|
3022 _L("%S"), &buf); |
|
3023 } |
|
3024 break; |
|
3025 case TTCKeywords::EAllocate: |
|
3026 continueTask = ExecuteAllocateL( aItem ); |
|
3027 break; |
|
3028 case TTCKeywords::EFree: |
|
3029 continueTask = ExecuteFreeL( aItem ); |
|
3030 break; |
|
3031 case TTCKeywords::ERemote: |
|
3032 continueTask = ExecuteRemoteL( aItem ); |
|
3033 break; |
|
3034 case TTCKeywords::ETimeout: |
|
3035 case TTCKeywords::EPriority: |
|
3036 // not used here |
|
3037 break; |
|
3038 case TTCKeywords::ECancelIfError: |
|
3039 // @js |
|
3040 iTestCombiner->iCancelIfError = ETrue; |
|
3041 break; |
|
3042 case TTCKeywords::EMeasurement: |
|
3043 TRAPD( retErr, iTestCombiner->ExecuteMeasurementL( aItem ) ); |
|
3044 if ( retErr == KErrArgument ) |
|
3045 { |
|
3046 iRunErrorMessage = KErrMsgMeasurementInvalidArgument; |
|
3047 } |
|
3048 if ( retErr != KErrNone ) |
|
3049 { |
|
3050 User::Leave( retErr ); |
|
3051 } |
|
3052 break; |
|
3053 case TTCKeywords::ELoop: |
|
3054 ExecuteLoopL( aItem ); |
|
3055 iTestCombiner->iLoopIsUsed = ETrue; |
|
3056 break; |
|
3057 case TTCKeywords::EEndLoop: |
|
3058 continueTask = ExecuteEndLoopL(); |
|
3059 break; |
|
3060 case TTCKeywords::ETitle: |
|
3061 // title has been handled already, this is duplicate |
|
3062 default: |
|
3063 { |
|
3064 __TRACE( KError, (_L("Unknown or illegal keyword") ) ); |
|
3065 // Unknown or illegal keyword |
|
3066 iRunErrorMessage.Format( KErrMsgUnknownKeyword, &keywordItem ); |
|
3067 User::Leave( KErrGeneral ); |
|
3068 } |
|
3069 break; |
|
3070 } |
|
3071 |
|
3072 __TRACE( KMessage, (_L("RunL: TestCase line executed"))); |
|
3073 |
|
3074 return continueTask; |
|
3075 |
|
3076 } |
|
3077 |
|
3078 /* |
|
3079 ------------------------------------------------------------------------------- |
|
3080 |
|
3081 Class: CTestRunner |
|
3082 |
|
3083 Method: ExecuteRunL |
|
3084 |
|
3085 Description: Executes run line |
|
3086 |
|
3087 Parameters: CStifItemParser* aItem: in: script line |
|
3088 |
|
3089 Return Values: ETrue: continue script file execution |
|
3090 EFalse: stop script file execution |
|
3091 |
|
3092 Errors/Exceptions: Leaves on error situations. |
|
3093 |
|
3094 Status: Proposal |
|
3095 |
|
3096 ------------------------------------------------------------------------------- |
|
3097 */ |
|
3098 TBool CTestRunner::ExecuteRunL( CStifItemParser* aItem ) |
|
3099 { |
|
3100 _LIT( KErrMsgCaseRunError, "Run : %S[case=%d] run error" ); |
|
3101 __TRACE( KMessage, (_L("Run"))); |
|
3102 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, KExecute, _L("Run")); |
|
3103 |
|
3104 CStartInfo* startInfo = CStartInfo::NewL(); |
|
3105 CleanupStack::PushL( startInfo ); |
|
3106 |
|
3107 ParseRunParamsL( aItem, *startInfo ); |
|
3108 |
|
3109 // Start new case with configurations parsed above |
|
3110 |
|
3111 iRunErrorMessage.Format( KErrMsgCaseRunError, &startInfo->iModule, startInfo->iCaseNum ); |
|
3112 User::LeaveIfError( |
|
3113 iTestCombiner->StartTestL( *startInfo ) ); |
|
3114 iRunErrorMessage = KNullDesC; |
|
3115 |
|
3116 CleanupStack::PopAndDestroy( startInfo ); |
|
3117 |
|
3118 return ETrue; |
|
3119 |
|
3120 } |
|
3121 |
|
3122 |
|
3123 /* |
|
3124 ------------------------------------------------------------------------------- |
|
3125 |
|
3126 Class: CTestRunner |
|
3127 |
|
3128 Method: ParseRunParamsL |
|
3129 |
|
3130 Description: Parses run parameters |
|
3131 |
|
3132 Parameters: CStifItemParser* aItem: in: script line |
|
3133 CStartInfo& aStartInfo: out: Parsed information |
|
3134 |
|
3135 Return Values: None |
|
3136 |
|
3137 Errors/Exceptions: Leaves on error situations. |
|
3138 |
|
3139 Status: Draft |
|
3140 |
|
3141 ------------------------------------------------------------------------------- |
|
3142 */ |
|
3143 void CTestRunner::ParseRunParamsL( CStifItemParser* aItem, |
|
3144 CStartInfo& aStartInfo ) |
|
3145 { |
|
3146 _LIT( KErrMsgRunTestmoduleNameNotDefined, "Run : Testmodule name is not defined " ); |
|
3147 _LIT( KErrMsgRunCfgFileNotDefined, "Run : Testmodule configuration file is not defined" ); |
|
3148 _LIT( KErrMsgRunTestcaseNumberNotDefined, "Run : Testcase number is not defined or has invalid value" ); |
|
3149 _LIT( KErrMsgRunCfgFileNameToLong, "Run : TestScripter test case file(config)'s name is too long. Current length[%d], allowed max length[%d]. Cannot continue" ); |
|
3150 _LIT( KErrMsgRunInvalidExpectValue, "Run : Invalid expected result value" ); |
|
3151 _LIT( KErrMsgRunUnknownOrIllegalCategory, "Run : Unknown or illegal result category" ); |
|
3152 _LIT( KErrMsgRunInvalidTimeoutValue, "Run: Invalid testcase timeout value" ); |
|
3153 _LIT( KErrMsgRunUnknowOrIllegalKeyword, "Run: Unknown or illegal keyword %S" ); |
|
3154 |
|
3155 TPtrC tmp; |
|
3156 TInt ret = KErrNone; |
|
3157 |
|
3158 // Get mandatory run arguments |
|
3159 // Testmodule name |
|
3160 ret = aItem->GetNextString( tmp ); |
|
3161 if ( ret != KErrNone ) |
|
3162 { |
|
3163 iRunErrorMessage = KErrMsgRunTestmoduleNameNotDefined; |
|
3164 User::Leave( ret ); |
|
3165 } |
|
3166 |
|
3167 aStartInfo.SetModuleNameL( tmp ); |
|
3168 __TRACE( KMessage, (_L("module: %S"), &aStartInfo.iModule )); |
|
3169 |
|
3170 // Configuration file |
|
3171 ret = aItem->GetNextString( tmp ); |
|
3172 if ( ret != KErrNone ) |
|
3173 { |
|
3174 iRunErrorMessage = KErrMsgRunCfgFileNotDefined; |
|
3175 User::Leave( ret ); |
|
3176 } |
|
3177 |
|
3178 TFileName cfgFileName( tmp ); |
|
3179 TStifUtil::CorrectFilePathL( cfgFileName ); |
|
3180 aStartInfo.SetConfigL( cfgFileName ); |
|
3181 |
|
3182 __TRACE( KMessage, (_L("config: %S"), &aStartInfo.iConfig )); |
|
3183 |
|
3184 // Check is TestScripter |
|
3185 if( aStartInfo.iModule.Find( KTestScripterName ) != KErrNotFound ) |
|
3186 { |
|
3187 // TestScripter name is format: 'testscripter_testcasefilename' |
|
3188 |
|
3189 TParse parse; |
|
3190 parse.Set( aStartInfo.iConfig, NULL, NULL ); |
|
3191 |
|
3192 // Maximum length of TestScripter's name(Max limitation from |
|
3193 // CTestModuleController creation) |
|
3194 TInt maximumLength = KMaxName - ( KTestScripterNameLength + 1 ); |
|
3195 |
|
3196 TFileName testScripterAndTestCaseFile; // InitL() takes TFileName |
|
3197 testScripterAndTestCaseFile.Copy( KTestScripterName ); |
|
3198 testScripterAndTestCaseFile.Append( _L( "_" ) ); |
|
3199 if( parse.Name().Length() < maximumLength ) |
|
3200 { |
|
3201 testScripterAndTestCaseFile.Append( parse.Name() ); |
|
3202 } |
|
3203 else |
|
3204 { |
|
3205 __TRACE( KInit, ( CStifLogger::ERed, |
|
3206 _L( "TestScripter test case file(config)'s name is too long. Current length[%d], allowed max length[%d]. Cannot continue" ), |
|
3207 parse.Name().Length(), maximumLength ) ); |
|
3208 iRunErrorMessage.Format( KErrMsgRunCfgFileNameToLong, parse.Name().Length(), maximumLength ); |
|
3209 User::Leave( KErrArgument ); |
|
3210 } |
|
3211 // ---- |
|
3212 aStartInfo.DeleteModuleName(); // Delete old name buffer for new one |
|
3213 aStartInfo.SetModuleNameL( testScripterAndTestCaseFile ); |
|
3214 } |
|
3215 |
|
3216 // Testcase number |
|
3217 ret = aItem->GetInt( tmp, aStartInfo.iCaseNum ); |
|
3218 if ( ret != KErrNone ) |
|
3219 { |
|
3220 iRunErrorMessage = KErrMsgRunTestcaseNumberNotDefined; |
|
3221 User::Leave( ret ); |
|
3222 } |
|
3223 |
|
3224 __TRACE( KMessage, (_L("testcasenum: %d"), aStartInfo.iCaseNum ) ); |
|
3225 |
|
3226 // Set mode of item parser to be able to read titles with spaces inside |
|
3227 aItem->SetParsingType(CStifItemParser::EQuoteStyleParsing); |
|
3228 |
|
3229 // Get optional run arguments |
|
3230 while( aItem->GetNextString( tmp ) == KErrNone ) |
|
3231 { |
|
3232 TPtrC val; |
|
3233 TPtrC arg; |
|
3234 ParseOptArgL( tmp, arg, val ); |
|
3235 CheckDefined( val ); |
|
3236 |
|
3237 // Parse optional argument |
|
3238 switch( TTCKeywords::Parse( arg, TTCKeywords::RunOptArg ) ) |
|
3239 { |
|
3240 case TTCKeywords::EExpect: |
|
3241 { |
|
3242 TLex ptr( val ); |
|
3243 ret = ptr.Val( aStartInfo.iExpectedResult ); |
|
3244 if ( ret != KErrNone ) |
|
3245 { |
|
3246 iRunErrorMessage = KErrMsgRunInvalidExpectValue; |
|
3247 User::Leave( ret ); |
|
3248 } |
|
3249 __TRACE( KMessage, (_L("expect=%d"), aStartInfo.iExpectedResult)); |
|
3250 } |
|
3251 break; |
|
3252 case TTCKeywords::ETestid: |
|
3253 { |
|
3254 aStartInfo.SetTestIdL( val ); |
|
3255 __TRACE( KMessage, (_L("TestId=%S"), &val)); |
|
3256 } |
|
3257 break; |
|
3258 case TTCKeywords::EIni: |
|
3259 { |
|
3260 __TRACE( KMessage, (_L("ini=%S"), &val)); |
|
3261 TFileName iniFileName( val ); |
|
3262 TStifUtil::CorrectFilePathL( iniFileName ); |
|
3263 aStartInfo.SetIniFileL( iniFileName ); |
|
3264 } |
|
3265 break; |
|
3266 case TTCKeywords::ECategory: |
|
3267 { |
|
3268 __TRACE( KMessage, (_L("category=%S"), &val)); |
|
3269 aStartInfo.iCategory = TTCKeywords::GetResultCategory( val ); |
|
3270 if( aStartInfo.iCategory == TFullTestResult::ECaseOngoing ) |
|
3271 { |
|
3272 __TRACE( KError, (_L("Unknown or illegal result category"))); |
|
3273 //Unknown or illegal category |
|
3274 iRunErrorMessage = KErrMsgRunUnknownOrIllegalCategory; |
|
3275 User::Leave( KErrGeneral ); |
|
3276 } |
|
3277 } |
|
3278 break; |
|
3279 case TTCKeywords::ECaseTimeout: |
|
3280 { |
|
3281 TLex ptr( val ); |
|
3282 ret = ptr.Val( aStartInfo.iTimeout ); |
|
3283 if ( ret != KErrNone ) |
|
3284 { |
|
3285 iRunErrorMessage = KErrMsgRunInvalidTimeoutValue; |
|
3286 User::Leave( ret ); |
|
3287 } |
|
3288 __TRACE( KMessage, (_L("timeout=%d"), aStartInfo.iTimeout ) ); |
|
3289 } |
|
3290 break; |
|
3291 case TTCKeywords::ECaseTitle: |
|
3292 { |
|
3293 __TRACE( KMessage, (_L("case title=%S"), &val)); |
|
3294 aStartInfo.SetTitleL(val); |
|
3295 break; |
|
3296 } |
|
3297 case TTCKeywords::EArgs: |
|
3298 { |
|
3299 __TRACE( KMessage, (_L("case arguments=%S"), &val)); |
|
3300 aStartInfo.SetTestCaseArgumentsL( val ); |
|
3301 } |
|
3302 break; |
|
3303 default: |
|
3304 { |
|
3305 __TRACE( KError, (_L("Unknown or illegal keyword"))); |
|
3306 //Unknown or illegal keyword |
|
3307 iRunErrorMessage.Format( KErrMsgRunUnknowOrIllegalKeyword, &arg ); |
|
3308 User::Leave( KErrGeneral ); |
|
3309 } |
|
3310 } |
|
3311 } |
|
3312 } |
|
3313 |
|
3314 /* |
|
3315 ------------------------------------------------------------------------------- |
|
3316 |
|
3317 Class: CTestRunner |
|
3318 |
|
3319 Method: ExecuteTestCtlL |
|
3320 |
|
3321 Description: Executes script line |
|
3322 |
|
3323 Parameters: CStifItemParser* aItem: in: script line |
|
3324 TTCKeywords::TKeywords aKeyword: in: keyword index |
|
3325 |
|
3326 Return Values: ETrue: continue script file execution |
|
3327 EFalse: stop script file execution |
|
3328 |
|
3329 Errors/Exceptions: Leaves on error situations. |
|
3330 |
|
3331 Status: Approved |
|
3332 |
|
3333 ------------------------------------------------------------------------------- |
|
3334 */ |
|
3335 TBool CTestRunner::ExecuteTestCtlL( CStifItemParser* aItem, |
|
3336 TTCKeywords::TKeywords aKeyword ) |
|
3337 { |
|
3338 _LIT( KErrMsgTestIdNotDefined, "%S : testid is not defined" ); |
|
3339 _LIT( KErrMsgTestCaseNotFound, "%S : Test case %S not found" ); |
|
3340 TBool continueTask = ETrue; |
|
3341 TPtrC tmp; |
|
3342 |
|
3343 TInt ret = KErrNone; |
|
3344 |
|
3345 TPtrC keywordStr = TTCKeywords::Keyword( aKeyword ); |
|
3346 |
|
3347 // Parse testid |
|
3348 ret = aItem->GetNextString( tmp ); |
|
3349 if( ret != KErrNone ) |
|
3350 { |
|
3351 iRunErrorMessage.Format( KErrMsgTestIdNotDefined, &keywordStr ); |
|
3352 User::Leave( ret ); |
|
3353 } |
|
3354 |
|
3355 // Get testcase identified with testid |
|
3356 CTestCase* testCase = iTestCombiner->GetTest( tmp ); |
|
3357 if( testCase == NULL ) |
|
3358 { |
|
3359 __TRACE( KError, (_L("ExecuteTestCtlL: Test case %S not found"), |
|
3360 &tmp)); |
|
3361 iRunErrorMessage.Format( KErrMsgTestCaseNotFound, &keywordStr, &tmp ); |
|
3362 User::Leave( KErrNotFound ); |
|
3363 } |
|
3364 |
|
3365 switch( aKeyword ) |
|
3366 { |
|
3367 // Test case execution control cases |
|
3368 case TTCKeywords::EPause: |
|
3369 continueTask = ExecutePauseL( aItem, testCase ); |
|
3370 break; |
|
3371 case TTCKeywords::EComplete: |
|
3372 continueTask = ExecuteCompleteL( aItem, testCase ); |
|
3373 break; |
|
3374 case TTCKeywords::ECancel: |
|
3375 __TRACE( KMessage, (_L("Cancel %S"), &tmp)); |
|
3376 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, |
|
3377 KExecute, _L("Cancel %S"), &tmp); |
|
3378 if( testCase->Type() == CTestCase::ECaseRemote ) |
|
3379 { |
|
3380 continueTask = |
|
3381 ExecuteRemoteTestCtlL( aItem, testCase, aKeyword ); |
|
3382 } |
|
3383 else |
|
3384 { |
|
3385 if( testCase->State() != CTestCase::ETestCaseRunning ) |
|
3386 { |
|
3387 __TRACE( KMessage, (_L("Cancelled task (%S) not running (%i)"), |
|
3388 &tmp, testCase->State() )); |
|
3389 User::Leave( KErrNotFound ); |
|
3390 } |
|
3391 CTCTestCase* test = ( CTCTestCase* )testCase; |
|
3392 // Cancel local testcase |
|
3393 test->TestExecution().CancelAsyncRequest( ETestExecutionRunTestCase ); |
|
3394 } |
|
3395 break; |
|
3396 case TTCKeywords::EResume: |
|
3397 { |
|
3398 __TRACE( KMessage, (_L("Resume %S"), &tmp)); |
|
3399 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, |
|
3400 KExecute, _L("Resume %S"), &tmp); |
|
3401 if( testCase->Type() == CTestCase::ECaseRemote ) |
|
3402 { |
|
3403 continueTask = |
|
3404 ExecuteRemoteTestCtlL( aItem, testCase, aKeyword ); |
|
3405 } |
|
3406 else |
|
3407 { |
|
3408 if( testCase->State() != CTestCase::ETestCaseRunning ) |
|
3409 { |
|
3410 __TRACE( KMessage, (_L("Resumed task (%S) not running (%i)"), |
|
3411 &tmp, testCase->State() )); |
|
3412 User::Leave( KErrNotFound ); |
|
3413 } |
|
3414 CTCTestCase* test = ( CTCTestCase* )testCase; |
|
3415 // Resume execution |
|
3416 User::LeaveIfError( test->TestExecution().Resume() ); |
|
3417 } |
|
3418 } |
|
3419 break; |
|
3420 |
|
3421 default: |
|
3422 // Should never come here |
|
3423 User::Leave( KErrGeneral ); |
|
3424 break; |
|
3425 } |
|
3426 |
|
3427 return continueTask; |
|
3428 |
|
3429 } |
|
3430 |
|
3431 |
|
3432 /* |
|
3433 ------------------------------------------------------------------------------- |
|
3434 |
|
3435 Class: CTestRunner |
|
3436 |
|
3437 Method: ExecuteCombinerPauseL |
|
3438 |
|
3439 Description: Executes causes pause in TestCombiner |
|
3440 |
|
3441 Parameters: CStifItemParser* aItem: in: script line |
|
3442 |
|
3443 Return Values: ETrue: continue script file execution |
|
3444 EFalse: stop script file execution |
|
3445 |
|
3446 Errors/Exceptions: Leaves on error situations. |
|
3447 |
|
3448 Status: Proposal |
|
3449 |
|
3450 ------------------------------------------------------------------------------- |
|
3451 */ |
|
3452 TBool CTestRunner::ExecuteCombinerPauseL( CStifItemParser* aItem ) |
|
3453 { |
|
3454 _LIT( KErrMsgPauseTimeoutNotDefined, "PauseCombiner : No timeout value given or value has invalid format" ); |
|
3455 _LIT( KErrMsgPauseTimeoutNotPositive, "PauseCombiner : Timeout value can't be <0" ); |
|
3456 |
|
3457 TBool continueTask = EFalse; |
|
3458 TInt pauseTime; |
|
3459 TInt ret = KErrNone; |
|
3460 |
|
3461 // Parse testid |
|
3462 ret = aItem->GetNextInt( pauseTime ); |
|
3463 if ( ret != KErrNone ) |
|
3464 { |
|
3465 iRunErrorMessage = KErrMsgPauseTimeoutNotDefined; |
|
3466 User::Leave( ret ); |
|
3467 } |
|
3468 |
|
3469 if( pauseTime < 0 ) |
|
3470 { |
|
3471 __TRACE( KError, (_L("CTestRunner::ExecuteCombinerPauseL: Given pause value < 0"))); |
|
3472 iRunErrorMessage = KErrMsgPauseTimeoutNotPositive; |
|
3473 User::Leave( KErrArgument ); |
|
3474 } |
|
3475 |
|
3476 |
|
3477 // Maximum time for one RTimer::After request |
|
3478 TInt maximumTime = KMaxTInt / 1000; |
|
3479 |
|
3480 // Check if pause value is suitable for RTimer::After |
|
3481 if(pauseTime < maximumTime) |
|
3482 { |
|
3483 iPauseCombTimer.After(iStatus, pauseTime * 1000); |
|
3484 iPauseCombRemainingTime = 0; |
|
3485 } |
|
3486 else |
|
3487 { |
|
3488 // Given pause value after multiplication with 1000 is |
|
3489 // larger than KMaxTInt, so we need to split it and |
|
3490 // re-request After with remaining value from RunL |
|
3491 |
|
3492 iPauseCombRemainingTime = pauseTime - maximumTime; |
|
3493 iPauseCombTimer.After(iStatus, maximumTime * 1000); |
|
3494 } |
|
3495 |
|
3496 SetActive(); |
|
3497 |
|
3498 __TRACE(KMessage, (_L("Executing pause, time=[%d]"), pauseTime)); |
|
3499 |
|
3500 iState = ERunnerRunning; |
|
3501 |
|
3502 return continueTask; |
|
3503 } |
|
3504 |
|
3505 /* |
|
3506 ------------------------------------------------------------------------------- |
|
3507 |
|
3508 Class: CTestRunner |
|
3509 |
|
3510 Method: ExecutePauseL |
|
3511 |
|
3512 Description: Executes pause line |
|
3513 |
|
3514 Parameters: CStifItemParser* aItem: in: script line |
|
3515 CTestCase* aTestcase: in: test case |
|
3516 |
|
3517 Return Values: ETrue: continue script file execution |
|
3518 EFalse: stop script file execution |
|
3519 |
|
3520 Errors/Exceptions: Leaves on error situations. |
|
3521 |
|
3522 Status: Approved |
|
3523 |
|
3524 ------------------------------------------------------------------------------- |
|
3525 */ |
|
3526 TBool CTestRunner::ExecutePauseL( CStifItemParser* aItem, |
|
3527 CTestCase* aTestcase ) |
|
3528 { |
|
3529 _LIT( KErrMsgPauseUnknownKeyword, "Pause : Unknown or illegal keyword %S" ); |
|
3530 _LIT( KErrMsgPauseTimeInvalidValue, "Pause : Pause time is not defined or has invalid value" ); |
|
3531 _LIT( KErrMsgPauseTimeNotPositive, "Pause : Pause time can't be <0" ); |
|
3532 TBool continueTask = ETrue; |
|
3533 |
|
3534 // Get optional pause arguments |
|
3535 TPtrC tmp; |
|
3536 iPauseTime = 0; |
|
3537 while( aItem->GetNextString( tmp ) == KErrNone ) |
|
3538 { |
|
3539 TPtrC val; |
|
3540 TPtrC arg; |
|
3541 ParseOptArgL( tmp, arg, val ); |
|
3542 CheckDefined( val ); |
|
3543 |
|
3544 // Parse optional argument |
|
3545 switch( TTCKeywords::Parse( arg, TTCKeywords::PauseOptArg ) ) |
|
3546 { |
|
3547 case TTCKeywords::ETime: |
|
3548 { |
|
3549 TLex ptr( val ); |
|
3550 TInt ret = KErrNone; |
|
3551 ret = ptr.Val( iPauseTime ); |
|
3552 if ( ret != KErrNone ) |
|
3553 { |
|
3554 iRunErrorMessage = KErrMsgPauseTimeInvalidValue; |
|
3555 User::Leave( ret ); |
|
3556 } |
|
3557 if ( iPauseTime < 0 ) |
|
3558 { |
|
3559 iRunErrorMessage = KErrMsgPauseTimeNotPositive; |
|
3560 User::Leave( KErrArgument ); |
|
3561 } |
|
3562 __TRACE( KMessage, (_L("time=%d"), iPauseTime )); |
|
3563 } |
|
3564 break; |
|
3565 default: |
|
3566 __TRACE( KError, (_L("Unknown or illegal keyword"))); |
|
3567 //Unknown or illegal keyword |
|
3568 iRunErrorMessage.Format( KErrMsgPauseUnknownKeyword, &arg ); |
|
3569 User::Leave( KErrGeneral ); |
|
3570 } |
|
3571 } |
|
3572 |
|
3573 // Store paused testcase id if timeout was given as pause argument |
|
3574 if( iPauseTime != 0 ) |
|
3575 { |
|
3576 iPausedTestCase.Copy( aTestcase->TestId() ); |
|
3577 } |
|
3578 |
|
3579 if( aTestcase->Type() == CTestCase::ECaseRemote ) |
|
3580 { |
|
3581 return ExecuteRemoteTestCtlL( aItem, aTestcase, TTCKeywords::EPause ); |
|
3582 } |
|
3583 if( aTestcase->State() != CTestCase::ETestCaseRunning ) |
|
3584 { |
|
3585 __TRACE( KMessage, (_L("Paused task (%S) not running (%i)"), |
|
3586 &aTestcase->TestId(), aTestcase->State() )); |
|
3587 User::Leave( KErrNotFound ); |
|
3588 } |
|
3589 CTCTestCase* test = ( CTCTestCase* )aTestcase; |
|
3590 |
|
3591 // Pause execution |
|
3592 User::LeaveIfError( test->TestExecution().Pause() ); |
|
3593 |
|
3594 // Resume paused case if timeout was given |
|
3595 if( iPauseTime != 0 ) |
|
3596 { |
|
3597 continueTask = EFalse; |
|
3598 iState = ERunnerWaitTimeout; |
|
3599 iPauseTimer.After( iStatus, iPauseTime*1000 ); |
|
3600 SetActive(); |
|
3601 } |
|
3602 |
|
3603 return continueTask; |
|
3604 } |
|
3605 |
|
3606 /* |
|
3607 ------------------------------------------------------------------------------- |
|
3608 |
|
3609 Class: CTestRunner |
|
3610 |
|
3611 Method: ExecuteCompleteL |
|
3612 |
|
3613 Description: Executes complete line |
|
3614 |
|
3615 Parameters: CStifItemParser* aItem: in: script line |
|
3616 CTestCase* aTestcase: in: test case |
|
3617 |
|
3618 Return Values: ETrue: continue script file execution |
|
3619 EFalse: stop script file execution |
|
3620 |
|
3621 Errors/Exceptions: Leaves on error situations. |
|
3622 |
|
3623 Status: Approved |
|
3624 |
|
3625 ------------------------------------------------------------------------------- |
|
3626 */ |
|
3627 TBool CTestRunner::ExecuteCompleteL( CStifItemParser* /* aItem */, |
|
3628 CTestCase* aTestcase ) |
|
3629 { |
|
3630 TBool ret = ETrue; |
|
3631 |
|
3632 if( aTestcase->State() == CTestCase::ETestCaseCompleted ) |
|
3633 { |
|
3634 // Requested testcase is completed already, |
|
3635 // proceed testcase execution |
|
3636 __TRACE( KMessage, (_L("Already completed"))); |
|
3637 } |
|
3638 else if( aTestcase->State() == CTCTestCase::ETestCaseRunning ) |
|
3639 { |
|
3640 // Wait testcase to complete |
|
3641 iTestCombiner->iWaitTestCase.Copy( aTestcase->TestId() ); |
|
3642 // Stop testcase execution until testcase completed |
|
3643 ret = EFalse; |
|
3644 iState = ERunnerWaitTestCase; |
|
3645 } |
|
3646 else |
|
3647 { |
|
3648 // This should newer happen |
|
3649 User::Leave( KErrGeneral ); |
|
3650 } |
|
3651 |
|
3652 return ret; |
|
3653 |
|
3654 } |
|
3655 |
|
3656 /* |
|
3657 ------------------------------------------------------------------------------- |
|
3658 |
|
3659 Class: CTestRunner |
|
3660 |
|
3661 Method: ExecuteEventSetL |
|
3662 |
|
3663 Description: Executes event set line |
|
3664 |
|
3665 Parameters: CStifItemParser* aItem: in: script line |
|
3666 |
|
3667 Return Values: ETrue: continue script file execution |
|
3668 EFalse: stop script file execution |
|
3669 |
|
3670 Errors/Exceptions: Leaves on error situations. |
|
3671 |
|
3672 Status: Approved |
|
3673 |
|
3674 ------------------------------------------------------------------------------- |
|
3675 */ |
|
3676 TBool CTestRunner::ExecuteEventSetL( CStifItemParser* aItem ) |
|
3677 { |
|
3678 _LIT( KErrMsgSetEventNameNotDefined, "Set : event name is not defined" ); |
|
3679 _LIT( KErrMsgSetUnknownOrIllegalKeyword, "Set :Unknown or illegal keyword %S" ); |
|
3680 _LIT( KErrMsgSetStateInvalidValue, "Set : State value is not defined or has invalid format" ); |
|
3681 TPtrC tmp; |
|
3682 TPtrC eventName; |
|
3683 TInt ret = KErrNone; |
|
3684 |
|
3685 // Get event name |
|
3686 ret = aItem->GetNextString( eventName ); |
|
3687 if( ret != KErrNone ) |
|
3688 { |
|
3689 iRunErrorMessage = KErrMsgSetEventNameNotDefined; |
|
3690 User::Leave( ret ); |
|
3691 } |
|
3692 __TRACE( KMessage, (_L("Set %S"), &eventName)); |
|
3693 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, KExecute, |
|
3694 _L("Set %S"), &eventName); |
|
3695 iEvent.SetName( eventName ); |
|
3696 iEvent.SetType( TEventIf::ESetEvent ); |
|
3697 |
|
3698 // Get optional set arguments |
|
3699 while( aItem->GetNextString( tmp ) == KErrNone ) |
|
3700 { |
|
3701 TPtrC val; |
|
3702 TPtrC arg; |
|
3703 ParseOptArgL( tmp, arg, val ); |
|
3704 CheckDefined( val ); |
|
3705 |
|
3706 // Parse optional set argument |
|
3707 switch( TTCKeywords::Parse( arg, TTCKeywords::EventOptArg ) ) |
|
3708 { |
|
3709 case TTCKeywords::EState: |
|
3710 { |
|
3711 TLex ptr( val ); |
|
3712 TInt tmpVal = 0; |
|
3713 ret = ptr.Val( tmpVal ); |
|
3714 if ( ret != KErrNone ) |
|
3715 { |
|
3716 iRunErrorMessage = KErrMsgSetStateInvalidValue; |
|
3717 User::Leave( ret ); |
|
3718 } |
|
3719 |
|
3720 // Only value 1 has special meaning, others are ignored |
|
3721 if( tmpVal == 1 ) |
|
3722 { |
|
3723 __TRACE( KMessage, (_L("State event"))); |
|
3724 iEvent.SetEventType( TEventIf::EState ); |
|
3725 } |
|
3726 } |
|
3727 break; |
|
3728 default: |
|
3729 __TRACE( KError, (_L("Unknown or illegal keyword"))); |
|
3730 //Unknown or illegal keyword |
|
3731 iRunErrorMessage.Format( KErrMsgSetUnknownOrIllegalKeyword, &arg ); |
|
3732 User::Leave( KErrGeneral ); |
|
3733 } |
|
3734 } |
|
3735 |
|
3736 // Set event |
|
3737 iTestCombiner->TestModuleIf().Event( iEvent, iStatus ); |
|
3738 iState = ERunnerRunning; |
|
3739 SetActive(); |
|
3740 |
|
3741 return EFalse; |
|
3742 |
|
3743 } |
|
3744 |
|
3745 /* |
|
3746 ------------------------------------------------------------------------------- |
|
3747 |
|
3748 Class: CTestRunner |
|
3749 |
|
3750 Method: ExecuteEventUnsetL |
|
3751 |
|
3752 Description: Executes event unset line |
|
3753 |
|
3754 Parameters: CStifItemParser* aItem: in: script line |
|
3755 |
|
3756 Return Values: ETrue: continue script file execution |
|
3757 EFalse: stop script file execution |
|
3758 |
|
3759 Errors/Exceptions: Leaves on error situations. |
|
3760 |
|
3761 Status: Approved |
|
3762 |
|
3763 ------------------------------------------------------------------------------- |
|
3764 */ |
|
3765 TBool CTestRunner::ExecuteEventUnsetL( CStifItemParser* aItem ) |
|
3766 { |
|
3767 _LIT( KErrMsgUnsetEventNameNotDefined, "Unset : Event name is not defined" ); |
|
3768 TPtrC eventName; |
|
3769 TInt ret = KErrNone; |
|
3770 // Get event name |
|
3771 ret = aItem->GetNextString( eventName ); |
|
3772 if ( ret != KErrNone ) |
|
3773 { |
|
3774 iRunErrorMessage = KErrMsgUnsetEventNameNotDefined; |
|
3775 User::Leave( ret ); |
|
3776 } |
|
3777 |
|
3778 __TRACE( KMessage, (_L("Unset %S"), &eventName)); |
|
3779 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, KExecute, |
|
3780 _L("Unset %S"), &eventName); |
|
3781 iEvent.Set( TEventIf::EUnsetEvent, eventName, TEventIf::EState ); |
|
3782 |
|
3783 // Check if trying to unset an event that is requested |
|
3784 // by testcombiner (otherwise testcombiner would deadlock) |
|
3785 TInt count = iTestCombiner->iEventArray.Count(); |
|
3786 TInt ind = 0; |
|
3787 for(; ind < count; ind++ ) |
|
3788 { |
|
3789 if( eventName == iTestCombiner->iEventArray[ind]->Name() ) |
|
3790 { |
|
3791 User::Leave( KErrInUse ); |
|
3792 } |
|
3793 } |
|
3794 |
|
3795 // Check if some testmodule below |
|
3796 // has event request pending |
|
3797 if( iTestCombiner->UnsetEvent( iEvent, |
|
3798 iStatus ) == EFalse ) |
|
3799 { |
|
3800 // If they haven't requested event, |
|
3801 // then check others above |
|
3802 iTestCombiner->TestModuleIf().Event( iEvent, iStatus ); |
|
3803 iState = ERunnerRunning; |
|
3804 SetActive(); |
|
3805 |
|
3806 } |
|
3807 else |
|
3808 { |
|
3809 // Some testmodule below has requested the event |
|
3810 // Wait unset to complete |
|
3811 SetActive(); |
|
3812 __TRACE( KPrint, ( _L("Unset: Start" ) ) ); |
|
3813 iState = ERunnerWaitUnset; |
|
3814 // Stop execution until unset has completed |
|
3815 } |
|
3816 return EFalse; |
|
3817 } |
|
3818 |
|
3819 /* |
|
3820 ------------------------------------------------------------------------------- |
|
3821 |
|
3822 Class: CTestRunner |
|
3823 |
|
3824 Method: ExecuteLineL |
|
3825 |
|
3826 Description: Executes script line |
|
3827 |
|
3828 Parameters: CStifItemParser* aItem: in: script line |
|
3829 TTCKeywords::TKeywords aKeyword: in: keyword index |
|
3830 |
|
3831 Return Values: ETrue: continue script file execution |
|
3832 EFalse: stop script file execution |
|
3833 |
|
3834 Errors/Exceptions: Leaves on error situations. |
|
3835 |
|
3836 Status: Approved |
|
3837 |
|
3838 ------------------------------------------------------------------------------- |
|
3839 */ |
|
3840 TBool CTestRunner::ExecuteEventCtlL( CStifItemParser* aItem, |
|
3841 TTCKeywords::TKeywords aKeyword ) |
|
3842 { |
|
3843 _LIT( KErrMsgEventNameNotDefined, "%S : Event name is not defined" ); |
|
3844 _LIT( KErrMsgEequestEventAlreadyExist, "Request : Requested event %S already exists" ); |
|
3845 _LIT( KErrMsgWaitEventNotRequested, "Wait :Waited event %S is not requested" ); |
|
3846 _LIT( KErrMsgReleaseEventNotRequested, "Release : Released event %S is not requested" ); |
|
3847 |
|
3848 TBool continueTask = ETrue; |
|
3849 TPtrC eventName; |
|
3850 TInt ret = KErrNone; |
|
3851 TPtrC keywordStr = TTCKeywords::Keyword( aKeyword ); |
|
3852 // Get event name |
|
3853 ret = aItem->GetNextString( eventName ); |
|
3854 if ( ret != KErrNone ) |
|
3855 { |
|
3856 iRunErrorMessage.Format( KErrMsgEventNameNotDefined, &keywordStr ); |
|
3857 User::Leave( ret ); |
|
3858 } |
|
3859 |
|
3860 TInt count = iTestCombiner->iEventArray.Count(); |
|
3861 TInt ind = 0; |
|
3862 for(; ind < count; ind++ ) |
|
3863 { |
|
3864 if( eventName == iTestCombiner->iEventArray[ind]->Name() ) |
|
3865 { |
|
3866 break; |
|
3867 } |
|
3868 } |
|
3869 |
|
3870 switch( aKeyword ) |
|
3871 { |
|
3872 case TTCKeywords::ERequest: |
|
3873 { |
|
3874 __TRACE( KMessage, (_L("Request %S"), &eventName)); |
|
3875 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, |
|
3876 KExecute, _L("Request %S"), &eventName); |
|
3877 |
|
3878 // Check that event is not already requested |
|
3879 if( ind < count ) |
|
3880 { |
|
3881 __TRACE( KError, (_L("Requested event %S already exists"), |
|
3882 &eventName)); |
|
3883 iRunErrorMessage.Format( KErrMsgEequestEventAlreadyExist, &eventName ); |
|
3884 User::Leave( KErrAlreadyExists ); |
|
3885 } |
|
3886 |
|
3887 // Add event to event array |
|
3888 iEvent.SetName( eventName ); |
|
3889 iEvent.SetType( TEventIf::EReqEvent ); |
|
3890 TEventTc* event = new (ELeave) TEventTc( iTestCombiner->iLog ); |
|
3891 CleanupStack::PushL( event ); |
|
3892 event->Copy( iEvent ); |
|
3893 User::LeaveIfError( iTestCombiner->iEventArray.Append( event )); |
|
3894 if( iTestCombiner->iLoopIsUsed ) |
|
3895 { |
|
3896 User::LeaveIfError( iTestCombiner->iLoopAllocationArray.Append( event ) ); |
|
3897 } |
|
3898 CleanupStack::Pop( event ); |
|
3899 |
|
3900 // Request event |
|
3901 iTestCombiner->TestModuleIf().Event( iEvent, iStatus ); |
|
3902 iState = ERunnerRunning; |
|
3903 SetActive(); |
|
3904 continueTask = EFalse; |
|
3905 } |
|
3906 break; |
|
3907 case TTCKeywords::EWait: |
|
3908 { |
|
3909 __TRACE( KMessage, (_L("Wait %S"), &eventName)); |
|
3910 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, KExecute, |
|
3911 _L("Wait %S"), &eventName); |
|
3912 |
|
3913 // Check that event is requested |
|
3914 if( ind == count ) |
|
3915 { |
|
3916 __TRACE( KError, (_L("Waited event %S is not requested"), |
|
3917 &eventName)); |
|
3918 iRunErrorMessage.Format( KErrMsgWaitEventNotRequested, &eventName ); |
|
3919 User::Leave( KErrNotFound ); |
|
3920 } |
|
3921 iEvent.SetName( eventName ); |
|
3922 iEvent.SetType( TEventIf::EWaitEvent ); |
|
3923 // Wait event |
|
3924 iTestCombiner->TestModuleIf().Event( iEvent, iStatus ); |
|
3925 iState = ERunnerRunning; |
|
3926 SetActive(); |
|
3927 continueTask = EFalse; |
|
3928 } |
|
3929 break; |
|
3930 case TTCKeywords::ERelease: |
|
3931 { |
|
3932 __TRACE( KMessage, (_L("Release %S"), &eventName)); |
|
3933 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, KExecute, |
|
3934 _L("Release %S"), &eventName); |
|
3935 // Check that event is requested |
|
3936 if( ind == count ) |
|
3937 { |
|
3938 __TRACE( KError, (_L("Released event %S is not requested"), |
|
3939 &eventName)); |
|
3940 iRunErrorMessage.Format( KErrMsgReleaseEventNotRequested, &eventName ); |
|
3941 User::Leave( KErrNotFound ); |
|
3942 } |
|
3943 // Remove event from array |
|
3944 TEventTc* event = iTestCombiner->iEventArray[ind]; |
|
3945 iTestCombiner->iEventArray.Remove( ind ); |
|
3946 delete event; |
|
3947 iEvent.SetName( eventName ); |
|
3948 iEvent.SetType( TEventIf::ERelEvent ); |
|
3949 |
|
3950 // Release event |
|
3951 iTestCombiner->TestModuleIf().Event( iEvent, iStatus ); |
|
3952 iState = ERunnerRunning; |
|
3953 SetActive(); |
|
3954 continueTask = EFalse; |
|
3955 } |
|
3956 break; |
|
3957 default: |
|
3958 { |
|
3959 __TRACE( KError, (_L("Illegal keyword") ) ); |
|
3960 |
|
3961 // Unknown or illegal keyword |
|
3962 User::Leave( KErrGeneral ); |
|
3963 } |
|
3964 break; |
|
3965 |
|
3966 } |
|
3967 return continueTask; |
|
3968 } |
|
3969 |
|
3970 /* |
|
3971 ------------------------------------------------------------------------------- |
|
3972 |
|
3973 Class: CTestRunner |
|
3974 |
|
3975 Method: ExecuteAllocateL |
|
3976 |
|
3977 Description: Executes allocate line |
|
3978 |
|
3979 Parameters: CStifItemParser* aItem: in: script line |
|
3980 |
|
3981 Return Values: ETrue: continue script file execution |
|
3982 EFalse: stop script file execution |
|
3983 |
|
3984 Errors/Exceptions: Leaves on error situations. |
|
3985 |
|
3986 Status: Draft |
|
3987 |
|
3988 ------------------------------------------------------------------------------- |
|
3989 */ |
|
3990 TBool CTestRunner::ExecuteAllocateL( CStifItemParser* aItem ) |
|
3991 { |
|
3992 _LIT( KErrMsgAllocateSlaveTypeNotDefined, "Allocate : Slave type was not given for allocate" ); |
|
3993 _LIT( KErrMsgAllocateSlaveNameNotDefined, "Allocate : Slave name is not defined" ); |
|
3994 _LIT( KErrMsgAllocateSlaveAlreadyAllocated, "Allocate : Slave with name %S already allocated" ); |
|
3995 __TRACE( KMessage, (_L("Allocate"))); |
|
3996 |
|
3997 TPtrC type; |
|
3998 TPtrC name; |
|
3999 // Get slave type |
|
4000 TInt ret = aItem->GetNextString( type ); |
|
4001 if( ret != KErrNone ) |
|
4002 { |
|
4003 __TRACE( KError, (_L("Slave type was not given for allocate"))); |
|
4004 iRunErrorMessage = KErrMsgAllocateSlaveTypeNotDefined; |
|
4005 User::Leave( KErrArgument ); |
|
4006 } |
|
4007 |
|
4008 // Get slave name |
|
4009 ret = aItem->GetNextString( name ); |
|
4010 if( ret != KErrNone ) |
|
4011 { |
|
4012 __TRACE( KError, (_L("Slave name was not given for allocate"))); |
|
4013 iRunErrorMessage = KErrMsgAllocateSlaveNameNotDefined; |
|
4014 User::Leave( KErrArgument ); |
|
4015 } |
|
4016 |
|
4017 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, KExecute, |
|
4018 _L("Allocate %S"), &name ); |
|
4019 |
|
4020 __TRACE( KMessage, (_L("Allocate %S [name: %S]"), &type, &name)); |
|
4021 |
|
4022 if( iTestCombiner->GetSlave( name ) ) |
|
4023 { |
|
4024 __TRACE( KError, (_L("Slave with name %S already allocated"), |
|
4025 &name ) ); |
|
4026 iRunErrorMessage.Format( KErrMsgAllocateSlaveAlreadyAllocated, &name ); |
|
4027 User::Leave( KErrAlreadyExists ); |
|
4028 } |
|
4029 |
|
4030 CSlaveInfo* slave = CSlaveInfo::NewL( name, KRemoteProtocolMasterId ); |
|
4031 CleanupStack::PushL( slave ); |
|
4032 User::LeaveIfError( iTestCombiner->iSlaveArray.Append( slave ) ); |
|
4033 if( iTestCombiner->iLoopIsUsed ) |
|
4034 { |
|
4035 User::LeaveIfError( iTestCombiner->iLoopAllocationArray.Append( slave ) ); |
|
4036 } |
|
4037 CleanupStack::Pop( slave ); |
|
4038 |
|
4039 CStifTFwIfProt* req = CStifTFwIfProt::NewL(); |
|
4040 CleanupStack::PushL( req ); |
|
4041 req->CreateL(); |
|
4042 |
|
4043 // Reserve message |
|
4044 User::LeaveIfError( |
|
4045 req->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgReserve ) ); |
|
4046 // Srcid. i.e. master id |
|
4047 User::LeaveIfError( |
|
4048 req->AppendId( slave->iMasterId ) ); |
|
4049 // DstId, broacast id |
|
4050 User::LeaveIfError( |
|
4051 req->AppendId( slave->iSlaveDevId ) ); |
|
4052 // Slave type |
|
4053 User::LeaveIfError( req->Append( type ) ); |
|
4054 |
|
4055 User::LeaveIfError( |
|
4056 iTestCombiner->TestModuleIf().RemoteSend( req->Message() ) ); |
|
4057 |
|
4058 iState = ERunnerAllocate; |
|
4059 slave->iState = CSlaveInfo::ESlaveReserveSent; |
|
4060 |
|
4061 // Start timer |
|
4062 iRemoteTimer->SetTimerActive( iTestCombiner->iRemoteTimeout ); |
|
4063 |
|
4064 CleanupStack::PopAndDestroy( req ); |
|
4065 |
|
4066 return EFalse; |
|
4067 |
|
4068 } |
|
4069 |
|
4070 /* |
|
4071 ------------------------------------------------------------------------------- |
|
4072 |
|
4073 Class: CTestRunner |
|
4074 |
|
4075 Method: ExecuteFreeL |
|
4076 |
|
4077 Description: Executes free line |
|
4078 |
|
4079 Parameters: CStifItemParser* aItem: in: script line |
|
4080 |
|
4081 Return Values: ETrue: continue script file execution |
|
4082 EFalse: stop script file execution |
|
4083 |
|
4084 Errors/Exceptions: Leaves on error situations. |
|
4085 |
|
4086 Status: Draft |
|
4087 |
|
4088 ------------------------------------------------------------------------------- |
|
4089 */ |
|
4090 TBool CTestRunner::ExecuteFreeL( CStifItemParser* aItem ) |
|
4091 { |
|
4092 _LIT( KErrMsgFreeSlaveNameNotDefined, "Free : Slave name is not defined" ); |
|
4093 _LIT( KErrMsgFreeSlaveNotFound, "Free : Slave %S not found" ); |
|
4094 _LIT( KErrMsgFreeSlaveReserved, "Free : Slave %S in illegal state %d, cannot be released" ); |
|
4095 __TRACE( KMessage, (_L("Free"))); |
|
4096 |
|
4097 TPtrC name; |
|
4098 // Get slave name |
|
4099 TInt ret = aItem->GetNextString( name ); |
|
4100 if( ret != KErrNone ) |
|
4101 { |
|
4102 __TRACE( KError, (_L("Slave name was not given for free"))); |
|
4103 iRunErrorMessage = KErrMsgFreeSlaveNameNotDefined; |
|
4104 User::Leave( KErrArgument ); |
|
4105 } |
|
4106 |
|
4107 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, KExecute, |
|
4108 _L("Free %S"), &name ); |
|
4109 |
|
4110 __TRACE( KMessage, (_L("Free %S"), &name ) ); |
|
4111 |
|
4112 CSlaveInfo* slave = iTestCombiner->GetSlave( name ); |
|
4113 if( slave == NULL ) |
|
4114 { |
|
4115 __TRACE( KError, (_L("Slave %S not found"), &name )); |
|
4116 iRunErrorMessage.Format( KErrMsgFreeSlaveNotFound, &name ); |
|
4117 User::Leave( KErrNotFound ); |
|
4118 } |
|
4119 if( slave->iState != CSlaveInfo::ESlaveReserved ) |
|
4120 { |
|
4121 __TRACE( KError, (_L("Slave %S in illegal state %d, cannot be released"), |
|
4122 &name, slave->iState )); |
|
4123 iRunErrorMessage.Format( KErrMsgFreeSlaveReserved, &name, slave->iState ); |
|
4124 User::Leave( KErrGeneral ); |
|
4125 } |
|
4126 |
|
4127 ExecuteFreeL( slave ); |
|
4128 |
|
4129 return EFalse; |
|
4130 |
|
4131 } |
|
4132 |
|
4133 /* |
|
4134 ------------------------------------------------------------------------------- |
|
4135 |
|
4136 Class: CTestRunner |
|
4137 |
|
4138 Method: ExecuteFreeL |
|
4139 |
|
4140 Description: Executes free line |
|
4141 |
|
4142 Parameters: CSlaveInfo* aSlave: in: slave info |
|
4143 |
|
4144 Return Values: None |
|
4145 |
|
4146 Errors/Exceptions: Leaves on error situations. |
|
4147 |
|
4148 Status: Draft |
|
4149 |
|
4150 ------------------------------------------------------------------------------- |
|
4151 */ |
|
4152 void CTestRunner::ExecuteFreeL( CSlaveInfo* aSlave ) |
|
4153 { |
|
4154 |
|
4155 CRemoteTestCase* testCase = |
|
4156 iTestCombiner->GetRemoteRunningTestOnSlave( aSlave->iSlaveDevId ); |
|
4157 |
|
4158 if( testCase ) |
|
4159 { |
|
4160 __TRACE( KMessage, |
|
4161 (_L("Postpone free until testcases completed"))); |
|
4162 // Test cases still running on slave, |
|
4163 // Free slave after test case has completed |
|
4164 testCase->iFreeSlave = ETrue; |
|
4165 return; |
|
4166 } |
|
4167 |
|
4168 CStifTFwIfProt* req = CStifTFwIfProt::NewL(); |
|
4169 CleanupStack::PushL( req ); |
|
4170 req->CreateL(); |
|
4171 |
|
4172 // Release message |
|
4173 User::LeaveIfError( |
|
4174 req->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRelease ) ); |
|
4175 // Srcid. i.e. master id |
|
4176 User::LeaveIfError( |
|
4177 req->AppendId( aSlave->iMasterId ) ); |
|
4178 // DstId is device broadcast |
|
4179 User::LeaveIfError( |
|
4180 req->AppendId( SETID( DEVID( aSlave->iSlaveDevId ), 0 ) ) ); |
|
4181 |
|
4182 User::LeaveIfError( |
|
4183 iTestCombiner->TestModuleIf().RemoteSend( req->Message() ) ); |
|
4184 |
|
4185 iState = ERunnerFree; |
|
4186 aSlave->iState = CSlaveInfo::ESlaveReleaseSent; |
|
4187 |
|
4188 // Start timer |
|
4189 iRemoteTimer->SetTimerActive( iTestCombiner->iRemoteTimeout ); |
|
4190 |
|
4191 CleanupStack::PopAndDestroy( req ); |
|
4192 |
|
4193 } |
|
4194 |
|
4195 /* |
|
4196 ------------------------------------------------------------------------------- |
|
4197 |
|
4198 Class: CTestRunner |
|
4199 |
|
4200 Method: ExecuteRemoteL |
|
4201 |
|
4202 Description: Executes remote line |
|
4203 |
|
4204 Parameters: CStifItemParser* aItem: in: script line |
|
4205 |
|
4206 Return Values: ETrue: continue script file execution |
|
4207 EFalse: stop script file execution |
|
4208 |
|
4209 Errors/Exceptions: Leaves on error situations. |
|
4210 |
|
4211 Status: Draft |
|
4212 |
|
4213 ------------------------------------------------------------------------------- |
|
4214 */ |
|
4215 TBool CTestRunner::ExecuteRemoteL( CStifItemParser* aItem ) |
|
4216 { |
|
4217 _LIT( KErrMsgRemoteSlaveNameNotDefined, "Remote : Slave name is not defined" ); |
|
4218 _LIT( KErrMsgRemoteSlaveNotFound, "Remore : Slave %S not found" ); |
|
4219 _LIT( KErrMsgRemoteIllegalState, "Remote : Slave %S in illegal state %d, cannot send remote call" ); |
|
4220 _LIT( KErrMsgRemoteCommandNotDefined, "Slave command name was not given for remote" ); |
|
4221 TPtrC name; |
|
4222 TPtrC command; |
|
4223 // Get slave name |
|
4224 TInt ret = aItem->GetNextString( name ); |
|
4225 if( ret != KErrNone ) |
|
4226 { |
|
4227 __TRACE( KError, (_L("Slave name was not given for remote"))); |
|
4228 iRunErrorMessage = KErrMsgRemoteSlaveNameNotDefined; |
|
4229 User::Leave( KErrArgument ); |
|
4230 } |
|
4231 |
|
4232 __TRACE( KMessage, (_L("Remote command to %S"), &name)); |
|
4233 |
|
4234 CSlaveInfo* slave = iTestCombiner->GetSlave( name ); |
|
4235 if( slave == NULL ) |
|
4236 { |
|
4237 __TRACE( KError, (_L("Slave %S not found"), &name )); |
|
4238 iRunErrorMessage.Format( KErrMsgRemoteSlaveNotFound, &name ); |
|
4239 User::Leave( KErrArgument ); |
|
4240 } |
|
4241 if( slave->iState != CSlaveInfo::ESlaveReserved ) |
|
4242 { |
|
4243 __TRACE( KError, (_L("Slave %S in illegal state %d, cannot send remote call"), |
|
4244 &name, slave->iState )); |
|
4245 iRunErrorMessage.Format( KErrMsgRemoteIllegalState, &name, slave->iState ); |
|
4246 User::Leave( KErrNotReady ); |
|
4247 } |
|
4248 |
|
4249 // Get remote command name |
|
4250 ret = aItem->GetNextString( command ); |
|
4251 if( ret != KErrNone ) |
|
4252 { |
|
4253 __TRACE( KError, (_L("Slave command name was not given for remote"))); |
|
4254 iRunErrorMessage = KErrMsgRemoteCommandNotDefined; |
|
4255 User::Leave( KErrArgument ); |
|
4256 } |
|
4257 |
|
4258 iTestCombiner->TestModuleIf().Printf( KPrintPriExec, KExecute, |
|
4259 _L("remote %S %S"), &name, &command ); |
|
4260 |
|
4261 __TRACE( KPrint, (_L("remote %S %S"), &name, &command ) ); |
|
4262 |
|
4263 // Parse command name |
|
4264 TInt key = TTCKeywords::Parse( command, TTCKeywords::Keyword ); |
|
4265 TBool continueTask = ETrue; |
|
4266 |
|
4267 switch( key ) |
|
4268 { |
|
4269 // Test case starting |
|
4270 case TTCKeywords::ERun: |
|
4271 continueTask = ExecuteRemoteRunL( aItem, slave ); |
|
4272 break; |
|
4273 |
|
4274 // Event control cases |
|
4275 case TTCKeywords::ERequest: |
|
4276 case TTCKeywords::EWait: |
|
4277 case TTCKeywords::ERelease: |
|
4278 continueTask = ExecuteRemoteEventCtlL( aItem, slave, key ); |
|
4279 break; |
|
4280 |
|
4281 case TTCKeywords::ESet: |
|
4282 case TTCKeywords::EUnset: |
|
4283 continueTask = ExecuteRemoteSetUnsetEventL(aItem, slave, key); |
|
4284 break; |
|
4285 // asynchronous 'sendreceive' |
|
4286 case TTCKeywords::ESendReceive: |
|
4287 continueTask = ExecuteRemoteSendReceiveL( aItem, slave ); |
|
4288 break; |
|
4289 |
|
4290 default: |
|
4291 // Some unknown remote command, forward as such |
|
4292 continueTask = ExecuteRemoteUnknownL( aItem, slave, command ); |
|
4293 break; |
|
4294 } |
|
4295 |
|
4296 return continueTask; |
|
4297 |
|
4298 } |
|
4299 |
|
4300 /* |
|
4301 ------------------------------------------------------------------------------- |
|
4302 |
|
4303 Class: CTestRunner |
|
4304 |
|
4305 Method: ExecuteRemoteRunL |
|
4306 |
|
4307 Description: Handles remote run |
|
4308 |
|
4309 Parameters: CStifItemParser* aItem: in: script line |
|
4310 CSlaveInfo* aSlave: in: slave info |
|
4311 HBufC *aSetUnsetEvent: in: data needed for startInfo |
|
4312 TInt aCaseNumber: in: data needed for startInfo |
|
4313 |
|
4314 Return Values: ETrue: continue script file execution |
|
4315 EFalse: stop script file execution and wait response |
|
4316 |
|
4317 Errors/Exceptions: Leaves on error situations. |
|
4318 |
|
4319 Status: Draft |
|
4320 |
|
4321 ------------------------------------------------------------------------------- |
|
4322 */ |
|
4323 TBool CTestRunner::ExecuteRemoteRunL( CStifItemParser* aItem, |
|
4324 CSlaveInfo* aSlave, |
|
4325 HBufC *aSetUnsetEvent, |
|
4326 TInt aCaseNumber ) |
|
4327 { |
|
4328 |
|
4329 CStifTFwIfProt* req = CStifTFwIfProt::NewL(); |
|
4330 CleanupStack::PushL( req ); |
|
4331 req->CreateL(); |
|
4332 |
|
4333 CStartInfo* startInfo = CStartInfo::NewL(); |
|
4334 CleanupStack::PushL( startInfo ); |
|
4335 //if aSetUnsetEvent is given, then get start info from this argument |
|
4336 if(aSetUnsetEvent != NULL) |
|
4337 { |
|
4338 TBuf<10> tmpModuleName; |
|
4339 tmpModuleName.Copy(_L("suevent")); |
|
4340 startInfo->SetModuleNameL(tmpModuleName); |
|
4341 startInfo->SetConfigL(*aSetUnsetEvent); |
|
4342 startInfo->iCaseNum = aCaseNumber; |
|
4343 } |
|
4344 else |
|
4345 { |
|
4346 ParseRunParamsL( aItem, *startInfo ); |
|
4347 } |
|
4348 |
|
4349 if( iTestCombiner->GetTest( startInfo->iTestId ) ) |
|
4350 { |
|
4351 /* |
|
4352 __TRACE( KError, (_L("´Slave test running already with testid %S"), |
|
4353 &startInfo->iTestId ) ); |
|
4354 */ |
|
4355 User::Leave( KErrAlreadyExists ); |
|
4356 } |
|
4357 |
|
4358 CRemoteTestCase* remote = |
|
4359 CRemoteTestCase::NewL( iTestCombiner, |
|
4360 startInfo->iTestId, |
|
4361 startInfo->iExpectedResult, |
|
4362 startInfo->iCategory ); |
|
4363 |
|
4364 CleanupStack::PushL( remote ); |
|
4365 |
|
4366 // Remote message |
|
4367 User::LeaveIfError( |
|
4368 req->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); |
|
4369 // Srcid. i.e. master id |
|
4370 User::LeaveIfError( req->AppendId( aSlave->iMasterId ) ); |
|
4371 // DstId is device broadcast |
|
4372 User::LeaveIfError( |
|
4373 req->AppendId( SETID( DEVID( aSlave->iSlaveDevId ), 0 ) ) ); |
|
4374 // Run command |
|
4375 User::LeaveIfError( |
|
4376 req->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRun ) ); |
|
4377 // Run parameters |
|
4378 User::LeaveIfError( |
|
4379 req->Append( CStifTFwIfProt::RunParams, |
|
4380 CStifTFwIfProt::ERunModule, |
|
4381 startInfo->iModule ) ); |
|
4382 User::LeaveIfError( |
|
4383 req->Append( CStifTFwIfProt::RunParams, |
|
4384 CStifTFwIfProt::ERunTestcasenum, |
|
4385 startInfo->iCaseNum )); |
|
4386 if( startInfo->iIniFile.Length() > 0 ) |
|
4387 { |
|
4388 // Initialization file |
|
4389 __TRACE( KMessage, (_L("ini: %S"), &startInfo->iIniFile )); |
|
4390 User::LeaveIfError( |
|
4391 req->Append( CStifTFwIfProt::RunParams, |
|
4392 CStifTFwIfProt::ERunInifile, |
|
4393 startInfo->iIniFile ) ); |
|
4394 } |
|
4395 if( startInfo->iConfig.Length() > 0 ) |
|
4396 { |
|
4397 // Initialization file |
|
4398 __TRACE( KMessage, (_L("config: %S"), &startInfo->iConfig )); |
|
4399 User::LeaveIfError( |
|
4400 req->Append( CStifTFwIfProt::RunParams, |
|
4401 CStifTFwIfProt::ERunTestcasefile, |
|
4402 startInfo->iConfig )); |
|
4403 } |
|
4404 //Title (must be given between quotation marks in case of any spaces inside |
|
4405 if( startInfo->iTitle.Length() > 0 ) |
|
4406 { |
|
4407 __TRACE(KMessage, (_L("title: %S"), &startInfo->iTitle)); |
|
4408 TName tit; |
|
4409 tit.Format(_L("\"title=%S\""), &startInfo->iTitle); |
|
4410 User::LeaveIfError(req->Append(tit)); |
|
4411 } |
|
4412 |
|
4413 User::LeaveIfError( |
|
4414 iTestCombiner->TestModuleIf().RemoteSend( req->Message() ) ); |
|
4415 |
|
4416 remote->iRemoteState = CRemoteTestCase::ECaseRunSent; |
|
4417 remote->iSlaveId = aSlave->iSlaveDevId; |
|
4418 remote->StartL(); |
|
4419 User::LeaveIfError( iTestCombiner->iTestCases.Append( remote ) ); |
|
4420 if( iTestCombiner->iLoopIsUsed ) |
|
4421 { |
|
4422 User::LeaveIfError( iTestCombiner->iLoopAllocationArray.Append( remote ) ); |
|
4423 } |
|
4424 CleanupStack::Pop( remote ); |
|
4425 |
|
4426 CleanupStack::PopAndDestroy( startInfo ); |
|
4427 |
|
4428 iTestCombiner->iRunningTests++; |
|
4429 |
|
4430 // Start timer |
|
4431 iRemoteTimer->SetTimerActive( iTestCombiner->iRemoteTimeout ); |
|
4432 |
|
4433 iState = ERunnerRemote; |
|
4434 |
|
4435 CleanupStack::PopAndDestroy( req ); |
|
4436 |
|
4437 return EFalse; |
|
4438 |
|
4439 } |
|
4440 |
|
4441 |
|
4442 /* |
|
4443 ------------------------------------------------------------------------------- |
|
4444 |
|
4445 Class: CTestRunner |
|
4446 |
|
4447 Method: ExecuteRemoteTestCtlL |
|
4448 |
|
4449 Description: Handles remote testcase controlling |
|
4450 |
|
4451 Parameters: CStifItemParser* aItem: in: script line |
|
4452 CTestCase* aTestCase: in: test case |
|
4453 TInt aCmd: in: remote command |
|
4454 |
|
4455 Return Values: ETrue: continue script file execution |
|
4456 EFalse: stop script file execution and wait response |
|
4457 |
|
4458 Errors/Exceptions: Leaves on error situations. |
|
4459 |
|
4460 Status: Draft |
|
4461 |
|
4462 ------------------------------------------------------------------------------- |
|
4463 */ |
|
4464 TBool CTestRunner::ExecuteRemoteTestCtlL( CStifItemParser* /* aItem */, |
|
4465 CTestCase* aTestCase, |
|
4466 TInt aCmd ) |
|
4467 { |
|
4468 |
|
4469 CRemoteTestCase* caseInfo = ( CRemoteTestCase* ) aTestCase; |
|
4470 |
|
4471 CStifTFwIfProt* req = CStifTFwIfProt::NewL(); |
|
4472 CleanupStack::PushL( req ); |
|
4473 req->CreateL(); |
|
4474 // Remote message |
|
4475 User::LeaveIfError( |
|
4476 req->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); |
|
4477 // Srcid. i.e. master id |
|
4478 //req->AppendId( ( TUint32 ) this ); |
|
4479 User::LeaveIfError( |
|
4480 req->AppendId( KRemoteProtocolMasterId )); |
|
4481 // DstId, i.e.slave id |
|
4482 User::LeaveIfError( |
|
4483 req->AppendId( caseInfo->iSlaveId )); |
|
4484 |
|
4485 switch( aCmd ) |
|
4486 { |
|
4487 case TTCKeywords::EPause: |
|
4488 if( caseInfo->iRemoteState != CRemoteTestCase::ECaseRunning ) |
|
4489 { |
|
4490 __TRACE( KError, (_L("Test case with testid %S not running"), |
|
4491 &aTestCase->TestId() )); |
|
4492 User::Leave( KErrGeneral ); |
|
4493 } |
|
4494 // Pause command |
|
4495 User::LeaveIfError( |
|
4496 req->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdPause ) ); |
|
4497 caseInfo->iRemoteState = CRemoteTestCase::ECasePauseSent; |
|
4498 break; |
|
4499 case TTCKeywords::EResume: |
|
4500 if( caseInfo->iRemoteState != CRemoteTestCase::ECasePaused ) |
|
4501 { |
|
4502 __TRACE( KError, (_L("Test case with testid %S not paused"), |
|
4503 &aTestCase->TestId() )); |
|
4504 User::Leave( KErrGeneral ); |
|
4505 } |
|
4506 // Resume command |
|
4507 User::LeaveIfError( |
|
4508 req->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdResume )); |
|
4509 caseInfo->iRemoteState = CRemoteTestCase::ECaseResumeSent; |
|
4510 break; |
|
4511 case TTCKeywords::ECancel: |
|
4512 if( ( caseInfo->iRemoteState != CRemoteTestCase::ECaseRunning ) && |
|
4513 ( caseInfo->iRemoteState != CRemoteTestCase::ECasePaused ) ) |
|
4514 { |
|
4515 __TRACE( KError, (_L("Test case with testid %S not running"), |
|
4516 &aTestCase->TestId() )); |
|
4517 User::Leave( KErrGeneral ); |
|
4518 } |
|
4519 // Cancel command |
|
4520 User::LeaveIfError( |
|
4521 req->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdCancel )); |
|
4522 caseInfo->iRemoteState = CRemoteTestCase::ECaseCancelSent; |
|
4523 break; |
|
4524 case TTCKeywords::EComplete: |
|
4525 if( caseInfo->iRemoteState == CRemoteTestCase::ECaseCompleted ) |
|
4526 { |
|
4527 __TRACE( KError, (_L("Test case with testid %S already completed"), |
|
4528 &aTestCase->TestId() )); |
|
4529 CleanupStack::PopAndDestroy( req ); |
|
4530 return ETrue; |
|
4531 } |
|
4532 else |
|
4533 { |
|
4534 iTestCombiner->iWaitTestCase = aTestCase->TestId(); |
|
4535 CleanupStack::PopAndDestroy( req ); |
|
4536 return EFalse; |
|
4537 } |
|
4538 default: |
|
4539 // Should never come here |
|
4540 User::Leave( KErrGeneral ); |
|
4541 } |
|
4542 |
|
4543 User::LeaveIfError( |
|
4544 iTestCombiner->TestModuleIf().RemoteSend( req->Message() ) ); |
|
4545 |
|
4546 // Start timer |
|
4547 iRemoteTimer->SetTimerActive( iTestCombiner->iRemoteTimeout ); |
|
4548 |
|
4549 iState = ERunnerRemote; |
|
4550 |
|
4551 CleanupStack::PopAndDestroy( req ); |
|
4552 |
|
4553 return EFalse; |
|
4554 |
|
4555 } |
|
4556 |
|
4557 /* |
|
4558 ------------------------------------------------------------------------------- |
|
4559 |
|
4560 Class: CTestRunner |
|
4561 |
|
4562 Method: ExecuteRemoteEventCtlL |
|
4563 |
|
4564 Description: Handles remote event controlling |
|
4565 |
|
4566 Parameters: CStifItemParser* aItem: in: script line |
|
4567 CSlaveInfo* aSlave: in: slave info |
|
4568 TInt aCmd: in: remote command |
|
4569 |
|
4570 Return Values: ETrue: continue script file execution |
|
4571 EFalse: stop script file execution and wait response |
|
4572 |
|
4573 Errors/Exceptions: Leaves on error situations. |
|
4574 |
|
4575 Status: Draft |
|
4576 |
|
4577 ------------------------------------------------------------------------------- |
|
4578 */ |
|
4579 TBool CTestRunner::ExecuteRemoteEventCtlL( CStifItemParser* aItem, |
|
4580 CSlaveInfo* aSlave, |
|
4581 TInt aCmd ) |
|
4582 { |
|
4583 |
|
4584 TPtrC eventName; |
|
4585 // Get event name |
|
4586 TInt ret = aItem->GetNextString( eventName ); |
|
4587 if( ret != KErrNone ) |
|
4588 { |
|
4589 __TRACE( KError, (_L("Event name was not given for remote"))); |
|
4590 User::Leave( KErrArgument ); |
|
4591 } |
|
4592 |
|
4593 if( aCmd == TTCKeywords::EWait ) |
|
4594 { |
|
4595 TEventTc* event = aSlave->GetEvent( eventName ); |
|
4596 if( event == NULL ) |
|
4597 { |
|
4598 __TRACE( KError, (_L("Waited event %S not requested"), |
|
4599 &eventName ) ); |
|
4600 User::Leave( KErrNotFound ); |
|
4601 } |
|
4602 iState = ERunnerRunning; |
|
4603 SetActive(); |
|
4604 event->WaitEvent( iStatus ); |
|
4605 // Execution continue if waited event is set or after it is set |
|
4606 return EFalse; |
|
4607 } |
|
4608 |
|
4609 CStifTFwIfProt* req = CStifTFwIfProt::NewL(); |
|
4610 CleanupStack::PushL( req ); |
|
4611 |
|
4612 req->CreateL(); |
|
4613 // Remote message |
|
4614 User::LeaveIfError( |
|
4615 req->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote )); |
|
4616 // Srcid. i.e. master id |
|
4617 User::LeaveIfError( req->AppendId( aSlave->iMasterId ) ); |
|
4618 // DstId, i.e.slave device id |
|
4619 User::LeaveIfError( req->AppendId( aSlave->iSlaveDevId ) ); |
|
4620 |
|
4621 switch( aCmd ) |
|
4622 { |
|
4623 // Event control cases |
|
4624 case TTCKeywords::ERequest: |
|
4625 { |
|
4626 TEventTc* event = aSlave->GetEvent( eventName ); |
|
4627 if( event != NULL ) |
|
4628 { |
|
4629 __TRACE( KError, (_L("Event %S already requested"), |
|
4630 &eventName ) ); |
|
4631 User::Leave( KErrNotFound ); |
|
4632 } |
|
4633 event = new( ELeave ) TEventTc( (TName&)eventName, |
|
4634 iTestCombiner->iLog ); |
|
4635 CleanupStack::PushL( event ); |
|
4636 User::LeaveIfError( aSlave->iEvents.Append( event ) ); |
|
4637 CleanupStack::Pop( event ); |
|
4638 // Request event |
|
4639 User::LeaveIfError( |
|
4640 req->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRequest )); |
|
4641 } |
|
4642 break; |
|
4643 |
|
4644 case TTCKeywords::ERelease: |
|
4645 { |
|
4646 TEventIf* event = NULL; |
|
4647 TInt count = aSlave->iEvents.Count(); |
|
4648 TInt i = 0; |
|
4649 for( ; i < count; i++ ) |
|
4650 { |
|
4651 if( aSlave->iEvents[i]->Name() == eventName ) |
|
4652 { |
|
4653 event = aSlave->iEvents[i]; |
|
4654 break; |
|
4655 } |
|
4656 } |
|
4657 if( event == NULL ) |
|
4658 { |
|
4659 __TRACE( KError, (_L("Event not found %S"), |
|
4660 &eventName ) ); |
|
4661 User::Leave( KErrNotFound ); |
|
4662 } |
|
4663 |
|
4664 aSlave->iEvents.Remove(i); |
|
4665 delete event; |
|
4666 // Release event |
|
4667 User::LeaveIfError( |
|
4668 req->Append( CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdRelease )); |
|
4669 } |
|
4670 break; |
|
4671 |
|
4672 case TTCKeywords::ESet: |
|
4673 { |
|
4674 __TRACE( KPrint, (_L("JIRA51 CTestRunner::ExecuteRemoteEventCtlL case ESet"))); |
|
4675 User::LeaveIfError(req->Append(CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdSetEvent)); |
|
4676 break; |
|
4677 } |
|
4678 case TTCKeywords::EUnset: |
|
4679 { |
|
4680 __TRACE( KPrint, (_L("JIRA51 CTestRunner::ExecuteRemoteEventCtlL case EUnset"))); |
|
4681 User::LeaveIfError(req->Append(CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdUnsetEvent)); |
|
4682 break; |
|
4683 } |
|
4684 default: |
|
4685 // Should never come here |
|
4686 User::Leave( KErrGeneral ); |
|
4687 } |
|
4688 |
|
4689 // Event name |
|
4690 User::LeaveIfError( req->Append( eventName ) ); |
|
4691 |
|
4692 if(aCmd == TTCKeywords::ESet) |
|
4693 { |
|
4694 TPtrC stateEvent; |
|
4695 TInt ret = aItem->GetNextString(stateEvent); |
|
4696 if(ret == KErrNotFound) //indication event - add indicate keyword to message |
|
4697 { |
|
4698 User::LeaveIfError(req->Append(CStifTFwIfProt::EventType, TEventIf::EIndication)); |
|
4699 } |
|
4700 else if(ret == KErrNone) //possibly state event |
|
4701 { |
|
4702 if(stateEvent.Compare(_L("state")) == 0) //state event - add state keyword to message |
|
4703 { |
|
4704 User::LeaveIfError(req->Append(CStifTFwIfProt::EventType, TEventIf::EState)); |
|
4705 } |
|
4706 else //syntax error in the line |
|
4707 { |
|
4708 __TRACE(KError, (_L("Unknown keyword %S"), &stateEvent)); |
|
4709 } |
|
4710 } |
|
4711 else //syntax error in the line |
|
4712 { |
|
4713 __TRACE(KError, (_L("Unknown keyword (2) %S"), &stateEvent)); |
|
4714 } |
|
4715 } |
|
4716 User::LeaveIfError( |
|
4717 iTestCombiner->TestModuleIf().RemoteSend( req->Message() ) ); |
|
4718 |
|
4719 // Start timer |
|
4720 iRemoteTimer->SetTimerActive( iTestCombiner->iRemoteTimeout ); |
|
4721 |
|
4722 iState = ERunnerRemote; |
|
4723 |
|
4724 CleanupStack::PopAndDestroy( req ); |
|
4725 |
|
4726 return EFalse; |
|
4727 |
|
4728 } |
|
4729 |
|
4730 TBool CTestRunner::ExecuteRemoteSetUnsetEventL(CStifItemParser* aItem, |
|
4731 CSlaveInfo* aSlave, |
|
4732 TInt aCmd) |
|
4733 { |
|
4734 TPtrC eventName; |
|
4735 // Get event name |
|
4736 TInt ret = aItem->GetNextString(eventName); |
|
4737 if(ret != KErrNone) |
|
4738 { |
|
4739 __TRACE(KError, (_L("Event name was not given for remote"))); |
|
4740 User::Leave(KErrArgument); |
|
4741 } |
|
4742 // Check if this is a state set, indication set, or unset command |
|
4743 TInt caseNumber = -1; |
|
4744 if(aCmd == TTCKeywords::ESet) |
|
4745 { |
|
4746 TPtrC stateEvent; |
|
4747 TInt ret = aItem->GetNextString(stateEvent); |
|
4748 if(ret == KErrNotFound) //indication event - add indicate keyword to message |
|
4749 { |
|
4750 caseNumber = 1; |
|
4751 } |
|
4752 else if(ret == KErrNone) //possibly state event |
|
4753 { |
|
4754 if(stateEvent.Compare(_L("state")) == 0) //state event - add state keyword to message |
|
4755 { |
|
4756 caseNumber = 0; |
|
4757 } |
|
4758 else //syntax error in the line |
|
4759 { |
|
4760 __TRACE(KError, (_L("Unknown keyword %S"), &stateEvent)); |
|
4761 } |
|
4762 } |
|
4763 else //syntax error in the line |
|
4764 { |
|
4765 } |
|
4766 } |
|
4767 else //TTCKeyword::EUnset |
|
4768 { |
|
4769 caseNumber = 2; |
|
4770 } |
|
4771 |
|
4772 if(caseNumber == -1) |
|
4773 { |
|
4774 __TRACE(KError, _L("Should never occur")); |
|
4775 } |
|
4776 // Build new descriptor with command to run hardcoded suevent test case on remote phone |
|
4777 HBufC* cmd = HBufC::NewL(100); |
|
4778 CleanupStack::PushL(cmd); |
|
4779 TPtr cmdPtr(cmd->Des()); |
|
4780 cmdPtr.Copy(eventName); |
|
4781 // Run remotely test case |
|
4782 RDebug::Print(_L("CTestRunner::ExecuteRemoteSetUnsetEventL calling ExecuteRemoteRun")); |
|
4783 TBool retval = ExecuteRemoteRunL(aItem, aSlave, cmd, caseNumber); |
|
4784 // Clean data |
|
4785 CleanupStack::PopAndDestroy(cmd); |
|
4786 RDebug::Print(_L("CTestRunner::ExecuteRemoteSetUnsetEventL end")); |
|
4787 return retval; |
|
4788 } |
|
4789 /* |
|
4790 ------------------------------------------------------------------------------- |
|
4791 |
|
4792 Class: CTestRunner |
|
4793 |
|
4794 Method: ExecuteRemoteSendReceiveL |
|
4795 |
|
4796 Description: Handles asynchronous remote sendreceive controlling |
|
4797 |
|
4798 Parameters: CStifItemParser* aItem: in: script line |
|
4799 CSlaveInfo* aSlave: in: slave info |
|
4800 |
|
4801 Return Values: ETrue: continue script file execution |
|
4802 EFalse: stop script file execution and wait response |
|
4803 |
|
4804 Errors/Exceptions: Leaves on error situations. |
|
4805 |
|
4806 Status: Draft |
|
4807 |
|
4808 ------------------------------------------------------------------------------- |
|
4809 */ |
|
4810 TBool CTestRunner::ExecuteRemoteSendReceiveL( CStifItemParser* aItem, |
|
4811 CSlaveInfo* aSlave ) |
|
4812 { |
|
4813 CStifTFwIfProt* req = CStifTFwIfProt::NewL(); |
|
4814 CleanupStack::PushL( req ); |
|
4815 |
|
4816 // Create CRemoteSendReceive object for taking sendreceive information to |
|
4817 // save for later use. |
|
4818 CRemoteSendReceive* remoteSendReceive = |
|
4819 CRemoteSendReceive::NewL( iTestCombiner ); |
|
4820 |
|
4821 CleanupStack::PushL( remoteSendReceive ); |
|
4822 |
|
4823 req->CreateL(); |
|
4824 // Remote message |
|
4825 User::LeaveIfError( |
|
4826 req->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); |
|
4827 // Srcid. i.e. master id |
|
4828 User::LeaveIfError( req->AppendId( aSlave->iMasterId ) ); |
|
4829 // DstId, i.e.slave device id |
|
4830 User::LeaveIfError( req->AppendId( aSlave->iSlaveDevId ) ); |
|
4831 // Run command |
|
4832 User::LeaveIfError( req->Append( |
|
4833 CStifTFwIfProt::CmdType, CStifTFwIfProt::ECmdSendReceive ) ); |
|
4834 // asynchronous sendreceive's parameters |
|
4835 TPtrC tmp; |
|
4836 |
|
4837 while( aItem->GetNextString( tmp ) == KErrNone ) |
|
4838 { |
|
4839 // Append parameters |
|
4840 User::LeaveIfError( req->Append( tmp ) ); |
|
4841 } |
|
4842 |
|
4843 User::LeaveIfError( |
|
4844 iTestCombiner->TestModuleIf().RemoteSend( req->Message() ) ); |
|
4845 |
|
4846 remoteSendReceive->iRemoteState = CRemoteSendReceive::ECaseSend; |
|
4847 remoteSendReceive->iSlaveId = aSlave->iSlaveDevId; |
|
4848 |
|
4849 // Take CRemoteSendReceive object to save in array. This can be used in |
|
4850 // TestCombiner when handling responses. |
|
4851 User::LeaveIfError( |
|
4852 iTestCombiner->iSendReceive.Append( remoteSendReceive ) ); |
|
4853 if( iTestCombiner->iLoopIsUsed ) |
|
4854 { |
|
4855 User::LeaveIfError( |
|
4856 iTestCombiner->iLoopAllocationArray.Append( remoteSendReceive ) ); |
|
4857 } |
|
4858 CleanupStack::Pop( remoteSendReceive ); |
|
4859 |
|
4860 // Start timer |
|
4861 iRemoteTimer->SetTimerActive( iTestCombiner->iRemoteTimeout ); |
|
4862 |
|
4863 iState = ERunnerRemote; |
|
4864 |
|
4865 CleanupStack::PopAndDestroy( req ); |
|
4866 |
|
4867 // Return EFalse=>start waiting response... |
|
4868 return EFalse; |
|
4869 |
|
4870 } |
|
4871 |
|
4872 /* |
|
4873 ------------------------------------------------------------------------------- |
|
4874 |
|
4875 Class: CTestRunner |
|
4876 |
|
4877 Method: ExecuteRemoteUnknownL |
|
4878 |
|
4879 Description: Forwards messages as such |
|
4880 |
|
4881 Parameters: CStifItemParser* aItem: in: script line |
|
4882 CSlaveInfo* aSlave: in: slave info |
|
4883 TInt aCmd: in: remote command |
|
4884 |
|
4885 Return Values: ETrue: continue script file execution |
|
4886 EFalse: stop script file execution and wait response |
|
4887 |
|
4888 Errors/Exceptions: Leaves on error situations. |
|
4889 |
|
4890 Status: Draft |
|
4891 |
|
4892 ------------------------------------------------------------------------------- |
|
4893 */ |
|
4894 TBool CTestRunner::ExecuteRemoteUnknownL( CStifItemParser* aItem, |
|
4895 CSlaveInfo* aSlave, |
|
4896 TDesC& aCommand ) |
|
4897 { |
|
4898 |
|
4899 CStifTFwIfProt* req = CStifTFwIfProt::NewL(); |
|
4900 CleanupStack::PushL( req ); |
|
4901 |
|
4902 req->CreateL(); |
|
4903 // Remote message |
|
4904 User::LeaveIfError( |
|
4905 req->Append( CStifTFwIfProt::MsgType, CStifTFwIfProt::EMsgRemote ) ); |
|
4906 // Srcid. i.e. master id |
|
4907 User::LeaveIfError( req->AppendId( aSlave->iMasterId ) ); |
|
4908 // DstId, i.e.slave device id |
|
4909 User::LeaveIfError( req->AppendId( aSlave->iSlaveDevId ) ); |
|
4910 |
|
4911 // Append command name |
|
4912 User::LeaveIfError( req->Append( aCommand ) ); |
|
4913 |
|
4914 TPtrC tmp; |
|
4915 while( aItem->GetNextString( tmp ) == KErrNone ) |
|
4916 { |
|
4917 // Append parameters |
|
4918 User::LeaveIfError( req->Append( tmp ) ); |
|
4919 } |
|
4920 |
|
4921 User::LeaveIfError( |
|
4922 iTestCombiner->TestModuleIf().RemoteSend( req->Message() ) ); |
|
4923 |
|
4924 // Start timer |
|
4925 iRemoteTimer->SetTimerActive( iTestCombiner->iRemoteTimeout ); |
|
4926 |
|
4927 iState = ERunnerRemote; |
|
4928 |
|
4929 CleanupStack::PopAndDestroy( req ); |
|
4930 |
|
4931 return EFalse; |
|
4932 |
|
4933 } |
|
4934 /* |
|
4935 ------------------------------------------------------------------------------- |
|
4936 |
|
4937 Class: CTestRunner |
|
4938 |
|
4939 Method: ReceiveResponseL |
|
4940 |
|
4941 Description: Handles responce received from slave |
|
4942 |
|
4943 Parameters: TDesC& aMsg: in: message |
|
4944 |
|
4945 Return Values: ETrue: continue script file execution |
|
4946 EFalse: stop script file execution |
|
4947 |
|
4948 Errors/Exceptions: Leaves on error situations. |
|
4949 |
|
4950 Status: Draft |
|
4951 |
|
4952 ------------------------------------------------------------------------------- |
|
4953 */ |
|
4954 TBool CTestRunner::ReceiveResponseL( TDesC& aMsg ) |
|
4955 { |
|
4956 __TRACE( KMessage, (_L("ReceiveResponse"))); |
|
4957 |
|
4958 iRemoteTimer->Cancel(); |
|
4959 |
|
4960 CStifTFwIfProt* msg = CStifTFwIfProt::NewL(); |
|
4961 CleanupStack::PushL( msg ); |
|
4962 TRAPD( err, msg->SetL( aMsg ); ); |
|
4963 if( err != KErrNone ) |
|
4964 { |
|
4965 __TRACE( KError, (_L("Response parsing failed"))); |
|
4966 User::Leave( err ); |
|
4967 } |
|
4968 |
|
4969 // Check protocol identifiers |
|
4970 if( ( msg->SrcDevId() == 0 ) || |
|
4971 ( msg->DstDevId() == 0 ) || |
|
4972 ( msg->DstTestId() == 0 ) ) |
|
4973 { |
|
4974 __TRACE( KError, (_L("Illegal deviceid received"))); |
|
4975 User::Leave( KErrGeneral ); |
|
4976 } |
|
4977 |
|
4978 // This is master, cannot receive anything else but responses |
|
4979 if( msg->iMsgType != CStifTFwIfProt::EMsgResponse ) |
|
4980 { |
|
4981 __TRACE( KError, (_L("Illegal message received %d"), |
|
4982 msg->iMsgType )); |
|
4983 User::Leave( KErrGeneral ); |
|
4984 } |
|
4985 |
|
4986 TBool continueTask = ETrue; |
|
4987 switch( msg->iRespType ) |
|
4988 { |
|
4989 case CStifTFwIfProt::EMsgReserve: |
|
4990 { |
|
4991 __TRACE( KMessage, (_L("ReceiveResponse Reserve"))); |
|
4992 if( iState != ERunnerAllocate ) |
|
4993 { |
|
4994 __TRACE( KError, (_L("Response reserve received in illegal state %d"), |
|
4995 iState )); |
|
4996 User::Leave( KErrGeneral ); |
|
4997 } |
|
4998 // Check protocol Src test id |
|
4999 if( msg->SrcTestId() != 0 ) |
|
5000 { |
|
5001 __TRACE( KError, (_L("Illegal deviceid received"))); |
|
5002 User::Leave( KErrGeneral ); |
|
5003 } |
|
5004 if( msg->iResult != KErrNone ) |
|
5005 { |
|
5006 __TRACE( KError, (_L("Response with error %d"), msg->iResult )); |
|
5007 User::Leave( msg->iResult ); |
|
5008 } |
|
5009 CSlaveInfo* slave = NULL; |
|
5010 TInt count = iTestCombiner->iSlaveArray.Count(); |
|
5011 for( TInt index = 0; index < count; index++ ) |
|
5012 { |
|
5013 slave = iTestCombiner->iSlaveArray[index]; |
|
5014 if( ( slave->iSlaveDevId == 0 ) && |
|
5015 ( slave->iState == CSlaveInfo::ESlaveReserveSent ) ) |
|
5016 { |
|
5017 break; |
|
5018 } |
|
5019 slave = NULL; |
|
5020 } |
|
5021 if( slave == NULL ) |
|
5022 { |
|
5023 User::Leave( KErrNotFound ); |
|
5024 } |
|
5025 slave->iSlaveDevId = msg->SrcId(); |
|
5026 slave->iState = CSlaveInfo::ESlaveReserved; |
|
5027 __TRACE( KMessage, (_L("Slave allocated succesfully, continue execution"))); |
|
5028 } |
|
5029 break; |
|
5030 case CStifTFwIfProt::EMsgRelease: |
|
5031 { |
|
5032 __TRACE( KMessage, (_L("ReceiveResponse Release"))); |
|
5033 if( iState != ERunnerFree ) |
|
5034 { |
|
5035 __TRACE( KError, (_L("Response release received in illegal state %d"), |
|
5036 iState )); |
|
5037 User::Leave( KErrGeneral ); |
|
5038 } |
|
5039 // Check protocol Src test id |
|
5040 if( msg->SrcTestId() != 0 ) |
|
5041 { |
|
5042 __TRACE( KError, (_L("Illegal deviceid received"))); |
|
5043 User::Leave( KErrGeneral ); |
|
5044 } |
|
5045 if( msg->iResult != KErrNone ) |
|
5046 { |
|
5047 __TRACE( KError, (_L("Response with error %d"), msg->iResult )); |
|
5048 User::Leave( msg->iResult ); |
|
5049 } |
|
5050 |
|
5051 CSlaveInfo* slave = iTestCombiner->GetSlave( msg->SrcId() ); |
|
5052 if( slave == NULL ) |
|
5053 { |
|
5054 User::Leave( KErrNotFound ); |
|
5055 } |
|
5056 slave->iState = CSlaveInfo::ESlaveReleased; |
|
5057 __TRACE( KMessage, (_L("Slave freed succesfully, continue execution"))); |
|
5058 } |
|
5059 break; |
|
5060 case CStifTFwIfProt::EMsgRemote: |
|
5061 { |
|
5062 __TRACE( KMessage, (_L("ReceiveResponse Remote"))); |
|
5063 switch( msg->iCmdType ) |
|
5064 { |
|
5065 case CStifTFwIfProt::ECmdRun: |
|
5066 continueTask = ReceiveResponseRunL( *msg ); |
|
5067 break; |
|
5068 case CStifTFwIfProt::ECmdPause: |
|
5069 case CStifTFwIfProt::ECmdResume: |
|
5070 case CStifTFwIfProt::ECmdCancel: |
|
5071 continueTask = ReceiveResponseTestCtlL( *msg ); |
|
5072 break; |
|
5073 case CStifTFwIfProt::ECmdRequest: |
|
5074 case CStifTFwIfProt::ECmdRelease: |
|
5075 case CStifTFwIfProt::ECmdSetEvent: |
|
5076 case CStifTFwIfProt::ECmdUnsetEvent: |
|
5077 continueTask = ReceiveResponseEventCtlL( *msg ); |
|
5078 break; |
|
5079 case CStifTFwIfProt::ECmdSendReceive: |
|
5080 continueTask = ReceiveResponseSendReceiveL( *msg ); |
|
5081 break; |
|
5082 default: |
|
5083 continueTask = ReceiveResponseUnknownL( *msg ); |
|
5084 break; |
|
5085 } |
|
5086 } |
|
5087 break; |
|
5088 default: |
|
5089 User::Leave( KErrGeneral ); |
|
5090 } |
|
5091 |
|
5092 |
|
5093 CleanupStack::PopAndDestroy( msg ); |
|
5094 return continueTask; |
|
5095 |
|
5096 } |
|
5097 |
|
5098 /* |
|
5099 ------------------------------------------------------------------------------- |
|
5100 |
|
5101 Class: CTestRunner |
|
5102 |
|
5103 Method: ReceiveResponseRunL |
|
5104 |
|
5105 Description: Handles response for run received from slave |
|
5106 |
|
5107 Parameters: CStifTFwIfProt& aMsg: in: protocol message parser |
|
5108 |
|
5109 Return Values: ETrue: continue script file execution |
|
5110 EFalse: stop script file execution |
|
5111 |
|
5112 Errors/Exceptions: Leaves on error situations. |
|
5113 |
|
5114 Status: Draft |
|
5115 |
|
5116 ------------------------------------------------------------------------------- |
|
5117 */ |
|
5118 TBool CTestRunner::ReceiveResponseRunL( CStifTFwIfProt& aMsg ) |
|
5119 { |
|
5120 |
|
5121 TPtrC tmp = CStifTFwIfProt::RunStatus(aMsg.iRunStatus); |
|
5122 __TRACE( KMessage, (_L("ReceiveResponse Remote Run %S"), &tmp )); |
|
5123 |
|
5124 TBool continueTask = ETrue; |
|
5125 switch( aMsg.iRunStatus ) |
|
5126 { |
|
5127 case CStifTFwIfProt::ERunStarted: |
|
5128 { |
|
5129 // Locate testcase |
|
5130 CRemoteTestCase* tcase = |
|
5131 iTestCombiner->GetRemoteTestRunSent( GETDEVID( aMsg.SrcId() ) ); |
|
5132 if( tcase == NULL ) |
|
5133 { |
|
5134 __TRACE( KError, (_L("Testcase not found"))); |
|
5135 User::Leave( KErrNotFound ); |
|
5136 } |
|
5137 tcase->iSlaveId = aMsg.SrcId(); |
|
5138 |
|
5139 tcase->iRemoteState = CRemoteTestCase::ECaseRunning; |
|
5140 } |
|
5141 break; |
|
5142 case CStifTFwIfProt::ERunError: |
|
5143 case CStifTFwIfProt::ERunReady: |
|
5144 { |
|
5145 // Locate testcase |
|
5146 CRemoteTestCase* tcase = |
|
5147 iTestCombiner->GetRunningRemoteTest( aMsg.SrcId() ); |
|
5148 if( tcase == NULL ) |
|
5149 { |
|
5150 __TRACE( KError, (_L("Testcase not found"))); |
|
5151 User::Leave( KErrNotFound ); |
|
5152 } |
|
5153 |
|
5154 switch( aMsg.iResultCategory ) |
|
5155 { |
|
5156 case CStifTFwIfProt::EResultNormal: |
|
5157 tcase->iResult.iCaseExecutionResultType = |
|
5158 TFullTestResult::ECaseExecuted; |
|
5159 tcase->iResult.iTestResult.iResult = aMsg.iResult; |
|
5160 tcase->iResult.iCaseExecutionResultCode = 0; |
|
5161 break; |
|
5162 case CStifTFwIfProt::EResultPanic: |
|
5163 tcase->iResult.iCaseExecutionResultType = |
|
5164 TFullTestResult::ECasePanic; |
|
5165 tcase->iResult.iTestResult.iResult = KErrGeneral; |
|
5166 tcase->iResult.iCaseExecutionResultCode = aMsg.iResult; |
|
5167 break; |
|
5168 case CStifTFwIfProt::EResultException: |
|
5169 tcase->iResult.iCaseExecutionResultType = |
|
5170 TFullTestResult::ECaseException; |
|
5171 tcase->iResult.iTestResult.iResult = KErrGeneral; |
|
5172 tcase->iResult.iCaseExecutionResultCode = aMsg.iResult; |
|
5173 break; |
|
5174 case CStifTFwIfProt::EResultTimeout: |
|
5175 tcase->iResult.iCaseExecutionResultType = |
|
5176 TFullTestResult::ECaseTimeout; |
|
5177 tcase->iResult.iTestResult.iResult = KErrGeneral; |
|
5178 tcase->iResult.iCaseExecutionResultCode = aMsg.iResult; |
|
5179 break; |
|
5180 case CStifTFwIfProt::EResultLeave: |
|
5181 tcase->iResult.iCaseExecutionResultType = |
|
5182 TFullTestResult::ECaseLeave; |
|
5183 tcase->iResult.iTestResult.iResult = KErrGeneral; |
|
5184 tcase->iResult.iCaseExecutionResultCode = aMsg.iResult; |
|
5185 break; |
|
5186 default: |
|
5187 User::Leave( KErrGeneral ); |
|
5188 } |
|
5189 |
|
5190 if( ( tcase->iRemoteState == CRemoteTestCase::ECaseCancelled ) || |
|
5191 ( tcase->iRemoteState == CRemoteTestCase::ECaseRunSent ) ) |
|
5192 { |
|
5193 // Complete for cancelled testcase or error for run request, |
|
5194 // set runner active again |
|
5195 continueTask = ETrue; |
|
5196 } |
|
5197 else |
|
5198 { |
|
5199 // Continued from Complete in state ECaseRunning |
|
5200 continueTask = EFalse; |
|
5201 } |
|
5202 |
|
5203 tcase->iRemoteState = CRemoteTestCase::ECaseCompleted; |
|
5204 |
|
5205 __TRACE( KMessage, (_L("ReceiveResponse Remote Run rq comp"))); |
|
5206 |
|
5207 TRequestStatus* rs = &tcase->iStatus; |
|
5208 // Complete testcase |
|
5209 User::RequestComplete( rs, KErrNone ); |
|
5210 |
|
5211 } |
|
5212 break; |
|
5213 default: |
|
5214 // Should never come here |
|
5215 User::Leave( KErrGeneral ); |
|
5216 } |
|
5217 |
|
5218 return continueTask; |
|
5219 |
|
5220 } |
|
5221 |
|
5222 /* |
|
5223 ------------------------------------------------------------------------------- |
|
5224 |
|
5225 Class: CTestRunner |
|
5226 |
|
5227 Method: ReceiveResponseTestCtlL |
|
5228 |
|
5229 Description: Handles responses for test control commands |
|
5230 received from slave |
|
5231 |
|
5232 Parameters: CStifTFwIfProt& aMsg: in: protocol message parser |
|
5233 |
|
5234 Return Values: ETrue: continue script file execution |
|
5235 EFalse: stop script file execution |
|
5236 |
|
5237 Errors/Exceptions: Leaves on error situations. |
|
5238 |
|
5239 Status: Draft |
|
5240 |
|
5241 ------------------------------------------------------------------------------- |
|
5242 */ |
|
5243 TBool CTestRunner::ReceiveResponseTestCtlL( CStifTFwIfProt& aMsg ) |
|
5244 { |
|
5245 |
|
5246 if( aMsg.iResult != KErrNone ) |
|
5247 { |
|
5248 __TRACE( KError, (_L("Response with error %d"), aMsg.iResult )); |
|
5249 User::Leave( aMsg.iResult ); |
|
5250 } |
|
5251 |
|
5252 // Locate testcase |
|
5253 CRemoteTestCase* tcase = iTestCombiner->GetRemoteTest( aMsg.SrcId() ); |
|
5254 if( tcase == NULL ) |
|
5255 { |
|
5256 __TRACE( KError, (_L("Testcase not found"))); |
|
5257 User::Leave( KErrNotFound ); |
|
5258 } |
|
5259 |
|
5260 TBool continueTask = ETrue; |
|
5261 |
|
5262 switch( aMsg.iCmdType ) |
|
5263 { |
|
5264 case CStifTFwIfProt::ECmdPause: |
|
5265 __TRACE( KMessage, (_L("ReceiveResponse Remote Pause"))); |
|
5266 |
|
5267 if( tcase->iRemoteState != CRemoteTestCase::ECasePauseSent ) |
|
5268 { |
|
5269 __TRACE( KError, (_L("Pause response received in illegal state"))); |
|
5270 User::Leave( KErrGeneral ); |
|
5271 } |
|
5272 tcase->iRemoteState = CRemoteTestCase::ECasePaused; |
|
5273 |
|
5274 // Start pause timer if timeout was given |
|
5275 if( ( iPausedTestCase.Length() > 0 ) && |
|
5276 ( iPauseTime != 0 ) ) |
|
5277 { |
|
5278 continueTask = EFalse; |
|
5279 iState = ERunnerWaitTimeout; |
|
5280 iPauseTimer.After( iStatus, iPauseTime*1000 ); |
|
5281 SetActive(); |
|
5282 } |
|
5283 break; |
|
5284 case CStifTFwIfProt::ECmdResume: |
|
5285 __TRACE( KMessage, (_L("ReceiveResponse Remote Resume"))); |
|
5286 |
|
5287 if( tcase->iRemoteState != CRemoteTestCase::ECaseResumeSent ) |
|
5288 { |
|
5289 __TRACE( KError, (_L("Resume response received in illegal state"))); |
|
5290 User::Leave( KErrGeneral ); |
|
5291 } |
|
5292 tcase->iRemoteState = CRemoteTestCase::ECaseRunning; |
|
5293 break; |
|
5294 case CStifTFwIfProt::ECmdCancel: |
|
5295 __TRACE( KMessage, (_L("ReceiveResponse Remote Cancel"))); |
|
5296 |
|
5297 if( tcase->iRemoteState != CRemoteTestCase::ECaseCancelSent ) |
|
5298 { |
|
5299 __TRACE( KError, (_L("Cancel response received in illegal state"))); |
|
5300 User::Leave( KErrGeneral ); |
|
5301 } |
|
5302 tcase->iRemoteState = CRemoteTestCase::ECaseCancelled; |
|
5303 // Need to wait Run response with KErrCancel |
|
5304 continueTask = EFalse; |
|
5305 // Start timer |
|
5306 iRemoteTimer->SetTimerActive( iTestCombiner->iRemoteTimeout ); |
|
5307 break; |
|
5308 default: |
|
5309 // Should never come here |
|
5310 User::Leave( KErrGeneral ); |
|
5311 } |
|
5312 |
|
5313 return continueTask; |
|
5314 } |
|
5315 |
|
5316 /* |
|
5317 ------------------------------------------------------------------------------- |
|
5318 |
|
5319 Class: CTestRunner |
|
5320 |
|
5321 Method: ReceiveResponseEventCtlL |
|
5322 |
|
5323 Description: Handles responses for event system control commands |
|
5324 received from slave |
|
5325 |
|
5326 Parameters: CStifTFwIfProt& aMsg: in: protocol message parser |
|
5327 |
|
5328 Return Values: ETrue: continue script file execution |
|
5329 EFalse: stop script file execution |
|
5330 |
|
5331 Errors/Exceptions: Leaves on error situations. |
|
5332 |
|
5333 Status: Draft |
|
5334 |
|
5335 ------------------------------------------------------------------------------- |
|
5336 */ |
|
5337 TBool CTestRunner::ReceiveResponseEventCtlL( CStifTFwIfProt& aMsg ) |
|
5338 { |
|
5339 |
|
5340 CSlaveInfo* slave = iTestCombiner->GetSlave( aMsg.SrcId() ); |
|
5341 if( slave == NULL ) |
|
5342 { |
|
5343 User::Leave( KErrNotFound ); |
|
5344 } |
|
5345 |
|
5346 TBool continueTask = ETrue; |
|
5347 switch( aMsg.iCmdType ) |
|
5348 { |
|
5349 case CStifTFwIfProt::ECmdRequest: |
|
5350 { |
|
5351 __TRACE( KMessage, (_L("ReceiveResponse Request"))); |
|
5352 |
|
5353 TEventTc* event = slave->GetEvent( aMsg.iEventName ); |
|
5354 if( event == NULL ) |
|
5355 { |
|
5356 User::Leave( KErrNotFound ); |
|
5357 } |
|
5358 switch( aMsg.iEventStatus ) |
|
5359 { |
|
5360 case CStifTFwIfProt::EEventActive: |
|
5361 __TRACE( KMessage, (_L("Event %S active"), &aMsg.iEventName )); |
|
5362 break; |
|
5363 case CStifTFwIfProt::EEventSet: |
|
5364 __TRACE( KMessage, (_L("Event %S set"), &aMsg.iEventName )); |
|
5365 // Set event |
|
5366 event->SetEvent( aMsg.iEventType ); |
|
5367 continueTask = EFalse; |
|
5368 break; |
|
5369 case CStifTFwIfProt::EEventError: |
|
5370 __TRACE( KMessage, (_L("Event %S error %d"), |
|
5371 &aMsg.iEventName, aMsg.iResult )); |
|
5372 User::Leave( aMsg.iResult ); |
|
5373 default: |
|
5374 User::Leave( KErrGeneral ); |
|
5375 } |
|
5376 } |
|
5377 break; |
|
5378 case CStifTFwIfProt::ECmdRelease: |
|
5379 __TRACE( KMessage, (_L("ReceiveResponse Release"))); |
|
5380 if( aMsg.iResult != KErrNone ) |
|
5381 { |
|
5382 __TRACE( KError, (_L("Response with error %d"), aMsg.iResult )); |
|
5383 User::Leave( aMsg.iResult ); |
|
5384 } |
|
5385 |
|
5386 // Everything ok, no need to do anything |
|
5387 break; |
|
5388 case CStifTFwIfProt::ECmdSetEvent: |
|
5389 __TRACE( KMessage, (_L("ReceiveResponse SetEvent"))); |
|
5390 if( aMsg.iResult != KErrNone ) |
|
5391 { |
|
5392 __TRACE( KError, (_L("Response with error %d"), aMsg.iResult )); |
|
5393 User::Leave( aMsg.iResult ); |
|
5394 } |
|
5395 |
|
5396 // Everything ok, no need to do anything |
|
5397 break; |
|
5398 case CStifTFwIfProt::ECmdUnsetEvent: |
|
5399 __TRACE( KMessage, (_L("ReceiveResponse Unset"))); |
|
5400 if( aMsg.iResult != KErrNone ) |
|
5401 { |
|
5402 __TRACE( KError, (_L("Response with error %d"), aMsg.iResult )); |
|
5403 User::Leave( aMsg.iResult ); |
|
5404 } |
|
5405 // Everything ok, no need to do anything |
|
5406 break; |
|
5407 default: |
|
5408 // Should never come here |
|
5409 User::Leave( KErrGeneral ); |
|
5410 } |
|
5411 |
|
5412 return continueTask; |
|
5413 |
|
5414 } |
|
5415 |
|
5416 /* |
|
5417 ------------------------------------------------------------------------------- |
|
5418 |
|
5419 Class: CTestRunner |
|
5420 |
|
5421 Method: ReceiveResponseSendReceiveL |
|
5422 |
|
5423 Description: Handles responses for asynchronous sendreceive commands |
|
5424 received from slave |
|
5425 |
|
5426 Parameters: CStifTFwIfProt& aMsg: in: protocol message parser |
|
5427 |
|
5428 Return Values: ETrue: continue script file execution |
|
5429 EFalse: stop script file execution |
|
5430 |
|
5431 Errors/Exceptions: Leaves on error situations. |
|
5432 |
|
5433 Status: Draft |
|
5434 |
|
5435 ------------------------------------------------------------------------------- |
|
5436 */ |
|
5437 TBool CTestRunner::ReceiveResponseSendReceiveL( CStifTFwIfProt& aMsg ) |
|
5438 { |
|
5439 |
|
5440 TPtrC tmp = CStifTFwIfProt::RunStatus(aMsg.iRunStatus); |
|
5441 __TRACE( KMessage, ( |
|
5442 _L("ReceiveResponseSendReceiveL asynchronous Remote SendReceive %S"), |
|
5443 &tmp ) ); |
|
5444 |
|
5445 TBool continueTask = EFalse; |
|
5446 switch( aMsg.iRunStatus ) |
|
5447 { |
|
5448 case CStifTFwIfProt::ERunStarted: |
|
5449 { |
|
5450 // Locate CRemoteSendReceive object |
|
5451 CRemoteSendReceive* sendreceive = |
|
5452 iTestCombiner->GetRemoteSendReceive( GETDEVID( |
|
5453 aMsg.SrcId() ) ); |
|
5454 if( sendreceive == NULL ) |
|
5455 { |
|
5456 __TRACE( KError, (_L("CRemoteSendReceive object not found"))); |
|
5457 User::Leave( KErrNotFound ); |
|
5458 } |
|
5459 sendreceive->iRemoteState = CRemoteSendReceive::ECaseSend; |
|
5460 |
|
5461 // continueTask is EFalse=>stop script file execution |
|
5462 break; |
|
5463 } |
|
5464 case CStifTFwIfProt::ERunError: |
|
5465 case CStifTFwIfProt::ERunReady: |
|
5466 { |
|
5467 if( aMsg.iResult != KErrNone ) |
|
5468 { |
|
5469 __TRACE( KError, (_L("sendreceive response with error %d"), aMsg.iResult )); |
|
5470 User::Leave( aMsg.iResult ); |
|
5471 } |
|
5472 |
|
5473 // Locate CRemoteSendReceive object |
|
5474 CRemoteSendReceive* sendreceive = |
|
5475 iTestCombiner->GetRemoteSendReceive( aMsg.SrcId() ); |
|
5476 if( sendreceive == NULL ) |
|
5477 { |
|
5478 __TRACE( KError, (_L("CRemoteSendReceive object not found"))); |
|
5479 User::Leave( KErrNotFound ); |
|
5480 } |
|
5481 |
|
5482 // continueTask is ETrue=>continue script file execution |
|
5483 continueTask = ETrue; |
|
5484 |
|
5485 sendreceive->iRemoteState = CRemoteSendReceive::ECaseCompleted; |
|
5486 |
|
5487 __TRACE( KMessage, ( |
|
5488 _L( "ReceiveResponseSendReceiveL asynchronous Remote SendReceive rq comp" ) ) ); |
|
5489 break; |
|
5490 } |
|
5491 default: |
|
5492 { |
|
5493 // Should never come here |
|
5494 User::Leave( KErrGeneral ); |
|
5495 } |
|
5496 } |
|
5497 return continueTask; |
|
5498 |
|
5499 } |
|
5500 |
|
5501 /* |
|
5502 ------------------------------------------------------------------------------- |
|
5503 |
|
5504 Class: CTestRunner |
|
5505 |
|
5506 Method: ReceiveResponseUnknownL |
|
5507 |
|
5508 Description: Handles responses for unspecified commands |
|
5509 |
|
5510 Parameters: CStifTFwIfProt& aMsg: in: protocol message parser |
|
5511 |
|
5512 Return Values: ETrue: continue script file execution |
|
5513 EFalse: stop script file execution |
|
5514 |
|
5515 Errors/Exceptions: Leaves on error situations. |
|
5516 |
|
5517 Status: Draft |
|
5518 |
|
5519 ------------------------------------------------------------------------------- |
|
5520 */ |
|
5521 TBool CTestRunner::ReceiveResponseUnknownL( CStifTFwIfProt& aMsg ) |
|
5522 { |
|
5523 |
|
5524 CSlaveInfo* slave = iTestCombiner->GetSlave( aMsg.SrcId() ); |
|
5525 if( slave == NULL ) |
|
5526 { |
|
5527 User::Leave( KErrNotFound ); |
|
5528 } |
|
5529 if( aMsg.iResult != KErrNone ) |
|
5530 { |
|
5531 __TRACE( KError, (_L("Response with error %d"), aMsg.iResult )); |
|
5532 User::Leave( aMsg.iResult ); |
|
5533 } |
|
5534 |
|
5535 return ETrue; |
|
5536 |
|
5537 } |
|
5538 |
|
5539 /* |
|
5540 ------------------------------------------------------------------------------- |
|
5541 |
|
5542 Class: CTestRunner |
|
5543 |
|
5544 Method: ParseOptArgL |
|
5545 |
|
5546 Description: Parses optional argument |
|
5547 |
|
5548 Parameters: const TDesC& aOptArg: in: |
|
5549 argument-value pair (format arg=value) |
|
5550 TPtrC& aArg: out: parsed argument |
|
5551 TPtrC& aVal: out: parsed value |
|
5552 |
|
5553 Return Values: None |
|
5554 |
|
5555 Errors/Exceptions: Leaves if parsing fails. |
|
5556 |
|
5557 Status: Approved |
|
5558 |
|
5559 ------------------------------------------------------------------------------- |
|
5560 */ |
|
5561 void CTestRunner::ParseOptArgL( const TDesC& aOptArg, TPtrC& aArg, TPtrC& aVal) |
|
5562 { |
|
5563 _LIT( KErrMsgUnknownOrIllegalKeyword, "Unknown or illegal argument %S" ); |
|
5564 _LIT( KErrMsgValueNotDefined, "Value of optional argument %S is not defined" ); |
|
5565 TInt length = aOptArg.Length(); |
|
5566 for( TInt i=0; i < length; i++) |
|
5567 { |
|
5568 // find the '=' sign |
|
5569 if( aOptArg[i] == '=' ) |
|
5570 { |
|
5571 if( i+1 >= length ) |
|
5572 { |
|
5573 __TRACE( KError, |
|
5574 (_L("Illegal optional argument(%S), no value"), |
|
5575 &aOptArg )); |
|
5576 TPtrC tmp = aOptArg.Left( i ); |
|
5577 iRunErrorMessage.Format( KErrMsgValueNotDefined, &tmp ); |
|
5578 User::Leave( KErrArgument ); |
|
5579 } |
|
5580 aArg.Set( aOptArg.Left( i ) ); |
|
5581 aVal.Set( aOptArg.Mid( i+1 ) ); |
|
5582 __TRACE( KMessage, ( _L( "arg '%S', val '%S'" ), |
|
5583 &aArg, &aVal )); |
|
5584 return; |
|
5585 } |
|
5586 } |
|
5587 __TRACE( KError, (_L("Illegal optional argument(%S)"), &aOptArg )); |
|
5588 iRunErrorMessage.Format( KErrMsgUnknownOrIllegalKeyword, &aOptArg ); |
|
5589 User::Leave( KErrArgument ); |
|
5590 |
|
5591 } |
|
5592 |
|
5593 /* |
|
5594 ------------------------------------------------------------------------------- |
|
5595 |
|
5596 Class: CTestRunner |
|
5597 |
|
5598 Method: CancelTestCases |
|
5599 |
|
5600 Description: Cancels all running testcases |
|
5601 |
|
5602 Parameters: None |
|
5603 |
|
5604 Return Values: None |
|
5605 |
|
5606 Errors/Exceptions: None. |
|
5607 |
|
5608 Status: Approved |
|
5609 |
|
5610 ------------------------------------------------------------------------------- |
|
5611 */ |
|
5612 void CTestRunner::CancelTestCases() |
|
5613 { |
|
5614 __TRACEFUNC(); |
|
5615 |
|
5616 TInt count = iTestCombiner->iTestCases.Count(); |
|
5617 for( TInt i=0; i < count; i++ ) |
|
5618 { |
|
5619 if( iTestCombiner->iTestCases[i]->State() == |
|
5620 CTCTestCase::ETestCaseRunning ) |
|
5621 { |
|
5622 iTestCombiner->iTestCases[i]->Cancel(); |
|
5623 } |
|
5624 } |
|
5625 |
|
5626 if( ( iTestCombiner->iRunningTests == 0 ) && |
|
5627 iTestCombiner->iSchedulerActive ) |
|
5628 { |
|
5629 // Stop execution |
|
5630 CActiveScheduler::Current()->Stop(); |
|
5631 iTestCombiner->iSchedulerActive = EFalse; |
|
5632 return; |
|
5633 } |
|
5634 |
|
5635 } |
|
5636 |
|
5637 /* |
|
5638 ------------------------------------------------------------------------------- |
|
5639 |
|
5640 Class: CTestRunner |
|
5641 |
|
5642 Method: SetRunnerActive |
|
5643 |
|
5644 Description: Set CTestRunner active and complete. |
|
5645 |
|
5646 Parameters: None. |
|
5647 |
|
5648 Return Values: None. |
|
5649 |
|
5650 Errors/Exceptions: None. |
|
5651 |
|
5652 Status: Approved |
|
5653 |
|
5654 ------------------------------------------------------------------------------- |
|
5655 */ |
|
5656 void CTestRunner::SetRunnerActive() |
|
5657 { |
|
5658 __TRACEFUNC(); |
|
5659 |
|
5660 if( IsActive() ) |
|
5661 { |
|
5662 __TRACE( KError, ( _L("Runner already active %d"), iState )); |
|
5663 User::Panic( KTestRunner, KErrInUse ); |
|
5664 } |
|
5665 |
|
5666 // Update state |
|
5667 iState = ERunnerRunning; |
|
5668 |
|
5669 iStatus = KRequestPending; |
|
5670 TRequestStatus* rs = &iStatus; |
|
5671 SetActive(); |
|
5672 User::RequestComplete( rs, KErrNone ); |
|
5673 |
|
5674 } |
|
5675 |
|
5676 /* |
|
5677 ------------------------------------------------------------------------------- |
|
5678 |
|
5679 Class: CTestRunner |
|
5680 |
|
5681 Method: CheckUnsetEvent |
|
5682 |
|
5683 Description: Check unset event. |
|
5684 |
|
5685 Parameters: None |
|
5686 |
|
5687 Return Values: ETrue: Unset event completed |
|
5688 EFalse: No unset event pending |
|
5689 |
|
5690 Errors/Exceptions: None |
|
5691 |
|
5692 Status: Approved |
|
5693 |
|
5694 ------------------------------------------------------------------------------- |
|
5695 */ |
|
5696 TBool CTestRunner::CheckUnsetEvent() |
|
5697 { |
|
5698 if( iEvent.Name().Length() == 0 ) |
|
5699 { |
|
5700 return EFalse; |
|
5701 } |
|
5702 |
|
5703 __TRACE( KMessage, (_L("Unset event completed") )); |
|
5704 // Check if some testmodule below has still event request pending |
|
5705 if( iTestCombiner->UnsetEvent( iEvent, iStatus ) == EFalse ) |
|
5706 { |
|
5707 // No event request pending |
|
5708 // then check other testmodules (may block) |
|
5709 TInt res = iTestCombiner->TestModuleIf().Event( iEvent ); |
|
5710 if( res != KErrNone ) |
|
5711 { |
|
5712 iTestCombiner->iResult = res; |
|
5713 } |
|
5714 |
|
5715 __TRACE( KPrint, (_L("Unset: Complete") ) ); |
|
5716 iEvent.SetName( _L("") ); |
|
5717 // Proceed testcase section execution |
|
5718 SetRunnerActive(); |
|
5719 } |
|
5720 else |
|
5721 { |
|
5722 iState = ERunnerWaitUnset; |
|
5723 // Wait for unset to complete |
|
5724 SetActive(); |
|
5725 } |
|
5726 |
|
5727 return ETrue; |
|
5728 } |
|
5729 |
|
5730 |
|
5731 /* |
|
5732 ------------------------------------------------------------------------------- |
|
5733 |
|
5734 Class: CTestRunner |
|
5735 |
|
5736 Method: ExecuteLoopL |
|
5737 |
|
5738 Description: Handle the loop keyword operations. |
|
5739 |
|
5740 Parameters: CStifItemParser* aItem: in: Pointer to parsed item object. |
|
5741 |
|
5742 Return Values: None. |
|
5743 |
|
5744 Errors/Exceptions: None. |
|
5745 |
|
5746 Status: Proposal |
|
5747 |
|
5748 ------------------------------------------------------------------------------- |
|
5749 */ |
|
5750 void CTestRunner::ExecuteLoopL( CStifItemParser* aItem ) |
|
5751 { |
|
5752 _LIT( KErrMsgLoopNestedLoop, "Loop: Nested loops are not supported " ); |
|
5753 _LIT( KErrMsgLoopInvalidLoopCountParam, "Loop: No loop count value given for loop or value has invalid format" ); |
|
5754 _LIT( KErrMsgLoopUnknownUnexpectedOption, "Loop: Unknown or unexpected loop option"); |
|
5755 _LIT( KErrMsgLoopPasslimitInvalidValue, "Loop: No passlimit value given for loop or value has invalid format" ); |
|
5756 _LIT( KErrMsgLoopPasslimitNotInRange, "Loop: Passlimit value is lower than 0 or higher than loop count" ); |
|
5757 __TRACEFUNC(); |
|
5758 |
|
5759 if( iLoopTimes != 0 ) |
|
5760 { |
|
5761 __TRACE( KError, (_L("ExecuteLoopL: Nested loop are not supported"))); |
|
5762 iRunErrorMessage = KErrMsgLoopNestedLoop; |
|
5763 User::Leave( KErrNotSupported ); |
|
5764 } |
|
5765 |
|
5766 iLoopTimes = 0; |
|
5767 iLoopCounter = 0; |
|
5768 iPasslimitEnabled = EFalse; |
|
5769 iTimedLoop = EFalse; |
|
5770 |
|
5771 if( aItem->GetNextInt( iLoopTimes ) != KErrNone ) |
|
5772 { |
|
5773 __TRACE( KError, (_L("ExecuteLoopL: No loop count value given for loop"))); |
|
5774 iRunErrorMessage = KErrMsgLoopInvalidLoopCountParam; |
|
5775 User::Leave( KErrArgument ); |
|
5776 } |
|
5777 __TRACE( KMessage, (_L("ExecuteLoopL: Loop for %d times" ), iLoopTimes ) ); |
|
5778 |
|
5779 //Check loop options |
|
5780 TPtrC option; |
|
5781 TInt ret = aItem->GetNextString(option); |
|
5782 if(ret == KErrNone) |
|
5783 { |
|
5784 if(option.Compare(_L("msec")) == 0) //time loop option |
|
5785 { |
|
5786 iTimedLoop = ETrue; |
|
5787 iStartTime.HomeTime(); |
|
5788 iExpectedLoopTime = TInt64(iLoopTimes) * TInt64(1000); //convert to micro seconds |
|
5789 __TRACE(KMessage, (_L("ExecuteLoopL: Timed loop for %d msec" ), iLoopTimes)); |
|
5790 |
|
5791 ret = aItem->GetNextString(option); //Get next option |
|
5792 } |
|
5793 } |
|
5794 |
|
5795 if(ret == KErrNone) |
|
5796 { |
|
5797 if(option.Compare(_L("passlimit")) == 0) //passlimit option |
|
5798 { |
|
5799 iPasslimit = 0; |
|
5800 if( aItem->GetNextInt( iPasslimit ) != KErrNone ) |
|
5801 { |
|
5802 __TRACE( KError, ( _L( "ExecuteLoopL: No passlimit value given for loop." ) ) ); |
|
5803 iRunErrorMessage = KErrMsgLoopPasslimitInvalidValue; |
|
5804 User::Leave( KErrArgument ); |
|
5805 } |
|
5806 __TRACE( KMessage, ( _L( "ExecuteLoopL: Passlimit set on %d" ), iPasslimit ) ); |
|
5807 //Check if passlimit has valid value |
|
5808 if(iPasslimit < 0 || (iPasslimit > iLoopTimes && !iTimedLoop)) |
|
5809 { |
|
5810 __TRACE( KError, ( _L( "ExecuteLoopL: Passlimit value is lower than 0 or higher than loop count." ) ) ); |
|
5811 iRunErrorMessage = KErrMsgLoopPasslimitNotInRange; |
|
5812 User::Leave( KErrArgument ); |
|
5813 } |
|
5814 iPasslimitEnabled = ETrue; |
|
5815 |
|
5816 ret = aItem->GetNextString(option); //Get next option |
|
5817 } |
|
5818 } |
|
5819 |
|
5820 if(ret == KErrNone) |
|
5821 { |
|
5822 __TRACE( KError, ( _L( "ExecuteLoopL: Unknown or unexpected loop option [%S]" ), &option ) ); |
|
5823 iRunErrorMessage = KErrMsgLoopUnknownUnexpectedOption; |
|
5824 User::Leave( KErrNotSupported ); |
|
5825 } |
|
5826 |
|
5827 iPassedIterationCnt = 0; |
|
5828 |
|
5829 iLoopStartPos = iTestCombiner->iSectionParser->GetPosition(); |
|
5830 } |
|
5831 |
|
5832 /* |
|
5833 ------------------------------------------------------------------------------- |
|
5834 |
|
5835 Class: CTestRunner |
|
5836 |
|
5837 Method: ExecuteEndLoopL |
|
5838 |
|
5839 Description: Handle the endloop keyword operations. |
|
5840 |
|
5841 Parameters: None. |
|
5842 |
|
5843 Return Values: TBool: Boolean value for indicate can testing continue. |
|
5844 |
|
5845 Errors/Exceptions: None. |
|
5846 |
|
5847 Status: Proposal |
|
5848 |
|
5849 ------------------------------------------------------------------------------- |
|
5850 */ |
|
5851 TBool CTestRunner::ExecuteEndLoopL() |
|
5852 { |
|
5853 __TRACEFUNC(); |
|
5854 |
|
5855 // Fail test case if there was no loop started |
|
5856 if(iTestCombiner->iLoopIsUsed == EFalse) |
|
5857 { |
|
5858 __TRACE(KError, (_L("Encountered \'endloop\' without \'loop\'. Aborting test case."))); |
|
5859 iTestCombiner->iResult = KErrGeneral; |
|
5860 iState = ERunnerError; |
|
5861 CancelTestCases(); |
|
5862 return ETrue; // Test case file parsing can be continue |
|
5863 } |
|
5864 |
|
5865 TBool iterationFailed = EFalse; //Has last iteration failed (at least one of test cases has failed) |
|
5866 |
|
5867 // First we check is all test cases that is set to run inside the loop |
|
5868 // completed. If not completed we wait until test case completes. |
|
5869 // Is some loop executions fails that is not allowed then loop execution |
|
5870 // will be stopped and error result is given to TestCombiner |
|
5871 |
|
5872 for( TInt s = 0; s < iTestCombiner->iTestCases.Count(); s++ ) |
|
5873 { |
|
5874 CTestCase* testCase = (CTestCase*)iTestCombiner->iTestCases[s]; |
|
5875 if( testCase == NULL ) |
|
5876 { |
|
5877 __TRACE( KError, (_L("ExecuteEndLoopL: CTestCase object not found") ) ); |
|
5878 return ETrue; |
|
5879 } |
|
5880 // Check that testCase object is allocated inside the loop |
|
5881 TBool isLoopTestCase( EFalse ); |
|
5882 for( TInt p = 0; p < iTestCombiner->iLoopAllocationArray.Count(); p++ ) |
|
5883 { |
|
5884 if( iTestCombiner->iLoopAllocationArray[p] == testCase ) |
|
5885 { |
|
5886 isLoopTestCase = ETrue; |
|
5887 break; |
|
5888 } |
|
5889 } |
|
5890 // testCase object is allocated inside loop |
|
5891 if( isLoopTestCase ) |
|
5892 { |
|
5893 // Test case is completed |
|
5894 //if( testCase->State() == CTCTestCase::ETestCaseCompleted ) |
|
5895 if(testCase->IsCompletelyFinished()) |
|
5896 { |
|
5897 // Check normal test result |
|
5898 if( testCase->iExpectedResultCategory == TFullTestResult:: ECaseExecuted ) |
|
5899 { |
|
5900 // Normal completion, check result |
|
5901 if( testCase->iResult.iTestResult.iResult != testCase->iExpectedResult ) |
|
5902 { |
|
5903 __TRACE( KPrint, ( _L( "Test failed, expect(%d) != result(%d)"), |
|
5904 testCase->iExpectedResult, |
|
5905 testCase->iResult.iTestResult.iResult )); |
|
5906 //If no passlimit is provided behave in old way |
|
5907 if( !iPasslimitEnabled ) |
|
5908 { |
|
5909 // We return the first error result as aResult |
|
5910 if( testCase->iResult.iTestResult.iResult != KErrNone ) |
|
5911 { |
|
5912 iTestCombiner->iScriptFailed = testCase->iResult.iCaseExecutionResultCode; |
|
5913 iTestCombiner->iScriptFailedDescription.Copy(testCase->iResult.iTestResult.iResultDes); |
|
5914 } |
|
5915 else |
|
5916 { |
|
5917 iTestCombiner->iScriptFailed = testCase->iResult.iCaseExecutionResultCode; |
|
5918 iTestCombiner->iScriptFailedDescription.Copy(_L("Test case has not finished with expected result (in loop).")); |
|
5919 } |
|
5920 |
|
5921 iState = ERunnerError; |
|
5922 CancelTestCases(); |
|
5923 return ETrue; // Test case file parsing can be continue |
|
5924 } |
|
5925 else |
|
5926 { |
|
5927 // Set flag that one of test cases has failed, so whole iteration is failed |
|
5928 iterationFailed = ETrue; |
|
5929 } |
|
5930 } |
|
5931 } |
|
5932 // Abnormal completion, i.e. panic, leave, exception or timeout |
|
5933 else |
|
5934 { |
|
5935 if( testCase->iResult.iCaseExecutionResultCode != testCase->iExpectedResult ) |
|
5936 { |
|
5937 __TRACE( KPrint, ( _L( "Test failed, expect errorcode(%d) != result(%d)"), |
|
5938 testCase->iExpectedResult, |
|
5939 testCase->iResult.iCaseExecutionResultCode ) ); |
|
5940 //If no passlimit is provided behave in old way |
|
5941 if( !iPasslimitEnabled ) |
|
5942 { |
|
5943 // We return the first error result as aResult |
|
5944 iTestCombiner->iScriptFailed = testCase->iResult.iCaseExecutionResultCode; |
|
5945 iTestCombiner->iScriptFailedDescription.Copy(_L("Test case has not finished with expected execution error (in loop).")); |
|
5946 |
|
5947 iState = ERunnerError; |
|
5948 // Return error from here |
|
5949 CancelTestCases(); |
|
5950 return ETrue; // Test case file parsing can be continue |
|
5951 } |
|
5952 else |
|
5953 { |
|
5954 // Set flag that one of test cases has failed, so whole iteration is failed |
|
5955 iterationFailed = ETrue; |
|
5956 } |
|
5957 } |
|
5958 |
|
5959 // Requested testcase is completed already, |
|
5960 // proceed testcase execution |
|
5961 __TRACE( KMessage, (_L("Already completed"))); |
|
5962 } |
|
5963 } // End "Test case is completed" |
|
5964 // Test case is running state, set to wait the test case complete |
|
5965 else if( testCase->State() == CTCTestCase::ETestCaseRunning ) |
|
5966 { |
|
5967 // Wait testcase to complete. If no id there should generate |
|
5968 // id that test case complete will be handled correctly |
|
5969 if( testCase->TestId().Length() == 0 ) |
|
5970 { |
|
5971 TPtrC generatedTestId( _L( "stif" ) ); |
|
5972 delete testCase->iTestId; |
|
5973 testCase->iTestId = generatedTestId.Alloc(); |
|
5974 } |
|
5975 iTestCombiner->iWaitTestCase.Copy( testCase->TestId() ); |
|
5976 // Stop testcase execution until testcase completed |
|
5977 iState = ERunnerWaitTestCase; |
|
5978 // Go to beginning of the endloop |
|
5979 User::LeaveIfError( |
|
5980 iTestCombiner->iSectionParser->SetPosition( iEndLoopStartPos )); |
|
5981 |
|
5982 // Testing is ongoing, test case file parsing cannot |
|
5983 // be continue. Next line will be run when some AO |
|
5984 // will be complete and allow parsing to continue |
|
5985 return EFalse; |
|
5986 } |
|
5987 else if(testCase->State() == CTCTestCase::ETestCaseCompleted) |
|
5988 { |
|
5989 // Go to beginning of the endloop |
|
5990 User::LeaveIfError(iTestCombiner->iSectionParser->SetPosition(iEndLoopStartPos)); |
|
5991 |
|
5992 // Testing is ongoing, test case file parsing cannot |
|
5993 // be continue. Next line will be run when some AO |
|
5994 // will be complete and allow parsing to continue |
|
5995 return ETrue; |
|
5996 } |
|
5997 else |
|
5998 { |
|
5999 // This should newer happen |
|
6000 __TRACE( KError, (_L("ExecuteEndLoopL: Illegal branch") ) ); |
|
6001 } |
|
6002 } |
|
6003 } // end for-loop |
|
6004 |
|
6005 iLoopCounter++; |
|
6006 __TRACE( KMessage, (_L("ExecuteLineL: Loop executed for %d times" ), |
|
6007 iLoopCounter ) ); |
|
6008 |
|
6009 //If passlimit (endurance) is enabled, we must check if any of test case in this iteration has failed |
|
6010 if( iPasslimitEnabled && !iterationFailed ) |
|
6011 { |
|
6012 iPassedIterationCnt++; |
|
6013 } |
|
6014 |
|
6015 TTime currTime; |
|
6016 currTime.HomeTime(); |
|
6017 //if( iLoopCounter < iLoopTimes ) |
|
6018 if(((!iTimedLoop) && (iLoopCounter < iLoopTimes)) //Normal loop |
|
6019 || |
|
6020 iTimedLoop && (currTime.MicroSecondsFrom(iStartTime) < iExpectedLoopTime)) //Timed loop |
|
6021 { |
|
6022 // Go to beginning of the loop |
|
6023 User::LeaveIfError( |
|
6024 iTestCombiner->iSectionParser->SetPosition( iLoopStartPos )); |
|
6025 } |
|
6026 else |
|
6027 { |
|
6028 // End looping |
|
6029 if( iPasslimitEnabled ) |
|
6030 { |
|
6031 __TRACE(KMessage, (_L("ExecuteLoopL: Loop executed. Iterations: %d, passed: %d, expected: %d"), iLoopCounter, iPassedIterationCnt, iPasslimit)); |
|
6032 } |
|
6033 |
|
6034 iLoopCounter = 0; |
|
6035 iLoopTimes = 0; |
|
6036 iLoopStartPos = 0; |
|
6037 // Loop related initializations |
|
6038 iTestCombiner->iLoopIsUsed = EFalse; |
|
6039 //--LOOPBUG-- Do not zero counter because there could be some test cases run before the loop (Stif-83) |
|
6040 //--LOOPBUG-- iTestCombiner->iRunningTests = 0; |
|
6041 |
|
6042 //If passlimit was given and number of passed test is less then expected, stop execution of combiner's test case |
|
6043 if( iPasslimitEnabled && iPassedIterationCnt < iPasslimit ) |
|
6044 { |
|
6045 __TRACE( KMessage, ( _L( "ExecuteLoopL: Loop has failed (passlimit). Finishing with KErrCompletion." ) ) ); |
|
6046 iTestCombiner->iScriptFailed = KErrCompletion; |
|
6047 iTestCombiner->iScriptFailedDescription = _L("Loop has not reached passlimit requirement."); |
|
6048 iState = ERunnerError; |
|
6049 CancelTestCases(); |
|
6050 return ETrue; // Test case file parsing can be continue |
|
6051 } |
|
6052 else if( iPasslimitEnabled && iPassedIterationCnt >= iPasslimit ) |
|
6053 { |
|
6054 __TRACE( KMessage, ( _L( "ExecuteLoopL: Loop has passed (passlimit)" ) ) ); |
|
6055 } |
|
6056 iPassedIterationCnt = 0; |
|
6057 iPasslimit = 0; |
|
6058 iPasslimitEnabled = EFalse; |
|
6059 } |
|
6060 |
|
6061 // Loop time is executed, free allocations that is allocated during loop |
|
6062 TInt a( 0 ); |
|
6063 TInt b( 0 ); |
|
6064 |
|
6065 for( b = 0; b < iTestCombiner->iLoopAllocationArray.Count(); b++ ) |
|
6066 { |
|
6067 //for( a = 0; a < iTestCombiner->iLoopAllocationArray.Count(); a++ ) |
|
6068 for( a = 0; a < iTestCombiner->iTestCases.Count(); a++ ) |
|
6069 { |
|
6070 if( a < iTestCombiner->iTestCases.Count() && iTestCombiner->iTestCases[a] == iTestCombiner->iLoopAllocationArray[b] ) |
|
6071 { |
|
6072 delete iTestCombiner->iTestCases[a]; |
|
6073 iTestCombiner->iTestCases.Remove( a ); |
|
6074 } |
|
6075 } |
|
6076 } |
|
6077 |
|
6078 for( b = 0; b < iTestCombiner->iLoopAllocationArray.Count(); b++ ) |
|
6079 { |
|
6080 //for( a = 0; a < iTestCombiner->iLoopAllocationArray.Count(); a++ ) |
|
6081 for( a = 0; a < iTestCombiner->iTestModules.Count(); a++ ) |
|
6082 { |
|
6083 if( a < iTestCombiner->iTestModules.Count() && iTestCombiner->iTestModules[a] == iTestCombiner->iLoopAllocationArray[b] ) |
|
6084 { |
|
6085 delete iTestCombiner->iTestModules[a]; |
|
6086 iTestCombiner->iTestModules.Remove( a ); |
|
6087 } |
|
6088 } |
|
6089 } |
|
6090 |
|
6091 for( b = 0; b < iTestCombiner->iLoopAllocationArray.Count(); b++ ) |
|
6092 { |
|
6093 //for( a = 0; a < iTestCombiner->iLoopAllocationArray.Count(); a++ ) |
|
6094 for( a = 0; a < iTestCombiner->iEventArray.Count(); a++ ) |
|
6095 { |
|
6096 if( a < iTestCombiner->iEventArray.Count() && iTestCombiner->iEventArray[a] == iTestCombiner->iLoopAllocationArray[b] ) |
|
6097 { |
|
6098 delete iTestCombiner->iEventArray[a]; |
|
6099 iTestCombiner->iEventArray.Remove( a ); |
|
6100 } |
|
6101 } |
|
6102 } |
|
6103 for( b = 0; b < iTestCombiner->iLoopAllocationArray.Count(); b++ ) |
|
6104 { |
|
6105 //for( a = 0; a < iTestCombiner->iLoopAllocationArray.Count(); a++ ) |
|
6106 for( a = 0; a < iTestCombiner->iSlaveArray.Count(); a++ ) |
|
6107 { |
|
6108 if( a < iTestCombiner->iSlaveArray.Count() && iTestCombiner->iSlaveArray[a] == iTestCombiner->iLoopAllocationArray[b] ) |
|
6109 { |
|
6110 delete iTestCombiner->iSlaveArray[a]; |
|
6111 iTestCombiner->iSlaveArray.Remove( a ); |
|
6112 } |
|
6113 } |
|
6114 } |
|
6115 for( b = 0; b < iTestCombiner->iLoopAllocationArray.Count(); b++ ) |
|
6116 { |
|
6117 //for( a = 0; a < iTestCombiner->iLoopAllocationArray.Count(); a++ ) |
|
6118 for( a = 0; a < iTestCombiner->iSendReceive.Count(); a++ ) |
|
6119 { |
|
6120 if( a < iTestCombiner->iSendReceive.Count() && iTestCombiner->iSendReceive[a] == iTestCombiner->iLoopAllocationArray[b] ) |
|
6121 { |
|
6122 delete iTestCombiner->iSendReceive[a]; |
|
6123 iTestCombiner->iSendReceive.Remove( a ); |
|
6124 } |
|
6125 } |
|
6126 } |
|
6127 |
|
6128 // Test operation can be continued |
|
6129 return ETrue; // Test case file parsing can be continue |
|
6130 |
|
6131 } |
|
6132 |
|
6133 /* |
|
6134 ------------------------------------------------------------------------------- |
|
6135 |
|
6136 DESCRIPTION |
|
6137 |
|
6138 This module contains the implementation of CRemoteTimer class |
|
6139 member functions. |
|
6140 |
|
6141 ------------------------------------------------------------------------------- |
|
6142 */ |
|
6143 // MACROS |
|
6144 #ifdef LOGGER |
|
6145 #undef LOGGER |
|
6146 #endif |
|
6147 #define LOGGER iTestRunner->iTestCombiner->iLog |
|
6148 |
|
6149 // ================= MEMBER FUNCTIONS ========================================= |
|
6150 |
|
6151 /* |
|
6152 ------------------------------------------------------------------------------- |
|
6153 |
|
6154 Class: CRemoteTimer |
|
6155 |
|
6156 Method: CRemoteTimer |
|
6157 |
|
6158 Description: Default constructor |
|
6159 |
|
6160 C++ default constructor can NOT contain any code, that |
|
6161 might leave. |
|
6162 |
|
6163 Parameters: CTestRunner* aTestRunner: in: Backpointer to CTestRunner |
|
6164 |
|
6165 Return Values: None |
|
6166 |
|
6167 Errors/Exceptions: None |
|
6168 |
|
6169 Status: Proposal |
|
6170 |
|
6171 ------------------------------------------------------------------------------- |
|
6172 */ |
|
6173 CRemoteTimer::CRemoteTimer( CTestCombiner* aTestCombiner ): |
|
6174 CActive( CActive::EPriorityLow ), // Executed with lowest priority |
|
6175 iState( ETimerIdle ), |
|
6176 iTestCombiner( aTestCombiner ) |
|
6177 { |
|
6178 CActiveScheduler::Add( this ); |
|
6179 |
|
6180 } |
|
6181 |
|
6182 /* |
|
6183 ------------------------------------------------------------------------------- |
|
6184 |
|
6185 Class: CRemoteTimer |
|
6186 |
|
6187 Method: ConstructL |
|
6188 |
|
6189 Description: Symbian OS second phase constructor |
|
6190 |
|
6191 Symbian OS default constructor can leave. |
|
6192 |
|
6193 Parameters: None |
|
6194 |
|
6195 Return Values: None |
|
6196 |
|
6197 Errors/Exceptions: None |
|
6198 |
|
6199 Status: Proposal |
|
6200 |
|
6201 ------------------------------------------------------------------------------- |
|
6202 */ |
|
6203 void CRemoteTimer::ConstructL() |
|
6204 { |
|
6205 |
|
6206 iTimer.CreateLocal(); |
|
6207 |
|
6208 } |
|
6209 |
|
6210 /* |
|
6211 ------------------------------------------------------------------------------- |
|
6212 |
|
6213 Class: CRemoteTimer |
|
6214 |
|
6215 Method: NewL |
|
6216 |
|
6217 Description: Two-phased constructor. |
|
6218 |
|
6219 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to CTestCombiner |
|
6220 |
|
6221 Return Values: CRemoteTimer*: new object |
|
6222 |
|
6223 Errors/Exceptions: Leaves if new or ConstructL leaves |
|
6224 |
|
6225 Status: Proposal |
|
6226 |
|
6227 ------------------------------------------------------------------------------- |
|
6228 */ |
|
6229 |
|
6230 CRemoteTimer* CRemoteTimer::NewL( CTestCombiner* aTestCombiner ) |
|
6231 { |
|
6232 |
|
6233 CRemoteTimer* self = new (ELeave) CRemoteTimer( aTestCombiner ); |
|
6234 |
|
6235 CleanupStack::PushL( self ); |
|
6236 self->ConstructL(); |
|
6237 CleanupStack::Pop(); |
|
6238 |
|
6239 return self; |
|
6240 |
|
6241 } |
|
6242 |
|
6243 /* |
|
6244 ------------------------------------------------------------------------------- |
|
6245 |
|
6246 Class: CRemoteTimer |
|
6247 |
|
6248 Method: ~CRemoteTimer |
|
6249 |
|
6250 Description: Destructor |
|
6251 |
|
6252 Parameters: None |
|
6253 |
|
6254 Return Values: None |
|
6255 |
|
6256 Errors/Exceptions: None |
|
6257 |
|
6258 Status: Proposal |
|
6259 |
|
6260 ------------------------------------------------------------------------------- |
|
6261 */ |
|
6262 |
|
6263 CRemoteTimer::~CRemoteTimer() |
|
6264 { |
|
6265 |
|
6266 Cancel(); |
|
6267 |
|
6268 iTimer.Close(); |
|
6269 |
|
6270 } |
|
6271 |
|
6272 /* |
|
6273 ------------------------------------------------------------------------------- |
|
6274 |
|
6275 Class: CRemoteTimer |
|
6276 |
|
6277 Method: RunL |
|
6278 |
|
6279 Description: Derived from CActive, handles testcase execution. |
|
6280 |
|
6281 Parameters: None. |
|
6282 |
|
6283 Return Values: None. |
|
6284 |
|
6285 Errors/Exceptions: Leaves on error situations. |
|
6286 |
|
6287 Status: Proposal |
|
6288 |
|
6289 ------------------------------------------------------------------------------- |
|
6290 */ |
|
6291 void CRemoteTimer::RunL() |
|
6292 { |
|
6293 |
|
6294 if( iState != ETimerPending ) |
|
6295 { |
|
6296 User::Panic( KRemoteTimer, KErrGeneral ); |
|
6297 } |
|
6298 |
|
6299 if( iStatus.Int() != KErrNone ) |
|
6300 { |
|
6301 User::Panic( KRemoteTimer, KErrDied ); |
|
6302 } |
|
6303 |
|
6304 iState = ETimerIdle; |
|
6305 |
|
6306 iTestCombiner->RemoteTimeout(); |
|
6307 |
|
6308 } |
|
6309 |
|
6310 /* |
|
6311 ------------------------------------------------------------------------------- |
|
6312 |
|
6313 Class: CRemoteTimer |
|
6314 |
|
6315 Method: DoCancel |
|
6316 |
|
6317 Description: Derived from CActive handles the Cancel |
|
6318 |
|
6319 Parameters: None. |
|
6320 |
|
6321 Return Values: None. |
|
6322 |
|
6323 Errors/Exceptions: None. |
|
6324 |
|
6325 Status: Draft |
|
6326 |
|
6327 ------------------------------------------------------------------------------- |
|
6328 */ |
|
6329 void CRemoteTimer::DoCancel() |
|
6330 { |
|
6331 iTimer.Cancel(); |
|
6332 iState = ETimerIdle; |
|
6333 |
|
6334 } |
|
6335 |
|
6336 /* |
|
6337 ------------------------------------------------------------------------------- |
|
6338 |
|
6339 Class: CRemoteTimer |
|
6340 |
|
6341 Method: SetTimerActive |
|
6342 |
|
6343 Description: Starts timer |
|
6344 |
|
6345 Parameters: TTimeIntervalMicroSeconds32 anInterval: in: Timeout |
|
6346 |
|
6347 Return Values: None. |
|
6348 |
|
6349 Errors/Exceptions: None. |
|
6350 |
|
6351 Status: Draft |
|
6352 |
|
6353 ------------------------------------------------------------------------------- |
|
6354 */ |
|
6355 void CRemoteTimer::SetTimerActive( TTimeIntervalMicroSeconds32 anInterval ) |
|
6356 { |
|
6357 if( iState != ETimerIdle ) |
|
6358 { |
|
6359 User::Panic( KRemoteTimer, KErrGeneral ); |
|
6360 } |
|
6361 |
|
6362 iState = ETimerPending; |
|
6363 |
|
6364 iTimer.After( iStatus, anInterval ); |
|
6365 SetActive(); |
|
6366 |
|
6367 } |
|
6368 |
|
6369 /* |
|
6370 ------------------------------------------------------------------------------- |
|
6371 |
|
6372 DESCRIPTION |
|
6373 |
|
6374 This module contains the implementation of CRemoteReceiver class |
|
6375 member functions. |
|
6376 |
|
6377 ------------------------------------------------------------------------------- |
|
6378 */ |
|
6379 // MACROS |
|
6380 #ifdef LOGGER |
|
6381 #undef LOGGER |
|
6382 #endif |
|
6383 #define LOGGER iTestCombiner->iLog |
|
6384 |
|
6385 // ================= MEMBER FUNCTIONS ========================================= |
|
6386 |
|
6387 /* |
|
6388 ------------------------------------------------------------------------------- |
|
6389 |
|
6390 Class: CRemoteReceiver |
|
6391 |
|
6392 Method: CRemoteReceiver |
|
6393 |
|
6394 Description: Default constructor |
|
6395 |
|
6396 C++ default constructor can NOT contain any code, that |
|
6397 might leave. |
|
6398 |
|
6399 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to CTestCombiner |
|
6400 |
|
6401 Return Values: None |
|
6402 |
|
6403 Errors/Exceptions: None |
|
6404 |
|
6405 Status: Proposal |
|
6406 |
|
6407 ------------------------------------------------------------------------------- |
|
6408 */ |
|
6409 CRemoteReceiver::CRemoteReceiver( CTestCombiner* aTestCombiner ): |
|
6410 CActive( CActive::EPriorityStandard ), |
|
6411 iState( EReceiverIdle ), |
|
6412 iTestCombiner( aTestCombiner ) |
|
6413 { |
|
6414 CActiveScheduler::Add( this ); |
|
6415 __TRACEFUNC(); |
|
6416 |
|
6417 } |
|
6418 |
|
6419 /* |
|
6420 ------------------------------------------------------------------------------- |
|
6421 |
|
6422 Class: CRemoteReceiver |
|
6423 |
|
6424 Method: ConstructL |
|
6425 |
|
6426 Description: Symbian OS second phase constructor |
|
6427 |
|
6428 Symbian OS default constructor can leave. |
|
6429 |
|
6430 Parameters: None |
|
6431 |
|
6432 Return Values: None |
|
6433 |
|
6434 Errors/Exceptions: None |
|
6435 |
|
6436 Status: Proposal |
|
6437 |
|
6438 ------------------------------------------------------------------------------- |
|
6439 */ |
|
6440 void CRemoteReceiver::ConstructL() |
|
6441 { |
|
6442 |
|
6443 |
|
6444 } |
|
6445 |
|
6446 /* |
|
6447 ------------------------------------------------------------------------------- |
|
6448 |
|
6449 Class: CRemoteReceiver |
|
6450 |
|
6451 Method: NewL |
|
6452 |
|
6453 Description: Two-phased constructor. |
|
6454 |
|
6455 Parameters: CTestCombiner* aTestCombiner: in: Backpointer to CTestCombiner |
|
6456 |
|
6457 Return Values: CRemoteReceiver*: new object |
|
6458 |
|
6459 Errors/Exceptions: Leaves if new or ConstructL leaves |
|
6460 |
|
6461 Status: Proposal |
|
6462 |
|
6463 ------------------------------------------------------------------------------- |
|
6464 */ |
|
6465 |
|
6466 CRemoteReceiver* CRemoteReceiver::NewL( CTestCombiner* aTestCombiner ) |
|
6467 { |
|
6468 CRemoteReceiver* self = new (ELeave) CRemoteReceiver( aTestCombiner ); |
|
6469 |
|
6470 CleanupStack::PushL( self ); |
|
6471 self->ConstructL(); |
|
6472 CleanupStack::Pop(); |
|
6473 |
|
6474 return self; |
|
6475 } |
|
6476 |
|
6477 /* |
|
6478 ------------------------------------------------------------------------------- |
|
6479 |
|
6480 Class: CRemoteReceiver |
|
6481 |
|
6482 Method: ~CRemoteReceiver |
|
6483 |
|
6484 Description: Destructor |
|
6485 |
|
6486 Parameters: None |
|
6487 |
|
6488 Return Values: None |
|
6489 |
|
6490 Errors/Exceptions: None |
|
6491 |
|
6492 Status: Proposal |
|
6493 |
|
6494 ------------------------------------------------------------------------------- |
|
6495 */ |
|
6496 |
|
6497 CRemoteReceiver::~CRemoteReceiver() |
|
6498 { |
|
6499 __TRACEFUNC(); |
|
6500 Cancel(); |
|
6501 |
|
6502 |
|
6503 } |
|
6504 |
|
6505 /* |
|
6506 ------------------------------------------------------------------------------- |
|
6507 |
|
6508 Class: CRemoteReceiver |
|
6509 |
|
6510 Method: StartL |
|
6511 |
|
6512 Description: Activates receiving. |
|
6513 |
|
6514 Parameters: None. |
|
6515 |
|
6516 Return Values: None. |
|
6517 |
|
6518 Errors/Exceptions: None. |
|
6519 |
|
6520 Status: Proposal |
|
6521 |
|
6522 ------------------------------------------------------------------------------- |
|
6523 */ |
|
6524 void CRemoteReceiver::Start() |
|
6525 { |
|
6526 __TRACEFUNC(); |
|
6527 __ASSERT_ALWAYS( iState == EReceiverIdle, |
|
6528 User::Panic( KRemoteReceiver, KErrGeneral ) ); |
|
6529 iState = EReceiverPending; |
|
6530 |
|
6531 iTestCombiner->TestModuleIf().RemoteReceive( iRemoteMsg, iStatus ); |
|
6532 SetActive(); |
|
6533 |
|
6534 } |
|
6535 |
|
6536 /* |
|
6537 ------------------------------------------------------------------------------- |
|
6538 |
|
6539 Class: CRemoteReceiver |
|
6540 |
|
6541 Method: RunL |
|
6542 |
|
6543 Description: Derived from CActive, handles testcase execution. |
|
6544 |
|
6545 Parameters: None. |
|
6546 |
|
6547 Return Values: None. |
|
6548 |
|
6549 Errors/Exceptions: Leaves on error situations. |
|
6550 |
|
6551 Status: Proposal |
|
6552 |
|
6553 ------------------------------------------------------------------------------- |
|
6554 */ |
|
6555 void CRemoteReceiver::RunL() |
|
6556 { |
|
6557 __TRACEFUNC(); |
|
6558 |
|
6559 __ASSERT_ALWAYS( iState == EReceiverPending, |
|
6560 User::Panic( KRemoteReceiver, KErrGeneral ) ); |
|
6561 iState = EReceiverIdle; |
|
6562 |
|
6563 iTestCombiner->ReceiveResponse( iRemoteMsg ); |
|
6564 |
|
6565 } |
|
6566 |
|
6567 /* |
|
6568 ------------------------------------------------------------------------------- |
|
6569 |
|
6570 Class: CRemoteReceiver |
|
6571 |
|
6572 Method: DoCancel |
|
6573 |
|
6574 Description: Derived from CActive handles the Cancel |
|
6575 |
|
6576 Parameters: None. |
|
6577 |
|
6578 Return Values: None. |
|
6579 |
|
6580 Errors/Exceptions: None. |
|
6581 |
|
6582 Status: Proposal |
|
6583 |
|
6584 ------------------------------------------------------------------------------- |
|
6585 */ |
|
6586 void CRemoteReceiver::DoCancel() |
|
6587 { |
|
6588 __TRACEFUNC(); |
|
6589 |
|
6590 iTestCombiner->TestModuleIf().RemoteReceiveCancel(); |
|
6591 |
|
6592 } |
|
6593 |
|
6594 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
6595 |
|
6596 /* |
|
6597 ------------------------------------------------------------------------------- |
|
6598 |
|
6599 Function: LibEntryL |
|
6600 |
|
6601 Description: Polymorphic Dll Entry Point |
|
6602 |
|
6603 Parameters: None. |
|
6604 |
|
6605 Return Values: CTestCombiner*: pointer to new CTestCombiner |
|
6606 |
|
6607 Errors/Exceptions: Leaves if NewL leaves. |
|
6608 |
|
6609 Status: Approved |
|
6610 |
|
6611 ------------------------------------------------------------------------------- |
|
6612 */ |
|
6613 |
|
6614 EXPORT_C CTestCombiner* LibEntryL() |
|
6615 { |
|
6616 return CTestCombiner::NewL(); |
|
6617 } |
|
6618 |
|
6619 // End of File |