Skip to content

test-runner: Consistently use global image handle #1189

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion uefi-test-runner/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
boot::test(&st);

// Test all the supported protocols.
proto::test(image, &mut st);
proto::test(&mut st);

// TODO: runtime services work before boot services are exited, but we'd
// probably want to test them after exit_boot_services. However,
Expand Down
4 changes: 2 additions & 2 deletions uefi-test-runner/src/proto/console/gop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use uefi::prelude::*;
use uefi::proto::console::gop::{BltOp, BltPixel, FrameBuffer, GraphicsOutput, PixelFormat};
use uefi::table::boot::{OpenProtocolAttributes, OpenProtocolParams};

pub unsafe fn test(image: Handle, bt: &BootServices) {
pub unsafe fn test(bt: &BootServices) {
info!("Running graphics output protocol test");
let handle = bt
.get_handle_for_protocol::<GraphicsOutput>()
Expand All @@ -12,7 +12,7 @@ pub unsafe fn test(image: Handle, bt: &BootServices) {
.open_protocol::<GraphicsOutput>(
OpenProtocolParams {
handle,
agent: image,
agent: bt.image_handle(),
controller: None,
},
// For this test, don't open in exclusive mode. That
Expand Down
4 changes: 2 additions & 2 deletions uefi-test-runner/src/proto/console/mod.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use uefi::prelude::*;

pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
pub fn test(st: &mut SystemTable<Boot>) {
info!("Testing console protocols");

stdout::test(st.stdout());

let bt = st.boot_services();
unsafe {
serial::test(bt);
gop::test(image, bt);
gop::test(bt);
}
pointer::test(bt);
}
Expand Down
8 changes: 4 additions & 4 deletions uefi-test-runner/src/proto/device_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ use uefi::proto::device_path::text::*;
use uefi::proto::device_path::{DevicePath, LoadedImageDevicePath};
use uefi::proto::loaded_image::LoadedImage;

pub fn test(image: Handle, bt: &BootServices) {
pub fn test(bt: &BootServices) {
info!("Running device path protocol test");

// test 1/2: test low-level API by directly opening all protocols
{
let loaded_image = bt
.open_protocol_exclusive::<LoadedImage>(image)
.open_protocol_exclusive::<LoadedImage>(bt.image_handle())
.expect("Failed to open LoadedImage protocol");

let device_path = bt
Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn test(image: Handle, bt: &BootServices) {
// Get the `LoadedImageDevicePath`. Verify it start with the same nodes as
// `device_path`.
let loaded_image_device_path = bt
.open_protocol_exclusive::<LoadedImageDevicePath>(image)
.open_protocol_exclusive::<LoadedImageDevicePath>(bt.image_handle())
.expect("Failed to open LoadedImageDevicePath protocol");

for (n1, n2) in device_path
Expand All @@ -69,7 +69,7 @@ pub fn test(image: Handle, bt: &BootServices) {
// test 2/2: test high-level to-string api
{
let loaded_image_device_path = bt
.open_protocol_exclusive::<LoadedImageDevicePath>(image)
.open_protocol_exclusive::<LoadedImageDevicePath>(bt.image_handle())
.expect("Failed to open LoadedImageDevicePath protocol");
let device_path: &DevicePath = &loaded_image_device_path;

Expand Down
4 changes: 2 additions & 2 deletions uefi-test-runner/src/proto/loaded_image.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use uefi::prelude::*;
use uefi::proto::loaded_image::LoadedImage;

pub fn test(image: Handle, bt: &BootServices) {
pub fn test(bt: &BootServices) {
info!("Running loaded image protocol test");

let loaded_image = bt
.open_protocol_exclusive::<LoadedImage>(image)
.open_protocol_exclusive::<LoadedImage>(bt.image_handle())
.expect("Failed to open LoadedImage protocol");

let load_options = loaded_image.load_options_as_bytes();
Expand Down
14 changes: 7 additions & 7 deletions uefi-test-runner/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ use uefi::prelude::*;
use uefi::proto::loaded_image::LoadedImage;
use uefi::{proto, Identify};

pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
pub fn test(st: &mut SystemTable<Boot>) {
info!("Testing various protocols");

console::test(image, st);
console::test(st);

let bt = st.boot_services();
find_protocol(bt);
test_protocols_per_handle(image, bt);
test_protocols_per_handle(bt);

debug::test(bt);
device_path::test(image, bt);
device_path::test(bt);
driver::test(bt);
loaded_image::test(image, bt);
loaded_image::test(bt);
media::test(bt);
network::test(bt);
pi::test(bt);
Expand Down Expand Up @@ -44,9 +44,9 @@ fn find_protocol(bt: &BootServices) {
);
}

fn test_protocols_per_handle(image: Handle, bt: &BootServices) {
fn test_protocols_per_handle(bt: &BootServices) {
let pph = bt
.protocols_per_handle(image)
.protocols_per_handle(bt.image_handle())
.expect("Failed to get protocols for image handle");

info!("Image handle has {} protocols", pph.len());
Expand Down