]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
TEST-80-NOTIFYACCESS: add test case for #37515 39376/head
authorMike Yuan <me@yhndnzj.com>
Tue, 21 Oct 2025 23:34:04 +0000 (01:34 +0200)
committerMike Yuan <me@yhndnzj.com>
Tue, 4 Nov 2025 11:18:34 +0000 (12:18 +0100)
test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.service [new file with mode: 0644]
test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.sh [new file with mode: 0755]
test/units/TEST-80-NOTIFYACCESS.sh

diff --git a/test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.service b/test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.service
new file mode 100644 (file)
index 0000000..95a501e
--- /dev/null
@@ -0,0 +1,4 @@
+[Service]
+Type=notify-reload
+TimeoutStartSec=40
+ExecStart=/usr/lib/systemd/tests/testdata/TEST-80-NOTIFYACCESS.units/reload-timeout.sh
diff --git a/test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.sh b/test/integration-tests/TEST-80-NOTIFYACCESS/TEST-80-NOTIFYACCESS.units/reload-timeout.sh
new file mode 100755 (executable)
index 0000000..266c3cf
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+# shellcheck disable=SC2016
+set -eux
+set -o pipefail
+
+COUNTER=0
+
+sync_in() {
+    read -r x < /tmp/syncfifo2
+    test "$x" = "$1"
+}
+
+wait_for_signal() {
+    sleep infinity &
+    wait "$!" || :
+}
+
+sighup_handler() {
+    echo "hup$(( ++COUNTER ))" > /tmp/syncfifo1
+}
+
+trap sighup_handler SIGHUP
+
+export SYSTEMD_LOG_LEVEL=debug
+
+systemd-notify --ready
+
+wait_for_signal
+systemd-notify --reloading
+
+wait_for_signal
+systemd-notify --reloading
+sync_in ready
+systemd-notify --ready
+
+wait_for_signal
+systemd-notify --reloading --ready
+
+exec sleep infinity
index a8ecd9fa7091a2c3fd0bbaf1d511c9f62950072e..22a5a3af80d05ff4ebf9226602cd201bdcdf4d74 100755 (executable)
@@ -62,6 +62,33 @@ assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "none"
 systemctl stop notify.service
 assert_eq "$(systemctl show notify.service -p NotifyAccess --value)" "all"
 
+# Timeout of READY=1 for Type=notify-reload services (issue #37515)
+
+systemctl start reload-timeout.service
+
+systemctl reload --no-block reload-timeout.service
+timeout 10 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "reload-signal" ]]; do sleep .5; done'
+sync_in hup1
+timeout 10 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "reload-notify" ]]; do sleep .5; done'
+timeout 80 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "running" ]]; do sleep 5; done'
+assert_eq "$(systemctl show reload-timeout.service -P ReloadResult)" "timeout"
+
+systemctl reload --no-block reload-timeout.service
+timeout 10 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "reload-signal" ]]; do sleep .5; done'
+assert_eq "$(systemctl show reload-timeout.service -P ReloadResult)" "success"
+sync_in hup2
+timeout 10 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "reload-notify" ]]; do sleep .5; done'
+sync_out ready
+timeout 40 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "running" ]]; do sleep 1; done'
+assert_eq "$(systemctl show reload-timeout.service -P ReloadResult)" "success"
+
+systemctl reload --no-block reload-timeout.service
+sync_in hup3
+timeout 40 bash -c 'until [[ $(systemctl show reload-timeout.service -P SubState) == "running" ]]; do sleep 1; done'
+assert_eq "$(systemctl show reload-timeout.service -P ReloadResult)" "success"
+
+systemctl stop reload-timeout.service
+
 rm /tmp/syncfifo1 /tmp/syncfifo2
 
 # Explicitly test busctl's BUSERROR= reporting and systemctl status should show it