From 1312d5df3a4375502eb134d29a4a678f7c1ab0f9 Mon Sep 17 00:00:00 2001 From: Matthew Kobayashi Date: Thu, 22 Oct 2026 10:56:15 +1000 Subject: smoketest: T9402: more robust GRUB menu selection The live ISO's UEFI GRUB menu was navigated with arrow keys sent on fixed sleeps, so a missed keystroke booted the wrong entry. The harness now waits for the autoboot countdown, sends one key at a time and waits for GRUB to highlight the expected entry before sending the next, restarting from the first entry if an acknowledgement is missing. Navigation uses Ctrl-A and Ctrl-N instead of multi-byte arrow-key escape sequences, which are less reliable on the EFI console. The run fails if GRUB never confirms the serial console entry. --- scripts/check-qemu-install | 56 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index cabda683..9b63e90f 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -644,21 +644,49 @@ def BOOTLOADERchooseSerialConsole(child, live: bool) -> None: # XXX: UEFI systems directly load GRUB, BIOS systems fallback to ISOLINUX if live and args.uefi: - # Let UEFI start before GRUB - child.expect(UEFI_STRING, timeout=BOOTLOADER_TMO) - # Wait for GRUB - child.expect(GRUB_STRING, timeout=BOOTLOADER_TMO) - time.sleep(BOOTLOADER_LOAD_TMO) + def expectSelected(title, timeout=15) -> bool: + try: + child.expect_exact(b'*' + title, timeout=timeout) + except (pexpect.TIMEOUT, pexpect.EOF): + recent = child.before[-1500:] + log.warning( + f'GRUB did not confirm selection of {title!r}; ' + f'recent output: {recent!r}' + ) + return False + return True + + # The countdown is printed after all menu entries have been drawn. + child.expect( + rb'The highlighted entry will be executed automatically in \d+s\.', + timeout=120, + ) - # Select GRUB serial console - # Key DOWN -> fail-safe mode - child.send(KEY_DOWN) - time.sleep(BOOTLOADER_SLEEP) - # Key DOWN -> Serial Console boot - child.send(KEY_DOWN) - time.sleep(BOOTLOADER_SLEEP) - # Boot - child.send(KEY_RETURN) + # A missing acknowledgement does not tell us whether the key was received. + # Restart from Home instead of repeating Down from an unknown selection. + for _ in range(3): + if child.eof(): + return + + # Ctrl-A is Home without the EFI console's escape-sequence parsing. + child.sendcontrol('a') + # Retry a dropped Home before the 10-second autoboot timeout expires. + if not expectSelected(b'Live system (vyos) - KVM console', timeout=1): + continue + + for title in ( + b'Live system (vyos fail-safe mode)', + b'Live system (vyos) - Serial console', + ): + # Ctrl-N is Down without the escape-sequence parsing of arrow keys. + child.sendcontrol('n') + if not expectSelected(title): + break + else: + child.send(b'\r') + return + + raise RuntimeError('Failed to confirm GRUB serial console boot selection after 3 attempts') elif live and not args.uefi: # Wait for ISOLINUX child.expect(ISOLINUX_STRING, timeout=BOOTLOADER_TMO) -- cgit v1.2.3 From 97445025558f23c66e0ce1f5965bb9de84c51465 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 10 Nov 2026 18:33:22 +0100 Subject: smoketest: T9402: fail with a clear error if QEMU exits during GRUB selection --- scripts/check-qemu-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index 9b63e90f..9f2f4eb5 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -666,7 +666,7 @@ def BOOTLOADERchooseSerialConsole(child, live: bool) -> None: # Restart from Home instead of repeating Down from an unknown selection. for _ in range(3): if child.eof(): - return + raise RuntimeError('QEMU exited during GRUB menu selection') # Ctrl-A is Home without the EFI console's escape-sequence parsing. child.sendcontrol('a') -- cgit v1.2.3 From f2ac8b0d4034438dd0aae46a6984bff12328e191 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Tue, 10 Nov 2026 18:33:29 +0100 Subject: smoketest: T9402: keep resending Home until the GRUB countdown expires Three unacknowledged Home keys failed the run after about three seconds, although most of the autoboot countdown was still left. A guest stalled for over a second on a loaded host could trigger it. Home is now resent until shortly before the countdown expires and only then counts against the three attempts. --- scripts/check-qemu-install | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/check-qemu-install b/scripts/check-qemu-install index 9f2f4eb5..b8ab3f61 100755 --- a/scripts/check-qemu-install +++ b/scripts/check-qemu-install @@ -658,21 +658,28 @@ def BOOTLOADERchooseSerialConsole(child, live: bool) -> None: # The countdown is printed after all menu entries have been drawn. child.expect( - rb'The highlighted entry will be executed automatically in \d+s\.', + rb'The highlighted entry will be executed automatically in (\d+)s\.', timeout=120, ) + # Until a key is confirmed, an unacknowledged Home is resent without + # using up an attempt, as long as the countdown may still be running. + autoboot = time.monotonic() + int(child.match.group(1)) - 2 # A missing acknowledgement does not tell us whether the key was received. # Restart from Home instead of repeating Down from an unknown selection. - for _ in range(3): + attempts = 3 + while attempts: if child.eof(): raise RuntimeError('QEMU exited during GRUB menu selection') # Ctrl-A is Home without the EFI console's escape-sequence parsing. child.sendcontrol('a') - # Retry a dropped Home before the 10-second autoboot timeout expires. if not expectSelected(b'Live system (vyos) - KVM console', timeout=1): + if time.monotonic() >= autoboot: + attempts -= 1 continue + # A received key stops the countdown + autoboot = 0 for title in ( b'Live system (vyos fail-safe mode)', @@ -685,6 +692,7 @@ def BOOTLOADERchooseSerialConsole(child, live: bool) -> None: else: child.send(b'\r') return + attempts -= 1 raise RuntimeError('Failed to confirm GRUB serial console boot selection after 3 attempts') elif live and not args.uefi: -- cgit v1.2.3