mirror of
https://github.com/systemd/systemd
synced 2024-09-06 00:41:36 +00: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:
parent
ceea144ed8
commit
3b2823a749
|
@ -5,11 +5,6 @@ set -e
|
||||||
TEST_DESCRIPTION="systemd-nspawn smoke test"
|
TEST_DESCRIPTION="systemd-nspawn smoke test"
|
||||||
IMAGE_NAME="nspawn"
|
IMAGE_NAME="nspawn"
|
||||||
TEST_NO_NSPAWN=1
|
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
|
# shellcheck source=test/test-functions
|
||||||
. "${TEST_BASE_DIR:?}/test-functions"
|
. "${TEST_BASE_DIR:?}/test-functions"
|
||||||
|
|
|
@ -1251,6 +1251,12 @@ install_systemd() {
|
||||||
# Ditto, but for the user daemon
|
# Ditto, but for the user daemon
|
||||||
mkdir -p "$initdir/etc/systemd/user/test-.service.d/"
|
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"
|
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
|
fi
|
||||||
|
|
||||||
# If we're built with -Dportabled=false, tests with systemd-analyze
|
# If we're built with -Dportabled=false, tests with systemd-analyze
|
||||||
|
|
Loading…
Reference in a new issue