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