build: fix coverage for various lcov versions 44/42044/3
authorBenoît Ganne <[email protected]>
Wed, 18 Dec 2024 16:38:23 +0000 (17:38 +0100)
committerDave Wallace <[email protected]>
Mon, 24 Mar 2025 13:48:01 +0000 (13:48 +0000)
Starting with lcov version 2, we need to add some errors filtering.
Unfortunately, those filters are not available with lcov version 1.

Type: fix
Fixes: 66fcfb845b8e588901b4f663435e9e1b30499467

Change-Id: Ic8f4c55be89dcc59370b5a69ed8e8f39c5647ec8
Signed-off-by: Benoît Ganne <[email protected]>
test/Makefile

index e26bf7f..de3a3ca 100644 (file)
@@ -399,16 +399,22 @@ COV_REM_HST_UNUSED_FEAT= "*/plugins/ping/*" "*/plugins/unittest/mpcap_node.c" "*
                                         "*/vppinfra/pcap.c" "*/vppinfra/pcap_funcs.h"
 endif
 
+LCOV_VERSION=$(shell lcov --version | sed -E 's/^lcov: LCOV version ([0-9]+)[.].*/\1/')
+LCOV_IGNORE_ERRORS=
+ifeq ($(LCOV_VERSION),2)
+LCOV_IGNORE_ERRORS=--ignore-errors unused,empty,mismatch,gcov
+endif
+
 .PHONY: cov-post
 cov-post: wipe-cov $(BUILD_COV_DIR)
-       @lcov --ignore-errors unused,empty,mismatch,gcov --capture \
+       @lcov $(LCOV_IGNORE_ERRORS) --capture \
                --directory $(VPP_BUILD_DIR) \
                --output-file $(BUILD_COV_DIR)/coverage$(HS_TEST).info
        @test -z "$(EXTERN_COV_DIR)" || \
-               lcov --ignore-errors unused,empty,mismatch,gcov --capture \
+               lcov $(LCOV_IGNORE_ERRORS) --capture \
                --directory $(EXTERN_COV_DIR) \
                --output-file $(BUILD_COV_DIR)/extern-coverage$(HS_TEST).info
-       @lcov --ignore-errors unused,empty,mismatch,gcov --remove $(BUILD_COV_DIR)/coverage$(HS_TEST).info \
+       @lcov $(LCOV_IGNORE_ERRORS) --remove $(BUILD_COV_DIR)/coverage$(HS_TEST).info \
                $(COV_REM_NOT_CODE) \
                $(COV_REM_DRIVERS)  \
                $(COV_REM_TODO_NO_TEST) \