From a4ca1e5979fe9c795e1ca210dd881f611d7fef21 Mon Sep 17 00:00:00 2001 From: Christian Breunig Date: Mon, 7 Sep 2026 16:34:09 +0200 Subject: smoketest: T9014: make configtest serial console image flavor agnostic The configuration tests hardcoded "system console device ttyS0 speed 115200", which only holds for amd64, whereas arm64 images expose the UART as ttyAMA0, so loading these configs produced a diff against the assert data and the tests failed. Replace the hardcoded values in all config test inputs and their assert counterparts with the @SERIAL_DEVICE@ and @SERIAL_SPEED@ placeholders. The vyos-1x-smoketest postinst queries the image flavor and implants the real values once at install time, so the test runner needs no runtime patching. Migration script 31-to-32 now derives the serial device from the flavor, too, instead of assuming ttyS0. This can be observed during vyos-1x package installation while building the ISO image Setting up vyos-1x-smoketest (999.0-14834-g16f1cf457-dirty) ... ... I: Implanted serial console ttyS0,115200 into /usr/libexec/vyos/tests/configs --- src/migration-scripts/system/31-to-32 | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/migration-scripts') diff --git a/src/migration-scripts/system/31-to-32 b/src/migration-scripts/system/31-to-32 index b68dab34f..e92473835 100644 --- a/src/migration-scripts/system/31-to-32 +++ b/src/migration-scripts/system/31-to-32 @@ -16,23 +16,34 @@ # Serial from vyos.configtree import ConfigTree +from vyos.flavor import get_image_serial_console from vyos.system import disk from vyos.system.grub import CFG_VYOS_VARS from vyos.system.grub import vars_read -serial_console = 'ttyS0' base = ['system', 'console'] def migrate(config: ConfigTree) -> None: if not config.exists(base): return + # The serial console device is defined by the image flavor - amd64 uses the + # 8250 UART at ttyS0 while arm64 systems expose the PL011 UART as ttyAMA0 + console_type, console_num, _ = get_image_serial_console() + if not console_type: + # image flavor carries no serial console data, assume 8250 UART + console_type, console_num = 'ttyS', '0' + serial_console = f'{console_type}{console_num}' + root_dir = disk.find_persistence() vars_file: str = f'{root_dir}/{CFG_VYOS_VARS}' vars_current: dict[str, str] = vars_read(vars_file) + # A system without persistent GRUB storage - like VyOS running inside a + # container - has no boot console we could detect + if not vars_current: + return + # Check if VyOS installation uses serial boot console - if vars_current['console_type'] == 'ttyS': - # In the past we only supported ttyS0 as boot console, that's why we - # can hardcode it ... + if vars_current['console_type'] == console_type: if config.exists(base + ['device', serial_console]): config.set(base + ['device', serial_console, 'kernel']) -- cgit v1.2.3