summaryrefslogtreecommitdiffstats
path: root/tester/covoar/ReportsBase.h
blob: 43cd80e5d3853d719b577a60ce14d607cade7851 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
/*! @file ReportsBase.h
 *  @brief Reports Base Class Specification
 *
 *  This file contains the specification of the Reports methods.  This
 *  collection of methods is used to generate the various reports of
 *  the analysis results.
 */

#ifndef __REPORTSBASE_H__
#define __REPORTSBASE_H__

#include <stdint.h>
#include <string>
#include <time.h>
#include "DesiredSymbols.h"

namespace Coverage {

/*!
 *   This class contains the base information to create a report 
 *   set.  The report set may be text based, html based or some
 *   other format to be defined at a future time.
 */
class ReportsBase {

  public:
    ReportsBase( time_t timestamp, std::string symbolSetName );
    virtual ~ReportsBase();

    /*!
     *  This method produces an index of the reports generated.
     *
     *  @param[in] fileName identifies the report file name
     */
    virtual void WriteIndex(
      const char* const fileName
    );

    /*!
     *  This method produces an annotated assembly listing report containing
     *  the disassembly of each symbol that was not completely covered.
     *
     *  @param[in] fileName identifies the annotated report file name
     */
    void WriteAnnotatedReport(
      const char* const fileName
    );

    /*!
     *  This method produces a report that contains information about each
     *  uncovered branch statement.
     *
     *  @param[in] fileName identifies the branch report file name
     */
    void WriteBranchReport(
      const char* const fileName
    );

    /*!
     *  This method produces a report that contains information about each
     *  uncovered range of bytes.
     *
     *  @param[in] fileName identifies the coverage report file name
     */
    void WriteCoverageReport(
      const char* const fileName
    );

    /*!
     *  This method produces a summary report that lists each uncovered
     *  range of bytes.
     *
     *  @param[in] fileName identifies the report file name
     */
    void WriteSizeReport(
      const char* const fileName
    );

    /*!
     *  This method produces a summary report that lists information on
     *  each symbol which did not achieve 100% coverage
     *
     *  @param[in] fileName identifies the report file name
     */
    void WriteSymbolSummaryReport(
      const char* const fileName
    );

    /*!
     *  This method produces a sumary report for the overall test run.
     */
    static void  WriteSummaryReport(
      const char* const fileName,
      const char* const symbolSetName
    );

    /*!
     *  This method returns the unique extension for the Report
     *  type.  If the extension is ".txt" files will be 
     *  named "annotated.txt", "branch.txt" ......
     */
    std::string ReportExtension() { return reportExtension_m; }

  protected:

    /*!
     * This type is used to track a state during the annotated output.
     */
    typedef enum {
      A_SOURCE,
      A_EXECUTED,
      A_NEVER_EXECUTED,
      A_BRANCH_TAKEN,
      A_BRANCH_NOT_TAKEN
    } AnnotatedLineState_t;

    /*!
     *  This member variable contains the extension used for all reports.
     */
    std::string reportExtension_m;

    /*!
     *  This member variable contains the name of the symbol set for the report.
     */
    std::string symbolSetName_m;

    /*!
     *  This member variable contains the timestamp for the report.
     */
    time_t timestamp_m;

    /*!
     *  This method Opens a report file and verifies that it opened
     *  correctly.  Upon failure NULL is returned.
     *
     *  @param[in] fileName identifies the report file name
     *  @param[in] symbolSetName identifies the name of the report's symbol set
     */
     static FILE* OpenFile(
      const char* const fileName,
      const char* const symbolSetName
    );

    /*!
     *  This method opens a report file and verifies that it opened.
     *  Then appedns any necessary header information onto the file.
     *
     *  @param[in] fileName identifies the report file name
     */
    virtual FILE* OpenAnnotatedFile(
      const char* const fileName
    );

    /*!
     *  This method opens a report file and verifies that it opened.
     *  Then appedns any necessary header information onto the file.
     *
     *  @param[in] fileName identifies the report file name
     *  @param[in] hasBranches indicates if there are branches to report
     */
    virtual FILE* OpenBranchFile(
      const char* const fileName,
      bool              hasBranches
    );

    /*!
     *  This method opens a report file and verifies that it opened.
     *  Then appedns any necessary header information onto the file.
     *
     *  @param[in] fileName identifies the report file name
     */
    virtual FILE* OpenCoverageFile(
      const char* const fileName
    );
    
    /*!
     *  This method opens a report file and verifies that it opened.
     *  Then appends any necessary header information onto the file.
     *
     *  @param[in] fileName identifies the report file name
     */
    virtual FILE* OpenNoRangeFile(
      const char* const fileName
    );

    /*!
     *  This method opens a report file and verifies that it opened.
     *  Then appedns any necessary header information onto the file.
     *
     *  @param[in] fileName identifies the report file name
     */
    virtual FILE* OpenSizeFile(
      const char* const fileName
    );

    /*!
     *  This method opens a report file and verifies that it opened.
     *  Then appedns any necessary header information onto the file.
     *
     *  @param[in] fileName identifies the report file name
     */
    virtual FILE* OpenSymbolSummaryFile(
      const char* const fileName
    );

    /*!
     *  This method Closes a report file. 
     *
     *  @param[in] aFile identifies the report file name
     */
    static void CloseFile(
      FILE*  aFile
    );

