[PATCH v2] Add coverage target
Dmitry V. Levin
ldv@altlinux.org
Tue Jan 12 12:23:42 GMT 2021
On Tue, Jan 12, 2021 at 12:48:17PM +0100, Mark Wielaard wrote:
> On Tue, 2021-01-12 at 07:29 +0300, Dmitry V. Levin wrote:
> > Implement a target for capturing code coverage using lcov.
> > It is available when elfutils is configured using --enable-gcov.
>
> Very nice.
>
> > +$(COVERAGE_OUTPUT_INDEX_HTML): $(COVERAGE_OUTPUT_FILE)
> > + LC_ALL=C $(GENHTML) \
> > + --legend \
> > + --show-details \
> > + --rc=genhtml_branch_coverage=1 \
> > + --title='$(COVERAGE_TITLE)' \
> > + --prefix='$(abspath $(abs_srcdir))' \
> > + --prefix='$(abspath $(abs_builddir)/..)' \
> > + --output-directory='$(COVERAGE_OUTPUT_DIRECTORY)' \
> > + $<
>
> Now that it is a top-level target the buildir /.. can be removed.
> Also depending on how I build there seems to be a combination of
> absolute and real paths in the coverage files (I have symlinks in my
> src and build dirs to make them go on separate disks). So I am using
> both:
If $(srcdir) != $(builddir), then there is a collision between
$(srcdir)/libcpu and $(builddir)/libcpu, so if we strip both $(abs_srcdir)
and $(abs_builddir) prefixes, we'll lose coverage in either $(srcdir)/libcpu
or $(builddir)/libcpu.
> diff --git a/Makefile.am b/Makefile.am
> index 30f763a9..69edcb02 100644
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -79,8 +79,10 @@ $(COVERAGE_OUTPUT_INDEX_HTML):
> $(COVERAGE_OUTPUT_FILE)
> --show-details \
> --rc=genhtml_branch_coverage=1 \
> --title='$(COVERAGE_TITLE)' \
> + --prefix='$(realpath $(abs_srcdir))' \
> --prefix='$(abspath $(abs_srcdir))' \
> - --prefix='$(abspath $(abs_builddir)/..)' \
> + --prefix='$(realpath $(abs_builddir))' \
> + --prefix='$(abspath $(abs_builddir))' \
> --output-directory='$(COVERAGE_OUTPUT_DIRECTORY)' \
> $<
>
> Make that makes sense? Either way feel free to push this.
I'll test the following variant:
--prefix='$(abspath $(abs_srcdir))' \
--prefix='$(realpath $(abs_srcdir))' \
--prefix='$(abspath $(abs_builddir)/..)' \
--prefix='$(realpath $(abs_builddir)/..)' \
--
ldv
More information about the Elfutils-devel
mailing list