From: Luca Boccassi Date: Wed, 3 Aug 2022 15:50:39 +0000 (+0100) Subject: test-63: convert to full shell script and generalize X-Git-Tag: v252-rc1~357^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d4f38ff036ce001081175292e87198ee4b19c364;p=thirdparty%2Fsystemd.git test-63: convert to full shell script and generalize Will add more path unit tests later --- diff --git a/test/TEST-63-ISSUE-17433/Makefile b/test/TEST-63-PATH/Makefile similarity index 100% rename from test/TEST-63-ISSUE-17433/Makefile rename to test/TEST-63-PATH/Makefile diff --git a/test/TEST-63-ISSUE-17433/test.sh b/test/TEST-63-PATH/test.sh similarity index 100% rename from test/TEST-63-ISSUE-17433/test.sh rename to test/TEST-63-PATH/test.sh diff --git a/test/units/testsuite-63.service b/test/units/testsuite-63.service index 40422127ff4..483c6a859bc 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 00000000000..20d93936b33 --- /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