Skip to content

Commit b9c1651

Browse files
committed
uefi: test new protocol helpers on Handle
1 parent b3e0059 commit b9c1651

File tree

1 file changed

+35
-0
lines changed
  • uefi-test-runner/src/proto

1 file changed

+35
-0
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// SPDX-License-Identifier: MIT OR Apache-2.0
22

33
use uefi::boot::{self, OpenProtocolParams};
4+
use uefi::proto::device_path::DevicePath;
5+
use uefi::proto::driver::ComponentName2;
46
use uefi::proto::loaded_image::LoadedImage;
57
use uefi::{Identify, proto};
68

@@ -44,6 +46,9 @@ pub fn test() {
4446
shim::test();
4547
shell::test();
4648
tcg::test();
49+
50+
// now test some convenience that combines several things
51+
test_handle_convenience();
4752
}
4853

4954
fn find_protocol() {
@@ -74,6 +79,36 @@ fn test_test_protocol() {
7479
);
7580
}
7681

82+
fn test_handle_convenience() {
83+
// Handles that implement the following protocols:
84+
// - component name 2
85+
// - device path
86+
let handles = {
87+
let mut cn2_handles = boot::find_handles::<ComponentName2>().unwrap();
88+
let dvp_handles = boot::find_handles::<DevicePath>().unwrap();
89+
90+
cn2_handles.retain(|x| dvp_handles.contains(x));
91+
cn2_handles
92+
};
93+
for handle in handles {
94+
let dvp = handle
95+
.device_path()
96+
.expect("should succeed to query protocol")
97+
.expect("should have device path");
98+
let cn2 = handle
99+
.component_name2()
100+
.expect("should succeed to query protocol")
101+
.expect("should have component name (v2)");
102+
info!("handle: {:x?}", handle);
103+
info!("|- dvp: {dvp}");
104+
info!("|- cn2 driver: {}", cn2.driver_name("en").unwrap());
105+
info!(
106+
"|- cn2 controller: {}",
107+
cn2.controller_name(handle, None, "en").unwrap()
108+
);
109+
}
110+
}
111+
77112
#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
78113
mod ata;
79114
mod console;

0 commit comments

Comments
 (0)