From 843cb225ad88c6d90c8992b0a6ed895bb38e4b77 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 29 Apr 2023 04:39:46 +0900 Subject: [PATCH] test: add tests for "systemctl stop" vs triggering by path unit --- .../test63-issue-24577-dep.service | 4 ++ .../test63-issue-24577.path | 3 ++ .../test63-issue-24577.service | 8 ++++ test/units/testsuite-63.sh | 39 +++++++++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 test/testsuite-63.units/test63-issue-24577-dep.service create mode 100644 test/testsuite-63.units/test63-issue-24577.path create mode 100644 test/testsuite-63.units/test63-issue-24577.service diff --git a/test/testsuite-63.units/test63-issue-24577-dep.service b/test/testsuite-63.units/test63-issue-24577-dep.service new file mode 100644 index 00000000000..e332ea474e7 --- /dev/null +++ b/test/testsuite-63.units/test63-issue-24577-dep.service @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Service] +Type=oneshot +ExecStart=bash -c 'sleep infinity' diff --git a/test/testsuite-63.units/test63-issue-24577.path b/test/testsuite-63.units/test63-issue-24577.path new file mode 100644 index 00000000000..80ba1dbe16e --- /dev/null +++ b/test/testsuite-63.units/test63-issue-24577.path @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Path] +PathExists=/tmp/hoge diff --git a/test/testsuite-63.units/test63-issue-24577.service b/test/testsuite-63.units/test63-issue-24577.service new file mode 100644 index 00000000000..568518bbf60 --- /dev/null +++ b/test/testsuite-63.units/test63-issue-24577.service @@ -0,0 +1,8 @@ +# SPDX-License-Identifier: LGPL-2.1-or-later +[Unit] +Requires=test63-issue-24577-dep.service +After=test63-issue-24577-dep.service + +[Service] +Type=oneshot +ExecStart=bash -c 'sleep infinity' diff --git a/test/units/testsuite-63.sh b/test/units/testsuite-63.sh index 7ee7fc15139..591e6d31045 100755 --- a/test/units/testsuite-63.sh +++ b/test/units/testsuite-63.sh @@ -3,6 +3,9 @@ set -ex set -o pipefail +# shellcheck source=test/units/assert.sh +. "$(dirname "$0")"/assert.sh + systemctl log-level debug # 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 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":[]}' +# tests for issue https://github.com/systemd/systemd/issues/24577#issuecomment-1522628906 +rm -f /tmp/hoge +systemctl start test63-issue-24577.path +systemctl status -n 0 test63-issue-24577.path +systemctl status -n 0 test63-issue-24577.service || : +systemctl list-jobs +output=$(systemctl list-jobs --no-legend) +assert_not_in "test63-issue-24577.service" "$output" +assert_not_in "test63-issue-24577-dep.service" "$output" + +touch /tmp/hoge +systemctl status -n 0 test63-issue-24577.path +systemctl status -n 0 test63-issue-24577.service || : +systemctl list-jobs +output=$(systemctl list-jobs --no-legend) +assert_in "test63-issue-24577.service" "$output" +assert_in "test63-issue-24577-dep.service" "$output" + +# even if the service is stopped, it will be soon retriggered. +systemctl stop test63-issue-24577.service +systemctl status -n 0 test63-issue-24577.path +systemctl status -n 0 test63-issue-24577.service || : +systemctl list-jobs +output=$(systemctl list-jobs --no-legend) +assert_in "test63-issue-24577.service" "$output" +assert_in "test63-issue-24577-dep.service" "$output" + +rm -f /tmp/hoge +systemctl stop test63-issue-24577.service +systemctl status -n 0 test63-issue-24577.path +systemctl status -n 0 test63-issue-24577.service || : +systemctl list-jobs +output=$(systemctl list-jobs --no-legend) +assert_not_in "test63-issue-24577.service" "$output" +assert_in "test63-issue-24577-dep.service" "$output" + systemctl log-level info echo OK >/testok -- 2.47.3