Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

lcov absolute versus relative paths

How does lcov decide when to use absolute paths versus relative paths?

I have an app directory containing subdirectories for each of my product's shared libraries and subdirectories for several binaries. Something like this:

/home/user/app/libfoo/bar
/home/user/app/libfoo/baz
/home/user/app/libqux
/home/user/app/testsuite
/home/user/app/product

However, when run through lcov and genhtml, the directories are listed like this:

/home/user/app/libqux
/home/user/app/testsuite
/home/user/app/product
bar
baz

In other words, everything within one of my shared library directories uses a relative path, while everything else uses absolute paths. Why?

My invoction of lcov and genhtml is pretty straightforward:

cd ~/app
testsuite/run_tests
lcov --capture --directory . --output-file coverage.info --gcov-tool gcov-5 --no-external
genhtml coverage.info --output-directory coverage
like image 645
Josh Kelley Avatar asked Sep 24 '15 13:09

Josh Kelley


1 Answers

This is the result of genhtml's --prefix feature.

   -p prefix
   --prefix prefix
          Remove prefix from all directory names.

          Because lists containing long filenames are difficult  to  read,
          there  is a mechanism implemented that will automatically try to
          shorten all directory names on the overview page beginning  with
          a  common  prefix.  By  default, this is done using an algorithm
          that tries to find the prefix which, when applied, will minimize
          the resulting sum of characters of all directory names.

          Use this option to specify the prefix to be removed by yourself.

In my case, the /home/user/app/libfoo library hierarchy was involved enough that genhtml decided it saved more characters by stripping that, rather than the more obvious approach of stripping /home/user/app.

Passing an explicit --prefix /home/user/app option fixes this.

like image 114
Josh Kelley Avatar answered Jan 02 '23 19:01

Josh Kelley