Skip to content

Commit 924d1da

Browse files
nicholasbishopphip1611
authored andcommitted
test-runner: Consistently use global image handle
Rather than passing the image handle around in function args, just use the global image handle.
1 parent a55ef5d commit 924d1da

File tree

6 files changed

+18
-18
lines changed

6 files changed

+18
-18
lines changed

uefi-test-runner/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
5555
boot::test(&st);
5656

5757
// Test all the supported protocols.
58-
proto::test(image, &mut st);
58+
proto::test(&mut st);
5959

6060
// TODO: runtime services work before boot services are exited, but we'd
6161
// probably want to test them after exit_boot_services. However,

uefi-test-runner/src/proto/console/gop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use uefi::prelude::*;
33
use uefi::proto::console::gop::{BltOp, BltPixel, FrameBuffer, GraphicsOutput, PixelFormat};
44
use uefi::table::boot::{OpenProtocolAttributes, OpenProtocolParams};
55

6-
pub unsafe fn test(image: Handle, bt: &BootServices) {
6+
pub unsafe fn test(bt: &BootServices) {
77
info!("Running graphics output protocol test");
88
let handle = bt
99
.get_handle_for_protocol::<GraphicsOutput>()
@@ -12,7 +12,7 @@ pub unsafe fn test(image: Handle, bt: &BootServices) {
1212
.open_protocol::<GraphicsOutput>(
1313
OpenProtocolParams {
1414
handle,
15-
agent: image,
15+
agent: bt.image_handle(),
1616
controller: None,
1717
},
1818
// For this test, don't open in exclusive mode. That

uefi-test-runner/src/proto/console/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use uefi::prelude::*;
22

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

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

88
let bt = st.boot_services();
99
unsafe {
1010
serial::test(bt);
11-
gop::test(image, bt);
11+
gop::test(bt);
1212
}
1313
pointer::test(bt);
1414
}

uefi-test-runner/src/proto/device_path.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ use uefi::proto::device_path::text::*;
55
use uefi::proto::device_path::{DevicePath, LoadedImageDevicePath};
66
use uefi::proto::loaded_image::LoadedImage;
77

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

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

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

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

uefi-test-runner/src/proto/loaded_image.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
use uefi::prelude::*;
22
use uefi::proto::loaded_image::LoadedImage;
33

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

77
let loaded_image = bt
8-
.open_protocol_exclusive::<LoadedImage>(image)
8+
.open_protocol_exclusive::<LoadedImage>(bt.image_handle())
99
.expect("Failed to open LoadedImage protocol");
1010

1111
let load_options = loaded_image.load_options_as_bytes();

uefi-test-runner/src/proto/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@ use uefi::prelude::*;
22
use uefi::proto::loaded_image::LoadedImage;
33
use uefi::{proto, Identify};
44

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

8-
console::test(image, st);
8+
console::test(st);
99

1010
let bt = st.boot_services();
1111
find_protocol(bt);
12-
test_protocols_per_handle(image, bt);
12+
test_protocols_per_handle(bt);
1313

1414
debug::test(bt);
15-
device_path::test(image, bt);
15+
device_path::test(bt);
1616
driver::test(bt);
17-
loaded_image::test(image, bt);
17+
loaded_image::test(bt);
1818
media::test(bt);
1919
network::test(bt);
2020
pi::test(bt);
@@ -44,9 +44,9 @@ fn find_protocol(bt: &BootServices) {
4444
);
4545
}
4646

47-
fn test_protocols_per_handle(image: Handle, bt: &BootServices) {
47+
fn test_protocols_per_handle(bt: &BootServices) {
4848
let pph = bt
49-
.protocols_per_handle(image)
49+
.protocols_per_handle(bt.image_handle())
5050
.expect("Failed to get protocols for image handle");
5151

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

0 commit comments

Comments
 (0)