Skip to content

Commit 9bf8b66

Browse files
committed
Added Unit-Test that only works inside QEMU
1 parent 4dea635 commit 9bf8b66

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

uefi-test-runner/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ log = { version = "0.4.11", default-features = false }
1717
rlibc = "1.0.0"
1818
qemu-exit = "2.0.0"
1919

20+
[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dependencies]
21+
runs_inside_qemu = "1.0.2"
22+
2023
[features]
2124
# This feature should only be enabled in our CI, it disables some tests
2225
# which currently fail in that environment (see #103 for discussion).

uefi-test-runner/src/main.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ use uefi::prelude::*;
1717
use uefi::proto::console::serial::Serial;
1818
use uefi::table::boot::MemoryDescriptor;
1919

20+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
21+
use runs_inside_qemu::runs_inside_qemu;
22+
2023
mod boot;
2124
mod proto;
2225
mod runtime;
@@ -31,6 +34,12 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
3134
// output firmware-vendor (CStr16 to Rust string)
3235
let mut buf = String::new();
3336
st.firmware_vendor().as_str_in_buf(&mut buf).unwrap();
37+
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
38+
{
39+
if runs_inside_qemu() {
40+
assert_eq!("EDK II", buf.as_str());
41+
}
42+
}
3443
info!("Firmware Vendor: {}", buf.as_str());
3544

3645
// Reset the console before running all the other tests.

0 commit comments

Comments
 (0)