diff options
author | Luca Boccassi <bluca@debian.org> | 2022-08-03 17:50:39 +0200 |
---|---|---|
committer | Luca Boccassi <bluca@debian.org> | 2022-08-23 21:04:41 +0200 |
commit | d4f38ff036ce001081175292e87198ee4b19c364 (patch) | |
tree | b6ca8f1ab84d5e467134fed1fd5e8921d3da04a3 /test/units | |
parent | sleep: support acpi_btp and suspend system if enabled, skipping custom timer (diff) | |
download | systemd-d4f38ff036ce001081175292e87198ee4b19c364.tar.xz systemd-d4f38ff036ce001081175292e87198ee4b19c364.zip |
test-63: convert to full shell script and generalize
Will add more path unit tests later
Diffstat (limited to 'test/units')
-rw-r--r-- | test/units/testsuite-63.service | 26 | ||||
-rwxr-xr-x | test/units/testsuite-63.sh | 33 |
2 files changed, 35 insertions, 24 deletions
diff --git a/test/units/testsuite-63.service b/test/units/testsuite-63.service index 40422127ff..483c6a859b 100644 --- a/test/units/testsuite-63.service +++ b/test/units/testsuite-63.service @@ -1,30 +1,8 @@ # SPDX-License-Identifier: LGPL-2.1-or-later [Unit] -Description=TEST-63-ISSUE-17433 +Description=TEST-63-PATH [Service] ExecStartPre=rm -f /failed /testok +ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh Type=oneshot - -# Test that a path unit continuously triggering a service that fails condition checks eventually fails with -# the trigger-limit-hit error. -ExecStart=rm -f /tmp/nonexistent -ExecStart=systemctl start test63.path -ExecStart=touch /tmp/test63 -# Make sure systemd has sufficient time to hit the trigger limit for test63.path. -ExecStart=sleep 2 -ExecStart=sh -x -c 'test "$(systemctl show test63.service -P ActiveState)" = inactive' -ExecStart=sh -x -c 'test "$(systemctl show test63.service -P Result)" = success' -ExecStart=sh -x -c 'test "$(systemctl show test63.path -P ActiveState)" = failed' -ExecStart=sh -x -c 'test "$(systemctl show test63.path -P Result)" = trigger-limit-hit' - -# Test that starting the service manually doesn't affect the path unit. -ExecStart=rm -f /tmp/test63 -ExecStart=systemctl reset-failed -ExecStart=systemctl start test63.path -ExecStart=systemctl start test63.service -ExecStart=sh -x -c 'test "$(systemctl show test63.service -P ActiveState)" = inactive' -ExecStart=sh -x -c 'test "$(systemctl show test63.service -P Result)" = success' -ExecStart=sh -x -c 'test "$(systemctl show test63.path -P ActiveState)" = active' -ExecStart=sh -x -c 'test "$(systemctl show test63.path -P Result)" = success' -ExecStart=sh -x -c 'echo OK >/testok' diff --git a/test/units/testsuite-63.sh b/test/units/testsuite-63.sh new file mode 100755 index 0000000000..20d93936b3 --- /dev/null +++ b/test/units/testsuite-63.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -ex +set -o pipefail + +systemctl log-level debug + +# Test that a path unit continuously triggering a service that fails condition checks eventually fails with +# the trigger-limit-hit error. +rm -f /tmp/nonexistent +systemctl start test63.path +touch /tmp/test63 + +# Make sure systemd has sufficient time to hit the trigger limit for test63.path. +sleep 2 +test "$(systemctl show test63.service -P ActiveState)" = inactive +test "$(systemctl show test63.service -P Result)" = success +test "$(systemctl show test63.path -P ActiveState)" = failed +test "$(systemctl show test63.path -P Result)" = trigger-limit-hit + +# Test that starting the service manually doesn't affect the path unit. +rm -f /tmp/test63 +systemctl reset-failed +systemctl start test63.path +systemctl start test63.service +test "$(systemctl show test63.service -P ActiveState)" = inactive +test "$(systemctl show test63.service -P Result)" = success +test "$(systemctl show test63.path -P ActiveState)" = active +test "$(systemctl show test63.path -P Result)" = success + +systemctl log-level info + +echo OK >/testok |