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