开发者

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

开发者 https://www.devze.com 2023-04-12 02:38 出处:网络
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.

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, pinpoin开发者_开发技巧ting the possible branches/race conditions/execution flows actually executed.


TestCocoon is a great tool to try, better than gcov with good tools and report facilities. As templates are compile-time beasts, I'm not sure what coverage information you want to get ?

my two cents


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


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.


C++ Coverage Validator provides coverage data for templates.

Code coverage is tracked for all threads.


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消