Skip to content

Commit fa9f26c

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

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
use uefi::proto::shell_params::ShellParameters;
2+
use uefi::table::boot::BootServices;
3+
use uefi::CStr16;
4+
5+
pub fn test(bt: &BootServices) {
6+
info!("Running loaded image protocol test");
7+
8+
let image = bt
9+
.get_handle_for_protocol::<ShellParameters>()
10+
.expect("No ShellParameters handles");
11+
let shell_params = bt
12+
.open_protocol_exclusive::<ShellParameters>(image)
13+
.expect("Failed to open ShellParameters protocol");
14+
15+
info!("Argc: {}", shell_params.argc);
16+
info!("Args:");
17+
for arg in shell_params.get_args_slice() {
18+
let arg_str = unsafe { CStr16::from_ptr(*arg) };
19+
info!(" '{}'", arg_str);
20+
}
21+
22+
assert_eq!(shell_params.argc, shell_params.get_args_slice().len());
23+
24+
// Was run as: shell.efi test_runner.efi
25+
assert_eq!(shell_params.argc, 2);
26+
}

0 commit comments

Comments
 (0)