]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: skip fdstore tests if test-fdstore is not available
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 23 Jun 2026 19:29:53 +0000 (21:29 +0200)
committerLuca Boccassi <luca.boccassi@gmail.com>
Tue, 23 Jun 2026 22:04:47 +0000 (23:04 +0100)
When the test suite is run in the "standalone" mode, the minimal
container might not contain the test-fdstore binary that's needed for a
couple of tests. Since installing systemd-tests into the minimal
container pulls in a lot of other dependencies, let's just skip the
affected tests instead to avoid this.

mkosi/mkosi.images/minimal-base/mkosi.postinst
test/units/TEST-13-NSPAWN.unpriv.sh
test/units/TEST-91-LIVEUPDATE.sh

index 7cb50ad97f4e50a0d2528e1d12056d789d65b3c8..3c85fe1b72090d74c941af777e63b4c5b11f7441 100755 (executable)
@@ -24,4 +24,6 @@ elif [[ -x "$BUILDROOT/usr/lib/systemd/tests/unit-tests/manual/test-fdstore" ]];
     cp "$BUILDROOT/usr/lib/systemd/tests/unit-tests/manual/test-fdstore" "$BUILDROOT/usr/bin/test-fdstore"
 elif [[ -x /usr/lib/systemd/tests/unit-tests/manual/test-fdstore ]]; then
     cp /usr/lib/systemd/tests/unit-tests/manual/test-fdstore "$BUILDROOT/usr/bin/test-fdstore"
+else
+    echo >&2 "WARNING: test-fdstore binary not found, fdstore container tests will be skipped"
 fi
index 086b1fe6f6f78115d5901e079c0b094f4ebfe6f1..f51de0018e4945a8ca8eb4f70b1b219656d93c1c 100755 (executable)
@@ -37,6 +37,7 @@ at_exit() {
     rm -rf /var/tmp/mangletest
     rm -f /var/tmp/mangletest.tar.gz
     rm -f /shouldnotwork
+    loginctl disable-linger testuser
 }
 
 trap at_exit EXIT
@@ -316,6 +317,10 @@ cmp /var/tmp/mangletest/mangletest-0.1/usr/lib/os-release /home/testuser/.local/
 # Then restart the nspawn service and verify the inner payload actually
 # receives the preserved fds back via LISTEN_FDS, with their original content.
 create_dummy_container /home/testuser/.local/state/machines/fdstore
+if [[ ! -x /home/testuser/.local/state/machines/fdstore/usr/bin/test-fdstore ]]; then
+    echo >&2 "test-fdstore not available in the minimal container, skipping fdstore tests"
+    exit 0
+fi
 # The container init execs the helper directly so the FDSTORE notification is
 # sent from PID 1 (nspawn rejects notify messages from anyone but the inner
 # payload's init). The helper itself execs sleep on success to keep the
@@ -404,5 +409,3 @@ assert_eq "$(run0 -u testuser systemctl --user show -P SubState systemd-nspawn@f
 run0 -u testuser systemctl --user reset-failed systemd-nspawn@fdstore.service
 
 machinectl terminate fdstore 2>/dev/null || true
-
-loginctl disable-linger testuser
index a295c4c230d6f85bf85eac1bdfa1242839cd0576..9fba388cfa53bd93ae0fa0d7133b4aa7c61c711b 100755 (executable)
@@ -112,21 +112,25 @@ if grep -qw luo_nboot=1 /proc/cmdline; then
     # then forwards the preserved fds via LISTEN_FDS to a fresh nspawn payload,
     # which verifies the content is intact.
     create_dummy_container /var/lib/machines/fdstore
-    cat >/var/lib/machines/fdstore/sbin/init <<'EOF'
+    if [[ -x /var/lib/machines/fdstore/usr/bin/test-fdstore ]]; then
+        cat >/var/lib/machines/fdstore/sbin/init <<'EOF'
 #!/usr/bin/env bash
 set -e
 exec /usr/bin/test-fdstore check
 EOF
-    chmod +x /var/lib/machines/fdstore/sbin/init
-    mkdir -p /run/systemd/nspawn
-    cat >/run/systemd/nspawn/fdstore.nspawn <<EOF
+        chmod +x /var/lib/machines/fdstore/sbin/init
+        mkdir -p /run/systemd/nspawn
+        cat >/run/systemd/nspawn/fdstore.nspawn <<EOF
 [Exec]
 KillSignal=SIGTERM
 EOF
-    n_nspawn_fds=$(systemctl show -P NFileDescriptorStore systemd-nspawn@fdstore.service)
-    test "${n_nspawn_fds}" -ge 2
-    systemctl start systemd-nspawn@fdstore.service
-    systemctl is-active systemd-nspawn@fdstore.service
+        n_nspawn_fds=$(systemctl show -P NFileDescriptorStore systemd-nspawn@fdstore.service)
+        test "${n_nspawn_fds}" -ge 2
+        systemctl start systemd-nspawn@fdstore.service
+        systemctl is-active systemd-nspawn@fdstore.service
+    else
+        echo >&2 "test-fdstore not available in the minimal container, skipping fdstore tests"
+    fi
 
     # late.service: rewrite the fragment with the second-boot ExecStart and
     # exercise the daemon-reload + daemon-reexec preservation paths.
@@ -271,22 +275,26 @@ else
     #   → LUO → after kexec PID 1 restores the fdstore → systemd-nspawn →
     #   payload verifies content matches.
     create_dummy_container /var/lib/machines/fdstore
-    cat >/var/lib/machines/fdstore/sbin/init <<'EOF'
+    if [[ -x /var/lib/machines/fdstore/usr/bin/test-fdstore ]]; then
+        cat >/var/lib/machines/fdstore/sbin/init <<'EOF'
 #!/usr/bin/env bash
 set -e
 exec /usr/bin/test-fdstore store
 EOF
-    chmod +x /var/lib/machines/fdstore/sbin/init
+        chmod +x /var/lib/machines/fdstore/sbin/init
 
-    mkdir -p /run/systemd/nspawn
-    cat >/run/systemd/nspawn/fdstore.nspawn <<EOF
+        mkdir -p /run/systemd/nspawn
+        cat >/run/systemd/nspawn/fdstore.nspawn <<EOF
 [Exec]
 KillSignal=SIGTERM
 EOF
 
-    systemctl start systemd-nspawn@fdstore.service
-    timeout 30s bash -c \
-        "until [[ \"\$(systemctl show -P NFileDescriptorStore systemd-nspawn@fdstore.service)\" -ge 2 ]]; do sleep 0.5; done"
+        systemctl start systemd-nspawn@fdstore.service
+        timeout 30s bash -c \
+            "until [[ \"\$(systemctl show -P NFileDescriptorStore systemd-nspawn@fdstore.service)\" -ge 2 ]]; do sleep 0.5; done"
+    else
+        echo >&2 "test-fdstore not available in the minimal container, skipping fdstore tests"
+    fi
 
     # Negative path: store a fd store entry that holds a child LUO session named
     # like PID 1's own ("systemd"). On kexec PID 1 must refuse to serialize it