]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use test-sleep executable in softreboot and coredump tests 40086/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 15 Dec 2025 09:20:28 +0000 (18:20 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 15 Dec 2025 09:20:53 +0000 (18:20 +0900)
This partially reverts 355bcc243ca30dd56ab142d5bfb5579c312192ca.

test/units/TEST-82-SOFTREBOOT.sh
test/units/TEST-87-AUX-UTILS-VM.coredump.sh

index 378ac2a2a296d0bf8baf9d045a44e52d3d212d87..03f6b78e57fb1d6946144d3cd1acd8dbc93895e2 100755 (executable)
@@ -90,16 +90,12 @@ if [ -f /run/TEST-82-SOFTREBOOT.touch3 ]; then
 
     # Check that the surviving services are still around
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive.service)" = "active"
-    if [[ ! -L $(command -v sleep) ]]; then
-        test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
-    fi
+    test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive-sigterm.service)" != "active"
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive.service)" != "active"
 
     [[ ! -e /run/credentials/TEST-82-SOFTREBOOT-nosurvive.service ]]
-    if [[ ! -L $(command -v sleep) ]]; then
-        assert_eq "$(cat /run/credentials/TEST-82-SOFTREBOOT-survive-argv.service/preserve)" "yay"
-    fi
+    assert_eq "$(cat /run/credentials/TEST-82-SOFTREBOOT-survive-argv.service/preserve)" "yay"
 
     # There may be huge amount of pending messages in sockets. Processing them may cause journal rotation and
     # removal of old archived journal files. If a journal file is removed during journalctl reading it,
@@ -134,9 +130,7 @@ elif [ -f /run/TEST-82-SOFTREBOOT.touch2 ]; then
 
     # Check that the surviving services are still around
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive.service)" = "active"
-    if [[ ! -L $(command -v sleep) ]]; then
-        test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
-    fi
+    test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive-sigterm.service)" != "active"
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive.service)" != "active"
 
@@ -192,9 +186,7 @@ elif [ -f /run/TEST-82-SOFTREBOOT.touch ]; then
 
     # Check that the surviving services are still around
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive.service)" = "active"
-    if [[ ! -L $(command -v sleep) ]]; then
-        test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
-    fi
+    test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-survive-argv.service)" = "active"
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive-sigterm.service)" != "active"
     test "$(systemctl show -P ActiveState TEST-82-SOFTREBOOT-nosurvive.service)" != "active"
 
@@ -261,7 +253,9 @@ EOF
 #!/usr/bin/env bash
 systemd-notify --ready
 rm "$survive_argv"
-exec -a @sleep sleep infinity
+# Here, we use our own sleep implementation, to support coreutils built with
+#  --enable-single-binary=symlinks, in that case we cannot rename COMM of sleep command.
+exec -a @sleep /usr/lib/systemd/tests/unit-tests/manual/test-sleep infinity
 EOF
     chmod +x "$survive_argv"
     # This sets DefaultDependencies=no so that they remain running until the very end, and
@@ -282,17 +276,15 @@ EOF
     # soft reboots due to journald being temporarily stopped.
     # Note, when coreutils is built with --enable-single-binary=symlinks, unfortunately we cannot freely rename
     # sleep command, hence we cannot test the feature.
-    if [[ ! -L $(command -v sleep) ]]; then
-        systemd-run --service-type=notify --unit=TEST-82-SOFTREBOOT-survive-argv.service \
-            --property SurviveFinalKillSignal=no \
-            --property IgnoreOnIsolate=yes \
-            --property DefaultDependencies=no \
-            --property After=basic.target \
-            --property "Conflicts=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
-            --property "Before=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
-            --property SetCredential=preserve:yay \
-            "$survive_argv"
-    fi
+    systemd-run --service-type=notify --unit=TEST-82-SOFTREBOOT-survive-argv.service \
+        --property SurviveFinalKillSignal=no \
+        --property IgnoreOnIsolate=yes \
+        --property DefaultDependencies=no \
+        --property After=basic.target \
+        --property "Conflicts=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
+        --property "Before=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
+        --property SetCredential=preserve:yay \
+        "$survive_argv"
     # shellcheck disable=SC2016
     systemd-run --service-type=exec --unit=TEST-82-SOFTREBOOT-survive.service \
         --property TemporaryFileSystem="/run /tmp /var" \
index 1b37197bde0ac5ff9be32acc2dcd023cb60ae280..b3f702a2b0d7fe73a5e0234ef637f820147a6425 100755 (executable)
@@ -6,11 +6,6 @@ set -o pipefail
 # shellcheck source=test/units/util.sh
 . "$(dirname "$0")"/util.sh
 
-if [[ -L $(command -v sleep) ]]; then
-    # coreutils is built with --enable-single-binary=symlinks, and we cannot rename it.
-    exit 0
-fi
-
 # Make sure the binary name fits into 15 characters
 CORE_TEST_BIN="/tmp/test-dump"
 CORE_TEST_UNPRIV_BIN="/tmp/test-usr-dump"
@@ -35,8 +30,8 @@ sysctl kernel.core_pattern | grep systemd-coredump
 
 # Prepare "fake" binaries for coredumps, so we can properly exercise
 # the matching stuff too
-cp -vf /bin/sleep "${CORE_TEST_BIN:?}"
-cp -vf /bin/sleep "${CORE_TEST_UNPRIV_BIN:?}"
+cp -vf /usr/lib/systemd/tests/unit-tests/manual/test-sleep "${CORE_TEST_BIN:?}"
+cp -vf /usr/lib/systemd/tests/unit-tests/manual/test-sleep "${CORE_TEST_UNPRIV_BIN:?}"
 # Simple script that spawns given "fake" binary and then kills it with
 # given signal
 cat >"${MAKE_DUMP_SCRIPT:?}" <<\EOF