fantasticsid
fantasticsid

Reputation: 707

What's the best C++ code coverage tool that works with templates?

I have used gcov for testing code coverage, but when it comes to templated c++ code it doesn't work so well. I use boost::spirit extensively and gcov seems to simply ignore templated spirit code.

Also I am wondering if there is a coverage tool to show how threads interacts with each other, pinpointing the possible branches/race conditions/execution flows actually executed.

Upvotes: 17

Views: 9707

Answers (5)

neuro
neuro

Reputation: 15180

TestCocoon was a great tool to try, better than gcov with good tools and report facilities. As mentioned by @vraj Pandya in the comments, TestCocoon is no more maintained. You can use Squish Coco, which is compatible. I can't tell what it's worth though.

Nowadays, I use LLVM coverage tools.

Upvotes: 2

Jay D
Jay D

Reputation: 3307

Parasoft CPP test is a good tool for various analysis including code coverage and static analysis. This is good for digging into multithreading as well.

http://www.parasoft.com/jsp/products/cpptest.jsp

Here are 10 good open soure tools for code coverage :

https://web.archive.org/web/20181018002302/http://open-tube.com/10-code-coverage-tools-c-c/

Upvotes: 1

Stephen Kellett
Stephen Kellett

Reputation: 3236

C++ Coverage Validator provides coverage data for templates.

Code coverage is tracked for all threads.

Upvotes: 1

Ira Baxter
Ira Baxter

Reputation: 95344

Our C++ Test Coverage tool provides test coverage on template bodies, or at least those templates that are defined in files you specify for it to cover.

It doesn't distinguish instantiations of templates.

If you have a multi-threaded application, the tool will record the branches executed by all threads, if you configure the tool to use flags that are atomically writable (typically the natural word size of the CPU [32 or 64 bits]. (If you don't do this, you may end up with a thread race in updating the coverage flags and you can lose a bit of coverage. This isn't a defect of the tool; its a consequence of unsynchronized access to the storage holding probe data.)

For race detection, OP needs to find a race detection tool; test coverage tools won't do this.

Upvotes: 1

Aditya Kumar Pandey
Aditya Kumar Pandey

Reputation: 991

I work on a large product and we used a third party app called BullsEye for coverage testing. It worked wonders.

Upvotes: 1

Related Questions