Skip to content

move uefi test to run-make #144454

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/ci/docker/host-x86_64/test-various/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ ENV MUSL_TARGETS=x86_64-unknown-linux-musl \
CXX_x86_64_unknown_linux_musl=x86_64-linux-musl-g++
ENV MUSL_SCRIPT python3 /checkout/x.py --stage 2 test --host='' --target $MUSL_TARGETS

COPY host-x86_64/test-various/uefi_qemu_test /uefi_qemu_test
ENV UEFI_TARGETS=aarch64-unknown-uefi,i686-unknown-uefi,x86_64-unknown-uefi \
CC_aarch64_unknown_uefi=clang-11 \
CXX_aarch64_unknown_uefi=clang++-11 \
Expand All @@ -88,6 +87,8 @@ ENV UEFI_TARGETS=aarch64-unknown-uefi,i686-unknown-uefi,x86_64-unknown-uefi \
CC_x86_64_unknown_uefi=clang-11 \
CXX_x86_64_unknown_uefi=clang++-11
ENV UEFI_SCRIPT python3 /checkout/x.py --stage 2 build --host='' --target $UEFI_TARGETS && \
python3 -u /uefi_qemu_test/run.py
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target aarch64-unknown-uefi && \
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target i686-unknown-uefi && \
python3 /checkout/x.py --stage 2 test tests/run-make/uefi-qemu/rmake.rs --target x86_64-unknown-uefi

ENV SCRIPT $WASM_SCRIPT && $NVPTX_SCRIPT && $MUSL_SCRIPT && $UEFI_SCRIPT
140 changes: 0 additions & 140 deletions src/ci/docker/host-x86_64/test-various/uefi_qemu_test/run.py

This file was deleted.

1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -991,6 +991,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"only-stable",
"only-thumb",
"only-tvos",
"only-uefi",
"only-unix",
"only-visionos",
"only-wasm32",
Expand Down
2 changes: 1 addition & 1 deletion src/tools/tidy/src/deps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ pub(crate) const WORKSPACES: &[(&str, ExceptionList, Option<(&[&str], &[&str])>,
// tidy-alphabetical-start
("compiler/rustc_codegen_gcc", EXCEPTIONS_GCC, None, &[]),
("src/bootstrap", EXCEPTIONS_BOOTSTRAP, None, &[]),
("src/ci/docker/host-x86_64/test-various/uefi_qemu_test", EXCEPTIONS_UEFI_QEMU_TEST, None, &[]),
("src/tools/cargo", EXCEPTIONS_CARGO, None, &["src/tools/cargo"]),
//("src/tools/miri/test-cargo-miri", &[], None), // FIXME uncomment once all deps are vendored
//("src/tools/miri/test_dependencies", &[], None), // FIXME uncomment once all deps are vendored
("src/tools/rust-analyzer", EXCEPTIONS_RUST_ANALYZER, None, &[]),
("src/tools/rustbook", EXCEPTIONS_RUSTBOOK, None, &["src/doc/book", "src/doc/reference"]),
("src/tools/rustc-perf", EXCEPTIONS_RUSTC_PERF, None, &["src/tools/rustc-perf"]),
("src/tools/test-float-parse", EXCEPTIONS, None, &[]),
("tests/run-make/uefi-qemu/uefi_qemu_test", EXCEPTIONS_UEFI_QEMU_TEST, None, &[]),
// tidy-alphabetical-end
];

Expand Down
84 changes: 84 additions & 0 deletions tests/run-make/uefi-qemu/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
//! This test builds and runs a basic UEFI application on QEMU for various targets.
//!
//! You must have the relevant OVMF or AAVMF firmware installed for this to work.
//!
//! Requires: qemu-system-x86_64, qemu-system-aarch64
//! OVMF/AAVMF firmware
//!
//! Note: test assumes `/uefi_qemu_test` exists and is a self-contained crate.

//@ only-uefi

use std::path::Path;

use run_make_support::{cargo, cmd, path, rfs};

fn main() {
let target = run_make_support::target();

let (boot_filename, ovmf_dir, ovmf_code_name, ovmf_vars_name, qemu, machine, cpu) =
match target.as_str() {
"aarch64-unknown-uefi" => (
"bootaa64.efi",
Path::new("/usr/share/AAVMF"),
"AAVMF_CODE.fd",
"AAVMF_VARS.fd",
"qemu-system-aarch64",
"virt",
"cortex-a72",
),
"i686-unknown-uefi" => (
"bootia32.efi",
Path::new("/usr/share/OVMF"),
"OVMF32_CODE_4M.secboot.fd",
"OVMF32_VARS_4M.fd",
"qemu-system-x86_64",
"q35",
"qemu64",
),
"x86_64-unknown-uefi" => (
"bootx64.efi",
Path::new("/usr/share/OVMF"),
"OVMF_CODE_4M.fd",
"OVMF_VARS_4M.fd",
"qemu-system-x86_64",
"q35",
"qemu64",
),
_ => panic!("unsupported target {target}"),
};

let tmp = std::env::temp_dir();
let test_crate = tmp.join("uefi_qemu_test");
rfs::copy_dir_all(path("uefi_qemu_test"), &test_crate);

cargo().args(&["build", "--target", &target]).current_dir(&test_crate).run();

// Prepare ESP
let esp = test_crate.join("esp");
let boot = esp.join("efi/boot");
rfs::create_dir_all(&boot);

let src_efi = test_crate.join("target").join(&target).join("debug/uefi_qemu_test.efi");
let dst_efi = boot.join(boot_filename);
rfs::copy(&src_efi, &dst_efi);

// Copy OVMF files
let code = ovmf_dir.join(ovmf_code_name);
let vars_src = ovmf_dir.join(ovmf_vars_name);
let vars_dst = tmp.join("vars.fd");
rfs::copy(&vars_src, &vars_dst);

let output = cmd(qemu)
.args(["-machine", machine])
.args(["-cpu", cpu])
.args(["-display", "none"])
.args(["-serial", "stdio"])
.args(["-drive", &format!("if=pflash,format=raw,readonly=on,file={}", code.display())])
.args(["-drive", &format!("if=pflash,format=raw,readonly=off,file={}", vars_dst.display())])
.args(["-drive", &format!("format=raw,file=fat:rw:{}", esp.display())])
.run()
.stdout_utf8();

assert!(output.contains("Hello World!"), "invalid output for {target}:\n{output}");
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,7 @@ fn panic_handler(_info: &panic::PanicInfo) -> ! {

#[export_name = "efi_main"]
pub extern "C" fn main(_h: Handle, st: *mut SystemTable) -> Status {
let s = [
0x0048u16, 0x0065u16, 0x006cu16, 0x006cu16, 0x006fu16, // "Hello"
0x0020u16, // " "
0x0057u16, 0x006fu16, 0x0072u16, 0x006cu16, 0x0064u16, // "World"
0x0021u16, // "!"
0x000au16, // "\n"
0x0000u16, // NUL
];
let s = b"Hello World!\n\0".map(|c| u16::from(c));

// Print "Hello World!".
let r = unsafe { ((*(*st).con_out).output_string)((*st).con_out, s.as_ptr() as *mut Char16) };
Expand Down
Loading