1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-27 18:55:40 +03:00

TEST-*: make failure tests actually fail on failure

Here the intent was actually correct, and the tests still pass when the check
is made effective.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2021-04-08 01:27:33 +02:00
parent 61494724ee
commit 4e20fe2795
16 changed files with 96 additions and 62 deletions

View File

@ -19,7 +19,7 @@ systemctl start --job-mode=ignore-dependencies hello
END_SEC=$(date -u '+%s')
ELAPSED=$(($END_SEC-$START_SEC))
[ "$ELAPSED" -lt 3 ]
test "$ELAPSED" -lt 3
# sleep should still be running, hello not.
systemctl list-jobs > /root/list-jobs.txt
@ -28,11 +28,11 @@ grep 'hello\.service' /root/list-jobs.txt && exit 1
systemctl stop sleep.service hello-after-sleep.target
# Some basic testing that --show-transaction does something useful
! systemctl is-active systemd-importd
systemctl is-active systemd-importd && { echo 'unexpected success'; exit 1; }
systemctl -T start systemd-importd
systemctl is-active systemd-importd
systemctl --show-transaction stop systemd-importd
! systemctl is-active systemd-importd
systemctl is-active systemd-importd && { echo 'unexpected success'; exit 1; }
# Test for a crash when enqueuing a JOB_NOP when other job already exists
systemctl start --no-block hello-after-sleep.target
@ -80,7 +80,7 @@ ELAPSED=$(($END_SEC-$START_SEC))
# wait5fail fails, so systemctl should fail
START_SEC=$(date -u '+%s')
! systemctl start --wait wait2.service wait5fail.service || exit 1
systemctl start --wait wait2.service wait5fail.service && { echo 'unexpected success'; exit 1; }
END_SEC=$(date -u '+%s')
ELAPSED=$(($END_SEC-$START_SEC))
[[ "$ELAPSED" -ge 5 ]] && [[ "$ELAPSED" -le 7 ]] || exit 1

View File

@ -59,8 +59,8 @@ journalctl -b -o export --output-fields=MESSAGE,FOO --output-fields=PRIORITY,MES
grep -q '^__CURSOR=' /output
grep -q '^MESSAGE=foo$' /output
grep -q '^PRIORITY=6$' /output
! grep -q '^FOO=' /output
! grep -q '^SYSLOG_FACILITY=' /output
grep '^FOO=' /output && { echo 'unexpected success'; exit 1; }
grep '^SYSLOG_FACILITY=' /output && { echo 'unexpected success'; exit 1; }
# `-b all` negates earlier use of -b (-b and -m are otherwise exclusive)
journalctl -b -1 -b all -m > /dev/null

View File

@ -3,7 +3,7 @@ set -ex
set -o pipefail
systemd-run --wait -p FailureAction=poweroff true
! systemd-run --wait -p SuccessAction=poweroff false
systemd-run --wait -p SuccessAction=poweroff false && { echo 'unexpected success'; exit 1; }
if ! test -f /firstphase ; then
echo OK > /firstphase

View File

@ -126,8 +126,18 @@ test -f /run/mainpidsh3/pid
EOF
chmod 755 /dev/shm/test20-mainpid3.sh
# This has to fail, as we shouldn't accept the dangerous PID file, and then inotify-wait on it to be corrected which we never do
! systemd-run --unit=test20-mainpidsh3.service -p StandardOutput=tty -p StandardError=tty -p Type=forking -p RuntimeDirectory=mainpidsh3 -p PIDFile=/run/mainpidsh3/pid -p DynamicUser=1 -p TimeoutStartSec=2s /dev/shm/test20-mainpid3.sh
# This has to fail, as we shouldn't accept the dangerous PID file, and then
# inotify-wait on it to be corrected which we never do.
systemd-run --unit=test20-mainpidsh3.service \
-p StandardOutput=tty \
-p StandardError=tty \
-p Type=forking \
-p RuntimeDirectory=mainpidsh3 \
-p PIDFile=/run/mainpidsh3/pid \
-p DynamicUser=1 \
-p TimeoutStartSec=2s \
/dev/shm/test20-mainpid3.sh \
&& { echo 'unexpected success'; exit 1; }
# Test that this failed due to timeout, and not some other error
test `systemctl show -P Result test20-mainpidsh3.service` = timeout

