summaryrefslogtreecommitdiffstats
path: root/test/testsuite-16.units/extend-timeout.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:49:52 +0000
commit55944e5e40b1be2afc4855d8d2baf4b73d1876b5 (patch)
tree33f869f55a1b149e9b7c2b7e201867ca5dd52992 /test/testsuite-16.units/extend-timeout.sh
parentInitial commit. (diff)
downloadsystemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.tar.xz
systemd-55944e5e40b1be2afc4855d8d2baf4b73d1876b5.zip
Adding upstream version 255.4.upstream/255.4
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test/testsuite-16.units/extend-timeout.sh')
-rwxr-xr-xtest/testsuite-16.units/extend-timeout.sh63
1 files changed, 63 insertions, 0 deletions
diff --git a/test/testsuite-16.units/extend-timeout.sh b/test/testsuite-16.units/extend-timeout.sh
new file mode 100755
index 0000000..45a18b9
--- /dev/null
+++ b/test/testsuite-16.units/extend-timeout.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: LGPL-2.1-or-later
+set -eux
+set -o pipefail
+
+# sleep interval (seconds)
+sleep_interval="${sleep_interval:-1}"
+# extend_timeout_interval second(s)
+extend_timeout_interval="${extend_timeout_interval:-1}"
+# number of sleep_intervals before READY=1
+start_intervals="${start_intervals:-10}"
+# number of sleep_intervals before exiting
+stop_intervals="${stop_intervals:-10}"
+# run intervals, number of sleep_intervals to run
+run_intervals="${run_intervals:-7}"
+
+# We convert to usec
+extend_timeout_interval=$((extend_timeout_interval * 1000000))
+
+# shellcheck disable=SC2064
+trap "{ touch /${SERVICE}.terminated; exit 1; }" SIGTERM SIGABRT
+
+rm -f "/${SERVICE}".*
+touch "/${SERVICE}.startfail"
+
+systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
+while [[ $start_intervals -gt 0 ]]
+do
+ sleep "$sleep_interval"
+ start_intervals=$((start_intervals - 1))
+ systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
+done
+
+systemd-notify --ready --status="Waiting for your request"
+
+touch "/${SERVICE}.runtimefail"
+rm "/${SERVICE}.startfail"
+
+systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
+while [[ $run_intervals -gt 0 ]]
+do
+ sleep "$sleep_interval"
+ run_intervals=$((run_intervals - 1))
+ systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
+done
+
+systemd-notify STOPPING=1
+
+touch "/${SERVICE}.stopfail"
+rm "/${SERVICE}.runtimefail"
+
+systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
+while [[ $stop_intervals -gt 0 ]]
+do
+ sleep "$sleep_interval"
+ stop_intervals=$((stop_intervals - 1))
+ systemd-notify EXTEND_TIMEOUT_USEC="$extend_timeout_interval"
+done
+
+touch "/${SERVICE}.success"
+rm "/${SERVICE}.stopfail"
+
+exit 0