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