summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2023-05-14 11:28:30 +0200
committerFrantisek Sumsal <frantisek@sumsal.cz>2023-05-14 19:32:07 +0200
commit3b2823a7497f3d851235ab86d8c9f5658c9996b6 (patch)
treeae07d5e1aea368002c0d3e8f572a07eac38d947e /test
parentceea144ed8b21bbad6a8db6658874d147416cbfa (diff)
downloadsystemd-3b2823a7497f3d851235ab86d8c9f5658c9996b6.tar.gz
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).
Diffstat (limited to 'test')
-rwxr-xr-xtest/TEST-13-NSPAWN-SMOKE/test.sh5
-rw-r--r--test/test-functions6
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 f607c2733b..8352541b17 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 b7c21a9d13..0bd011b2ed 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