Skip to content

Commit c46a09d

Browse files
test-runner: Drop qemu feature
We now assume that the app is always running in QEMU, so this doesn't need to be conditional.
1 parent 136b88f commit c46a09d

File tree

5 files changed

+58
-71
lines changed

5 files changed

+58
-71
lines changed

uefi-test-runner/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ qemu-exit = "3.0.0"
1717
# This feature should only be enabled in our CI, it disables some tests
1818
# which currently fail in that environment (see #103 for discussion).
1919
ci = []
20-
qemu = ["uefi-services/qemu"]
20+

uefi-test-runner/src/main.rs

Lines changed: 56 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -83,64 +83,51 @@ fn check_revision(rev: uefi::table::Revision) {
8383
/// of it, we just pause the tests for a couple of seconds to allow visual
8484
/// inspection of the output.
8585
fn check_screenshot(bt: &BootServices, name: &str) {
86-
if cfg!(feature = "qemu") {
87-
let serial_handles = bt
88-
.find_handles::<Serial>()
89-
.expect("Failed to get serial handles");
90-
91-
// Use the second serial device handle. Opening a serial device
92-
// in exclusive mode breaks the connection between stdout and
93-
// the serial device, and we don't want that to happen to the
94-
// first serial device since it's used for log transport.
95-
let serial_handle = *serial_handles
96-
.get(1)
97-
.expect("Second serial device is missing");
98-
99-
let mut serial = bt
100-
.open_protocol_exclusive::<Serial>(serial_handle)
101-
.expect("Could not open serial protocol");
102-
103-
// Set a large timeout to avoid problems with CI
104-
let mut io_mode = *serial.io_mode();
105-
io_mode.timeout = 10_000_000;
106-
serial
107-
.set_attributes(&io_mode)
108-
.expect("Failed to configure serial port timeout");
109-
110-
// Send a screenshot request to the host
111-
serial
112-
.write(b"SCREENSHOT: ")
113-
.expect("Failed to send request");
114-
let name_bytes = name.as_bytes();
115-
serial.write(name_bytes).expect("Failed to send request");
116-
serial.write(b"\n").expect("Failed to send request");
117-
118-
// Wait for the host's acknowledgement before moving forward
119-
let mut reply = [0; 3];
120-
serial
121-
.read(&mut reply[..])
122-
.expect("Failed to read host reply");
123-
124-
assert_eq!(&reply[..], b"OK\n", "Unexpected screenshot request reply");
125-
} else {
126-
// Outside of QEMU, give the user some time to inspect the output
127-
bt.stall(3_000_000);
128-
}
86+
let serial_handles = bt
87+
.find_handles::<Serial>()
88+
.expect("Failed to get serial handles");
89+
90+
// Use the second serial device handle. Opening a serial device
91+
// in exclusive mode breaks the connection between stdout and
92+
// the serial device, and we don't want that to happen to the
93+
// first serial device since it's used for log transport.
94+
let serial_handle = *serial_handles
95+
.get(1)
96+
.expect("Second serial device is missing");
97+
98+
let mut serial = bt
99+
.open_protocol_exclusive::<Serial>(serial_handle)
100+
.expect("Could not open serial protocol");
101+
102+
// Set a large timeout to avoid problems with CI
103+
let mut io_mode = *serial.io_mode();
104+
io_mode.timeout = 10_000_000;
105+
serial
106+
.set_attributes(&io_mode)
107+
.expect("Failed to configure serial port timeout");
108+
109+
// Send a screenshot request to the host
110+
serial
111+
.write(b"SCREENSHOT: ")
112+
.expect("Failed to send request");
113+
let name_bytes = name.as_bytes();
114+
serial.write(name_bytes).expect("Failed to send request");
115+
serial.write(b"\n").expect("Failed to send request");
116+
117+
// Wait for the host's acknowledgement before moving forward
118+
let mut reply = [0; 3];
119+
serial
120+
.read(&mut reply[..])
121+
.expect("Failed to read host reply");
122+
123+
assert_eq!(&reply[..], b"OK\n", "Unexpected screenshot request reply");
129124
}
130125

131126
fn shutdown(image: uefi::Handle, mut st: SystemTable<Boot>) -> ! {
132-
use uefi::table::runtime::ResetType;
133-
134127
// Get our text output back.
135128
st.stdout().reset(false).unwrap();
136129

137-
// Inform the user, and give him time to read on real hardware
138-
if cfg!(not(feature = "qemu")) {
139-
info!("Testing complete, shutting down in 3 seconds...");
140-
st.boot_services().stall(3_000_000);
141-
} else {
142-
info!("Testing complete, shutting down...");
143-
}
130+
info!("Testing complete, shutting down...");
144131

145132
// Exit boot services as a proof that it works :)
146133
let sizes = st.boot_services().memory_map_size();
@@ -152,15 +139,23 @@ fn shutdown(image: uefi::Handle, mut st: SystemTable<Boot>) -> ! {
152139

153140
#[cfg(target_arch = "x86_64")]
154141
{
155-
if cfg!(feature = "qemu") {
156-
use qemu_exit::QEMUExit;
157-
let custom_exit_success = 3;
158-
let qemu_exit_handle = qemu_exit::X86::new(0xF4, custom_exit_success);
159-
qemu_exit_handle.exit_success();
160-
}
142+
// Prevent unused variable warning.
143+
drop(st);
144+
145+
use qemu_exit::QEMUExit;
146+
let custom_exit_success = 3;
147+
let qemu_exit_handle = qemu_exit::X86::new(0xF4, custom_exit_success);
148+
qemu_exit_handle.exit_success();
161149
}
162150

163-
// Shut down the system
164-
let rt = unsafe { st.runtime_services() };
165-
rt.reset(ResetType::Shutdown, Status::SUCCESS, None);
151+
#[cfg(not(target_arch = "x86_64"))]
152+
{
153+
// Shut down the system
154+
let rt = unsafe { st.runtime_services() };
155+
rt.reset(
156+
uefi::table::runtime::ResetType::Shutdown,
157+
Status::SUCCESS,
158+
None,
159+
);
160+
}
166161
}

uefi-test-runner/src/proto/media/known_disk.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -248,12 +248,6 @@ fn test_raw_disk_io2(handle: Handle, bt: &BootServices) {
248248
/// Run various file-system related tests on a special test disk. The disk is created by
249249
/// `xtask/src/disk.rs`.
250250
pub fn test_known_disk(bt: &BootServices) {
251-
// This test is only valid when running in the specially-prepared
252-
// qemu with the test disk.
253-
if !cfg!(feature = "qemu") {
254-
return;
255-
}
256-
257251
let handles = bt
258252
.find_handles::<SimpleFileSystem>()
259253
.expect("Failed to get handles for `SimpleFileSystem` protocol");

xtask/src/cargo.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ pub enum Feature {
5050
Logger,
5151

5252
Ci,
53-
Qemu,
5453
}
5554

5655
impl Feature {
@@ -61,7 +60,6 @@ impl Feature {
6160
Self::Logger => "logger",
6261

6362
Self::Ci => "uefi-test-runner/ci",
64-
Self::Qemu => "uefi-test-runner/qemu",
6563
}
6664
}
6765

xtask/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ fn run_miri() -> Result<()> {
8686

8787
/// Build uefi-test-runner and run it in QEMU.
8888
fn run_vm_tests(opt: &QemuOpt) -> Result<()> {
89-
let mut features = vec![Feature::Qemu];
89+
let mut features = vec![];
9090

9191
// Always enable the ci feature when not building on Linux so that
9292
// the MP test is skipped. That test doesn't work with kvm disabled

0 commit comments

Comments
 (0)