Skip to content

Commit ef50e43

Browse files
yuwatabluca
authored andcommitted
test: add tests for "systemctl stop" vs triggering by path unit
(cherry picked from commit 843cb22) (cherry picked from commit e0da5c9)
1 parent 63aab85 commit ef50e43

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
[Service]
3+
Type=oneshot
4+
ExecStart=bash -c 'sleep infinity'
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
[Path]
3+
PathExists=/tmp/hoge
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: LGPL-2.1-or-later
2+
[Unit]
3+
Requires=test63-issue-24577-dep.service
4+
After=test63-issue-24577-dep.service
5+
6+
[Service]
7+
Type=oneshot
8+
ExecStart=bash -c 'sleep infinity'

test/units/testsuite-63.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
set -ex
44
set -o pipefail
55

6+
# shellcheck source=test/units/assert.sh
7+
. "$(dirname "$0")"/assert.sh
8+
69
systemctl log-level debug
710

811
# Test that a path unit continuously triggering a service that fails condition checks eventually fails with
@@ -41,6 +44,42 @@ systemctl stop test63-glob.path test63-glob.service
4144

4245
test "$(busctl --json=short get-property org.freedesktop.systemd1 /org/freedesktop/systemd1/unit/test63_2dglob_2eservice org.freedesktop.systemd1.Unit ActivationDetails)" = '{"type":"a(ss)","data":[]}'
4346

47+
# tests for issue https://github.com/systemd/systemd/issues/24577#issuecomment-1522628906
48+
rm -f /tmp/hoge
49+
systemctl start test63-issue-24577.path
50+
systemctl status -n 0 test63-issue-24577.path
51+
systemctl status -n 0 test63-issue-24577.service || :
52+
systemctl list-jobs
53+
output=$(systemctl list-jobs --no-legend)
54+
assert_not_in "test63-issue-24577.service" "$output"
55+
assert_not_in "test63-issue-24577-dep.service" "$output"
56+
57+
touch /tmp/hoge
58+
systemctl status -n 0 test63-issue-24577.path
59+
systemctl status -n 0 test63-issue-24577.service || :
60+
systemctl list-jobs
61+
output=$(systemctl list-jobs --no-legend)
62+
assert_in "test63-issue-24577.service" "$output"
63+
assert_in "test63-issue-24577-dep.service" "$output"
64+
65+
# even if the service is stopped, it will be soon retriggered.
66+
systemctl stop test63-issue-24577.service
67+
systemctl status -n 0 test63-issue-24577.path
68+
systemctl status -n 0 test63-issue-24577.service || :
69+
systemctl list-jobs
70+
output=$(systemctl list-jobs --no-legend)
71+
assert_in "test63-issue-24577.service" "$output"
72+
assert_in "test63-issue-24577-dep.service" "$output"
73+
74+
rm -f /tmp/hoge
75+
systemctl stop test63-issue-24577.service
76+
systemctl status -n 0 test63-issue-24577.path
77+
systemctl status -n 0 test63-issue-24577.service || :
78+
systemctl list-jobs
79+
output=$(systemctl list-jobs --no-legend)
80+
assert_not_in "test63-issue-24577.service" "$output"
81+
assert_in "test63-issue-24577-dep.service" "$output"
82+
4483
systemctl log-level info
4584

4685
echo OK >/testok

0 commit comments

Comments
 (0)