接我的上一篇
问题:在产生了.gcno 和 .gcda两个文件后,使用lcov -c -d Debug/source/ -o Debug/coverage.info 产生中间文件coverage.info文件,然后用genhtml -o output/ Debug/coverage.info产生html文件,发现产生的index.xml文件包含了include,甚至/usr/*下的公共头文件,怎么去除这些不需要统计覆盖率的文件?
1。正向提取需要的文件:
//比如希望把source相关的路径提取出来
lcov --extract Debug/coverage.info '*source/*' -o Debug/finalresult.info
//然后产生的xml就包含所有source相关的文件
genhtml -o output/ Debug/finalresult.info
2。反向去除不需要的文件:
//比如希望去除UnitTest 和/usr/相关文件:
lcov --remove Debug/coverage.info '*UnitTest/*' '/usr/*' -o Debug/finalresult.info
//然后产生的xml就去除了UnitTest 和/usr/相关的文件
genhtml -o output/ Debug/finalresult.info
注意:lcov 不允许同时使用--extract 和 --remove