From 3b2823a7497f3d851235ab86d8c9f5658c9996b6 Mon Sep 17 00:00:00 2001 From: Frantisek Sumsal Date: Sun, 14 May 2023 11:28:30 +0200 Subject: [PATCH] test: bind mount the $BUILD_DIR into nspawn containers when collecting coverage. This applies only to containers started via machinectl (or directly via the systemd-nspawn@.service unit). --- test/TEST-13-NSPAWN-SMOKE/test.sh | 5 ----- test/test-functions | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/test/TEST-13-NSPAWN-SMOKE/test.sh b/test/TEST-13-NSPAWN-SMOKE/test.sh index f607c2733b2..8352541b172 100755 --- a/test/TEST-13-NSPAWN-SMOKE/test.sh +++ b/test/TEST-13-NSPAWN-SMOKE/test.sh @@ -5,11 +5,6 @@ set -e TEST_DESCRIPTION="systemd-nspawn smoke test" IMAGE_NAME="nspawn" TEST_NO_NSPAWN=1 -# The test containers are missing the $BUILD_DIR with the necessary note files -# which generates lots of errors regarding missing coverage. Since fixing this -# would make the test code unnecessarily messy, let's just ignore them, at least -# for now. -IGNORE_MISSING_COVERAGE=yes # shellcheck source=test/test-functions . "${TEST_BASE_DIR:?}/test-functions" diff --git a/test/test-functions b/test/test-functions index b7c21a9d130..0bd011b2ed4 100644 --- a/test/test-functions +++ b/test/test-functions @@ -1251,6 +1251,12 @@ install_systemd() { # Ditto, but for the user daemon mkdir -p "$initdir/etc/systemd/user/test-.service.d/" echo -ne "[Service]\nReadWritePaths=${BUILD_DIR:?}\n" >"$initdir/etc/systemd/user/test-.service.d/99-gcov-rwpaths-override.conf" + # Bind the $BUILD_DIR into nspawn containers that are executed using + # machinectl. Unfortunately, the .nspawn files don't support drop-ins + # so we have to inject the bind mount directly into + # the systemd-nspawn@.service unit. + cp "$initdir/usr/lib/systemd/system/systemd-nspawn@.service" "$initdir/etc/systemd/system/systemd-nspawn@.service" + sed -ri "s/^ExecStart=.+$/& --bind=${BUILD_DIR//\//\\\/}/" "$initdir/etc/systemd/system/systemd-nspawn@.service" fi # If we're built with -Dportabled=false, tests with systemd-analyze