View File

@ -39,7 +39,7 @@ test $(stat -c %U:%G:%a /tmp/f/1) = "daemon:daemon:666"
mkfifo /tmp/f/fifo
chmod 644 /tmp/f/fifo
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
f /tmp/f/fifo 0666 daemon daemon - This string should not be written
EOF
@ -50,7 +50,7 @@ test $(stat -c %U:%G:%a /tmp/f/fifo) = "root:root:644"
ln -s missing /tmp/f/dangling
ln -s /tmp/file-owned-by-root /tmp/f/symlink
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
f /tmp/f/dangling 0644 daemon daemon - -
f /tmp/f/symlink 0644 daemon daemon - -
EOF
@ -72,12 +72,12 @@ f /tmp/f/ro-fs/foo 0644 - - - - This string should not be written
EOF
test -f /tmp/f/ro-fs/foo; test ! -s /tmp/f/ro-fs/foo
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
f /tmp/f/ro-fs/foo 0666 - - - -
EOF
test $(stat -c %U:%G:%a /tmp/f/fifo) = "root:root:644"
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
f /tmp/f/ro-fs/bar 0644 - - - -
EOF
test ! -e /tmp/f/ro-fs/bar
@ -87,7 +87,7 @@ mkdir /tmp/f/daemon
ln -s /root /tmp/f/daemon/unsafe-symlink
chown -R --no-dereference daemon:daemon /tmp/f/daemon
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
f /tmp/f/daemon/unsafe-symlink/exploit 0644 daemon daemon - -
EOF
test ! -e /tmp/f/daemon/unsafe-symlink/exploit
@ -117,7 +117,7 @@ test $(stat -c %U:%G:%a /tmp/F/truncated-with-content) = "daemon:daemon:666"
### unspecified in the other cases.
mkfifo /tmp/F/fifo
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
F /tmp/F/fifo 0644 - - - -
EOF
@ -127,7 +127,7 @@ test -p /tmp/F/fifo
ln -s missing /tmp/F/dangling
ln -s /tmp/file-owned-by-root /tmp/F/symlink
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
f /tmp/F/dangling 0644 daemon daemon - -
f /tmp/F/symlink 0644 daemon daemon - -
EOF
@ -150,11 +150,11 @@ EOF
test -f /tmp/F/ro-fs/foo; test ! -s /tmp/F/ro-fs/foo
echo "truncating is not allowed anymore" >/tmp/F/rw-fs/foo
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
F /tmp/F/ro-fs/foo 0644 - - - -
EOF
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
F /tmp/F/ro-fs/foo 0644 - - - - This string should not be written
EOF
test -f /tmp/F/ro-fs/foo
@ -162,13 +162,13 @@ grep -q 'truncating is not allowed' /tmp/F/ro-fs/foo
# Trying to change the perms should fail.
>/tmp/F/rw-fs/foo
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
F /tmp/F/ro-fs/foo 0666 - - - -
EOF
test $(stat -c %U:%G:%a /tmp/F/ro-fs/foo) = "root:root:644"
### Try to create a new file.
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
F /tmp/F/ro-fs/bar 0644 - - - -
EOF
test ! -e /tmp/F/ro-fs/bar
@ -178,7 +178,7 @@ mkdir /tmp/F/daemon
ln -s /root /tmp/F/daemon/unsafe-symlink
chown -R --no-dereference daemon:daemon /tmp/F/daemon
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
F /tmp/F/daemon/unsafe-symlink/exploit 0644 daemon daemon - -
EOF
test ! -e /tmp/F/daemon/unsafe-symlink/exploit
@ -195,7 +195,7 @@ EOF
test ! -e /tmp/w/unexistent
### no argument given -> fails.
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
w /tmp/w/unexistent 0644 - - - -
EOF
@ -231,7 +231,7 @@ mkdir /tmp/w/daemon
ln -s /root /tmp/w/daemon/unsafe-symlink
chown -R --no-dereference daemon:daemon /tmp/w/daemon
! systemd-tmpfiles --create - <<EOF
systemd-tmpfiles --create - <<EOF && { echo 'unexpected success'; exit 1; }
f /tmp/w/daemon/unsafe-symlink/exploit 0644 daemon daemon - -
EOF
test ! -e /tmp/w/daemon/unsafe-symlink/exploit

