diff --git a/test/units/testsuite-09.journal.sh b/test/units/testsuite-09.journal.sh index c6c1f6eccb..2ef192c7a8 100755 --- a/test/units/testsuite-09.journal.sh +++ b/test/units/testsuite-09.journal.sh @@ -7,7 +7,7 @@ set -o pipefail . "$(dirname "$0")"/util.sh get_first_boot_id() { - journalctl -b "${1:?}" -o json | jq -sr '.[0]._BOOT_ID' + journalctl -b "${1:?}" -o json -n +1 | jq -r '._BOOT_ID' } get_last_boot_id() { @@ -15,7 +15,7 @@ get_last_boot_id() { } get_first_timestamp() { - journalctl -b "${1:?}" -o json | jq -sr '.[0].__REALTIME_TIMESTAMP' + journalctl -b "${1:?}" -o json -n +1 | jq -r '.__REALTIME_TIMESTAMP' } get_last_timestamp() { diff --git a/test/units/testsuite-82.sh b/test/units/testsuite-82.sh index b6b6615997..fec29eef12 100755 --- a/test/units/testsuite-82.sh +++ b/test/units/testsuite-82.sh @@ -3,6 +3,19 @@ set -ex set -o pipefail +at_exit() { + # Since the soft-reboot drops the enqueued end.service, we won't shutdown + # the test VM if the test fails and have to wait for the watchdog to kill + # us (which may take quite a long time). Let's just forcibly kill the machine + # instead to save CI resources. + if [[ $? -ne 0 ]]; then + echo >&2 "Test failed, shutting down the machine..." + systemctl poweroff -ff + fi +} + +trap at_exit EXIT + systemd-analyze log-level debug export SYSTEMD_LOG_LEVEL=debug @@ -84,7 +97,8 @@ elif [ -f /run/testsuite82.touch ]; then test "$x" = "wuffwuff" # Check that we got a PrepareForShutdownWithMetadata signal with the right type - test "$(jq .payload.data[1].type.data