Skip to content

Commit

Permalink
test: Test all logger level case variants
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Woollett-LIght <jcawl@amazon.co.uk>
  • Loading branch information
Jonathan Woollett-Light committed Nov 15, 2023
1 parent 3bace34 commit a208275
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/vmm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ base64 = "0.13.0"
bincode = "1.2.1"
micro_http = { git = "https://github.com/firecracker-microvm/micro-http" }
log-instrument = { path = "../log-instrument", optional = true }
itertools = "0.12.0"

seccompiler = { path = "../seccompiler" }
snapshot = { path = "../snapshot"}
Expand Down
17 changes: 17 additions & 0 deletions src/vmm/src/logger/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,23 @@ mod tests {
);
}
#[test]
fn levelfilter_from_str_all_variants() {
use itertools::Itertools;

for level in ["off","trace","debug","info","warn", "warning", "error"] {
let mut multi = level.chars().map(|_|0..=1).multi_cartesian_product()();
for combination in multi {
let variant = level.chars().zip_eq(combination).map(|(c,v)| match v {
0 => c.to_lowercase(),
1 => c.to_uppercase(),
_ => unreachable!()
}).collect::<String>();
assert!(LevelFilter::from_str(&variant).is_ok());
assert!(serde_json::from_str::<_, LevelFilter>(&variant).is_ok());
}
}
}
#[test]
fn levelfilter_from_str() {
assert_eq!(
LevelFilter::from_str("bad"),
Expand Down

0 comments on commit a208275

Please sign in to comment.