View File

@ -22,9 +22,11 @@ test -d /tmp/root/test2
# Verify the command fails to write to a root-owned subdirectory under an
# unprivileged user's directory when it's not part of the prefix, as expected
# by the unsafe_transition function.
! echo 'd /tmp/user/root/test' | systemd-tmpfiles --create -
echo 'd /tmp/user/root/test' | systemd-tmpfiles --create - \
&& { echo 'unexpected success'; exit 1; }
test ! -e /tmp/user/root/test
! echo 'd /user/root/test' | systemd-tmpfiles --root=/tmp --create -
echo 'd /user/root/test' | systemd-tmpfiles --root=/tmp --create - \
&& { echo 'unexpected success'; exit 1; }
test ! -e /tmp/user/root/test
# Verify the above works when all user-owned directories are in the prefix.

View File

@ -16,8 +16,8 @@ systemd-run --unit=three -p Type=simple /tmp/brokenbinary
# And now, do the same with Type=exec, where the latter two should fail
systemd-run --unit=four -p Type=exec /bin/sleep infinity
! systemd-run --unit=five -p Type=exec -p User=idontexist /bin/sleep infinity
! systemd-run --unit=six -p Type=exec /tmp/brokenbinary
systemd-run --unit=five -p Type=exec -p User=idontexist /bin/sleep infinity && { echo 'unexpected success'; exit 1; }
systemd-run --unit=six -p Type=exec /tmp/brokenbinary && { echo 'unexpected success'; exit 1; }
systemd-run --unit=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

View File

@ -35,7 +35,7 @@ cmp /var/tmp/testimage.raw /var/lib/machines/testimage3.raw
# Test removal
machinectl remove testimage
test ! -f /var/lib/machines/testimage.raw
! machinectl image-status testimage
machinectl image-status testimage && { echo 'unexpected success'; exit 1; }
# Test export of clone
machinectl export-raw testimage3 /var/tmp/testimage3.raw
@ -47,7 +47,7 @@ machinectl rename testimage3 testimage4
test -f /var/lib/machines/testimage4.raw
machinectl image-status testimage4
test ! -f /var/lib/machines/testimage3.raw
! machinectl image-status testimage3
machinectl image-status testimage3 && { echo 'unexpected success'; exit 1; }
cmp /var/tmp/testimage.raw /var/lib/machines/testimage4.raw
# Test export of rename
@ -58,7 +58,7 @@ rm /var/tmp/testimage4.raw
# Test removal
machinectl remove testimage4
test ! -f /var/lib/machines/testimage4.raw
! machinectl image-status testimage4
machinectl image-status testimage4 && { echo 'unexpected success'; exit 1; }
# → And now, let's test directory trees ← #
@ -91,7 +91,7 @@ diff -r /var/tmp/scratch/ /var/lib/machines/scratch2
# Test removal
machinectl remove scratch
test ! -f /var/lib/machines/scratch
! machinectl image-status scratch
machinectl image-status scratchi && { echo 'unexpected success'; exit 1; }
# Test clone
machinectl clone scratch2 scratch3
@ -104,20 +104,20 @@ diff -r /var/tmp/scratch/ /var/lib/machines/scratch3
# Test removal
machinectl remove scratch2
test ! -f /var/lib/machines/scratch2
! machinectl image-status scratch2
machinectl image-status scratch2 && { echo 'unexpected success'; exit 1; }
# Test rename
machinectl rename scratch3 scratch4
test -d /var/lib/machines/scratch4
machinectl image-status scratch4
test ! -f /var/lib/machines/scratch3
! machinectl image-status scratch3
machinectl image-status scratch3 && { echo 'unexpected success'; exit 1; }
diff -r /var/tmp/scratch/ /var/lib/machines/scratch4
# Test removal
machinectl remove scratch4
test ! -f /var/lib/machines/scratch4
! machinectl image-status scratch4
machinectl image-status scratch4 && { echo 'unexpected success'; exit 1; }
# Test import-tar hyphen/stdin pipe behavior
cat /var/tmp/scratch.tar.gz | machinectl import-tar - scratch5
@ -136,7 +136,7 @@ rm -rf /var/tmp/scratch
# Test removal
machinectl remove scratch5
test ! -f /var/lib/machines/scratch5
! machinectl image-status scratch5
machinectl image-status scratch5 && { echo 'unexpected success'; exit 1; }
echo OK > /testok

