4

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

Yih
  • 41
  • 1
  • 1
  • 4

2 Answers2

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.

Vikas Tawniya
  • 1,323
  • 1
  • 13
  • 22
  • 1
    If the environment variable `GCOV_PREFIX`is set to some path gcov adds that path in front of the absolute paths in the `.o` file and generates the `.gcda` file there. – user26756 Oct 04 '17 at 14:39
  • And this is typically done to be able to run the program in many parallel processes, like with many tests run with "make -j test" – thoni56 Jul 20 '22 at 07:40
1

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
user26756
  • 233
  • 1
  • 9
  • This is very expensive if you are running many tests in different directories with GCOV_PREFIX set to generate separate sets. Then you need to copy the `.gcno` files many times. `rsync` helps a bit since it does not copy files unnecessarily. But is there actually no better method? Like a switch or environment variable? – thoni56 Jul 20 '22 at 07:43