Skip to content

Commit 2c9185b

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

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-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: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use uefi::proto::shell_params::ShellParameters;
2+
use uefi::table::boot::BootServices;
3+
4+
use alloc::string::ToString;
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+
assert_eq!(shell_params.args_len(), 4);
18+
assert_eq!(
19+
shell_params
20+
.args()
21+
.map(|x| x.to_string())
22+
.collect::<Vec<_>>(),
23+
&["shell.efi", "test_runner.efi", "arg1", "arg2"]
24+
);
25+
}

0 commit comments

Comments
 (0)