Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

How to interpret "Stat" and "Off" values in C++Test coverage report?

spz1kor
spz1kor Posts: 5

I have the following code coverage report snippet and want to understand what do "Stat" and "Off" values represent and how to interpret them?

<CvgData cvgType="SC"> <Stat val="0;3;0;3;0;3;0"/> <Off val="0;76;115;120;146;153;198"/> </CvgData>undefined</File>undefined<File loc="/parasoft_example/parasoft_example/sub/sub.cpp"> <Content>int get_fifty() { return 50; } </Content>

Best Answer

  • Bogdan Czwartkowski
    Bogdan Czwartkowski Posts: 160 admin
    edited July 10 Answer ✓

    @spz1kor ,
    I think that you are looking at incorrect piece of your XML report, or the code is not that simple. The CovData record that you shown must refer to another file.

    A file as simple as this one
    int get_fifty() \n {\n return 50;\n }
    will only have three offsets - start of the file, start of the return statement and end of the return statement.
    If I have a file with only these 4 lines:

    int get_fifty()
    {
        return 50;
    }
    
    

    then its statement coverage detail data will look like this:

                <CvgData cvgType="SC">
                   <Stat val="0;3;0"/>
                   <Off val="0;21;31"/>
                </CvgData>
    

    Obviously, if there are comments before the function definition, the offsets will change naturally. if there is another coverable code before or after the function, there will be more offset values.

Answers

  • Bogdan Czwartkowski
    Bogdan Czwartkowski Posts: 160 admin
    edited July 5

    @spz1kor ,

    The <CovData> tags are added to XML reports when detailed coverage reports are enabled. They tell our HTML report generator which statements to highlight for coverage in the detailed HTML reports. The values in <Off> tag are byte offsets from the beginning of a source file, and <Stat> values represent coverage highlight (covered, non-covered, partial).

    These tags are for our internal reporting and rendering purposes, I do not think they will be of any use for end users.

  • spz1kor
    spz1kor Posts: 5
    edited July 5

    It would be helpful if you could elaborate the values in the example mentioned above. We need some custom reports and that info would be helpful.

  • Bogdan Czwartkowski
    Bogdan Czwartkowski Posts: 160 admin
    edited July 9

    @spz1kor ,

    I would like to stress again that these values are for coverage rendering in C/C++test's detailed coverage reports, hence it is all for internal use and it is subject to change. These values do not contain actual values of coverage achieved during tests. Still, here is an explanation given your example:

    First of all, the starting XML tag is <File> and it has <Content> and <CovData> child tags which represent source file content and coverage data to render on the content, respectively.

    Since <Content> is obvious, let us focus on <CovData>.
    Given our example:
    <CvgData cvgType="SC"> <Stat val="0;3;0;3;0;3;0"/> <Off val="0;76;115;120;146;153;198"/></CvgData>
    we have:

    • <CvgData cvgType="SC"> - "SC" means that details represent statement coverage, which was enabled for the detailed coverage report,
    • <Off val="0;76;115;120;146;153;198"/> - represents places in the code specified as offsets (number of characters) counted from the beginning of the source file,
    • <Stat val="0;3;0;3;0;3;0"/> - represents coverage state to render starting at particular offsets in the code, with the values meaning:
      • 0 - no coverage rendered (no highlight),
      • 1 - rendered as not covered (red),
      • 2 - partially covered (yellow),
      • 3 - fully covered (green).
  • spz1kor
    spz1kor Posts: 5
    edited July 9

    @Bogdan Czwartkowski , thanks for the response, but I highly doubt if the "Off" values are correct here.
    If you see the code snippet is very small, and we do have character offset as high as 76,115..198:

    int get_fifty() \n {\n return 50;\n } -> total number of character bytes here is 39.

    So these values really don't make sense in this context.

  • spz1kor
    spz1kor Posts: 5

    Makes sense!

  • spz1kor
    spz1kor Posts: 5
    edited July 15

    Is there a way to get combined offset values for SC, DC and MCDC together?