From 3e0641f91f7296dca67224babc221f3a161224e1 Mon Sep 17 00:00:00 2001 From: David Gibson Date: Thu, 12 May 2022 12:42:50 +1000 Subject: 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 [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 --- test/lib/test | 10 +++++----- test/run | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/lib/test b/test/lib/test index 93c86e8..2cfec9a 100755 --- a/test/lib/test +++ b/test/lib/test @@ -153,7 +153,7 @@ test_one_line() { "htools") pane_run HOST 'which '"${__arg}"' >/dev/null || echo skip' pane_wait HOST - [ "$(pane_parse HOST)" = "skip" ] && TEST_ONE_skip=1 + [ "$(pane_parse HOST)" = "skip" ] && TEST_ONE_skip=1 || true ;; "passt") pane_run PASST "${__arg}" @@ -194,17 +194,17 @@ test_one_line() { "gtools") pane_run GUEST 'which '"${__arg}"' >/dev/null || echo skip' pane_wait GUEST - [ "$(pane_parse GUEST)" = "skip" ] && TEST_ONE_skip=1 + [ "$(pane_parse GUEST)" = "skip" ] && TEST_ONE_skip=1 || true ;; "g1tools") pane_run GUEST_1 'which '"${__arg}"' >/dev/null || echo skip' pane_wait GUEST_1 - [ "$(pane_parse GUEST_1)" = "skip" ] && TEST_ONE_skip=1 + [ "$(pane_parse GUEST_1)" = "skip" ] && TEST_ONE_skip=1 || true ;; "g2tools") pane_run GUEST_2 'which '"${__arg}"' >/dev/null || echo skip' pane_wait GUEST_2 - [ "$(pane_parse GUEST_2)" = "skip" ] && TEST_ONE_skip=1 + [ "$(pane_parse GUEST_2)" = "skip" ] && TEST_ONE_skip=1 || true ;; "guest2") pane_run GUEST_2 "${__arg}" @@ -249,7 +249,7 @@ test_one_line() { "nstools") pane_run NS 'which '"${__arg}"' >/dev/null || echo skip' pane_wait NS - [ "$(pane_parse NS)" = "skip" ] && TEST_ONE_skip=1 + [ "$(pane_parse NS)" = "skip" ] && TEST_ONE_skip=1 || true ;; "gout") __varname="${__arg%% *}" diff --git a/test/run b/test/run index a8e1c98..737fa81 100755 --- a/test/run +++ b/test/run @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/sh -e # # SPDX-License-Identifier: AGPL-3.0-or-later # -- cgit v1.2.3