From: Daan De Meyer Date: Tue, 19 Apr 2022 19:15:41 +0000 (+0200) Subject: machine: Fail test more gracefully if the image fails to boot X-Git-Tag: v13~27^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F982%2Fhead;p=thirdparty%2Fmkosi.git machine: Fail test more gracefully if the image fails to boot --- diff --git a/mkosi/machine.py b/mkosi/machine.py index e8519c902..e572b868a 100644 --- a/mkosi/machine.py +++ b/mkosi/machine.py @@ -212,7 +212,13 @@ class MkosiMachineTest(unittest.TestCase): # Necessary for shell otherwise racing conditions to the disk image will happen. test_name = self.id().split(".")[3] self.machine.args.hostname = test_name.replace("_", "-") - self.machine.boot() + + try: + self.machine.boot() + except pexpect.EOF: + self.fail(f'Failed to boot machine with command "{self.machine.serial.args}"') + except pexpect.TIMEOUT: + self.fail(f'Timed out while waiting for machine to boot with command "{self.machine.serial.args}"') def tearDown(self) -> None: self.machine.kill()