public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix 'make coverage' when used with lcov version 2.0+
@ 2024-05-06 20:45 Aaron Merey
  2024-05-06 23:35 ` Dmitry V. Levin
  2024-05-08 16:28 ` Aaron Merey
  0 siblings, 2 replies; 12+ messages in thread
From: Aaron Merey @ 2024-05-06 20:45 UTC (permalink / raw)
  To: elfutils-devel; +Cc: Aaron Merey

Starting with version 2.0, various lcov warnings now trigger an error
exit.  This results in 'make coverage' terminating before completion.

Fix this by invoking lcov and genhtml with --ignore-errors to prevent
the error exit when version 2.0+ is in use.

Manually tested by running elfutils-htdocs/update-coverage.sh with
lcov 1.14 and 2.0.

Signed-off-by: Aaron Merey <amerey@redhat.com>
---
 Makefile.am  | 30 +++++++++++++++++++++++++++++-
 configure.ac |  4 ++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index c9d59d4a..a1f0b0c3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -77,6 +77,7 @@ coverage-clean:
 coverage: $(COVERAGE_OUTPUT_INDEX_HTML)
 	@echo 'file://$(abs_builddir)/$(COVERAGE_OUTPUT_INDEX_HTML)'
 
+if LCOV_OLD
 $(COVERAGE_OUTPUT_INDEX_HTML): $(COVERAGE_OUTPUT_FILE)
 	LC_ALL=C $(GENHTML) \
 		--legend \
@@ -89,7 +90,23 @@ $(COVERAGE_OUTPUT_INDEX_HTML): $(COVERAGE_OUTPUT_FILE)
 		--prefix='$(realpath $(abs_builddir)/..)' \
 		--output-directory='$(COVERAGE_OUTPUT_DIRECTORY)' \
 		$<
+else
+$(COVERAGE_OUTPUT_INDEX_HTML): $(COVERAGE_OUTPUT_FILE)
+	LC_ALL=C $(GENHTML) \
+		--legend \
+		--show-details \
+		--ignore-errors empty,negative \
+		--rc=genhtml_branch_coverage=1 \
+		--title='$(COVERAGE_TITLE)' \
+		--prefix='$(abspath $(abs_srcdir))' \
+		--prefix='$(realpath $(abs_srcdir))' \
+		--prefix='$(abspath $(abs_builddir)/..)' \
+		--prefix='$(realpath $(abs_builddir)/..)' \
+		--output-directory='$(COVERAGE_OUTPUT_DIRECTORY)' \
+		$<
+endif
 
+if LCOV_OLD
 $(COVERAGE_OUTPUT_FILE):
 	$(LCOV) \
 		--capture \
@@ -99,7 +116,18 @@ $(COVERAGE_OUTPUT_FILE):
 		--gcov-tool='$(GCOV)' \
 		--output-file='$@' \
 		$(LCOV_DIRS_ARGS)
-
+else
+$(COVERAGE_OUTPUT_FILE):
+	$(LCOV) \
+		--capture \
+		--no-external \
+		--no-checksum \
+		--ignore-errors empty,negative \
+		--rc=lcov_branch_coverage=1 \
+		--gcov-tool='$(GCOV)' \
+		--output-file='$@' \
+		$(LCOV_DIRS_ARGS)
+endif
 endif
 
 # Tell version 3.79 and up of GNU make to not build goals in this
diff --git a/configure.ac b/configure.ac
index a279bb52..2aa728bd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -322,6 +322,10 @@ if test "$use_gcov" = yes; then
 fi
 AM_CONDITIONAL(GCOV, test "$use_gcov" = yes)
 
+# Check if lcov/genhtml supports ignoring additional errors.
+AM_CONDITIONAL([LCOV_OLD],
+  [test "$LCOV" = "lcov" && lcov --version | grep -E -q "version 0|version 1"])
+
 AC_ARG_ENABLE([sanitize-undefined],
               AS_HELP_STRING([--enable-sanitize-undefined],
                              [Use gcc undefined behaviour sanitizer]),
-- 
2.43.0


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2024-05-14 15:39 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-06 20:45 [PATCH] Fix 'make coverage' when used with lcov version 2.0+ Aaron Merey
2024-05-06 23:35 ` Dmitry V. Levin
2024-05-08 16:28 ` Aaron Merey
2024-05-09 21:53   ` Dmitry V. Levin
2024-05-09 22:08     ` Frank Ch. Eigler
2024-05-09 22:59       ` Dmitry V. Levin
2024-05-09 23:03         ` Frank Ch. Eigler
2024-05-10  0:16           ` Dmitry V. Levin
2024-05-10  1:37             ` Frank Ch. Eigler
2024-05-14 15:39               ` Mark Wielaard
2024-05-09 23:24         ` [COMMITTED] Makefile.am: Avoid code duplication Aaron Merey
2024-05-09 23:36           ` Dmitry V. Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).