Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions uefi-test-runner/src/runtime/vars.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ fn test_variables(rt: &RuntimeServices) {
info!("First variable: {}", key);
}

// Test that the `runtime::variable_keys` iterator gives exactly the same
// list as the `RuntimeServices::variable_keys` function.
assert_eq!(
runtime::variable_keys()
.map(|k| k.unwrap())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could also be filter_map(core::ops::identity) I think

.collect::<alloc::vec::Vec<_>>(),
variable_keys
);

info!("Testing delete_variable()");
rt.delete_variable(NAME, VENDOR)
.expect("failed to delete variable");
Expand Down Expand Up @@ -86,6 +95,15 @@ fn test_variables_freestanding() {
assert_eq!(&*data, VALUE);
assert_eq!(attrs, ATTRS);

// Test that the variable is present in the `variable_keys` iterator.
let find_by_key = || {
runtime::variable_keys().any(|k| {
let k = k.as_ref().unwrap();
k.name().unwrap() == NAME && &k.vendor == VENDOR
})
};
assert!(find_by_key());

// Delete the variable and verify it can no longer be read.
runtime::delete_variable(NAME, VENDOR).expect("failed to delete variable");
assert_eq!(
Expand All @@ -94,6 +112,8 @@ fn test_variables_freestanding() {
.status(),
Status::NOT_FOUND
);
// Variable is no longer present in the `variable_keys` iterator.
assert!(!find_by_key());
}

fn test_variable_info(rt: &RuntimeServices) {
Expand Down