View File

@ -22,8 +22,8 @@ systemctl show-environment | grep -q '^FOO=BAR$'
systemctl unset-environment FOO PATH
# Check that one is gone and the other reverted to the built-in
! (systemctl show-environment | grep -q '^FOO=$')
! (systemctl show-environment | grep -q '^PATH=.*testaddition$')
systemctl show-environment | grep '^FOO=$' && exit 1
systemctl show-environment | grep '^PATH=.*testaddition$' && exit 1
systemctl show-environment | grep -q '^PATH='
echo OK > /testok

View File

@ -32,7 +32,7 @@ test -d /var/lib/testservice
test -d /var/cache/testservice
test -d /var/log/testservice
! systemctl clean testservice
systemctl clean testservice && { echo 'unexpected success'; exit 1; }
systemctl stop testservice
@ -107,7 +107,7 @@ test -L /var/lib/testservice
test -L /var/cache/testservice
test -L /var/log/testservice
! systemctl clean testservice
systemctl clean testservice && { echo 'unexpected success'; exit 1; }
systemctl stop testservice
@ -196,7 +196,7 @@ test -d /var/lib/hoge
test -d /var/cache/hoge
test -d /var/log/hoge
! systemctl clean tmp-hoge.mount
systemctl clean tmp-hoge.mount && { echo 'unexpected success'; exit 1; }
test -d /etc/hoge
test -d /run/hoge
@ -272,7 +272,7 @@ test -d /var/lib/testsocket
test -d /var/cache/testsocket
test -d /var/log/testsocket
! systemctl clean testservice.socket
systemctl clean testservice.socket && { echo 'unexpected success'; exit 1; }
systemctl stop testservice.socket

View File

@ -9,7 +9,8 @@ systemd-analyze log-target console
systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz touch /var/lib/zzz/test
systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test
! systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing
systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing \
&& { echo 'unexpected success'; exit 1; }
test -d /var/lib/zzz
test ! -L /var/lib/zzz
@ -20,7 +21,8 @@ test ! -f /var/lib/zzz/test-missing
# Convert to DynamicUser=1
systemd-run --wait -p DynamicUser=1 -p StateDirectory=zzz test -f /var/lib/zzz/test
! systemd-run --wait -p DynamicUser=1 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing
systemd-run --wait -p DynamicUser=1 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing \
&& { echo 'unexpected success'; exit 1; }
test -L /var/lib/zzz
test -d /var/lib/private/zzz
@ -31,7 +33,8 @@ test ! -f /var/lib/zzz/test-missing
# Convert back
systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test
! systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing
systemd-run --wait -p DynamicUser=0 -p StateDirectory=zzz test -f /var/lib/zzz/test-missing \
&& { echo 'unexpected success'; exit 1; }
test -d /var/lib/zzz
test ! -L /var/lib/zzz

View File

