Skip to content

Commit bea0fd9

Browse files
test-runner: Add tests for uefi::runtime::variable_keys
1 parent 9745299 commit bea0fd9

File tree

1 file changed

+20
-0
lines changed
  • uefi-test-runner/src/runtime

1 file changed

+20
-0
lines changed

uefi-test-runner/src/runtime/vars.rs

+20
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ fn test_variables(rt: &RuntimeServices) {
5151
info!("First variable: {}", key);
5252
}
5353

54+
// Test that the `runtime::variable_keys` iterator gives exactly the same
55+
// list as the `RuntimeServices::variable_keys` function.
56+
assert_eq!(
57+
runtime::variable_keys()
58+
.map(|k| k.unwrap())
59+
.collect::<alloc::vec::Vec<_>>(),
60+
variable_keys
61+
);
62+
5463
info!("Testing delete_variable()");
5564
rt.delete_variable(NAME, VENDOR)
5665
.expect("failed to delete variable");
@@ -86,6 +95,15 @@ fn test_variables_freestanding() {
8695
assert_eq!(&*data, VALUE);
8796
assert_eq!(attrs, ATTRS);
8897

98+
// Test that the variable is present in the `variable_keys` iterator.
99+
let find_by_key = || {
100+
runtime::variable_keys().any(|k| {
101+
let k = k.as_ref().unwrap();
102+
k.name().unwrap() == NAME && &k.vendor == VENDOR
103+
})
104+
};
105+
assert!(find_by_key());
106+
89107
// Delete the variable and verify it can no longer be read.
90108
runtime::delete_variable(NAME, VENDOR).expect("failed to delete variable");
91109
assert_eq!(
@@ -94,6 +112,8 @@ fn test_variables_freestanding() {
94112
.status(),
95113
Status::NOT_FOUND
96114
);
115+
// Variable is no longer present in the `variable_keys` iterator.
116+
assert!(!find_by_key());
97117
}
98118

99119
fn test_variable_info(rt: &RuntimeServices) {

0 commit comments

Comments
 (0)