test: merge unit file related tests into TEST-23-UNIT-FILE

Rename TEST-23-TYPE-EXEC to TEST-23-UNIT-FILE and merge it with
following tests:
  - TEST-37-RUNTIMEDIRECTORYPRESERV
  - TEST-40-EXEC-COMMAND-EX
  - TEST-41-ONESHOT-RESTART
  - TEST-42-EXECSTOPPOST
  - TEST-57-ONSUCCESS-UPHOLD
This commit is contained in:
Frantisek Sumsal 2023-05-08 22:38:34 +02:00 committed by Yu Watanabe
parent 97211510b0
commit 539af5c441
44 changed files with 262 additions and 325 deletions

View file

@ -2,7 +2,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test Type=exec"
TEST_DESCRIPTION="Tests for various unit file settings"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"

View file

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View file

@ -1,12 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
set -e
TEST_DESCRIPTION="test RuntimeDirectoryPreserve=yes"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View file

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Test ExecReload= (PR #13098)"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View file

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test ExecXYZEx= service unit dbus hookups"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View file

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="Test oneshot unit restart on failure"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View file

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View file

@ -1,10 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test that ExecStopPost= is always run"
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
do_test "$@"

View file

@ -1 +0,0 @@
../TEST-01-BASIC/Makefile

View file

@ -1,9 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -e
TEST_DESCRIPTION="test OnSuccess= + Uphold= + PropagatesStopTo= + BindsTo="
# shellcheck source=test/test-functions
. "$TEST_BASE_DIR/test-functions"
do_test "$@" 57

View file

@ -1,10 +1,10 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Unit with BindsTo=
BindsTo=testsuite-57-bound-by.service
After=testsuite-57-bound-by.service
BindsTo=testsuite-23-bound-by.service
After=testsuite-23-bound-by.service
[Service]
ExecStart=/bin/sleep infinity
# --kill-who= (no 'm') to check that the short form is accepted
ExecStopPost=systemctl kill --kill-who=main -sRTMIN+1 testsuite-57.service
ExecStopPost=systemctl kill --kill-who=main -sRTMIN+1 testsuite-23.service

View file

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Failing unit
OnFailure=testsuite-57-uphold.service
OnFailure=testsuite-23-uphold.service
[Service]
ExecStart=/bin/false

View file

@ -0,0 +1,10 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Stop Propagation Receiver
Wants=testsuite-23-prop-stop-two.service
After=testsuite-23-prop-stop-two.service
StopPropagatedFrom=testsuite-23-prop-stop-two.service
[Service]
ExecStart=/bin/sleep infinity
ExecStopPost=systemctl kill --kill-whom=main -sUSR2 testsuite-23.service

View file

@ -5,5 +5,5 @@ Description=Failed Dependency Unit
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/sh -c "if [ -f /tmp/testsuite-57-retry-fail ]; then exit 0; else exit 1; fi"
ExecStart=/bin/sh -c "if [ -f /tmp/testsuite-23-retry-fail ]; then exit 0; else exit 1; fi"
Restart=no

View file

@ -1,8 +1,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Upheld Unit
Requires=testsuite-57-retry-fail.service
After=testsuite-57-retry-fail.service
Requires=testsuite-23-retry-fail.service
After=testsuite-23-retry-fail.service
[Service]
Type=oneshot

View file

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Upholding Unit
Upholds=testsuite-57-retry-upheld.service
Upholds=testsuite-23-retry-upheld.service
[Service]
ExecStart=/bin/sleep infinity

View file

@ -8,4 +8,4 @@ StartLimitBurst=15
StartLimitIntervalSec=1h
[Service]
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-57-short-lived.sh
ExecStart=/usr/lib/systemd/tests/testdata/units/testsuite-23-short-lived.sh

View file

@ -0,0 +1,18 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -ex
if [ -f /tmp/testsuite-23.counter ] ; then
read -r counter < /tmp/testsuite-23.counter
counter=$((counter + 1))
else
counter=0
fi
echo "$counter" >/tmp/testsuite-23.counter
if [ "$counter" -eq 5 ] ; then
systemctl kill --kill-whom=main -sUSR1 testsuite-23.service
fi
exec sleep 1.5

View file

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Succeeding unit
OnSuccess=testsuite-57-fail.service
OnSuccess=testsuite-23-fail.service
[Service]
ExecStart=/bin/true

View file

@ -1,7 +1,7 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Upholding Unit
Upholds=testsuite-57-short-lived.service
Upholds=testsuite-23-short-lived.service
[Service]
ExecStart=/bin/sleep infinity

View file

@ -3,6 +3,8 @@
set -eux
set -o pipefail
# Test ExecReload= (PR #13098)
systemd-analyze log-level debug
export SYSTEMD_PAGER=
@ -57,7 +59,3 @@ systemctl status "$SERVICE_NAME"
systemctl stop "$SERVICE_NAME"
systemd-analyze log-level info
echo OK >/testok
exit 0

View file

@ -2,6 +2,8 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
# Test that ExecStopPost= is always run
systemd-analyze log-level debug
systemd-run --unit=simple1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple \
@ -100,7 +102,3 @@ test -f /run/idle1
test -f /run/idle2
systemd-analyze log-level info
echo OK >/testok
exit 0

View file

@ -5,6 +5,8 @@
set -eux
set -o pipefail
# Test RuntimeDirectoryPreserve=yes
systemd-mount -p RuntimeDirectory=hoge -p RuntimeDirectoryPreserve=yes -t tmpfs tmpfs /tmp/aaa
touch /run/hoge/foo
@ -14,7 +16,3 @@ systemctl restart tmp-aaa.mount
test -e /run/hoge/foo
test ! -e /tmp/aaa/bbb
echo OK >/testok
exit 0

View file

@ -0,0 +1,96 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
# Test OnSuccess= + Uphold= + PropagatesStopTo= + BindsTo=
systemd-analyze log-level debug
systemd-analyze log-target journal
# Idea is this:
# 1. we start testsuite-23-success.service
# 2. which through OnSuccess= starts testsuite-23-fail.service,
# 3. which through OnFailure= starts testsuite-23-uphold.service,
# 4. which through Uphold= starts/keeps testsuite-23-short-lived.service running,
# 5. which will sleep 1s when invoked, and on the 5th invocation send us a SIGUSR1
# 6. once we got that we finish cleanly
sigusr1=0
trap sigusr1=1 SIGUSR1
trap -p SIGUSR1
systemctl start testsuite-23-success.service
while [ "$sigusr1" -eq 0 ] ; do
sleep .5
done
systemctl stop testsuite-23-uphold.service
# Idea is this:
# 1. we start testsuite-23-retry-uphold.service
# 2. which through Uphold= starts testsuite-23-retry-upheld.service
# 3. which through Requires= starts testsuite-23-retry-fail.service
# 4. which fails as /tmp/testsuite-23-retry-fail does not exist, so testsuite-23-retry-upheld.service
# is no longer restarted
# 5. we create /tmp/testsuite-23-retry-fail
# 6. now testsuite-23-retry-upheld.service will be restarted since upheld, and its dependency will
# be satisfied
rm -f /tmp/testsuite-23-retry-fail
systemctl start testsuite-23-retry-uphold.service
while ! systemctl is-failed testsuite-23-retry-fail.service ; do
sleep .5
done
systemctl is-active testsuite-23-retry-upheld.service && { echo 'unexpected success'; exit 1; }
touch /tmp/testsuite-23-retry-fail
while ! systemctl is-active testsuite-23-retry-upheld.service ; do
sleep .5
done
systemctl stop testsuite-23-retry-uphold.service testsuite-23-retry-fail.service testsuite-23-retry-upheld.service
# Idea is this:
# 1. we start testsuite-23-prop-stop-one.service
# 2. which through Wants=/After= pulls in testsuite-23-prop-stop-two.service as well
# 3. testsuite-23-prop-stop-one.service then sleeps indefinitely
# 4. testsuite-23-prop-stop-two.service sleeps a short time and exits
# 5. the StopPropagatedFrom= dependency between the two should ensure *both* will exit as result
# 6. an ExecStopPost= line on testsuite-23-prop-stop-one.service will send us a SIGUSR2
# 7. once we got that we finish cleanly
sigusr2=0
trap sigusr2=1 SIGUSR2
systemctl start testsuite-23-prop-stop-one.service
while [ "$sigusr2" -eq 0 ] ; do
sleep .5
done
# Idea is this:
# 1. we start testsuite-23-binds-to.service
# 2. which through BindsTo=/After= pulls in testsuite-23-bound-by.service as well
# 3. testsuite-23-bound-by.service suddenly dies
# 4. testsuite-23-binds-to.service should then also be pulled down (it otherwise just hangs)
# 6. an ExecStopPost= line on testsuite-23-binds-to.service will send us a SIGRTMIN1+1
# 7. once we got that we finish cleanly
sigrtmin1=0
trap sigrtmin1=1 SIGRTMIN+1
systemctl start testsuite-23-binds-to.service
while [ "$sigrtmin1" -eq 0 ] ; do
sleep .5
done
systemd-analyze log-level info

View file

@ -3,6 +3,8 @@
set -eux
set -o pipefail
# Test ExecXYZEx= service unit dbus hookups
systemd-analyze log-level debug
declare -A property
@ -40,7 +42,3 @@ for c in "${!property_ex[@]}"; do
done
systemd-analyze log-level info
echo OK >/testok
exit 0

View file

@ -3,19 +3,21 @@
set -eux
set -o pipefail
# Test oneshot unit restart on failure
# wait this many secs for each test service to succeed in what is being tested
MAX_SECS=60
systemd-analyze log-level debug
# test one: Restart=on-failure should restart the service
(! systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1")
(! systemd-run --unit=oneshot-restart-one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1")
for ((secs = 0; secs < MAX_SECS; secs++)); do
[[ "$(systemctl show one.service -P NRestarts)" -le 0 ]] || break
[[ "$(systemctl show oneshot-restart-one.service -P NRestarts)" -le 0 ]] || break
sleep 1
done
if [[ "$(systemctl show one.service -P NRestarts)" -le 0 ]]; then
if [[ "$(systemctl show oneshot-restart-one.service -P NRestarts)" -le 0 ]]; then
exit 1
fi
@ -25,7 +27,7 @@ TMP_FILE="/tmp/test-41-oneshot-restart-test"
# test two: make sure StartLimitBurst correctly limits the number of restarts
# and restarts execution of the unit from the first ExecStart=
(! systemd-run --unit=two \
(! systemd-run --unit=oneshot-restart-two \
-p StartLimitIntervalSec=120 \
-p StartLimitBurst=3 \
-p Type=oneshot \
@ -48,7 +50,3 @@ if [[ $(cat $TMP_FILE) != "aaa" ]]; then
fi
systemd-analyze log-level info
echo OK >/testok
exit 0

View file

@ -3,63 +3,64 @@
set -eux
set -o pipefail
systemd-analyze log-level debug
: >/failed
# Create a binary for which execve() will fail
touch /tmp/brokenbinary
chmod +x /tmp/brokenbinary
declare -i CHILD_PID=0
# These three commands should succeed.
systemd-run --unit=one -p Type=simple /bin/sleep infinity
systemd-run --unit=two -p Type=simple -p User=idontexist /bin/sleep infinity
systemd-run --unit=three -p Type=simple /tmp/brokenbinary
# Note: all the signal shenanigans are necessary for the Upholds= tests
# And now, do the same with Type=exec, where the latter two should fail
systemd-run --unit=four -p Type=exec /bin/sleep infinity
(! systemd-run --unit=five -p Type=exec -p User=idontexist /bin/sleep infinity)
(! systemd-run --unit=six -p Type=exec /tmp/brokenbinary)
# Like trap, but passes the signal name as the first argument
trap_with_sig() {
local fun="${1:?}"
local sig
shift
systemd-run --unit=seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec /bin/sleep infinity
# Both TERM and SIGINT happen to have the same number on all architectures
test "$(systemctl show --value -p KillSignal seven.service)" -eq 15
test "$(systemctl show --value -p RestartKillSignal seven.service)" -eq 2
for sig in "$@"; do
# shellcheck disable=SC2064
trap "$fun $sig" "$sig"
done
}
systemctl restart seven.service
systemctl stop seven.service
# Propagate the caught signal to the current child process
handle_signal() {
local sig="${1:?}"
# For issue #20933
if [[ $CHILD_PID -gt 0 ]]; then
echo "Propagating signal $sig to child process $CHILD_PID"
kill -s "$sig" "$CHILD_PID"
fi
}
# Should work normally
busctl call \
org.freedesktop.systemd1 /org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager StartTransientUnit \
"ssa(sv)a(sa(sv))" test-20933-ok.service replace 1 \
ExecStart "a(sasb)" 1 \
/usr/bin/sleep 2 /usr/bin/sleep 1 true \
0
# In order to make the handle_signal() stuff above work, we have to execute
# each script asynchronously, since bash won't execute traps until the currently
# executed command finishes. This, however, introduces another issue regarding
# how bash's wait works. Quoting:
#
# When bash is waiting for an asynchronous command via the wait builtin,
# the reception of a signal for which a trap has been set will cause the wait
# builtin to return immediately with an exit status greater than 128,
# immediately after which the trap is executed.
#
# In other words - every time we propagate a signal, wait returns with
# 128+signal, so we have to wait again - repeat until the process dies.
wait_harder() {
local pid="${1:?}"
# DBus call should fail but not crash systemd
(! busctl call \
org.freedesktop.systemd1 /org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager StartTransientUnit \
"ssa(sv)a(sa(sv))" test-20933-bad.service replace 1 \
ExecStart "a(sasb)" 1 \
/usr/bin/sleep 0 true \
0)
while kill -0 "$pid"; do
wait "$pid" || :
done
# Same but with the empty argv in the middle
(! busctl call \
org.freedesktop.systemd1 /org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager StartTransientUnit \
"ssa(sv)a(sa(sv))" test-20933-bad-middle.service replace 1 \
ExecStart "a(sasb)" 3 \
/usr/bin/sleep 2 /usr/bin/sleep 1 true \
/usr/bin/sleep 0 true \
/usr/bin/sleep 2 /usr/bin/sleep 1 true \
0)
wait "$pid"
}
systemd-analyze log-level info
trap_with_sig handle_signal SIGUSR1 SIGUSR2 SIGRTMIN+1
echo OK >/testok
for script in "${0%.sh}".*.sh; do
echo "Running $script"
"./$script" &
CHILD_PID=$!
wait_harder "$CHILD_PID"
done
exit 0
touch /testok
rm /failed

View file

@ -0,0 +1,63 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
# Test Type=exec
systemd-analyze log-level debug
# Create a binary for which execve() will fail
touch /tmp/brokenbinary
chmod +x /tmp/brokenbinary
# These three commands should succeed.
systemd-run --unit=exec-one -p Type=simple /bin/sleep infinity
systemd-run --unit=exec-two -p Type=simple -p User=idontexist /bin/sleep infinity
systemd-run --unit=exec-three -p Type=simple /tmp/brokenbinary
# And now, do the same with Type=exec, where the latter two should fail
systemd-run --unit=exec-four -p Type=exec /bin/sleep infinity
(! systemd-run --unit=exec-five -p Type=exec -p User=idontexist /bin/sleep infinity)
(! systemd-run --unit=exec-six -p Type=exec /tmp/brokenbinary)
systemd-run --unit=exec-seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec /bin/sleep infinity
# Both TERM and SIGINT happen to have the same number on all architectures
test "$(systemctl show --value -p KillSignal exec-seven.service)" -eq 15
test "$(systemctl show --value -p RestartKillSignal exec-seven.service)" -eq 2
systemctl restart exec-seven.service
systemctl stop exec-seven.service
# For issue #20933
# Should work normally
busctl call \
org.freedesktop.systemd1 /org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager StartTransientUnit \
"ssa(sv)a(sa(sv))" test-20933-ok.service replace 1 \
ExecStart "a(sasb)" 1 \
/usr/bin/sleep 2 /usr/bin/sleep 1 true \
0
# DBus call should fail but not crash systemd
(! busctl call \
org.freedesktop.systemd1 /org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager StartTransientUnit \
"ssa(sv)a(sa(sv))" test-20933-bad.service replace 1 \
ExecStart "a(sasb)" 1 \
/usr/bin/sleep 0 true \
0)
# Same but with the empty argv in the middle
(! busctl call \
org.freedesktop.systemd1 /org/freedesktop/systemd1 \
org.freedesktop.systemd1.Manager StartTransientUnit \
"ssa(sv)a(sa(sv))" test-20933-bad-middle.service replace 1 \
ExecStart "a(sasb)" 3 \
/usr/bin/sleep 2 /usr/bin/sleep 1 true \
/usr/bin/sleep 0 true \
/usr/bin/sleep 2 /usr/bin/sleep 1 true \
0)
systemd-analyze log-level info

View file

@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-37-RUNTIMEDIRECTORYPRESERVE
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View file

@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-39-EXECRELOAD
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View file

@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-40-EXEC-COMMAND-EX
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View file

@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-41-ONESHOT-RESTART
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View file

@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-42-EXECSTOPPOST
Before=getty-pre.target
Wants=getty-pre.target
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View file

@ -1,10 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=Stop Propagation Receiver
Wants=testsuite-57-prop-stop-two.service
After=testsuite-57-prop-stop-two.service
StopPropagatedFrom=testsuite-57-prop-stop-two.service
[Service]
ExecStart=/bin/sleep infinity
ExecStopPost=systemctl kill --kill-whom=main -sUSR2 testsuite-57.service

View file

@ -1,18 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -ex
if [ -f /tmp/testsuite-57.counter ] ; then
read -r counter < /tmp/testsuite-57.counter
counter=$((counter + 1))
else
counter=0
fi
echo "$counter" >/tmp/testsuite-57.counter
if [ "$counter" -eq 5 ] ; then
systemctl kill --kill-whom=main -sUSR1 testsuite-57.service
fi
exec sleep 1.5

View file

@ -1,8 +0,0 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Unit]
Description=TEST-57-ONSUCCESS-UPHOLD
[Service]
ExecStartPre=rm -f /failed /testok
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
Type=oneshot

View file

@ -1,96 +0,0 @@
#!/usr/bin/env bash
# SPDX-License-Identifier: LGPL-2.1-or-later
set -eux
set -o pipefail
systemd-analyze log-level debug
systemd-analyze log-target journal
# Idea is this:
# 1. we start testsuite-57-success.service
# 2. which through OnSuccess= starts testsuite-57-fail.service,
# 3. which through OnFailure= starts testsuite-57-uphold.service,
# 4. which through Uphold= starts/keeps testsuite-57-short-lived.service running,
# 5. which will sleep 1s when invoked, and on the 5th invocation send us a SIGUSR1
# 6. once we got that we finish cleanly
sigusr1=0
trap sigusr1=1 SIGUSR1
systemctl start testsuite-57-success.service
while [ "$sigusr1" -eq 0 ] ; do
sleep .5
done
systemctl stop testsuite-57-uphold.service
# Idea is this:
# 1. we start testsuite-57-retry-uphold.service
# 2. which through Uphold= starts testsuite-57-retry-upheld.service
# 3. which through Requires= starts testsuite-57-retry-fail.service
# 4. which fails as /tmp/testsuite-57-retry-fail does not exist, so testsuite-57-retry-upheld.service
# is no longer restarted
# 5. we create /tmp/testsuite-57-retry-fail
# 6. now testsuite-57-retry-upheld.service will be restarted since upheld, and its dependency will
# be satisfied
rm -f /tmp/testsuite-57-retry-fail
systemctl start testsuite-57-retry-uphold.service
while ! systemctl is-failed testsuite-57-retry-fail.service ; do
sleep .5
done
systemctl is-active testsuite-57-retry-upheld.service && { echo 'unexpected success'; exit 1; }
touch /tmp/testsuite-57-retry-fail
while ! systemctl is-active testsuite-57-retry-upheld.service ; do
sleep .5
done
systemctl stop testsuite-57-retry-uphold.service testsuite-57-retry-fail.service testsuite-57-retry-upheld.service
# Idea is this:
# 1. we start testsuite-57-prop-stop-one.service
# 2. which through Wants=/After= pulls in testsuite-57-prop-stop-two.service as well
# 3. testsuite-57-prop-stop-one.service then sleeps indefinitely
# 4. testsuite-57-prop-stop-two.service sleeps a short time and exits
# 5. the StopPropagatedFrom= dependency between the two should ensure *both* will exit as result
# 6. an ExecStopPost= line on testsuite-57-prop-stop-one.service will send us a SIGUSR2
# 7. once we got that we finish cleanly
sigusr2=0
trap sigusr2=1 SIGUSR2
systemctl start testsuite-57-prop-stop-one.service
while [ "$sigusr2" -eq 0 ] ; do
sleep .5
done
# Idea is this:
# 1. we start testsuite-57-binds-to.service
# 2. which through BindsTo=/After= pulls in testsuite-57-bound-by.service as well
# 3. testsuite-57-bound-by.service suddenly dies
# 4. testsuite-57-binds-to.service should then also be pulled down (it otherwise just hangs)
# 6. an ExecStopPost= line on testsuite-57-binds-to.service will send us a SIGRTMIN1+1
# 7. once we got that we finish cleanly
sigrtmin1=0
trap sigrtmin1=1 SIGRTMIN+1
systemctl start testsuite-57-binds-to.service
while [ "$sigrtmin1" -eq 0 ] ; do
sleep .5
done
systemd-analyze log-level info
echo OK >/testok
exit 0