@ -21,7 +21,7 @@ systemctl daemon-reload
systemctl start $SERVICE_NAME
systemctl status $SERVICE_NAME
# The reload SHOULD fail but SHOULD NOT affect the service state
! systemctl reload $SERVICE_NAME
systemctl reload $SERVICE_NAME && { echo 'unexpected success'; exit 1; }
systemctl status $SERVICE_NAME
systemctl stop $SERVICE_NAME
@ -39,7 +39,7 @@ systemctl daemon-reload
systemctl start $SERVICE_NAME
systemctl status $SERVICE_NAME
# The reload SHOULD fail but SHOULD NOT affect the service state
! systemctl reload $SERVICE_NAME
systemctl reload $SERVICE_NAME && { echo 'unexpected success'; exit 1; }
systemctl status $SERVICE_NAME
systemctl stop $SERVICE_NAME

View File

@ -9,7 +9,8 @@ systemd-analyze log-level debug
systemd-analyze log-target console
# test one: Restart=on-failure should restart the service
! systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1"
systemd-run --unit=one -p Type=oneshot -p Restart=on-failure /bin/bash -c "exit 1" \
&& { echo 'unexpected success'; exit 1; }
for ((secs=0; secs<$MAX_SECS; secs++)); do
[[ "$(systemctl show one.service -P NRestarts)" -le 0 ]] || break
@ -25,7 +26,13 @@ TMP_FILE="/tmp/test-41-oneshot-restart-test"
# test two: make sure StartLimitBurst correctly limits the number of restarts
# and restarts execution of the unit from the first ExecStart=
! systemd-run --unit=two -p StartLimitIntervalSec=120 -p StartLimitBurst=3 -p Type=oneshot -p Restart=on-failure -p ExecStart="/bin/bash -c \"printf a >> $TMP_FILE\"" /bin/bash -c "exit 1"
systemd-run --unit=two \
-p StartLimitIntervalSec=120 \
-p StartLimitBurst=3 \
-p Type=oneshot \
-p Restart=on-failure \
-p ExecStart="/bin/bash -c \"printf a >> $TMP_FILE\"" /bin/bash -c "exit 1" \
&& { echo 'unexpected success'; exit 1; }
# wait for at least 3 restarts
for ((secs=0; secs<$MAX_SECS; secs++)); do

View File

@ -6,13 +6,15 @@ systemd-analyze log-level debug
systemd-run --unit=simple1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple1' true
test -f /run/simple1
! systemd-run --unit=simple2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple2' false
systemd-run --unit=simple2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=simple -p ExecStopPost='/bin/touch /run/simple2' false \
&& { echo 'unexpected success'; exit 1; }
test -f /run/simple2
systemd-run --unit=exec1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec1' sleep 1
test -f /run/exec1
! systemd-run --unit=exec2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec2' sh -c 'sleep 1; false'
systemd-run --unit=exec2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=exec -p ExecStopPost='/bin/touch /run/exec2' sh -c 'sleep 1; false' \
&& { echo 'unexpected success'; exit 1; }
test -f /run/exec2
cat > /tmp/forking1.sh <<EOF
@ -44,13 +46,15 @@ systemd-notify MAINPID=\$MAINPID
EOF
chmod +x /tmp/forking2.sh
! systemd-run --unit=forking2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking2' /tmp/forking2.sh
systemd-run --unit=forking2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=forking -p NotifyAccess=exec -p ExecStopPost='/bin/touch /run/forking2' /tmp/forking2.sh \
&& { echo 'unexpected success'; exit 1; }
test -f /run/forking2
systemd-run --unit=oneshot1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot1' true
test -f /run/oneshot1
! systemd-run --unit=oneshot2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot2' false
systemd-run --unit=oneshot2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=oneshot -p ExecStopPost='/bin/touch /run/oneshot2' false \
&& { echo 'unexpected success'; exit 1; }
test -f /run/oneshot2
systemd-run --unit=dbus1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=dbus -p BusName=systemd.test.ExecStopPost -p ExecStopPost='/bin/touch /run/dbus1' \
@ -73,13 +77,15 @@ chmod +x /tmp/notify1.sh
systemd-run --unit=notify1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify1' /tmp/notify1.sh
test -f /run/notify1
! systemd-run --unit=notify2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify2' true
systemd-run --unit=notify2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=notify -p ExecStopPost='/bin/touch /run/notify2' true \
&& { echo 'unexpected success'; exit 1; }
test -f /run/notify2
systemd-run --unit=idle1.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle1' true
test -f /run/idle1
! systemd-run --unit=idle2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle2' false
systemd-run --unit=idle2.service --wait -p StandardOutput=tty -p StandardError=tty -p Type=idle -p ExecStopPost='/bin/touch /run/idle2' false \
&& { echo 'unexpected success'; exit 1; }
test -f /run/idle2
systemd-analyze log-level info

