From 0590da1a261ab31e763c4ad9f35ef65ff3269b8e Mon Sep 17 00:00:00 2001 From: Joy Date: Fri, 24 Jan 2025 19:03:51 +0000 Subject: [PATCH] use --add-tracefile option to handle duplicate SF in coverage.info --- debian/rules | 1 + tests/conftest.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/debian/rules b/debian/rules index 0d7f82646e..7b40977954 100755 --- a/debian/rules +++ b/debian/rules @@ -44,6 +44,7 @@ override_dh_auto_install: ifeq ($(ENABLE_GCOV), y) mkdir -p debian/swss/tmp/gcov lcov -c --directory . --no-external --exclude "$(shell pwd)/tests/*" --exclude "$(shell pwd)/**/tests/*" --ignore-errors gcov --output-file coverage.info + lcov --add-tracefile coverage.info -o coverage.info lcov_cobertura coverage.info -o coverage.xml find ./ -type f -regex '.*\.\(h\|cpp\|gcno\|info\)' | tar -cf debian/swss/tmp/gcov/gcov-source.tar -T - endif diff --git a/tests/conftest.py b/tests/conftest.py index 20e3a219d1..466e182a03 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -462,7 +462,7 @@ def collect_coverage(self): self.runcmd('supervisorctl stop all') # Generate the converage info by lcov and copy to the host - cmd = f"docker exec {self.ctn.short_id} sh -c 'cd $BUILD_DIR; rm -rf **/.libs ./lib/libSaiRedis*; lcov -c --directory . --no-external --exclude tests --ignore-errors gcov,unused --output-file /tmp/coverage.info; sed -i \"s#SF:$BUILD_DIR/#SF:#\" /tmp/coverage.info; lcov_cobertura /tmp/coverage.info -o /tmp/coverage.xml'" + cmd = f"docker exec {self.ctn.short_id} sh -c 'cd $BUILD_DIR; rm -rf **/.libs ./lib/libSaiRedis*; lcov -c --directory . --no-external --exclude tests --ignore-errors gcov,unused --output-file /tmp/coverage.info && lcov --add-tracefile /tmp/coverage.info -o /tmp/coverage.info; sed -i \"s#SF:$BUILD_DIR/#SF:#\" /tmp/coverage.info; lcov_cobertura /tmp/coverage.info -o /tmp/coverage.xml'" subprocess.getstatusoutput(cmd) cmd = f"docker exec {self.ctn.short_id} sh -c 'cd $BUILD_DIR; find . -name *.gcda -type f -exec tar -rf /tmp/gcda.tar {{}} \\;'" subprocess.getstatusoutput(cmd)