美文网首页
gcov使用

gcov使用

作者: dixiaochuan | 来源:发表于2018-12-10 14:39 被阅读0次
    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.

    相关文章

      网友评论

          本文标题:gcov使用

          本文链接:https://www.haomeiwen.com/subject/xwwlhqtx.html