From b799c6de4ec80a5519391a7c15ac52481b50d33f Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Tue, 19 Apr 2022 21:15:41 +0200 Subject: [PATCH] machine: Fail test more gracefully if the image fails to boot --- mkosi/machine.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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() -- 2.47.2