Skip to content

Commit

Permalink
test-runner: Test boot::get_handle_for_protocol
Browse files Browse the repository at this point in the history
Modify send_request_to_host to use freestanding boot functions instead of
BootServices. There are plenty of other places that still test
BootServices::get_handle_for_protocol.
  • Loading branch information
nicholasbishop committed Aug 11, 2024
1 parent d66959a commit 9e2cf34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
12 changes: 5 additions & 7 deletions uefi-test-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,9 @@ fn reconnect_serial_to_console(serial_handle: Handle) {
/// Send the `request` string to the host via the `serial` device, then
/// wait up to 10 seconds to receive a reply. Returns an error if the
/// reply is not `"OK\n"`.
fn send_request_to_host(bt: &BootServices, request: HostRequest) {
let serial_handle = bt
.get_handle_for_protocol::<Serial>()
.expect("Failed to get serial handle");
fn send_request_to_host(request: HostRequest) {
let serial_handle =
uefi::boot::get_handle_for_protocol::<Serial>().expect("Failed to get serial handle");

// Open the serial protocol in exclusive mode.
//
Expand All @@ -183,8 +182,7 @@ fn send_request_to_host(bt: &BootServices, request: HostRequest) {
// end with `connect_controller`.
//
// [console splitter driver]: https://github.com/tianocore/edk2/blob/HEAD/MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitter.c
let mut serial = bt
.open_protocol_exclusive::<Serial>(serial_handle)
let mut serial = uefi::boot::open_protocol_exclusive::<Serial>(serial_handle)
.expect("Could not open serial protocol");

// Send the request, but don't check the result yet so that first
Expand All @@ -211,7 +209,7 @@ fn shutdown(mut st: SystemTable<Boot>) -> ! {
// Tell the host that tests are done. We are about to exit boot
// services, so we can't easily communicate with the host any later
// than this.
send_request_to_host(st.boot_services(), HostRequest::TestsComplete);
send_request_to_host(HostRequest::TestsComplete);

// Send a special log to the host so that we can verify that logging works
// up until exiting boot services. See `reconnect_serial_to_console` for the
Expand Down
2 changes: 1 addition & 1 deletion uefi-test-runner/src/proto/console/gop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub unsafe fn test(bt: &BootServices) {

// `draw_fb` is skipped on aarch64, so the screenshot doesn't match.
if cfg!(not(target_arch = "aarch64")) {
send_request_to_host(bt, HostRequest::Screenshot("gop_test"));
send_request_to_host(HostRequest::Screenshot("gop_test"));
}
}

Expand Down

0 comments on commit 9e2cf34

Please sign in to comment.