Skip to content

Commit 43ee6a8

Browse files
authored
Merge pull request systemd#6475 from martinpitt/test-set-e
test: Run qemu/nspawn tests with "set -e"
2 parents 2935311 + 818567f commit 43ee6a8

File tree

17 files changed

+61
-43
lines changed

17 files changed

+61
-43
lines changed

test/TEST-01-BASIC/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="Basic systemd setup"
56

67
. $TEST_BASE_DIR/test-functions

test/TEST-02-CRYPTSETUP/test.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="cryptsetup systemd setup"
56
TEST_NO_NSPAWN=1
67

@@ -78,9 +79,9 @@ EOF
7879
}
7980

8081
test_cleanup() {
81-
umount $TESTDIR/root/var 2>/dev/null
82+
[ -d $TESTDIR/root/var ] && mountpoint $TESTDIR/root/var && umount $TESTDIR/root/var
8283
[[ -b /dev/mapper/varcrypt ]] && cryptsetup luksClose /dev/mapper/varcrypt
83-
umount $TESTDIR/root 2>/dev/null
84+
umount $TESTDIR/root 2>/dev/null || true
8485
[[ $LOOPDEV ]] && losetup -d $LOOPDEV
8586
return 0
8687
}

test/TEST-03-JOBS/test-jobs.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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
1111
done
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.
1616
START_SEC=$(date -u '+%s')
1717
systemctl start --job-mode=ignore-dependencies hello
1818
END_SEC=$(date -u '+%s')
1919
ELAPSED=$(($END_SEC-$START_SEC))
2020

21-
[ "$ELAPSED" -lt 3 ] || exit 1
21+
[ "$ELAPSED" -lt 3 ]
2222

2323
# sleep should still be running, hello not.
2424
systemctl 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
2626
grep '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'
4343
systemctl 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
5353
cat <<EOF > /run/systemd/system/wait2.service
@@ -65,7 +65,7 @@ EOF
6565

6666
# wait2 succeeds
6767
START_SEC=$(date -u '+%s')
68-
systemctl start --wait wait2.service || exit 1
68+
systemctl start --wait wait2.service
6969
END_SEC=$(date -u '+%s')
7070
ELAPSED=$(($END_SEC-$START_SEC))
7171
[[ "$ELAPSED" -ge 2 ]] && [[ "$ELAPSED" -le 4 ]] || exit 1

test/TEST-03-JOBS/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="Job-related tests"
56

67
. $TEST_BASE_DIR/test-functions

test/TEST-04-JOURNAL/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="Journal-related tests"
56

67
. $TEST_BASE_DIR/test-functions

test/TEST-05-RLIMITS/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="Resource limits-related tests"
56

67
. $TEST_BASE_DIR/test-functions

test/TEST-06-SELINUX/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="SELinux tests"
56
TEST_NO_NSPAWN=1
67

test/TEST-07-ISSUE-1981/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981"
56
TEST_NO_QEMU=1
67

test/TEST-08-ISSUE-2730/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730"
56
TEST_NO_NSPAWN=1
67

test/TEST-09-ISSUE-2691/test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
33
# ex: ts=8 sw=4 sts=4 et filetype=sh
4+
set -e
45
TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691"
56
TEST_NO_NSPAWN=1
67

0 commit comments

Comments
 (0)