我正在使用gcov在macosx平台中进行覆盖率测试。我通过设置完成xcode的配置:
1. Build Settings ==> Generate Test Coverage Files == Yes
2. Build Settings ==> Instrument Progaram Flow == Yes
3. Build Phases ==> Link Binary with library ==> add "libprofile_rt.dylib"
然后生成文件“
Test.d, Test.dia, Test.gcno, Test.gcda, Test.o
”然后,我使用
gcov-4.2 -b Test.gcno
命令生成Test.m.gcov
文件(这就是我想要的),但是下次当我再次运行测试用例时,将再次生成文件“Test.d, Test.dia, Test.gcno, Test.gcda, Test.o
”,并且将重置数据。所以我有两个问题:
merge two Test.gcno
文件(由两次运行生成)合并为一个。我在终端中尝试gcov,以下是gcov命令的选项:gcov-4.2 -help
Usage: gcov [OPTION]... SOURCEFILE
Print code coverage information.
-h, --help Print this help, then exit
-v, --version Print version number, then exit
-a, --all-blocks Show information for every basic block
-b, --branch-probabilities Include branch probabilities in output
-c, --branch-counts Given counts of branches taken
rather than percentages
-n, --no-output Do not create an output file
-l, --long-file-names Use long output file names for included
source files
-f, --function-summaries Output summaries for each function
-o, --object-directory DIR|FILE Search for object files in DIR or called FILE
-p, --preserve-paths Preserve all pathname components
-u, --unconditional-branches Show unconditional branch counts too
For bug reporting instructions, please see:
<URL:http://developer.apple.com/bugreporter>.
谢谢您提前提供的所有帮助
最佳答案
gcov
的通常工作流程是
-fprofile-arcs -ftest-coverage
).gcda
文件gcov
以人类可读格式(.gcov
)获取覆盖率统计信息因此,基本上,该应用程序的连续运行将产生累积的覆盖率统计信息。只是这些累积将发生在
.gcda
文件中,而不是.gcov
文件中,因此您每次想要查看更新的统计信息时都必须重新运行gcov
。
关于code-coverage - 无论如何有将两个gcov文件合并为一个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15612077/