1- #! /bin/bash -x
1+ #! /bin/bash -e
22
33# Test merging of a --job-mode=ignore-dependencies job into a previously
44# installed job.
@@ -10,44 +10,44 @@ while ! grep 'sleep\.service.*running' /root/list-jobs.txt; do
1010 systemctl list-jobs > /root/list-jobs.txt
1111done
1212
13- grep ' hello\.service.*waiting' /root/list-jobs.txt || exit 1
13+ grep ' hello\.service.*waiting' /root/list-jobs.txt
1414
1515# This is supposed to finish quickly, not wait for sleep to finish.
1616START_SEC=$( date -u ' +%s' )
1717systemctl start --job-mode=ignore-dependencies hello
1818END_SEC=$( date -u ' +%s' )
1919ELAPSED=$(( $END_SEC - $START_SEC ))
2020
21- [ " $ELAPSED " -lt 3 ] || exit 1
21+ [ " $ELAPSED " -lt 3 ]
2222
2323# sleep should still be running, hello not.
2424systemctl list-jobs > /root/list-jobs.txt
25- grep ' sleep\.service.*running' /root/list-jobs.txt || exit 1
25+ grep ' sleep\.service.*running' /root/list-jobs.txt
2626grep ' hello\.service' /root/list-jobs.txt && exit 1
27- systemctl stop sleep.service hello-after-sleep.target || exit 1
27+ systemctl stop sleep.service hello-after-sleep.target
2828
2929# Test for a crash when enqueuing a JOB_NOP when other job already exists
30- systemctl start --no-block hello-after-sleep.target || exit 1
30+ systemctl start --no-block hello-after-sleep.target
3131# hello.service should still be waiting, so these try-restarts will collapse
3232# into NOPs.
33- systemctl try-restart --job-mode=fail hello.service || exit 1
34- systemctl try-restart hello.service || exit 1
35- systemctl stop hello.service sleep.service hello-after-sleep.target || exit 1
33+ systemctl try-restart --job-mode=fail hello.service
34+ systemctl try-restart hello.service
35+ systemctl stop hello.service sleep.service hello-after-sleep.target
3636
3737# TODO: add more job queueing/merging tests here.
3838
3939# Test for irreversible jobs
40- systemctl start unstoppable.service || exit 1
40+ systemctl start unstoppable.service
4141
4242# This is expected to fail with 'job cancelled'
4343systemctl stop unstoppable.service && exit 1
4444# But this should succeed
45- systemctl stop --job-mode=replace-irreversibly unstoppable.service || exit 1
45+ systemctl stop --job-mode=replace-irreversibly unstoppable.service
4646
4747# We're going to shutdown soon. Let's see if it succeeds when
4848# there's an active service that tries to be unstoppable.
4949# Shutdown of the container/VM will hang if not.
50- systemctl start unstoppable.service || exit 1
50+ systemctl start unstoppable.service
5151
5252# Test waiting for a started unit(s) to terminate again
5353cat << EOF > /run/systemd/system/wait2.service
6565
6666# wait2 succeeds
6767START_SEC=$( date -u ' +%s' )
68- systemctl start --wait wait2.service || exit 1
68+ systemctl start --wait wait2.service
6969END_SEC=$( date -u ' +%s' )
7070ELAPSED=$(( $END_SEC - $START_SEC ))
7171[[ " $ELAPSED " -ge 2 ]] && [[ " $ELAPSED " -le 4 ]] || exit 1
0 commit comments