]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: add test cases for issue #26839 in TEST-03-JOBS 26844/head
authorMike Yuan <me@yhndnzj.com>
Thu, 16 Mar 2023 08:23:17 +0000 (16:23 +0800)
committerMike Yuan <me@yhndnzj.com>
Wed, 5 Jul 2023 00:15:35 +0000 (08:15 +0800)
test/testsuite-03.units/propagatestopto-and-pullin.target [new file with mode: 0644]
test/testsuite-03.units/propagatestopto-only.target [new file with mode: 0644]
test/testsuite-03.units/sleep-infinity-simple.service [new file with mode: 0644]
test/units/testsuite-03.sh

diff --git a/test/testsuite-03.units/propagatestopto-and-pullin.target b/test/testsuite-03.units/propagatestopto-and-pullin.target
new file mode 100644 (file)
index 0000000..8e409af
--- /dev/null
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Requires=sleep-infinity-simple.service
+After=sleep-infinity-simple.service
+PropagatesStopTo=sleep-infinity-simple.service
diff --git a/test/testsuite-03.units/propagatestopto-only.target b/test/testsuite-03.units/propagatestopto-only.target
new file mode 100644 (file)
index 0000000..327b7c1
--- /dev/null
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+PropagatesStopTo=sleep-infinity-simple.service
diff --git a/test/testsuite-03.units/sleep-infinity-simple.service b/test/testsuite-03.units/sleep-infinity-simple.service
new file mode 100644 (file)
index 0000000..211346d
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+[Unit]
+Description=Sleep infinitely
+
+[Service]
+Type=simple
+ExecStart=/bin/sleep infinity
index 6ed7d8687a1329334dfc5106ba127c85be829901..22c500debf019555586fff06cd1773b9a92e9ada 100755 (executable)
@@ -3,6 +3,9 @@
 set -eux
 set -o pipefail
 
+# shellcheck source=test/units/util.sh
+. "$(dirname "$0")"/util.sh
+
 # Simple test for that daemon-reexec works in container.
 # See: https://github.com/systemd/systemd/pull/23883
 systemctl daemon-reexec
@@ -127,4 +130,19 @@ for i in {0..19}; do
     systemctl start "transaction-cycle$i.service"
 done
 
+# Test PropagatesStopTo= when restart (issue #26839)
+systemctl start propagatestopto-and-pullin.target
+systemctl --quiet is-active propagatestopto-and-pullin.target
+
+systemctl restart propagatestopto-and-pullin.target
+systemctl --quiet is-active propagatestopto-and-pullin.target
+systemctl --quiet is-active sleep-infinity-simple.service
+
+systemctl start propagatestopto-only.target
+systemctl --quiet is-active propagatestopto-only.target
+systemctl --quiet is-active sleep-infinity-simple.service
+
+systemctl restart propagatestopto-only.target
+assert_rc 3 systemctl --quiet is-active sleep-infinity-simple.service
+
 touch /testok