Skip to content

Commit cdbc0ef

Browse files
committed
uefi-test-runner: Add test for ShellParams protocol
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent ab93da8 commit cdbc0ef

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

uefi-test-runner/src/bin/shell_launcher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
6969
let mut shell_loaded_image = boot_services
7070
.open_protocol_exclusive::<LoadedImage>(shell_image_handle)
7171
.expect("failed to open LoadedImage protocol");
72-
let load_options = cstr16!(r"shell.efi test_runner.efi");
72+
let load_options = cstr16!(r"shell.efi test_runner.efi arg1 arg2");
7373
unsafe {
7474
shell_loaded_image.set_load_options(
7575
load_options.as_ptr().cast(),

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
2020
network::test(bt);
2121
pi::test(bt);
2222
rng::test(bt);
23+
shell_params::test(bt);
2324
string::test(bt);
2425

2526
#[cfg(any(
@@ -63,6 +64,7 @@ mod media;
6364
mod network;
6465
mod pi;
6566
mod rng;
67+
mod shell_params;
6668
#[cfg(any(
6769
target_arch = "x86",
6870
target_arch = "x86_64",
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use uefi::proto::shell_params::ShellParameters;
2+
use uefi::table::boot::BootServices;
3+
use uefi::CStr16;
4+
5+
use alloc::vec::Vec;
6+
7+
pub fn test(bt: &BootServices) {
8+
info!("Running loaded image protocol test");
9+
10+
let image = bt
11+
.get_handle_for_protocol::<ShellParameters>()
12+
.expect("No ShellParameters handles");
13+
let shell_params = bt
14+
.open_protocol_exclusive::<ShellParameters>(image)
15+
.expect("Failed to open ShellParameters protocol");
16+
17+
info!("Args:");
18+
for arg in shell_params.get_args_slice() {
19+
let arg_str = unsafe { CStr16::from_ptr(*arg) };
20+
info!(" '{}'", arg_str);
21+
}
22+
23+
assert_eq!(shell_params.get_args_slice().len(), 4);
24+
assert_eq!(
25+
shell_params.get_args().collect::<Vec<_>>(),
26+
&["shell.efi", "test_runner.efi", "arg1", "arg2"]
27+
);
28+
}

0 commit comments

Comments
 (0)