From 28826f6ba9e93ce7f8e153dd3e0f26adcc5c9cdf Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 15 Dec 2025 18:20:28 +0900 Subject: [PATCH] test: use test-sleep executable in softreboot and coredump tests This partially reverts 355bcc243ca30dd56ab142d5bfb5579c312192ca. --- test/units/TEST-82-SOFTREBOOT.sh | 40 +++++++++------------ test/units/TEST-87-AUX-UTILS-VM.coredump.sh | 9 ++--- 2 files changed, 18 insertions(+), 31 deletions(-) diff --git a/test/units/TEST-82-SOFTREBOOT.sh b/test/units/TEST-82-SOFTREBOOT.sh index 378ac2a2a29..03f6b78e57f 100755 --- a/test/units/TEST-82-SOFTREBOOT.sh +++ b/test/units/TEST-82-SOFTREBOOT.sh @@ -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" \ diff --git a/test/units/TEST-87-AUX-UTILS-VM.coredump.sh b/test/units/TEST-87-AUX-UTILS-VM.coredump.sh index 1b37197bde0..b3f702a2b0d 100755 --- a/test/units/TEST-87-AUX-UTILS-VM.coredump.sh +++ b/test/units/TEST-87-AUX-UTILS-VM.coredump.sh @@ -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 -- 2.47.3