From: Simon Glass <simon.glass@canonical.com> Enable CONFIG_ULIB and CONFIG_EXAMPLES in qemu-x86_64_nospl_defconfig so that the demo.rom binary is built. Add test_ulib_demo_rom_64() which boots demo.rom under qemu-system-x86_64 and verifies the expected output, following the same pattern as the existing qemu-x86 test. Co-developed-by: Claude Opus 4.5 <noreply@anthropic.com> Signed-off-by: Simon Glass <simon.glass@canonical.com> --- configs/qemu-x86_64_nospl_defconfig | 2 ++ test/py/tests/test_ulib.py | 37 ++++++++++++++++++++++------- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/configs/qemu-x86_64_nospl_defconfig b/configs/qemu-x86_64_nospl_defconfig index 4452b8c6e0a..950d2d2e419 100644 --- a/configs/qemu-x86_64_nospl_defconfig +++ b/configs/qemu-x86_64_nospl_defconfig @@ -79,4 +79,6 @@ CONFIG_CONSOLE_SCROLL_LINES=5 CONFIG_GENERATE_ACPI_TABLE=y CONFIG_CMD_DHRYSTONE=y # CONFIG_GZIP is not set +CONFIG_ULIB=y +CONFIG_EXAMPLES=y CONFIG_UNIT_TEST=y diff --git a/test/py/tests/test_ulib.py b/test/py/tests/test_ulib.py index 957417ede31..b1ce5792801 100644 --- a/test/py/tests/test_ulib.py +++ b/test/py/tests/test_ulib.py @@ -221,19 +221,26 @@ def test_ulib_api_header(ubman): assert 'ub_snprintf(char *buf, size_t size, const char *fmt, ...)' in out assert 'ub_vprintf(const char *fmt, va_list args)' in out -@pytest.mark.localqemu -@pytest.mark.boardspec('qemu-x86') -@pytest.mark.buildconfigspec("examples") -def test_ulib_demo_rom(ubman): - """Test the ulib demo ROM image under QEMU x86.""" +def run_x86_rom_demo(ubman, qemu_binary): + """Boot the demo ROM image under QEMU and check for expected output. + + Locates demo.rom in the build directory, launches the given QEMU + binary with it, and asserts that the expected demo output is present. + + Args: + ubman (ConsoleBase): Test fixture providing build directory + etc. + qemu_binary (str): QEMU system binary + (e.g. 'qemu-system-i386') + """ build = ubman.config.build_dir demo_rom = os.path.join(build, 'demo.rom') assert os.path.exists(demo_rom), 'demo.rom not found in build directory' - assert shutil.which('qemu-system-i386'), 'qemu-system-i386 not found' + assert shutil.which(qemu_binary), f'{qemu_binary} not found' + + cmd = [qemu_binary, '-bios', demo_rom, '-nographic', '-no-reboot'] - cmd = ['qemu-system-i386', '-bios', demo_rom, '-nographic', - '-no-reboot'] with subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: try: @@ -250,3 +257,17 @@ def test_ulib_demo_rom(ubman): assert 'helper: Adding 42 + 13 = 55' in out assert '=================================' in out assert 'Demo complete' in out + +@pytest.mark.localqemu +@pytest.mark.boardspec('qemu-x86') +@pytest.mark.buildconfigspec("examples") +def test_ulib_demo_rom(ubman): + """Test the ulib demo ROM image under QEMU x86.""" + run_x86_rom_demo(ubman, 'qemu-system-i386') + +@pytest.mark.localqemu +@pytest.mark.boardspec('qemu-x86_64_nospl') +@pytest.mark.buildconfigspec("examples") +def test_ulib_demo_rom_64(ubman): + """Test the ulib demo ROM image under QEMU x86_64.""" + run_x86_rom_demo(ubman, 'qemu-system-x86_64') -- 2.43.0