views:

257

answers:

5

Is there a tool for code coverage for C language.

I know there are many. But I wanted something like perl Devel::cover. Where I get:

  • Line coverage
  • Branch Coverage
  • Condition coverage
  • Subroutine coverage

And all this in a nice HTML output.

Is there anything like this for C?

+5  A: 

GNU Gcov, but it doesn't produce HTML output

qrdl
Thanks..seems to do the work..if only someone had written a HTML output for gcov..
someguy
Sounds like you want lcov - http://ltp.sourceforge.net/coverage/lcov.php
Douglas Leeder
+3  A: 

gcov with lcov to generate HTML.

It'll do line coverage, but not branch, function coverage (as far as I know).

Douglas Leeder
A: 

GCOV is the easiest to use - I wrote a small perl script that parses gcov files and outputs html stuff (because I didn't know about lcov).

Very easy to do, and you can tailor it to your own needs (I also got my html to output the covered percentage, as well as overall percentage if parsing multiple files).

Relevant regular expressions below (inside []), for posterity.

(lines without code match) [/^[ \t]*-:[ \t]*([0-9]+:)(.*)\r\n/]        
(covered lines match) [/^[ \t]*[0-9]+:[ \t]*([0-9]+:)(.*)\r\n/]    
(non-covered lines match) [/^[ \t]*#####:[ \t]*([0-9]+:)(.*)\r\n/]
laura
+1  A: 

Devel::Cover includes a utility called "gcov2perl" which converts gcov files to Devel::Cover databases. That would allow you to use Devel::Cover's reporting features, though you would of course be limited to reporting things that gcov collects.

Michael Carman
A: 

Semantic Designs C Test Coverage Tool. Nice UI display of code coverage on lines. XML report on what's covered; you can manufacture whatever HTML you want from that. Provides branch coverage. Low overhead for very large systems; works well in embedded system contexts.

Ira Baxter