diff options
author | Frantisek Sumsal <frantisek@sumsal.cz> | 2023-05-08 22:38:34 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2023-05-10 02:39:12 +0900 |
commit | 539af5c4413efbcdb57713b7ad563440217b28a5 (patch) | |
tree | b5bb128f8bcae217928573be7cedbe53a993d1af /test/units/testsuite-23.type-exec.sh | |
parent | 97211510b06b01a4f053d4cacba4ad4184849bcf (diff) | |
download | systemd-539af5c4413efbcdb57713b7ad563440217b28a5.tar.gz |
test: merge unit file related tests into TEST-23-UNIT-FILE
Rename TEST-23-TYPE-EXEC to TEST-23-UNIT-FILE and merge it with
following tests:
- TEST-37-RUNTIMEDIRECTORYPRESERV
- TEST-40-EXEC-COMMAND-EX
- TEST-41-ONESHOT-RESTART
- TEST-42-EXECSTOPPOST
- TEST-57-ONSUCCESS-UPHOLD
Diffstat (limited to 'test/units/testsuite-23.type-exec.sh')
-rwxr-xr-x | test/units/testsuite-23.type-exec.sh | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/test/units/testsuite-23.type-exec.sh b/test/units/testsuite-23.type-exec.sh new file mode 100755 index 0000000000..87f32ccb58 --- /dev/null +++ b/test/units/testsuite-23.type-exec.sh @@ -0,0 +1,63 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: LGPL-2.1-or-later +set -eux +set -o pipefail + +# Test Type=exec + +systemd-analyze log-level debug + +# Create a binary for which execve() will fail +touch /tmp/brokenbinary +chmod +x /tmp/brokenbinary + +# These three commands should succeed. +systemd-run --unit=exec-one -p Type=simple /bin/sleep infinity +systemd-run --unit=exec-two -p Type=simple -p User=idontexist /bin/sleep infinity +systemd-run --unit=exec-three -p Type=simple /tmp/brokenbinary + +# And now, do the same with Type=exec, where the latter two should fail +systemd-run --unit=exec-four -p Type=exec /bin/sleep infinity +(! systemd-run --unit=exec-five -p Type=exec -p User=idontexist /bin/sleep infinity) +(! systemd-run --unit=exec-six -p Type=exec /tmp/brokenbinary) + +systemd-run --unit=exec-seven -p KillSignal=SIGTERM -p RestartKillSignal=SIGINT -p Type=exec /bin/sleep infinity +# Both TERM and SIGINT happen to have the same number on all architectures +test "$(systemctl show --value -p KillSignal exec-seven.service)" -eq 15 +test "$(systemctl show --value -p RestartKillSignal exec-seven.service)" -eq 2 + +systemctl restart exec-seven.service +systemctl stop exec-seven.service + +# For issue #20933 + +# Should work normally +busctl call \ + org.freedesktop.systemd1 /org/freedesktop/systemd1 \ + org.freedesktop.systemd1.Manager StartTransientUnit \ + "ssa(sv)a(sa(sv))" test-20933-ok.service replace 1 \ + ExecStart "a(sasb)" 1 \ + /usr/bin/sleep 2 /usr/bin/sleep 1 true \ + 0 + +# DBus call should fail but not crash systemd +(! busctl call \ + org.freedesktop.systemd1 /org/freedesktop/systemd1 \ + org.freedesktop.systemd1.Manager StartTransientUnit \ + "ssa(sv)a(sa(sv))" test-20933-bad.service replace 1 \ + ExecStart "a(sasb)" 1 \ + /usr/bin/sleep 0 true \ + 0) + +# Same but with the empty argv in the middle +(! busctl call \ + org.freedesktop.systemd1 /org/freedesktop/systemd1 \ + org.freedesktop.systemd1.Manager StartTransientUnit \ + "ssa(sv)a(sa(sv))" test-20933-bad-middle.service replace 1 \ + ExecStart "a(sasb)" 3 \ + /usr/bin/sleep 2 /usr/bin/sleep 1 true \ + /usr/bin/sleep 0 true \ + /usr/bin/sleep 2 /usr/bin/sleep 1 true \ + 0) + +systemd-analyze log-level info |