Skip to content

Commit

Permalink
test: add test for invalid boot_counter
Browse files Browse the repository at this point in the history
Signed-off-by: Sayan Paul <[email protected]>
  • Loading branch information
say-paul committed Nov 2, 2023
1 parent 6924a0f commit 489ada8
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ enum Commands {
Rollback,
}

/// this runs the scripts in required.d and wanted.d
/// this runs all the scripts in required.d and wanted.d
fn run_diagnostics() -> Result<(), Error> {
let mut script_failure: bool = false;
let mut path_exists: bool = false;
Expand Down Expand Up @@ -302,6 +302,20 @@ mod tests {
unset_boot_counter().ok();
}

#[test]
fn test_boot_counter_having_invalid_value() {
unset_boot_counter().ok();
let _ = Command::new("grub2-editenv")
.arg("-")
.arg("set")
.arg("boot_counter=foo")
.spawn()
.context("Cannot create grub variable boot_counter");
set_boot_counter(13).ok();
assert_eq!(get_boot_counter(), Some(13));
unset_boot_counter().ok();
}

fn setup_folder_structure(passing: bool) -> Result<()> {
let required_path = format!("{}/check/required.d", GREENBOOT_INSTALL_PATHS[1]);
let wanted_path = format!("{}/check/wanted.d", GREENBOOT_INSTALL_PATHS[1]);
Expand Down

0 comments on commit 489ada8

Please sign in to comment.