From patchwork Mon Feb 16 01:35:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1895 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771205773; bh=G58+tz6kF8VWz++rdhyV6QcwM7A73p9VXyhRM6+wy80=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uWft/553htf1TKrjwbQSk+jbcQ8F/6zjDI305vfugM3VuG4RlHVk1sINcwni5EHD0 4HnfWmdWgTufaEC4jlOphr6qjmtZ4zo8s97tjC+P/Xs495iKzcjIpFnMS4oflxm3J0 IPS0Z/NSIL6R996T8gi4V72Yp7YuLAMjO45CarsqDUGmJbk7NB6jIxJaPpLrNSrKYY FHARQv6Js8L6amWxyUobxwZKVs3olnNTrm5sNLrzgYE2KjUQnGgvE1l01NqyfuLrQ8 9H117EUTBDx9+f8P1hAIlSc9klfq87iF4ZGeroiwLVAskr6WRFDfZxdn8SUO/peviv bEvUTGJG66fnA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id AA56869BDB for ; Sun, 15 Feb 2026 18:36:13 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id CN7Mfv0kswo2 for ; Sun, 15 Feb 2026 18:36:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771205773; bh=G58+tz6kF8VWz++rdhyV6QcwM7A73p9VXyhRM6+wy80=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=uWft/553htf1TKrjwbQSk+jbcQ8F/6zjDI305vfugM3VuG4RlHVk1sINcwni5EHD0 4HnfWmdWgTufaEC4jlOphr6qjmtZ4zo8s97tjC+P/Xs495iKzcjIpFnMS4oflxm3J0 IPS0Z/NSIL6R996T8gi4V72Yp7YuLAMjO45CarsqDUGmJbk7NB6jIxJaPpLrNSrKYY FHARQv6Js8L6amWxyUobxwZKVs3olnNTrm5sNLrzgYE2KjUQnGgvE1l01NqyfuLrQ8 9H117EUTBDx9+f8P1hAIlSc9klfq87iF4ZGeroiwLVAskr6WRFDfZxdn8SUO/peviv bEvUTGJG66fnA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 96CBA69BDD for ; Sun, 15 Feb 2026 18:36:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771205772; bh=TchDHfsIgoj2p/3iLAp4NS0D6z29LR00a2jKiHTTA0Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZCHCmjEywF5SC/dJPbHG+jErsfon8+1sAIM3Bo8z7yMKNoYhnUxblh2QWnyA/2WlM kjrSOda9HUCHlDlOAfC7akRKaR39w2NXphf4E0/CWTBdl5F6qzqPLE1deg8U3hWyxC sqVB4W7uzspO8evZYVTq1SISreaY84v9hNxp5fI6b/PaJGD1lGbdCmoav85TOjrTFr DCUYOgX3baqHWOOHwWN8UNYR3z9Jw3bTEOaQFKcsdne+VlUmuLtvceCnEC2NIfvpgd o5tyDZID2tiTP//q+7v/BKwocUVl6J/Te7OfKrD3Z3i1yeEETu5y6b7azvfLXDtRgr jU/SYrenz4d1A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9C8A969BDB; Sun, 15 Feb 2026 18:36:12 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id L9PS2O0pI3OM; Sun, 15 Feb 2026 18:36:12 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1771205768; bh=1qdcLv/rfSIT/PcklgX31ixviuzEOC+Io2Q+06ENFbU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j0z5Fuf/szYJHdjYHQNQWIBTwZKWMC3644oPClW47iVPmgavx72PyoOh1OJQmDqIf EKfHLhC7T7xk+JDYzhVSIA9T3bIySb3msfnAEjttO9BcSOaCppRj7wjJdCd1VpIeTY 7ba6yF0jZlfteL/h0xFV5Y8SGk2BaXFvY32IVZmy0+69OdH5wL5MSYpjptskxb6baS RCQVyz34Vbvbzg9cmIWB8zYzttvwHpuFFgndw95OoCWy2H30KtJ3CGn0m0FH75b5aQ sf9zyKi02zKVr7jPUFmuYhb+m9D8BPprUDmkGE4O4mdBs+FT/tbejWg84YrPqIZvS9 2hTMu80cz5xcQ== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 03E1169BCC; Sun, 15 Feb 2026 18:36:07 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Sun, 15 Feb 2026 18:35:03 -0700 Message-ID: <20260216013511.4079770-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260216013511.4079770-1-sjg@u-boot.org> References: <20260216013511.4079770-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: YQ2XHH3IRF2GN5MRAUQT72EAIVOWQ7BN X-Message-ID-Hash: YQ2XHH3IRF2GN5MRAUQT72EAIVOWQ7BN X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Simon Glass , "Claude Opus 4 . 6" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/17] ulib: test: Add EFI demo pytest for arm64 List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Add run_efi_demo() helper that writes a startup.nsh script next to demo-app.efi in the build directory, boots QEMU with the given UEFI firmware, and checks for the expected demo output. Refactor test_ulib_demo_efi_x86() to use the shared helper and add test_ulib_demo_efi_arm64() which uses qemu-system-aarch64 with the appropriate firmware path. Co-developed-by: Claude Opus 4.6 Signed-off-by: Simon Glass --- test/py/tests/test_ulib.py | 69 ++++++++++++++++++++++++++++---------- 1 file changed, 51 insertions(+), 18 deletions(-) diff --git a/test/py/tests/test_ulib.py b/test/py/tests/test_ulib.py index 1c98b8b6880..c7d79515bb9 100644 --- a/test/py/tests/test_ulib.py +++ b/test/py/tests/test_ulib.py @@ -6,6 +6,7 @@ import os import shutil import subprocess +import tempfile import pytest import utils @@ -333,34 +334,66 @@ def test_ulib_demo_riscv64(ubman): """Test the ulib demo binary under QEMU RISC-V 64.""" run_bios_demo(ubman, 'qemu-system-riscv64') -@pytest.mark.localqemu -@pytest.mark.boardspec('efi-x86_app64') -@pytest.mark.buildconfigspec("examples") -def test_ulib_demo_efi_x86(ubman): - """Test the ulib demo EFI application under QEMU x86_64 with OVMF.""" +def run_efi_demo(ubman, qemu_binary, fw_code, fw_vars, extra_qemu_args=None): + """Run a ulib demo EFI application under QEMU with UEFI firmware. + + Writes a startup.nsh script next to demo-app.efi in the build + directory, boots QEMU with the given firmware, and checks for + expected output. + + Args: + ubman (ConsoleBase): Test fixture providing build directory + etc. + qemu_binary (str): QEMU system binary name + (e.g. 'qemu-system-x86_64') + fw_code (str): Path to UEFI firmware code file + fw_vars (str): Path to UEFI firmware variables file (or None) + extra_qemu_args (list): Additional QEMU arguments + """ build = ubman.config.build_dir efi_dir = os.path.join(build, 'examples', 'ulib') demo_efi = os.path.join(efi_dir, 'demo-app.efi') assert os.path.exists(demo_efi), 'demo-app.efi not found in build directory' - assert shutil.which('qemu-system-x86_64'), 'qemu-system-x86_64 not found' - - ovmf_code = '/usr/share/OVMF/OVMF_CODE_4M.fd' - ovmf_vars = '/usr/share/OVMF/OVMF_VARS_4M.fd' - assert os.path.exists(ovmf_code), 'OVMF firmware not found' + assert shutil.which(qemu_binary), f'{qemu_binary} not found' + assert os.path.exists(fw_code), f'UEFI firmware not found: {fw_code}' with open(os.path.join(efi_dir, 'startup.nsh'), 'w', encoding='utf-8') as nsh: nsh.write('fs0:demo-app.efi\n') - # OVMF needs a writable copy of the vars file - vars_copy = os.path.join(efi_dir, 'OVMF_VARS_4M.fd') - shutil.copy(ovmf_vars, vars_copy) + cmd = [qemu_binary] - cmd = ['qemu-system-x86_64', - '-drive', f'if=pflash,format=raw,file={ovmf_code},readonly=on', - '-drive', f'if=pflash,format=raw,file={vars_copy}', - '-drive', f'file=fat:rw:{efi_dir},format=raw', - '-nographic', '-no-reboot', '-nic', 'none'] + # Set up firmware pflash drives + cmd += ['-drive', f'if=pflash,format=raw,file={fw_code},readonly=on'] + if fw_vars: + vars_copy = os.path.join(efi_dir, 'vars.fd') + shutil.copy(fw_vars, vars_copy) + cmd += ['-drive', f'if=pflash,format=raw,file={vars_copy}'] + + if extra_qemu_args: + cmd += extra_qemu_args + + # FAT drive with EFI binary and startup script + cmd += ['-drive', f'file=fat:rw:{efi_dir},format=raw', + '-nographic', '-no-reboot', '-nic', 'none'] out = run_qemu_demo(cmd, timeout=15) assert_demo_output(out) + +@pytest.mark.localqemu +@pytest.mark.boardspec('efi-x86_app64') +@pytest.mark.buildconfigspec("examples") +def test_ulib_demo_efi_x86(ubman): + """Test the ulib demo EFI application under QEMU x86_64 with OVMF.""" + run_efi_demo(ubman, 'qemu-system-x86_64', + '/usr/share/OVMF/OVMF_CODE_4M.fd', + '/usr/share/OVMF/OVMF_VARS_4M.fd') + +@pytest.mark.localqemu +@pytest.mark.boardspec('efi-arm_app64') +@pytest.mark.buildconfigspec("examples") +def test_ulib_demo_efi_arm64(ubman): + """Test the ulib demo EFI application under QEMU aarch64 with UEFI.""" + run_efi_demo(ubman, 'qemu-system-aarch64', + '/usr/share/qemu-efi-aarch64/QEMU_EFI.fd', None, + ['--machine', 'virt', '-cpu', 'max'])