1 | /*! @file ReportsBase.h |
---|
2 | * @brief Reports Base Class Specification |
---|
3 | * |
---|
4 | * This file contains the specification of the Reports methods. This |
---|
5 | * collection of methods is used to generate the various reports of |
---|
6 | * the analysis results. |
---|
7 | */ |
---|
8 | |
---|
9 | #ifndef __REPORTSBASE_H__ |
---|
10 | #define __REPORTSBASE_H__ |
---|
11 | |
---|
12 | #include <stdint.h> |
---|
13 | #include <string> |
---|
14 | #include <time.h> |
---|
15 | #include "DesiredSymbols.h" |
---|
16 | |
---|
17 | namespace Coverage { |
---|
18 | |
---|
19 | /*! |
---|
20 | * This class contains the base information to create a report |
---|
21 | * set. The report set may be text based, html based or some |
---|
22 | * other format to be defined at a future time. |
---|
23 | */ |
---|
24 | class ReportsBase { |
---|
25 | |
---|
26 | public: |
---|
27 | ReportsBase( time_t timestamp ); |
---|
28 | virtual ~ReportsBase(); |
---|
29 | |
---|
30 | /*! |
---|
31 | * This method produces an index of the reports generated. |
---|
32 | * |
---|
33 | * @param[in] fileName identifies the report file name |
---|
34 | */ |
---|
35 | virtual void WriteIndex( |
---|
36 | const char* const fileName |
---|
37 | ); |
---|
38 | |
---|
39 | /*! |
---|
40 | * This method produces an annotated assembly listing report containing |
---|
41 | * the disassembly of each symbol that was not completely covered. |
---|
42 | * |
---|
43 | * @param[in] fileName identifies the annotated report file name |
---|
44 | */ |
---|
45 | void WriteAnnotatedReport( |
---|
46 | const char* const fileName |
---|
47 | ); |
---|
48 | |
---|
49 | /*! |
---|
50 | * This method produces a report that contains information about each |
---|
51 | * uncovered branch statement. |
---|
52 | * |
---|
53 | * @param[in] fileName identifies the branch report file name |
---|
54 | */ |
---|
55 | void WriteBranchReport( |
---|
56 | const char* const fileName |
---|
57 | ); |
---|
58 | |
---|
59 | /*! |
---|
60 | * This method produces a report that contains information about each |
---|
61 | * uncovered range of bytes. |
---|
62 | * |
---|
63 | * @param[in] fileName identifies the coverage report file name |
---|
64 | */ |
---|
65 | void WriteCoverageReport( |
---|
66 | const char* const fileName |
---|
67 | ); |
---|
68 | |
---|
69 | /*! |
---|
70 | * This method produces a summary report that lists each uncovered |
---|
71 | * range of bytes. |
---|
72 | * |
---|
73 | * @param[in] fileName identifies the report file name |
---|
74 | */ |
---|
75 | void WriteSizeReport( |
---|
76 | const char* const fileName |
---|
77 | ); |
---|
78 | |
---|
79 | /*! |
---|
80 | * This method produces a summary report that lists information on |
---|
81 | * each symbol which did not achieve 100% coverage |
---|
82 | * |
---|
83 | * @param[in] fileName identifies the report file name |
---|
84 | */ |
---|
85 | void WriteSymbolSummaryReport( |
---|
86 | const char* const fileName |
---|
87 | ); |
---|
88 | |
---|
89 | /*! |
---|
90 | * This method produces a sumary report for the overall test run. |
---|
91 | */ |
---|
92 | static void WriteSummaryReport( |
---|
93 | const char* const fileName |
---|
94 | ); |
---|
95 | |
---|
96 | /*! |
---|
97 | * This method returns the unique extension for the Report |
---|
98 | * type. If the extension is ".txt" files will be |
---|
99 | * named "annotated.txt", "branch.txt" ...... |
---|
100 | */ |
---|
101 | std::string ReportExtension() { return reportExtension_m; } |
---|
102 | |
---|
103 | protected: |
---|
104 | |
---|
105 | /*! |
---|
106 | * This type is used to track a state during the annotated output. |
---|
107 | */ |
---|
108 | typedef enum { |
---|
109 | A_SOURCE, |
---|
110 | A_EXECUTED, |
---|
111 | A_NEVER_EXECUTED, |
---|
112 | A_BRANCH_TAKEN, |
---|
113 | A_BRANCH_NOT_TAKEN |
---|
114 | } AnnotatedLineState_t; |
---|
115 | |
---|
116 | /*! |
---|
117 | * This member variable contains the extension used for all reports. |
---|
118 | */ |
---|
119 | std::string reportExtension_m; |
---|
120 | |
---|
121 | /*! |
---|
122 | * This member variable contains the timestamp for the report. |
---|
123 | */ |
---|
124 | time_t timestamp_m; |
---|
125 | |
---|
126 | /*! |
---|
127 | * This method Opens a report file and verifies that it opened |
---|
128 | * correctly. Upon failure NULL is returned. |
---|
129 | * |
---|
130 | * @param[in] fileName identifies the report file name |
---|
131 | */ |
---|
132 | static FILE* OpenFile( |
---|
133 | const char* const fileName |
---|
134 | ); |
---|
135 | |
---|
136 | /*! |
---|
137 | * This method opens a report file and verifies that it opened. |
---|
138 | * Then appedns any necessary header information onto the file. |
---|
139 | * |
---|
140 | * @param[in] fileName identifies the report file name |
---|
141 | */ |
---|
142 | virtual FILE* OpenAnnotatedFile( |
---|
143 | const char* const fileName |
---|
144 | ); |
---|
145 | |
---|
146 | /*! |
---|
147 | * This method opens a report file and verifies that it opened. |
---|
148 | * Then appedns any necessary header information onto the file. |
---|
149 | * |
---|
150 | * @param[in] fileName identifies the report file name |
---|
151 | * @param[in] hasBranches indicates if there are branches to report |
---|
152 | */ |
---|
153 | virtual FILE* OpenBranchFile( |
---|
154 | const char* const fileName, |
---|
155 | bool hasBranches |
---|
156 | ); |
---|
157 | |
---|
158 | /*! |
---|
159 | * This method opens a report file and verifies that it opened. |
---|
160 | * Then appedns any necessary header information onto the file. |
---|
161 | * |
---|
162 | * @param[in] fileName identifies the report file name |
---|
163 | */ |
---|
164 | virtual FILE* OpenCoverageFile( |
---|
165 | const char* const fileName |
---|
166 | ); |
---|
167 | |
---|
168 | /*! |
---|
169 | * This method opens a report file and verifies that it opened. |
---|
170 | * Then appends any necessary header information onto the file. |
---|
171 | * |
---|
172 | * @param[in] fileName identifies the report file name |
---|
173 | */ |
---|
174 | virtual FILE* OpenNoRangeFile( |
---|
175 | const char* const fileName |
---|
176 | ); |
---|
177 | |
---|
178 | /*! |
---|
179 | * This method opens a report file and verifies that it opened. |
---|
180 | * Then appedns any necessary header information onto the file. |
---|
181 | * |
---|
182 | * @param[in] fileName identifies the report file name |
---|
183 | */ |
---|
184 | virtual FILE* OpenSizeFile( |
---|
185 | const char* const fileName |
---|
186 | ); |
---|
187 | |
---|
188 | /*! |
---|
189 | * This method opens a report file and verifies that it opened. |
---|
190 | * Then appedns any necessary header information onto the file. |
---|
191 | * |
---|
192 | * @param[in] fileName identifies the report file name |
---|
193 | */ |
---|
194 | virtual FILE* OpenSymbolSummaryFile( |
---|
195 | const char* const fileName |
---|
196 | ); |
---|
197 | |
---|
198 | /*! |
---|
199 | * This method Closes a report file. |
---|
200 | * |
---|
201 | * @param[in] aFile identifies the report file name |
---|
202 | */ |
---|
203 | static void CloseFile( |
---|
204 | FILE* aFile |
---|
205 | ); |
---|
206 | |
---|
207 | /*! |
---|
208 | * This method puts any necessary footer information into |
---|
209 | * the report then closes the file. |
---|
210 | * |
---|
211 | * @param[in] aFile identifies the report file name |
---|
212 | */ |
---|
213 | virtual void CloseAnnotatedFile( |
---|
214 | FILE* aFile |
---|
215 | ); |
---|
216 | |
---|
217 | /*! |
---|
218 | * This method puts any necessary footer information into |
---|
219 | * the report then closes the file. |
---|
220 | * |
---|
221 | * @param[in] aFile identifies the report file name |
---|
222 | * @param[in] hasBranches indicates if there are branches to report |
---|
223 | */ |
---|
224 | virtual void CloseBranchFile( |
---|
225 | FILE* aFile, |
---|
226 | bool hasBranches |
---|
227 | ); |
---|
228 | |
---|
229 | /*! |
---|
230 | * This method puts any necessary footer information into |
---|
231 | * the report then closes the file. |
---|
232 | * |
---|
233 | * @param[in] aFile identifies the report file name |
---|
234 | */ |
---|
235 | virtual void CloseCoverageFile( |
---|
236 | FILE* aFile |
---|
237 | ); |
---|
238 | |
---|
239 | /*! |
---|
240 | * This method puts any necessary footer information into |
---|
241 | * the report then closes the file. |
---|
242 | * |
---|
243 | * @param[in] aFile identifies the report file name |
---|
244 | */ |
---|
245 | void CloseNoRangeFile( |
---|
246 | FILE* aFile |
---|
247 | ); |
---|
248 | |
---|
249 | /*! |
---|
250 | * This method puts any necessary footer information into |
---|
251 | * the report then closes the file. |
---|
252 | * |
---|
253 | * @param[in] aFile identifies the report file name |
---|
254 | */ |
---|
255 | virtual void CloseSizeFile( |
---|
256 | FILE* aFile |
---|
257 | ); |
---|
258 | |
---|
259 | /*! |
---|
260 | * This method puts any necessary footer information into |
---|
261 | * the report then closes the file. |
---|
262 | * |
---|
263 | * @param[in] aFile identifies the report file name |
---|
264 | */ |
---|
265 | virtual void CloseSymbolSummaryFile( |
---|
266 | FILE* aFile |
---|
267 | ); |
---|
268 | |
---|
269 | /*! |
---|
270 | * This method puts any necessary a line of annotated |
---|
271 | * data into the file. |
---|
272 | * |
---|
273 | * @param[in] aFile identifies the report file name |
---|
274 | * @param[in] state identifies the state machine state |
---|
275 | * @param[in] line identifies the string to print |
---|
276 | * @param[in] id identifies the branch or range id. |
---|
277 | */ |
---|
278 | virtual void PutAnnotatedLine( |
---|
279 | FILE* aFile, |
---|
280 | AnnotatedLineState_t state, |
---|
281 | std::string line, |
---|
282 | uint32_t id |
---|
283 | )=0; |
---|
284 | |
---|
285 | /*! |
---|
286 | * This method puts any necessary header information in |
---|
287 | * front of an annotated section. |
---|
288 | * |
---|
289 | * @param[in] aFile identifies the report file name |
---|
290 | */ |
---|
291 | virtual void AnnotatedStart( |
---|
292 | FILE* aFile |
---|
293 | )=0; |
---|
294 | |
---|
295 | /*! |
---|
296 | * This method puts any necessary footer information in |
---|
297 | * front of an annotated section. |
---|
298 | * |
---|
299 | * @param[in] aFile identifies the report file name |
---|
300 | */ |
---|
301 | virtual void AnnotatedEnd( |
---|
302 | FILE* aFile |
---|
303 | )=0; |
---|
304 | |
---|
305 | |
---|
306 | /*! |
---|
307 | * This method puts any necessary footer information into |
---|
308 | * the report then closes the file. |
---|
309 | * |
---|
310 | * @param[in] report identifies the report file name |
---|
311 | */ |
---|
312 | virtual bool PutNoBranchInfo( |
---|
313 | FILE* report |
---|
314 | ) = 0; |
---|
315 | |
---|
316 | /*! |
---|
317 | * This method puts a branch entry into the branch report. |
---|
318 | * |
---|
319 | * @param[in] report identifies the report file name |
---|
320 | * @param[in] number identifies the line number. |
---|
321 | * @param[in] symbolPtr is a pointer to the symbol information |
---|
322 | * @param[in] rangePtr is a pointer to the range information. |
---|
323 | */ |
---|
324 | virtual bool PutBranchEntry( |
---|
325 | FILE* report, |
---|
326 | unsigned int number, |
---|
327 | Coverage::DesiredSymbols::symbolSet_t::iterator symbolPtr, |
---|
328 | Coverage::CoverageRanges::ranges_t::iterator rangePtr |
---|
329 | )=0; |
---|
330 | |
---|
331 | /*! |
---|
332 | * This method reports when no range is available for |
---|
333 | * a symbol in the coverage report. |
---|
334 | * |
---|
335 | * @param[in] report identifies the report file name |
---|
336 | * @param[in] number identifies the line number. |
---|
337 | * @param[in] symbol is a pointer to the symbol information |
---|
338 | */ |
---|
339 | virtual void putCoverageNoRange( |
---|
340 | FILE* report, |
---|
341 | FILE* noRangeFile, |
---|
342 | unsigned int number, |
---|
343 | std::string symbol |
---|
344 | )=0; |
---|
345 | |
---|
346 | /*! |
---|
347 | * This method puts a line in the coverage report. |
---|
348 | * |
---|
349 | * @param[in] report identifies the report file name |
---|
350 | * @param[in] number identifies the line number. |
---|
351 | * @param[in] ditr is a iterator to the symbol information |
---|
352 | * @param[in] ritr is a iterator to the range information. |
---|
353 | */ |
---|
354 | virtual bool PutCoverageLine( |
---|
355 | FILE* report, |
---|
356 | unsigned int number, |
---|
357 | Coverage::DesiredSymbols::symbolSet_t::iterator ditr, |
---|
358 | Coverage::CoverageRanges::ranges_t::iterator ritr |
---|
359 | )=0; |
---|
360 | |
---|
361 | /*! |
---|
362 | * This method method puts a line into the size report. |
---|
363 | * |
---|
364 | * @param[in] report identifies the size report file name |
---|
365 | * @param[in] number identifies the line number. |
---|
366 | * @param[in] symbol is a pointer to the symbol information |
---|
367 | * @param[in] range is a iterator to the range information. |
---|
368 | */ |
---|
369 | virtual bool PutSizeLine( |
---|
370 | FILE* report, |
---|
371 | unsigned int number, |
---|
372 | Coverage::DesiredSymbols::symbolSet_t::iterator symbol, |
---|
373 | Coverage::CoverageRanges::ranges_t::iterator range |
---|
374 | )=0; |
---|
375 | |
---|
376 | /*! |
---|
377 | * This method method puts a line into the symbol summary report. |
---|
378 | * |
---|
379 | * @param[in] report identifies the report file name |
---|
380 | * @param[in] number identifies the line number. |
---|
381 | * @param[in] symbol is a pointer to the symbol information |
---|
382 | */ |
---|
383 | virtual bool PutSymbolSummaryLine( |
---|
384 | FILE* report, |
---|
385 | unsigned int number, |
---|
386 | Coverage::DesiredSymbols::symbolSet_t::iterator symbol |
---|
387 | )=0; |
---|
388 | }; |
---|
389 | |
---|
390 | /*! |
---|
391 | * This method iterates over all report set types and generates |
---|
392 | * all reports. |
---|
393 | */ |
---|
394 | void GenerateReports(); |
---|
395 | |
---|
396 | } |
---|
397 | |
---|
398 | #endif |
---|