问题
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