Skip to content

Commit

Permalink
uefi-test-runner: Add test for ShellParams protocol
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Schaefer <[email protected]>
  • Loading branch information
JohnAZoidberg committed Sep 5, 2023
1 parent 5a443ee commit 2c9185b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion uefi-test-runner/src/bin/shell_launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ fn efi_main(image: Handle, mut st: SystemTable<Boot>) -> Status {
let mut shell_loaded_image = boot_services
.open_protocol_exclusive::<LoadedImage>(shell_image_handle)
.expect("failed to open LoadedImage protocol");
let load_options = cstr16!(r"shell.efi test_runner.efi");
let load_options = cstr16!(r"shell.efi test_runner.efi arg1 arg2");
unsafe {
shell_loaded_image.set_load_options(
load_options.as_ptr().cast(),
Expand Down
2 changes: 2 additions & 0 deletions uefi-test-runner/src/proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub fn test(image: Handle, st: &mut SystemTable<Boot>) {
network::test(bt);
pi::test(bt);
rng::test(bt);
shell_params::test(bt);
string::test(bt);

#[cfg(any(
Expand Down Expand Up @@ -63,6 +64,7 @@ mod media;
mod network;
mod pi;
mod rng;
mod shell_params;
#[cfg(any(
target_arch = "x86",
target_arch = "x86_64",
Expand Down
25 changes: 25 additions & 0 deletions uefi-test-runner/src/proto/shell_params.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use uefi::proto::shell_params::ShellParameters;
use uefi::table::boot::BootServices;

use alloc::string::ToString;
use alloc::vec::Vec;

pub fn test(bt: &BootServices) {
info!("Running loaded image protocol test");

let image = bt
.get_handle_for_protocol::<ShellParameters>()
.expect("No ShellParameters handles");
let shell_params = bt
.open_protocol_exclusive::<ShellParameters>(image)
.expect("Failed to open ShellParameters protocol");

assert_eq!(shell_params.args_len(), 4);
assert_eq!(
shell_params
.args()
.map(|x| x.to_string())
.collect::<Vec<_>>(),
&["shell.efi", "test_runner.efi", "arg1", "arg2"]
);
}

0 comments on commit 2c9185b

Please sign in to comment.