1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00

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).
This commit is contained in:
Frantisek Sumsal 2023-05-14 11:28:30 +02:00
parent ceea144ed8
commit 3b2823a749
2 changed files with 6 additions and 5 deletions

View File

@ -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"

View File

@ -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