]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: shutdown the machine on fail after soft-reboot
authorFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 29 Sep 2023 20:07:12 +0000 (22:07 +0200)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Fri, 29 Sep 2023 20:07:12 +0000 (22:07 +0200)
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.

test/units/testsuite-82.sh

index b6b6615997a558c7827816d351a32d299522a38e..71ea7d5b5eac1ad069d7a4ee585ab9b0e7f0dcd7 100755 (executable)
@@ -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