Skip to content

Commit c6f1a18

Browse files
committed
integration-test: SNP: print device path
1 parent 1b41dfe commit c6f1a18

File tree

1 file changed

+32
-20
lines changed
  • uefi-test-runner/src/proto/network

1 file changed

+32
-20
lines changed

uefi-test-runner/src/proto/network/snp.rs

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
use core::ops::DerefMut;
44
use core::time::Duration;
5+
use uefi::proto::device_path::text::{AllowShortcuts, DisplayOnly};
6+
use uefi::proto::device_path::DevicePath;
57

68
use uefi::proto::network::snp::{InterruptStatus, NetworkState, ReceiveFlags, SimpleNetwork};
79
use uefi::proto::network::MacAddress;
@@ -41,11 +43,21 @@ pub fn test() {
4143
info!("Testing the simple network protocol");
4244

4345
let handles = boot::find_handles::<SimpleNetwork>().unwrap_or_default();
44-
4546
for handle in handles {
4647
let Ok(mut simple_network) = boot::open_protocol_exclusive::<SimpleNetwork>(handle) else {
4748
continue;
4849
};
50+
// Print device path
51+
{
52+
let simple_network_dvp = boot::open_protocol_exclusive::<DevicePath>(handle)
53+
.expect("Should have device path");
54+
log::info!(
55+
"Network interface: {}",
56+
simple_network_dvp
57+
.to_string(DisplayOnly(true), AllowShortcuts(true))
58+
.unwrap()
59+
);
60+
}
4961

5062
assert_eq!(
5163
simple_network.mode().state,
@@ -138,28 +150,28 @@ pub fn test() {
138150
let n = receive(simple_network.deref_mut(), &mut buffer).unwrap();
139151
debug!("Reply has {n} bytes");
140152

141-
// Check payload in UDP packet that was reversed by our EchoService.
142-
assert_eq!(buffer[42..47], [4, 4, 3, 2, 1]);
153+
// Check payload in UDP packet that was reversed by our EchoService.
154+
assert_eq!(buffer[42..47], [4, 4, 3, 2, 1]);
143155

144-
// Get stats
145-
let res = simple_network.collect_statistics();
146-
match res {
147-
Ok(stats) => {
148-
info!("Stats: {:?}", stats);
156+
// Get stats
157+
let res = simple_network.collect_statistics();
158+
match res {
159+
Ok(stats) => {
160+
info!("Stats: {:?}", stats);
149161

150-
// One frame should have been transmitted and one received
151-
assert_eq!(stats.tx_total_frames().unwrap(), 1);
152-
assert_eq!(stats.rx_total_frames().unwrap(), 1);
153-
}
154-
Err(e) => {
155-
if e == Status::UNSUPPORTED.into() {
156-
info!("Stats: unsupported.");
157-
} else {
158-
panic!("{e}");
159-
}
162+
// One frame should have been transmitted and one received
163+
assert_eq!(stats.tx_total_frames().unwrap(), 1);
164+
assert_eq!(stats.rx_total_frames().unwrap(), 1);
165+
}
166+
Err(e) => {
167+
if e == Status::UNSUPPORTED.into() {
168+
info!("Stats: unsupported.");
169+
} else {
170+
panic!("{e}");
160171
}
161172
}
162-
163-
simple_network.shutdown().unwrap();
164173
}
174+
175+
simple_network.shutdown().unwrap();
165176
}
177+
}

0 commit comments

Comments
 (0)