gcov使用

Step 1: modify the Makefile for the source codes

To use the tool of gcov, one must add flags to generate reports flags to be added as follows:
For the .cpp file, one need to add flags: -fprofile-arcs -ftest-coverage
For the .cu files, one need to add flags: -Xcompiler -fprofile-arcs -Xcompiler -ftest-coverage
Link with “-lgcov” .
After compiling the source code with the newly added gcov flags, corresponding .gcno files will be generated for each source code file (in src/ folder).

Step 2: run the tests

After this step, *.gcda files will be created (in src/ folder).

Step 3: use gcovr to generate HTML output

Under the directory of the library, create a new folder(say gcov/) and copy the *gcno and *gcda files to this folder.
In the root directory, use the following command line to generate the HTML file:

gcovr gcov/ -e ".stub.|.hxx|..h|.iostream|.include.*" --html --html-details -o coverage.html

Here gcovr provides a utility for managing the use of the GNU gcov utility and generating summarized code coverage results.
'-e' means to exclude data files that match this regular expression.

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • This project was bootstrapped with Create React App. Belo...
    unspecx阅读 10,603评论 0 2
  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,196评论 0 10
  • 写的初衷仅仅是想用文字来记录自己的心境。文学让情感丰富,文字让回忆铭心。 标题里是该先致敬我们的爱情还是先...
    姜国琴阅读 2,972评论 0 0
  • 无主情书 写给每一个辗转难眠的日子 写给每一场你不在身边的倾盆大雨 写给思念里的流浪汉 写给 全世界的被爱 与不被...
    舍梨阅读 3,885评论 3 49
  • 昨天参加老同事的聚会,聚会地点放在了他的千万豪宅。在去之前有很多的评判、恐惧、比较,觉得自己现在和他们比起来很差。...
    在云端01阅读 1,711评论 0 0

友情链接更多精彩内容