mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-10 01:17:44 +03:00
test-63: convert to full shell script and generalize
Will add more path unit tests later
This commit is contained in:
parent
1afe3d712e
commit
d4f38ff036
@ -1,30 +1,8 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=TEST-63-ISSUE-17433
|
Description=TEST-63-PATH
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
ExecStartPre=rm -f /failed /testok
|
ExecStartPre=rm -f /failed /testok
|
||||||
|
ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
|
||||||
Type=oneshot
|
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'
|
|
||||||
|
33
test/units/testsuite-63.sh
Executable file
33
test/units/testsuite-63.sh
Executable file
@ -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
|
Loading…
Reference in New Issue
Block a user