9.04.2011

Gcov Coverage Reports in Jenkins

I am currently evaluating the applicability and limitations of the Jenkins continuous integration server for C++ development. Besides several limitations which are mainly caused by the complexity of C++, Jenkins provides a solid basis for continuous integration of C++ projects.

One thing which I was not happy with so far was the missing integration of open-source coverage tools for Linux. Here, Gcov can be used to generate more or less precise coverage reports for projects compiled with GCC. Unfortunately, Gcov itself does not provide tools to export the results in any common or even nicely readable format. Until now, the only working solution I found was to use the Gcov front-end LCOV to generate a HTML report. This report is nice to read but it cannot be tracked by Jenkins with the drawback that no trend report for the code coverage can be generated. Nevertheless, I’ve wrapped the creation of such a HTML report in a CMake function and worked with it so far.

Today, I searched again for cheap solutions to overcome this drawback (this means without writing a custom Jenkins plugin for Gcov coverage files). While searching the net, I found the gcovr script, which parses Gcov result files and is able to convert them into XML files that satisfy the format generated by Cobertura, which is a coverage tool for Java with an existing plugin for Jenkins.

As far as I tested it, this script works well with the Jenkins plugin, so I integrated the execution of this script in my existing coverage function for CMake, which is available in the RSC library. This library also contains additional CMake wrappers for tools that can be used to generate trend reports in Jenkins, like cppcheck. Now our Jenkins can also generate coverage trend reports for C++ projects.

Kommentare

Hello J.
First of all , you’re doing a great job with your blog , very instructive.

I’ve visited your project at https://code.cor-lab.de/projects/rsc , and have a look because I’m currently facing the same issue you’ve done with Hudons and gcovr.

Checking your code I’ve realize the way you create the cobertura.xml file with EnableCoverageReport.cmake.

But my doubt is about the compilation process, from where I’ve learn the flags “-fprofile-arcs -ftest-coverage” shall be added to the CACHE variable CXX_MAKE_FLAGS.
But revising you project I haven’t found the setting of these flags.

As your project is currently generating coverage reports, I must be wrong. So I will be very greatful if you can show me how you have defined these flags.

Thanks in advance for your blog.

There is an alternate option to enable this in GCC: –coverage. Have a look at line 69 of the cmake file.

Hinterlasse einen Kommentar

Dein Kommentar:

Kategorien