]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: bind mount the $BUILD_DIR into nspawn containers
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 14 May 2023 09:28:30 +0000 (11:28 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sun, 14 May 2023 17:32:07 +0000 (19:32 +0200)
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
test/test-functions

index f607c2733b23e00c5b5c4062fa7eccbf33b49fbc..8352541b17272e99e4fc75e3212021782dfefe6a 100755 (executable)
@@ -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"
index b7c21a9d130ca2355754f3bcf962bb0deb71d33e..0bd011b2ed45005d2c11d5df84690baa4fb806cf 100644 (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