summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2022-02-14 13:51:08 +0000
committerGitHub <noreply@github.com>2022-02-14 13:51:08 +0000
commitfdf9de694f4c55b8cebd9d749f9c17c4bfb32650 (patch)
tree06c7e405d2d88080377b2f685d08d034c6204c84
parent42672c80dc9d4d3f918e2e6e49f064155c90d8e4 (diff)
parentd282e57e2a93f034d7f7936f87fc5cb67d913151 (diff)
downloadsystemd-fdf9de694f4c55b8cebd9d749f9c17c4bfb32650.tar.gz
Merge pull request #22505 from mrc0mmand/more-coverage-tweaks
A couple of coverage-related tweaks
-rw-r--r--test/test-functions17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/test-functions b/test/test-functions
index a7b0be0c2b..2c13baab04 100644
--- a/test/test-functions
+++ b/test/test-functions
@@ -1070,6 +1070,9 @@ install_compiled_systemd() {
if get_bool "$IS_BUILT_WITH_COVERAGE"; then
mkdir -p "${initdir}/${BUILD_DIR:?}/"
rsync -am --include='*/' --include='*.gcno' --exclude='*' "${BUILD_DIR:?}/" "${initdir}/${BUILD_DIR:?}/"
+ # Set effective & default ACLs for the build dir so unprivileged
+ # processes can write gcda files with coverage stats
+ setfacl -R -m 'd:o:rwX' -m 'o:rwX' "${initdir}/${BUILD_DIR:?}/"
fi
}
@@ -1384,6 +1387,20 @@ check_coverage_reports() {
lcov --remove "${dest}" -o "${dest}" '/usr/include/*' '/usr/lib/*'
fi
+ # If the test logs contain lines like:
+ #
+ # ...systemd-resolved[735885]: profiling:/systemd-meson-build/src/shared/libsystemd-shared-250.a.p/base-filesystem.c.gcda:Cannot open
+ #
+ # it means we're possibly missing some coverage since gcov can't write the stats,
+ # usually due to the sandbox being too restrictive (e.g. ProtectSystem=yes,
+ # ProtectHome=yes) or the $BUILD_DIR being inaccessible to non-root users - see
+ # `setfacl` stuff in install_compiled_systemd().
+
+ if "${JOURNALCTL:?}" -q --no-pager -D "${root:?}/var/log/journal" --grep "profiling:.+?gcda:[Cc]annot open"; then
+ derror "Detected possibly missing coverage, check the journal"
+ return 1
+ fi
+
return 0
}