[CMake] Coverage information overestimated? Globbing for *.gcno instead of *.gcda?

Bill Hoffman bill.hoffman at kitware.com
Mon Apr 27 11:01:18 EDT 2009


Tom Vercauteren wrote:
>>> I just saw that when ctest is used to generate coverage information,
>>> it looks for (gc)da files in the build directory - cf.
>>> cmCTestCoverageHandler::FindGCovFiles in cmCTestCoverageHandler.cxx.
>>>
>>> If I understand it correctly, when everything is setup correctly for a
>>> coverage build:
>>>  - gcc generates (gc)no files at compile time
>>>  - (gc)da files are generated at run time - i.e. when the unit tests are
>>> run
>>>
>>> So, it seems to me that for each (gc)da file we are sure that a (gc)no
>>> file exists but not the other way round.
>>>
>>> Since ctest is looking for (gc)da files, it seems to me that it will
>>> lead to over-estimating the coverage information. Indeed, some code
>>> can be compiled but never executed by the unit tests.
>>>
>> I don't think this is a problem.   Do you have an example that shows the
>> problem?  If the code is not run, it does not produce any coverage
>> information in any file for ctest to find???
> 
> The reason I am looking at this is because I would like to get a
> global coverage percentage that reflects the coverage of my project as
> a whole as opposed to only the subset that has some unit tests.
> 
> So, it would be interesting for me to show on a cdash-dashboard this
> compiled but untested code (at least not automatically by ctest). One
> way to do that might be to use gcno files instead of gcda files in
> ctest.
> 
> The coverage information that I would get form it is that when a gcno
> file exists but has no gcda counterpart, there is no coverage at all.
> Right now, this is silently discarded.
> 
> Tom
> 
> P.S.: Thanks for the lightning fast answer!
> 
CTest does that for you.  As you run tests ctest will accumulate the 
test code that is actually run.  I am not sure I understand the coverage 
information you are looking for?  What does compile time coverage mean?


-Bill


More information about the CMake mailing list