Skip to content

Commit 7b7a7da

Browse files
e820nicholasbishop
authored andcommitted
Format and make DiskIo2 test optional
1 parent 7151e7f commit 7b7a7da

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

uefi-test-runner/src/proto/media/known_disk.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,24 +189,31 @@ unsafe extern "efiapi" fn disk_io2_callback(event: Event, ctx: Option<NonNull<c_
189189
assert_eq!(*ptr.offset(510), 0x55);
190190
assert_eq!(*ptr.offset(511), 0xaa);
191191

192-
system_table().as_ref().boot_services().close_event(event).unwrap();
192+
system_table()
193+
.as_ref()
194+
.boot_services()
195+
.close_event(event)
196+
.unwrap();
193197
}
194198

195199
/// Tests raw disk I/O through the DiskIo2 protocol.
196200
fn test_raw_disk_io2(handle: Handle, image: Handle, bt: &BootServices) {
197201
info!("Testing raw disk I/O 2");
198202

199203
// Open the disk I/O protocol on the input handle
200-
let disk_io2 = bt
201-
.open_protocol::<DiskIo2>(
202-
OpenProtocolParams {
203-
handle,
204-
agent: image,
205-
controller: None,
206-
},
207-
OpenProtocolAttributes::GetProtocol,
208-
)
209-
.expect("Failed to get disk I/O 2 protocol");
204+
let disk_io2 = bt.open_protocol::<DiskIo2>(
205+
OpenProtocolParams {
206+
handle,
207+
agent: image,
208+
controller: None,
209+
},
210+
OpenProtocolAttributes::GetProtocol,
211+
);
212+
if disk_io2.is_err() {
213+
return;
214+
}
215+
216+
let disk_io2 = disk_io2.unwrap();
210217

211218
// Allocate a temporary buffer to read into
212219
const SIZE: usize = 512;
@@ -236,7 +243,7 @@ fn test_raw_disk_io2(handle: Handle, image: Handle, bt: &BootServices) {
236243
.read_disk_raw(0, 0, &mut token, SIZE, buf)
237244
.expect("Failed to read from disk");
238245
}
239-
246+
240247
info!("Raw disk I/O 2 succeeded");
241248
bt.free_pool(buf).unwrap();
242249
}

0 commit comments

Comments
 (0)