Skip to content

Commit 8e673f9

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 df262ab commit 8e673f9

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

129124
fn shutdown(image: uefi::Handle, mut st: SystemTable<Boot>) -> ! {
130-
use uefi::table::runtime::ResetType;
131-
132125
// Get our text output back.
133126
st.stdout().reset(false).unwrap();
134127

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

143130
// Exit boot services as a proof that it works :)
144131
let sizes = st.boot_services().memory_map_size();
@@ -150,15 +137,23 @@ fn shutdown(image: uefi::Handle, mut st: SystemTable<Boot>) -> ! {
150137

151138
#[cfg(target_arch = "x86_64")]
152139
{
153-
if cfg!(feature = "qemu") {
154-
use qemu_exit::QEMUExit;
155-
let custom_exit_success = 3;
156-
let qemu_exit_handle = qemu_exit::X86::new(0xF4, custom_exit_success);
157-
qemu_exit_handle.exit_success();
158-
}
140+
// Prevent unused variable warning.
141+
let _ = st;
142+
143+
use qemu_exit::QEMUExit;
144+
let custom_exit_success = 3;
145+
let qemu_exit_handle = qemu_exit::X86::new(0xF4, custom_exit_success);
146+
qemu_exit_handle.exit_success();
159147
}
160148

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

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)