    /*!
     *  This method puts any necessary footer information into
     *  the report then closes the file.
     *
     *  @param[in] aFile identifies the report file name
     */
    virtual void CloseAnnotatedFile(
      FILE*  aFile
    );

    /*!
     *  This method puts any necessary footer information into
     *  the report then closes the file.
     *
     *  @param[in] aFile identifies the report file name
     *  @param[in] hasBranches indicates if there are branches to report
     */
    virtual void CloseBranchFile(
      FILE*  aFile,
      bool   hasBranches
    );

    /*!
     *  This method puts any necessary footer information into
     *  the report then closes the file.
     *
     *  @param[in] aFile identifies the report file name
     */
    virtual void CloseCoverageFile(
      FILE*  aFile
    );

    /*!
     *  This method puts any necessary footer information into
     *  the report then closes the file.
     *
     *  @param[in] aFile identifies the report file name
     */
    void  CloseNoRangeFile(
      FILE*  aFile
    );

    /*!
     *  This method puts any necessary footer information into
     *  the report then closes the file.
     *
     *  @param[in] aFile identifies the report file name
     */
    virtual void CloseSizeFile(
      FILE*  aFile
    );

    /*!
     *  This method puts any necessary footer information into
     *  the report then closes the file.
     *
     *  @param[in] aFile identifies the report file name
     */
    virtual void CloseSymbolSummaryFile(
      FILE*  aFile
    );

    /*!
     *  This method puts any necessary a line of annotated
     *  data into the file.
     *
     *  @param[in] aFile identifies the report file name
     *  @param[in] state identifies the state machine state
     *  @param[in] line identifies the string to print  
     *  @param[in] id identifies the branch or range id.
     */
    virtual void PutAnnotatedLine( 
      FILE*                aFile, 
      AnnotatedLineState_t state, 
      std::string          line,
      uint32_t             id 
    )=0;

    /*!
     *  This method puts any necessary header information in
     *  front of an annotated section.
     *
     *  @param[in] aFile identifies the report file name
     */
     virtual void AnnotatedStart(
      FILE*                aFile
    )=0;
 
    /*!
     *  This method puts any necessary footer information in
     *  front of an annotated section.
     *
     *  @param[in] aFile identifies the report file name
     */
     virtual void AnnotatedEnd(
      FILE*                aFile
    )=0;
 

    /*!
     *  This method puts any necessary footer information into
     *  the report then closes the file.
     *
     *  @param[in] report identifies the report file name
     */
    virtual bool PutNoBranchInfo(
      FILE* report
    ) = 0;

    /*!
     *  This method puts a branch entry into the branch report. 
     *
     *  @param[in] report identifies the report file name
     *  @param[in] number identifies the line number.
     *  @param[in] symbolName is the symbol's name.
     *  @param[in] symbolInfo is the symbol's information.
     *  @param[in] rangePtr is a pointer to the range information.
     */
    virtual bool PutBranchEntry(
      FILE*                                            report,
      unsigned int                                     number,
      const std::string&                               symbolName,
      const SymbolInformation&                         symbolInfo,
      Coverage::CoverageRanges::ranges_t::iterator     rangePtr
    )=0;

    /*!
     *  This method reports when no range is available for 
     *  a symbol in the coverage report.
     *
     *  @param[in] report identifies the report file name
     *  @param[in] number identifies the line number.
     *  @param[in] symbol is a pointer to the symbol information
     */
    virtual void putCoverageNoRange(
      FILE*        report,
      FILE*        noRangeFile,
      unsigned int number,
      std::string  symbol
    )=0;

    /*!
     *  This method puts a line in the coverage report.
     *
     *  @param[in] report identifies the report file name
     *  @param[in] number identifies the line number.
     *  @param[in] symbolName is the symbol's name.
     *  @param[in] symbolInfo is the symbol's information.
     *  @param[in] ritr is a iterator to the range information.
     */
    virtual bool PutCoverageLine(
      FILE*                                           report,
      unsigned int                                    number,
      const std::string&                              symbolName,
      const SymbolInformation&                        symbolInfo,
      Coverage::CoverageRanges::ranges_t::iterator    ritr
    )=0;

    /*!
     *  This method method puts a line into the size report.
     *
     *  @param[in] report identifies the size report file name
     *  @param[in] number identifies the line number.
     *  @param[in] symbolName is the symbol's name.
     *  @param[in] range is a iterator to the range information.
     */
    virtual bool PutSizeLine(
      FILE*                                           report,
      unsigned int                                    number,
      const std::string&                              symbolName,
      Coverage::CoverageRanges::ranges_t::iterator    range
    )=0;

    /*!
     *  This method method puts a line into the symbol summary report.
     *
     *  @param[in] report identifies the report file name
     *  @param[in] number identifies the line number.
     *  @param[in] symbolName is the symbol's name.
     *  @param[in] symbolInfo is the symbol's information.
     */
    virtual bool PutSymbolSummaryLine(
      FILE*                                           report,
      unsigned int                                    number,
      const std::string&                              symbolName,
      const SymbolInformation&                        symbolInfo
    )=0;
};

/*!
 *  This method iterates over all report set types and generates
 *  all reports.
 *
 *  @param[in] symbolSetName is the name of the symbol set to report on.
 */
void GenerateReports(const std::string& symbolSetName);

}

#endif