View File

@ -15,14 +15,16 @@ systemd-run -p LoadCredential=passwd:/etc/passwd \
rm /tmp/ts54-concat
# Verify that the creds are immutable
! systemd-run -p LoadCredential=passwd:/etc/passwd \
systemd-run -p LoadCredential=passwd:/etc/passwd \
-p DynamicUser=1 \
--wait \
touch '${CREDENTIALS_DIRECTORY}/passwd'
! systemd-run -p LoadCredential=passwd:/etc/passwd \
touch '${CREDENTIALS_DIRECTORY}/passwd' \
&& { echo 'unexpected success'; exit 1; }
systemd-run -p LoadCredential=passwd:/etc/passwd \
-p DynamicUser=1 \
--wait \
rm '${CREDENTIALS_DIRECTORY}/passwd'
rm '${CREDENTIALS_DIRECTORY}/passwd' \
&& { echo 'unexpected success'; exit 1; }
systemd-analyze log-level info

View File

@ -29,11 +29,13 @@ systemd-run --wait --unit=one -p ExitType=cgroup /tmp/test56-exit-cgroup.sh
systemd-run --wait --unit=two -p ExitType=cgroup -p ExecCondition=true /tmp/test56-exit-cgroup.sh
# false exec condition: systemd-run should exit immediately with status code: 1
! systemd-run --wait --unit=three -p ExitType=cgroup -p ExecCondition=false /tmp/test56-exit-cgroup.sh
systemd-run --wait --unit=three -p ExitType=cgroup -p ExecCondition=false /tmp/test56-exit-cgroup.sh \
&& { echo 'unexpected success'; exit 1; }
# service should exit uncleanly
(sleep 1; systemctl kill --signal 9 four) &
! systemd-run --wait --unit=four -p ExitType=cgroup /tmp/test56-exit-cgroup.sh
systemd-run --wait --unit=four -p ExitType=cgroup /tmp/test56-exit-cgroup.sh \
&& { echo 'unexpected success'; exit 1; }
# Multiple level process tree, parent process exits quickly
@ -55,7 +57,8 @@ systemd-run --wait --unit=five -p ExitType=cgroup /tmp/test56-exit-cgroup-parent
# service should exit uncleanly
(sleep 1; systemctl kill --signal 9 six) &
! systemd-run --wait --unit=six -p ExitType=cgroup /tmp/test56-exit-cgroup-parentless.sh
systemd-run --wait --unit=six -p ExitType=cgroup /tmp/test56-exit-cgroup-parentless.sh \
&& { echo 'unexpected success'; exit 1; }
# Multiple level process tree, parent process exits uncleanly but last process exits cleanly
@ -85,7 +88,8 @@ EOF
chmod +x /tmp/test56-exit-cgroup-unclean.sh
# service should exit uncleanly after 1 second
! systemd-run --wait --unit=eight -p ExitType=cgroup /tmp/test56-exit-cgroup-unclean.sh
systemd-run --wait --unit=eight -p ExitType=cgroup /tmp/test56-exit-cgroup-unclean.sh \
&& { echo 'unexpected success'; exit 1; }
systemd-analyze log-level info