Skip to content

Commit 149396e

Browse files
committed
Add tests for convert text
1 parent 1c95dd5 commit 149396e

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/proto/device_path/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub struct DevicePathHeader {
3838
/// This can be opened on a `LoadedImage.device()` handle using the `HandleProtocol` boot service.
3939
#[repr(C, packed)]
4040
#[unsafe_guid("09576e91-6d3f-11d2-8e39-00a0c969723b")]
41-
#[derive(Eq, Protocol)]
41+
#[derive(Debug, Eq, Protocol)]
4242
pub struct DevicePath {
4343
header: DevicePathHeader,
4444
}

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use uefi::prelude::*;
2-
use uefi::proto::device_path::DevicePath;
2+
use uefi::proto::device_path::{text::*, DevicePath};
33
use uefi::proto::loaded_image::LoadedImage;
44
use uefi::table::boot::{BootServices, OpenProtocolAttributes, OpenProtocolParams};
55

@@ -30,12 +30,32 @@ pub fn test(image: Handle, bt: &BootServices) {
3030
.expect("Failed to open DevicePath protocol");
3131
let device_path = unsafe { &*device_path.interface.get() };
3232

33+
let device_path_to_text = bt
34+
.locate_protocol::<DevicePathToText>()
35+
.expect("Failed to open DevicePathToText protocol");
36+
let device_path_to_text = unsafe { &*device_path_to_text.get() };
37+
38+
let device_path_from_text = bt
39+
.locate_protocol::<DevicePathFromText>()
40+
.expect("Failed to open DevicePathFromText protocol");
41+
let device_path_from_text = unsafe { &*device_path_from_text.get() };
42+
3343
for path in device_path.iter() {
3444
info!(
3545
"path: type={:?}, subtype={:?}, length={}",
3646
path.device_type(),
3747
path.sub_type(),
3848
path.length(),
3949
);
50+
51+
let text = device_path_to_text
52+
.convert_device_path_to_text(path, DisplayOnly(true), AllowShortcuts(false))
53+
.expect("Failed to convert device path to text");
54+
info!("path name: {text}");
55+
56+
let convert = device_path_from_text
57+
.convert_text_to_device_path(text)
58+
.expect("Failed to convert text to device path");
59+
assert_eq!(path, convert);
4060
}
4161
}

0 commit comments

Comments
 (0)