How to deal with .gcda and .gcno files in different directory by lcov & code coverage compare

≡放荡痞女 提交于 2019-12-10 20:41:56

问题


I can generate .info files by lcov with .gcda files and .gcno files in the same directory, BUT how can I generate code coverage with .gcda files and .gcno files in defferent location?

For example,

/Users/swd/Library/Developer/Xcode/DerivedData/test1aaeyiowcssrymfbwtudrqqakuvr/Build/Intermediates/test1.build/Cov/test1.build/Objects-normal/x86_64/AppDelegate.gcno

/Volumes/Data/test1/test1/AppDelegate.gcda

I tried --add-tracefile but failed, and output 'lcov: ERROR: no valid records found in trace file'

My second question is whether lcov have some command to compare my old version coverage html to my new one, so that I can find the difference.

Any ideas? Thanks


回答1:


Well few things needs to be cleared first to avoid confusion for other people.

.gcno and .gcda are never generated on different location for a single object file. (At least that's what I know from my experience)
When a source file is compiled either by using an automated builder or by manual commands, it generates .gcno files and .o files at the same location. And afterwards when you perform any kind of execution the object files trigger coverage generation functions and generate .gcda files at the same location as '.gcno' and object files.
And if they are generated for different .gcno files then they can not be used together anyway.




回答2:


This can happen if the environment variable GCOV_PREFIX is set. See here The suggested solution is to release the .gcno files to $GCOV_PREFIX by doing something like

rsync -acv --filter='+ */' --filter='+ *.gcno' --filter='- *' <directory-containing-object-files> $GCOV_PREFIX


来源:https://stackoverflow.com/questions/27940017/how-to-deal-with-gcda-and-gcno-files-in-different-directory-by-lcov-code-cov

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!