Skip to content

Commit 46e47c7

Browse files
test-runner: Test the uefi::system module
1 parent fc637c8 commit 46e47c7

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

uefi-test-runner/src/main.rs

+25-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use uefi::proto::console::serial::Serial;
1313
use uefi::proto::device_path::build::{self, DevicePathBuilder};
1414
use uefi::proto::device_path::messaging::Vendor;
1515
use uefi::table::boot::{MemoryMap, MemoryType};
16-
use uefi::{print, println, Result};
16+
use uefi::{print, println, system, Result};
1717

1818
mod boot;
1919
mod fs;
@@ -45,6 +45,9 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
4545
// Ensure the tests are run on a version of UEFI we support.
4646
check_revision(st.uefi_revision());
4747

48+
// Check the `uefi::system` module.
49+
check_system(&st);
50+
4851
// Test all the boot services.
4952
let bt = st.boot_services();
5053

@@ -67,6 +70,8 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
6770
}
6871

6972
fn check_revision(rev: uefi::table::Revision) {
73+
assert_eq!(system::uefi_revision(), rev);
74+
7075
let (major, minor) = (rev.major(), rev.minor());
7176

7277
info!("UEFI {}.{}", major, minor / 10);
@@ -78,6 +83,25 @@ fn check_revision(rev: uefi::table::Revision) {
7883
);
7984
}
8085

86+
fn check_system(st: &SystemTable<Boot>) {
87+
assert_eq!(system::firmware_vendor(), cstr16!("EDK II"));
88+
check_revision(system::uefi_revision());
89+
90+
assert_eq!(system::firmware_revision(), st.firmware_revision());
91+
system::with_config_table(|t| assert_eq!(t, st.config_table()));
92+
93+
system::with_stdout(|stdout| {
94+
stdout
95+
.output_string(cstr16!("test system::with_stdout\n"))
96+
.unwrap()
97+
});
98+
system::with_stderr(|stdout| {
99+
stdout
100+
.output_string(cstr16!("test system::with_stderr\n"))
101+
.unwrap()
102+
});
103+
}
104+
81105
#[derive(Clone, Copy, Debug)]
82106
enum HostRequest {
83107
/// Tell the host to take a screenshot and compare against the

0 commit comments

Comments
 (0)