From: Frantisek Sumsal Date: Tue, 23 Jun 2026 19:29:53 +0000 (+0200) Subject: test: skip fdstore tests if test-fdstore is not available X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=926bf653591ed34aed21948f9fcebd7ae90d9f0e;p=thirdparty%2Fsystemd.git test: skip fdstore tests if test-fdstore is not available 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. --- diff --git a/mkosi/mkosi.images/minimal-base/mkosi.postinst b/mkosi/mkosi.images/minimal-base/mkosi.postinst index 7cb50ad97f4..3c85fe1b720 100755 --- a/mkosi/mkosi.images/minimal-base/mkosi.postinst +++ b/mkosi/mkosi.images/minimal-base/mkosi.postinst @@ -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 diff --git a/test/units/TEST-13-NSPAWN.unpriv.sh b/test/units/TEST-13-NSPAWN.unpriv.sh index 086b1fe6f6f..f51de0018e4 100755 --- a/test/units/TEST-13-NSPAWN.unpriv.sh +++ b/test/units/TEST-13-NSPAWN.unpriv.sh @@ -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 diff --git a/test/units/TEST-91-LIVEUPDATE.sh b/test/units/TEST-91-LIVEUPDATE.sh index a295c4c230d..9fba388cfa5 100755 --- a/test/units/TEST-91-LIVEUPDATE.sh +++ b/test/units/TEST-91-LIVEUPDATE.sh @@ -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 </run/systemd/nspawn/fdstore.nspawn <&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 </run/systemd/nspawn/fdstore.nspawn <&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