mirror of
https://github.com/aya-rs/aya.git
synced 2026-05-31 11:18:53 +02:00
integration-test: use bool for lpm_trie ran flag
Mirror the stack_trace test's `TestResult::ran: bool`; the field only distinguishes a recorded result from a zero-initialised slot.
This commit is contained in:
@@ -152,7 +152,8 @@ pub mod lpm_trie {
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct TestResult {
|
||||
pub value: u32,
|
||||
pub ran: u32,
|
||||
/// Distinguishes a recorded result from a zero-initialised slot.
|
||||
pub ran: bool,
|
||||
}
|
||||
|
||||
#[cfg(feature = "user")]
|
||||
|
||||
@@ -39,7 +39,7 @@ macro_rules! define_lpm_trie_test {
|
||||
if let Some(val) = $routes_map.get(key) {
|
||||
(*ptr).value = *val;
|
||||
}
|
||||
(*ptr).ran = 1;
|
||||
(*ptr).ran = true;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,21 +44,21 @@ fn lpm_trie_basic(prog_name: &str, routes_map: &str, results_map: &str) {
|
||||
let results = Array::<_, TestResult>::try_from(bpf.map(results_map).unwrap()).unwrap();
|
||||
|
||||
let TestResult { ran, value } = results.get(&LPM_MATCH_SLOT, 0).unwrap();
|
||||
assert_eq!(ran, 1, "LPM-match probe did not run");
|
||||
assert!(ran, "LPM-match probe did not run");
|
||||
assert_eq!(
|
||||
value, 7,
|
||||
"longest-prefix-match should return the /24 value, not the /16"
|
||||
);
|
||||
|
||||
let TestResult { ran, value } = results.get(&NO_MATCH_SLOT, 0).unwrap();
|
||||
assert_eq!(ran, 1, "no-match probe did not run");
|
||||
assert!(ran, "no-match probe did not run");
|
||||
assert_eq!(
|
||||
value, 0,
|
||||
"get() should return None for a key outside the trie"
|
||||
);
|
||||
|
||||
let TestResult { ran, value } = results.get(&REMOVE_SLOT, 0).unwrap();
|
||||
assert_eq!(ran, 1, "after-remove probe did not run");
|
||||
assert!(ran, "after-remove probe did not run");
|
||||
assert_eq!(
|
||||
value, 42,
|
||||
"after removing the /24, longest-prefix-match should fall back to the /16"
|
||||
|
||||
Reference in New Issue
Block a user