|
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 * Interface class which exposes methods to TestExecute to mediate calls to HTML and XML log client sessions |
|
16 * Includes construction of console which was previosly within the testexecute.cpp |
|
17 * Includes methods for initialising log creation & writing initial and end up tags and results summary |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 /** |
|
24 @file TestExecuteLogger.cpp |
|
25 */ |
|
26 |
|
27 #include "TestExecuteLogger.h" |
|
28 #include "Version.h" |
|
29 #include "TEFConst.h" |
|
30 #include "SerialWriter.h" |
|
31 #include <wrapperutilsplugin.h> |
|
32 #include <test/tefutils.h> |
|
33 |
|
34 _LIT8(KHtmlBegin8,"<html><body><pre>\n"); |
|
35 _LIT8(KHtmlEnd8,"</pre></body></html>\n"); |
|
36 _LIT(KHtmlBegin16,"<html><body><pre>"); |
|
37 _LIT(KHtmlEnd16,"</pre></body></html>"); |
|
38 |
|
39 // Test Block XML literals |
|
40 _LIT(KObjectType, "OBJECT_TYPE"); |
|
41 _LIT(KObjectSection, "OBJECT_SECTION"); |
|
42 _LIT(KSection, "SECTION"); |
|
43 _LIT(KFunctionName, "FUNCTION_NAME"); |
|
44 _LIT(KDelay, "DELAY"); |
|
45 _LIT(KInterval, "INTERVAL"); |
|
46 _LIT(KEErrorCode, "EXPECTED_ERROR_CODE"); |
|
47 _LIT(KErrorCode, "ERROR_CODE"); |
|
48 _LIT(KEAsyncErrorCode, "EXPECTED_ASYNC_ERROR_CODE"); |
|
49 _LIT(KAsyncErrorCode, "ASYNC_ERROR_CODE"); |
|
50 _LIT(KBadCommand, "BAD_COMMAND"); |
|
51 |
|
52 /** |
|
53 * Logging Test result information to html formatted file and, at same time, |
|
54 * a simplified test file. |
|
55 * The html file is TEF traditional log result file used to acting as TestDB. |
|
56 * The simplified file is used to enable super amount test cases. |
|
57 * @param aLogFileDir - Directory of log file, usually @ testexecute.ini |
|
58 * HTML = ${SYSDRIVE}\logs\testexecute\ |
|
59 * @param aLogFileName - name of log file. |
|
60 * @param aResultBuf - log result this is buffer of log. |
|
61 * |
|
62 * @internalComponent |
|
63 */ |
|
64 void CTestExecuteLogger::LoggingTestCaseResultToSummaryResultL( const TDesC &aLogFileDir,const TDesC &aLogFileName,const TDesC8 &aResultBuf) |
|
65 { |
|
66 RFs fS; |
|
67 User::LeaveIfError(fS.Connect()); |
|
68 CleanupClosePushL(fS); |
|
69 |
|
70 TBuf<KMaxTestExecuteNameLength> resultFileName(aLogFileDir); |
|
71 resultFileName.Append(aLogFileName); |
|
72 RFile logFile; |
|
73 User::LeaveIfError(logFile.Open(fS,resultFileName, EFileWrite | EFileRead | EFileShareAny)); |
|
74 CleanupClosePushL(logFile); |
|
75 |
|
76 TInt pos=0; |
|
77 (void)logFile.Seek(ESeekEnd, pos); |
|
78 (void)logFile.Write(aResultBuf); |
|
79 |
|
80 // Closing of objects |
|
81 CleanupStack::Pop(&logFile); |
|
82 logFile.Close(); |
|
83 CleanupStack::Pop(&fS); |
|
84 fS.Close(); |
|
85 } |
|
86 |
|
87 |
|
88 /** |
|
89 * @param aLogOptions - One of the 3 enum values for HTML, XML and both HTML & XML logging |
|
90 * Constructor |
|
91 * Initialises HTML & XML objects for logging |
|
92 */ |
|
93 EXPORT_C CTestExecuteLogger::CTestExecuteLogger(TLoggerOptions aLogOptions) : |
|
94 iLoggerOptions(aLogOptions), |
|
95 iSerialWriter(NULL), |
|
96 iPIPSExists(false) |
|
97 { |
|
98 } |
|
99 |
|
100 /** |
|
101 * Destructor |
|
102 */ |
|
103 EXPORT_C CTestExecuteLogger::~CTestExecuteLogger() |
|
104 { |
|
105 } |
|
106 |
|
107 /** |
|
108 * @param aFile - Name of the file that intiates the LogExtra call |
|
109 * @param aLine - Line number within the file that initiates the call |
|
110 * @param aSeverity - One of the 4 enum values indicating the severity of the message to be logged |
|
111 * @param aFmt - Format string that indicates the number & type of inputs required for the variable argument call |
|
112 * Function displays the message in the log based on the number of inputs followed by the format string |
|
113 */ |
|
114 EXPORT_C void CTestExecuteLogger::LogExtra(const TText8* aFile, TInt aLine, TInt aSeverity,TRefByValue<const TDesC> aFmt,...) |
|
115 { |
|
116 // Create a variable list and collect the arguments into it |
|
117 VA_LIST aList; |
|
118 VA_START(aList, aFmt); |
|
119 |
|
120 if(iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
121 { |
|
122 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
123 { |
|
124 // Call the Html log client interface for logging into html log |
|
125 HtmlLogger().LogExtra(aFile, aLine, aSeverity, aFmt, aList); |
|
126 } |
|
127 if (iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth) |
|
128 { |
|
129 // Call the Xml log client interface for logging into xml log |
|
130 XmlLogger().Log(aFile, aLine, RFileFlogger::TLogSeverity(aSeverity), aFmt, aList); |
|
131 } |
|
132 if(iPIPSExists) |
|
133 { |
|
134 PIPSLogger().LogExtra(aFile, aLine, aSeverity, aFmt, aList); |
|
135 } |
|
136 } |
|
137 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
138 { |
|
139 HBufC* buffer = HBufC::New(KMaxTestExecuteLogLineLength*2); |
|
140 if (buffer) |
|
141 { |
|
142 TPtr ptr(buffer->Des()); |
|
143 ptr.AppendFormatList(aFmt, aList); |
|
144 iSerialWriter->WriteDecorated(ptr); |
|
145 delete buffer; |
|
146 } |
|
147 } |
|
148 |
|
149 VA_END(aList); |
|
150 } |
|
151 |
|
152 EXPORT_C TInt CTestExecuteLogger::ShareAuto() |
|
153 { |
|
154 if(iPIPSExists) |
|
155 { |
|
156 PIPSLogger().ShareAuto(); |
|
157 } |
|
158 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
159 { |
|
160 return HtmlLogger().ShareAuto(); |
|
161 } |
|
162 return KErrNone; |
|
163 } |
|
164 |
|
165 EXPORT_C void CTestExecuteLogger::Write(const TDesC& aLogBuffer) |
|
166 { |
|
167 if(iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
168 { |
|
169 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
170 { |
|
171 HtmlLogger().Write(aLogBuffer); |
|
172 } |
|
173 } |
|
174 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
175 { |
|
176 iSerialWriter->WriteDecorated(aLogBuffer) ; |
|
177 } |
|
178 if(iPIPSExists) |
|
179 { |
|
180 PIPSLogger().Write(aLogBuffer); |
|
181 } |
|
182 } |
|
183 |
|
184 EXPORT_C void CTestExecuteLogger::WriteFormat(TRefByValue<const TDesC> aFmt,...) |
|
185 { |
|
186 VA_LIST aList; |
|
187 VA_START(aList, aFmt); |
|
188 if(iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
189 { |
|
190 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
191 { |
|
192 HtmlLogger().WriteFormat(aFmt, aList); |
|
193 } |
|
194 } |
|
195 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
196 { |
|
197 HBufC* buffer = HBufC::New(KMaxTestExecuteLogLineLength*2); |
|
198 if (buffer) |
|
199 { |
|
200 TPtr ptr(buffer->Des()); |
|
201 ptr.AppendFormatList(aFmt, aList); |
|
202 iSerialWriter->WriteDecorated(ptr); |
|
203 delete buffer; |
|
204 } |
|
205 } |
|
206 if(iPIPSExists) |
|
207 { |
|
208 PIPSLogger().WriteFormat(aFmt, aList); |
|
209 } |
|
210 |
|
211 VA_END(aList); |
|
212 } |
|
213 |
|
214 EXPORT_C void CTestExecuteLogger::Write(const TDesC8& aLogBuffer) |
|
215 { |
|
216 if(iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
217 { |
|
218 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
219 { |
|
220 HtmlLogger().Write(aLogBuffer); |
|
221 } |
|
222 } |
|
223 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
224 { |
|
225 iSerialWriter->WriteDecorated(aLogBuffer) ; |
|
226 } |
|
227 if(iPIPSExists) |
|
228 { |
|
229 PIPSLogger().Write(aLogBuffer); |
|
230 } |
|
231 } |
|
232 |
|
233 EXPORT_C void CTestExecuteLogger::WriteFormat(TRefByValue<const TDesC8> aFmt,...) |
|
234 { |
|
235 // Set up a Variable argument list and call private method |
|
236 VA_LIST aList; |
|
237 VA_START(aList, aFmt); |
|
238 if(iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
239 { |
|
240 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
241 { |
|
242 HtmlLogger().WriteFormat(aFmt, aList); |
|
243 } |
|
244 } |
|
245 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
246 { |
|
247 HBufC8* buffer = HBufC8::New(KMaxTestExecuteLogLineLength*2); |
|
248 if (buffer) |
|
249 { |
|
250 TPtr8 ptr(buffer->Des()); |
|
251 ptr.AppendFormatList(aFmt, aList); |
|
252 iSerialWriter->WriteDecorated(ptr); |
|
253 delete buffer; |
|
254 } |
|
255 } |
|
256 if(iPIPSExists) |
|
257 { |
|
258 PIPSLogger().WriteFormat(aFmt, aList); |
|
259 } |
|
260 VA_END(aList); |
|
261 } |
|
262 |
|
263 /** |
|
264 * @param aFile - Name of the file that intiates the LogExtra call |
|
265 * @param aLine - Line number within the file that initiates the call |
|
266 * @param aSeverity - One of the 4 enum values indicating the severity of the message to be logged |
|
267 * @param aCommandName - Name of the command whose fields are logged with the call to the function |
|
268 * @param aNumberOfParams - Represents the size of the structure array being passed in to the function |
|
269 * @param aLogFields - Pointer to the structure array passed in, that contains the field name & their values |
|
270 * Logs the command name along with their field names and values corresponding to each of them |
|
271 * The array should be passed in with structures for holding each of the field name/value pairs |
|
272 */ |
|
273 EXPORT_C void CTestExecuteLogger::LogToXml(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aCommandName, const TInt aNumberOfParams, TExtraLogField* aLogFields) |
|
274 { |
|
275 if((iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
276 &&(iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth)) |
|
277 { |
|
278 XmlLogger().Log(aFile, aLine, RFileFlogger::TLogSeverity(aSeverity), aNumberOfParams, aLogFields, KTEFStringFormat, &aCommandName); |
|
279 } |
|
280 } |
|
281 |
|
282 /** |
|
283 * @param aFile - Name of the file that intiates the LogExtra call |
|
284 * @param aLine - Line number within the file that initiates the call |
|
285 * @param aSeverity - One of the 4 enum values indicating the severity of the message to be logged |
|
286 * @param aCommandName - Name of the command whose fields are logged with the call to the function |
|
287 * Logs the command name alone for those that does not have any valid fields for logging |
|
288 */ |
|
289 EXPORT_C void CTestExecuteLogger::LogToXml(const TText8* aFile, TInt aLine, TInt aSeverity,const TDesC& aCommandName) |
|
290 { |
|
291 if((iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
292 &&(iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth)) |
|
293 { |
|
294 XmlLogger().Log(aFile, aLine, RFileFlogger::TLogSeverity(aSeverity), KTEFStringFormat, &aCommandName); |
|
295 } |
|
296 } |
|
297 |
|
298 /** |
|
299 * @param aScriptFilePath - Relative path where the script file is placed |
|
300 * @param aSeparateLogFileMode - Flag that is switched on for separate file for logging, off otherwise |
|
301 * @param aLogLevel - Indicates the default threshold level for logging messages within the XML log |
|
302 * Initialises the logging for both HTML and XML, creating the directory path & files and adding initial tags for the logs |
|
303 */ |
|
304 EXPORT_C void CTestExecuteLogger::InitialiseLoggingL(const TDesC& aScriptFilePath, TBool aSeparateLogFileMode, TInt aLogLevel) |
|
305 { |
|
306 // Check to see if the plugin wrapper around the GetSystemDrive is loadable |
|
307 // If yes, then instantiate the wrapper object and obtain the default system drive |
|
308 // Else, use the hardcoded default drive as c: |
|
309 TDriveName defaultSysDrive(KTEFLegacySysDrive); |
|
310 RFs fileServer; |
|
311 TVersionName version(fileServer.Version().Name()); |
|
312 |
|
313 RLibrary pluginLibrary; |
|
314 CWrapperUtilsPlugin* plugin = TEFUtils::WrapperPluginNew(pluginLibrary); |
|
315 |
|
316 if (plugin!=NULL) |
|
317 { |
|
318 TDriveUnit driveUnit(plugin->GetSystemDrive()); |
|
319 defaultSysDrive.Copy(driveUnit.Name()); |
|
320 delete plugin; |
|
321 pluginLibrary.Close(); |
|
322 } |
|
323 |
|
324 // Create a object of Cinidata for parsing ini files |
|
325 CTestExecuteIniData* parseTestExecuteIni = NULL; |
|
326 TBuf<KMaxTestExecuteNameLength> htmlLogPath; |
|
327 TBuf<KMaxTestExecuteNameLength> xmlLogPath; |
|
328 TInt logLevel(aLogLevel); |
|
329 TInt enableCommandsCountLogging; |
|
330 TInt outPort; |
|
331 |
|
332 TRAPD(err,parseTestExecuteIni = CTestExecuteIniData::NewL(defaultSysDrive)); |
|
333 if (err == KErrNone) |
|
334 { |
|
335 CleanupStack::PushL(parseTestExecuteIni); |
|
336 parseTestExecuteIni->ExtractValuesFromIni(); |
|
337 parseTestExecuteIni->GetKeyValueFromIni(KTEFHtmlKey, htmlLogPath); |
|
338 iHtmlLogPath.Copy(htmlLogPath); |
|
339 parseTestExecuteIni->GetKeyValueFromIni(KTEFXmlKey, xmlLogPath); |
|
340 iXmlLogPath.Copy(xmlLogPath); |
|
341 parseTestExecuteIni->GetKeyValueFromIni(KTEFRemotePanicDetection, iRemotePanic); |
|
342 parseTestExecuteIni->GetKeyValueFromIni(KTEFEnableTestsCountLog, enableCommandsCountLogging); |
|
343 parseTestExecuteIni->GetKeyValueFromIni(KTEFLogChannel, iLoggerChannel); |
|
344 parseTestExecuteIni->GetKeyValueFromIni(KTEFOutputPort, outPort); |
|
345 CleanupStack::PopAndDestroy(parseTestExecuteIni); |
|
346 } |
|
347 else |
|
348 { |
|
349 TBuf<KMaxTestExecuteNameLength> testExecuteLogPath(KTestExecuteLogPath); |
|
350 testExecuteLogPath.Replace(0, 2, defaultSysDrive); |
|
351 iHtmlLogPath.Copy(testExecuteLogPath); |
|
352 iXmlLogPath.Copy(testExecuteLogPath); |
|
353 iRemotePanic = 0; |
|
354 enableCommandsCountLogging = KTEFOneValue; |
|
355 } |
|
356 |
|
357 RFs fS; |
|
358 User::LeaveIfError(fS.Connect()); |
|
359 CleanupClosePushL(fS); |
|
360 // Create the path arrived above |
|
361 err = fS.MkDirAll(iHtmlLogPath); |
|
362 if(err != KErrNone && err != KErrAlreadyExists) |
|
363 User::Leave(err); // Leave if unable to create the HTML log path |
|
364 err = fS.MkDirAll(iXmlLogPath); |
|
365 if(err != KErrNone && err != KErrAlreadyExists) |
|
366 User::Leave(err); // Leave if unable to create the XML log path |
|
367 |
|
368 // Delete any existing KTestExecuteScheduleTestLogCompatibilityNameFile |
|
369 TBuf<KMaxTestExecuteNameLength> scheduleTestLogFileNameFile(iHtmlLogPath); |
|
370 scheduleTestLogFileNameFile.Append(KTestExecuteScheduleTestLogCompatibilityNameFile); |
|
371 (void)fS.Delete(scheduleTestLogFileNameFile); |
|
372 TBuf<KMaxTestExecuteNameLength> loggerFile; |
|
373 // Set up for separate log files as a safeguard |
|
374 _LIT(KScriptEngine,"ScriptEngine"); |
|
375 loggerFile.Copy(KScriptEngine); |
|
376 |
|
377 // HTML format |
|
378 _LIT(KHtmExtension,".htm"); |
|
379 // XML format |
|
380 _LIT(KXmlExtension,".xml"); |
|
381 |
|
382 if(!aSeparateLogFileMode) |
|
383 { |
|
384 // Extract the log file name from the full script file path |
|
385 // For example - z:\somefolder\somefile.script |
|
386 // We try and extract "somefile". |
|
387 _LIT(KTEFScriptExtension,".script"); |
|
388 TInt offset = aScriptFilePath.Find(KTEFScriptExtension); |
|
389 if(offset != KErrNotFound) |
|
390 { |
|
391 // Loop back to isolate \somefile.script |
|
392 TInt i = offset-1; |
|
393 for(;i;i--) |
|
394 { |
|
395 if(aScriptFilePath[i] == '\\') |
|
396 break; |
|
397 } |
|
398 if(i) |
|
399 { |
|
400 // Get rid of the '\' |
|
401 i++; |
|
402 // For defect 116013, check the name length+path length. If bigger than 80 then leave KErrTooBig |
|
403 if (offset-i+iHtmlLogPath.Length()+KHtmExtension().Length() > KMaxTestExecuteNameLength |
|
404 || offset-i+iHtmlLogPath.Length()+KXmlExtension().Length() > KMaxTestExecuteNameLength) |
|
405 { |
|
406 User::Leave(KErrTooBig); |
|
407 } |
|
408 // END defect 116013 |
|
409 // Isolated somefile.script |
|
410 TInt j(0); |
|
411 // Chop off the ".script" |
|
412 loggerFile.SetLength(offset-i); |
|
413 for(;i<offset;i++,j++) |
|
414 loggerFile[j]=aScriptFilePath[i]; |
|
415 RFile file; |
|
416 CleanupClosePushL(file); |
|
417 // Create KTestExecuteScheduleTestLogCompatibilityNameFile |
|
418 User::LeaveIfError(file.Create(fS,scheduleTestLogFileNameFile,EFileShareAny | EFileWrite)); |
|
419 TBuf8<KMaxTestExecuteNameLength> loggerFile8; |
|
420 loggerFile8.Copy(loggerFile); |
|
421 // Write "somefile" |
|
422 User::LeaveIfError(file.Write(loggerFile8)); |
|
423 CleanupStack::Pop(&file); |
|
424 file.Close(); |
|
425 } |
|
426 } |
|
427 } |
|
428 |
|
429 // Construct the full path for HTML |
|
430 TBuf<KMaxTestExecuteNameLength> loggerHtmlFilePath(iHtmlLogPath); |
|
431 loggerHtmlFilePath.Append(loggerFile); |
|
432 loggerHtmlFilePath.Append(KHtmExtension); |
|
433 // Construct the full path for XML |
|
434 TBuf<KMaxTestExecuteNameLength> loggerXmlFilePath(iXmlLogPath); |
|
435 loggerXmlFilePath.Append(loggerFile); |
|
436 loggerXmlFilePath.Append(KXmlExtension); |
|
437 |
|
438 // Delete the log files if it exists |
|
439 (void)fS.Delete(loggerHtmlFilePath); |
|
440 (void)fS.Delete(loggerXmlFilePath); |
|
441 |
|
442 // Delete the summary file if it exists |
|
443 TBuf<KMaxTestExecuteNameLength> resultSummary(iHtmlLogPath); |
|
444 resultSummary.Append(KTEFTestExecuteResultSummaryFile); |
|
445 (void)fS.Delete(resultSummary); |
|
446 RFile file; |
|
447 // Create a summary file and write the html tags |
|
448 User::LeaveIfError(file.Create(fS,resultSummary, EFileShareAny | EFileWrite)); |
|
449 CleanupClosePushL(file); |
|
450 User::LeaveIfError(file.Write(KHtmlBegin8)); |
|
451 CleanupStack::Pop(&file); |
|
452 file.Close(); |
|
453 |
|
454 // Delete the simplified summary file |
|
455 TBuf<KMaxTestExecuteNameLength> resultSimplifiedSummaryFile(iHtmlLogPath); |
|
456 resultSimplifiedSummaryFile.Append(KTEFTestExecuteResultSimplifiedSummaryFile); |
|
457 (void)fS.Delete(resultSimplifiedSummaryFile); |
|
458 // Create the brand-new simplified summary file |
|
459 User::LeaveIfError(file.Create(fS,resultSimplifiedSummaryFile, EFileShareAny | EFileWrite)); |
|
460 file.Close(); |
|
461 |
|
462 CleanupStack::Pop(&fS); |
|
463 fS.Close(); |
|
464 |
|
465 // Connect to HTML and XML log client session |
|
466 User::LeaveIfError(Connect()); |
|
467 |
|
468 // Update the array of commands for any additions to commands count |
|
469 // Also update the KTEFCommandCountsStructSize from the TEFExportConst.h for array size |
|
470 TPtrC commandList[KTEFCommandCountsStructSize] = |
|
471 { |
|
472 TPtrC(KTEFRunScriptCommand), |
|
473 TPtrC(KTEFStartTestCaseCommand), |
|
474 TPtrC(KTEFRunTestStepCommand), |
|
475 TPtrC(KTEFRunTestStepResultCommand), |
|
476 TPtrC(KTEFRunPanicStepCommand), |
|
477 TPtrC(KTEFRunPanicStepResultCommand), |
|
478 TPtrC(KTEFRunProgramCommand), |
|
479 TPtrC(KTEFRunWSProgramCommand), |
|
480 TPtrC(KTEFStartTestBlock) |
|
481 }; |
|
482 |
|
483 iRunScriptCommandCount = 0; |
|
484 // Create an instance of the script pre-processor to extract count details of commands listed in array defined above |
|
485 CScriptPreProcess scriptPreProcess(aScriptFilePath, commandList); |
|
486 |
|
487 // enableCommandsCountLogging is a flag which is updated based on the configuration done in testexecute.ini |
|
488 // The script should be pre-processed only if the flag is set to ON in testexecute.ini |
|
489 // The flag is set to OFF by default |
|
490 if (enableCommandsCountLogging == KTEFOneValue) |
|
491 { |
|
492 // Start pre-processing and updates the counts in the structure array |
|
493 scriptPreProcess.CountNoOfOccurences(); |
|
494 } |
|
495 |
|
496 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
497 { |
|
498 InitialiseSerialLoggingL(logLevel, enableCommandsCountLogging, scriptPreProcess,outPort); |
|
499 } |
|
500 if(iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
501 { |
|
502 if (iLoggerOptions == ELogHTMLOnly) |
|
503 { |
|
504 // Call Initilise routine for HTML logging |
|
505 // Also need to pass in the status of the enableCommandsCountLogging and the pre-processor object |
|
506 InitialiseHTMLLoggingL(loggerHtmlFilePath, logLevel, enableCommandsCountLogging, scriptPreProcess); |
|
507 } |
|
508 else if (iLoggerOptions == ELogXMLOnly) |
|
509 { |
|
510 // Call Initilise routine for XML logging |
|
511 // Also need to pass in the status of the enableCommandsCountLogging and the pre-processor object |
|
512 InitialiseXMLLoggingL(loggerXmlFilePath, logLevel, enableCommandsCountLogging, scriptPreProcess); |
|
513 } |
|
514 else |
|
515 { |
|
516 // Call Initilise routine for HTML & XML logging |
|
517 // Also need to pass in the status of the enableCommandsCountLogging and the pre-processor object |
|
518 InitialiseHTMLLoggingL(loggerHtmlFilePath, logLevel, enableCommandsCountLogging, scriptPreProcess); |
|
519 InitialiseXMLLoggingL(loggerXmlFilePath, logLevel, enableCommandsCountLogging, scriptPreProcess); |
|
520 } |
|
521 } |
|
522 if(iPIPSExists) |
|
523 { |
|
524 InitialisePIPSLoggingL(logLevel, enableCommandsCountLogging, scriptPreProcess) ; |
|
525 } |
|
526 } |
|
527 |
|
528 |
|
529 |
|
530 EXPORT_C void CTestExecuteLogger::SetPipeName(TPtrC& aPipeName) |
|
531 |
|
532 { |
|
533 User::LeaveIfError(PIPSLogger().CreateLog(aPipeName)); |
|
534 } |
|
535 /** |
|
536 * Connects to the HTML log client session and creating the logs with initial tags for logging |
|
537 * @param aLogFilePath - Relative path that is arrived after retrieving the path from the user through testexecute.ini |
|
538 * @param aEnableCommandCount - Integer value representing the status of the EnableTestsCountLog option in the testexecute.ini |
|
539 * @param aScriptPreProcess - Reference to the script pre-processor object used for retrieving values from structure array for logging |
|
540 * @leave - If the logger instance is not able to create the HTML log file |
|
541 */ |
|
542 void CTestExecuteLogger::InitialisePIPSLoggingL( TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess) |
|
543 { |
|
544 |
|
545 PIPSLogger().SetLogLevel(TLogSeverity(aLogLevel)); |
|
546 PIPSLogger().Write(KHtmlBegin16); // Write initial HTML tags |
|
547 // Introduce a new information block called TEST SCRIPT SYNOPSIS |
|
548 // To display synopsis of the script file and to display the TEF version |
|
549 const TInt KTEFSynopsisStringMaxLength = 512; |
|
550 TBuf<KTEFSynopsisStringMaxLength> lineBuf(KTEFFontLightBlue); |
|
551 lineBuf.Append(KTEFTestSynopsisHTM); |
|
552 lineBuf.Append(KTEFFontEnd); |
|
553 lineBuf.Append(KTEFVersionMessage); |
|
554 lineBuf.Append(KTEFProductVersion); |
|
555 lineBuf.Append(KTEFNewLine); |
|
556 |
|
557 // If EnableTestsCountLog is set to ON, append the command and count details to the log file during intialisation |
|
558 if (aEnableCommandCount == KTEFOneValue) |
|
559 { |
|
560 TInt index; |
|
561 // Run a loop for the structure array size |
|
562 for (index=0;index<aScriptPreProcess.GetStructSize();index++) |
|
563 { |
|
564 TBuf<KMaxTestExecuteNameLength> commandName; |
|
565 TInt commandCount; |
|
566 // Retrieve the command name and count at each array index |
|
567 aScriptPreProcess.RetrieveValues(index, commandName, commandCount); |
|
568 |
|
569 // Append the command name and details to the synopsis block for logging |
|
570 if (commandCount > KTEFZeroValue) |
|
571 { |
|
572 if (commandName.CompareF(KTEFRunScriptCommand) == 0) |
|
573 { |
|
574 iRunScriptCommandCount = commandCount; |
|
575 } |
|
576 lineBuf.Append(commandName); |
|
577 lineBuf.Append(KTEFCountMessageHTM); |
|
578 lineBuf.AppendNum(commandCount); |
|
579 lineBuf.Append(KTEFNewLine); |
|
580 } |
|
581 } |
|
582 } |
|
583 // Write a time and date header |
|
584 _LIT(KStarted,"*** TestExecute Started "); |
|
585 |
|
586 lineBuf.Append(KTEFNewLine); |
|
587 lineBuf.Append(KTEFFontGreen); |
|
588 lineBuf.Append(KStarted); |
|
589 |
|
590 TTime now; |
|
591 now.UniversalTime(); |
|
592 TDateTime dateTime = now.DateTime(); |
|
593 _LIT(KFormat,"%02d/%02d/%04d %02d:%02d:%02d:%03d ***"); |
|
594 // add the current time and date |
|
595 lineBuf.AppendFormat(KFormat, |
|
596 dateTime.Day()+1, |
|
597 dateTime.Month()+1, |
|
598 dateTime.Year(), |
|
599 dateTime.Hour(), |
|
600 dateTime.Minute(), |
|
601 dateTime.Second(), |
|
602 (dateTime.MicroSecond()/1000) ); |
|
603 lineBuf.Append(KTEFFontEnd); |
|
604 PIPSLogger().Write(lineBuf); // Append initial header message & time of logging at the start |
|
605 |
|
606 } |
|
607 /** |
|
608 * Connects to the HTML log client session and creating the logs with initial tags for logging |
|
609 * @param aLogFilePath - Relative path that is arrived after retrieving the path from the user through testexecute.ini |
|
610 * @param aEnableCommandCount - Integer value representing the status of the EnableTestsCountLog option in the testexecute.ini |
|
611 * @param aScriptPreProcess - Reference to the script pre-processor object used for retrieving values from structure array for logging |
|
612 * @leave - If the logger instance is not able to create the HTML log file |
|
613 */ |
|
614 void CTestExecuteLogger::InitialiseHTMLLoggingL(const TDesC& aLogFilePath, TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess) |
|
615 { |
|
616 // Connect to the file logger server and create the log file we've just constructed |
|
617 // This will be c:\logs\testexecute\somefile.htm or c:\logs\scriptengine.htm |
|
618 |
|
619 // Create the log file in the specified path with overwrite mode on |
|
620 User::LeaveIfError(HtmlLogger().CreateLog(aLogFilePath,RTestExecuteLogServ::ELogModeOverWrite)); |
|
621 HtmlLogger().SetLogLevel(TLogSeverity(aLogLevel)); |
|
622 |
|
623 HtmlLogger().Write(KHtmlBegin16); // Write initial HTML tags |
|
624 |
|
625 // Introduce a new information block called TEST SCRIPT SYNOPSIS |
|
626 // To display synopsis of the script file and to display the TEF version |
|
627 const TInt KTEFSynopsisStringMaxLength = 512; |
|
628 TBuf<KTEFSynopsisStringMaxLength> lineBuf(KTEFFontLightBlue); |
|
629 lineBuf.Append(KTEFTestSynopsisHTM); |
|
630 lineBuf.Append(KTEFFontEnd); |
|
631 lineBuf.Append(KTEFVersionMessage); |
|
632 lineBuf.Append(KTEFProductVersion); |
|
633 lineBuf.Append(KTEFNewLine); |
|
634 |
|
635 // If EnableTestsCountLog is set to ON, append the command and count details to the log file during intialisation |
|
636 if (aEnableCommandCount == KTEFOneValue) |
|
637 { |
|
638 TInt index; |
|
639 // Run a loop for the structure array size |
|
640 for (index=0;index<aScriptPreProcess.GetStructSize();index++) |
|
641 { |
|
642 TBuf<KMaxTestExecuteNameLength> commandName; |
|
643 TInt commandCount; |
|
644 // Retrieve the command name and count at each array index |
|
645 aScriptPreProcess.RetrieveValues(index, commandName, commandCount); |
|
646 |
|
647 // Append the command name and details to the synopsis block for logging |
|
648 if (commandCount > KTEFZeroValue) |
|
649 { |
|
650 if (commandName.CompareF(KTEFRunScriptCommand) == 0) |
|
651 { |
|
652 iRunScriptCommandCount = commandCount; |
|
653 } |
|
654 lineBuf.Append(commandName); |
|
655 lineBuf.Append(KTEFCountMessageHTM); |
|
656 lineBuf.AppendNum(commandCount); |
|
657 lineBuf.Append(KTEFNewLine); |
|
658 } |
|
659 } |
|
660 } |
|
661 |
|
662 // Write a time and date header |
|
663 _LIT(KStarted,"*** TestExecute Started "); |
|
664 |
|
665 lineBuf.Append(KTEFNewLine); |
|
666 lineBuf.Append(KTEFFontGreen); |
|
667 lineBuf.Append(KStarted); |
|
668 |
|
669 TTime now; |
|
670 now.UniversalTime(); |
|
671 TDateTime dateTime = now.DateTime(); |
|
672 _LIT(KFormat,"%02d/%02d/%04d %02d:%02d:%02d:%03d ***"); |
|
673 // add the current time and date |
|
674 lineBuf.AppendFormat(KFormat, |
|
675 dateTime.Day()+1, |
|
676 dateTime.Month()+1, |
|
677 dateTime.Year(), |
|
678 dateTime.Hour(), |
|
679 dateTime.Minute(), |
|
680 dateTime.Second(), |
|
681 (dateTime.MicroSecond()/1000) ); |
|
682 lineBuf.Append(KTEFFontEnd); |
|
683 HtmlLogger().Write(lineBuf); // Append initial header message & time of logging at the start |
|
684 } |
|
685 |
|
686 /** |
|
687 * Connects to the XML log client session and creates the logs in the path passed in |
|
688 * Also sets in the default threshold for log level |
|
689 * @param aLogFilePath - Relative path that is arrived after retrieving the path from the user through testexecute.ini |
|
690 * @param aLogLevel - Indicates the default threshold level for logging messages within the XML log |
|
691 * @param aEnableCommandCount - Integer value representing the status of the EnableTestsCountLog option in the testexecute.ini |
|
692 * @param aScriptPreProcess - Reference to the script pre-processor object used for retrieving values from structure array for logging |
|
693 * @leave - If the logger instance is not able to create the HTML log file |
|
694 */ |
|
695 void CTestExecuteLogger::InitialiseXMLLoggingL(const TDesC& aLogFilePath, TInt aLogLevel, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess) |
|
696 { |
|
697 // Create the log file for XML logging & open it in overwrite mode for writing the results |
|
698 User::LeaveIfError(XmlLogger().CreateLog(aLogFilePath,RFileFlogger::ELogModeOverWrite)); |
|
699 // Accept and set the default threshold log level for the XML logging from the user |
|
700 XmlLogger().SetLogLevel(RFileFlogger::TLogSeverity(aLogLevel)); |
|
701 |
|
702 if (aEnableCommandCount == KTEFOneValue) |
|
703 { |
|
704 // Create an array of TLogField structure of size equal to the number of commands counted |
|
705 TExtraLogField logField[KTEFCommandsCountPlusOne]; |
|
706 |
|
707 // The first structure array holds the TEF version information |
|
708 logField[0].iLogFieldName.Copy(KTEFVersionMessageXML); |
|
709 logField[0].iLogFieldValue.Copy(KTEFProductVersion); |
|
710 |
|
711 TInt index; |
|
712 TInt actualStructSize=KTEFOneValue; |
|
713 // Run through a loop for all the array indices |
|
714 for (index=0;index<aScriptPreProcess.GetStructSize();index++) |
|
715 { |
|
716 TBuf<KMaxTestExecuteNameLength> commandName; |
|
717 TInt commandCount; |
|
718 // Retrieve the command names and counts for each array index |
|
719 aScriptPreProcess.RetrieveValues(index, commandName, commandCount); |
|
720 |
|
721 // Append the command name and counts details to the TExtraLogField array created already |
|
722 if (commandCount > KTEFZeroValue) |
|
723 { |
|
724 if (commandName.CompareF(KTEFRunScriptCommand) == 0) |
|
725 { |
|
726 iRunScriptCommandCount = commandCount; |
|
727 } |
|
728 logField[actualStructSize].iLogFieldName.Copy(commandName); |
|
729 logField[actualStructSize].iLogFieldName.Append(KTEFCountMessageXML); |
|
730 logField[actualStructSize].iLogFieldValue.AppendNum(commandCount); |
|
731 actualStructSize++; |
|
732 } |
|
733 } |
|
734 |
|
735 // Pass in the updated TExtraLogField array along with a message block name |
|
736 // To construct a new XML message block during the XML logging initialisation |
|
737 LogToXml(((TText8*)__FILE__),__LINE__,RFileFlogger::TLogSeverity(ESevrHigh),KTEFTestSynopsisXML,actualStructSize,logField); |
|
738 } |
|
739 else |
|
740 { |
|
741 // Create an array of TLogField structure of size equal to the number of result categories for test steps |
|
742 TExtraLogField logField[KTEFOneValue]; |
|
743 |
|
744 // The first member of the structure stores the field name |
|
745 // The second one holds the value for the particular field |
|
746 logField[0].iLogFieldName.Copy(_L("TEF_VERSION")); |
|
747 logField[0].iLogFieldValue.Copy(KTEFProductVersion); |
|
748 |
|
749 LogToXml(((TText8*)__FILE__),__LINE__,RFileFlogger::TLogSeverity(ESevrHigh),KTEFTestSynopsisXML,KTEFOneValue,logField); |
|
750 } |
|
751 } |
|
752 |
|
753 void CTestExecuteLogger::OpenSerialPortL(const TInt aPortNumber) |
|
754 { |
|
755 if(iSerialWriter == NULL) |
|
756 { |
|
757 iSerialWriter = CSerialWriter::NewL(); |
|
758 } |
|
759 iPortNumber = aPortNumber; |
|
760 iSerialWriter->Settings(iPortNumber) ; |
|
761 } |
|
762 /** |
|
763 * Instantiates the Serial Logger and passes start log header |
|
764 * @param aLogLevel - Indicates the default threshold level for logging messages within the XML log |
|
765 * @param aEnableCommandCount - Integer value representing the status of the EnableTestsCountLog option in the testexecute.ini |
|
766 * @param aScriptPreProcess - Reference to the script pre-processor object used for retrieving values from structure array for logging |
|
767 * @param aPortNumber - Port to be used for serial logging. |
|
768 * @leave - If the logger instance is not successful |
|
769 */ |
|
770 void CTestExecuteLogger::InitialiseSerialLoggingL(TInt /*aLogLevel*/, const TInt& aEnableCommandCount, CScriptPreProcess& aScriptPreProcess,TInt aPortNumber) |
|
771 { |
|
772 OpenSerialPortL(aPortNumber); |
|
773 // Introduce a new information block called TEST SCRIPT SYNOPSIS |
|
774 // To display synopsis of the script file and to display the TEF version |
|
775 const TInt KTEFSynopsisStringMaxLength = 512; |
|
776 TBuf<KTEFSynopsisStringMaxLength> lineBuf(KTEFTestSynopsisHTM); |
|
777 lineBuf.Append(KTEFVersionMessage); |
|
778 lineBuf.Append(KTEFProductVersion); |
|
779 lineBuf.Append(KTEFNewLine); |
|
780 |
|
781 // If EnableTestsCountLog is set to ON, append the command and count details to the log file during intialisation |
|
782 if (aEnableCommandCount == KTEFOneValue) |
|
783 { |
|
784 TInt index; |
|
785 // Run a loop for the structure array size |
|
786 for (index=0;index<aScriptPreProcess.GetStructSize();index++) |
|
787 { |
|
788 TBuf<KMaxTestExecuteNameLength> commandName; |
|
789 TInt commandCount; |
|
790 // Retrieve the command name and count at each array index |
|
791 aScriptPreProcess.RetrieveValues(index, commandName, commandCount); |
|
792 |
|
793 // Append the command name and details to the synopsis block for logging |
|
794 if (commandCount > KTEFZeroValue) |
|
795 { |
|
796 if (commandName.CompareF(KTEFRunScriptCommand) == 0) |
|
797 { |
|
798 iRunScriptCommandCount = commandCount; |
|
799 } |
|
800 lineBuf.Append(commandName); |
|
801 lineBuf.Append(KTEFCountMessageHTM); |
|
802 lineBuf.AppendNum(commandCount); |
|
803 lineBuf.Append(KTEFNewLine); |
|
804 } |
|
805 } |
|
806 } |
|
807 _LIT(KStarted,"*** TestExecute Started "); |
|
808 lineBuf.Append(KTEFNewLine); |
|
809 lineBuf.Append(KStarted); |
|
810 iSerialWriter->WriteDecorated(lineBuf) ; |
|
811 } |
|
812 |
|
813 /** |
|
814 * @param aCommentedCommandsCount - Integer descriptor containing the counts |
|
815 * of commented commands in the script for logging |
|
816 * Terminate Logging routine |
|
817 * Responsible for closing the objects created for logging and also to close the log client sessions |
|
818 * Also appends final end up tags for the logs |
|
819 */ |
|
820 EXPORT_C void CTestExecuteLogger::TerminateLoggingL(const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount) |
|
821 { |
|
822 RFs fS; |
|
823 User::LeaveIfError(fS.Connect()); |
|
824 CleanupClosePushL(fS); |
|
825 |
|
826 // Delete the KTestExecuteScheduleTestLogCompatibilityNameFile |
|
827 // May not exist but who cares |
|
828 TBuf<KMaxTestExecuteNameLength> scheduleTestLogFileNameFile(iHtmlLogPath); |
|
829 scheduleTestLogFileNameFile.Append(KTestExecuteScheduleTestLogCompatibilityNameFile); |
|
830 (void)fS.Delete(scheduleTestLogFileNameFile); |
|
831 // Open the result summary file |
|
832 TBuf<KMaxTestExecuteNameLength> resultFileName(iHtmlLogPath); |
|
833 //load simpifiled log results in case of out-of-memory |
|
834 resultFileName.Append(KTEFTestExecuteResultSimplifiedSummaryFile); |
|
835 RFile logFile; |
|
836 User::LeaveIfError(logFile.Open(fS,resultFileName, EFileWrite | EFileRead | EFileShareAny)); |
|
837 CleanupClosePushL(logFile); |
|
838 TInt fileSize; |
|
839 // Read the complete result summary file onto the heap |
|
840 // It wont be that large |
|
841 User::LeaveIfError(logFile.Size(fileSize)); |
|
842 HBufC* resultData = HBufC::NewLC(fileSize); |
|
843 HBufC8* resultData8 = HBufC8::NewLC(fileSize); |
|
844 TPtr8 ptrData8(resultData8->Des()); |
|
845 User::LeaveIfError(logFile.Read(ptrData8)); |
|
846 TPtr ptrData(resultData->Des()); |
|
847 ptrData.Copy(ptrData8); |
|
848 logFile.Close(); |
|
849 CleanupStack::PopAndDestroy(resultData8); |
|
850 |
|
851 // Set up some vars for the test step result types |
|
852 iPassCount=0; |
|
853 iFailCount=0; |
|
854 iAbortCount=0; |
|
855 iUnknownCount=0; |
|
856 iInconclusiveCount=0; |
|
857 iPanicCount=0; |
|
858 iUnexecutedCount=0; |
|
859 |
|
860 // Set up some vars for the RUN_PROGRAM result types |
|
861 iRunProgramUsed=EFalse; |
|
862 iRunProgramPassCount=0; |
|
863 iRunProgramFailCount=0; |
|
864 iRunProgramAbortCount=0; |
|
865 iRunProgramUnknownCount=0; |
|
866 iRunProgramInconclusiveCount=0; |
|
867 iRunProgramPanicCount=0; |
|
868 iRunProgramUnexecutedCount=0; |
|
869 |
|
870 // Set up some vars for the testcase result types |
|
871 iTestCasesUsed=EFalse; |
|
872 iTestCasePassCount=0; |
|
873 iTestCaseFailCount=0; |
|
874 iTestCaseSkippedCount=0; |
|
875 iTestCaseInconclusiveCount=0; |
|
876 |
|
877 // We loop through looking for the ***Result test step & |
|
878 // testcase ***TestCaseResult tokens |
|
879 // The result code will be the token after the '=' |
|
880 _LIT(KEquality,"="); |
|
881 |
|
882 TLex lex(ptrData); |
|
883 |
|
884 while (!lex.Eos()) |
|
885 { |
|
886 // Find the ***Result keywords to retrieve the test step summary results |
|
887 |
|
888 TPtrC token(lex.NextToken()); |
|
889 |
|
890 if(token==KTEFRunProgramCommand || token==KTEFRunWSProgramCommand) |
|
891 { |
|
892 iRunProgramUsed = ETrue; |
|
893 TPtrC token(lex.NextToken()); |
|
894 while(token != KTEFResultTag) |
|
895 token.Set(lex.NextToken()); |
|
896 if (lex.NextToken() != KEquality) |
|
897 continue; |
|
898 token.Set(lex.NextToken()); |
|
899 if(token == KTEFResultAbort) |
|
900 iRunProgramAbortCount++; |
|
901 else if(token == KTEFResultFail) |
|
902 iRunProgramFailCount++; |
|
903 else if(token == KTEFResultPass) |
|
904 iRunProgramPassCount++; |
|
905 else if(token == KTEFResultInconclusive) |
|
906 iRunProgramInconclusiveCount++; |
|
907 else if(token == KTEFResultPanic) |
|
908 iRunProgramPanicCount++; |
|
909 else if (token == KTEFResultUnexecuted) |
|
910 iRunProgramUnexecutedCount++; |
|
911 else |
|
912 iRunProgramUnknownCount++; |
|
913 } |
|
914 else if(token == KTEFResultTag) |
|
915 { |
|
916 if (lex.NextToken() != KEquality) |
|
917 continue; |
|
918 TPtrC token(lex.NextToken()); |
|
919 if(token == KTEFResultAbort) |
|
920 iAbortCount++; |
|
921 else if(token == KTEFResultFail) |
|
922 iFailCount++; |
|
923 else if(token == KTEFResultPass) |
|
924 iPassCount++; |
|
925 else if(token == KTEFResultInconclusive) |
|
926 iInconclusiveCount++; |
|
927 else if(token == KTEFResultPanic) |
|
928 iPanicCount++; |
|
929 else if (token == KTEFResultUnexecuted) |
|
930 iUnexecutedCount++; |
|
931 else |
|
932 iUnknownCount++; |
|
933 } |
|
934 else |
|
935 { |
|
936 if (token == KTEFTestCaseResultTag) // Find the ***TestCaseResult keywords to retrieve the test case summary results |
|
937 { |
|
938 iTestCasesUsed = ETrue; |
|
939 if (lex.NextToken() != KEquality) |
|
940 continue; |
|
941 TPtrC token(lex.NextToken()); |
|
942 if(token == KTEFResultPass) |
|
943 iTestCasePassCount++; |
|
944 else if(token == KTEFResultFail) |
|
945 iTestCaseFailCount++; |
|
946 else if(token == KTEFResultSkippedSelectively) |
|
947 iTestCaseSkippedCount++; |
|
948 else |
|
949 iTestCaseInconclusiveCount++; |
|
950 } |
|
951 } |
|
952 } |
|
953 // Cleanup heap memory |
|
954 CleanupStack::PopAndDestroy(resultData); |
|
955 |
|
956 //summary save to test result to "TestResults.htm" |
|
957 resultFileName.Copy(iHtmlLogPath); |
|
958 resultFileName.Append(KTEFTestExecuteResultSummaryFile); |
|
959 User::LeaveIfError(logFile.Open(fS,resultFileName, EFileWrite | EFileRead | EFileShareAny)); |
|
960 TInt pos=0; |
|
961 (void)logFile.Seek(ESeekEnd, pos); |
|
962 if(iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
963 { |
|
964 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
965 { |
|
966 TerminateHTMLLoggingL(&logFile, aCommentedCommandsCount, aRemotePanicsCount, aRunScriptFailCount); |
|
967 } |
|
968 if (iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth) |
|
969 { |
|
970 TerminateXMLLoggingL(aCommentedCommandsCount, aRemotePanicsCount, aRunScriptFailCount); |
|
971 } |
|
972 } |
|
973 // Cleanup/Close allocated objects |
|
974 Close(); |
|
975 CleanupStack::Pop(&logFile); |
|
976 logFile.Close(); |
|
977 CleanupStack::Pop(&fS); |
|
978 fS.Close(); |
|
979 } |
|
980 |
|
981 |
|
982 |
|
983 /** |
|
984 * @param aLogFile - Pointer to the file object for appending end up tags for HTML log result |
|
985 * @param aCommentedCommandsCount - Integer descriptor containing the counts |
|
986 * of commented commands in the script for logging |
|
987 * Called by the Termination routine based on the logger options set by the user for HTML specific log results |
|
988 */ |
|
989 void CTestExecuteLogger::TerminateHTMLLoggingL(RFile* aLogFile, const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount) |
|
990 { |
|
991 // Construct a summary buffer |
|
992 // And write it to the logger file and the result summary file |
|
993 TBuf<KMaxTestExecuteLogLineLength> summaryLine; |
|
994 summaryLine.Append(KTEFFontLightBlue); |
|
995 |
|
996 if (iTestCasesUsed) |
|
997 { |
|
998 _LIT(KTEFTestSummary,"TEST STEP SUMMARY:"); |
|
999 summaryLine.Append(KTEFTestSummary); |
|
1000 } |
|
1001 else |
|
1002 { |
|
1003 _LIT(KSummary,"SUMMARY:"); |
|
1004 summaryLine.Append(KSummary); |
|
1005 } |
|
1006 |
|
1007 summaryLine.Append(KTEFFontEnd); |
|
1008 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1009 HtmlLogger().Write(summaryLine); |
|
1010 TBuf8<KMaxTestExecuteLogLineLength> summaryLine8; |
|
1011 summaryLine8.Copy(summaryLine); |
|
1012 summaryLine8.Append(KTEFEndOfLine); |
|
1013 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1014 |
|
1015 summaryLine.Zero(); |
|
1016 summaryLine.Append(KTEFFontGreen); |
|
1017 summaryLine.Append(KTEFResultPass); |
|
1018 summaryLine.AppendFormat(KTEFEqualsInteger,iPassCount); |
|
1019 summaryLine.Append(KTEFFontEnd); |
|
1020 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1021 HtmlLogger().Write(summaryLine); |
|
1022 summaryLine8.Copy(summaryLine); |
|
1023 summaryLine8.Append(KTEFEndOfLine); |
|
1024 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1025 |
|
1026 summaryLine.Zero(); |
|
1027 summaryLine.Append(KTEFFontRed); |
|
1028 summaryLine.Append(KTEFResultFail); |
|
1029 summaryLine.AppendFormat(KTEFEqualsInteger,iFailCount); |
|
1030 summaryLine.Append(KTEFFontEnd); |
|
1031 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1032 HtmlLogger().Write(summaryLine); |
|
1033 summaryLine8.Copy(summaryLine); |
|
1034 summaryLine8.Append(KTEFEndOfLine); |
|
1035 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1036 |
|
1037 summaryLine.Zero(); |
|
1038 summaryLine.Append(KTEFFontBlue); |
|
1039 summaryLine.Append(KTEFResultAbort); |
|
1040 summaryLine.AppendFormat(KTEFEqualsInteger,iAbortCount); |
|
1041 summaryLine.Append(KTEFFontEnd); |
|
1042 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1043 HtmlLogger().Write(summaryLine); |
|
1044 summaryLine8.Copy(summaryLine); |
|
1045 summaryLine8.Append(KTEFEndOfLine); |
|
1046 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1047 |
|
1048 summaryLine.Zero(); |
|
1049 summaryLine.Append(KTEFFontBlue); |
|
1050 summaryLine.Append(KTEFResultPanic); |
|
1051 summaryLine.AppendFormat(KTEFEqualsInteger,iPanicCount); |
|
1052 summaryLine.Append(KTEFFontEnd); |
|
1053 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1054 HtmlLogger().Write(summaryLine); |
|
1055 summaryLine8.Copy(summaryLine); |
|
1056 summaryLine8.Append(KTEFEndOfLine); |
|
1057 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1058 |
|
1059 summaryLine.Zero(); |
|
1060 summaryLine.Append(KTEFFontBlue); |
|
1061 summaryLine.Append(KTEFResultInconclusive); |
|
1062 summaryLine.AppendFormat(KTEFEqualsInteger,iInconclusiveCount); |
|
1063 summaryLine.Append(KTEFFontEnd); |
|
1064 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1065 HtmlLogger().Write(summaryLine); |
|
1066 summaryLine8.Copy(summaryLine); |
|
1067 summaryLine8.Append(KTEFEndOfLine); |
|
1068 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1069 |
|
1070 summaryLine.Zero(); |
|
1071 summaryLine.Append(KTEFFontBlue); |
|
1072 summaryLine.Append(KTEFResultUnknown); |
|
1073 summaryLine.AppendFormat(KTEFEqualsInteger,iUnknownCount); |
|
1074 summaryLine.Append(KTEFFontEnd); |
|
1075 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1076 HtmlLogger().Write(summaryLine); |
|
1077 summaryLine8.Copy(summaryLine); |
|
1078 summaryLine8.Append(KTEFEndOfLine); |
|
1079 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1080 |
|
1081 summaryLine.Zero(); |
|
1082 summaryLine.Append(KTEFFontBlue); |
|
1083 summaryLine.Append(KTEFResultUnexecuted); |
|
1084 summaryLine.AppendFormat(KTEFEqualsInteger,iUnexecutedCount); |
|
1085 summaryLine.Append(KTEFFontEnd); |
|
1086 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1087 HtmlLogger().Write(summaryLine); |
|
1088 summaryLine8.Copy(summaryLine); |
|
1089 summaryLine8.Append(KTEFEndOfLine); |
|
1090 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1091 |
|
1092 summaryLine.Zero(); |
|
1093 summaryLine.Append(KTEFFontBlue); |
|
1094 summaryLine.Append(KTEFCommentedCommands); |
|
1095 summaryLine.AppendFormat(KTEFEqualsInteger,aCommentedCommandsCount); |
|
1096 summaryLine.Append(KTEFFontEnd); |
|
1097 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1098 HtmlLogger().Write(summaryLine); |
|
1099 summaryLine8.Copy(summaryLine); |
|
1100 summaryLine8.Append(KTEFEndOfLine); |
|
1101 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1102 |
|
1103 if (iRemotePanic != 0) |
|
1104 { |
|
1105 summaryLine.Zero(); |
|
1106 summaryLine.Append(KTEFFontBlue); |
|
1107 _LIT(KTEFSystemPanics, "SYSTEM PANICS COUNT"); |
|
1108 summaryLine.Append(KTEFSystemPanics); |
|
1109 summaryLine.AppendFormat(KTEFEqualsInteger,aRemotePanicsCount); |
|
1110 summaryLine.Append(KTEFFontEnd); |
|
1111 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1112 HtmlLogger().Write(summaryLine); |
|
1113 summaryLine8.Copy(summaryLine); |
|
1114 summaryLine8.Append(KTEFEndOfLine); |
|
1115 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1116 } |
|
1117 |
|
1118 if(iRunProgramUsed) |
|
1119 { |
|
1120 summaryLine.Zero(); |
|
1121 summaryLine.Append(KTEFFontLightBlue); |
|
1122 _LIT(KTEFTestCaseSummary, "RUN_PROGRAM SUMMARY:"); |
|
1123 summaryLine.Append(KTEFTestCaseSummary); |
|
1124 summaryLine.Append(KTEFFontEnd); |
|
1125 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1126 HtmlLogger().Write(summaryLine); |
|
1127 TBuf8<KMaxTestExecuteLogLineLength> summaryLine8; |
|
1128 summaryLine8.Copy(summaryLine); |
|
1129 summaryLine8.Append(KTEFEndOfLine); |
|
1130 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1131 |
|
1132 summaryLine.Zero(); |
|
1133 summaryLine.Append(KTEFFontGreen); |
|
1134 summaryLine.Append(KTEFResultPass); |
|
1135 summaryLine.AppendFormat(KTEFEqualsInteger,iRunProgramPassCount); |
|
1136 summaryLine.Append(KTEFFontEnd); |
|
1137 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1138 HtmlLogger().Write(summaryLine); |
|
1139 summaryLine8.Copy(summaryLine); |
|
1140 summaryLine8.Append(KTEFEndOfLine); |
|
1141 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1142 |
|
1143 summaryLine.Zero(); |
|
1144 summaryLine.Append(KTEFFontRed); |
|
1145 summaryLine.Append(KTEFResultFail); |
|
1146 summaryLine.AppendFormat(KTEFEqualsInteger,iRunProgramFailCount); |
|
1147 summaryLine.Append(KTEFFontEnd); |
|
1148 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1149 HtmlLogger().Write(summaryLine); |
|
1150 summaryLine8.Copy(summaryLine); |
|
1151 summaryLine8.Append(KTEFEndOfLine); |
|
1152 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1153 |
|
1154 summaryLine.Zero(); |
|
1155 summaryLine.Append(KTEFFontBlue); |
|
1156 summaryLine.Append(KTEFResultAbort); |
|
1157 summaryLine.AppendFormat(KTEFEqualsInteger,iRunProgramAbortCount); |
|
1158 summaryLine.Append(KTEFFontEnd); |
|
1159 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1160 HtmlLogger().Write(summaryLine); |
|
1161 summaryLine8.Copy(summaryLine); |
|
1162 summaryLine8.Append(KTEFEndOfLine); |
|
1163 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1164 |
|
1165 summaryLine.Zero(); |
|
1166 summaryLine.Append(KTEFFontBlue); |
|
1167 summaryLine.Append(KTEFResultPanic); |
|
1168 summaryLine.AppendFormat(KTEFEqualsInteger,iRunProgramPanicCount); |
|
1169 summaryLine.Append(KTEFFontEnd); |
|
1170 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1171 HtmlLogger().Write(summaryLine); |
|
1172 summaryLine8.Copy(summaryLine); |
|
1173 summaryLine8.Append(KTEFEndOfLine); |
|
1174 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1175 |
|
1176 summaryLine.Zero(); |
|
1177 summaryLine.Append(KTEFFontBlue); |
|
1178 summaryLine.Append(KTEFResultInconclusive); |
|
1179 summaryLine.AppendFormat(KTEFEqualsInteger,iRunProgramInconclusiveCount); |
|
1180 summaryLine.Append(KTEFFontEnd); |
|
1181 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1182 HtmlLogger().Write(summaryLine); |
|
1183 summaryLine8.Copy(summaryLine); |
|
1184 summaryLine8.Append(KTEFEndOfLine); |
|
1185 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1186 |
|
1187 summaryLine.Zero(); |
|
1188 summaryLine.Append(KTEFFontBlue); |
|
1189 summaryLine.Append(KTEFResultUnknown); |
|
1190 summaryLine.AppendFormat(KTEFEqualsInteger,iRunProgramUnknownCount); |
|
1191 summaryLine.Append(KTEFFontEnd); |
|
1192 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1193 HtmlLogger().Write(summaryLine); |
|
1194 summaryLine8.Copy(summaryLine); |
|
1195 summaryLine8.Append(KTEFEndOfLine); |
|
1196 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1197 |
|
1198 summaryLine.Zero(); |
|
1199 summaryLine.Append(KTEFFontBlue); |
|
1200 summaryLine.Append(KTEFResultUnexecuted); |
|
1201 summaryLine.AppendFormat(KTEFEqualsInteger,iRunProgramUnexecutedCount); |
|
1202 summaryLine.Append(KTEFFontEnd); |
|
1203 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1204 HtmlLogger().Write(summaryLine); |
|
1205 summaryLine8.Copy(summaryLine); |
|
1206 summaryLine8.Append(KTEFEndOfLine); |
|
1207 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1208 } |
|
1209 |
|
1210 if (iTestCasesUsed) |
|
1211 { |
|
1212 summaryLine.Zero(); |
|
1213 summaryLine.Append(KTEFFontLightBlue); |
|
1214 _LIT(KTEFTestCaseSummary, "TEST CASE SUMMARY:"); |
|
1215 summaryLine.Append(KTEFTestCaseSummary); |
|
1216 summaryLine.Append(KTEFFontEnd); |
|
1217 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1218 HtmlLogger().Write(summaryLine); |
|
1219 TBuf8<KMaxTestExecuteLogLineLength> summaryLine8; |
|
1220 summaryLine8.Copy(summaryLine); |
|
1221 summaryLine8.Append(KTEFEndOfLine); |
|
1222 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1223 |
|
1224 summaryLine.Zero(); |
|
1225 summaryLine.Append(KTEFFontGreen); |
|
1226 summaryLine.Append(KTEFResultPass); |
|
1227 summaryLine.AppendFormat(KTEFEqualsInteger,iTestCasePassCount); |
|
1228 summaryLine.Append(KTEFFontEnd); |
|
1229 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1230 HtmlLogger().Write(summaryLine); |
|
1231 summaryLine8.Copy(summaryLine); |
|
1232 summaryLine8.Append(KTEFEndOfLine); |
|
1233 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1234 |
|
1235 summaryLine.Zero(); |
|
1236 summaryLine.Append(KTEFFontRed); |
|
1237 summaryLine.Append(KTEFResultFail); |
|
1238 summaryLine.AppendFormat(KTEFEqualsInteger,iTestCaseFailCount); |
|
1239 summaryLine.Append(KTEFFontEnd); |
|
1240 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1241 HtmlLogger().Write(summaryLine); |
|
1242 summaryLine8.Copy(summaryLine); |
|
1243 summaryLine8.Append(KTEFEndOfLine); |
|
1244 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1245 |
|
1246 summaryLine.Zero(); |
|
1247 summaryLine.Append(KTEFFontGrey); |
|
1248 summaryLine.Append(KTEFResultSkippedSelectively); |
|
1249 summaryLine.AppendFormat(KTEFEqualsInteger,iTestCaseSkippedCount); |
|
1250 summaryLine.Append(KTEFFontEnd); |
|
1251 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1252 HtmlLogger().Write(summaryLine); |
|
1253 summaryLine8.Copy(summaryLine); |
|
1254 summaryLine8.Append(KTEFEndOfLine); |
|
1255 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1256 |
|
1257 summaryLine.Zero(); |
|
1258 summaryLine.Append(KTEFFontBlue); |
|
1259 summaryLine.Append(KTEFResultInconclusive); |
|
1260 summaryLine.AppendFormat(KTEFEqualsInteger,iTestCaseInconclusiveCount); |
|
1261 summaryLine.Append(KTEFFontEnd); |
|
1262 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1263 HtmlLogger().Write(summaryLine); |
|
1264 summaryLine8.Copy(summaryLine); |
|
1265 summaryLine8.Append(KTEFEndOfLine); |
|
1266 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1267 } |
|
1268 |
|
1269 if (iRunScriptCommandCount > 0) |
|
1270 { |
|
1271 summaryLine.Zero(); |
|
1272 summaryLine.Append(KTEFFontLightBlue); |
|
1273 summaryLine.Append(KTEFRunScriptSummary); |
|
1274 summaryLine.Append(KTEFFontEnd); |
|
1275 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1276 HtmlLogger().Write(summaryLine); |
|
1277 TBuf8<KMaxTestExecuteLogLineLength> summaryLine8; |
|
1278 summaryLine8.Copy(summaryLine); |
|
1279 summaryLine8.Append(KTEFEndOfLine); |
|
1280 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1281 |
|
1282 summaryLine.Zero(); |
|
1283 summaryLine.Append(KTEFFontGreen); |
|
1284 summaryLine.Append(KTEFScriptExecuted); |
|
1285 TInt executedCount = iRunScriptCommandCount - aRunScriptFailCount; |
|
1286 summaryLine.AppendFormat(KTEFEqualsInteger,executedCount); |
|
1287 summaryLine.Append(KTEFFontEnd); |
|
1288 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1289 HtmlLogger().Write(summaryLine); |
|
1290 summaryLine8.Copy(summaryLine); |
|
1291 summaryLine8.Append(KTEFEndOfLine); |
|
1292 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1293 |
|
1294 summaryLine.Zero(); |
|
1295 summaryLine.Append(KTEFFontRed); |
|
1296 summaryLine.Append(KTEFFailedOpen); |
|
1297 summaryLine.AppendFormat(KTEFEqualsInteger,aRunScriptFailCount); |
|
1298 summaryLine.Append(KTEFFontEnd); |
|
1299 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1300 HtmlLogger().Write(summaryLine); |
|
1301 summaryLine8.Copy(summaryLine); |
|
1302 summaryLine8.Append(KTEFEndOfLine); |
|
1303 User::LeaveIfError(aLogFile->Write(summaryLine8)); |
|
1304 } |
|
1305 |
|
1306 User::LeaveIfError(aLogFile->Write(KHtmlEnd8)); |
|
1307 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1308 HtmlLogger().Write(KHtmlEnd16); // Write the summary results to the HTML log file |
|
1309 |
|
1310 } |
|
1311 |
|
1312 /** |
|
1313 * @param aCommentedCommandsCount - Integer descriptor containing the counts |
|
1314 * of commented commands in the script for logging |
|
1315 * Called by the Termination routine based on the logger options set by the user for HTML specific log results |
|
1316 * Appends the XML tags for displaying the summary results for the test cases and test steps executed |
|
1317 * Closes the session with XML log client session |
|
1318 */ |
|
1319 void CTestExecuteLogger::TerminateXMLLoggingL(const TInt aCommentedCommandsCount, const TInt aRemotePanicsCount, const TInt aRunScriptFailCount) |
|
1320 { |
|
1321 TBuf<KMaxTestExecuteCommandLength> fieldValue; |
|
1322 TBuf<KMaxTestExecuteCommandLength> commandName; |
|
1323 |
|
1324 // Create an array of TLogField structure of size equal to the number of result categories for test steps |
|
1325 TExtraLogField logField[9]; |
|
1326 |
|
1327 // The first member of the structure stores the field name |
|
1328 // The second one holds the value for the particular field |
|
1329 logField[0].iLogFieldName.Copy(KTEFResultPass); |
|
1330 fieldValue.Copy(KNull); |
|
1331 fieldValue.AppendNum(iPassCount); |
|
1332 logField[0].iLogFieldValue.Copy(fieldValue); |
|
1333 |
|
1334 // The first member of the structure stores the field name |
|
1335 // The second one holds the value for the particular field |
|
1336 logField[1].iLogFieldName.Copy(KTEFResultFail); |
|
1337 fieldValue.Copy(KNull); |
|
1338 fieldValue.AppendNum(iFailCount); |
|
1339 logField[1].iLogFieldValue.Copy(fieldValue); |
|
1340 |
|
1341 // The first member of the structure stores the field name |
|
1342 // The second one holds the value for the particular field |
|
1343 logField[2].iLogFieldName.Copy(KTEFResultAbort); |
|
1344 fieldValue.Copy(KNull); |
|
1345 fieldValue.AppendNum(iAbortCount); |
|
1346 logField[2].iLogFieldValue.Copy(fieldValue); |
|
1347 |
|
1348 // The first member of the structure stores the field name |
|
1349 // The second one holds the value for the particular field |
|
1350 logField[3].iLogFieldName.Copy(KTEFResultUnknown); |
|
1351 fieldValue.Copy(KNull); |
|
1352 fieldValue.AppendNum(iUnknownCount); |
|
1353 logField[3].iLogFieldValue.Copy(fieldValue); |
|
1354 |
|
1355 // The first member of the structure stores the field name |
|
1356 // The second one holds the value for the particular field |
|
1357 logField[4].iLogFieldName.Copy(KTEFResultInconclusive); |
|
1358 fieldValue.Copy(KNull); |
|
1359 fieldValue.AppendNum(iInconclusiveCount); |
|
1360 logField[4].iLogFieldValue.Copy(fieldValue); |
|
1361 |
|
1362 // The first member of the structure stores the field name |
|
1363 // The second one holds the value for the particular field |
|
1364 logField[5].iLogFieldName.Copy(KTEFResultPanic); |
|
1365 fieldValue.Copy(KNull); |
|
1366 fieldValue.AppendNum(iPanicCount); |
|
1367 logField[5].iLogFieldValue.Copy(fieldValue); |
|
1368 |
|
1369 // The first member of the structure stores the field name |
|
1370 // The second one holds the value for the particular field |
|
1371 logField[6].iLogFieldName.Copy(KTEFResultUnexecuted); |
|
1372 fieldValue.Copy(KNull); |
|
1373 fieldValue.AppendNum(iUnexecutedCount); |
|
1374 logField[6].iLogFieldValue.Copy(fieldValue); |
|
1375 |
|
1376 _LIT(KTEFCommentedCommands,"COMMENTED_COMMANDS"); |
|
1377 logField[7].iLogFieldName.Copy(KTEFCommentedCommands); |
|
1378 fieldValue.Copy(KNull); |
|
1379 fieldValue.AppendNum(aCommentedCommandsCount); |
|
1380 logField[7].iLogFieldValue.Copy(fieldValue); |
|
1381 |
|
1382 if (iRemotePanic != 0) |
|
1383 { |
|
1384 _LIT(KTEFSystemPanics, "SYSTEMPANICS"); |
|
1385 logField[8].iLogFieldName.Copy(KTEFSystemPanics); |
|
1386 fieldValue.Copy(KNull); |
|
1387 fieldValue.AppendNum(aRemotePanicsCount); |
|
1388 logField[8].iLogFieldValue.Copy(fieldValue); |
|
1389 |
|
1390 commandName.Copy(KTEFTestStepSummary); |
|
1391 |
|
1392 // Call the Logger().LogToXml routine which handles XML logging for individual commands |
|
1393 // Takes in the command name, number of fields and the struture array |
|
1394 LogToXml(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrHigh, commandName, 9, logField); |
|
1395 } |
|
1396 else |
|
1397 { |
|
1398 commandName.Copy(KTEFTestStepSummary); |
|
1399 |
|
1400 // Call the Logger().LogToXml routine which handles XML logging for individual commands |
|
1401 // Takes in the command name, number of fields and the struture array |
|
1402 LogToXml(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrHigh, commandName, 8, logField); |
|
1403 } |
|
1404 |
|
1405 if (iRunProgramUsed) |
|
1406 { |
|
1407 // Create an array of TLogField structure of size equal to the number of result categories for run program logging |
|
1408 TExtraLogField logField[7]; |
|
1409 |
|
1410 // The first member of the structure stores the field name |
|
1411 // The second one holds the value for the particular field |
|
1412 logField[0].iLogFieldName.Copy(KTEFResultPass); |
|
1413 fieldValue.Copy(KNull); |
|
1414 fieldValue.AppendNum(iRunProgramPassCount); |
|
1415 logField[0].iLogFieldValue.Copy(fieldValue); |
|
1416 |
|
1417 // The first member of the structure stores the field name |
|
1418 // The second one holds the value for the particular field |
|
1419 logField[1].iLogFieldName.Copy(KTEFResultFail); |
|
1420 fieldValue.Copy(KNull); |
|
1421 fieldValue.AppendNum(iRunProgramFailCount); |
|
1422 logField[1].iLogFieldValue.Copy(fieldValue); |
|
1423 |
|
1424 // The first member of the structure stores the field name |
|
1425 // The second one holds the value for the particular field |
|
1426 logField[2].iLogFieldName.Copy(KTEFResultAbort); |
|
1427 fieldValue.Copy(KNull); |
|
1428 fieldValue.AppendNum(iRunProgramAbortCount); |
|
1429 logField[2].iLogFieldValue.Copy(fieldValue); |
|
1430 |
|
1431 // The first member of the structure stores the field name |
|
1432 // The second one holds the value for the particular field |
|
1433 logField[3].iLogFieldName.Copy(KTEFResultUnknown); |
|
1434 fieldValue.Copy(KNull); |
|
1435 fieldValue.AppendNum(iRunProgramUnknownCount); |
|
1436 logField[3].iLogFieldValue.Copy(fieldValue); |
|
1437 |
|
1438 // The first member of the structure stores the field name |
|
1439 // The second one holds the value for the particular field |
|
1440 logField[4].iLogFieldName.Copy(KTEFResultInconclusive); |
|
1441 fieldValue.Copy(KNull); |
|
1442 fieldValue.AppendNum(iRunProgramInconclusiveCount); |
|
1443 logField[4].iLogFieldValue.Copy(fieldValue); |
|
1444 |
|
1445 // The first member of the structure stores the field name |
|
1446 // The second one holds the value for the particular field |
|
1447 logField[5].iLogFieldName.Copy(KTEFResultPanic); |
|
1448 fieldValue.Copy(KNull); |
|
1449 fieldValue.AppendNum(iRunProgramPanicCount); |
|
1450 logField[5].iLogFieldValue.Copy(fieldValue); |
|
1451 |
|
1452 // The first member of the structure stores the field name |
|
1453 // The second one holds the value for the particular field |
|
1454 logField[6].iLogFieldName.Copy(KTEFResultUnexecuted); |
|
1455 fieldValue.Copy(KNull); |
|
1456 fieldValue.AppendNum(iRunProgramUnexecutedCount); |
|
1457 logField[6].iLogFieldValue.Copy(fieldValue); |
|
1458 |
|
1459 commandName.Copy(KTEFRunProgramSummary); |
|
1460 |
|
1461 // Call the Logger().LogToXml routine which handles XML logging for individual commands |
|
1462 // Takes in the command name, number of fields and the struture array |
|
1463 LogToXml(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrHigh, commandName, 7, logField); |
|
1464 } |
|
1465 |
|
1466 if (iTestCasesUsed) |
|
1467 { |
|
1468 // Create a TLogField structure array |
|
1469 // Size of array equals to number of fields to be displayed |
|
1470 TExtraLogField logField[3]; |
|
1471 |
|
1472 // The first member of the structure stores the field name |
|
1473 // The second one holds the value for the particular field |
|
1474 logField[0].iLogFieldName.Copy(KTEFResultPass); |
|
1475 fieldValue.Copy(KNull); |
|
1476 fieldValue.AppendNum(iTestCasePassCount); |
|
1477 logField[0].iLogFieldValue.Copy(fieldValue); |
|
1478 |
|
1479 // The first member of the structure stores the field name |
|
1480 // The second one holds the value for the particular field |
|
1481 logField[1].iLogFieldName.Copy(KTEFResultFail); |
|
1482 fieldValue.Copy(KNull); |
|
1483 fieldValue.AppendNum(iTestCaseFailCount); |
|
1484 logField[1].iLogFieldValue.Copy(fieldValue); |
|
1485 |
|
1486 // The first member of the structure stores the field name |
|
1487 // The second one holds the value for the particular field |
|
1488 logField[1].iLogFieldName.Copy(KTEFResultSkippedSelectively); |
|
1489 fieldValue.Copy(KNull); |
|
1490 fieldValue.AppendNum(iTestCaseSkippedCount); |
|
1491 logField[1].iLogFieldValue.Copy(fieldValue); |
|
1492 |
|
1493 // The first member of the structure stores the field name |
|
1494 // The second one holds the value for the particular field |
|
1495 logField[2].iLogFieldName.Copy(KTEFResultInconclusive); |
|
1496 fieldValue.Copy(KNull); |
|
1497 fieldValue.AppendNum(iTestCaseInconclusiveCount); |
|
1498 logField[2].iLogFieldValue.Copy(fieldValue); |
|
1499 |
|
1500 commandName.Copy(KTEFTestCaseSummary); |
|
1501 |
|
1502 // Call the Logger().LogToXml routine which handles XML logging for individual commands |
|
1503 // Takes in the command name, number of fields and the struture array |
|
1504 LogToXml(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrHigh, commandName, 3, logField); |
|
1505 } |
|
1506 |
|
1507 if (iRunScriptCommandCount > 0) |
|
1508 { |
|
1509 // Create a TLogField structure array |
|
1510 // Size of array equals to number of fields to be displayed |
|
1511 TExtraLogField logField[2]; |
|
1512 |
|
1513 // The first member of the structure stores the field name |
|
1514 // The second one holds the value for the particular field |
|
1515 logField[0].iLogFieldName.Copy(KTEFScriptExecuted); |
|
1516 fieldValue.Copy(KNull); |
|
1517 TInt runScriptPassCount = iRunScriptCommandCount - aRunScriptFailCount; |
|
1518 fieldValue.AppendNum(runScriptPassCount); |
|
1519 logField[0].iLogFieldValue.Copy(fieldValue); |
|
1520 |
|
1521 // The first member of the structure stores the field name |
|
1522 // The second one holds the value for the particular field |
|
1523 logField[1].iLogFieldName.Copy(KTEFFailedOpen); |
|
1524 fieldValue.Copy(KNull); |
|
1525 fieldValue.AppendNum(aRunScriptFailCount); |
|
1526 logField[1].iLogFieldValue.Copy(fieldValue); |
|
1527 |
|
1528 commandName.Copy(KTEFRunScriptSummary); |
|
1529 |
|
1530 // Call the Logger().LogToXml routine which handles XML logging for individual commands |
|
1531 // Takes in the command name, number of fields and the struture array |
|
1532 LogToXml(((TText8*)__FILE__), __LINE__,RFileFlogger::ESevrHigh, commandName, 2, logField); |
|
1533 } |
|
1534 } |
|
1535 |
|
1536 /** |
|
1537 * @param aFile - Name of the file that intiated the call |
|
1538 * @param aLine - Line number within the file that initiates the call |
|
1539 * @param aSeverity - One of the 4 enum values indicating the severity of the message to be logged |
|
1540 * @param aCommand - Name of the command whose fields are logged with the call to the function |
|
1541 * @param aResult - Result of the test case for logging |
|
1542 * Logs the name of the test case and the result corresponding to each START_TESTCASE/END_TESTCASE pairs |
|
1543 * This function branches out of the main one for logging over serial. |
|
1544 * This is done to avoid complexity in original code. |
|
1545 */ |
|
1546 void CTestExecuteLogger::LogTestCaseResultSerialL(const TDesC& aFile, TInt aLine, TInt aSeverity, const TDesC& aCommand, const TDesC& aTestCaseName, TVerdict aResult) |
|
1547 { |
|
1548 |
|
1549 _LIT(KTEFSpace, " "); |
|
1550 _LIT(KCommand, "Command = "); |
|
1551 _LIT(KLineNumber,"Line = %d"); |
|
1552 if (aCommand == KTEFStartTestCaseCommand || aCommand == KTEFEndTestCaseCommand |
|
1553 || aCommand == KTEFStartSyncTestCaseCommand || aCommand == KTEFEndSyncTestCaseCommand ) |
|
1554 { |
|
1555 |
|
1556 // Create a heap buffer to hold the log string for HTML |
|
1557 HBufC* resultBuffer = HBufC::NewLC(KMaxTestExecuteCommandLength*3); |
|
1558 TPtr ptr(resultBuffer->Des()); |
|
1559 HBufC* simplifiedResultBuf = HBufC::NewLC(KMaxTestExecuteCommandLength*2); |
|
1560 TPtr simplifiedPtr(simplifiedResultBuf->Des()); |
|
1561 simplifiedPtr.Zero(); |
|
1562 |
|
1563 // Appends remainder of the information required for logging |
|
1564 ptr.Append(aFile); |
|
1565 ptr.Append(KTEFSpace); |
|
1566 ptr.AppendFormat(KLineNumber,aLine); |
|
1567 ptr.Append(KTEFSpace); |
|
1568 ptr.Append(KCommand); |
|
1569 ptr.Append(aCommand); |
|
1570 simplifiedPtr.Append(aCommand); |
|
1571 ptr.Append(KTEFSpace); |
|
1572 simplifiedPtr.Append(KTEFSpace); |
|
1573 ptr.Append(aTestCaseName); |
|
1574 simplifiedPtr.Append(aTestCaseName); |
|
1575 ptr.Append(KTEFSpace); |
|
1576 simplifiedPtr.Append(KTEFSpace); |
|
1577 |
|
1578 TBuf<KMaxTestExecuteCommandLength> resultTmpBuf; |
|
1579 resultTmpBuf.Zero(); |
|
1580 // Append ***TestCaseResult only in case of END_TESTCASE command with result of the test case |
|
1581 if (aCommand == KTEFEndTestCaseCommand || aCommand == KTEFEndSyncTestCaseCommand |
|
1582 || aResult==ESkippedSelectively) //append for when command is start_test_case |
|
1583 //but this is being skipped selectively |
|
1584 { |
|
1585 resultTmpBuf.Append(KTEFTestCaseResultTag); |
|
1586 resultTmpBuf.Append(KTEFSpaceEquals); |
|
1587 if (aResult == EPass) |
|
1588 { |
|
1589 resultTmpBuf.Append(KTEFResultPass); |
|
1590 } |
|
1591 else if (aResult == EFail) |
|
1592 { |
|
1593 resultTmpBuf.Append(KTEFResultFail); |
|
1594 } |
|
1595 else if(aResult==ESkippedSelectively) |
|
1596 { |
|
1597 resultTmpBuf.Append(KTEFResultSkippedSelectively); |
|
1598 } |
|
1599 else |
|
1600 { |
|
1601 resultTmpBuf.Append(KTEFResultInconclusive); |
|
1602 } |
|
1603 ptr.Append(resultTmpBuf); |
|
1604 simplifiedPtr.Append(resultTmpBuf); |
|
1605 } |
|
1606 |
|
1607 ptr.Append(KTEFSpace); |
|
1608 simplifiedPtr.Append(KTEFSpace); |
|
1609 // Copy the 16 bit heap descriptor value to 8 bit descriptor using a TPtr pointer to 8 bit heap descriptor |
|
1610 HBufC8* resultBuffer8 = HBufC8::NewLC(ptr.Length()+2); |
|
1611 TPtr8 ptr8(resultBuffer8->Des()); |
|
1612 ptr8.Copy(ptr); |
|
1613 ptr8.Append(KTEFEndOfLine); // Append new line & carriage return for the log string |
|
1614 |
|
1615 //the result summary file HTML |
|
1616 LoggingTestCaseResultToSummaryResultL(iHtmlLogPath,KTEFTestExecuteResultSummaryFile,ptr8); |
|
1617 //the result summary file simplified text |
|
1618 //re-use result buffer |
|
1619 ptr8.Copy(simplifiedPtr); |
|
1620 ptr8.Append(KTEFEndOfLine); |
|
1621 LoggingTestCaseResultToSummaryResultL(iHtmlLogPath,KTEFTestExecuteResultSimplifiedSummaryFile,ptr8); |
|
1622 CleanupStack::PopAndDestroy(resultBuffer8); |
|
1623 // Create objects of RFs & RFile for opening the result summary file for logging |
|
1624 |
|
1625 TInt bytesCopied = 0; |
|
1626 |
|
1627 while(bytesCopied < ptr.Length()) |
|
1628 { |
|
1629 TInt bytesToCopy = ptr.Length() - bytesCopied; |
|
1630 if(bytesToCopy > KMaxTestExecuteLogLineLength) |
|
1631 { |
|
1632 bytesToCopy = KMaxTestExecuteLogLineLength; |
|
1633 } |
|
1634 TPtrC tmp(&ptr[bytesCopied],bytesToCopy); |
|
1635 bytesCopied += bytesToCopy; |
|
1636 iSerialWriter->WriteDecorated(tmp, aSeverity); |
|
1637 } |
|
1638 // Cleanup heap allocations |
|
1639 CleanupStack::PopAndDestroy(simplifiedResultBuf); |
|
1640 CleanupStack::PopAndDestroy(resultBuffer); |
|
1641 } |
|
1642 } |
|
1643 |
|
1644 /** |
|
1645 * @param aFile - Name of the file that intiated the call |
|
1646 * @param aLine - Line number within the file that initiates the call |
|
1647 * @param aSeverity - One of the 4 enum values indicating the severity of the message to be logged |
|
1648 * @param aCommand - Name of the command whose fields are logged with the call to the function |
|
1649 * @param aResult - Result of the test case for logging |
|
1650 * Logs the name of the test case and the result corresponding to each START_TESTCASE/END_TESTCASE pairs |
|
1651 */ |
|
1652 EXPORT_C void CTestExecuteLogger::LogTestCaseResult(const TDesC& aFile, TInt aLine, TInt aSeverity, const TDesC& aCommand, const TDesC& aTestCaseName, TVerdict aResult) |
|
1653 { |
|
1654 |
|
1655 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
1656 { |
|
1657 LogTestCaseResultSerialL(aFile, aLine, aSeverity, aCommand, aTestCaseName, aResult); |
|
1658 } |
|
1659 if(iLoggerChannel != EFile && iLoggerChannel != EBoth) |
|
1660 { |
|
1661 return ; |
|
1662 } |
|
1663 |
|
1664 _LIT(KTEFSpace, " "); |
|
1665 _LIT(KCommand, "Command = "); |
|
1666 _LIT(KLineNumber,"Line = %d"); |
|
1667 |
|
1668 if (aCommand == KTEFStartTestCaseCommand || aCommand == KTEFEndTestCaseCommand |
|
1669 || aCommand == KTEFStartSyncTestCaseCommand || aCommand == KTEFEndSyncTestCaseCommand ) |
|
1670 { |
|
1671 // Create a heap buffer to hold the log string for HTML |
|
1672 HBufC* resultBuffer = HBufC::NewLC(KMaxTestExecuteCommandLength*3); |
|
1673 TPtr ptr(resultBuffer->Des()); |
|
1674 HBufC* simplifiedResultBuf = HBufC::NewLC(KMaxTestExecuteCommandLength*2); |
|
1675 TPtr simplifiedPtr(simplifiedResultBuf->Des()); |
|
1676 simplifiedPtr.Zero(); |
|
1677 |
|
1678 // Colour of the HTML result is controlled by the result of the command |
|
1679 // Anyway, the START_TESTCASE has no result attached with it & hence is always set to PASS |
|
1680 if (aResult == EPass) |
|
1681 { |
|
1682 // Log the message in Green |
|
1683 ptr.Append(KTEFFontGreen); |
|
1684 } |
|
1685 else if (aResult == EFail) |
|
1686 { |
|
1687 // Log the message in Red |
|
1688 ptr.Append(KTEFFontRed); |
|
1689 } |
|
1690 else if(aResult == ESkippedSelectively) |
|
1691 { |
|
1692 ptr.Append(KTEFFontGrey); |
|
1693 } |
|
1694 else |
|
1695 { |
|
1696 // Log the message in Blue |
|
1697 ptr.Append(KTEFFontBlue); |
|
1698 } |
|
1699 |
|
1700 // Appends remainder of the information required for logging |
|
1701 ptr.Append(aFile); |
|
1702 ptr.Append(KTEFSpace); |
|
1703 ptr.AppendFormat(KLineNumber,aLine); |
|
1704 ptr.Append(KTEFSpace); |
|
1705 ptr.Append(KCommand); |
|
1706 ptr.Append(aCommand); |
|
1707 simplifiedPtr.Append(aCommand); |
|
1708 ptr.Append(KTEFSpace); |
|
1709 simplifiedPtr.Append(KTEFSpace); |
|
1710 ptr.Append(aTestCaseName); |
|
1711 simplifiedPtr.Append(aTestCaseName); |
|
1712 ptr.Append(KTEFSpace); |
|
1713 simplifiedPtr.Append(KTEFSpace); |
|
1714 |
|
1715 TBuf<KMaxTestExecuteCommandLength> resultTmpBuf; |
|
1716 resultTmpBuf.Zero(); |
|
1717 // Append ***TestCaseResult only in case of END_TESTCASE command with result of the test case |
|
1718 if (aCommand == KTEFEndTestCaseCommand || aCommand == KTEFEndSyncTestCaseCommand |
|
1719 || aResult==ESkippedSelectively) //append for when command is start_test_case |
|
1720 //but this is being skipped selectively |
|
1721 { |
|
1722 resultTmpBuf.Append(KTEFTestCaseResultTag); |
|
1723 resultTmpBuf.Append(KTEFSpaceEquals); |
|
1724 if (aResult == EPass) |
|
1725 { |
|
1726 resultTmpBuf.Append(KTEFResultPass); |
|
1727 } |
|
1728 else if (aResult == EFail) |
|
1729 { |
|
1730 resultTmpBuf.Append(KTEFResultFail); |
|
1731 } |
|
1732 else if(aResult==ESkippedSelectively) |
|
1733 { |
|
1734 resultTmpBuf.Append(KTEFResultSkippedSelectively); |
|
1735 } |
|
1736 else |
|
1737 { |
|
1738 resultTmpBuf.Append(KTEFResultInconclusive); |
|
1739 } |
|
1740 ptr.Append(resultTmpBuf); |
|
1741 simplifiedPtr.Append(resultTmpBuf); |
|
1742 } |
|
1743 |
|
1744 ptr.Append(KTEFSpace); |
|
1745 ptr.Append(KTEFFontEnd); |
|
1746 |
|
1747 // Copy the 16 bit heap descriptor value to 8 bit descriptor using a TPtr pointer to 8 bit heap descriptor |
|
1748 HBufC8* resultBuffer8 = HBufC8::NewLC(ptr.Length()+2); |
|
1749 TPtr8 ptr8(resultBuffer8->Des()); |
|
1750 ptr8.Copy(ptr); |
|
1751 ptr8.Append(KTEFEndOfLine); // Append new line & carriage return for the log string |
|
1752 |
|
1753 // Create objects of RFs & RFile for opening the result summary file for logging |
|
1754 LoggingTestCaseResultToSummaryResultL(iHtmlLogPath,KTEFTestExecuteResultSummaryFile,ptr8); |
|
1755 |
|
1756 ptr8.Copy(simplifiedPtr); |
|
1757 ptr8.Append(KTEFEndOfLine); |
|
1758 LoggingTestCaseResultToSummaryResultL(iHtmlLogPath,KTEFTestExecuteResultSimplifiedSummaryFile,ptr8); |
|
1759 |
|
1760 |
|
1761 CleanupStack::PopAndDestroy(resultBuffer8); |
|
1762 CleanupStack::PopAndDestroy(simplifiedResultBuf); |
|
1763 |
|
1764 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
1765 { |
|
1766 TInt bytesCopied = 0; |
|
1767 |
|
1768 while(bytesCopied < ptr.Length()) |
|
1769 { |
|
1770 TInt bytesToCopy = ptr.Length() - bytesCopied; |
|
1771 if(bytesToCopy > KMaxTestExecuteLogLineLength) |
|
1772 { |
|
1773 bytesToCopy = KMaxTestExecuteLogLineLength; |
|
1774 } |
|
1775 TPtrC tmp(&ptr[bytesCopied],bytesToCopy); |
|
1776 bytesCopied += bytesToCopy; |
|
1777 HtmlLogger().Write(tmp); // Write results to HTML log file |
|
1778 if(iPIPSExists) |
|
1779 { |
|
1780 PIPSLogger().Write(tmp); |
|
1781 } |
|
1782 } |
|
1783 } |
|
1784 |
|
1785 // Cleanup heap allocations |
|
1786 CleanupStack::PopAndDestroy(resultBuffer); |
|
1787 } |
|
1788 |
|
1789 if (iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth) |
|
1790 { |
|
1791 _LIT(KTEFTestCaseName,"TESTCASENAME"); |
|
1792 _LIT(KTEFSyncTestCaseName,"SYNCTESTCASENAME"); |
|
1793 _LIT(KTEFTestCaseResult,"RESULT"); |
|
1794 |
|
1795 if (aCommand == KTEFStartTestCaseCommand || aCommand == KTEFStartSyncTestCaseCommand ) |
|
1796 { |
|
1797 // Create a TExtraLogField object and set the TestCaseName for Logging |
|
1798 TExtraLogField logField[1]; |
|
1799 if( aCommand == KTEFStartSyncTestCaseCommand ) |
|
1800 { |
|
1801 logField[0].iLogFieldName.Copy(KTEFSyncTestCaseName); // Sync Test Case Name |
|
1802 } |
|
1803 else |
|
1804 { |
|
1805 logField[0].iLogFieldName.Copy(KTEFTestCaseName); // Test Case Name |
|
1806 } |
|
1807 logField[0].iLogFieldValue.Copy(aTestCaseName); |
|
1808 |
|
1809 // Log the command name along with the field-value pairs |
|
1810 XmlLogger().Log(((TText8*)__FILE__), aLine, RFileFlogger::TLogSeverity(aSeverity), 1, logField, KTEFStringFormat, &aCommand); |
|
1811 } |
|
1812 |
|
1813 // If the command is END_TESTCASE, an extra RESULT field also needs to be logged |
|
1814 else if (aCommand == KTEFEndTestCaseCommand || aCommand == KTEFEndSyncTestCaseCommand) |
|
1815 { |
|
1816 // Create a TExtraLogField object and set the TestCaseName & Result fields for Logging |
|
1817 TExtraLogField logField[2]; |
|
1818 if( aCommand == KTEFEndSyncTestCaseCommand ) |
|
1819 { |
|
1820 logField[0].iLogFieldName.Copy(KTEFSyncTestCaseName); // Sync Test Case Name |
|
1821 } |
|
1822 else |
|
1823 { |
|
1824 logField[0].iLogFieldName.Copy(KTEFTestCaseName); // Test Case Name |
|
1825 } |
|
1826 |
|
1827 logField[0].iLogFieldValue.Copy(aTestCaseName); |
|
1828 |
|
1829 logField[1].iLogFieldName.Copy(KTEFTestCaseResult); // Test Case Result |
|
1830 |
|
1831 // Set the result value based on the aResult parameter being passed in |
|
1832 if (aResult == EPass) |
|
1833 { |
|
1834 logField[1].iLogFieldValue.Copy(KTEFResultPass); |
|
1835 } |
|
1836 else if (aResult == EFail) |
|
1837 { |
|
1838 logField[1].iLogFieldValue.Copy(KTEFResultFail); |
|
1839 } |
|
1840 else if(aResult == ESkippedSelectively) |
|
1841 { |
|
1842 logField[1].iLogFieldValue.Copy(KTEFResultSkippedSelectively); |
|
1843 } |
|
1844 else |
|
1845 { |
|
1846 logField[1].iLogFieldValue.Copy(KTEFResultInconclusive); |
|
1847 } |
|
1848 |
|
1849 // Log the command name along with the field-value pairs & Result |
|
1850 XmlLogger().Log(((TText8*)__FILE__), aLine, RFileFlogger::TLogSeverity(aSeverity), 2, logField, KTEFStringFormat, &aCommand); |
|
1851 } |
|
1852 } |
|
1853 } |
|
1854 |
|
1855 /** |
|
1856 * @param aCurrentScriptLine - Reference to a descriptor that holds the current script line |
|
1857 * @param aScriptFile - Name of the file where the current script file exists |
|
1858 * Prints the current script line |
|
1859 */ |
|
1860 EXPORT_C void CTestExecuteLogger::PrintCurrentScriptLine(TDes& aCurrentScriptLine) |
|
1861 { |
|
1862 TInt length = aCurrentScriptLine.Length(); |
|
1863 (aCurrentScriptLine[length - 2] == '\r') ? (aCurrentScriptLine.SetLength(length - 2)) : (aCurrentScriptLine.SetLength(length - 1)); |
|
1864 |
|
1865 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
1866 { |
|
1867 iSerialWriter->WriteDecorated(aCurrentScriptLine) ; |
|
1868 } |
|
1869 if( (iLoggerChannel == EFile || iLoggerChannel == EBoth) |
|
1870 && (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth)) |
|
1871 { |
|
1872 // Log the current script line to Html result log |
|
1873 HtmlLogger().WriteFormat(KTEFStringFormat,&aCurrentScriptLine); |
|
1874 } |
|
1875 if(iPIPSExists) |
|
1876 { |
|
1877 PIPSLogger().WriteFormat(KTEFStringFormat,&aCurrentScriptLine); |
|
1878 } |
|
1879 } |
|
1880 |
|
1881 LOCAL_C TVerdict SetExpectedResult(TLex aResultValue) |
|
1882 { |
|
1883 TInt expectedResult; |
|
1884 TInt err = aResultValue.Val(expectedResult); |
|
1885 if (err != KErrNone) |
|
1886 { |
|
1887 TBuf <KTEFMaxVerdictLength> tempString(aResultValue.NextToken()); |
|
1888 tempString.UpperCase(); |
|
1889 if (tempString.CompareF(KTEFResultFail) == KTEFZeroValue) |
|
1890 { |
|
1891 expectedResult = EFail; |
|
1892 } |
|
1893 else if(tempString.CompareF(KTEFResultInconclusive) == KTEFZeroValue) |
|
1894 { |
|
1895 expectedResult = EInconclusive; |
|
1896 } |
|
1897 else if(tempString.CompareF(KTEFResultAbort) == KTEFZeroValue) |
|
1898 { |
|
1899 expectedResult = EAbort; |
|
1900 } |
|
1901 else if(tempString.CompareF(KTEFResultPass) == KTEFZeroValue) |
|
1902 { |
|
1903 expectedResult = EPass; |
|
1904 } |
|
1905 else |
|
1906 { |
|
1907 expectedResult = EInconclusive; |
|
1908 } |
|
1909 } |
|
1910 return TVerdict(expectedResult); |
|
1911 } |
|
1912 |
|
1913 /** |
|
1914 * @param aResult - Result of execution of test steps for logging |
|
1915 * @param aPanicString - Reference descriptor containing the panic string if the test step results in a panic |
|
1916 * @param aScriptLineNumber - Line number within the script file where the RUN_TEST_STEP command is available |
|
1917 * @param aCommand - Command name being being executed (RUN_TEST_STEP & variants) |
|
1918 * @param aScriptFile - Name of the script file being used for execution |
|
1919 * @param aSeverity - One of the 4 enum values indicating the severity of the message to be logged |
|
1920 * Responsible for logging results for the RUN_TEST_STEP command/variants |
|
1921 */ |
|
1922 void CTestExecuteLogger::LogResultSerialL(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile) |
|
1923 { |
|
1924 |
|
1925 HBufC* resultBuffer = HBufC::NewLC(KMaxTestExecuteCommandLength*3); |
|
1926 TPtr ptr(resultBuffer->Des()); |
|
1927 TLex scriptLineLex(aCommand); |
|
1928 TLex scriptLineParamLex(aCommand); |
|
1929 TLex xmlLogCommandParseLex(aCommand); |
|
1930 TPtrC command(scriptLineLex.NextToken()); |
|
1931 TBool showPanicResult(ETrue); |
|
1932 TBool showActualResult(EFalse); |
|
1933 TBool showPanicInfo(EFalse); |
|
1934 TVerdict actualResult(aResult); |
|
1935 TVerdict actualPanic(aResult); |
|
1936 TInt expectedPanicCode(0); |
|
1937 TInt expectedReturnCode(EPass); |
|
1938 TPtrC expectedPanicStringLex(KNull); |
|
1939 TPtrC expectedErrorStringLex(KNull); |
|
1940 |
|
1941 // Newly added variables for implementing !Params for TEF |
|
1942 TVerdict tefResult(EPass); |
|
1943 TBuf<KTEFTestExecuteParamLength> tefError(KNull); |
|
1944 TBuf<KMaxTestExecuteCommandLength> tefPanicString(KNull); |
|
1945 TBuf<KTEFTestExecuteParamLength> tefPanicCode(KNull); |
|
1946 TBool paramExistence(EFalse); |
|
1947 TPtrC panicString; |
|
1948 TPtrC errorString; |
|
1949 TPtrC defaultStr(KNull); |
|
1950 /// Start of defect Fix : defect 037262 |
|
1951 |
|
1952 // RUN_TEST_STEP_RESULT |
|
1953 // RUN_PANIC_STEP_RESULT |
|
1954 // |
|
1955 // Check that the expected result meets that of the actual result. |
|
1956 // |
|
1957 // RUN_TEST_STEP_RESULT will return : |
|
1958 // |
|
1959 // PASS if the expected result meets the actual result |
|
1960 // FAIL if expected result was not the same as actual, the actual result is also displayed |
|
1961 // PANIC if the testcode panicked. |
|
1962 // |
|
1963 // RUN_PANIC_STEP_RESULT will return : |
|
1964 // |
|
1965 // PASS if Testcode panicked and expected/actual panic code/ strings match |
|
1966 // PANIC if TestCode panicked but the expected/actual panic code/ strings differ |
|
1967 // FAIL if Testcode did not panic, the actual result is also displayed |
|
1968 // |
|
1969 // RUN_PANIC_STEP will will now return : (for defect 039749) |
|
1970 // PASS if Testcode panicked irrespective of panic code/ strings, the code & strings are displayed |
|
1971 // FAIL if Testcode did not panic, the actual result is also displayed |
|
1972 |
|
1973 if (aPanicString.Length() >= KTEFMinPanicStringLength && aPanicString.Mid(0,KTEFMinPanicStringLength).CompareF(KErrorEquals) == KTEFZeroValue) |
|
1974 { |
|
1975 errorString.Set(aPanicString.Mid(KTEFMinPanicStringLength)); |
|
1976 panicString.Set(KNull); |
|
1977 } |
|
1978 else if (aPanicString.Length() >= KTEFMinPanicStringLength && aPanicString.Mid(0,KTEFMinPanicStringLength).CompareF(KPanicEquals) == KTEFZeroValue) |
|
1979 { |
|
1980 panicString.Set(aPanicString.Mid(KTEFMinPanicStringLength)); |
|
1981 defaultStr.Set(panicString); |
|
1982 errorString.Set(KNull); |
|
1983 } |
|
1984 |
|
1985 if(command == KTEFRunTestStepCommand && aResult!= EIgnore) |
|
1986 { |
|
1987 TInt firstChar; |
|
1988 TPtrC commandStr(scriptLineParamLex.NextToken()); |
|
1989 while(!scriptLineParamLex.Eos()) |
|
1990 { |
|
1991 TInt err(0); |
|
1992 scriptLineParamLex.SkipSpace(); |
|
1993 commandStr.Set(scriptLineParamLex.NextToken()); |
|
1994 firstChar = commandStr[0]; |
|
1995 // 33 is the ascii value for "!". Used here for confirming switches |
|
1996 if (firstChar == KTEFAsciiExclamation) |
|
1997 { |
|
1998 if (commandStr.Length() >= KTEFMinErrorParamLength && commandStr.Mid(0,KTEFMinErrorParamLength).CompareF(KTEFError) == KTEFZeroValue) |
|
1999 { |
|
2000 if(command == KTEFRunTestStepCommand) |
|
2001 { |
|
2002 paramExistence = ETrue; |
|
2003 command.Set(KTEFRunErrorStepResultCommand); |
|
2004 TRAP(err,tefError.Copy(commandStr.Mid(KTEFMinErrorParamLength))); |
|
2005 if (err) |
|
2006 tefError.Copy(KNull); |
|
2007 defaultStr.Set(errorString); |
|
2008 } |
|
2009 } |
|
2010 else if (commandStr.Length() >= KTEFMinResultParamLength && commandStr.Mid(0,KTEFMinResultParamLength).CompareF(KTEFResult) == KTEFZeroValue) |
|
2011 { |
|
2012 if (command == KTEFRunTestStepCommand) |
|
2013 { |
|
2014 paramExistence = ETrue; |
|
2015 command.Set(KTEFRunTestStepResultCommand); |
|
2016 TLex resultVal(commandStr.Mid(KTEFMinResultParamLength)); |
|
2017 tefResult = SetExpectedResult(resultVal); |
|
2018 } |
|
2019 } |
|
2020 else if (commandStr.Length() >= KTEFMinPanicCodeParamLength && commandStr.Mid(0,KTEFMinPanicCodeParamLength).CompareF(KTEFPanicCode) == KTEFZeroValue) |
|
2021 { |
|
2022 if(command == KTEFRunTestStepCommand) |
|
2023 { |
|
2024 paramExistence = ETrue; |
|
2025 command.Set(KTEFRunPanicStepResultCommand); |
|
2026 TRAP(err,tefPanicCode.Copy(commandStr.Mid(KTEFMinPanicCodeParamLength))); |
|
2027 if (err) |
|
2028 tefPanicCode.Copy(KNull); |
|
2029 defaultStr.Set(panicString); |
|
2030 } |
|
2031 else if(command == KTEFRunPanicStepResultCommand && tefPanicString.Length() != KTEFZeroValue) |
|
2032 { |
|
2033 TRAP(err,tefPanicCode.Copy(commandStr.Mid(KTEFMinPanicCodeParamLength))); |
|
2034 if (err) |
|
2035 tefPanicCode.Copy(KNull); |
|
2036 defaultStr.Set(panicString); |
|
2037 } |
|
2038 } |
|
2039 else if (commandStr.Length() >= KTEFMinPanicStringParamLength && commandStr.Mid(0,KTEFMinPanicStringParamLength).CompareF(KTEFPanicString) == KTEFZeroValue) |
|
2040 { |
|
2041 if(command == KTEFRunTestStepCommand) |
|
2042 { |
|
2043 paramExistence = ETrue; |
|
2044 command.Set(KTEFRunPanicStepResultCommand); |
|
2045 TRAP(err,tefPanicString.Copy(commandStr.Mid(KTEFMinPanicStringParamLength))); |
|
2046 if (err) |
|
2047 tefPanicString.Copy(KNull); |
|
2048 else |
|
2049 { |
|
2050 if (tefPanicString.Mid(0,1) == KTEFOpenQuotes) |
|
2051 tefPanicString.Copy(tefPanicString.Mid(1,tefPanicString.Length()-2)); |
|
2052 } |
|
2053 defaultStr.Set(panicString); |
|
2054 } |
|
2055 else if(command == KTEFRunPanicStepResultCommand && tefPanicString.Length() != KTEFZeroValue) |
|
2056 { |
|
2057 TRAP(err,tefPanicString.Copy(commandStr.Mid(KTEFMinPanicStringParamLength))); |
|
2058 if (err) |
|
2059 tefPanicString.Copy(KNull); |
|
2060 else |
|
2061 { |
|
2062 if (tefPanicString.Mid(0,1) == KTEFOpenQuotes) |
|
2063 tefPanicString.Copy(tefPanicString.Mid(1,tefPanicString.Length()-2)); |
|
2064 } |
|
2065 defaultStr.Set(panicString); |
|
2066 } |
|
2067 } |
|
2068 } |
|
2069 else |
|
2070 break; |
|
2071 } |
|
2072 } |
|
2073 |
|
2074 if (aResult!= EIgnore) |
|
2075 { |
|
2076 if ((command == KTEFRunTestStepResultCommand) && (defaultStr.Length() == KTEFZeroValue)) |
|
2077 { |
|
2078 // Pickout the expected returncode value |
|
2079 TLex expectedReturnCodeLex(scriptLineLex.NextToken()); |
|
2080 TInt err; |
|
2081 if (paramExistence) |
|
2082 { |
|
2083 expectedReturnCode = tefResult; |
|
2084 err = 0; |
|
2085 } |
|
2086 else |
|
2087 err = expectedReturnCodeLex.Val(expectedReturnCode); |
|
2088 if (err == KTEFZeroValue) |
|
2089 { |
|
2090 if (expectedReturnCode == aResult) |
|
2091 { |
|
2092 aResult = EPass; |
|
2093 } |
|
2094 else |
|
2095 { |
|
2096 aResult = EFail; |
|
2097 showActualResult = ETrue; |
|
2098 } |
|
2099 } |
|
2100 } |
|
2101 else if (command == KTEFRunPanicStepResultCommand) |
|
2102 { |
|
2103 if (defaultStr.Length()) // we have indeed panicked |
|
2104 { |
|
2105 // Pickout the expected panic code value |
|
2106 // not necessarily 0, 106-110, but any integer value set by test step |
|
2107 TLex expectedPanicCodeLex(scriptLineLex.NextToken()); |
|
2108 //TInt expectedPanicCode; |
|
2109 TInt err; |
|
2110 if (paramExistence) |
|
2111 { |
|
2112 if (tefPanicCode.Length()) |
|
2113 { |
|
2114 TLex PanicCodeLex(tefPanicCode); |
|
2115 err = PanicCodeLex.Val(expectedPanicCode); |
|
2116 } |
|
2117 else |
|
2118 { |
|
2119 expectedPanicCode = aResult; |
|
2120 err = 0; |
|
2121 } |
|
2122 } |
|
2123 else |
|
2124 err = expectedPanicCodeLex.Val(expectedPanicCode); |
|
2125 |
|
2126 if (err == KTEFZeroValue) |
|
2127 { |
|
2128 if (expectedPanicCode == aResult) |
|
2129 { |
|
2130 //TPtrC expectedPanicStringLex; |
|
2131 // Now check ALSO that the panic string is identical. |
|
2132 if (paramExistence) |
|
2133 { |
|
2134 if (tefPanicString.Length()) |
|
2135 expectedPanicStringLex.Set(tefPanicString); |
|
2136 else |
|
2137 expectedPanicStringLex.Set(defaultStr); |
|
2138 } |
|
2139 else |
|
2140 expectedPanicStringLex.Set(scriptLineLex.NextToken()); |
|
2141 if (expectedPanicStringLex == defaultStr) |
|
2142 { |
|
2143 // Pretend its not a Panic |
|
2144 aResult = EPass; |
|
2145 showPanicResult = EFalse; |
|
2146 } |
|
2147 else |
|
2148 { |
|
2149 aResult = EFail; |
|
2150 showPanicInfo = ETrue; |
|
2151 showPanicResult = EFalse; |
|
2152 } |
|
2153 } |
|
2154 else |
|
2155 { |
|
2156 aResult = EFail; |
|
2157 showPanicInfo = ETrue; |
|
2158 showPanicResult = EFalse; |
|
2159 } |
|
2160 } |
|
2161 } |
|
2162 else |
|
2163 { |
|
2164 // we haven't panicked, we were looking for one, so this is a FAIL. |
|
2165 aResult = EFail; |
|
2166 showPanicResult = EFalse; |
|
2167 showActualResult = ETrue; |
|
2168 } |
|
2169 } |
|
2170 else if (command == KTEFRunPanicStepCommand) |
|
2171 { |
|
2172 if (defaultStr.Length()) // we have indeed panicked |
|
2173 { |
|
2174 // Pretend its not a Panic |
|
2175 aResult = EPass; |
|
2176 showPanicInfo = ETrue; |
|
2177 showPanicResult = EFalse; |
|
2178 } |
|
2179 else |
|
2180 { |
|
2181 // we haven't panicked, we were looking for one, so this is a FAIL. |
|
2182 aResult = EFail; |
|
2183 showPanicResult = EFalse; |
|
2184 showActualResult = ETrue; |
|
2185 } |
|
2186 } |
|
2187 else if (command == KTEFRunErrorStepResultCommand && paramExistence) |
|
2188 { |
|
2189 if (defaultStr.Length()) |
|
2190 { |
|
2191 // Pickout the expected returncode value |
|
2192 //TPtrC expectedErrorStringLex; |
|
2193 expectedErrorStringLex.Set(tefError); |
|
2194 |
|
2195 if (expectedErrorStringLex == defaultStr) |
|
2196 { |
|
2197 // Pretend its not Error |
|
2198 aResult = EPass; |
|
2199 showPanicResult = EFalse; |
|
2200 } |
|
2201 else |
|
2202 { |
|
2203 aResult = EFail; |
|
2204 showPanicResult = EFalse; |
|
2205 showPanicInfo = ETrue; |
|
2206 } |
|
2207 } |
|
2208 else |
|
2209 { |
|
2210 // We haven't got any error, so this is a FAIL |
|
2211 aResult = EFail; |
|
2212 showPanicResult = EFalse; |
|
2213 showActualResult = ETrue; |
|
2214 } |
|
2215 } |
|
2216 else if (errorString.Length()) |
|
2217 { |
|
2218 aResult = EFail; |
|
2219 defaultStr.Set(errorString); |
|
2220 showPanicResult = EFalse; |
|
2221 showPanicInfo = ETrue; |
|
2222 } |
|
2223 } |
|
2224 |
|
2225 // End of bulk of defect defect 037262, fix also includes references to showPanicResult below |
|
2226 // allowing expected Panics to show as Passes + printing of actualResult. |
|
2227 ptr.Append(aScriptFile); |
|
2228 _LIT(KLineNumber," Line = %d"); |
|
2229 ptr.AppendFormat(KLineNumber,aScriptLineNumber); |
|
2230 _LIT(KCommand," Command = "); |
|
2231 ptr.Append(KCommand); |
|
2232 ptr.Append(aCommand); |
|
2233 ptr.Trim(); |
|
2234 _LIT(KTEFSpace," "); |
|
2235 ptr.Append(KTEFSpace); |
|
2236 |
|
2237 _LIT(KCode," Code = %d "); |
|
2238 if (showActualResult) |
|
2239 { |
|
2240 _LIT(KActualResult, "Returned: "); |
|
2241 ptr.Append(KActualResult); |
|
2242 if(actualResult == EPass) |
|
2243 ptr.Append(KTEFResultPass); |
|
2244 else if(actualResult == EFail) |
|
2245 ptr.Append(KTEFResultFail); |
|
2246 else if(actualResult == EInconclusive) |
|
2247 ptr.Append(KTEFResultInconclusive); |
|
2248 else if(actualResult == EAbort || aResult == KErrAbort) |
|
2249 ptr.Append(KTEFResultAbort); |
|
2250 else |
|
2251 { |
|
2252 // Log the error code |
|
2253 ptr.Append(KTEFResultUnknown); |
|
2254 ptr.AppendFormat(KCode,(TInt)actualResult); |
|
2255 } |
|
2256 ptr.Append(KTEFSpace); |
|
2257 } |
|
2258 |
|
2259 if (showPanicInfo) |
|
2260 { |
|
2261 if (errorString.Length()) |
|
2262 { |
|
2263 TLex errorValue(defaultStr); |
|
2264 TInt errorInt; |
|
2265 errorValue.Val(errorInt); |
|
2266 ptr.AppendFormat(KCode,(TInt)errorInt); |
|
2267 ptr.Append(KTEFSpace); |
|
2268 } |
|
2269 else |
|
2270 { |
|
2271 ptr.AppendFormat(KCode,(TInt)actualPanic); |
|
2272 ptr.Append(KTEFSpace); |
|
2273 ptr.Append(defaultStr); |
|
2274 ptr.Append(KTEFSpace); |
|
2275 } |
|
2276 } |
|
2277 |
|
2278 ptr.Append(KTEFResultTag); |
|
2279 ptr.Append(KTEFSpaceEquals); |
|
2280 |
|
2281 if ((defaultStr.Length()) && showPanicResult) |
|
2282 { |
|
2283 ptr.Append(KTEFResultPanic); |
|
2284 _LIT(KHyphen," - "); |
|
2285 ptr.Append(KHyphen); |
|
2286 ptr.Append(defaultStr); |
|
2287 ptr.AppendFormat(KCode,(TInt)aResult); |
|
2288 } |
|
2289 else if(aResult == EPass) |
|
2290 ptr.Append(KTEFResultPass); |
|
2291 else if(aResult == EFail) |
|
2292 ptr.Append(KTEFResultFail); |
|
2293 else if(aResult == EInconclusive) |
|
2294 ptr.Append(KTEFResultInconclusive); |
|
2295 else if(aResult == EAbort || aResult == KErrAbort) |
|
2296 ptr.Append(KTEFResultAbort); |
|
2297 else if (aResult == EIgnore) |
|
2298 ptr.Append(KTEFResultUnexecuted); |
|
2299 else |
|
2300 { |
|
2301 // Log the error code |
|
2302 ptr.Append(KTEFResultUnknown); |
|
2303 ptr.AppendFormat(KCode,(TInt)aResult); |
|
2304 } |
|
2305 ptr.Append(KTEFSpace); |
|
2306 |
|
2307 HBufC8* resultBuffer8 = HBufC8::NewLC(ptr.Length()+2); |
|
2308 TPtr8 ptr8(resultBuffer8->Des()); |
|
2309 ptr8.Copy(ptr); |
|
2310 ptr8.Append(KTEFEndOfLine); |
|
2311 |
|
2312 LoggingTestCaseResultToSummaryResultL(iHtmlLogPath,KTEFTestExecuteResultSummaryFile,ptr8); |
|
2313 |
|
2314 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
2315 { |
|
2316 TInt bytesCopied = 0; |
|
2317 |
|
2318 while(bytesCopied < ptr.Length()) |
|
2319 { |
|
2320 TInt bytesToCopy = ptr.Length() - bytesCopied; |
|
2321 if(bytesToCopy > KMaxTestExecuteLogLineLength) |
|
2322 { |
|
2323 bytesToCopy = KMaxTestExecuteLogLineLength; |
|
2324 } |
|
2325 TPtrC tmp(&ptr[bytesCopied],bytesToCopy); |
|
2326 bytesCopied += bytesToCopy; |
|
2327 iSerialWriter->WriteDecorated(tmp); |
|
2328 } |
|
2329 } |
|
2330 CleanupStack::PopAndDestroy(resultBuffer8); |
|
2331 CleanupStack::PopAndDestroy(resultBuffer); |
|
2332 } |
|
2333 |
|
2334 /** |
|
2335 * @param aResult - Result of execution of test steps for logging |
|
2336 * @param aPanicString - Reference descriptor containing the panic string if the test step results in a panic |
|
2337 * @param aScriptLineNumber - Line number within the script file where the RUN_TEST_STEP command is available |
|
2338 * @param aCommand - Command name being being executed (RUN_TEST_STEP & variants) |
|
2339 * @param aScriptFile - Name of the script file being used for execution |
|
2340 * @param aSeverity - One of the 4 enum values indicating the severity of the message to be logged |
|
2341 * Responsible for logging results for the RUN_TEST_STEP command/variants |
|
2342 */ |
|
2343 void CTestExecuteLogger::LogResultFileL(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile, TInt aSeverity) |
|
2344 { |
|
2345 HBufC* resultBuffer = HBufC::NewLC(KMaxTestExecuteCommandLength*3); |
|
2346 TPtr ptr(resultBuffer->Des()); |
|
2347 HBufC* simplifiedResultBuf = HBufC::NewLC(KMaxTestExecuteCommandLength*3); |
|
2348 TPtr simplifiedPtr(simplifiedResultBuf->Des()); |
|
2349 TLex scriptLineLex(aCommand); |
|
2350 TLex scriptLineParamLex(aCommand); |
|
2351 TLex xmlLogCommandParseLex(aCommand); |
|
2352 TPtrC command(scriptLineLex.NextToken()); |
|
2353 TBool showPanicResult(ETrue); |
|
2354 TBool showActualResult(EFalse); |
|
2355 TBool showPanicInfo(EFalse); |
|
2356 TBool isARealPanic(EFalse); //PDEF117769 |
|
2357 TVerdict actualResult(aResult); |
|
2358 TVerdict actualPanic(aResult); |
|
2359 TInt expectedPanicCode(0); |
|
2360 TInt expectedReturnCode(EPass); |
|
2361 TPtrC expectedPanicStringLex(KNull); |
|
2362 TPtrC expectedErrorStringLex(KNull); |
|
2363 |
|
2364 // Newly added variables for implementing !Params for TEF |
|
2365 TVerdict tefResult(EPass); |
|
2366 TBuf<KTEFTestExecuteParamLength> tefError(KNull); |
|
2367 // using 256 because in script this parameter could be very long |
|
2368 TBuf<KMaxTestExecuteCommandLength> tefPanicString(KNull); |
|
2369 TBuf<KTEFTestExecuteParamLength> tefPanicCode(KNull); |
|
2370 TBool paramExistence(EFalse); |
|
2371 TPtrC panicString; |
|
2372 TPtrC errorString; |
|
2373 TPtrC defaultStr(KNull); |
|
2374 /// Start of defect Fix : defect 037262 |
|
2375 |
|
2376 // RUN_TEST_STEP_RESULT |
|
2377 // RUN_PANIC_STEP_RESULT |
|
2378 // |
|
2379 // Check that the expected result meets that of the actual result. |
|
2380 // |
|
2381 // RUN_TEST_STEP_RESULT will return : |
|
2382 // |
|
2383 // PASS if the expected result meets the actual result |
|
2384 // FAIL if expected result was not the same as actual, the actual result is also displayed |
|
2385 // PANIC if the testcode panicked. |
|
2386 // |
|
2387 // RUN_PANIC_STEP_RESULT will return : |
|
2388 // |
|
2389 // PASS if Testcode panicked and expected/actual panic code/ strings match |
|
2390 // PANIC if TestCode panicked but the expected/actual panic code/ strings differ |
|
2391 // FAIL if Testcode did not panic, the actual result is also displayed |
|
2392 // |
|
2393 // RUN_PANIC_STEP will will now return : (for defect 039749) |
|
2394 // PASS if Testcode panicked irrespective of panic code/ strings, the code & strings are displayed |
|
2395 // FAIL if Testcode did not panic, the actual result is also displayed |
|
2396 |
|
2397 if (aPanicString.Length() >= KTEFMinPanicStringLength && aPanicString.Mid(0,KTEFMinPanicStringLength).CompareF(KErrorEquals) == KTEFZeroValue) |
|
2398 { |
|
2399 errorString.Set(aPanicString.Mid(KTEFMinPanicStringLength)); |
|
2400 panicString.Set(KNull); |
|
2401 } |
|
2402 else if (aPanicString.Length() >= KTEFMinPanicStringLength && aPanicString.Mid(0,KTEFMinPanicStringLength).CompareF(KPanicEquals) == KTEFZeroValue) |
|
2403 { |
|
2404 panicString.Set(aPanicString.Mid(KTEFMinPanicStringLength)); |
|
2405 defaultStr.Set(panicString); |
|
2406 errorString.Set(KNull); |
|
2407 isARealPanic = ETrue;//PDEF117769 |
|
2408 if (panicString.Length() == KTEFMaxPanicStringLength ) |
|
2409 { |
|
2410 //TEF not know whether the panic string is being turncated. |
|
2411 //if received panic string == 16, TEF will give warning info to log. |
|
2412 LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, KTEFWarnPanicString ); |
|
2413 } |
|
2414 } |
|
2415 |
|
2416 //PDEF117769 |
|
2417 // the panic code (110) is SAME with define of EIgnore(110) |
|
2418 // When Panic 110 really happens, the defect code will take this situation as EIgnore. |
|
2419 // Solution is get the panic string when panic happens, then compare with expected panic string. |
|
2420 // aPanicString.Length() > 0, when panic really happens. |
|
2421 // So an extra condition at last. |
|
2422 if((command == KTEFRunTestStepCommand || command == KTEFEndTestBlock) && (aResult!= EIgnore || isARealPanic )) |
|
2423 { |
|
2424 TInt firstChar; |
|
2425 TPtrC commandStr(scriptLineParamLex.NextToken()); |
|
2426 while(!scriptLineParamLex.Eos()) |
|
2427 { |
|
2428 TInt err(0); |
|
2429 scriptLineParamLex.SkipSpace(); |
|
2430 commandStr.Set(scriptLineParamLex.NextToken()); |
|
2431 if( commandStr.Length()>0 ) |
|
2432 { |
|
2433 firstChar = commandStr[0]; |
|
2434 // 33 is the ascii value for "!". Used here for confirming switches |
|
2435 if (firstChar == KTEFAsciiExclamation) |
|
2436 { |
|
2437 if (commandStr.Length() >= KTEFMinErrorParamLength && commandStr.Mid(0,KTEFMinErrorParamLength).CompareF(KTEFError) == KTEFZeroValue) |
|
2438 { |
|
2439 if(command == KTEFRunTestStepCommand || command == KTEFEndTestBlock) |
|
2440 { |
|
2441 paramExistence = ETrue; |
|
2442 command.Set(KTEFRunErrorStepResultCommand); |
|
2443 TRAP(err,tefError.Copy(commandStr.Mid(KTEFMinErrorParamLength))); |
|
2444 if (err) |
|
2445 tefError.Copy(KNull); |
|
2446 defaultStr.Set(errorString); |
|
2447 } |
|
2448 } |
|
2449 else if (commandStr.Length() >= KTEFMinResultParamLength && commandStr.Mid(0,KTEFMinResultParamLength).CompareF(KTEFResult) == KTEFZeroValue) |
|
2450 { |
|
2451 if (command == KTEFRunTestStepCommand || command == KTEFEndTestBlock) |
|
2452 { |
|
2453 paramExistence = ETrue; |
|
2454 command.Set(KTEFRunTestStepResultCommand); |
|
2455 TLex resultVal(commandStr.Mid(KTEFMinResultParamLength)); |
|
2456 tefResult = SetExpectedResult(resultVal); |
|
2457 } |
|
2458 } |
|
2459 else if (commandStr.Length() >= KTEFMinPanicCodeParamLength && commandStr.Mid(0,KTEFMinPanicCodeParamLength).CompareF(KTEFPanicCode) == KTEFZeroValue) |
|
2460 { |
|
2461 if(command == KTEFRunTestStepCommand || command == KTEFEndTestBlock) |
|
2462 { |
|
2463 paramExistence = ETrue; |
|
2464 command.Set(KTEFRunPanicStepResultCommand); |
|
2465 TRAP(err,tefPanicCode.Copy(commandStr.Mid(KTEFMinPanicCodeParamLength))); |
|
2466 if (err) |
|
2467 tefPanicCode.Copy(KNull); |
|
2468 defaultStr.Set(panicString); |
|
2469 } |
|
2470 //PDEF117769 |
|
2471 else if( command == KTEFRunPanicStepResultCommand ) |
|
2472 { |
|
2473 TRAP(err,tefPanicCode.Copy(commandStr.Mid(KTEFMinPanicCodeParamLength))); |
|
2474 if (err) |
|
2475 tefPanicCode.Copy(KNull); |
|
2476 defaultStr.Set(panicString); |
|
2477 } |
|
2478 } |
|
2479 else if (commandStr.Length() >= KTEFMinPanicStringParamLength && commandStr.Mid(0,KTEFMinPanicStringParamLength).CompareF(KTEFPanicString) == KTEFZeroValue) |
|
2480 { |
|
2481 if(command == KTEFRunTestStepCommand || command == KTEFEndTestBlock) |
|
2482 { |
|
2483 paramExistence = ETrue; |
|
2484 command.Set(KTEFRunPanicStepResultCommand); |
|
2485 |
|
2486 ParsePaincStringFromScriptCommandLine(commandStr,scriptLineParamLex,tefPanicString); |
|
2487 defaultStr.Set(panicString); |
|
2488 } |
|
2489 //PDEF117769 |
|
2490 else if(command == KTEFRunPanicStepResultCommand) |
|
2491 { |
|
2492 ParsePaincStringFromScriptCommandLine(commandStr,scriptLineParamLex,tefPanicString); |
|
2493 defaultStr.Set(panicString); |
|
2494 } |
|
2495 |
|
2496 // print out the panic string in panic dialog |
|
2497 // this make easier to user check what happened, when panic string compare fail. |
|
2498 if (isARealPanic && tefPanicString.Compare(panicString)) |
|
2499 { |
|
2500 LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, KTEFExpectedPanicString, &tefPanicString); |
|
2501 LogExtra(((TText8*)__FILE__), __LINE__, ESevrInfo, KTEFReceivedPanicString, &panicString); |
|
2502 } |
|
2503 } |
|
2504 } |
|
2505 } |
|
2506 else |
|
2507 break; |
|
2508 } |
|
2509 } |
|
2510 |
|
2511 //PDEF117769 |
|
2512 // See more detail above |
|
2513 if (aResult!= EIgnore || isARealPanic ) |
|
2514 { |
|
2515 if ((command == KTEFRunTestStepResultCommand) && (defaultStr.Length() == KTEFZeroValue)) |
|
2516 { |
|
2517 // Pickout the expected returncode value |
|
2518 TLex expectedReturnCodeLex(scriptLineLex.NextToken()); |
|
2519 TInt err; |
|
2520 if (paramExistence) |
|
2521 { |
|
2522 expectedReturnCode = tefResult; |
|
2523 err = 0; |
|
2524 } |
|
2525 else |
|
2526 err = expectedReturnCodeLex.Val(expectedReturnCode); |
|
2527 if (err == KTEFZeroValue) |
|
2528 { |
|
2529 if (expectedReturnCode == aResult) |
|
2530 { |
|
2531 aResult = EPass; |
|
2532 } |
|
2533 else |
|
2534 { |
|
2535 aResult = EFail; |
|
2536 showActualResult = ETrue; |
|
2537 } |
|
2538 } |
|
2539 } |
|
2540 else if (command == KTEFRunPanicStepResultCommand) |
|
2541 { |
|
2542 //PDEF117769 start |
|
2543 if ( isARealPanic ) // if panic really happens aPanicString !=0 (or >=2) |
|
2544 // we have indeed panicked |
|
2545 //PDEF117769 end |
|
2546 { |
|
2547 // Pickout the expected panic code value |
|
2548 // not necessarily 0, 106-110, but any integer value set by test step |
|
2549 TLex expectedPanicCodeLex(scriptLineLex.NextToken()); |
|
2550 //TInt expectedPanicCode; |
|
2551 TInt err; |
|
2552 if (paramExistence) |
|
2553 { |
|
2554 if (tefPanicCode.Length()) |
|
2555 { |
|
2556 TLex PanicCodeLex(tefPanicCode); |
|
2557 err = PanicCodeLex.Val(expectedPanicCode); |
|
2558 } |
|
2559 else |
|
2560 { |
|
2561 expectedPanicCode = aResult; |
|
2562 err = 0; |
|
2563 } |
|
2564 } |
|
2565 else |
|
2566 err = expectedPanicCodeLex.Val(expectedPanicCode); |
|
2567 |
|
2568 if (err == KTEFZeroValue) |
|
2569 { |
|
2570 if (expectedPanicCode == aResult) |
|
2571 { |
|
2572 //TPtrC expectedPanicStringLex; |
|
2573 // Now check ALSO that the panic string is identical. |
|
2574 if (paramExistence) |
|
2575 { |
|
2576 if (tefPanicString.Length()) |
|
2577 expectedPanicStringLex.Set(tefPanicString); |
|
2578 else |
|
2579 expectedPanicStringLex.Set(defaultStr); |
|
2580 } |
|
2581 else |
|
2582 { |
|
2583 expectedPanicStringLex.Set(scriptLineLex.NextToken()); |
|
2584 if (expectedPanicStringLex.Left(1) == KTEFOpenQuotes) |
|
2585 { |
|
2586 if (expectedPanicStringLex.Right(1) != KTEFOpenQuotes) |
|
2587 { |
|
2588 TBuf<KTEFTestExecuteParamLength> concatPanicString(expectedPanicStringLex.Mid(1,expectedPanicStringLex.Length()-1)); |
|
2589 TBool panicStringCompleted(EFalse); |
|
2590 while(!scriptLineLex.Eos() && !panicStringCompleted) |
|
2591 { |
|
2592 TPtrC panicStringExt(scriptLineLex.NextToken()); |
|
2593 concatPanicString.Append(KTEFSpace); |
|
2594 if(panicStringExt.Right(1) == KTEFOpenQuotes) |
|
2595 { |
|
2596 panicStringCompleted = ETrue; |
|
2597 concatPanicString.Append(panicStringExt.Mid(0, panicStringExt.Length()-1)); |
|
2598 } |
|
2599 else |
|
2600 concatPanicString.Append(panicStringExt); |
|
2601 } |
|
2602 expectedPanicStringLex.Set(concatPanicString); |
|
2603 } |
|
2604 else |
|
2605 expectedPanicStringLex.Set(expectedPanicStringLex.Mid(1,expectedPanicStringLex.Length()-2)); |
|
2606 } |
|
2607 } |
|
2608 //PDEF117769 |
|
2609 if ( (expectedPanicStringLex.Length() == KTEFZeroValue && defaultStr.Length() == KTEFZeroValue ) || expectedPanicStringLex == defaultStr ) |
|
2610 { |
|
2611 // Pretend its not a Panic |
|
2612 aResult = EPass; |
|
2613 showPanicResult = EFalse; |
|
2614 } |
|
2615 else |
|
2616 { |
|
2617 aResult = EFail; |
|
2618 showPanicInfo = ETrue; |
|
2619 showPanicResult = EFalse; |
|
2620 } |
|
2621 } |
|
2622 else |
|
2623 { |
|
2624 aResult = EFail; |
|
2625 showPanicInfo = ETrue; |
|
2626 showPanicResult = EFalse; |
|
2627 } |
|
2628 } |
|
2629 } |
|
2630 else |
|
2631 { |
|
2632 // we haven't panicked, we were looking for one, so this is a FAIL. |
|
2633 aResult = EFail; |
|
2634 showPanicResult = EFalse; |
|
2635 showActualResult = ETrue; |
|
2636 } |
|
2637 } |
|
2638 else if (command == KTEFRunPanicStepCommand) |
|
2639 { |
|
2640 if ( isARealPanic ) // we have indeed panicked |
|
2641 { |
|
2642 // Pretend its not a Panic |
|
2643 aResult = EPass; |
|
2644 showPanicInfo = ETrue; |
|
2645 showPanicResult = EFalse; |
|
2646 } |
|
2647 else |
|
2648 { |
|
2649 // we haven't panicked, we were looking for one, so this is a FAIL. |
|
2650 aResult = EFail; |
|
2651 showPanicResult = EFalse; |
|
2652 showActualResult = ETrue; |
|
2653 } |
|
2654 } |
|
2655 else if (command == KTEFRunErrorStepResultCommand && paramExistence) |
|
2656 { |
|
2657 if (defaultStr.Length()) |
|
2658 { |
|
2659 // Pickout the expected returncode value |
|
2660 //TPtrC expectedErrorStringLex; |
|
2661 expectedErrorStringLex.Set(tefError); |
|
2662 |
|
2663 if (expectedErrorStringLex == defaultStr) |
|
2664 { |
|
2665 // Pretend its not Error |
|
2666 aResult = EPass; |
|
2667 showPanicResult = EFalse; |
|
2668 } |
|
2669 else |
|
2670 { |
|
2671 aResult = EFail; |
|
2672 showPanicResult = EFalse; |
|
2673 showPanicInfo = ETrue; |
|
2674 } |
|
2675 } |
|
2676 else |
|
2677 { |
|
2678 // We haven't got any error, so this is a FAIL |
|
2679 aResult = EFail; |
|
2680 showPanicResult = EFalse; |
|
2681 showActualResult = ETrue; |
|
2682 } |
|
2683 } |
|
2684 else if (errorString.Length()) |
|
2685 { |
|
2686 aResult = EFail; |
|
2687 defaultStr.Set(errorString); |
|
2688 showPanicResult = EFalse; |
|
2689 showPanicInfo = ETrue; |
|
2690 } |
|
2691 } |
|
2692 |
|
2693 // End of bulk of defect defect 037262, fix also includes references to showPanicResult below |
|
2694 // allowing expected Panics to show as Passes + printing of actualResult. |
|
2695 |
|
2696 // Construct result tags for HTML logging |
|
2697 if ((defaultStr.Length()) && showPanicResult) |
|
2698 ptr.Append(KTEFFontBlue); |
|
2699 else if(aResult == EPass) |
|
2700 ptr.Append(KTEFFontGreen); |
|
2701 else if (aResult == EFail) |
|
2702 ptr.Append(KTEFFontRed); |
|
2703 else |
|
2704 ptr.Append(KTEFFontBlue); |
|
2705 ptr.Append(aScriptFile); |
|
2706 _LIT(KLineNumber," Line = %d"); |
|
2707 ptr.AppendFormat(KLineNumber,aScriptLineNumber); |
|
2708 _LIT(KCommand," Command = "); |
|
2709 ptr.Append(KCommand); |
|
2710 ptr.Append(aCommand); |
|
2711 ptr.Trim(); |
|
2712 simplifiedPtr.Append(aCommand); |
|
2713 simplifiedPtr.Trim(); |
|
2714 ptr.Append(KTEFSpace); |
|
2715 simplifiedPtr.Append(KTEFSpace); |
|
2716 |
|
2717 _LIT(KCode," Code = %d "); |
|
2718 |
|
2719 TBuf<KMaxTestExecuteCommandLength> resultTmpBuf; |
|
2720 resultTmpBuf.Zero(); |
|
2721 if (showActualResult) |
|
2722 { |
|
2723 _LIT(KActualResult, "Returned: "); |
|
2724 resultTmpBuf.Copy(KActualResult); |
|
2725 if(actualResult == EPass) |
|
2726 resultTmpBuf.Append(KTEFResultPass); |
|
2727 else if(actualResult == EFail) |
|
2728 resultTmpBuf.Append(KTEFResultFail); |
|
2729 else if(actualResult == EInconclusive) |
|
2730 resultTmpBuf.Append(KTEFResultInconclusive); |
|
2731 else if(actualResult == EAbort || aResult == KErrAbort) |
|
2732 resultTmpBuf.Append(KTEFResultAbort); |
|
2733 else |
|
2734 { |
|
2735 // Log the error code |
|
2736 resultTmpBuf.Append(KTEFResultUnknown); |
|
2737 resultTmpBuf.AppendFormat(KCode,(TInt)actualResult); |
|
2738 } |
|
2739 resultTmpBuf.Append(KTEFSpace); |
|
2740 } |
|
2741 ptr.Append(resultTmpBuf); |
|
2742 simplifiedPtr.Append(resultTmpBuf); |
|
2743 |
|
2744 if (showPanicInfo) |
|
2745 { |
|
2746 if (errorString.Length()) |
|
2747 { |
|
2748 TLex errorValue(defaultStr); |
|
2749 TInt errorInt; |
|
2750 errorValue.Val(errorInt); |
|
2751 ptr.AppendFormat(KCode,(TInt)errorInt); |
|
2752 ptr.Append(KTEFSpace); |
|
2753 } |
|
2754 else |
|
2755 { |
|
2756 ptr.AppendFormat(KCode,(TInt)actualPanic); |
|
2757 ptr.Append(KTEFSpace); |
|
2758 ptr.Append(defaultStr); |
|
2759 ptr.Append(KTEFSpace); |
|
2760 } |
|
2761 } |
|
2762 |
|
2763 ptr.Append(KTEFResultTag); |
|
2764 simplifiedPtr.Append(KTEFResultTag); |
|
2765 ptr.Append(KTEFSpaceEquals); |
|
2766 simplifiedPtr.Append(KTEFSpaceEquals); |
|
2767 |
|
2768 resultTmpBuf.Zero(); |
|
2769 if ((defaultStr.Length()) && showPanicResult) |
|
2770 { |
|
2771 resultTmpBuf.Append(KTEFResultPanic); |
|
2772 _LIT(KHyphen," - "); |
|
2773 resultTmpBuf.Append(KHyphen); |
|
2774 resultTmpBuf.Append(defaultStr); |
|
2775 resultTmpBuf.AppendFormat(KCode,(TInt)aResult); |
|
2776 } |
|
2777 else if(aResult == EPass) |
|
2778 resultTmpBuf.Append(KTEFResultPass); |
|
2779 else if(aResult == EFail) |
|
2780 resultTmpBuf.Append(KTEFResultFail); |
|
2781 else if(aResult == EInconclusive) |
|
2782 resultTmpBuf.Append(KTEFResultInconclusive); |
|
2783 else if(aResult == EAbort || aResult == KErrAbort) |
|
2784 resultTmpBuf.Append(KTEFResultAbort); |
|
2785 else if (aResult == EIgnore) |
|
2786 resultTmpBuf.Append(KTEFResultUnexecuted); |
|
2787 else |
|
2788 { |
|
2789 // Log the error code |
|
2790 resultTmpBuf.Append(KTEFResultUnknown); |
|
2791 resultTmpBuf.AppendFormat(KCode,(TInt)aResult); |
|
2792 } |
|
2793 ptr.Append(resultTmpBuf); |
|
2794 simplifiedPtr.Append(resultTmpBuf); |
|
2795 |
|
2796 ptr.Append(KTEFSpace); |
|
2797 simplifiedPtr.Append(KTEFSpace); |
|
2798 ptr.Append(KTEFFontEnd); |
|
2799 |
|
2800 HBufC8* resultBuffer8 = HBufC8::NewLC(ptr.Length()+2); |
|
2801 TPtr8 ptr8(resultBuffer8->Des()); |
|
2802 ptr8.Copy(ptr); |
|
2803 ptr8.Append(KTEFEndOfLine); |
|
2804 |
|
2805 // Only log the START_TEST_BLOCK command to the results file if it has failed |
|
2806 // and therefore the END_TEST_BLOCK command may not be logged. |
|
2807 if( 0 != command.Compare(KTEFStartTestBlock) || |
|
2808 (0 == command.Compare(KTEFStartTestBlock) && EPass != aResult) ) |
|
2809 { |
|
2810 LoggingTestCaseResultToSummaryResultL(iHtmlLogPath,KTEFTestExecuteResultSummaryFile,ptr8); |
|
2811 //re-use result buffer |
|
2812 ptr8.Zero(); |
|
2813 ptr8.Copy(simplifiedPtr); |
|
2814 ptr8.Append(KTEFEndOfLine); |
|
2815 LoggingTestCaseResultToSummaryResultL(iHtmlLogPath,KTEFTestExecuteResultSimplifiedSummaryFile,ptr8); |
|
2816 } |
|
2817 |
|
2818 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
2819 { |
|
2820 TInt bytesCopied = 0; |
|
2821 |
|
2822 while(bytesCopied < ptr.Length()) |
|
2823 { |
|
2824 TInt bytesToCopy = ptr.Length() - bytesCopied; |
|
2825 if(bytesToCopy > KMaxTestExecuteLogLineLength) |
|
2826 { |
|
2827 bytesToCopy = KMaxTestExecuteLogLineLength; |
|
2828 } |
|
2829 TPtrC tmp(&ptr[bytesCopied],bytesToCopy); |
|
2830 bytesCopied += bytesToCopy; |
|
2831 HtmlLogger().Write(tmp); |
|
2832 if(iPIPSExists) |
|
2833 { |
|
2834 PIPSLogger().Write(tmp); |
|
2835 } |
|
2836 } |
|
2837 } |
|
2838 |
|
2839 CleanupStack::PopAndDestroy(resultBuffer8); |
|
2840 CleanupStack::PopAndDestroy(simplifiedResultBuf); |
|
2841 CleanupStack::PopAndDestroy(resultBuffer); |
|
2842 |
|
2843 // Construct tags for XML logging |
|
2844 if (iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth) |
|
2845 { |
|
2846 _LIT(KTimeout,"TIMEOUT"); |
|
2847 _LIT(KProgramName,"PROGRAMNAME"); |
|
2848 _LIT(KServerName,"SERVERNAME"); |
|
2849 _LIT(KStepName,"TESTSTEPNAME"); |
|
2850 _LIT(KIniFile,"INIFILENAME"); |
|
2851 _LIT(KTEFSection,"SECTIONNAME"); |
|
2852 _LIT(KEResult,"EXPECTEDRESULT"); |
|
2853 _LIT(KAResult,"ACTUALRESULT"); |
|
2854 _LIT(KEPanicCode,"EXPECTEDPANICCODE"); |
|
2855 _LIT(KAPanicCode,"PANICCODE"); |
|
2856 _LIT(KEPanicString,"EXPECTEDPANICSTRING"); |
|
2857 _LIT(KAPanicString,"PANICSTRING"); |
|
2858 _LIT(KEErrorCode,"EXPECTEDERRORCODE"); |
|
2859 _LIT(KAErrorCode,"ERRORCODE"); |
|
2860 _LIT(KHeapSize,"HEAPSIZE"); |
|
2861 _LIT(KMaximumHeapSize,"0x100000"); |
|
2862 |
|
2863 TPtrC panicCodeExpected; |
|
2864 TPtrC panicStringExpected; |
|
2865 |
|
2866 TBuf<KMaxTestExecuteCommandLength> taskHeapSize(KMaximumHeapSize); |
|
2867 |
|
2868 TBuf<KMaxTestExecuteCommandLength> fieldName; |
|
2869 TBuf<KMaxTestExecuteCommandLength> fieldValue; |
|
2870 TBuf8<KMaxTestExecuteCommandLength> string1; |
|
2871 TBuf8<KMaxTestExecuteCommandLength> string2; |
|
2872 |
|
2873 TPtrC commandName(xmlLogCommandParseLex.NextToken()); // Collect the command name from current script line |
|
2874 |
|
2875 if(commandName == KTEFRunTestStepResultCommand) |
|
2876 { |
|
2877 // Mark the position to the timeout token within the current script line |
|
2878 xmlLogCommandParseLex.NextToken(); |
|
2879 xmlLogCommandParseLex.SkipSpace(); |
|
2880 xmlLogCommandParseLex.Mark(); |
|
2881 } |
|
2882 |
|
2883 else if(commandName == KTEFRunPanicStepResultCommand) |
|
2884 { |
|
2885 // Mark the position to the timeout token within the current script line |
|
2886 // Also retrieve the expected panic code & strings |
|
2887 panicCodeExpected.Set(xmlLogCommandParseLex.NextToken()); |
|
2888 panicStringExpected.Set(xmlLogCommandParseLex.NextToken()); |
|
2889 xmlLogCommandParseLex.SkipSpace(); |
|
2890 xmlLogCommandParseLex.Mark(); |
|
2891 } |
|
2892 else if(commandName == KTEFRunTestStepCommand || commandName == KTEFEndTestBlock || commandName == KTEFStartTestBlock ) |
|
2893 { |
|
2894 // Mark the position to the timeout token within the current script line |
|
2895 // The !TEF parameters are to be neglected if there are any |
|
2896 TInt firstChar; |
|
2897 TPtrC commandStr; |
|
2898 |
|
2899 while(!xmlLogCommandParseLex.Eos()) |
|
2900 { |
|
2901 xmlLogCommandParseLex.SkipSpace(); |
|
2902 xmlLogCommandParseLex.Mark(); |
|
2903 commandStr.Set(xmlLogCommandParseLex.NextToken()); |
|
2904 if( commandStr.Length()>0 ) |
|
2905 { |
|
2906 firstChar = commandStr[0]; |
|
2907 // 33 is the ascii value for "!". Used here for confirming switches |
|
2908 if (firstChar != KTEFAsciiExclamation) |
|
2909 { |
|
2910 break; |
|
2911 } |
|
2912 else |
|
2913 { |
|
2914 if (commandStr.Length() >= KTEFMinHeapParamLength && commandStr.Mid(0,KTEFMinHeapParamLength).CompareF(KTEFHeap) == KTEFZeroValue) |
|
2915 taskHeapSize.Copy(commandStr.Mid(KTEFMinHeapParamLength)); |
|
2916 } |
|
2917 } |
|
2918 else |
|
2919 { |
|
2920 break; |
|
2921 } |
|
2922 } |
|
2923 } |
|
2924 |
|
2925 TLex lexTimeout; |
|
2926 // We need to skip the timeout if it's there. |
|
2927 if(commandName == KTEFRunTestStepCommand || commandName == KTEFStartTestBlock) |
|
2928 lexTimeout=xmlLogCommandParseLex.MarkedToken(); |
|
2929 else |
|
2930 lexTimeout=xmlLogCommandParseLex.NextToken(); |
|
2931 TInt timeout; |
|
2932 TPtrC serverName; |
|
2933 |
|
2934 // Extract the timeout value and server name |
|
2935 if(lexTimeout.Val(timeout) != KErrNone) |
|
2936 { |
|
2937 if (commandName == KTEFRunProgramCommand) |
|
2938 { |
|
2939 serverName.Set(lexTimeout.NextToken()); |
|
2940 } |
|
2941 else |
|
2942 { |
|
2943 // No timeout so use the second token |
|
2944 serverName.Set(xmlLogCommandParseLex.MarkedToken()); |
|
2945 } |
|
2946 const TInt KDefaultTimeoutSeconds=120; |
|
2947 timeout=KDefaultTimeoutSeconds; |
|
2948 } |
|
2949 else |
|
2950 { |
|
2951 // Timeout value there |
|
2952 serverName.Set(xmlLogCommandParseLex.NextToken()); |
|
2953 } |
|
2954 |
|
2955 TBuf<KMaxTestExecuteCommandLength> timeoutString; |
|
2956 timeoutString.AppendNum(timeout); // Convert the integral timeout to its equivalent string |
|
2957 TPtrC stepName; |
|
2958 if( commandName != KTEFStartTestBlock && commandName != KTEFEndTestBlock ) |
|
2959 { |
|
2960 stepName.Set( xmlLogCommandParseLex.NextToken() ); // Extract the step name |
|
2961 } |
|
2962 TPtrC iniName(xmlLogCommandParseLex.NextToken()); // Extract the ini file name |
|
2963 TPtrC sectionName(xmlLogCommandParseLex.NextToken()); // Extract the section name |
|
2964 |
|
2965 TExtraLogField logField[15]; |
|
2966 TInt index = 0; |
|
2967 |
|
2968 if( commandName != KTEFEndTestBlock ) |
|
2969 { |
|
2970 logField[index].iLogFieldName.Copy(KTimeout); |
|
2971 logField[index].iLogFieldValue.Copy(timeoutString); |
|
2972 index++; |
|
2973 } |
|
2974 |
|
2975 if(commandName == KTEFRunProgramCommand || commandName == KTEFRunWSProgramCommand) |
|
2976 { |
|
2977 logField[index].iLogFieldName.Copy(KProgramName); |
|
2978 logField[index].iLogFieldValue.Copy(serverName); |
|
2979 index++; |
|
2980 } |
|
2981 else if( commandName != KTEFEndTestBlock ) |
|
2982 { |
|
2983 logField[index].iLogFieldName.Copy(KServerName); |
|
2984 logField[index].iLogFieldValue.Copy(serverName); |
|
2985 index++; |
|
2986 } |
|
2987 |
|
2988 if (commandName != KTEFRunProgramCommand && commandName != KTEFRunWSProgramCommand && |
|
2989 commandName != KTEFEndTestBlock && commandName != KTEFStartTestBlock ) |
|
2990 { |
|
2991 logField[index].iLogFieldName.Copy(KStepName); |
|
2992 logField[index].iLogFieldValue.Copy(stepName); |
|
2993 index++; |
|
2994 |
|
2995 logField[index].iLogFieldName.Copy(KTEFSection); |
|
2996 logField[index].iLogFieldValue.Copy(sectionName); |
|
2997 index++; |
|
2998 } |
|
2999 |
|
3000 if (commandName != KTEFRunProgramCommand && commandName != KTEFRunWSProgramCommand && |
|
3001 commandName != KTEFEndTestBlock ) |
|
3002 { |
|
3003 logField[index].iLogFieldName.Copy(KIniFile); |
|
3004 logField[index].iLogFieldValue.Copy(iniName); |
|
3005 index++; |
|
3006 } |
|
3007 |
|
3008 if (commandName == KTEFRunTestStepResultCommand) |
|
3009 { |
|
3010 fieldValue.Copy(KNull); |
|
3011 fieldValue.AppendNum(expectedReturnCode); |
|
3012 logField[index].iLogFieldName.Copy(KEResult); |
|
3013 logField[index].iLogFieldValue.Copy(fieldValue); |
|
3014 index++; |
|
3015 |
|
3016 fieldValue.Copy(KNull); |
|
3017 fieldValue.AppendNum(actualResult); |
|
3018 logField[index].iLogFieldName.Copy(KAResult); |
|
3019 logField[index].iLogFieldValue.Copy(fieldValue); |
|
3020 index++; |
|
3021 } |
|
3022 |
|
3023 if (commandName == KTEFRunPanicStepResultCommand || commandName == KTEFEndTestBlock ) |
|
3024 { |
|
3025 if (defaultStr.Length()) // we have indeed panicked |
|
3026 { |
|
3027 fieldValue.Copy(KNull); |
|
3028 fieldValue.AppendNum(expectedPanicCode); |
|
3029 logField[index].iLogFieldName.Copy(KEPanicCode); |
|
3030 logField[index].iLogFieldValue.Copy(fieldValue); |
|
3031 index++; |
|
3032 |
|
3033 fieldValue.Copy(KNull); |
|
3034 fieldValue.AppendNum(actualPanic); |
|
3035 logField[index].iLogFieldName.Copy(KAPanicCode); |
|
3036 logField[index].iLogFieldValue.Copy(fieldValue); |
|
3037 index++; |
|
3038 |
|
3039 if (expectedPanicCode == actualPanic) |
|
3040 { |
|
3041 fieldValue.Copy(expectedPanicStringLex); |
|
3042 logField[index].iLogFieldName.Copy(KEPanicString); |
|
3043 logField[index].iLogFieldValue.Copy(fieldValue); |
|
3044 index++; |
|
3045 |
|
3046 fieldValue.Copy(defaultStr); |
|
3047 logField[index].iLogFieldName.Copy(KAPanicString); |
|
3048 logField[index].iLogFieldValue.Copy(fieldValue); |
|
3049 index++; |
|
3050 } |
|
3051 } |
|
3052 } |
|
3053 |
|
3054 if (commandName == KTEFRunErrorStepResultCommand) |
|
3055 { |
|
3056 if (errorString.Length()) // Error has occured |
|
3057 { |
|
3058 logField[index].iLogFieldName.Copy(KEErrorCode); |
|
3059 logField[index].iLogFieldValue.Copy(tefError); |
|
3060 index++; |
|
3061 |
|
3062 logField[index].iLogFieldName.Copy(KAErrorCode); |
|
3063 logField[index].iLogFieldValue.Copy(errorString); |
|
3064 index++; |
|
3065 } |
|
3066 } |
|
3067 |
|
3068 logField[index].iLogFieldName.Copy(KHeapSize); |
|
3069 logField[index].iLogFieldValue.Copy(taskHeapSize); |
|
3070 index++; |
|
3071 |
|
3072 if ((defaultStr.Length()) && showPanicResult) |
|
3073 { |
|
3074 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3075 logField[index].iLogFieldValue.Copy(KTEFResultPanic); |
|
3076 index++; |
|
3077 |
|
3078 _LIT(KTEFPanicString, "PANICSTRING"); |
|
3079 logField[index].iLogFieldName.Copy(KTEFPanicString); |
|
3080 logField[index].iLogFieldValue.Copy(defaultStr); |
|
3081 index++; |
|
3082 |
|
3083 _LIT(KTEFPanicCode, "PANICCODE"); |
|
3084 logField[index].iLogFieldName.Copy(KTEFPanicCode); |
|
3085 logField[index].iLogFieldValue.AppendNum(aResult); |
|
3086 index++; |
|
3087 } |
|
3088 else if(aResult == EPass) |
|
3089 { |
|
3090 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3091 logField[index].iLogFieldValue.Copy(KTEFResultPass); |
|
3092 index++; |
|
3093 } |
|
3094 else if(aResult == EFail) |
|
3095 { |
|
3096 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3097 logField[index].iLogFieldValue.Copy(KTEFResultFail); |
|
3098 index++; |
|
3099 } |
|
3100 else if(aResult == EAbort || aResult == KErrAbort) |
|
3101 { |
|
3102 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3103 logField[index].iLogFieldValue.Copy(KTEFResultAbort); |
|
3104 index++; |
|
3105 } |
|
3106 else if (aResult == EIgnore) |
|
3107 { |
|
3108 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3109 logField[index].iLogFieldValue.Copy(KTEFResultUnexecuted); |
|
3110 index++; |
|
3111 } |
|
3112 else if(aResult == EInconclusive) |
|
3113 { |
|
3114 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3115 logField[index].iLogFieldValue.Copy(KTEFResultInconclusive); |
|
3116 index++; |
|
3117 } |
|
3118 else |
|
3119 { |
|
3120 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3121 TBuf<KMaxTestExecuteNameLength> fieldValue(KTEFResultUnknown); |
|
3122 fieldValue.Append(KTEFSpaceEquals); |
|
3123 fieldValue.AppendNum(aResult); |
|
3124 logField[index].iLogFieldValue.Copy(fieldValue); |
|
3125 index++; |
|
3126 } |
|
3127 |
|
3128 // Log the commmand name along with field-value pairs |
|
3129 XmlLogger().Log(((TText8*)__FILE__), aScriptLineNumber, RFileFlogger::TLogSeverity(aSeverity), index, logField, KTEFStringFormat, &commandName); |
|
3130 } |
|
3131 } |
|
3132 |
|
3133 /** |
|
3134 * @param aResult - Result of execution of test steps for logging |
|
3135 * @param aPanicString - Reference descriptor containing the panic string if the test step results in a panic |
|
3136 * @param aScriptLineNumber - Line number within the script file where the RUN_TEST_STEP command is available |
|
3137 * @param aCommand - Command name being being executed (RUN_TEST_STEP & variants) |
|
3138 * @param aScriptFile - Name of the script file being used for execution |
|
3139 * @param aSeverity - One of the 4 enum values indicating the severity of the message to be logged |
|
3140 * Responsible for logging results for the RUN_TEST_STEP command/variants |
|
3141 */ |
|
3142 EXPORT_C void CTestExecuteLogger::LogResult(TVerdict aResult, const TDesC& aPanicString, TInt aScriptLineNumber,const TDesC& aCommand,const TDesC& aScriptFile, TInt aSeverity) |
|
3143 { |
|
3144 if((ESerial == iLoggerChannel) || (EBoth == iLoggerChannel )) |
|
3145 { |
|
3146 TRAP_IGNORE( LogResultSerialL(aResult, aPanicString, aScriptLineNumber,aCommand,aScriptFile) ); |
|
3147 } |
|
3148 if( (EFile == iLoggerChannel ) |
|
3149 || (EBoth== iLoggerChannel ) ) |
|
3150 { |
|
3151 TRAP_IGNORE( LogResultFileL(aResult, aPanicString, aScriptLineNumber,aCommand,aScriptFile, aSeverity) ); |
|
3152 } |
|
3153 } |
|
3154 |
|
3155 EXPORT_C TVerdict CTestExecuteLogger::LogBlock( TTEFItemArray* aItemArray, const TInt aScriptLineNumber ) |
|
3156 { |
|
3157 TVerdict result = EPass; |
|
3158 |
|
3159 // HTML specific block logging |
|
3160 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
3161 { |
|
3162 result = LogHTMLBlockL( *aItemArray ); |
|
3163 } |
|
3164 |
|
3165 // XML specific block logging |
|
3166 if (iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth) |
|
3167 { |
|
3168 result = LogXMLBlock( *aItemArray, aScriptLineNumber ); |
|
3169 } |
|
3170 |
|
3171 return result; |
|
3172 } |
|
3173 |
|
3174 TVerdict CTestExecuteLogger::LogHTMLBlockL( const TTEFItemArray& aItemArray ) |
|
3175 { |
|
3176 TVerdict result = EPass; |
|
3177 TInt numCommands = aItemArray.Count(); |
|
3178 |
|
3179 // Iterate through the item array and verify all of the error codes |
|
3180 for( TInt i = 0 ; i<numCommands ; i++ ) |
|
3181 { |
|
3182 TVerdict err = EPass; |
|
3183 // Check the error code is correct |
|
3184 TBuf<KMaxTestExecuteCommandLength*2> blockLine; |
|
3185 |
|
3186 // Log the block command |
|
3187 // Set the correct coolour for the HTML |
|
3188 if( !aItemArray.At(i).iExecuted ) |
|
3189 { |
|
3190 err = EInconclusive; |
|
3191 blockLine += KTEFFontBlue; |
|
3192 } |
|
3193 else if( aItemArray.At(i).iError != aItemArray.At(i).iExpectedError |
|
3194 || aItemArray.At(i).iAsyncError != aItemArray.At(i).iExpectedAsyncError ) |
|
3195 { |
|
3196 err = EFail; |
|
3197 blockLine += KTEFFontRed; |
|
3198 } |
|
3199 else |
|
3200 { |
|
3201 blockLine += KTEFFontGreen; |
|
3202 } |
|
3203 |
|
3204 switch( aItemArray.At(i).iItemType ) |
|
3205 { |
|
3206 case ETEFCreateObject: |
|
3207 { |
|
3208 blockLine += KTEFCreateObject; |
|
3209 blockLine += KTEFSpace; |
|
3210 blockLine += aItemArray.At(i).iObjectType; |
|
3211 blockLine += KTEFSpace; |
|
3212 blockLine += aItemArray.At(i).iSection; |
|
3213 } |
|
3214 break; |
|
3215 case ETEFRestoreObject: |
|
3216 { |
|
3217 blockLine += KTEFRestoreObject; |
|
3218 blockLine += KTEFSpace; |
|
3219 blockLine += aItemArray.At(i).iObjectType; |
|
3220 blockLine += KTEFSpace; |
|
3221 blockLine += aItemArray.At(i).iSection; |
|
3222 } |
|
3223 break; |
|
3224 case ETEFCommand: |
|
3225 { |
|
3226 blockLine += KTEFCommand; |
|
3227 blockLine += KTEFSpace; |
|
3228 blockLine += KTEFError; |
|
3229 blockLine.AppendNum( aItemArray.At(i).iExpectedError ); |
|
3230 blockLine += KTEFSpace; |
|
3231 blockLine += KTEFAsyncError; |
|
3232 blockLine.AppendNum( aItemArray.At(i).iExpectedAsyncError ); |
|
3233 blockLine += KTEFSpace; |
|
3234 blockLine += aItemArray.At(i).iCommand.iObject; |
|
3235 blockLine += KTEFSpace; |
|
3236 blockLine += aItemArray.At(i).iCommand.iFunction; |
|
3237 blockLine += KTEFSpace; |
|
3238 blockLine += aItemArray.At(i).iSection; |
|
3239 } |
|
3240 break; |
|
3241 case ETEFStore: |
|
3242 { |
|
3243 blockLine += KTEFStore; |
|
3244 blockLine += KTEFSpace; |
|
3245 blockLine += aItemArray.At(i).iSection; |
|
3246 } |
|
3247 break; |
|
3248 case ETEFOutstanding: |
|
3249 { |
|
3250 blockLine += KTEFOutstanding; |
|
3251 blockLine += KTEFSpace; |
|
3252 blockLine.AppendNum( aItemArray.At(i).iTime ); |
|
3253 blockLine += KTEFSpace; |
|
3254 blockLine += aItemArray.At(i).iSection; |
|
3255 } |
|
3256 break; |
|
3257 case ETEFDelay: |
|
3258 { |
|
3259 blockLine += KTEFDelay; |
|
3260 blockLine += KTEFSpace; |
|
3261 blockLine.AppendNum( aItemArray.At(i).iTime ); |
|
3262 } |
|
3263 break; |
|
3264 case ETEFAsyncDelay: |
|
3265 { |
|
3266 blockLine += KTEFAsyncDelay; |
|
3267 blockLine += KTEFSpace; |
|
3268 blockLine.AppendNum( aItemArray.At(i).iTime ); |
|
3269 } |
|
3270 break; |
|
3271 case ETEFSharedActiveScheduler: |
|
3272 { |
|
3273 blockLine += KTEFSharedActiveScheduler; |
|
3274 } |
|
3275 break; |
|
3276 case ETEFStoreActiveScheduler: |
|
3277 { |
|
3278 blockLine += KTEFStoreActiveScheduler; |
|
3279 } |
|
3280 break; |
|
3281 |
|
3282 default: |
|
3283 { |
|
3284 blockLine += _L("Bad Command."); |
|
3285 result = EFail; |
|
3286 err = EFail; |
|
3287 } |
|
3288 break; |
|
3289 } |
|
3290 |
|
3291 // Append an extra space for clearer logging. |
|
3292 blockLine += KTEFSpace; |
|
3293 |
|
3294 // Log the block command |
|
3295 if( !aItemArray.At(i).iExecuted ) |
|
3296 { |
|
3297 err = EInconclusive; |
|
3298 // If a command has failed then the overall block has failed |
|
3299 result = EFail; |
|
3300 } |
|
3301 else if( aItemArray.At(i).iError != aItemArray.At(i).iExpectedError |
|
3302 || aItemArray.At(i).iAsyncError != aItemArray.At(i).iExpectedAsyncError ) |
|
3303 { |
|
3304 blockLine += KTEFErrorResult; |
|
3305 blockLine.AppendNum(aItemArray.At(i).iError); |
|
3306 blockLine += KTEFAsyncErrorResult; |
|
3307 blockLine.AppendNum(aItemArray.At(i).iAsyncError); |
|
3308 err = EFail; |
|
3309 // If a command has failed then the overall block has failed |
|
3310 result = EFail; |
|
3311 } |
|
3312 |
|
3313 // Append the result |
|
3314 blockLine += KTEFSpace; |
|
3315 blockLine += KTEFResultTag; |
|
3316 blockLine += KTEFSpace; |
|
3317 blockLine += KTEFEquals; |
|
3318 blockLine += KTEFSpace; |
|
3319 if( EPass == err ) |
|
3320 { |
|
3321 blockLine += KTEFResultPass; |
|
3322 } |
|
3323 else if( EFail == err ) |
|
3324 { |
|
3325 blockLine += KTEFResultFail; |
|
3326 } |
|
3327 else |
|
3328 { |
|
3329 blockLine += KTEFResultInconclusive; |
|
3330 } |
|
3331 |
|
3332 // Terminate the html line |
|
3333 blockLine += KTEFSpace; |
|
3334 blockLine += KTEFFontEnd; |
|
3335 |
|
3336 HBufC8* resultBuffer8 = HBufC8::NewLC(blockLine.Length()+2); |
|
3337 TPtr8 ptr8(resultBuffer8->Des()); |
|
3338 ptr8.Copy(blockLine); |
|
3339 |
|
3340 // Write to the log file |
|
3341 HtmlLogger().Write(ptr8); |
|
3342 if(iPIPSExists) |
|
3343 { |
|
3344 PIPSLogger().Write(ptr8); |
|
3345 } |
|
3346 CleanupStack::PopAndDestroy(resultBuffer8); |
|
3347 } |
|
3348 |
|
3349 return result; |
|
3350 } |
|
3351 |
|
3352 TVerdict CTestExecuteLogger::LogXMLBlock( const TTEFItemArray& aItemArray, const TInt aScriptLineNumber ) |
|
3353 { |
|
3354 TVerdict result = EPass; |
|
3355 TInt numCommands = aItemArray.Count(); |
|
3356 |
|
3357 for( TInt i = 0 ; i<numCommands ; i++ ) |
|
3358 { |
|
3359 TInt index = 0; |
|
3360 TExtraLogField logField[8]; |
|
3361 TBuf<KTEFMaxNameLength> command; |
|
3362 |
|
3363 switch( aItemArray.At(i).iItemType ) |
|
3364 { |
|
3365 case ETEFCreateObject: |
|
3366 { |
|
3367 command = KTEFCreateObject; |
|
3368 logField[index].iLogFieldName.Copy(KObjectType); |
|
3369 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iObjectType); |
|
3370 index++; |
|
3371 logField[index].iLogFieldName.Copy(KObjectSection); |
|
3372 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iSection); |
|
3373 index++; |
|
3374 } |
|
3375 break; |
|
3376 case ETEFRestoreObject: |
|
3377 { |
|
3378 command = KTEFRestoreObject; |
|
3379 logField[index].iLogFieldName.Copy(KObjectType); |
|
3380 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iObjectType); |
|
3381 index++; |
|
3382 logField[index].iLogFieldName.Copy(KObjectSection); |
|
3383 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iSection); |
|
3384 index++; |
|
3385 } |
|
3386 break; |
|
3387 case ETEFCommand: |
|
3388 { |
|
3389 command = KTEFCommand; |
|
3390 logField[index].iLogFieldName.Copy(KEErrorCode); |
|
3391 logField[index].iLogFieldValue.AppendNum(aItemArray.At(i).iExpectedError); |
|
3392 index++; |
|
3393 logField[index].iLogFieldName.Copy(KEAsyncErrorCode); |
|
3394 logField[index].iLogFieldValue.AppendNum(aItemArray.At(i).iExpectedAsyncError); |
|
3395 index++; |
|
3396 logField[index].iLogFieldName.Copy(KErrorCode); |
|
3397 logField[index].iLogFieldValue.AppendNum(aItemArray.At(i).iError); |
|
3398 index++; |
|
3399 logField[index].iLogFieldName.Copy(KAsyncErrorCode); |
|
3400 logField[index].iLogFieldValue.AppendNum(aItemArray.At(i).iAsyncError); |
|
3401 index++; |
|
3402 logField[index].iLogFieldName.Copy(KObjectSection); |
|
3403 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iCommand.iObject); |
|
3404 index++; |
|
3405 logField[index].iLogFieldName.Copy(KFunctionName); |
|
3406 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iCommand.iFunction); |
|
3407 index++; |
|
3408 logField[index].iLogFieldName.Copy(KSection); |
|
3409 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iSection); |
|
3410 index++; |
|
3411 } |
|
3412 break; |
|
3413 case ETEFStore: |
|
3414 { |
|
3415 command = KTEFStore; |
|
3416 logField[index].iLogFieldName.Copy(KObjectSection); |
|
3417 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iSection); |
|
3418 index++; |
|
3419 } |
|
3420 break; |
|
3421 case ETEFOutstanding: |
|
3422 { |
|
3423 command = KTEFOutstanding; |
|
3424 logField[index].iLogFieldName.Copy(KInterval); |
|
3425 logField[index].iLogFieldValue.AppendNum(aItemArray.At(i).iTime); |
|
3426 index++; |
|
3427 logField[index].iLogFieldName.Copy(KSection); |
|
3428 logField[index].iLogFieldValue.Copy(aItemArray.At(i).iSection); |
|
3429 index++; |
|
3430 } |
|
3431 break; |
|
3432 case ETEFDelay: |
|
3433 { |
|
3434 command = KTEFDelay; |
|
3435 logField[index].iLogFieldName.Copy(KDelay); |
|
3436 logField[index].iLogFieldValue.AppendNum(aItemArray.At(i).iTime); |
|
3437 index++; |
|
3438 } |
|
3439 break; |
|
3440 case ETEFAsyncDelay: |
|
3441 { |
|
3442 command = KTEFAsyncDelay; |
|
3443 logField[index].iLogFieldName.Copy(KDelay); |
|
3444 logField[index].iLogFieldValue.AppendNum(aItemArray.At(i).iTime); |
|
3445 index++; |
|
3446 } |
|
3447 break; |
|
3448 default: |
|
3449 { |
|
3450 command = KBadCommand; |
|
3451 } |
|
3452 break; |
|
3453 } |
|
3454 |
|
3455 // Set the correct result for the XML |
|
3456 if( !aItemArray.At(i).iExecuted ) |
|
3457 { |
|
3458 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3459 logField[index].iLogFieldValue.Copy(KTEFResultInconclusive); |
|
3460 index++; |
|
3461 // If a command has failed then the overall block has failed |
|
3462 result = EFail; |
|
3463 } |
|
3464 else if( aItemArray.At(i).iError != aItemArray.At(i).iExpectedError |
|
3465 || aItemArray.At(i).iAsyncError != aItemArray.At(i).iExpectedAsyncError ) |
|
3466 { |
|
3467 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3468 logField[index].iLogFieldValue.Copy(KTEFResultFail); |
|
3469 index++; |
|
3470 // If a command has failed then the overall block has failed |
|
3471 result = EFail; |
|
3472 } |
|
3473 else |
|
3474 { |
|
3475 logField[index].iLogFieldName.Copy(KTEFResultString); |
|
3476 logField[index].iLogFieldValue.Copy(KTEFResultPass); |
|
3477 index++; |
|
3478 } |
|
3479 |
|
3480 // Call the Xml log client interface for logging into xml log |
|
3481 // Log the commmand name along with field-value pairs |
|
3482 XmlLogger().Log(((TText8*)__FILE__), aScriptLineNumber, RFileFlogger::ESevrHigh, index, logField, KTEFStringFormat, &command); |
|
3483 } |
|
3484 |
|
3485 return result; |
|
3486 } |
|
3487 |
|
3488 /** |
|
3489 * @param aLogMode - Integer descriptor containing either of the 3 enum values |
|
3490 * ELogHTMLOnly(0)/ELogXMLOnly(1)/ELogBoth(2) |
|
3491 * Responsible for setting the logger options for the logger object based on user request |
|
3492 */ |
|
3493 EXPORT_C void CTestExecuteLogger::SetLoggerOptions(TInt aLogMode) |
|
3494 { |
|
3495 iLoggerOptions = TLoggerOptions(aLogMode); |
|
3496 } |
|
3497 |
|
3498 /** |
|
3499 * @param aLogChannel - Integer descriptor containing either of the 3 enum values |
|
3500 * Responsible for setting the logger Channel |
|
3501 */ |
|
3502 EXPORT_C void CTestExecuteLogger::SetLoggerChannel(TInt aLogChannel) |
|
3503 { |
|
3504 iLoggerChannel = aLogChannel ; |
|
3505 } |
|
3506 |
|
3507 /** |
|
3508 * @return - System wide errors |
|
3509 * Connects to the HTML & XML logger client sessions |
|
3510 */ |
|
3511 EXPORT_C TInt CTestExecuteLogger::Connect() |
|
3512 { |
|
3513 TInt err = KErrNone; |
|
3514 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
3515 { |
|
3516 // Call the Html log client interface for logging into html log |
|
3517 err = HtmlLogger().Connect(); |
|
3518 } |
|
3519 |
|
3520 if ((iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth) && err == KErrNone) |
|
3521 { |
|
3522 err = XmlLogger().Connect(); |
|
3523 } |
|
3524 |
|
3525 //TRAPD(errPIP, PIPSLogger().Connect()) ; |
|
3526 TInt errPIP = PIPSLogger().Connect() ; |
|
3527 iPIPSExists = (errPIP == KErrNone)? true : false ; |
|
3528 |
|
3529 return err; |
|
3530 } |
|
3531 |
|
3532 /** |
|
3533 * Closes the connection with HTML & XML logger client sessions |
|
3534 */ |
|
3535 EXPORT_C void CTestExecuteLogger::Close() |
|
3536 { |
|
3537 |
|
3538 if(iLoggerChannel == ESerial || iLoggerChannel == EBoth) |
|
3539 { |
|
3540 //iSerialWriter->UnlockResources(); |
|
3541 delete iSerialWriter; |
|
3542 iSerialWriter = NULL; |
|
3543 } |
|
3544 if (iLoggerOptions == ELogHTMLOnly || iLoggerOptions == ELogBoth) |
|
3545 { |
|
3546 // defect 116046 |
|
3547 THandleInfo info; |
|
3548 HtmlLogger().HandleInfo(&info); |
|
3549 if (0 != info.iNumOpenInThread) |
|
3550 { |
|
3551 HtmlLogger().Close(); |
|
3552 } |
|
3553 // END defect 116046 |
|
3554 } |
|
3555 if (iLoggerOptions == ELogXMLOnly || iLoggerOptions == ELogBoth) |
|
3556 { |
|
3557 XmlLogger().Close(); |
|
3558 } |
|
3559 if(iPIPSExists) |
|
3560 { |
|
3561 PIPSLogger().Close(); |
|
3562 } |
|
3563 } |
|
3564 |
|
3565 /** |
|
3566 * Two phase Construction |
|
3567 */ |
|
3568 EXPORT_C CTestExecuteLogger* CTestExecuteLogger::NewL(TLoggerOptions aLogOptions) |
|
3569 { |
|
3570 CTestExecuteLogger* self = CTestExecuteLogger::NewLC(aLogOptions); |
|
3571 CleanupStack::Pop(); |
|
3572 return self; |
|
3573 } |
|
3574 |
|
3575 /** |
|
3576 * Two phase Construction |
|
3577 */ |
|
3578 EXPORT_C CTestExecuteLogger* CTestExecuteLogger::NewLC(TLoggerOptions aLogOptions) |
|
3579 { |
|
3580 CTestExecuteLogger* self = new(ELeave) CTestExecuteLogger(aLogOptions); |
|
3581 CleanupStack::PushL(self); |
|
3582 //self->ConstructL(); //if in future the contructor is expected to do anything. |
|
3583 return self; |
|
3584 } |
|
3585 |
|
3586 ////////////////////////////////////////////////////// |
|
3587 // Methods implementation for CTestExecuteIniData used |
|
3588 // For parsing the testexecute.ini |
|
3589 ////////////////////////////////////////////////////// |
|
3590 |
|
3591 /** |
|
3592 * Constructor |
|
3593 */ |
|
3594 EXPORT_C CTestExecuteIniData::CTestExecuteIniData() : |
|
3595 iHtmlLogPath(KNull), |
|
3596 iXmlLogPath(KNull), |
|
3597 iDefaultScriptDirectory(KNull), |
|
3598 iLogSeverity(RFileFlogger::ESevrAll), |
|
3599 iLoggerOptions(TLoggerOptions(ELogHTMLOnly)), |
|
3600 iJustInTime(KTEFZeroValue), |
|
3601 iRemotePanicDetection(KTEFZeroValue), |
|
3602 iEnableIniAccessLog(KTEFOneValue), |
|
3603 iEnableTestsCountLog(KTEFOneValue), |
|
3604 iEnableSystemStarter(KTEFOneValue), |
|
3605 iLoggerChannel(TLoggerChannels(EFile)), |
|
3606 iPortNumber(KTEFZeroValue), |
|
3607 iDefaultSysDrive(KTEFLegacySysDrive), |
|
3608 iIniSysDriveName(KTEFIniSysDrive) |
|
3609 { |
|
3610 iConfigData = NULL; |
|
3611 } |
|
3612 |
|
3613 /** |
|
3614 * Two phase Construction |
|
3615 */ |
|
3616 EXPORT_C CTestExecuteIniData* CTestExecuteIniData::NewL() |
|
3617 { |
|
3618 CTestExecuteIniData* self = CTestExecuteIniData::NewLC(); |
|
3619 CleanupStack::Pop(); |
|
3620 return self; |
|
3621 } |
|
3622 |
|
3623 /** |
|
3624 * Two phase Construction |
|
3625 */ |
|
3626 EXPORT_C CTestExecuteIniData* CTestExecuteIniData::NewLC() |
|
3627 { |
|
3628 CTestExecuteIniData* self = new(ELeave) CTestExecuteIniData(); |
|
3629 CleanupStack::PushL(self); |
|
3630 self->ConstructL(); |
|
3631 return self; |
|
3632 } |
|
3633 |
|
3634 EXPORT_C CTestExecuteIniData::CTestExecuteIniData(TDriveName& aSysDrive) : |
|
3635 iHtmlLogPath(KNull), |
|
3636 iXmlLogPath(KNull), |
|
3637 iDefaultScriptDirectory(KNull), |
|
3638 iLogSeverity(RFileFlogger::ESevrAll), |
|
3639 iLoggerOptions(TLoggerOptions(ELogHTMLOnly)), |
|
3640 iJustInTime(KTEFZeroValue), |
|
3641 iRemotePanicDetection(KTEFZeroValue), |
|
3642 iEnableIniAccessLog(KTEFOneValue), |
|
3643 iEnableTestsCountLog(KTEFOneValue), |
|
3644 iEnableSystemStarter(KTEFOneValue), |
|
3645 iLoggerChannel(TLoggerChannels(EFile)), |
|
3646 iPortNumber(KTEFZeroValue), |
|
3647 iDefaultSysDrive(aSysDrive), |
|
3648 iIniSysDriveName(KTEFIniSysDrive) |
|
3649 { |
|
3650 iConfigData = NULL; |
|
3651 } |
|
3652 |
|
3653 /** |
|
3654 * Two phase Construction |
|
3655 */ |
|
3656 EXPORT_C CTestExecuteIniData* CTestExecuteIniData::NewL(TDriveName& aSysDrive) |
|
3657 { |
|
3658 CTestExecuteIniData* self = CTestExecuteIniData::NewLC(aSysDrive); |
|
3659 CleanupStack::Pop(); |
|
3660 return self; |
|
3661 } |
|
3662 |
|
3663 /** |
|
3664 * Two phase Construction |
|
3665 */ |
|
3666 EXPORT_C CTestExecuteIniData* CTestExecuteIniData::NewLC(TDriveName& aSysDrive) |
|
3667 { |
|
3668 CTestExecuteIniData* self = new(ELeave) CTestExecuteIniData(aSysDrive); |
|
3669 CleanupStack::PushL(self); |
|
3670 self->ConstructL(); |
|
3671 return self; |
|
3672 } |
|
3673 |
|
3674 /** |
|
3675 * ConstructL |
|
3676 */ |
|
3677 EXPORT_C void CTestExecuteIniData::ConstructL() |
|
3678 { |
|
3679 TBuf<KMaxTestExecuteNameLength> iniDefaultPath(KTEFDefaultPath); |
|
3680 iniDefaultPath.Replace(0, 2, iDefaultSysDrive); |
|
3681 TRAPD(err,iConfigData = CIniData::NewL(iniDefaultPath, iDefaultSysDrive)); |
|
3682 if (err != KErrNone) |
|
3683 { |
|
3684 TRAP(err,iConfigData = CIniData::NewL(KTEFAlternatePath, iDefaultSysDrive)); |
|
3685 if (err != KErrNone) |
|
3686 { |
|
3687 User::Leave(err); |
|
3688 } |
|
3689 } |
|
3690 } |
|
3691 |
|
3692 /** |
|
3693 * Destructor |
|
3694 */ |
|
3695 EXPORT_C CTestExecuteIniData::~CTestExecuteIniData() |
|
3696 { |
|
3697 if (iConfigData != NULL) |
|
3698 { |
|
3699 delete iConfigData; |
|
3700 } |
|
3701 } |
|
3702 |
|
3703 /** |
|
3704 * Extracts the values for all the keys within testexecute.ini |
|
3705 * And stores it into member variables for the class |
|
3706 */ |
|
3707 EXPORT_C void CTestExecuteIniData::ExtractValuesFromIni() |
|
3708 { |
|
3709 TBuf<KMaxTestExecuteNameLength> testExecuteLogPath(KTestExecuteLogPath); |
|
3710 testExecuteLogPath.Replace(0, 2, iDefaultSysDrive); |
|
3711 |
|
3712 if (!iConfigData->FindVar(KTEFSection, KTEFHtmlKey, iHtmlLogPath)) |
|
3713 { |
|
3714 iHtmlLogPath.Set(testExecuteLogPath); |
|
3715 } |
|
3716 if (iHtmlLogPath.Compare(KNull) == 0) |
|
3717 { |
|
3718 iHtmlLogPath.Set(testExecuteLogPath); |
|
3719 } |
|
3720 if (!iConfigData->FindVar(KTEFSection, KTEFXmlKey, iXmlLogPath)) |
|
3721 { |
|
3722 iXmlLogPath.Set(testExecuteLogPath); |
|
3723 } |
|
3724 if (iXmlLogPath.Compare(KNull) == 0) |
|
3725 { |
|
3726 iXmlLogPath.Set(testExecuteLogPath); |
|
3727 } |
|
3728 if (!iConfigData->FindVar(KTEFSection, KTEFDefaultSysDrive, iIniSysDriveName)) |
|
3729 { |
|
3730 iIniSysDriveName.Set(KTEFIniSysDrive); |
|
3731 } |
|
3732 TPtrC stringValue; |
|
3733 if (iConfigData->FindVar(KTEFSection, KTEFDefaultScriptPath,stringValue)) |
|
3734 { |
|
3735 iDefaultScriptDirectory.Set(stringValue); |
|
3736 } |
|
3737 TInt intValue = KTEFZeroValue; |
|
3738 if (iConfigData->FindVar(KTEFSection, KTEFJustInTimeDebug,intValue)) |
|
3739 { |
|
3740 iJustInTime = intValue; |
|
3741 } |
|
3742 intValue = KTEFZeroValue; |
|
3743 if (iConfigData->FindVar(KTEFSection, KTEFOutputPort,intValue)) |
|
3744 { |
|
3745 iPortNumber = intValue; |
|
3746 } |
|
3747 |
|
3748 if (!iConfigData->FindVar(KTEFSection, KTEFWaitForLoggingTime, iWaitForLoggingTime)) |
|
3749 { |
|
3750 iWaitForLoggingTime = 5; |
|
3751 } |
|
3752 |
|
3753 if(iConfigData->FindVar(KTEFSection, KTEFLogSeverityKey, stringValue)) |
|
3754 { |
|
3755 _LIT(KBasic,"BASIC"); |
|
3756 _LIT(KMedium,"MEDIUM"); |
|
3757 _LIT(KFull,"FULL"); |
|
3758 if (stringValue.CompareF(KBasic) == 0) |
|
3759 iLogSeverity = RFileFlogger::ESevrHigh; |
|
3760 else if (stringValue.CompareF(KMedium) == 0) |
|
3761 iLogSeverity = RFileFlogger::ESevrMedium; |
|
3762 else if (stringValue.CompareF(KFull) == 0) |
|
3763 iLogSeverity = RFileFlogger::ESevrTEFUnit; |
|
3764 else |
|
3765 iLogSeverity = RFileFlogger::ESevrAll; |
|
3766 } |
|
3767 |
|
3768 stringValue.Set(KNull); |
|
3769 if(iConfigData->FindVar(KTEFSection, KTEFLogMode, stringValue)) |
|
3770 { |
|
3771 _LIT(KLogBoth, "BOTH"); |
|
3772 _LIT(KLogXml, "XML"); |
|
3773 if (stringValue.CompareF(KLogBoth) == 0) |
|
3774 iLoggerOptions = TLoggerOptions(ELogBoth); |
|
3775 else if (stringValue.CompareF(KLogXml) == 0) |
|
3776 iLoggerOptions = TLoggerOptions(ELogXMLOnly); |
|
3777 else |
|
3778 iLoggerOptions = TLoggerOptions(ELogHTMLOnly); |
|
3779 } |
|
3780 |
|
3781 stringValue.Set(KNull); |
|
3782 if(iConfigData->FindVar(KTEFSection, KTEFLogChannel, stringValue)) |
|
3783 { |
|
3784 _LIT(KLogFile, "File"); |
|
3785 _LIT(KLogSerial, "Serial"); |
|
3786 if (stringValue.CompareF(KLogFile) == 0) |
|
3787 iLoggerChannel = TLoggerChannels(EFile); |
|
3788 else if (stringValue.CompareF(KLogSerial) == 0) |
|
3789 iLoggerChannel = TLoggerChannels(ESerial); |
|
3790 else |
|
3791 iLoggerChannel = TLoggerChannels(EBoth); |
|
3792 } |
|
3793 |
|
3794 stringValue.Set(KNull); |
|
3795 if (iConfigData->FindVar(KTEFSection, KTEFRemotePanicDetection, stringValue)) |
|
3796 { |
|
3797 _LIT(KPanicDetectionOn,"ON"); |
|
3798 _LIT(KPanicDetectionOne,"1"); |
|
3799 if (stringValue.CompareF(KPanicDetectionOn) == 0 || stringValue.CompareF(KPanicDetectionOne) == 0) |
|
3800 iRemotePanicDetection = 1; |
|
3801 else |
|
3802 iRemotePanicDetection = 0; |
|
3803 } |
|
3804 |
|
3805 stringValue.Set(KNull); |
|
3806 if (iConfigData->FindVar(KTEFSection, KTEFEnableIniAccessLog, stringValue)) |
|
3807 { |
|
3808 _LIT(KEnableIniAccessLogOff,"OFF"); |
|
3809 _LIT(KEnableIniAccessLogZero,"0"); |
|
3810 if (stringValue.CompareF(KEnableIniAccessLogOff) == 0 || stringValue.CompareF(KEnableIniAccessLogZero) == 0) |
|
3811 iEnableIniAccessLog = 0; |
|
3812 else |
|
3813 iEnableIniAccessLog = 1; |
|
3814 } |
|
3815 |
|
3816 stringValue.Set(KNull); |
|
3817 if (iConfigData->FindVar(KTEFSection, KTEFEnableTestsCountLog, stringValue)) |
|
3818 { |
|
3819 _LIT(KEnableTestsCountLogOff,"OFF"); |
|
3820 _LIT(KEnableTestsCountLogZero,"0"); |
|
3821 if (stringValue.CompareF(KEnableTestsCountLogOff) == 0 || stringValue.CompareF(KEnableTestsCountLogZero) == 0) |
|
3822 iEnableTestsCountLog = 0; |
|
3823 else |
|
3824 iEnableTestsCountLog = 1; |
|
3825 } |
|
3826 |
|
3827 stringValue.Set(KNull); |
|
3828 if (iConfigData->FindVar(KTEFSection, KTEFSystemStarter, stringValue)) |
|
3829 { |
|
3830 _LIT(KEnableSystemStarterOff,"OFF"); |
|
3831 _LIT(KEnableSystemStarterZero,"0"); |
|
3832 if (stringValue.CompareF(KEnableSystemStarterOff) == 0 || stringValue.CompareF(KEnableSystemStarterZero) == 0) |
|
3833 iEnableSystemStarter = 0; |
|
3834 else |
|
3835 iEnableSystemStarter = 1; |
|
3836 } |
|
3837 |
|
3838 } |
|
3839 |
|
3840 /** |
|
3841 * @param aKeyName - Reference to string descriptor containing the name of the key within ini |
|
3842 * @param aValue - Reference to string descriptor to store the value for the key in return |
|
3843 * Copies the value for the key name input to the reference aValue string descriptor passed in |
|
3844 */ |
|
3845 EXPORT_C void CTestExecuteIniData::GetKeyValueFromIni(const TDesC& aKeyName, TDes& aValue) |
|
3846 { |
|
3847 if (aKeyName.Compare(KTEFHtmlKey) == 0) |
|
3848 { |
|
3849 aValue.Copy(iHtmlLogPath); |
|
3850 } |
|
3851 else if (aKeyName.Compare(KTEFXmlKey) == 0) |
|
3852 { |
|
3853 aValue.Copy(iXmlLogPath); |
|
3854 } |
|
3855 else if (aKeyName.Compare(KTEFDefaultScriptPath) == 0) |
|
3856 { |
|
3857 aValue.Copy(iDefaultScriptDirectory); |
|
3858 } |
|
3859 else if (aKeyName.Compare(KTEFDefaultSysDrive) == 0) |
|
3860 { |
|
3861 aValue.Copy(iIniSysDriveName); |
|
3862 } |
|
3863 else |
|
3864 { |
|
3865 aValue.Copy(KNull); |
|
3866 } |
|
3867 } |
|
3868 |
|
3869 /** |
|
3870 * @param aKeyName - Reference to string descriptor containing the name of the key within ini |
|
3871 * @param aValue - Reference to integer descriptor to store the value for the key in return |
|
3872 * Copies the value for the key name input to the reference aValue integer descriptor passed in |
|
3873 */ |
|
3874 EXPORT_C void CTestExecuteIniData::GetKeyValueFromIni(const TDesC& aKeyName, TInt& aValue) |
|
3875 { |
|
3876 if (aKeyName.Compare(KTEFLogSeverityKey) == 0) |
|
3877 { |
|
3878 aValue = iLogSeverity; |
|
3879 } |
|
3880 else if (aKeyName.Compare(KTEFLogMode) == 0) |
|
3881 { |
|
3882 aValue = iLoggerOptions; |
|
3883 } |
|
3884 else if (aKeyName.Compare(KTEFLogChannel) == 0) |
|
3885 { |
|
3886 aValue = iLoggerChannel; |
|
3887 } |
|
3888 else if (aKeyName.Compare(KTEFOutputPort) == 0) |
|
3889 { |
|
3890 aValue = iPortNumber; |
|
3891 } |
|
3892 else if (aKeyName.Compare(KTEFJustInTimeDebug) == 0) |
|
3893 { |
|
3894 aValue = iJustInTime; |
|
3895 } |
|
3896 else if (aKeyName.Compare(KTEFRemotePanicDetection) == 0) |
|
3897 { |
|
3898 aValue = iRemotePanicDetection; |
|
3899 } |
|
3900 else if (aKeyName.Compare(KTEFEnableIniAccessLog) == 0) |
|
3901 { |
|
3902 aValue = iEnableIniAccessLog; |
|
3903 } |
|
3904 else if (aKeyName.Compare(KTEFEnableTestsCountLog) == 0) |
|
3905 { |
|
3906 aValue = iEnableTestsCountLog; |
|
3907 } |
|
3908 else if (aKeyName.Compare(KTEFSystemStarter) == 0) |
|
3909 { |
|
3910 aValue = iEnableSystemStarter; |
|
3911 } |
|
3912 else if (aKeyName.CompareF(KTEFWaitForLoggingTime) == 0) |
|
3913 { |
|
3914 aValue = iWaitForLoggingTime; |
|
3915 } |
|
3916 else |
|
3917 { |
|
3918 aValue = KTEFZeroValue; |
|
3919 } |
|
3920 } |
|
3921 |
|
3922 /** |
|
3923 * @param aCommandStr - Current script command line, this string started form !PanicString. |
|
3924 * @param aScriptLineParamLex - Current script line Lexer. This parameter will be used when exit this function, |
|
3925 * so aScriptLineParamLex must moved to the next parameter. |
|
3926 * @param aTEFPanicString - The parse result . return the string in after !PanicString= . |
|
3927 * EX1: !PanicString=STRING restult is:STRING, return ETrue |
|
3928 * EX2: !PanicString="STRING" restult is:STRING, return ETrue |
|
3929 * EX3: !PanicString="STRING panic" restult is:STRING panic, return ETrue |
|
3930 * EX4: !PanicString=STRING panic restult is:STRING, return EFalse |
|
3931 * EX5: !PanicString="STRING panic restult is:STRING panic, return EFalse |
|
3932 * @return - parse result of the funtion. |
|
3933 * protected: |
|
3934 * This fuction is being added for DEF120600. |
|
3935 */ |
|
3936 TBool CTestExecuteLogger::ParsePaincStringFromScriptCommandLine(const TDesC& aCommandStr,TLex& aScriptLineParamLex,TDes& aTEFPanicString) |
|
3937 { |
|
3938 TInt err(0); |
|
3939 TBool panicStringCompleted(ETrue);// if the string are complexed within "" or just one word, this flag will be ture |
|
3940 TRAP(err,aTEFPanicString.Copy(aCommandStr.Mid(KTEFMinPanicStringParamLength))); |
|
3941 if (err) |
|
3942 { |
|
3943 aTEFPanicString.Copy(KNull); |
|
3944 panicStringCompleted = EFalse; |
|
3945 } |
|
3946 else |
|
3947 { |
|
3948 if (aTEFPanicString.Left(1) == KTEFOpenQuotes) |
|
3949 { |
|
3950 panicStringCompleted = EFalse; |
|
3951 if (aTEFPanicString.Right(1) != KTEFOpenQuotes) |
|
3952 { |
|
3953 aTEFPanicString.Copy(aTEFPanicString.Mid(1,aTEFPanicString.Length()-1)); |
|
3954 while(!aScriptLineParamLex.Eos() && !panicStringCompleted) |
|
3955 { |
|
3956 aScriptLineParamLex.Mark(); |
|
3957 TPtrC spaceBegin( aScriptLineParamLex.RemainderFromMark() ); |
|
3958 TPtrC panicStringExt(aScriptLineParamLex.NextToken()); |
|
3959 TInt span = spaceBegin.Find(panicStringExt); |
|
3960 |
|
3961 // append the white space to the end of the expected panic string |
|
3962 if (aTEFPanicString.MaxLength() >= aTEFPanicString.Length() + span ) |
|
3963 { |
|
3964 aTEFPanicString.Append(spaceBegin.Left(span).Ptr(),span);// append write spaces to the panic string |
|
3965 } |
|
3966 else |
|
3967 { |
|
3968 // this string too large |
|
3969 panicStringCompleted = EFalse; |
|
3970 break; |
|
3971 } |
|
3972 if(panicStringExt.Right(1) == KTEFOpenQuotes) |
|
3973 { |
|
3974 aTEFPanicString.Append(panicStringExt.Mid(0, panicStringExt.Length()-1)); |
|
3975 panicStringCompleted = ETrue; |
|
3976 } |
|
3977 else |
|
3978 { |
|
3979 aTEFPanicString.Append(panicStringExt); |
|
3980 } |
|
3981 } |
|
3982 } |
|
3983 else |
|
3984 { |
|
3985 aTEFPanicString.Copy(aTEFPanicString.Mid(1,aTEFPanicString.Length()-2)); |
|
3986 panicStringCompleted = ETrue; |
|
3987 } |
|
3988 } |
|
3989 if (aTEFPanicString.Length()>KTEFMaxPanicStringLength) |
|
3990 { |
|
3991 // warnning panic string too long |
|
3992 LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, KTEFPanicStringTooLong, &KTEFPanicString, &aTEFPanicString ); |
|
3993 LogExtra(((TText8*)__FILE__), __LINE__, ESevrWarn, KTEFPanicStringErrorInfo); |
|
3994 } |
|
3995 } |
|
3996 return panicStringCompleted; |
|
3997 } |