tests: Don't ignore errors during script

Most commands issued during the testing scripts aren't explicitly checked
for errors.  Therefore, if they fail, the shell will just keep on
executing.  This makes it difficult to figure out where things started
going wrong if things fall over.

Run the whole script with the set -e mode so that it will exit in the case
of any (unchecked) failing command.  To make this work we do need to add
explicit checks / fallbacks for some commands which we expect to fail.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
[sbrivio: use sh -e instead of setting -e later, so that we don't miss
 anything before set -e is issued]
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2022-05-12 12:42:50 +10:00 committed by Stefano Brivio
parent c638129a9e
commit 3e0641f91f
2 changed files with 6 additions and 6 deletions

View file

@ -153,7 +153,7 @@ test_one_line() {
"htools") "htools")
pane_run HOST 'which '"${__arg}"' >/dev/null || echo skip' pane_run HOST 'which '"${__arg}"' >/dev/null || echo skip'
pane_wait HOST pane_wait HOST
[ "$(pane_parse HOST)" = "skip" ] && TEST_ONE_skip=1 [ "$(pane_parse HOST)" = "skip" ] && TEST_ONE_skip=1 || true
;; ;;
"passt") "passt")
pane_run PASST "${__arg}" pane_run PASST "${__arg}"
@ -194,17 +194,17 @@ test_one_line() {
"gtools") "gtools")
pane_run GUEST 'which '"${__arg}"' >/dev/null || echo skip' pane_run GUEST 'which '"${__arg}"' >/dev/null || echo skip'
pane_wait GUEST pane_wait GUEST
[ "$(pane_parse GUEST)" = "skip" ] && TEST_ONE_skip=1 [ "$(pane_parse GUEST)" = "skip" ] && TEST_ONE_skip=1 || true
;; ;;
"g1tools") "g1tools")
pane_run GUEST_1 'which '"${__arg}"' >/dev/null || echo skip' pane_run GUEST_1 'which '"${__arg}"' >/dev/null || echo skip'
pane_wait GUEST_1 pane_wait GUEST_1
[ "$(pane_parse GUEST_1)" = "skip" ] && TEST_ONE_skip=1 [ "$(pane_parse GUEST_1)" = "skip" ] && TEST_ONE_skip=1 || true
;; ;;
"g2tools") "g2tools")
pane_run GUEST_2 'which '"${__arg}"' >/dev/null || echo skip' pane_run GUEST_2 'which '"${__arg}"' >/dev/null || echo skip'
pane_wait GUEST_2 pane_wait GUEST_2
[ "$(pane_parse GUEST_2)" = "skip" ] && TEST_ONE_skip=1 [ "$(pane_parse GUEST_2)" = "skip" ] && TEST_ONE_skip=1 || true
;; ;;
"guest2") "guest2")
pane_run GUEST_2 "${__arg}" pane_run GUEST_2 "${__arg}"
@ -249,7 +249,7 @@ test_one_line() {
"nstools") "nstools")
pane_run NS 'which '"${__arg}"' >/dev/null || echo skip' pane_run NS 'which '"${__arg}"' >/dev/null || echo skip'
pane_wait NS pane_wait NS
[ "$(pane_parse NS)" = "skip" ] && TEST_ONE_skip=1 [ "$(pane_parse NS)" = "skip" ] && TEST_ONE_skip=1 || true
;; ;;
"gout") "gout")
__varname="${__arg%% *}" __varname="${__arg%% *}"

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh -e
# #
# SPDX-License-Identifier: AGPL-3.0-or-later # SPDX-License-Identifier: AGPL-3.0-or-later
# #