1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: This module contains implementation of CTestReport |
|
15 * class member functions. |
|
16 * |
|
17 */ |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <e32svr.h> |
|
21 #include <f32file.h> |
|
22 #include <hal.h> |
|
23 #include "TestReport.h" |
|
24 #include "TestEngineCommon.h" |
|
25 #include "Logging.h" |
|
26 |
|
27 // EXTERNAL DATA STRUCTURES |
|
28 // None |
|
29 |
|
30 // EXTERNAL FUNCTION PROTOTYPES |
|
31 // None |
|
32 |
|
33 // CONSTANTS |
|
34 // None |
|
35 |
|
36 // MACROS |
|
37 const TInt KMaxLenEol = 6; |
|
38 const TInt KMaxReportData = 256; |
|
39 typedef TBuf<KMaxReportData> TPrintInfo; |
|
40 const TInt KSummaryLineEndLen = 12; |
|
41 _LIT( KSummaryLineEnd, " "); |
|
42 |
|
43 // XML Tags (alphabetically) |
|
44 _LIT(KXMLCaseNumberTag, "<CaseNumber>"); |
|
45 _LIT(KXMLCaseNumberTagEnd, "</CaseNumber>"); |
|
46 _LIT(KXMLCaseTitleTag, "<Title>"); |
|
47 _LIT(KXMLCaseTitleTagEnd, "</Title>"); |
|
48 _LIT(KXMLConfigFileTag, "<Config>"); |
|
49 _LIT(KXMLConfigFileTagEnd, "</Config>"); |
|
50 _LIT(KXMLCpuSpeedTag, "<CPUSpeed>"); |
|
51 _LIT(KXMLCpuSpeedTagEnd, "</CPUSpeed>"); |
|
52 _LIT(KXMLCpuTag, "<CPU>"); |
|
53 _LIT(KXMLCpuTagEnd, "</CPU>"); |
|
54 _LIT(KXMLCrashedTag, "<Crashed>"); |
|
55 _LIT(KXMLCrashedTagEnd, "</Crashed>"); |
|
56 _LIT(KXMLDateTag, "<Date>"); |
|
57 _LIT(KXMLDateTagEnd, "</Date>"); |
|
58 _LIT(KXMLDllSummaryTag, "<Dlls>"); |
|
59 _LIT(KXMLDllSummaryTagEnd, "</Dlls>"); |
|
60 _LIT(KXMLDllTag, "<Dll>"); |
|
61 _LIT(KXMLDllTagEnd, "</Dll>"); |
|
62 _LIT(KXMLEndTimeTag, "<EndTime>"); |
|
63 _LIT(KXMLEndTimeTagEnd, "</EndTime>"); |
|
64 _LIT(KXMLEnvironmentInfoTag, "<EnvironmentInfo>"); |
|
65 _LIT(KXMLEnvironmentInfoTagEnd, "</EnvironmentInfo>"); |
|
66 _LIT(KXMLExecutionResultTag, "<ExecutionResultCode>"); |
|
67 _LIT(KXMLExecutionResultTagEnd, "</ExecutionResultCode>"); |
|
68 _LIT(KXMLFailedTag, "<Failed>"); |
|
69 _LIT(KXMLFailedTagEnd, "</Failed>"); |
|
70 _LIT(KXMLFileNameTag, "<FileName>"); |
|
71 _LIT(KXMLFileNameTagEnd, "</FileName>"); |
|
72 _LIT(KXMLHardwareInfoTag, "<HardwareInfo>"); |
|
73 _LIT(KXMLHardwareInfoTagEnd, "</HardwareInfo>"); |
|
74 _LIT(KXMLHwRevisionTag, "<HwRevision>"); |
|
75 _LIT(KXMLHwRevisionTagEnd, "</HwRevision>"); |
|
76 _LIT(KXMLLanguageTag, "<Language>"); |
|
77 _LIT(KXMLLanguageTagEnd, "</Language>"); |
|
78 _LIT(KXMLMachineUidTag, "<MachineUID>"); |
|
79 _LIT(KXMLMachineUidTagEnd, "</MachineUID>"); |
|
80 _LIT(KXMLManufacturerTag, "<Manufacturer>"); |
|
81 _LIT(KXMLManufacturerTagEnd, "</Manufacturer>"); |
|
82 _LIT(KXMLMemoryInfoTag, "<MemoryInfo>"); |
|
83 _LIT(KXMLMemoryInfoTagEnd, "</MemoryInfo>"); |
|
84 _LIT(KXMLModelTag, "<Model>"); |
|
85 _LIT(KXMLModelTagEnd, "</Model>"); |
|
86 _LIT(KXMLModuleNameTag, "<ModuleName>"); |
|
87 _LIT(KXMLModuleNameTagEnd, "</ModuleName>"); |
|
88 _LIT(KXMLModuleSummaryTag, "<Modules>"); |
|
89 _LIT(KXMLModuleSummaryTagEnd, "</Modules>"); |
|
90 _LIT(KXMLModuleTag, "<Module>"); |
|
91 _LIT(KXMLModuleTagEnd, "</Module>"); |
|
92 _LIT(KXMLPassedTag, "<Passed>"); |
|
93 _LIT(KXMLPassedTagEnd, "</Passed>"); |
|
94 _LIT(KXMLRamFreeTag, "<RAMFree>"); |
|
95 _LIT(KXMLRamFreeTagEnd, "</RAMFree>"); |
|
96 _LIT(KXMLRamTag, "<RAM>"); |
|
97 _LIT(KXMLRamTagEnd, "</RAM>"); |
|
98 _LIT(KXMLResultDescrTag, "<ResultDescription>"); |
|
99 _LIT(KXMLResultDescrTagEnd, "</ResultDescription>"); |
|
100 _LIT(KXMLResultTag, "<Result>"); |
|
101 _LIT(KXMLResultTagEnd, "</Result>"); |
|
102 _LIT(KXMLSoftwareInfoTag, "<SoftwareInfo>"); |
|
103 _LIT(KXMLSoftwareInfoTagEnd, "</SoftwareInfo>"); |
|
104 _LIT(KXMLStartTimeTag, "<StartTime>"); |
|
105 _LIT(KXMLStartTimeTagEnd, "</StartTime>"); |
|
106 _LIT(KXMLSwBuildTag, "<SwBuild>"); |
|
107 _LIT(KXMLSwBuildTagEnd, "</SwBuild>"); |
|
108 _LIT(KXMLSwRevisionTag, "<SwRevision>"); |
|
109 _LIT(KXMLSwRevisionTagEnd, "</SwRevision>"); |
|
110 _LIT(KXMLTestCasesSummaryTag, "<TestCasesSummary>"); |
|
111 _LIT(KXMLTestCasesSummaryTagEnd, "</TestCasesSummary>"); |
|
112 _LIT(KXMLTestCasesTag, "<TestCases>"); |
|
113 _LIT(KXMLTestCasesTagEnd, "</TestCases>"); |
|
114 _LIT(KXMLTestCaseTag, "<TestCase>"); |
|
115 _LIT(KXMLTestCaseTagEnd, "</TestCase>"); |
|
116 _LIT(KXMLTestReportTag, "<TestReport>"); |
|
117 _LIT(KXMLTestReportTagEnd, "</TestReport>"); |
|
118 _LIT(KXMLTestResultTag, "<ResultCode>"); |
|
119 _LIT(KXMLTestResultTagEnd, "</ResultCode>"); |
|
120 _LIT(KXMLTimeoutedTag, "<Timeout>"); |
|
121 _LIT(KXMLTimeoutedTagEnd, "</Timeout>"); |
|
122 _LIT(KXMLTimeTag, "<Time>"); |
|
123 _LIT(KXMLTimeTagEnd, "</Time>"); |
|
124 _LIT(KXMLTotalTag, "<Total>"); |
|
125 _LIT(KXMLTotalTagEnd, "</Total>"); |
|
126 _LIT(KXMLVersionTag, "<Version>"); |
|
127 _LIT(KXMLVersionTagEnd, "</Version>"); |
|
128 _LIT(KXMLSTIFVersionTag, "<STIFVersion>"); |
|
129 _LIT(KXMLSTIFVersionTagEnd, "</STIFVersion>"); |
|
130 |
|
131 // LOCAL CONSTANTS AND MACROS |
|
132 // None |
|
133 |
|
134 // MODULE DATA STRUCTURES |
|
135 // None |
|
136 |
|
137 // LOCAL FUNCTION PROTOTYPES |
|
138 // None |
|
139 |
|
140 // FORWARD DECLARATIONS |
|
141 // None |
|
142 |
|
143 // ==================== LOCAL FUNCTIONS ======================================= |
|
144 // None |
|
145 |
|
146 // ================= MEMBER FUNCTIONS ========================================= |
|
147 |
|
148 /* |
|
149 ------------------------------------------------------------------------------- |
|
150 |
|
151 Class: CTestReport |
|
152 |
|
153 Method: CTestReport |
|
154 |
|
155 Description: Default constructor |
|
156 |
|
157 C++ default constructor can NOT contain any code, that |
|
158 might leave. |
|
159 |
|
160 Parameters: const TTestReportMode aReportMode: in: Report mode |
|
161 |
|
162 Return Values: None |
|
163 |
|
164 Errors/Exceptions: None |
|
165 |
|
166 Status: Approved |
|
167 |
|
168 ------------------------------------------------------------------------------- |
|
169 */ |
|
170 CTestReport::CTestReport( const TTestReportMode aReportMode ): |
|
171 iReportMode( aReportMode ) |
|
172 { |
|
173 iXML = EFalse; |
|
174 iReportHWInfo = TTestHWInfo(); |
|
175 |
|
176 } |
|
177 |
|
178 /* |
|
179 ------------------------------------------------------------------------------- |
|
180 |
|
181 Class: CTestReport |
|
182 |
|
183 Method: ConstructL |
|
184 |
|
185 Description: Symbian OS second phase constructor |
|
186 |
|
187 Symbian OS default constructor can leave. |
|
188 |
|
189 Parameters: CTestReportSettings& aTestReportSettings: in: Report settings |
|
190 |
|
191 Return Values: None |
|
192 |
|
193 Errors/Exceptions: Leaves if memory allocation for iTotalSummary fails |
|
194 |
|
195 Status: Approved |
|
196 |
|
197 ------------------------------------------------------------------------------- |
|
198 */ |
|
199 void CTestReport::ConstructL( CTestReportSettings& aTestReportSettings ) |
|
200 { |
|
201 // Create summary for all test cases |
|
202 _LIT( KName, "All test cases" ); |
|
203 iTotalSummary = new ( ELeave ) TTestSummary( KName() ); |
|
204 |
|
205 User::LeaveIfError( iFs.Connect() ); |
|
206 |
|
207 TPtrC path; |
|
208 path.Set( aTestReportSettings.iPath->Des() ); |
|
209 TPtrC name; |
|
210 name.Set( aTestReportSettings.iName->Des() ); |
|
211 |
|
212 iFormat = aTestReportSettings.iFormat; |
|
213 iOutput = aTestReportSettings.iOutput; |
|
214 iXML = aTestReportSettings.iXML; |
|
215 |
|
216 // XML format can be used only when report is of txt file type. |
|
217 if(iFormat != CStifLogger::ETxt && iOutput != CStifLogger::EFile && iXML) |
|
218 { |
|
219 RDebug::Print(_L("Stif: XML report is available only when TestReportFormat is TXT and TestReportOutput is FILE")); |
|
220 iXML = EFalse; |
|
221 } |
|
222 |
|
223 if( iOutput == CStifLogger::EFile ) |
|
224 { |
|
225 iFs.MkDirAll( path ); |
|
226 |
|
227 HBufC* pathAndFileBuf = HBufC::NewLC( path.Length() + name.Length() + 5 ); |
|
228 TPtr pathAndFile(pathAndFileBuf->Des() ); |
|
229 pathAndFile.Append( path ); |
|
230 pathAndFile.Append( name ); |
|
231 |
|
232 if(iXML) |
|
233 { |
|
234 pathAndFile.Append( _L(".xml") ); |
|
235 } |
|
236 else |
|
237 { |
|
238 if( ( iFormat == CStifLogger::EHtml ) && |
|
239 ( iOutput == CStifLogger::EFile ) ) |
|
240 { |
|
241 pathAndFile.Append( _L(".html") ); |
|
242 } |
|
243 else |
|
244 { |
|
245 pathAndFile.Append( _L(".txt") ); |
|
246 } |
|
247 } |
|
248 |
|
249 if( aTestReportSettings.iOverwrite ) |
|
250 { |
|
251 User::LeaveIfError( iFile.Replace( iFs, |
|
252 pathAndFile, |
|
253 EFileWrite | EFileStreamText | EFileShareExclusive ) ); |
|
254 } |
|
255 else |
|
256 { |
|
257 TInt fileOpen = iFile.Open( iFs, |
|
258 pathAndFile, |
|
259 EFileWrite | EFileStreamText | EFileShareAny ); |
|
260 if( fileOpen == KErrNotFound ) |
|
261 { |
|
262 User::LeaveIfError( |
|
263 iFile.Create( iFs, |
|
264 pathAndFile, |
|
265 EFileWrite | EFileStreamText | EFileShareExclusive ) ); |
|
266 } |
|
267 else if( fileOpen == KErrNone ) |
|
268 { |
|
269 TInt endPosOfFile = 0; |
|
270 User::LeaveIfError( iFile.Seek( ESeekEnd, endPosOfFile ) ); |
|
271 } |
|
272 else |
|
273 { |
|
274 User::Leave( fileOpen ); |
|
275 } |
|
276 } |
|
277 |
|
278 CleanupStack::PopAndDestroy( pathAndFileBuf ); |
|
279 } |
|
280 |
|
281 WriteHeaderL(); |
|
282 |
|
283 // Add temporarily closing tags to keep valid xml structure |
|
284 CloseXMLTagsInUnfinishedFileL(); |
|
285 } |
|
286 |
|
287 /* |
|
288 ------------------------------------------------------------------------------- |
|
289 |
|
290 Class: CTestReport |
|
291 |
|
292 Method: NewL |
|
293 |
|
294 Description: Two-phased constructor. |
|
295 |
|
296 Parameters: CTestReportSettings& aTestReportSettings: in: Report settings |
|
297 const TTestReportMode aReportMode: in: Report mode |
|
298 |
|
299 Return Values: CTestReport* : pointer to created object |
|
300 |
|
301 Errors/Exceptions: Leaves if memory allocation for object fails |
|
302 Leaves if ConstructL leaves |
|
303 |
|
304 Status: Approved |
|
305 |
|
306 ------------------------------------------------------------------------------- |
|
307 */ |
|
308 CTestReport* CTestReport::NewL( CTestReportSettings& aTestReportSettings, |
|
309 const TTestReportMode aReportMode ) |
|
310 { |
|
311 CTestReport* self = new ( ELeave ) CTestReport( aReportMode ); |
|
312 CleanupStack::PushL( self ); |
|
313 self->ConstructL( aTestReportSettings ); |
|
314 CleanupStack::Pop( self ); |
|
315 return self; |
|
316 |
|
317 } |
|
318 |
|
319 /* |
|
320 ------------------------------------------------------------------------------- |
|
321 |
|
322 Class: CTestReport |
|
323 |
|
324 Method: ~CTestReport |
|
325 |
|
326 Description: Destructor |
|
327 |
|
328 Parameters: None |
|
329 |
|
330 Return Values: None |
|
331 |
|
332 Errors/Exceptions: None |
|
333 |
|
334 Status: Approved |
|
335 |
|
336 ------------------------------------------------------------------------------- |
|
337 */ |
|
338 CTestReport::~CTestReport() |
|
339 { |
|
340 iTestModulesVersionsInfo.ResetAndDestroy(); |
|
341 iTestModulesVersionsInfo.Close(); |
|
342 |
|
343 // Reset and destroy arrays |
|
344 iTestSummaries.ResetAndDestroy(); |
|
345 delete iTotalSummary; |
|
346 if( iOutput != CStifLogger::ERDebug ) |
|
347 { |
|
348 // Delete file |
|
349 iFile.Close(); |
|
350 iFs.Close(); |
|
351 } |
|
352 } |
|
353 |
|
354 /* |
|
355 ------------------------------------------------------------------------------- |
|
356 |
|
357 Class: CTestReport |
|
358 |
|
359 Method: AddTestCaseResultL |
|
360 |
|
361 Description: Add new test case result. |
|
362 |
|
363 Parameters: const TTestInfo& aTestInfo: in: TTestInfo: Test info |
|
364 const TFullTestResult& aTestResult: in: TTestResult: Testresult |
|
365 const TInt aError: in: Symbian OS error: Additional error code |
|
366 |
|
367 Return Values: None |
|
368 |
|
369 Errors/Exceptions: Leave is iReportGenerated is generated |
|
370 Leave if summary creation fails |
|
371 Leave if summary adding fails |
|
372 |
|
373 Status: Approved |
|
374 |
|
375 ------------------------------------------------------------------------------- |
|
376 */ |
|
377 void CTestReport::AddTestCaseResultL( const TTestInfo& aTestInfo, |
|
378 const TFullTestResult& aTestResult, |
|
379 const TInt aError ) |
|
380 { |
|
381 // Create summary for this test case |
|
382 TTestCaseSummary summary; |
|
383 |
|
384 summary.iTestInfo = aTestInfo; |
|
385 summary.iFullTestResult = aTestResult; |
|
386 |
|
387 TBool passed( EFalse ); |
|
388 TBool crashed( EFalse ); |
|
389 TBool timeout( EFalse ); |
|
390 if( ( aError == KErrNone ) && |
|
391 ( summary.iFullTestResult.iCaseExecutionResultType == TFullTestResult::ECaseExecuted ) && |
|
392 ( KErrNone == summary.iFullTestResult.iTestResult.iResult ) ) |
|
393 { |
|
394 passed = ETrue; |
|
395 } |
|
396 else if( summary.iFullTestResult.iCaseExecutionResultType == TFullTestResult::ECaseTimeout ) |
|
397 { |
|
398 timeout = ETrue; |
|
399 } |
|
400 else if( ( summary.iFullTestResult.iCaseExecutionResultCode != KErrNone ) |
|
401 || ( summary.iFullTestResult.iCaseExecutionResultType == TFullTestResult::ECasePanic ) |
|
402 || ( summary.iFullTestResult.iCaseExecutionResultType == TFullTestResult::ECaseException ) ) |
|
403 { |
|
404 crashed = ETrue; |
|
405 } |
|
406 |
|
407 if ( iReportMode & ETestReportCases ) |
|
408 { |
|
409 // Print summary to file |
|
410 if(iXML) |
|
411 { |
|
412 WriteLineL(_L("%S"), &KXMLTestCaseTag); |
|
413 WriteLineL(_L("%S%S%S"), &KXMLModuleNameTag, &summary.iTestInfo.iModuleName, &KXMLModuleNameTagEnd); |
|
414 if(summary.iTestInfo.iConfig != KNullDesC) |
|
415 { |
|
416 WriteLineL(_L("%S%S%S"), &KXMLConfigFileTag, &summary.iTestInfo.iConfig, &KXMLConfigFileTagEnd); |
|
417 } |
|
418 WriteLineL(_L("%S%d%S"), &KXMLCaseNumberTag, summary.iTestInfo.iTestCaseInfo.iCaseNumber, &KXMLCaseNumberTagEnd); |
|
419 WriteLineL(_L("%S%S%S"), &KXMLCaseTitleTag, &summary.iTestInfo.iTestCaseInfo.iTitle, &KXMLCaseTitleTagEnd); |
|
420 } |
|
421 else |
|
422 { |
|
423 WriteLineL( _L("[%S][%S][%d] Title:[%S]"), |
|
424 &summary.iTestInfo.iModuleName, |
|
425 &summary.iTestInfo.iConfig, |
|
426 summary.iTestInfo.iTestCaseInfo.iCaseNumber, |
|
427 &summary.iTestInfo.iTestCaseInfo.iTitle ); |
|
428 } |
|
429 |
|
430 const TInt KTimeFieldLength = 30; |
|
431 TBuf<KTimeFieldLength> startTime; |
|
432 TBuf<KTimeFieldLength> endTime; |
|
433 _LIT(KDateString4,"%-B%:0%J%:1%T%:2%S%.%*C4%:3%+B"); |
|
434 summary.iFullTestResult.iStartTime.FormatL( |
|
435 startTime,KDateString4 ); |
|
436 summary.iFullTestResult.iEndTime.FormatL( |
|
437 endTime,KDateString4 ); |
|
438 |
|
439 // Result description needs max length 0x80(Must be same as |
|
440 // TResultDes length) + specific characters see below. |
|
441 TBuf<KMaxReportData> printBuf2; |
|
442 TInt code = CStifLogger::ENoStyle; |
|
443 if( ( summary.iFullTestResult.iCaseExecutionResultType |
|
444 != TFullTestResult::ECasePanic ) && |
|
445 ( summary.iFullTestResult.iCaseExecutionResultCode |
|
446 == KErrNone ) ) |
|
447 { |
|
448 printBuf2.AppendFormat( _L("\tResult: %d [%S]"), |
|
449 summary.iFullTestResult.iTestResult.iResult, |
|
450 &summary.iFullTestResult.iTestResult.iResultDes ); |
|
451 |
|
452 if ( KErrNone == |
|
453 summary.iFullTestResult.iTestResult.iResult ) |
|
454 { |
|
455 printBuf2.AppendFormat( _L(" ==> PASSED")); |
|
456 } |
|
457 else |
|
458 { |
|
459 code = CStifLogger::ERed; |
|
460 printBuf2.AppendFormat( _L(" ==> FAILED")); |
|
461 } |
|
462 } |
|
463 else |
|
464 { |
|
465 code = CStifLogger::ERed; |
|
466 printBuf2.AppendFormat( _L("\tCaseExecutionResult: %S with %d"), |
|
467 &summary.iFullTestResult.iTestResult.iResultDes, |
|
468 summary.iFullTestResult.iCaseExecutionResultCode ); |
|
469 } |
|
470 |
|
471 if(iXML) |
|
472 { |
|
473 WriteLineL(_L("%S%S%S"), &KXMLStartTimeTag, &startTime, &KXMLStartTimeTagEnd); |
|
474 WriteLineL(_L("%S%S%S"), &KXMLEndTimeTag, &endTime, &KXMLEndTimeTagEnd); |
|
475 WriteLineL(_L("%S%d%S"), &KXMLTestResultTag, summary.iFullTestResult.iTestResult.iResult, &KXMLTestResultTagEnd); |
|
476 WriteLineL(_L("%S%S%S"), &KXMLResultDescrTag, &summary.iFullTestResult.iTestResult.iResultDes, &KXMLResultDescrTagEnd); |
|
477 WriteLineL(_L("%S%d%S"), &KXMLExecutionResultTag, summary.iFullTestResult.iCaseExecutionResultCode, &KXMLExecutionResultTagEnd); |
|
478 } |
|
479 else |
|
480 { |
|
481 WriteLineL( _L("\tStartTime: %S, EndTime: %S"), |
|
482 &startTime, |
|
483 &endTime ); |
|
484 WriteLineL( printBuf2, code ); |
|
485 WriteDelimiterL( _L( "- " ), 10 ); |
|
486 WriteLineL( _L( "" ) ); |
|
487 } |
|
488 } |
|
489 |
|
490 // Add test summary |
|
491 // Check if the module already exists for this test case |
|
492 TTestSummary* moduleSummary = NULL; |
|
493 TInt count = iTestSummaries.Count(); |
|
494 for( TInt i = 0; i < count; i++ ) |
|
495 { |
|
496 if ( iTestSummaries[i]->iName == aTestInfo.iModuleName ) |
|
497 { |
|
498 moduleSummary = iTestSummaries[i]; |
|
499 break; |
|
500 } |
|
501 } |
|
502 |
|
503 if( moduleSummary == NULL ) |
|
504 { |
|
505 // Create new module array |
|
506 moduleSummary = new ( ELeave ) TTestSummary( aTestInfo.iModuleName ); |
|
507 User::LeaveIfError( iTestSummaries.Append( moduleSummary ) ); |
|
508 } |
|
509 |
|
510 if( passed ) |
|
511 { |
|
512 moduleSummary->iPassedCases++; |
|
513 iTotalSummary->iPassedCases++; |
|
514 if(iXML && (iReportMode & ETestReportCases)) |
|
515 { |
|
516 WriteLineL(_L("%SPASSED%S"), &KXMLResultTag, &KXMLResultTagEnd); |
|
517 } |
|
518 } |
|
519 else if( timeout ) |
|
520 { |
|
521 moduleSummary->iTimeoutCases++; |
|
522 iTotalSummary->iTimeoutCases++; |
|
523 if(iXML && (iReportMode & ETestReportCases)) |
|
524 { |
|
525 WriteLineL(_L("%STIMEOUT%S"), &KXMLResultTag, &KXMLResultTagEnd); |
|
526 } |
|
527 } |
|
528 else if( crashed || |
|
529 ( aError != KErrNone ) ) |
|
530 { |
|
531 moduleSummary->iCrashedCases++; |
|
532 iTotalSummary->iCrashedCases++; |
|
533 if(iXML && (iReportMode & ETestReportCases)) |
|
534 { |
|
535 WriteLineL(_L("%SCRASHED%S"), &KXMLResultTag, &KXMLResultTagEnd); |
|
536 } |
|
537 } |
|
538 else |
|
539 { |
|
540 moduleSummary->iFailedCases++; |
|
541 iTotalSummary->iFailedCases++; |
|
542 if(iXML && (iReportMode & ETestReportCases)) |
|
543 { |
|
544 WriteLineL(_L("%SFAILED%S"), &KXMLResultTag, &KXMLResultTagEnd); |
|
545 } |
|
546 } |
|
547 |
|
548 if(iXML && (iReportMode & ETestReportCases)) |
|
549 { |
|
550 WriteLineL(_L("%S"), &KXMLTestCaseTagEnd); |
|
551 } |
|
552 |
|
553 // Add temporarily closing tags to keep valid xml structure |
|
554 CloseXMLTagsInUnfinishedFileL(); |
|
555 } |
|
556 |
|
557 |
|
558 /* |
|
559 ------------------------------------------------------------------------------- |
|
560 |
|
561 Class: CTestReport |
|
562 |
|
563 Method: WriteHeaderL |
|
564 |
|
565 Description: Write test report header. |
|
566 |
|
567 Parameters: None |
|
568 |
|
569 Return Values: None |
|
570 |
|
571 Errors/Exceptions: None |
|
572 |
|
573 Status: Proposal |
|
574 |
|
575 ------------------------------------------------------------------------------- |
|
576 */ |
|
577 void CTestReport::WriteHeaderL() |
|
578 { |
|
579 if( ( iFormat == CStifLogger::EHtml ) && |
|
580 ( iOutput == CStifLogger::EFile ) ) |
|
581 { |
|
582 // Html start tags to whole page and header section |
|
583 iFile.Write( |
|
584 _L8( "\n<html>\n<head>\n<title>TestReport</title>\n</head>\n\n\n<body>\n" ) ); |
|
585 } |
|
586 |
|
587 if(iXML) |
|
588 { |
|
589 WriteLineL(_L("<?xml version=\"1.0\" ?>")); |
|
590 WriteLineL(_L("%S"), &KXMLTestReportTag); |
|
591 } |
|
592 else |
|
593 { |
|
594 WriteDelimiterL( _L( "***" ), 25 ); |
|
595 } |
|
596 |
|
597 // Generate date and time |
|
598 TTime time; |
|
599 time.HomeTime(); |
|
600 TBuf<30> date; |
|
601 TBuf<30> clock; |
|
602 // Date |
|
603 _LIT( KDate, "%E%D%X%N%Y %1 %2 %3" ); |
|
604 time.FormatL( date, KDate ); |
|
605 // Time |
|
606 _LIT( KClock,"%-B%:0%J%:1%T%:2%S%:3%+B" ); |
|
607 time.FormatL( clock,KClock ); |
|
608 // Add date and time |
|
609 if(iXML) |
|
610 { |
|
611 WriteLineL(_L("%S%S%S"), &KXMLDateTag, &date, &KXMLDateTagEnd); |
|
612 WriteLineL(_L("%S%S%S"), &KXMLTimeTag, &clock, &KXMLTimeTagEnd); |
|
613 } |
|
614 else |
|
615 { |
|
616 WriteLineL( _L( "%S" ), &date ); |
|
617 WriteLineL( _L( "%S" ), &clock ); |
|
618 } |
|
619 |
|
620 // Add STIF version info |
|
621 TInt majorV; |
|
622 TInt minorV; |
|
623 TInt buildV; |
|
624 TBuf<30> relDate; |
|
625 TStifUtil::STIFVersion(majorV, minorV, buildV, relDate); |
|
626 if(iXML) |
|
627 { |
|
628 WriteLineL(_L("%S%d.%d.%d (%S)%S"), &KXMLSTIFVersionTag, majorV, minorV, buildV, &relDate, &KXMLSTIFVersionTagEnd); |
|
629 } |
|
630 else |
|
631 { |
|
632 WriteLineL(_L("v.%d.%d.%d (%S)"), majorV, minorV, buildV, &relDate); |
|
633 } |
|
634 |
|
635 if ( iReportMode & ETestReportSummary ) |
|
636 { |
|
637 if( iOutput == CStifLogger::EFile ) |
|
638 { |
|
639 // Get current file position |
|
640 iSummaryPos = 0; |
|
641 User::LeaveIfError( iFile.Seek( ESeekCurrent, iSummaryPos ) ); |
|
642 } |
|
643 // Generate Summary to Report |
|
644 if(iXML) |
|
645 { |
|
646 WriteLineL(_L("%S"), &KXMLTestCasesSummaryTag); |
|
647 WriteLineL(_L("%S%S%S"), &KXMLPassedTag, &KXMLPassedTagEnd, &KSummaryLineEnd); |
|
648 WriteLineL(_L("%S%S%S"), &KXMLFailedTag, &KXMLFailedTagEnd, &KSummaryLineEnd); |
|
649 WriteLineL(_L("%S%S%S"), &KXMLTimeoutedTag, &KXMLTimeoutedTagEnd, &KSummaryLineEnd); |
|
650 WriteLineL(_L("%S%S%S"), &KXMLCrashedTag, &KXMLCrashedTagEnd, &KSummaryLineEnd); |
|
651 WriteLineL(_L("%S%S%S"), &KXMLTotalTag, &KXMLTotalTagEnd, &KSummaryLineEnd); |
|
652 WriteLineL(_L("%S"), &KXMLTestCasesSummaryTagEnd); |
|
653 } |
|
654 else |
|
655 { |
|
656 WriteDelimiterL( _L( "-- " ), 25 ); |
|
657 WriteLineL(_L("SUMMARY:") ); |
|
658 WriteLineL(_L("\tPassed cases: %S"), &KSummaryLineEnd ); |
|
659 WriteLineL(_L("\tFailed cases: %S"), &KSummaryLineEnd ); |
|
660 WriteLineL(_L("\tTimeout cases: %S"), &KSummaryLineEnd ); |
|
661 WriteLineL(_L("\tCrashed cases: %S"), &KSummaryLineEnd ); |
|
662 WriteLineL(_L("\tTotal cases: %S"), &KSummaryLineEnd ); |
|
663 WriteLineL( _L( "" )); |
|
664 } |
|
665 } |
|
666 |
|
667 if ( iReportMode & ETestReportEnvironment ) |
|
668 { |
|
669 const TInt KMegaByte = 1024*1024; |
|
670 if(iXML) |
|
671 { |
|
672 WriteLineL(_L("%S"), &KXMLEnvironmentInfoTag); |
|
673 WriteLineL(_L("%S"), &KXMLHardwareInfoTag); |
|
674 WriteLineL(_L("%S0x%x%S"), &KXMLManufacturerTag, iReportHWInfo.iHwInfo.iManufacturer, &KXMLManufacturerTagEnd); |
|
675 WriteLineL(_L("%S0x%x%S"), &KXMLMachineUidTag, iReportHWInfo.iHwInfo.iMachineUid, &KXMLMachineUidTagEnd); |
|
676 WriteLineL(_L("%S0x%x%S"), &KXMLModelTag, iReportHWInfo.iHwInfo.iModel, &KXMLModelTagEnd); |
|
677 WriteLineL(_L("%S0x%x%S"), &KXMLHwRevisionTag, iReportHWInfo.iHwInfo.iHwRev, &KXMLHwRevisionTagEnd); |
|
678 WriteLineL(_L("%S0x%x%S"), &KXMLCpuTag, iReportHWInfo.iHwInfo.iCpu, &KXMLCpuTagEnd); |
|
679 WriteLineL(_L("%S%d%S"), &KXMLCpuSpeedTag, iReportHWInfo.iHwInfo.iCpuSpeed/1000, &KXMLCpuSpeedTagEnd); |
|
680 WriteLineL(_L("%S%d%S"), &KXMLLanguageTag, iReportHWInfo.iHwInfo.iLanguage, &KXMLLanguageTagEnd); |
|
681 WriteLineL(_L("%S"), &KXMLHardwareInfoTagEnd); |
|
682 WriteLineL(_L("%S"), &KXMLSoftwareInfoTag); |
|
683 WriteLineL(_L("%S0x%x%S"), &KXMLSwRevisionTag, iReportHWInfo.iSwInfo.iSwRev, &KXMLSwRevisionTagEnd); |
|
684 WriteLineL(_L("%S0x%x%S"), &KXMLSwBuildTag, iReportHWInfo.iSwInfo.iSwBuild, &KXMLSwBuildTagEnd); |
|
685 WriteLineL(_L("%S"), &KXMLSoftwareInfoTagEnd); |
|
686 WriteLineL(_L("%S"), &KXMLMemoryInfoTag); |
|
687 WriteLineL(_L("%S%d%S"), &KXMLRamTag, iReportHWInfo.iMemoryInfo.iRAM/KMegaByte, &KXMLRamTagEnd); |
|
688 WriteLineL(_L("%S%d%S"), &KXMLRamFreeTag, iReportHWInfo.iMemoryInfo.iRAMFree/KMegaByte, &KXMLRamFreeTagEnd); |
|
689 WriteLineL(_L("%S"), &KXMLMemoryInfoTagEnd); |
|
690 WriteLineL(_L("%S"), &KXMLEnvironmentInfoTagEnd); |
|
691 } |
|
692 else |
|
693 { |
|
694 // HW Info |
|
695 WriteDelimiterL( _L( "-- " ), 25 ); |
|
696 WriteLineL( _L("ENVIRONMENT INFO:") ); |
|
697 WriteLineL( _L("HW Info:") ); |
|
698 |
|
699 WriteLineL( |
|
700 _L("\tManufacturer: 0x%x, MachineUid: 0x%x, Model: 0x%x "), |
|
701 iReportHWInfo.iHwInfo.iManufacturer, |
|
702 iReportHWInfo.iHwInfo.iMachineUid, |
|
703 iReportHWInfo.iHwInfo.iModel ); |
|
704 WriteLineL( |
|
705 _L("\tHW Rev: 0x%x, CPU: 0x%x, CPU Speed: %d MHz "), |
|
706 iReportHWInfo.iHwInfo.iHwRev, |
|
707 iReportHWInfo.iHwInfo.iCpu, |
|
708 iReportHWInfo.iHwInfo.iCpuSpeed/1000 ); |
|
709 WriteLineL(_L("\tLanguage: %d "), |
|
710 iReportHWInfo.iHwInfo.iLanguage ); |
|
711 |
|
712 // SW Info |
|
713 WriteLineL(_L("SW Info:") ); |
|
714 WriteLineL(_L("\tSW Rev: 0x%x, SW Build: 0x%x"), |
|
715 iReportHWInfo.iSwInfo.iSwRev, |
|
716 iReportHWInfo.iSwInfo.iSwBuild ); |
|
717 |
|
718 // Memory Info |
|
719 WriteLineL(_L("Memory Info:") ); |
|
720 WriteLineL(_L("\tRAM: %d MB, RAM Free: %d MB"), |
|
721 ( iReportHWInfo.iMemoryInfo.iRAM/KMegaByte ), |
|
722 ( iReportHWInfo.iMemoryInfo.iRAMFree/KMegaByte ) ); |
|
723 |
|
724 WriteLineL( _L( "" ) ); |
|
725 } |
|
726 } |
|
727 |
|
728 if ( iReportMode & ETestReportCases ) |
|
729 { |
|
730 if(iXML) |
|
731 { |
|
732 WriteLineL(_L("%S"), &KXMLTestCasesTag); |
|
733 } |
|
734 else |
|
735 { |
|
736 // Generate Test Cases to Report |
|
737 WriteDelimiterL( _L( "-- " ), 25 ); |
|
738 WriteLineL( _L("TESTCASE SUMMARY:") ); |
|
739 } |
|
740 } |
|
741 |
|
742 if ( iReportMode == ETestReportBlank ) |
|
743 { |
|
744 if(!iXML) |
|
745 { |
|
746 WriteLineL( _L( "") ); |
|
747 WriteLineL( _L( "'Empty' configuration given in initialization file's [Engine_Defaults] section" ) ); |
|
748 WriteLineL( _L( "No test report created" ) ); |
|
749 } |
|
750 } |
|
751 } |
|
752 |
|
753 /* |
|
754 ------------------------------------------------------------------------------- |
|
755 |
|
756 Class: CTestReport |
|
757 |
|
758 Method: WriteTrailerL |
|
759 |
|
760 Description: Write test report trailer. |
|
761 |
|
762 Parameters: None |
|
763 |
|
764 Return Values: None |
|
765 |
|
766 Errors/Exceptions: None |
|
767 |
|
768 Status: Proposal |
|
769 |
|
770 ------------------------------------------------------------------------------- |
|
771 */ |
|
772 void CTestReport::WriteTrailerL() |
|
773 { |
|
774 if(iXML && (iReportMode & ETestReportCases)) |
|
775 { |
|
776 WriteLineL(_L("%S"), &KXMLTestCasesTagEnd); |
|
777 } |
|
778 |
|
779 if ( iReportMode & ETestReportSummary ) |
|
780 { |
|
781 if(iXML) |
|
782 { |
|
783 WriteLineL(_L("%S"), &KXMLModuleSummaryTag); |
|
784 } |
|
785 else |
|
786 { |
|
787 WriteDelimiterL( _L( "-- " ), 25 ); |
|
788 WriteLineL(_L("TESTMODULE SUMMARIES:") ); |
|
789 } |
|
790 // Generate module related reports |
|
791 for ( TInt k = 0; k < iTestSummaries.Count(); k++ ) |
|
792 { |
|
793 if(iXML) |
|
794 { |
|
795 WriteLineL(_L("%S"), &KXMLModuleTag); |
|
796 WriteLineL(_L("%S%S%S"), &KXMLModuleNameTag, &iTestSummaries[k]->iName, &KXMLModuleNameTagEnd); |
|
797 WriteLineL(_L("%S%d%S"), &KXMLPassedTag, iTestSummaries[k]->iPassedCases, &KXMLPassedTagEnd); |
|
798 WriteLineL(_L("%S%d%S"), &KXMLFailedTag, iTestSummaries[k]->iFailedCases, &KXMLFailedTagEnd); |
|
799 WriteLineL(_L("%S%d%S"), &KXMLTimeoutedTag, iTestSummaries[k]->iTimeoutCases, &KXMLTimeoutedTagEnd); |
|
800 WriteLineL(_L("%S%d%S"), &KXMLCrashedTag, iTestSummaries[k]->iCrashedCases, &KXMLCrashedTagEnd); |
|
801 WriteLineL(_L("%S%d%S"), &KXMLTotalTag, iTestSummaries[k]->iPassedCases + iTestSummaries[k]->iFailedCases + iTestSummaries[k]->iTimeoutCases + iTestSummaries[k]->iCrashedCases, &KXMLTotalTagEnd); |
|
802 WriteLineL(_L("%S"), &KXMLModuleTagEnd); |
|
803 } |
|
804 else |
|
805 { |
|
806 WriteLineL(_L("Module: [%S]"), |
|
807 &iTestSummaries[k]->iName ); |
|
808 WriteLineL(_L("\tPassed cases: %d"), |
|
809 iTestSummaries[k]->iPassedCases ); |
|
810 WriteLineL(_L("\tFailed cases: %d"), |
|
811 iTestSummaries[k]->iFailedCases ); |
|
812 WriteLineL(_L("\tTimeout cases: %d"), |
|
813 iTestSummaries[k]->iTimeoutCases ); |
|
814 WriteLineL(_L("\tCrashed cases: %d"), |
|
815 iTestSummaries[k]->iCrashedCases ); |
|
816 TInt moduleTotal = iTestSummaries[k]->iPassedCases + |
|
817 iTestSummaries[k]->iFailedCases + |
|
818 iTestSummaries[k]->iTimeoutCases + |
|
819 iTestSummaries[k]->iCrashedCases; |
|
820 WriteLineL(_L("\tTotal cases: %d"), moduleTotal ); |
|
821 WriteLineL( _L( "" ) ); |
|
822 } |
|
823 } |
|
824 |
|
825 if(iXML) |
|
826 { |
|
827 WriteLineL(_L("%S"), &KXMLModuleSummaryTagEnd); |
|
828 } |
|
829 |
|
830 if(iXML) |
|
831 { |
|
832 WriteLineL(_L("%S"), &KXMLDllSummaryTag); |
|
833 } |
|
834 else |
|
835 { |
|
836 WriteDelimiterL(_L( "-- " ), 25 ); |
|
837 WriteLineL(_L("TEST MODULES VERSIONS:")); |
|
838 } |
|
839 |
|
840 // Generate test module versions info |
|
841 for( TInt i = 0; i < iTestModulesVersionsInfo.Count(); i++ ) |
|
842 { |
|
843 TTestModuleVersionInfo* versionInfo = (TTestModuleVersionInfo*)iTestModulesVersionsInfo[i]; |
|
844 if(iXML) |
|
845 { |
|
846 WriteLineL(_L("%S"), &KXMLDllTag); |
|
847 WriteLineL(_L("%S%S%S"), &KXMLFileNameTag, &(versionInfo->iTestModuleName), &KXMLFileNameTagEnd); |
|
848 WriteLineL(_L("%S%d.%d.%d%S"), &KXMLVersionTag, versionInfo->iMajor, versionInfo->iMinor, versionInfo->iBuild, &KXMLVersionTagEnd); |
|
849 WriteLineL(_L("%S"), &KXMLDllTagEnd); |
|
850 } |
|
851 else |
|
852 { |
|
853 WriteLineL(_L("%S %d.%d.%d"), &(versionInfo->iTestModuleName), versionInfo->iMajor, versionInfo->iMinor, versionInfo->iBuild); |
|
854 } |
|
855 } |
|
856 |
|
857 if(iXML) |
|
858 { |
|
859 WriteLineL(_L("%S"), &KXMLDllSummaryTagEnd); |
|
860 } |
|
861 } |
|
862 |
|
863 if(!iXML) |
|
864 { |
|
865 WriteLineL( _L( "" ) ); |
|
866 } |
|
867 |
|
868 if( ( iFormat == CStifLogger::EHtml ) && |
|
869 ( iOutput == CStifLogger::EFile ) ) |
|
870 { |
|
871 // Html start tags to whole page and header section |
|
872 iFile.Write( |
|
873 _L8( "\n\n\n</html>\n</body>\n\n\n" ) ); |
|
874 } |
|
875 |
|
876 if(iXML) |
|
877 { |
|
878 WriteLineL(_L("%S"), &KXMLTestReportTagEnd); |
|
879 } |
|
880 } |
|
881 |
|
882 /* |
|
883 ------------------------------------------------------------------------------- |
|
884 |
|
885 Class: CTestReport |
|
886 |
|
887 Method: UpdateReportSummaryL |
|
888 |
|
889 Description: Updates the test report summary. |
|
890 |
|
891 Parameters: None |
|
892 |
|
893 Return Values: None |
|
894 |
|
895 Errors/Exceptions: None |
|
896 |
|
897 Status: Draft |
|
898 |
|
899 ------------------------------------------------------------------------------- |
|
900 */ |
|
901 void CTestReport::UpdateReportSummaryL() |
|
902 { |
|
903 TInt currentPos = 0; |
|
904 // Add numeric information to summary |
|
905 if ( iReportMode & ETestReportSummary ) |
|
906 { |
|
907 // Go to the summary start position of the file |
|
908 if( iOutput == CStifLogger::EFile ) |
|
909 { |
|
910 User::LeaveIfError(iFile.Seek(ESeekCurrent, currentPos));//Get current position |
|
911 User::LeaveIfError( iFile.Seek( ESeekStart, iSummaryPos ) ); |
|
912 } |
|
913 TBuf<KSummaryLineEndLen> numStr; |
|
914 // Generate Summary to Report |
|
915 if(iXML) |
|
916 { |
|
917 WriteLineL(_L("%S"), &KXMLTestCasesSummaryTag); |
|
918 } |
|
919 else |
|
920 { |
|
921 WriteDelimiterL( _L( "-- " ), 25 ); |
|
922 WriteLineL(_L("SUMMARY:") ); |
|
923 } |
|
924 numStr.Num( iTotalSummary->iPassedCases ); |
|
925 if(iXML) |
|
926 { |
|
927 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
928 WriteLineL(_L("%S%S%S%S"), &KXMLPassedTag, &numStr, &KXMLPassedTagEnd, &spaces); |
|
929 } |
|
930 else |
|
931 { |
|
932 numStr.Append( KSummaryLineEnd().Ptr(), |
|
933 KSummaryLineEnd().Length() - numStr.Length() ); |
|
934 WriteLineL(_L("\tPassed cases: %S"), &numStr ); |
|
935 } |
|
936 |
|
937 numStr.Num( iTotalSummary->iFailedCases ); |
|
938 if(iXML) |
|
939 { |
|
940 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
941 WriteLineL(_L("%S%S%S%S"), &KXMLFailedTag, &numStr, &KXMLFailedTagEnd, &spaces); |
|
942 } |
|
943 else |
|
944 { |
|
945 numStr.Append( KSummaryLineEnd().Ptr(), |
|
946 KSummaryLineEnd().Length() - numStr.Length() ); |
|
947 WriteLineL(_L("\tFailed cases: %S"), &numStr ); |
|
948 } |
|
949 |
|
950 numStr.Num( iTotalSummary->iTimeoutCases ); |
|
951 if(iXML) |
|
952 { |
|
953 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
954 WriteLineL(_L("%S%S%S%S"), &KXMLTimeoutedTag, &numStr, &KXMLTimeoutedTagEnd, &spaces); |
|
955 } |
|
956 else |
|
957 { |
|
958 numStr.Append( KSummaryLineEnd().Ptr(), |
|
959 KSummaryLineEnd().Length() - numStr.Length() ); |
|
960 WriteLineL(_L("\tTimeout cases: %S"), &numStr ); |
|
961 } |
|
962 |
|
963 numStr.Num( iTotalSummary->iCrashedCases ); |
|
964 if(iXML) |
|
965 { |
|
966 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
967 WriteLineL(_L("%S%S%S%S"), &KXMLCrashedTag, &numStr, &KXMLCrashedTagEnd, &spaces); |
|
968 } |
|
969 else |
|
970 { |
|
971 numStr.Append( KSummaryLineEnd().Ptr(), |
|
972 KSummaryLineEnd().Length() - numStr.Length() ); |
|
973 WriteLineL(_L("\tCrashed cases: %S"), &numStr ); |
|
974 } |
|
975 |
|
976 TInt total = iTotalSummary->iPassedCases + |
|
977 iTotalSummary->iFailedCases + |
|
978 iTotalSummary->iTimeoutCases + |
|
979 iTotalSummary->iCrashedCases; |
|
980 numStr.Num( total ); |
|
981 if(iXML) |
|
982 { |
|
983 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
984 WriteLineL(_L("%S%S%S%S"), &KXMLTotalTag, &numStr, &KXMLTotalTagEnd, &spaces); |
|
985 } |
|
986 else |
|
987 { |
|
988 numStr.Append( KSummaryLineEnd().Ptr(), |
|
989 KSummaryLineEnd().Length() - numStr.Length() ); |
|
990 WriteLineL(_L("\tTotal cases: %S"), &numStr ); |
|
991 } |
|
992 |
|
993 if(iXML) |
|
994 { |
|
995 WriteLineL(_L("%S"), &KXMLTestCasesSummaryTagEnd); |
|
996 } |
|
997 |
|
998 if(iOutput == CStifLogger::EFile) |
|
999 { |
|
1000 User::LeaveIfError(iFile.Seek(ESeekStart, currentPos)); |
|
1001 } |
|
1002 } |
|
1003 } |
|
1004 |
|
1005 /* |
|
1006 ------------------------------------------------------------------------------- |
|
1007 |
|
1008 Class: CTestReport |
|
1009 |
|
1010 Method: GenerateReportL |
|
1011 |
|
1012 Description: Generate the test report. |
|
1013 |
|
1014 Parameters: None |
|
1015 |
|
1016 Return Values: None |
|
1017 |
|
1018 Errors/Exceptions: None |
|
1019 |
|
1020 Status: Approved |
|
1021 |
|
1022 ------------------------------------------------------------------------------- |
|
1023 */ |
|
1024 void CTestReport::GenerateReportL() |
|
1025 { |
|
1026 WriteTrailerL(); |
|
1027 |
|
1028 // Add numeric information to summary |
|
1029 if ( iReportMode & ETestReportSummary ) |
|
1030 { |
|
1031 // Go to the summary start position of the file |
|
1032 if( iOutput == CStifLogger::EFile ) |
|
1033 { |
|
1034 User::LeaveIfError( iFile.Seek( ESeekStart, iSummaryPos ) ); |
|
1035 } |
|
1036 TBuf<KSummaryLineEndLen> numStr; |
|
1037 // Generate Summary to Report |
|
1038 if(iXML) |
|
1039 { |
|
1040 WriteLineL(_L("%S"), &KXMLTestCasesSummaryTag); |
|
1041 } |
|
1042 else |
|
1043 { |
|
1044 WriteDelimiterL( _L( "-- " ), 25 ); |
|
1045 WriteLineL(_L("SUMMARY:") ); |
|
1046 } |
|
1047 |
|
1048 numStr.Num( iTotalSummary->iPassedCases ); |
|
1049 if(iXML) |
|
1050 { |
|
1051 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
1052 WriteLineL(_L("%S%S%S%S"), &KXMLPassedTag, &numStr, &KXMLPassedTagEnd, &spaces); |
|
1053 } |
|
1054 else |
|
1055 { |
|
1056 numStr.Append( KSummaryLineEnd().Ptr(), |
|
1057 KSummaryLineEnd().Length() - numStr.Length() ); |
|
1058 WriteLineL(_L("\tPassed cases: %S"), &numStr ); |
|
1059 } |
|
1060 |
|
1061 numStr.Num( iTotalSummary->iFailedCases ); |
|
1062 if(iXML) |
|
1063 { |
|
1064 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
1065 WriteLineL(_L("%S%S%S%S"), &KXMLFailedTag, &numStr, &KXMLFailedTagEnd, &spaces); |
|
1066 } |
|
1067 else |
|
1068 { |
|
1069 numStr.Append( KSummaryLineEnd().Ptr(), |
|
1070 KSummaryLineEnd().Length() - numStr.Length() ); |
|
1071 WriteLineL(_L("\tFailed cases: %S"), &numStr ); |
|
1072 } |
|
1073 |
|
1074 numStr.Num( iTotalSummary->iTimeoutCases ); |
|
1075 if(iXML) |
|
1076 { |
|
1077 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
1078 WriteLineL(_L("%S%S%S%S"), &KXMLTimeoutedTag, &numStr, &KXMLTimeoutedTagEnd, &spaces); |
|
1079 } |
|
1080 else |
|
1081 { |
|
1082 numStr.Append( KSummaryLineEnd().Ptr(), |
|
1083 KSummaryLineEnd().Length() - numStr.Length() ); |
|
1084 WriteLineL(_L("\tTimeout cases: %S"), &numStr ); |
|
1085 } |
|
1086 |
|
1087 numStr.Num( iTotalSummary->iCrashedCases ); |
|
1088 if(iXML) |
|
1089 { |
|
1090 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
1091 WriteLineL(_L("%S%S%S%S"), &KXMLCrashedTag, &numStr, &KXMLCrashedTagEnd, &spaces); |
|
1092 } |
|
1093 else |
|
1094 { |
|
1095 numStr.Append( KSummaryLineEnd().Ptr(), |
|
1096 KSummaryLineEnd().Length() - numStr.Length() ); |
|
1097 WriteLineL(_L("\tCrashed cases: %S"), &numStr ); |
|
1098 } |
|
1099 |
|
1100 TInt total = iTotalSummary->iPassedCases + |
|
1101 iTotalSummary->iFailedCases + |
|
1102 iTotalSummary->iTimeoutCases + |
|
1103 iTotalSummary->iCrashedCases; |
|
1104 numStr.Num( total ); |
|
1105 if(iXML) |
|
1106 { |
|
1107 TPtrC spaces(KSummaryLineEnd().Ptr(), KSummaryLineEnd().Length() - numStr.Length()); |
|
1108 WriteLineL(_L("%S%S%S%S"), &KXMLTotalTag, &numStr, &KXMLTotalTagEnd, &spaces); |
|
1109 } |
|
1110 else |
|
1111 { |
|
1112 numStr.Append( KSummaryLineEnd().Ptr(), |
|
1113 KSummaryLineEnd().Length() - numStr.Length() ); |
|
1114 WriteLineL(_L("\tTotal cases: %S"), &numStr ); |
|
1115 } |
|
1116 |
|
1117 if(iXML) |
|
1118 { |
|
1119 WriteLineL(_L("%S"), &KXMLTestCasesSummaryTagEnd); |
|
1120 } |
|
1121 } |
|
1122 } |
|
1123 |
|
1124 /* |
|
1125 ------------------------------------------------------------------------------- |
|
1126 |
|
1127 Class: CTestReport |
|
1128 |
|
1129 Method: WriteLine |
|
1130 |
|
1131 Description: Write line to file. |
|
1132 |
|
1133 Parameters: TRefByValue<const TDesC> aStr: in: test to print |
|
1134 |
|
1135 Return Values: None |
|
1136 |
|
1137 Errors/Exceptions: None |
|
1138 |
|
1139 Status: Proposal |
|
1140 |
|
1141 ------------------------------------------------------------------------------- |
|
1142 */ |
|
1143 void CTestReport::WriteLineL( TRefByValue<const TDesC> aStr,... ) |
|
1144 { |
|
1145 |
|
1146 VA_LIST list; |
|
1147 VA_START( list, aStr ); |
|
1148 TPrintInfo line; |
|
1149 |
|
1150 // Parse parameters |
|
1151 line.AppendFormatList( aStr, list, NULL ); |
|
1152 |
|
1153 if( iOutput == CStifLogger::ERDebug ) |
|
1154 { |
|
1155 // RDebug output |
|
1156 RDebug::Print( line ); |
|
1157 return; |
|
1158 } |
|
1159 |
|
1160 HBufC8* buf = HBufC8::NewLC( line.Length() + KMaxLenEol ); |
|
1161 TPtr8 ptr( buf->Des() ); |
|
1162 ptr.Copy( line ); |
|
1163 |
|
1164 if( ( iFormat == CStifLogger::EHtml ) && |
|
1165 ( iOutput == CStifLogger::EFile ) ) |
|
1166 { |
|
1167 // Html output, add linefeed |
|
1168 ptr.Append( _L8("<BR>\r\n") ); |
|
1169 } |
|
1170 else |
|
1171 { |
|
1172 // Default: Text format to file |
|
1173 // Add linefeed |
|
1174 ptr.Append( _L8("\r\n") ); |
|
1175 } |
|
1176 |
|
1177 // Write to file |
|
1178 iFile.Write( ptr ); |
|
1179 CleanupStack::PopAndDestroy( buf ); |
|
1180 |
|
1181 } |
|
1182 |
|
1183 /* |
|
1184 ------------------------------------------------------------------------------- |
|
1185 |
|
1186 Class: CTestReport |
|
1187 |
|
1188 Method: WriteDelimiter |
|
1189 |
|
1190 Description: Write delimiter line to file. |
|
1191 |
|
1192 Parameters: const TDesC& aDelimiter: in: delimiter mark |
|
1193 TInt aCount: in: number of delimiters written |
|
1194 |
|
1195 Return Values: None |
|
1196 |
|
1197 Errors/Exceptions: None |
|
1198 |
|
1199 Status: Proposal |
|
1200 |
|
1201 ------------------------------------------------------------------------------- |
|
1202 */ |
|
1203 void CTestReport::WriteDelimiterL( const TDesC& aDelimiter, TInt aCount ) |
|
1204 { |
|
1205 |
|
1206 if( iOutput == CStifLogger::ERDebug ) |
|
1207 { |
|
1208 // RDebug output |
|
1209 // Nothing is printed |
|
1210 return; |
|
1211 } |
|
1212 |
|
1213 HBufC8* buf = HBufC8::NewLC( aDelimiter.Length() ); |
|
1214 TPtr8 ptr( buf->Des() ); |
|
1215 ptr.Copy( aDelimiter ); |
|
1216 |
|
1217 for( TInt i = 0; i<aCount; i++ ) |
|
1218 { |
|
1219 // Write to file |
|
1220 iFile.Write( ptr ); |
|
1221 } |
|
1222 CleanupStack::PopAndDestroy( buf ); |
|
1223 |
|
1224 TBuf8<KMaxLenEol> linefeed; |
|
1225 if( ( iFormat == CStifLogger::EHtml ) && |
|
1226 ( iOutput == CStifLogger::EFile ) ) |
|
1227 { |
|
1228 // Html output, add linefeed |
|
1229 linefeed.Append( _L8("<BR>\r\n") ); |
|
1230 } |
|
1231 else |
|
1232 { |
|
1233 // Default: Text format to file |
|
1234 // Add linefeed |
|
1235 linefeed.Append( _L8("\r\n") ); |
|
1236 } |
|
1237 // Write to file |
|
1238 iFile.Write( linefeed ); |
|
1239 |
|
1240 } |
|
1241 |
|
1242 /* |
|
1243 ------------------------------------------------------------------------------- |
|
1244 |
|
1245 Class: CTestReport |
|
1246 |
|
1247 Method: TTestReportHeader::TTestReportHeader |
|
1248 |
|
1249 Description: Constructor of TTestReportHeader |
|
1250 |
|
1251 Parameters: None |
|
1252 |
|
1253 Return Values: None |
|
1254 |
|
1255 Errors/Exceptions: None |
|
1256 |
|
1257 Status: Approved |
|
1258 |
|
1259 ------------------------------------------------------------------------------- |
|
1260 */ |
|
1261 CTestReport::TTestHWInfo::TTestHWInfo() |
|
1262 { |
|
1263 // Initialize, fills a specified block of data with binary zeroes |
|
1264 Mem::FillZ( this, sizeof( CTestReport::TTestHWInfo ) ); |
|
1265 |
|
1266 // Get HW Info |
|
1267 HAL::Get( HALData::EManufacturer, iHwInfo.iManufacturer ); |
|
1268 HAL::Get( HALData::EMachineUid, iHwInfo.iMachineUid ); |
|
1269 HAL::Get( HALData::EManufacturerHardwareRev, iHwInfo.iHwRev ); |
|
1270 HAL::Get( HALData::EModel, iHwInfo.iModel ); |
|
1271 HAL::Get( HALData::ECPU, iHwInfo.iCpu ); |
|
1272 HAL::Get( HALData::ECPUSpeed, iHwInfo.iCpuSpeed ); |
|
1273 HAL::Get( HALData::ELanguageIndex, iHwInfo.iLanguage ); |
|
1274 |
|
1275 // Get SW Info |
|
1276 HAL::Get( HALData::EManufacturerSoftwareRev, iSwInfo.iSwRev ); |
|
1277 HAL::Get( HALData::EManufacturerSoftwareBuild, iSwInfo.iSwBuild ); |
|
1278 |
|
1279 // Memory Info |
|
1280 HAL::Get( HALData::EMemoryRAM, iMemoryInfo.iRAM ); |
|
1281 HAL::Get( HALData::EMemoryRAMFree, iMemoryInfo.iRAMFree ); |
|
1282 |
|
1283 } |
|
1284 |
|
1285 /* |
|
1286 ------------------------------------------------------------------------------- |
|
1287 |
|
1288 Class: CTestReport |
|
1289 |
|
1290 Method: TTestSummary::TTestSummary |
|
1291 |
|
1292 Description: Constructor of TTestSummary. |
|
1293 |
|
1294 Parameters: const TName& aName: in: Name of summary |
|
1295 |
|
1296 Return Values: None |
|
1297 |
|
1298 Errors/Exceptions: None |
|
1299 |
|
1300 Status: Approved |
|
1301 |
|
1302 ------------------------------------------------------------------------------- |
|
1303 */ |
|
1304 CTestReport::TTestSummary::TTestSummary( const TName& aName ) : |
|
1305 iName( aName ), |
|
1306 iPassedCases( 0 ), |
|
1307 iFailedCases( 0 ), |
|
1308 iCrashedCases( 0 ), |
|
1309 iTimeoutCases( 0 ) |
|
1310 { |
|
1311 |
|
1312 } |
|
1313 |
|
1314 /* |
|
1315 ------------------------------------------------------------------------------- |
|
1316 |
|
1317 Class: CTestReport |
|
1318 |
|
1319 Method: AddTestModuleVersion |
|
1320 |
|
1321 Description: Method adds version of a test module to the list of versions |
|
1322 that will be printed when stif is stopped. |
|
1323 |
|
1324 Parameters: TTestModuleVersionInfo aVersion : object contains information about version and |
|
1325 name of test module. |
|
1326 |
|
1327 Return Values: None |
|
1328 |
|
1329 Errors/Exceptions: None |
|
1330 |
|
1331 ------------------------------------------------------------------------------- |
|
1332 */ |
|
1333 |
|
1334 void CTestReport::AddTestModuleVersion(TTestModuleVersionInfo& aVersion) |
|
1335 { |
|
1336 for(TInt i = 0; i < iTestModulesVersionsInfo.Count(); i++) |
|
1337 { |
|
1338 if( aVersion.iTestModuleName == iTestModulesVersionsInfo[i]->iTestModuleName ) |
|
1339 { |
|
1340 return; |
|
1341 } |
|
1342 } |
|
1343 |
|
1344 TTestModuleVersionInfo* testModuleVersionInfo = new (ELeave) TTestModuleVersionInfo; |
|
1345 testModuleVersionInfo->iMajor = aVersion.iMajor; |
|
1346 testModuleVersionInfo->iMinor = aVersion.iMinor; |
|
1347 testModuleVersionInfo->iBuild = aVersion.iBuild; |
|
1348 testModuleVersionInfo->iTestModuleName = aVersion.iTestModuleName; |
|
1349 |
|
1350 TInt res = iTestModulesVersionsInfo.Append(testModuleVersionInfo); |
|
1351 if( res != KErrNone ) |
|
1352 { |
|
1353 delete testModuleVersionInfo; |
|
1354 } |
|
1355 } |
|
1356 |
|
1357 /* |
|
1358 ------------------------------------------------------------------------------- |
|
1359 |
|
1360 Class: CTestReport |
|
1361 |
|
1362 Method: TTestCaseSummary::TTestCaseSummary |
|
1363 |
|
1364 Description: Constructor of TTestCaseSummary. |
|
1365 |
|
1366 Parameters: None |
|
1367 |
|
1368 Return Values: None |
|
1369 |
|
1370 Errors/Exceptions: None |
|
1371 |
|
1372 Status: Approved |
|
1373 |
|
1374 ------------------------------------------------------------------------------- |
|
1375 */ |
|
1376 CTestReport::TTestCaseSummary::TTestCaseSummary() |
|
1377 { |
|
1378 |
|
1379 } |
|
1380 |
|
1381 /* |
|
1382 ------------------------------------------------------------------------------- |
|
1383 |
|
1384 Class: CTestReport |
|
1385 |
|
1386 Method: CloseXMLTagsInUnfinishedFileL |
|
1387 |
|
1388 Description: Adds needed tags to get valid xml file. |
|
1389 |
|
1390 Parameters: None |
|
1391 |
|
1392 Return Values: None |
|
1393 |
|
1394 Errors/Exceptions: Seek operations may cause leaves |
|
1395 |
|
1396 Status: Approved |
|
1397 |
|
1398 ------------------------------------------------------------------------------- |
|
1399 */ |
|
1400 void CTestReport::CloseXMLTagsInUnfinishedFileL(void) |
|
1401 { |
|
1402 // For xml file keep current position in file. |
|
1403 if(iXML) |
|
1404 { |
|
1405 TInt currentPos = 0; |
|
1406 User::LeaveIfError(iFile.Seek(ESeekCurrent, currentPos)); |
|
1407 |
|
1408 // Add closing tags to get valid xml file |
|
1409 WriteLineL(_L("%S"), &KXMLTestCasesTagEnd); |
|
1410 WriteLineL(_L("%S"), &KXMLTestReportTagEnd); |
|
1411 |
|
1412 // Move back to previous position |
|
1413 User::LeaveIfError(iFile.Seek(ESeekStart, currentPos)); |
|
1414 } |
|
1415 } |
|
1416 |
|
1417 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
1418 |
|
1419 // None |
|
1420 |
|
1421 // End of File |
|