Skip to content

Commit

Permalink
test(efiboot): add test for fix_file_path()
Browse files Browse the repository at this point in the history
  • Loading branch information
iTrooz committed Dec 23, 2023
1 parent d32a700 commit 83b7c31
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions efiboot/src/cli/boot/tests/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,59 @@ fn add_set_id() {
assert_eq!(data, utils::u16_to_u8(&[0x1000, 0x0001]));
}

#[test]
fn add_verify_file_path_fix() {
//! Use `efiboot boot add` with a given entry ID.

let manager = &mut MemoryStore::new();

let setup_entry = standard_setup(manager, 0x0001);

// execute `efiboot boot add`
assert_eq!(
ExitCode::SUCCESS,
crate::run(
Command::parse_from([
"efiboot",
"boot",
"add",
"--file",
"a/b/c",
"--description",
"Some entry",
"--id",
"1000"
]),
manager,
)
);

// verify Boot0000 did not get inserted
assert_var_not_found(manager, &Variable::new("Boot0000"));

// verify inserted entry is right
let (data, _) = manager.read(&Variable::new("Boot1000")).unwrap();
let entry = BootEntry::parse(data).unwrap();
assert_eq!(
entry,
BootEntry {
attributes: BootEntryAttributes::LOAD_OPTION_ACTIVE,
description: "Some entry".to_owned(),
file_path_list: Some(FilePathList {
file_path: FilePath {
path: "\\a\\b\\c".into()
},
hard_drive: setup_entry.file_path_list.unwrap().hard_drive // use partition defined earlier
}),
optional_data: vec![]
}
);

// verify new boot order is right
let (data, _) = manager.read(&Variable::new("BootOrder")).unwrap();
assert_eq!(data, utils::u16_to_u8(&[0x1000, 0x0001]));
}

#[test]
fn add_on_existing() {
//! Try to add a boot entry with an already-existing id
Expand Down

0 comments on commit 83b7c31

Please sign in to comment.