|
1 /* |
|
2 * Copyright (c) 2005-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 // For TEF |
|
20 #include "scriptengine.h" |
|
21 #include <test/testexecuteclient.h> |
|
22 #include <test/testexecutelogger.h> |
|
23 #include "testwatcher.h" |
|
24 #include "version.h" |
|
25 #include "tefutils.h" |
|
26 #include <f32file.h> |
|
27 #include <test/wrapperutilsplugin.h> |
|
28 // For STIF |
|
29 #include <StifTestInterface.h> |
|
30 #include "teftestmodule.h" |
|
31 #include "SettingServerClient.h" |
|
32 #include "logging.h" |
|
33 |
|
34 GLDEF_D TInt CScriptControl::commentedCommandsCount; |
|
35 GLDEF_D TInt CScriptControl::iRunScriptFailCount; |
|
36 |
|
37 |
|
38 // EXTERNAL DATA STRUCTURES |
|
39 //extern ?external_data; |
|
40 |
|
41 // EXTERNAL FUNCTION PROTOTYPES |
|
42 //extern ?external_function( ?arg_type,?arg_type ); |
|
43 |
|
44 // CONSTANTS |
|
45 //const ?type ?constant_var = ?constant; |
|
46 |
|
47 // MACROS |
|
48 //#define ?macro ?macro_def |
|
49 |
|
50 // LOCAL CONSTANTS AND MACROS |
|
51 //const ?type ?constant_var = ?constant; |
|
52 //#define ?macro_name ?macro_def |
|
53 |
|
54 // MODULE DATA STRUCTURES |
|
55 //enum ?declaration |
|
56 //typedef ?declaration |
|
57 |
|
58 // LOCAL FUNCTION PROTOTYPES |
|
59 //?type ?function_name( ?arg_type, ?arg_type ); |
|
60 |
|
61 // FORWARD DECLARATIONS |
|
62 //class ?FORWARD_CLASSNAME; |
|
63 |
|
64 // ============================= LOCAL FUNCTIONS =============================== |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // ?function_name ?description. |
|
68 // ?description |
|
69 // Returns: ?value_1: ?description |
|
70 // ?value_n: ?description_line1 |
|
71 // ?description_line2 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 /* |
|
75 ?type ?function_name( |
|
76 ?arg_type arg, // ?description |
|
77 ?arg_type arg) // ?description |
|
78 { |
|
79 |
|
80 ?code // ?comment |
|
81 |
|
82 // ?comment |
|
83 ?code |
|
84 } |
|
85 */ |
|
86 |
|
87 // ============================ MEMBER FUNCTIONS =============================== |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CTEFTestModule::CTEFTestModule |
|
91 // C++ default constructor can NOT contain any code, that |
|
92 // might leave. |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 CTEFTestModule::CTEFTestModule() |
|
96 { |
|
97 |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CTEFTestModule::ConstructL |
|
102 // Symbian 2nd phase constructor can leave. |
|
103 // Note: If OOM test case uses STIF Logger, then STIF Logger must be created |
|
104 // with static buffer size parameter (aStaticBufferSize). Otherwise Logger |
|
105 // allocates memory from heap and therefore causes error situations with OOM |
|
106 // testing. For more information about STIF Logger construction, see STIF Users |
|
107 // Guide. |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CTEFTestModule::ConstructL() |
|
111 { |
|
112 //Read logger settings to check whether test case name is to be |
|
113 //appended to log file name. |
|
114 RSettingServer settingServer; |
|
115 TInt ret = settingServer.Connect(); |
|
116 if(ret != KErrNone) |
|
117 { |
|
118 User::Leave(ret); |
|
119 } |
|
120 // Struct to StifLogger settigs. |
|
121 TLoggerSettings loggerSettings; |
|
122 // Parse StifLogger defaults from STIF initialization file. |
|
123 ret = settingServer.GetLoggerSettings(loggerSettings); |
|
124 if(ret != KErrNone) |
|
125 { |
|
126 User::Leave(ret); |
|
127 } |
|
128 // Close Setting server session |
|
129 settingServer.Close(); |
|
130 iAddTestCaseTitleToLogName = loggerSettings.iAddTestCaseTitle; |
|
131 |
|
132 iStdLog = CStifLogger::NewL( KTEFTestModuleLogPath, |
|
133 KTEFTestModuleLogFile); |
|
134 iLog = iStdLog; |
|
135 |
|
136 iVersionLogged = EFalse; |
|
137 |
|
138 iCfg_tcs = EOFF; |
|
139 iCfg_Debug = EFalse; |
|
140 iCfg_SeparateLog = EFalse; |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CTEFTestModule::NewL |
|
145 // Two-phased constructor. |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 CTEFTestModule* CTEFTestModule::NewL() |
|
149 { |
|
150 CTEFTestModule* self = new (ELeave) CTEFTestModule; |
|
151 |
|
152 CleanupStack::PushL( self ); |
|
153 self->ConstructL(); |
|
154 CleanupStack::Pop(); |
|
155 |
|
156 return self; |
|
157 |
|
158 } |
|
159 |
|
160 // Destructor |
|
161 CTEFTestModule::~CTEFTestModule() |
|
162 { |
|
163 iLog = NULL; |
|
164 delete iStdLog; |
|
165 iStdLog = NULL; |
|
166 delete iTCLog; |
|
167 iTCLog = NULL; |
|
168 iArray_ScriptFilePaths.Close(); |
|
169 iArray_Cfg_TcsData.Close(); |
|
170 } |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // CTEFTestModule::InitL |
|
174 // InitL is used to initialize the Test Module. |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CTEFTestModule::InitL( |
|
178 TFileName& /*aIniFile*/, |
|
179 TBool /*aFirstTime*/ ) |
|
180 { |
|
181 return KErrNone; |
|
182 |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CTEFTestModule::CreateTitleLoggerL |
|
187 // Check for settings and create logger with test case title in file name. |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 void CTEFTestModule::CreateTitleLoggerL(void) |
|
191 { |
|
192 //Open new log file with test case title in file name |
|
193 if(iAddTestCaseTitleToLogName) |
|
194 { |
|
195 // Check if there is no test case logger already created. |
|
196 if(iTCLog) |
|
197 { |
|
198 delete iTCLog; |
|
199 iTCLog = NULL; |
|
200 } |
|
201 |
|
202 TFileName logFileName; |
|
203 TName title; |
|
204 TestModuleIf().GetTestCaseTitleL(title); |
|
205 |
|
206 logFileName.Format(KTEFTestModuleLogFileWithTitle, &title); |
|
207 |
|
208 iTCLog = CStifLogger::NewL(KTEFTestModuleLogPath, |
|
209 logFileName); |
|
210 iLog = iTCLog; |
|
211 } |
|
212 } |
|
213 |
|
214 // ----------------------------------------------------------------------------- |
|
215 // CTEFTestModule::CreateStdLoggerL |
|
216 // Check for logger settings and create standard logger. |
|
217 // ----------------------------------------------------------------------------- |
|
218 // |
|
219 void CTEFTestModule::DeleteTitleLogger(void) |
|
220 { |
|
221 //Delete title logger |
|
222 if(iAddTestCaseTitleToLogName) |
|
223 { |
|
224 iLog = iStdLog; |
|
225 delete iTCLog; |
|
226 iTCLog = NULL; |
|
227 } |
|
228 } |
|
229 |
|
230 // ----------------------------------------------------------------------------- |
|
231 // CTEFTestModule::GetTestCasesL |
|
232 // GetTestCases is used to inquire test cases from the Test Module. Test |
|
233 // cases are stored to array of test cases. The Test Framework will be |
|
234 // the owner of the data in the RPointerArray after GetTestCases return |
|
235 // and it does the memory deallocation. |
|
236 // ----------------------------------------------------------------------------- |
|
237 // |
|
238 TInt CTEFTestModule::GetTestCasesL( |
|
239 const TFileName& aConfig, |
|
240 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
241 { |
|
242 iLog->Log(_L("GetTestCasesL")); |
|
243 TInt ret = KErrNone; |
|
244 |
|
245 TRAPD(err, ret = ParseTEFTestCfgFileL(aConfig, aTestCases)); |
|
246 if(err != KErrNone) |
|
247 { |
|
248 //ret = KErrNotFound; |
|
249 _LIT(KErrLog, "Error in given test configuration file %S. Error = %d."); |
|
250 iLog->Log(CStifLogger::ERed, KErrLog, &aConfig, ret); |
|
251 } |
|
252 |
|
253 return ret; |
|
254 } |
|
255 |
|
256 // ----------------------------------------------------------------------------- |
|
257 // CTEFTestModule::RunTestCaseL |
|
258 // RunTestCaseL is used to run an individual test case specified |
|
259 // by aTestCase. Test cases that can be run may be requested from |
|
260 // Test Module by GetTestCases method before calling RunTestCase. |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 TInt CTEFTestModule::RunTestCaseL( |
|
264 const TInt aCaseNumber, |
|
265 const TFileName& /*aConfig*/, |
|
266 TTestResult& aResult ) |
|
267 { |
|
268 iLog->Log(_L("RunTestCaseL")); |
|
269 SendTestModuleVersion(); |
|
270 |
|
271 CreateTitleLoggerL(); |
|
272 //Test case implementation or function call here |
|
273 TRAPD(err, TEFInitialize() ); |
|
274 __ASSERT_ALWAYS(!err, User::Panic(KTestExecuteName,err)); |
|
275 |
|
276 #if (defined __DATA_CAGING__) |
|
277 // Platform security hooks |
|
278 RProcess().DataCaging(RProcess::EDataCagingOn); |
|
279 RProcess().SecureApi(RProcess::ESecureApiOn); |
|
280 #endif |
|
281 |
|
282 CActiveScheduler* sched = new (ELeave) CActiveScheduler(); |
|
283 CleanupStack::PushL(sched); |
|
284 CActiveScheduler::Install(sched); |
|
285 |
|
286 if(!sched) |
|
287 { |
|
288 __RDEBUG( (_L("Error: TEFTestModule.dll, Error in getting current active scheduler.") ) ); |
|
289 iLog->Log(CStifLogger::ERed, _L("Error: TEFTestModule.dll, Error in getting current active scheduler.")); |
|
290 User::Panic(_L("TEFTestModule"), -2); |
|
291 } |
|
292 |
|
293 TInt scriptCount = iArray_ScriptFilePaths.Count(); |
|
294 TInt tcsDataCount = iArray_Cfg_TcsData.Count(); |
|
295 |
|
296 if(aCaseNumber > scriptCount) |
|
297 { |
|
298 __RDEBUG( (_L("Error: Case number to run is bigger than expected.") ) ); |
|
299 iLog->Log(CStifLogger::ERed, _L("Error: Case number to run is bigger than expected.")); |
|
300 // Cleanup the scheduler object |
|
301 CleanupStack::PopAndDestroy(sched); |
|
302 DeleteTitleLogger(); |
|
303 User::Leave(KErrNotFound); |
|
304 } |
|
305 |
|
306 TRAPD(errRun, RunScriptL( sched, |
|
307 *(iArray_ScriptFilePaths[aCaseNumber-1]), |
|
308 *(iArray_Cfg_TcsData[aCaseNumber-1]) |
|
309 ) ); |
|
310 if (errRun != KErrNone) |
|
311 { |
|
312 __RDEBUG( (_L("Run script leave. code=%d"),errRun) ); |
|
313 iLog->Log(CStifLogger::ERed, _L("Run script leave. code=%d"),errRun); |
|
314 } |
|
315 |
|
316 // Cleanup the scheduler object |
|
317 CleanupStack::PopAndDestroy(sched); |
|
318 |
|
319 aResult.SetResult( errRun, *(iArray_ScriptFilePaths[aCaseNumber-1]) ); |
|
320 |
|
321 // Test case was executed |
|
322 DeleteTitleLogger(); |
|
323 return KErrNone; |
|
324 } |
|
325 |
|
326 // ----------------------------------------------------------------------------- |
|
327 // CTEFTestModule::OOMTestQueryL |
|
328 // Used to check if a particular test case should be run in OOM conditions and |
|
329 // which memory allocations should fail. |
|
330 // |
|
331 // NOTE: This method is virtual and must be implemented only if test case |
|
332 // should be executed using OOM conditions. |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 TBool CTEFTestModule::OOMTestQueryL( |
|
336 const TFileName& /* aTestCaseFile */, |
|
337 const TInt /* aCaseNumber */, |
|
338 TOOMFailureType& /* aFailureType */, |
|
339 TInt& /* aFirstMemFailure */, |
|
340 TInt& /* aLastMemFailure */ ) |
|
341 { |
|
342 _LIT( KOOMTestQueryL, "CTEFTestModule::OOMTestQueryL" ); |
|
343 iLog->Log( KOOMTestQueryL ); |
|
344 |
|
345 return EFalse; |
|
346 |
|
347 } |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CTEFTestModule::OOMTestInitializeL |
|
351 // Used to perform the test environment setup for a particular OOM test case. |
|
352 // Test Modules may use the initialization file to read parameters for Test |
|
353 // Module initialization but they can also have their own configure file or |
|
354 // some other routine to initialize themselves. |
|
355 // |
|
356 // NOTE: This method is virtual and must be implemented only if test case |
|
357 // should be executed using OOM conditions. |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void CTEFTestModule::OOMTestInitializeL( |
|
361 const TFileName& /* aTestCaseFile */, |
|
362 const TInt /* aCaseNumber */ ) |
|
363 { |
|
364 } |
|
365 |
|
366 // ----------------------------------------------------------------------------- |
|
367 // CTEFTestModule::OOMHandleWarningL |
|
368 // In some cases the heap memory allocation should be skipped, either due to |
|
369 // problems in the OS code or components used by the code being tested, or even |
|
370 // inside the tested components which are implemented this way on purpose (by |
|
371 // design), so it is important to give the tester a way to bypass allocation |
|
372 // failures. |
|
373 // |
|
374 // NOTE: This method is virtual and must be implemented only if test case |
|
375 // should be executed using OOM conditions. |
|
376 // ----------------------------------------------------------------------------- |
|
377 // |
|
378 void CTEFTestModule::OOMHandleWarningL( |
|
379 const TFileName& /* aTestCaseFile */, |
|
380 const TInt /* aCaseNumber */, |
|
381 TInt& /* aFailNextValue */ ) |
|
382 { |
|
383 } |
|
384 |
|
385 // ----------------------------------------------------------------------------- |
|
386 // CTEFTestModule::OOMTestFinalizeL |
|
387 // Used to perform the test environment cleanup for a particular OOM test case. |
|
388 // |
|
389 // NOTE: This method is virtual and must be implemented only if test case |
|
390 // should be executed using OOM conditions. |
|
391 // ----------------------------------------------------------------------------- |
|
392 // |
|
393 void CTEFTestModule::OOMTestFinalizeL( |
|
394 const TFileName& /* aTestCaseFile */, |
|
395 const TInt /* aCaseNumber */ ) |
|
396 { |
|
397 } |
|
398 |
|
399 //----------------------------------------------------------------------------- |
|
400 // CTemplateScriptTEFTestModule::SendTestModuleVersion |
|
401 // Method used to send version of test module |
|
402 //----------------------------------------------------------------------------- |
|
403 // |
|
404 void CTEFTestModule::SendTestModuleVersion() |
|
405 { |
|
406 if(iVersionLogged) |
|
407 { |
|
408 return; |
|
409 } |
|
410 |
|
411 TVersion moduleVersion; |
|
412 moduleVersion.iMajor = TEST_MODULE_VERSION_MAJOR; |
|
413 moduleVersion.iMinor = TEST_MODULE_VERSION_MINOR; |
|
414 moduleVersion.iBuild = TEST_MODULE_VERSION_BUILD; |
|
415 |
|
416 TFileName moduleName; |
|
417 moduleName = _L("TEFTestModule.dll"); |
|
418 |
|
419 TBool newVersionOfMethod = ETrue; |
|
420 TestModuleIf().SendTestModuleVersion(moduleVersion, moduleName, newVersionOfMethod); |
|
421 iVersionLogged = ETrue; |
|
422 } |
|
423 |
|
424 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
425 |
|
426 // ----------------------------------------------------------------------------- |
|
427 // LibEntryL is a polymorphic Dll entry point |
|
428 // Returns: CTestModuleBase*: Pointer to Test Module object |
|
429 // ----------------------------------------------------------------------------- |
|
430 // |
|
431 EXPORT_C CTestModuleBase* LibEntryL() |
|
432 { |
|
433 return CTEFTestModule::NewL(); |
|
434 |
|
435 } |
|
436 |
|
437 // ----------------------------------------------------------------------------- |
|
438 // SetRequirements handles test module parameters(implements evolution |
|
439 // version 1 for test module's heap and stack sizes configuring). |
|
440 // Returns: TInt: Symbian error code. |
|
441 // ----------------------------------------------------------------------------- |
|
442 // |
|
443 EXPORT_C TInt SetRequirements( CTestModuleParam*& aTestModuleParam, |
|
444 TUint32& aParameterValid ) |
|
445 { |
|
446 |
|
447 /* --------------------------------- NOTE --------------------------------- |
|
448 USER PANICS occurs in test thread creation when: |
|
449 1) "The panic occurs when the value of the stack size is negative." |
|
450 2) "The panic occurs if the minimum heap size specified is less |
|
451 than KMinHeapSize". |
|
452 KMinHeapSize: "Functions that require a new heap to be allocated will |
|
453 either panic, or will reset the required heap size to this value if |
|
454 a smaller heap size is specified". |
|
455 3) "The panic occurs if the minimum heap size specified is greater than |
|
456 the maximum size to which the heap can grow". |
|
457 Other: |
|
458 1) Make sure that your hardware or Symbian OS is supporting given sizes. |
|
459 e.g. Hardware might support only sizes that are divisible by four. |
|
460 ------------------------------- NOTE end ------------------------------- */ |
|
461 |
|
462 // Normally STIF uses default heap and stack sizes for test thread, see: |
|
463 // KTestThreadMinHeap, KTestThreadMinHeap and KStackSize. |
|
464 // If needed heap and stack sizes can be configured here by user. Remove |
|
465 // comments and define sizes. |
|
466 aParameterValid = KStifTestModuleParameterChanged; |
|
467 |
|
468 CTestModuleParamVer01* param = CTestModuleParamVer01::NewL(); |
|
469 //We're quite heavy on the stack... |
|
470 // Stack size |
|
471 param->iTestThreadStackSize= 28672; // 28K stack |
|
472 // Heap sizes |
|
473 param->iTestThreadMinHeap = 4096; // 4K heap min |
|
474 param->iTestThreadMaxHeap = 1260480;// 1.2M heap max |
|
475 |
|
476 TInt stackSizeFromUser = -1; |
|
477 TInt parseErr = KErrNone; |
|
478 TRAPD( err, parseErr = CTEFTestModule::ParseStackSizeL(stackSizeFromUser)); |
|
479 if(err != KErrNone) |
|
480 { |
|
481 __RDEBUG( (_L("Error: Leaves when get StackSize from TestFramework.ini") ) ); |
|
482 } |
|
483 if(parseErr != KErrNone) |
|
484 { |
|
485 __RDEBUG( (_L("Error: Error when get StackSize from TestFramework.ini, err= %d"), parseErr) ); |
|
486 } |
|
487 |
|
488 if(stackSizeFromUser > 0) |
|
489 { |
|
490 param->iTestThreadStackSize = stackSizeFromUser; // user configed stack size |
|
491 } |
|
492 aTestModuleParam = param; |
|
493 |
|
494 return KErrNone; |
|
495 |
|
496 } |
|
497 |
|
498 // ----------------------------------------------------------------------------- |
|
499 // CTEFTestModule::TEFInitialize |
|
500 // InitializeModule is used to do some preparations. |
|
501 // Returns: void |
|
502 // ----------------------------------------------------------------------------- |
|
503 // |
|
504 void CTEFTestModule::TEFInitialize(void) |
|
505 { |
|
506 // Check to see if the plugin wrapper around the GetSystemDrive is loadable |
|
507 // If yes, then instantiate the wrapper object and obtain the default system drive |
|
508 // Else, use the hardcoded default drive as c: |
|
509 iDefaultSysDrive = KTEFLegacySysDrive; |
|
510 |
|
511 RLibrary pluginLibrary; |
|
512 CWrapperUtilsPlugin* plugin = TEFUtils::WrapperPluginNew(pluginLibrary); |
|
513 |
|
514 if (plugin!=NULL) |
|
515 { |
|
516 TDriveUnit driveUnit(plugin->GetSystemDrive()); |
|
517 iDefaultSysDrive.Copy(driveUnit.Name()); |
|
518 delete plugin; |
|
519 pluginLibrary.Close(); |
|
520 } |
|
521 |
|
522 TBool enableSysStart = ETrue; |
|
523 CTestExecuteIniData* iniData = NULL; |
|
524 TRAPD(err, iniData = CTestExecuteIniData::NewL(iDefaultSysDrive)); |
|
525 if (err == KErrNone) |
|
526 { |
|
527 // Extract all the key values within the object |
|
528 iniData->ExtractValuesFromIni(); |
|
529 iniData->GetKeyValueFromIni(KTEFSystemStarter, enableSysStart); |
|
530 } |
|
531 |
|
532 err = KErrNone; |
|
533 |
|
534 #if !(defined TEF_LITE) |
|
535 if (enableSysStart) |
|
536 { |
|
537 TRAP(err, StartSystemL()); |
|
538 if (KErrNone != err) |
|
539 { |
|
540 __RDEBUG( (_L("Wait for system starter failed, error code=%d"),err) ); |
|
541 iLog->Log(CStifLogger::ERed, _L("Wait for system starter failed, error code=%d"),err); |
|
542 User::After(5000000); |
|
543 } |
|
544 } |
|
545 #endif |
|
546 |
|
547 if (iniData != NULL) |
|
548 { |
|
549 delete iniData; |
|
550 } |
|
551 |
|
552 } |
|
553 |
|
554 // ----------------------------------------------------------------------------- |
|
555 // CTEFTestModule::ParseTEFTestCfgFileL |
|
556 // ParseTEFTestCfgFileL is used to parse configuration file |
|
557 // to get config information and script list. |
|
558 // Returns: TInt: Symbian error code. |
|
559 // ----------------------------------------------------------------------------- |
|
560 // |
|
561 TInt CTEFTestModule::ParseTEFTestCfgFileL( const TFileName& aConfigFile, |
|
562 RPointerArray<TTestCaseInfo>& aTestCases) |
|
563 { |
|
564 iLog->Log(_L("Start parsing TEFTestModule configuration.")); |
|
565 |
|
566 if( aConfigFile.Length() == 0 ) |
|
567 { |
|
568 iLog->Log(CStifLogger::ERed, _L("Error: No test configuration file given") ) ; |
|
569 __RDEBUG( (_L("Error: No test configuration file given") ) ); |
|
570 return KErrNotFound; |
|
571 } |
|
572 |
|
573 CStifParser* parser = NULL; |
|
574 |
|
575 // Open .cfg file |
|
576 TRAPD( err, |
|
577 parser = CStifParser::NewL( _L(""), |
|
578 aConfigFile, |
|
579 CStifParser::ECStyleComments ) ); |
|
580 if( err != KErrNone ) |
|
581 { |
|
582 __RDEBUG( (_L("Error: Given test configuration file [%S] not found"), |
|
583 &aConfigFile ) ); |
|
584 iLog->Log(CStifLogger::ERed, _L("Error: Given test configuration file [%S] not found. Error=%d."), |
|
585 &aConfigFile,err); |
|
586 return err; |
|
587 } |
|
588 |
|
589 CleanupStack::PushL( parser ); |
|
590 CStifSectionParser* section = NULL; |
|
591 TPtrC tmp; |
|
592 TInt ret = KErrNone; |
|
593 |
|
594 // Find first section |
|
595 _LIT( KModuleStartTag, "[New_TEFTest]" ); |
|
596 _LIT( KModuleEndTag, "[End_TEFTest]" ); |
|
597 section = parser->SectionL( KModuleStartTag, KModuleEndTag ); |
|
598 if( section == NULL ) |
|
599 { |
|
600 __RDEBUG( (_L("Error: Can not find TEFTest section from %S."), |
|
601 &aConfigFile) ); |
|
602 iLog->Log(CStifLogger::ERed, _L("Error: Can not find TEFTest section from %S."), |
|
603 &aConfigFile); |
|
604 ret = KErrNotFound; |
|
605 } |
|
606 else |
|
607 { |
|
608 // Parse section |
|
609 CleanupStack::PushL( section ); |
|
610 |
|
611 CStifItemParser* item = NULL; |
|
612 |
|
613 // Get Tcs from configuration file. |
|
614 TRAPD( getTcs, item = section ->GetItemLineL(_L( "Tcs=" ), ENoTag)); |
|
615 if( getTcs != KErrNone ) |
|
616 { |
|
617 __RDEBUG( (_L("Error: From file %S, get item 'Tcs=' leaves with error: %d."), &aConfigFile ,getTcs) ); |
|
618 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, get item 'Tcs=' leaves with error: %d."), &aConfigFile ,getTcs); |
|
619 delete item; |
|
620 item=NULL; |
|
621 return getTcs; |
|
622 } |
|
623 if( !item ) |
|
624 { |
|
625 __RDEBUG( (_L("Warning: From file %S, can not get item 'Tcs=' value. Use default OFF."), &aConfigFile) ); |
|
626 iLog->Log( _L("Warning: From file %S, can not get item 'Tcs=' value. Use default OFF."), &aConfigFile); |
|
627 //set Tcs to default OFF. |
|
628 iCfg_tcs = EOFF; |
|
629 iLog->Log(_L("Tcs = %d"),iCfg_tcs); |
|
630 delete item; |
|
631 item=NULL; |
|
632 } |
|
633 else |
|
634 { |
|
635 TPtrC tcs; |
|
636 ret = item->GetString( _L( "" ), tcs ); |
|
637 |
|
638 HBufC* tcsHbuf = tcs.AllocL(); |
|
639 TPtr modifiableString = tcsHbuf->Des(); |
|
640 modifiableString.UpperCase(); |
|
641 |
|
642 if( modifiableString == _L( "INCLUDE" ) ) |
|
643 { |
|
644 iCfg_tcs = EInclude; |
|
645 } |
|
646 else if( modifiableString == _L( "EXCLUDE" ) ) |
|
647 { |
|
648 iCfg_tcs = EExclude; |
|
649 } |
|
650 else if( modifiableString == _L( "OFF" ) ) |
|
651 { |
|
652 iCfg_tcs = EOFF; |
|
653 } |
|
654 else |
|
655 { |
|
656 __RDEBUG( (_L("Warning: From file %S, item 'Tcs=' value is not recognized. Use default OFF."), &aConfigFile) ); |
|
657 iLog->Log( _L("Warning: From file %S, item 'Tcs=' value is not recognized. Use default OFF."), &aConfigFile); |
|
658 iCfg_tcs = EOFF; |
|
659 } |
|
660 iLog->Log(_L("Tcs = %d"),iCfg_tcs); |
|
661 delete tcsHbuf; |
|
662 tcsHbuf=NULL; |
|
663 delete item; |
|
664 item=NULL; |
|
665 } |
|
666 |
|
667 //Get Debug from configuration file. |
|
668 TRAPD( getDebug, item = section ->GetItemLineL(_L( "Debug=" ), ENoTag)); |
|
669 if( getDebug != KErrNone ) |
|
670 { |
|
671 __RDEBUG( (_L("Error: From file %S, get item 'Debug=' leaves with error: %d."), &aConfigFile, getDebug) ); |
|
672 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, get item 'Debug=' leaves with error: %d."), &aConfigFile, getDebug); |
|
673 delete item; |
|
674 item=NULL; |
|
675 return getDebug; |
|
676 } |
|
677 if( !item ) |
|
678 { |
|
679 __RDEBUG( (_L("Warning: From file %S, can not get item 'Debug=' value. Use default OFF."), &aConfigFile) ); |
|
680 iLog->Log( _L("Warning: From file %S, can not get item 'Debug=' value. Use default OFF."), &aConfigFile); |
|
681 // set Debug to default OFF. |
|
682 iCfg_Debug = EFalse; |
|
683 iLog->Log(_L("Debug = %d"),iCfg_Debug); |
|
684 delete item; |
|
685 item=NULL; |
|
686 } |
|
687 else |
|
688 { |
|
689 TPtrC debug; |
|
690 ret = item->GetString( _L( "" ), debug ); |
|
691 |
|
692 HBufC* debugHbuf = debug.AllocL(); |
|
693 TPtr modifiableString = debugHbuf->Des(); |
|
694 modifiableString.UpperCase(); |
|
695 |
|
696 if( modifiableString == _L( "ON" ) ) |
|
697 { |
|
698 iCfg_Debug = ETrue; |
|
699 } |
|
700 else if( modifiableString == _L( "OFF" ) ) |
|
701 { |
|
702 iCfg_Debug = EFalse; |
|
703 } |
|
704 else |
|
705 { |
|
706 __RDEBUG( (_L("Warning: From file %S, item 'Debug=' value is not recognized. Use default OFF."), &aConfigFile) ); |
|
707 iLog->Log( _L("Warning: From file %S, item 'Debug=' value is not recognized. Use default OFF."), &aConfigFile); |
|
708 iCfg_Debug = EFalse; |
|
709 } |
|
710 iLog->Log(_L("Debug = %d"),iCfg_Debug); |
|
711 delete debugHbuf; |
|
712 debugHbuf=NULL; |
|
713 delete item; |
|
714 item=NULL; |
|
715 } |
|
716 |
|
717 //Get SeparateLog from configuration file. |
|
718 TRAPD( getSep, item = section ->GetItemLineL(_L( "SeparateLog=" ), ENoTag)); |
|
719 if( getSep != KErrNone ) |
|
720 { |
|
721 __RDEBUG( (_L("Error: From file %S, get item 'SeparateLog=' leaves with error: %d."), &aConfigFile, getSep) ); |
|
722 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, get item 'SeparateLog=' leaves with error: %d."), &aConfigFile, getSep); |
|
723 delete item; |
|
724 item=NULL; |
|
725 return getSep; |
|
726 } |
|
727 if( !item ) |
|
728 { |
|
729 __RDEBUG( (_L("Warning: From file %S, can not get item 'SeparateLog=' value. Use default OFF."), &aConfigFile) ); |
|
730 iLog->Log( _L("Warning: From file %S, can not get item 'SeparateLog=' value. Use default OFF."), &aConfigFile); |
|
731 //set SeparateLog to OFF. |
|
732 iCfg_SeparateLog = EFalse; |
|
733 iLog->Log(_L("SeparateLog = %d"),iCfg_SeparateLog); |
|
734 delete item; |
|
735 item=NULL; |
|
736 } |
|
737 else |
|
738 { |
|
739 TPtrC separateLog; |
|
740 ret = item->GetString( _L( "" ), separateLog ); |
|
741 |
|
742 HBufC* separateLogHbuf = separateLog.AllocL(); |
|
743 TPtr modifiableString = separateLogHbuf->Des(); |
|
744 modifiableString.UpperCase(); |
|
745 |
|
746 if( modifiableString == _L( "ON" ) ) |
|
747 { |
|
748 iCfg_SeparateLog = ETrue; |
|
749 } |
|
750 else if( modifiableString == _L( "OFF" ) ) |
|
751 { |
|
752 iCfg_SeparateLog = EFalse; |
|
753 } |
|
754 else |
|
755 { |
|
756 __RDEBUG( (_L("Warning: From file %S, item 'SeparateLog=' value is not recognized. Use default OFF."), &aConfigFile) ); |
|
757 iLog->Log( _L("Warning: From file %S, item 'SeparateLog=' value is not recognized. Use default OFF."), &aConfigFile); |
|
758 iCfg_SeparateLog = EFalse; |
|
759 } |
|
760 iLog->Log(_L("SeparateLog = %d"),iCfg_SeparateLog); |
|
761 delete separateLogHbuf; |
|
762 separateLogHbuf=NULL; |
|
763 delete item; |
|
764 item=NULL; |
|
765 } |
|
766 |
|
767 //Get Pipe from configuration file. |
|
768 TRAPD( getPipe, item = section ->GetItemLineL(_L( "Pipe=" ), ENoTag)); |
|
769 if( getPipe != KErrNone ) |
|
770 { |
|
771 __RDEBUG( (_L("Error: From file %S, get item 'Pipe=' leaves with error: %d."), &aConfigFile, getPipe) ); |
|
772 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, get item 'Pipe=' leaves with error: %d."), &aConfigFile, getPipe); |
|
773 delete item; |
|
774 item=NULL; |
|
775 return getPipe; |
|
776 } |
|
777 if( !item ) |
|
778 { |
|
779 __RDEBUG( (_L("Warning: From file %S, can not get item 'Pipe=' value. Use default OFF."), &aConfigFile) ); |
|
780 iLog->Log( _L("Warning: From file %S, can not get item 'Pipe=' value. Use default OFF."), &aConfigFile); |
|
781 iCfg_Pipe.Copy(_L("OFF")); |
|
782 iLog->Log(_L("Pipe = %S"),&iCfg_Pipe); |
|
783 delete item; |
|
784 item=NULL; |
|
785 } |
|
786 else |
|
787 { |
|
788 TPtrC pipeName; |
|
789 ret = item->GetString( _L( "" ), pipeName ); |
|
790 iCfg_Pipe.Copy(pipeName); |
|
791 if(iCfg_Pipe.Length()<=0) |
|
792 { |
|
793 __RDEBUG( (_L("Warning: From file %S, can not get item 'Pipe=' value. Use default OFF."), &aConfigFile) ); |
|
794 iLog->Log( _L("Warning: From file %S, can not get item 'Pipe=' value. Use default OFF."), &aConfigFile); |
|
795 iCfg_Pipe.Copy(_L("OFF")); |
|
796 delete item; |
|
797 item=NULL; |
|
798 } |
|
799 iLog->Log(_L("Pipe = %S"),&iCfg_Pipe); |
|
800 delete item; |
|
801 item=NULL; |
|
802 } |
|
803 |
|
804 //Get Script from configuration file. |
|
805 TInt scriptCount = 0; |
|
806 TRAPD(getScript, item = section->GetItemLineL(_L( "Script=" ), ENoTag)); |
|
807 if( getScript != KErrNone ) |
|
808 { |
|
809 __RDEBUG( (_L("Error: From file %S, get item 'Script=' leaves with error: %d."), &aConfigFile, getScript) ); |
|
810 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, get item 'Script=' leaves with error: %d."), &aConfigFile, getScript); |
|
811 delete item; |
|
812 item=NULL; |
|
813 return getScript; |
|
814 } |
|
815 if( !item ) |
|
816 { |
|
817 __RDEBUG( (_L("Error: From file %S, can not get item 'Script=' value."), &aConfigFile) ); |
|
818 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, can not get item 'Script=' value."), &aConfigFile); |
|
819 delete item; |
|
820 item=NULL; |
|
821 return KErrNotFound; |
|
822 } |
|
823 |
|
824 while(item) |
|
825 { |
|
826 //script count, from 1 to ... |
|
827 scriptCount++; |
|
828 CleanupStack::PushL(item); |
|
829 TPtrC script; |
|
830 ret = item->GetString(_L( "" ), script); |
|
831 |
|
832 TScriptName scriptFile; |
|
833 scriptFile.Copy(script); |
|
834 TStifUtil::CorrectFilePathL( scriptFile ); |
|
835 scriptFile.LowerCase(); |
|
836 iLog->Log(_L("Script = %S"),&scriptFile); |
|
837 |
|
838 ret = MatchScriptsToCasesL(scriptFile, scriptCount, aTestCases); |
|
839 |
|
840 CleanupStack::PopAndDestroy(item); |
|
841 item=NULL; |
|
842 TRAPD(getScript2, item = section->GetNextItemLineL(_L( "Script=" ), ENoTag)); |
|
843 if( getScript2 != KErrNone ) |
|
844 { |
|
845 __RDEBUG( (_L("Error: From file %S, get item 'Script=' leaves with error: %d."), &aConfigFile, getScript2) ); |
|
846 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, get item 'Script=' leaves with error: %d."), &aConfigFile, getScript2); |
|
847 delete item; |
|
848 item=NULL; |
|
849 return getScript2; |
|
850 } |
|
851 } |
|
852 |
|
853 //Get TcsFile from configuration file. |
|
854 if (iCfg_tcs != EOFF) |
|
855 { |
|
856 TInt tcsCount = 0; |
|
857 TRAPD(getTcsData, item = section->GetItemLineL(_L( "TcsData=" ), ENoTag)); |
|
858 if( getTcsData != KErrNone ) |
|
859 { |
|
860 __RDEBUG( (_L("Error: From file %S, get item 'TcsData=' leaves with error: %d."), &aConfigFile, getTcsData) ); |
|
861 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, get item 'TcsData=' leaves with error: %d."), &aConfigFile, getTcsData); |
|
862 delete item; |
|
863 item=NULL; |
|
864 return getTcsData; |
|
865 } |
|
866 if( !item ) |
|
867 { |
|
868 __RDEBUG( (_L("Error: From file %S, can not get item 'TcsData=' value."), &aConfigFile) ); |
|
869 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, can not get item 'TcsData=' value."), &aConfigFile); |
|
870 delete item; |
|
871 item=NULL; |
|
872 return KErrNotFound; |
|
873 } |
|
874 |
|
875 while(item) |
|
876 { |
|
877 //script count, from 1 to ... |
|
878 tcsCount++; |
|
879 CleanupStack::PushL(item); |
|
880 TPtrC tcsFile; |
|
881 ret = item->GetString(_L( "" ), tcsFile); |
|
882 |
|
883 TTcsName* tcsData = new(ELeave) TTcsName(tcsFile); |
|
884 TStifUtil::CorrectFilePathL( *tcsData ); |
|
885 tcsData->LowerCase(); |
|
886 iLog->Log(_L("TcsData = %S"),&(*tcsData)); |
|
887 |
|
888 //Add tcsData list to iArray_Cfg_TcsData. |
|
889 CleanupStack::PushL( tcsData ); |
|
890 // Append tcsData to the iArray_Cfg_TcsData array. After appended succesfully |
|
891 // the tcsData object is owned (and freed) by the iArray_Cfg_TcsData in ~CTEFTestModule() method. |
|
892 // The sequence of tcs in iArray_Cfg_TcsData is same as sequence of script list iArray_ScriptFilePaths. |
|
893 // tcsData and script is paired. |
|
894 User::LeaveIfError( iArray_Cfg_TcsData.Append( tcsData ) ); |
|
895 CleanupStack::Pop(tcsData); |
|
896 |
|
897 CleanupStack::PopAndDestroy(item); |
|
898 item=NULL; |
|
899 TRAPD(getTcsData2, item = section->GetNextItemLineL(_L( "TcsData=" ), ENoTag)); |
|
900 if( getTcsData2 != KErrNone ) |
|
901 { |
|
902 __RDEBUG( (_L("Error: From file %S, get item 'TcsData=' leaves with error: %d."), &aConfigFile, getTcsData2) ); |
|
903 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, get item 'TcsData=' leaves with error: %d."), &aConfigFile, getTcsData2); |
|
904 delete item; |
|
905 item=NULL; |
|
906 return getTcsData2; |
|
907 } |
|
908 } |
|
909 } |
|
910 else |
|
911 //iCfg_tcs == EOFF, pair Script with TcsData(NULL). |
|
912 { |
|
913 TTcsName* tcsDataNull = new(ELeave) TTcsName(); |
|
914 CleanupStack::PushL( tcsDataNull ); |
|
915 for(TInt i=0; i<iArray_ScriptFilePaths.Count();i++) |
|
916 { |
|
917 // Append tcsDataNull to the iArray_Cfg_TcsData array. After appended succesfully |
|
918 // the tcsDataNull object is owned (and freed) by the iArray_Cfg_TcsData in ~CTEFTestModule() method. |
|
919 User::LeaveIfError( iArray_Cfg_TcsData.Append( tcsDataNull ) ); |
|
920 } |
|
921 CleanupStack::Pop(tcsDataNull); |
|
922 } |
|
923 |
|
924 CleanupStack::PopAndDestroy( section ); |
|
925 section = NULL; |
|
926 } |
|
927 CleanupStack::PopAndDestroy( parser ); |
|
928 |
|
929 //check: At leasr one script exist in TEFTestModule configration file |
|
930 if(iArray_ScriptFilePaths.Count()<=0) |
|
931 { |
|
932 __RDEBUG( (_L("Error: From file %S, no Script founded."), &aConfigFile) ); |
|
933 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, no Script founded."), &aConfigFile); |
|
934 ret = KErrArgument; |
|
935 } |
|
936 |
|
937 //check: Script is paired with TcsData. |
|
938 if(iArray_ScriptFilePaths.Count() != iArray_Cfg_TcsData.Count()) |
|
939 { |
|
940 __RDEBUG( (_L("Error: From file %S, Script is not paired with TcsData."), &aConfigFile) ); |
|
941 iLog->Log(CStifLogger::ERed, _L("Error: From file %S, Script is not paired with TcsData."), &aConfigFile); |
|
942 ret = KErrArgument; |
|
943 } |
|
944 |
|
945 |
|
946 return ret; |
|
947 } |
|
948 |
|
949 // ----------------------------------------------------------------------------- |
|
950 // CTEFTestModule::MatchScriptsToCasesL |
|
951 // MatchScriptsToCasesL is used to add cases based on script list. |
|
952 // Case title use script short name(xxx, No path and No extension '.script'). |
|
953 // Script list stores in iArray_ScriptFilePaths, using full name(c:\xx\xxx\xxx.script) |
|
954 // The sequence of Case list and script list are the same. |
|
955 // This is called by ParseTestFrameWorkCfgL(). |
|
956 // Returns: TInt: Symbian error code. |
|
957 // ----------------------------------------------------------------------------- |
|
958 // |
|
959 TInt CTEFTestModule::MatchScriptsToCasesL( const TScriptName& aScriptFile, |
|
960 TInt aScriptCount, |
|
961 RPointerArray<TTestCaseInfo>& aTestCases ) |
|
962 { |
|
963 |
|
964 TInt ret = KErrNone; |
|
965 |
|
966 //Get the script name(xxx.script) from full name(c:\xx\xxx\xxx.script) |
|
967 TInt offset = aScriptFile.LocateReverse('\\'); |
|
968 if (offset == KErrNotFound) |
|
969 { |
|
970 ret = KErrNotFound; |
|
971 return ret; |
|
972 } |
|
973 TFileName scriptName; |
|
974 scriptName.Copy( aScriptFile.Mid(offset+1)); |
|
975 //Get the script name(xxx, No '.script') |
|
976 offset = scriptName.LocateReverse('.'); |
|
977 if (offset == KErrNotFound) |
|
978 { |
|
979 ret = KErrNotFound; |
|
980 return ret; |
|
981 } |
|
982 scriptName.Copy( scriptName.Left(offset)); |
|
983 |
|
984 //Add script list. Full name(c:\xx\xxx\xxx.script) to iArray_ScriptFilePaths. |
|
985 TScriptName* scriptfile = new(ELeave) TScriptName(aScriptFile); |
|
986 CleanupStack::PushL( scriptfile ); |
|
987 // Append TTestCaseInfo to the iArray_ScriptFilePaths array. After appended succesfully |
|
988 // the TTestCaseInfo object is owned (and freed) by the iArray_ScriptFilePaths in ~CTEFTestModule() method. |
|
989 // The sequence of script in iArray_ScriptFilePaths is same as sequence of case list. |
|
990 User::LeaveIfError( iArray_ScriptFilePaths.Append( scriptfile ) ); |
|
991 CleanupStack::Pop(scriptfile); |
|
992 |
|
993 //Add case, case title is xxx, no path, no extesion '.script' |
|
994 TTestCaseInfo* testCase = new(ELeave) TTestCaseInfo(); |
|
995 CleanupStack::PushL( testCase ); |
|
996 testCase->iCaseNumber = aScriptCount; |
|
997 testCase->iTitle.Copy( scriptName ); |
|
998 |
|
999 // Append TTestCaseInfo to the testcase array. After appended succesfully |
|
1000 // the TTestCaseInfo object is owned (and freed) by the TestServer. |
|
1001 User::LeaveIfError( aTestCases.Append( testCase ) ); |
|
1002 CleanupStack::Pop(testCase); |
|
1003 |
|
1004 return ret; |
|
1005 } |
|
1006 |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // CTEFTestModule::RunScriptL |
|
1009 // RunScriptL is used to Execute sigle script. |
|
1010 // This is the main functionality of script execution based |
|
1011 // on legacy TEF's functionality. |
|
1012 // Returns: TInt: Symbian error code. |
|
1013 // ----------------------------------------------------------------------------- |
|
1014 // |
|
1015 TInt CTEFTestModule::RunScriptL(CActiveScheduler* aScheduler, |
|
1016 const TScriptName& aScriptFilePath, |
|
1017 const TTcsName& aTcsData ) |
|
1018 { |
|
1019 TDriveName testSysDrive(KTEFLegacySysDrive); |
|
1020 TInt waitForLoggingTime = 0; |
|
1021 TBuf<KMaxTestExecuteNameLength> htmlLogPath; |
|
1022 // Create a object of the Parser for TestExecute.ini |
|
1023 CTestExecuteIniData* parseTestExecuteIni = NULL; |
|
1024 TRAPD(err, parseTestExecuteIni = CTestExecuteIniData::NewL(iDefaultSysDrive)); |
|
1025 if (err == KErrNone) |
|
1026 { |
|
1027 CleanupStack::PushL(parseTestExecuteIni); |
|
1028 // Extract all the key values within the object |
|
1029 parseTestExecuteIni->ExtractValuesFromIni(); |
|
1030 } |
|
1031 |
|
1032 TDesC* selTestCfgFileData = NULL; //the pointer to the data of in the .tcs file |
|
1033 |
|
1034 // If Debug == ON, then set Just In Time debugging. Panicks break into debug on emulator |
|
1035 (iCfg_Debug) ? (User::SetJustInTime(ETrue)) : (User::SetJustInTime(EFalse)); |
|
1036 |
|
1037 // Create a console |
|
1038 _LIT(KMessage,"TestExecute Script Engine"); |
|
1039 CConsoleBase* console = Console::NewL(KMessage,TSize(KConsFullScreen,KConsFullScreen)); |
|
1040 CleanupStack::PushL(console); |
|
1041 console->SetCursorHeight(0); |
|
1042 RConsoleLogger consoleLogger(*console); |
|
1043 |
|
1044 // Check whether script name is provided along with folder path in the command line |
|
1045 // If not, take the path from testexecute.ini & name from the command line |
|
1046 TPtrC scriptFilePath(aScriptFilePath); |
|
1047 TScriptName tempScriptPath(scriptFilePath); |
|
1048 TInt ret=scriptFilePath.FindC(KTEFColon); |
|
1049 if(ret==KErrNotFound) |
|
1050 { |
|
1051 if (parseTestExecuteIni != NULL) |
|
1052 { |
|
1053 TBuf<KMaxTestExecuteNameLength> tempBuffer; |
|
1054 parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultScriptPath, tempBuffer); |
|
1055 // If the relative script file path does not refer to the root, |
|
1056 // we will look for DefaultScriptDir entry in testexecute.ini |
|
1057 // If available prepend it to the relative path |
|
1058 // else if the relative path refers to root, |
|
1059 // then set the default system drive, i.e. c: |
|
1060 // else leaving it as it is (considering invalid path) |
|
1061 if (scriptFilePath.Left(1).CompareF(KTEFSlash) != 0 && |
|
1062 tempBuffer.Length() > 0) |
|
1063 scriptFilePath.Set(tempBuffer); |
|
1064 else if (scriptFilePath.Left(1).CompareF(KTEFSlash) == 0) |
|
1065 scriptFilePath.Set(iDefaultSysDrive); |
|
1066 else |
|
1067 scriptFilePath.Set(KNull); |
|
1068 } |
|
1069 else |
|
1070 { |
|
1071 // If the file path is not provided in command line as well as in testexecute.ini |
|
1072 // then set the script file path to be 'blank' |
|
1073 scriptFilePath.Set(KNull); |
|
1074 } |
|
1075 |
|
1076 // Construct the full file path from the values extracted from command line and ini file |
|
1077 TScriptName storeScriptPathTemp(scriptFilePath); |
|
1078 storeScriptPathTemp.Append(tempScriptPath); |
|
1079 scriptFilePath.Set(storeScriptPathTemp); |
|
1080 tempScriptPath.Copy(scriptFilePath); |
|
1081 } |
|
1082 |
|
1083 //If scriptFilePath is not appended by .script Append .script |
|
1084 if(scriptFilePath.Find(KTEFScriptExtension)==KErrNotFound) |
|
1085 { |
|
1086 tempScriptPath.Append(KTEFScriptExtension); |
|
1087 } |
|
1088 scriptFilePath.Set(tempScriptPath); |
|
1089 |
|
1090 //Parse TcsData from configration file to select test case flag. Get cases Included or Excluded. |
|
1091 TSelectiveTestingOptions* selTestingOptions =NULL; |
|
1092 if(iCfg_tcs!=EOFF) |
|
1093 { |
|
1094 RArray<TRange> selectiveCaseRange; |
|
1095 ParseTcsDataForSelectiveTestingOptions(aTcsData, *parseTestExecuteIni,selectiveCaseRange, selTestCfgFileData); |
|
1096 |
|
1097 //you need to sort these two arrays first, and also if they are both empty ignore the entire option altogether. |
|
1098 if( selectiveCaseRange.Count() > 0 ) |
|
1099 { |
|
1100 CleanupStack::PushL(selTestCfgFileData); |
|
1101 TLinearOrder<TRange> orderingrng(TRange::CompareTRangeStartOrder) ; |
|
1102 selectiveCaseRange.Sort(orderingrng ); |
|
1103 ESelectiveTesting selectiveTestingType(iExclusive); |
|
1104 if(iCfg_tcs == EInclude) |
|
1105 { |
|
1106 selectiveTestingType = iInclusive ; |
|
1107 } |
|
1108 selTestingOptions = new(ELeave) TSelectiveTestingOptions(selectiveCaseRange, selectiveTestingType); |
|
1109 } |
|
1110 else |
|
1111 { |
|
1112 //if iCfg_tcs == EOFF, no tcs option used, ignore it... |
|
1113 delete selTestCfgFileData; |
|
1114 } |
|
1115 } |
|
1116 |
|
1117 if (scriptFilePath.CompareF(KNull)==0) |
|
1118 { |
|
1119 if (!iCfg_SeparateLog && !iCfg_Debug) |
|
1120 { |
|
1121 // Print the product version details through console window |
|
1122 iLog->Log(KTEFVersionMessage); |
|
1123 iLog->Log(KTEFProductVersion); |
|
1124 } |
|
1125 else |
|
1126 { |
|
1127 // Display a error message on the log file of error TEF configration file. |
|
1128 __RDEBUG( (_L("Error: In TEFTestModule configuration file. No script founded.") ) ); |
|
1129 iLog->Log(CStifLogger::ERed, _L("Error: In TEFTestModule configuration file. No script founded.")); |
|
1130 } |
|
1131 // Exit on a key press from user |
|
1132 console->Printf(KTEFEnterKeyMessage); |
|
1133 console->Getch(); |
|
1134 } |
|
1135 else |
|
1136 { |
|
1137 // Create a Interface class object for generating HTML & XML logs |
|
1138 CTestExecuteLogger *tefLogger = new(ELeave) CTestExecuteLogger(); |
|
1139 CleanupStack::PushL(tefLogger); |
|
1140 |
|
1141 TInt logMode; |
|
1142 TInt logLevel; |
|
1143 TInt remotePanicDetection; |
|
1144 TBuf<KMaxTestExecuteNameLength> iniSysDrive; |
|
1145 |
|
1146 if (parseTestExecuteIni != NULL) |
|
1147 { |
|
1148 // Parse ini for retrieving logging options set through ini |
|
1149 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogMode, logMode); |
|
1150 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogSeverityKey, logLevel); |
|
1151 parseTestExecuteIni->GetKeyValueFromIni(KTEFRemotePanicDetection, remotePanicDetection); |
|
1152 parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultSysDrive, iniSysDrive); |
|
1153 parseTestExecuteIni->GetKeyValueFromIni(KTEFWaitForLoggingTime, waitForLoggingTime); |
|
1154 parseTestExecuteIni->GetKeyValueFromIni(KTEFHtmlKey, htmlLogPath); |
|
1155 } |
|
1156 else |
|
1157 { |
|
1158 // Set default values for logging options if parser is not functioning |
|
1159 logMode = TLoggerOptions(ELogHTMLOnly); |
|
1160 logLevel = RFileFlogger::TLogSeverity(ESevrAll); |
|
1161 remotePanicDetection = 0; |
|
1162 iniSysDrive.Copy(KTEFIniSysDrive); |
|
1163 waitForLoggingTime = 5; |
|
1164 htmlLogPath.Copy(KTestExecuteLogPath); |
|
1165 htmlLogPath.Replace(0, 2, iDefaultSysDrive); |
|
1166 } |
|
1167 |
|
1168 tefLogger->SetLoggerOptions(logMode); |
|
1169 if(iCfg_Pipe!=_L("OFF")) |
|
1170 { |
|
1171 TPtrC pipeName(iCfg_Pipe); |
|
1172 tefLogger->SetPipeName(pipeName); |
|
1173 } |
|
1174 |
|
1175 // Initialise the logging passing in the script file path & log level to the interface |
|
1176 tefLogger->InitialiseLoggingL(scriptFilePath, iCfg_SeparateLog, logLevel); |
|
1177 |
|
1178 // Check to see if defaultsysdrive key is set in testexecute.ini |
|
1179 // if set to SYSDRIVE, assign the default system drive obtained from the plugin |
|
1180 // else, if a true value is set in testexecute.ini, use it as system drive for all test artifacts |
|
1181 if (iniSysDrive.Length() == 2 && iniSysDrive.Right(1).Compare(KTEFColon) == 0) |
|
1182 testSysDrive.Copy(iniSysDrive); |
|
1183 else if (iniSysDrive.CompareF(KTEFIniSysDrive) == 0) |
|
1184 testSysDrive.Copy(iDefaultSysDrive); |
|
1185 |
|
1186 |
|
1187 // Pass the first command line argument to the script master |
|
1188 // which is always the command script |
|
1189 CScriptMaster* scriptMaster = new (ELeave) CScriptMaster(scriptFilePath,*tefLogger, consoleLogger, iDefaultSysDrive, testSysDrive, selTestingOptions); |
|
1190 // To kick the state machine of the script master off - |
|
1191 // Call the kick method which jumps us into the RunL() of the CScriptMaster class |
|
1192 // CScriptMaster is the top AO in the hierarchy. |
|
1193 scriptMaster->Kick(); |
|
1194 |
|
1195 // Construct and Install a test watcher object for capturing remote panics during test execution |
|
1196 CTestWatcher* testWatcher = NULL; |
|
1197 if (remotePanicDetection != 0) |
|
1198 { |
|
1199 testWatcher = CTestWatcher::NewL(); |
|
1200 testWatcher->StartL(); |
|
1201 } |
|
1202 // Enter the Active Scheduler |
|
1203 aScheduler->Start(); |
|
1204 |
|
1205 // Cleanup |
|
1206 delete scriptMaster; |
|
1207 |
|
1208 TInt commentedCommandsCnt=CScriptControl::commentedCommandsCount; |
|
1209 if(commentedCommandsCnt==-1) |
|
1210 { |
|
1211 CScriptControl::commentedCommandsCount=0; |
|
1212 //If the path specified fails check out for path from testexecute.ini |
|
1213 if(ret!=KErrNotFound) |
|
1214 { |
|
1215 //To get scriptFile name i.e get sampleFile.script |
|
1216 TInt posOfLastSlash=scriptFilePath.LocateReverse('\\') ; |
|
1217 scriptFilePath.Set(scriptFilePath.Mid(posOfLastSlash+1)); |
|
1218 TScriptName tempStore(scriptFilePath); |
|
1219 if (parseTestExecuteIni != NULL) |
|
1220 { |
|
1221 TBuf<KMaxTestExecuteNameLength> tempBuffer; |
|
1222 parseTestExecuteIni->GetKeyValueFromIni(KTEFDefaultScriptPath, tempBuffer); |
|
1223 if (tempBuffer.CompareF(KNull) != 0) |
|
1224 { |
|
1225 scriptFilePath.Set(tempBuffer); |
|
1226 TScriptName tempStoreScriptPath(scriptFilePath); |
|
1227 tempStoreScriptPath.Append(tempStore); |
|
1228 scriptFilePath.Set(tempStoreScriptPath); |
|
1229 TBuf<KMaxTestExecuteNameLength> scriptFileLocation(scriptFilePath); |
|
1230 CScriptMaster* scriptMaster = new (ELeave) CScriptMaster(scriptFilePath,*tefLogger, consoleLogger, iDefaultSysDrive, testSysDrive, selTestingOptions); |
|
1231 // To kick the state machine of the script master off - |
|
1232 // Call the kick method which jumps us into the RunL() of the CScriptMaster class |
|
1233 // CScriptMaster is the top AO in the hierarchy. |
|
1234 scriptMaster->Kick(); |
|
1235 // Enter the Active Scheduler |
|
1236 aScheduler->Start(); |
|
1237 |
|
1238 commentedCommandsCnt=CScriptControl::commentedCommandsCount; |
|
1239 if(commentedCommandsCnt==-1) |
|
1240 { |
|
1241 CScriptControl::commentedCommandsCount=0; |
|
1242 } |
|
1243 |
|
1244 // Cleanup |
|
1245 delete scriptMaster; |
|
1246 } |
|
1247 } |
|
1248 } |
|
1249 } |
|
1250 delete selTestingOptions; |
|
1251 |
|
1252 TInt commandsCount = CScriptControl::commentedCommandsCount; |
|
1253 TInt countOfRemotePanics = 0; |
|
1254 |
|
1255 // Stop and Process the test watcher object for extracting panic informations and print them to the log files |
|
1256 if (remotePanicDetection != 0) |
|
1257 { |
|
1258 testWatcher->Stop(); |
|
1259 countOfRemotePanics = testWatcher->iSharedData->iPanicDetails.Count(); |
|
1260 if (countOfRemotePanics > 0) |
|
1261 { |
|
1262 tefLogger->LogExtra((TText8*)__FILE__,__LINE__,ESevrErr, |
|
1263 _L("The panic detection thread detected %d panics:"), countOfRemotePanics); |
|
1264 for (TInt count = 0; count < countOfRemotePanics; count++) |
|
1265 tefLogger->LogExtra((TText8*)__FILE__,__LINE__,ESevrErr,_L("Remote Panic %d - Name of Panicked Thread: %S, Exit Reason: %d, Exit Category %S"), count+1, &(testWatcher->iSharedData->iPanicDetails)[count]->iThreadName,(testWatcher->iSharedData->iPanicDetails)[count]->iReason,&(testWatcher->iSharedData->iPanicDetails)[count]->iCategory); |
|
1266 } |
|
1267 delete testWatcher; |
|
1268 } |
|
1269 |
|
1270 // Call the Termination routine for logging within the interface |
|
1271 tefLogger->TerminateLoggingL(commandsCount, countOfRemotePanics, CScriptControl::iRunScriptFailCount); |
|
1272 CleanupStack::Pop(tefLogger); |
|
1273 delete tefLogger; |
|
1274 } |
|
1275 |
|
1276 if(iCfg_tcs != EOFF) |
|
1277 { |
|
1278 CleanupStack::PopAndDestroy(selTestCfgFileData); |
|
1279 selTestCfgFileData = NULL; |
|
1280 } |
|
1281 |
|
1282 // Close the parser instance if it is active |
|
1283 CleanupStack::PopAndDestroy(console); |
|
1284 if (parseTestExecuteIni != NULL) |
|
1285 { |
|
1286 CleanupStack::PopAndDestroy(parseTestExecuteIni); |
|
1287 } |
|
1288 |
|
1289 if (scriptFilePath.CompareF(KNull)!=0) |
|
1290 { |
|
1291 // Wait for flogger to write to file |
|
1292 _LIT(KHtmExtension,".htm"); |
|
1293 TParse fileNameParse; |
|
1294 fileNameParse.Set(scriptFilePath, NULL, NULL); |
|
1295 |
|
1296 TPtrC fileName = fileNameParse.Name(); |
|
1297 htmlLogPath.Append(fileName); |
|
1298 htmlLogPath.Append(KHtmExtension); |
|
1299 |
|
1300 __RDEBUG( (_L("Log file path--> %S"), &htmlLogPath) ); |
|
1301 |
|
1302 RFs fs; |
|
1303 fs.Connect(); |
|
1304 TBool answer = EFalse; |
|
1305 while(ETrue) |
|
1306 { |
|
1307 TInt err = fs.IsFileOpen(htmlLogPath, answer); |
|
1308 if ((KErrNone==err&&!answer) || KErrNotFound==err || KErrPathNotFound==err) |
|
1309 { |
|
1310 break; |
|
1311 } |
|
1312 User::After(100000); |
|
1313 } |
|
1314 |
|
1315 if (waitForLoggingTime > 0) |
|
1316 { |
|
1317 User::After(waitForLoggingTime*1000000); |
|
1318 } |
|
1319 fs.Close(); |
|
1320 } |
|
1321 return KErrNone; |
|
1322 } |
|
1323 |
|
1324 // ----------------------------------------------------------------------------- |
|
1325 // CTEFTestModule::CreateCfgDataFromFileL |
|
1326 // ParseTestFrameWorkCfg is used to Read the Cfg File data into a heap buffer |
|
1327 // And populate the arrays of selective test case IDs and |
|
1328 // Ranges to be used by the state machine. |
|
1329 // NOTE: we do not support nested cfgs... |
|
1330 // Returns: void |
|
1331 // ----------------------------------------------------------------------------- |
|
1332 // |
|
1333 void CTEFTestModule::CreateCfgDataFromFileL(TPtrC& aCfgFilePath,RArray<TRange>& aSelectiveCaseRange, TDesC*& aSelTestCfgFileData) |
|
1334 { |
|
1335 RFs fS; |
|
1336 User::LeaveIfError(fS.Connect()); |
|
1337 CleanupClosePushL(fS); |
|
1338 RFile cfgFile; |
|
1339 User::LeaveIfError(cfgFile.Open(fS,aCfgFilePath,EFileRead | EFileShareAny)); |
|
1340 CleanupClosePushL(cfgFile); |
|
1341 TInt fileSize; |
|
1342 User::LeaveIfError(cfgFile.Size(fileSize)); |
|
1343 // Create a 16bit heap buffer |
|
1344 HBufC* cfgData = HBufC::NewL(fileSize); |
|
1345 CleanupStack::PushL(cfgData); |
|
1346 HBufC8* narrowData = HBufC8::NewL(fileSize); |
|
1347 CleanupStack::PushL(narrowData); |
|
1348 TPtr8 narrowPtr=narrowData->Des(); |
|
1349 // Read the file into an 8bit heap buffer |
|
1350 User::LeaveIfError(cfgFile.Read(narrowPtr)); |
|
1351 TPtr widePtr(cfgData->Des()); |
|
1352 // Copy it to the 16bit buffer |
|
1353 widePtr.Copy(narrowData->Des()); |
|
1354 CleanupStack::PopAndDestroy(narrowData); |
|
1355 CleanupStack::Pop(cfgData); |
|
1356 CleanupStack::Pop(2); |
|
1357 cfgFile.Close(); |
|
1358 fS.Close(); |
|
1359 // Set up the instance token parser |
|
1360 TLex cfgLex = cfgData->Des(); |
|
1361 aSelTestCfgFileData = cfgData; // to preserve the pointer of cfgdata and transfer the ownership to aSelTestCfgFileData |
|
1362 cfgData = NULL; // relinquish the ownership |
|
1363 while(!cfgLex.Eos()) |
|
1364 { |
|
1365 DistinguishElement(cfgLex.NextToken(),aSelectiveCaseRange) ; |
|
1366 } |
|
1367 } |
|
1368 |
|
1369 // ----------------------------------------------------------------------------- |
|
1370 // CTEFTestModule::ParseTcsDataForSelectiveTestingOptions |
|
1371 // DistinguishElement is used to parse TcsData from configration file to select test case flag. |
|
1372 // Get cases Included or Excluded. |
|
1373 // Returns: void |
|
1374 // ----------------------------------------------------------------------------- |
|
1375 // |
|
1376 void CTEFTestModule::ParseTcsDataForSelectiveTestingOptions( const TTcsName& aTcsData, |
|
1377 CTestExecuteIniData& aParseTestExecuteIni, |
|
1378 RArray<TRange>& aSelectiveCaseRange, |
|
1379 TDesC*& aSelTestCfgFileData ) |
|
1380 { |
|
1381 TPtrC argument(aTcsData) ; |
|
1382 while(argument.Length() > 0 ) |
|
1383 { |
|
1384 TInt commaOccurance = argument.FindC(KTEFComma) ; |
|
1385 TPtrC element ; |
|
1386 if(commaOccurance == -1) |
|
1387 { |
|
1388 //handle the case where no comma is found, |
|
1389 //assume only one item in the list |
|
1390 element.Set(argument) ; |
|
1391 //reset argument to break the while |
|
1392 argument.Set(KNull); |
|
1393 } |
|
1394 else |
|
1395 { |
|
1396 element.Set(argument.Left(commaOccurance)); |
|
1397 //take the remaining in the argument |
|
1398 TInt len = argument.Length()-commaOccurance-1 ; |
|
1399 argument.Set(argument.Right(len)) ; |
|
1400 } |
|
1401 |
|
1402 TInt cfgExtensionOccurance = element.FindC(KTEFCfgExtension) ; |
|
1403 if (cfgExtensionOccurance!=KErrNotFound) //madatory extension to be given |
|
1404 { |
|
1405 |
|
1406 TPtrC cfgFilePath(element); |
|
1407 //its probably the cfg file path. |
|
1408 TScriptName tempScriptPath(cfgFilePath); |
|
1409 // Check whether cfg name is provided along with folder path in the command line |
|
1410 // If not, take the path from testexecute.ini & name from the command line |
|
1411 if(cfgFilePath.FindC(KTEFColon)==KErrNotFound) |
|
1412 { |
|
1413 TBuf<KMaxTestExecuteNameLength> tempBuffer; |
|
1414 aParseTestExecuteIni.GetKeyValueFromIni(KTEFDefaultScriptPath, tempBuffer); |
|
1415 cfgFilePath.Set(tempBuffer); |
|
1416 // Construct the full file path from the values extracted from command line and ini file |
|
1417 TScriptName storeScriptPathTemp(cfgFilePath); |
|
1418 storeScriptPathTemp.Append(tempScriptPath); |
|
1419 cfgFilePath.Set(storeScriptPathTemp); |
|
1420 tempScriptPath.Copy(cfgFilePath); |
|
1421 } |
|
1422 // and parse this cfg File to populate our structures |
|
1423 TRAP_IGNORE(CreateCfgDataFromFileL(cfgFilePath,aSelectiveCaseRange, aSelTestCfgFileData)); |
|
1424 //actually do nothing with the error... |
|
1425 } |
|
1426 else |
|
1427 { |
|
1428 DistinguishElement(element,aSelectiveCaseRange ); |
|
1429 } |
|
1430 } |
|
1431 } |
|
1432 // ----------------------------------------------------------------------------- |
|
1433 // CTEFTestModule::DistinguishElement |
|
1434 // DistinguishElement is used to get the element from configration |
|
1435 // Returns: void |
|
1436 // ----------------------------------------------------------------------------- |
|
1437 // |
|
1438 void CTEFTestModule::DistinguishElement(const TPtrC& aElement, RArray<TRange>& aSelectiveCaseRange) |
|
1439 { |
|
1440 |
|
1441 TInt colonOccurance = aElement.FindC(KTEFColon); |
|
1442 //we are expecting only a range or a test case ID over here... |
|
1443 if( colonOccurance!=KErrNotFound ) |
|
1444 { |
|
1445 //then this is a range of testcases, split it at the colon |
|
1446 TRange newRange(aElement.Left(colonOccurance),aElement.Mid(colonOccurance+1)); |
|
1447 aSelectiveCaseRange.Append(newRange); |
|
1448 } |
|
1449 else |
|
1450 { |
|
1451 TRange newRange(aElement,aElement); |
|
1452 aSelectiveCaseRange.Append(newRange); |
|
1453 } |
|
1454 } |
|
1455 |
|
1456 // ----------------------------------------------------------------------------- |
|
1457 // CTEFTestModule::ParseStackSize |
|
1458 // Get stack size set by user, in TestFramework.ini. |
|
1459 // Returns: TInt. System wide error code. |
|
1460 // ----------------------------------------------------------------------------- |
|
1461 // |
|
1462 TInt CTEFTestModule::ParseStackSizeL(TInt& aStackSize) |
|
1463 { |
|
1464 //Parse from testframwork to get stack size set of TEFTestModule. |
|
1465 //If not found, default stack size is 28672. |
|
1466 CStifParser* parser = NULL; |
|
1467 TRAPD( err, |
|
1468 parser = CStifParser::NewL( _L(""), |
|
1469 _L("c:\\TestFramework\\TestFramework.ini"), |
|
1470 CStifParser::ECStyleComments ) ); |
|
1471 if( err != KErrNone ) |
|
1472 { |
|
1473 __RDEBUG( (_L("Error: TestFramework.ini not found"))); |
|
1474 return err; |
|
1475 } |
|
1476 CleanupStack::PushL( parser ); |
|
1477 CStifSectionParser* section = NULL; |
|
1478 _LIT( KModuleStartTag, "[New_Module]" ); |
|
1479 _LIT( KModuleEndTag, "[End_Module]" ); |
|
1480 section = parser->SectionL( KModuleStartTag, KModuleEndTag ); |
|
1481 if( section == NULL ) |
|
1482 { |
|
1483 CleanupStack::PopAndDestroy( parser ); |
|
1484 parser = NULL; |
|
1485 return KErrNone; |
|
1486 } |
|
1487 while(section) |
|
1488 { |
|
1489 // Parse section |
|
1490 CleanupStack::PushL( section ); |
|
1491 |
|
1492 CStifItemParser* item = NULL; |
|
1493 // Get ModuleName from configuration file. |
|
1494 TRAPD( getModuleName, item = section ->GetItemLineL(_L( "ModuleName=" ), ENoTag)); |
|
1495 if( getModuleName != KErrNone ) |
|
1496 { |
|
1497 __RDEBUG( (_L("Error: From file TestFramework.ini, get item 'ModuleName=' leaves with error: %d."),getModuleName) ); |
|
1498 delete item; |
|
1499 item=NULL; |
|
1500 CleanupStack::PopAndDestroy( section ); |
|
1501 section = NULL; |
|
1502 CleanupStack::PopAndDestroy( parser ); |
|
1503 parser = NULL; |
|
1504 return getModuleName; |
|
1505 } |
|
1506 if( !item ) |
|
1507 { |
|
1508 delete item; |
|
1509 item=NULL; |
|
1510 CleanupStack::PopAndDestroy( section ); |
|
1511 section = NULL; |
|
1512 CleanupStack::PopAndDestroy( parser ); |
|
1513 parser = NULL; |
|
1514 return KErrNone; |
|
1515 } |
|
1516 else |
|
1517 { |
|
1518 TPtrC moduleName; |
|
1519 item->GetString( _L( "" ), moduleName ); |
|
1520 HBufC* moduleNameHbuf = moduleName.AllocL(); |
|
1521 TPtr modifiableString = moduleNameHbuf->Des(); |
|
1522 modifiableString.UpperCase(); |
|
1523 |
|
1524 if( modifiableString == _L( "TEFTESTMODULE" ) ) |
|
1525 { |
|
1526 CStifItemParser* itemStackSize = NULL; |
|
1527 TRAPD( getStackSize, itemStackSize = section ->GetItemLineL(_L( "StackSize=" ), ENoTag)); |
|
1528 if( getStackSize != KErrNone ) |
|
1529 { |
|
1530 __RDEBUG( (_L("Error: From file TestFramework.ini, get item 'getStackSize=' leaves with error: %d."),getStackSize) ); |
|
1531 delete item; |
|
1532 item=NULL; |
|
1533 delete moduleNameHbuf; |
|
1534 moduleNameHbuf=NULL; |
|
1535 CleanupStack::PopAndDestroy( section ); |
|
1536 section = NULL; |
|
1537 CleanupStack::PopAndDestroy( parser ); |
|
1538 parser = NULL; |
|
1539 return getStackSize; |
|
1540 } |
|
1541 if( !itemStackSize ) |
|
1542 { |
|
1543 delete item; |
|
1544 item=NULL; |
|
1545 delete moduleNameHbuf; |
|
1546 moduleNameHbuf=NULL; |
|
1547 CleanupStack::PopAndDestroy( section ); |
|
1548 section = NULL; |
|
1549 CleanupStack::PopAndDestroy( parser ); |
|
1550 parser = NULL; |
|
1551 return KErrNone; |
|
1552 } |
|
1553 else |
|
1554 { |
|
1555 itemStackSize->GetInt( _L( "" ), aStackSize ); |
|
1556 CleanupStack::PopAndDestroy( section ); |
|
1557 section = NULL; |
|
1558 delete itemStackSize; |
|
1559 itemStackSize = NULL; |
|
1560 } |
|
1561 } |
|
1562 else |
|
1563 { |
|
1564 CleanupStack::PopAndDestroy(section); |
|
1565 section = NULL; |
|
1566 section = parser->NextSectionL(KModuleStartTag, KModuleEndTag); |
|
1567 } |
|
1568 |
|
1569 delete moduleNameHbuf; |
|
1570 moduleNameHbuf=NULL; |
|
1571 delete item; |
|
1572 item=NULL; |
|
1573 |
|
1574 } |
|
1575 } |
|
1576 CleanupStack::PopAndDestroy( parser ); |
|
1577 return KErrNone; |
|
1578 } |
|
1579 // ----------------------------------------------------------------------------- |
|
1580 // CTEFTestModule::StartSystemL |
|
1581 // DistinguishElement is used to load and wait to start. |
|
1582 // StartSystemL() will be build and called only when Lite version is NOT defined. |
|
1583 // Returns: void |
|
1584 // ----------------------------------------------------------------------------- |
|
1585 // |
|
1586 |
|
1587 #if !(defined TEF_LITE) |
|
1588 void CTEFTestModule::StartSystemL(void) |
|
1589 { |
|
1590 CActiveScheduler* theScheduler = new (ELeave) CActiveScheduler(); |
|
1591 CleanupStack::PushL(theScheduler); |
|
1592 CActiveScheduler::Install(theScheduler); |
|
1593 |
|
1594 RLibrary pluginLibrary; |
|
1595 CWrapperUtilsPlugin* plugin = TEFUtils::WrapperPluginNew(pluginLibrary); |
|
1596 |
|
1597 if (plugin!=NULL) |
|
1598 { |
|
1599 CleanupStack::PushL(plugin); |
|
1600 plugin->WaitForSystemStartL(); |
|
1601 CleanupStack::PopAndDestroy(plugin); |
|
1602 pluginLibrary.Close(); |
|
1603 } |
|
1604 else |
|
1605 { |
|
1606 User::Leave(KErrGeneral); |
|
1607 } |
|
1608 |
|
1609 CleanupStack::PopAndDestroy(theScheduler); |
|
1610 } |
|
1611 #endif |
|
1612 |
|
1613 // End of File |