[Concept,05/13] ulib: x86: Add Rust demo for qemu-x86_64_nospl
Commit Message
From: Simon Glass <simon.glass@canonical.com>
Define the x86_64-unknown-none Rust target and enable
CONFIG_RUST_EXAMPLES in the qemu-x86_64_nospl defconfig. Add the DTS
node for the Rust demo binary and a QEMU boot test.
Co-developed-by: Claude Opus 4.6 <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---
arch/x86/dts/u-boot.dtsi | 18 +++++++++++++++++
configs/qemu-x86_64_nospl_defconfig | 1 +
scripts/Makefile.ulib-example | 1 +
test/py/tests/test_ulib.py | 30 +++++++++++++++++++++++++++++
4 files changed, 50 insertions(+)
@@ -213,4 +213,22 @@
};
}; };
#endif
+
+#ifdef CONFIG_RUST_EXAMPLES
+/ { binman {
+ rust-demo-rom {
+ filename = "rust-demo.rom";
+ insert-template = <&rom_common>;
+
+ blob {
+ filename = "examples/ulib/rust-demo-nodtb.bin";
+ offset = <CONFIG_X86_OFFSET_U_BOOT>;
+ };
+ u-boot-dtb {
+ };
+ fdtmap {
+ };
+ };
+}; };
+#endif
#endif
@@ -81,4 +81,5 @@ CONFIG_CMD_DHRYSTONE=y
# CONFIG_GZIP is not set
CONFIG_ULIB=y
CONFIG_EXAMPLES=y
+CONFIG_RUST_EXAMPLES=y
CONFIG_UNIT_TEST=y
@@ -21,6 +21,7 @@ ULIB_EXAMPLES := demo
# --- Rust examples ---
RUSTC := rustc
+RUST_TARGET_x86 := x86_64-unknown-none
RUST_TARGET := $(RUST_TARGET_$(EXAMPLE_ARCH))
ifeq ($(CONFIG_RUST_EXAMPLES),y)
@@ -292,6 +292,36 @@ 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')
+def run_x86_rom_rust_demo(ubman, qemu_binary):
+ """Boot the Rust demo ROM image under QEMU and check for expected output.
+
+ Locates rust-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-x86_64')
+ """
+ build = ubman.config.build_dir
+ demo_rom = os.path.join(build, 'rust-demo.rom')
+
+ assert os.path.exists(demo_rom), \
+ 'rust-demo.rom not found in build directory'
+ assert shutil.which(qemu_binary), f'{qemu_binary} not found'
+
+ cmd = [qemu_binary, '-bios', demo_rom, '-nographic', '-no-reboot']
+ out = run_qemu_demo(cmd)
+ assert_demo_output(out)
+
+@pytest.mark.localqemu
+@pytest.mark.boardspec('qemu-x86_64_nospl')
+@pytest.mark.buildconfigspec("rust_examples")
+def test_ulib_rust_demo_rom_64(ubman):
+ """Test the Rust ulib demo ROM image under QEMU x86_64."""
+ run_x86_rom_rust_demo(ubman, 'qemu-system-x86_64')
+
def run_bios_demo(ubman, qemu_binary, extra_qemu_args=None):
"""Boot the demo.bin binary under QEMU and check for expected output.