]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: merge TEST-56-EXIT-TYPE into TEST-19-CGROUP
authorFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 16 May 2023 17:26:42 +0000 (19:26 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Tue, 16 May 2023 20:43:52 +0000 (22:43 +0200)
And clean it up a bit.

test/TEST-56-EXIT-TYPE/Makefile [deleted symlink]
test/TEST-56-EXIT-TYPE/test.sh [deleted file]
test/units/testsuite-19.ExitType-cgroup.sh [new file with mode: 0755]
test/units/testsuite-56.service [deleted file]
test/units/testsuite-56.sh [deleted file]

diff --git a/test/TEST-56-EXIT-TYPE/Makefile b/test/TEST-56-EXIT-TYPE/Makefile
deleted file mode 120000 (symlink)
index e9f93b1..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../TEST-01-BASIC/Makefile
\ No newline at end of file
diff --git a/test/TEST-56-EXIT-TYPE/test.sh b/test/TEST-56-EXIT-TYPE/test.sh
deleted file mode 100755 (executable)
index 37475e8..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-TEST_DESCRIPTION="test ExitType=cgroup"
-
-# shellcheck source=test/test-functions
-. "${TEST_BASE_DIR:?}/test-functions"
-
-if [[ "$(get_cgroup_hierarchy)" != unified ]]; then
-    echo "This test requires unified cgroup hierarchy, skipping..."
-    exit 0
-fi
-
-do_test "$@"
diff --git a/test/units/testsuite-19.ExitType-cgroup.sh b/test/units/testsuite-19.ExitType-cgroup.sh
new file mode 100755 (executable)
index 0000000..cd221d7
--- /dev/null
@@ -0,0 +1,102 @@
+#!/usr/bin/env bash
+set -eux
+
+# Test ExitType=cgroup
+
+# shellcheck source=test/units/util.sh
+. "$(dirname "$0")"/util.sh
+
+if [[ "$(get_cgroup_hierarchy)" != unified ]]; then
+    echo "Skipping $0 as we're not running with the unified cgroup hierarchy"
+    exit 0
+fi
+
+systemd-analyze log-level debug
+
+# Multiple level process tree, parent process stays up
+cat >/tmp/test19-exit-cgroup.sh <<EOF
+#!/usr/bin/env bash
+set -eux
+
+# process tree: systemd -> sleep
+sleep infinity &
+disown
+
+# process tree: systemd -> bash -> bash -> sleep
+((sleep infinity); true) &
+
+systemd-notify --ready
+
+# Run the stop/kill command
+\$1 &
+
+# process tree: systemd -> bash -> sleep
+sleep infinity
+EOF
+chmod +x /tmp/test19-exit-cgroup.sh
+
+# service should be stopped cleanly
+systemd-run --wait \
+           --unit=one \
+           --property="Type=notify" \
+           --property="ExitType=cgroup" \
+           /tmp/test19-exit-cgroup.sh 'systemctl stop one'
+
+# same thing with a truthy exec condition
+systemd-run --wait \
+            --unit=two \
+            --property="Type=notify" \
+            --property="ExitType=cgroup" \
+            --property="ExecCondition=true" \
+            /tmp/test19-exit-cgroup.sh 'systemctl stop two'
+
+# false exec condition: systemd-run should exit immediately with status code: 1
+(! systemd-run --wait \
+               --unit=three \
+               --property="Type=notify" \
+               --property="ExitType=cgroup" \
+               --property="ExecCondition=false" \
+               /tmp/test19-exit-cgroup.sh)
+
+# service should exit uncleanly (main process exits with SIGKILL)
+(! systemd-run --wait \
+               --unit=four \
+               --property="Type=notify" \
+               --property="ExitType=cgroup" \
+               /tmp/test19-exit-cgroup.sh 'systemctl kill --signal 9 four')
+
+
+# Multiple level process tree, parent process exits quickly
+cat >/tmp/test19-exit-cgroup-parentless.sh <<EOF
+#!/usr/bin/env bash
+set -eux
+
+# process tree: systemd -> sleep
+sleep infinity &
+
+# process tree: systemd -> bash -> sleep
+((sleep infinity); true) &
+
+systemd-notify --ready
+
+# Run the stop/kill command after this bash process exits
+(sleep 1; \$1) &
+EOF
+chmod +x /tmp/test19-exit-cgroup-parentless.sh
+
+# service should be stopped cleanly
+systemd-run --wait \
+            --unit=five \
+            --property="Type=notify" \
+            --property="ExitType=cgroup" \
+            /tmp/test19-exit-cgroup-parentless.sh 'systemctl stop five'
+
+# service should still exit cleanly despite SIGKILL (the main process already exited cleanly)
+systemd-run --wait \
+            --unit=six \
+            --property="Type=notify" \
+            --property="ExitType=cgroup" \
+            /tmp/test19-exit-cgroup-parentless.sh 'systemctl kill --signal 9 six'
+
+
+systemd-analyze log-level info
diff --git a/test/units/testsuite-56.service b/test/units/testsuite-56.service
deleted file mode 100644 (file)
index d8ad589..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-[Unit]
-Description=TEST-56-EXIT-TYPE
-
-[Service]
-ExecStart=/usr/lib/systemd/tests/testdata/units/%N.sh
-Type=oneshot
diff --git a/test/units/testsuite-56.sh b/test/units/testsuite-56.sh
deleted file mode 100755 (executable)
index f81c6dd..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#!/usr/bin/env bash
-set -eux
-
-systemd-analyze log-level debug
-
-# Multiple level process tree, parent process stays up
-cat >/tmp/test56-exit-cgroup.sh <<EOF
-#!/usr/bin/env bash
-set -eux
-
-# process tree: systemd -> sleep
-sleep infinity &
-disown
-
-# process tree: systemd -> bash -> bash -> sleep
-((sleep infinity); true) &
-
-systemd-notify --ready
-
-# Run the stop/kill command
-\$1 &
-
-# process tree: systemd -> bash -> sleep
-sleep infinity
-EOF
-chmod +x /tmp/test56-exit-cgroup.sh
-
-# service should be stopped cleanly
-systemd-run --wait --unit=one -p Type=notify -p ExitType=cgroup \
-    /tmp/test56-exit-cgroup.sh 'systemctl stop one'
-
-# same thing with a truthy exec condition
-systemd-run --wait --unit=two -p Type=notify -p ExitType=cgroup \
-    -p ExecCondition=true \
-    /tmp/test56-exit-cgroup.sh 'systemctl stop two'
-
-# false exec condition: systemd-run should exit immediately with status code: 1
-(! systemd-run --wait --unit=three -p Type=notify -p ExitType=cgroup \
-    -p ExecCondition=false \
-    /tmp/test56-exit-cgroup.sh)
-
-# service should exit uncleanly (main process exits with SIGKILL)
-(! systemd-run --wait --unit=four -p Type=notify -p ExitType=cgroup \
-    /tmp/test56-exit-cgroup.sh 'systemctl kill --signal 9 four')
-
-
-# Multiple level process tree, parent process exits quickly
-cat >/tmp/test56-exit-cgroup-parentless.sh <<EOF
-#!/usr/bin/env bash
-set -eux
-
-# process tree: systemd -> sleep
-sleep infinity &
-
-# process tree: systemd -> bash -> sleep
-((sleep infinity); true) &
-
-systemd-notify --ready
-
-# Run the stop/kill command after this bash process exits
-(sleep 1; \$1) &
-EOF
-chmod +x /tmp/test56-exit-cgroup-parentless.sh
-
-# service should be stopped cleanly
-systemd-run --wait --unit=five -p Type=notify -p ExitType=cgroup \
-    /tmp/test56-exit-cgroup-parentless.sh 'systemctl stop five'
-
-# service should still exit cleanly despite SIGKILL (the main process already exited cleanly)
-systemd-run --wait --unit=six -p Type=notify -p ExitType=cgroup \
-    /tmp/test56-exit-cgroup-parentless.sh 'systemctl kill --signal 9 six'
-
-
-systemd-analyze log-level info
-
-echo OK >/testok
-
-exit 0