Skip to content

Commit

Permalink
efiboot(test): add more tests for efiboot boot next subcommands
Browse files Browse the repository at this point in the history
  • Loading branch information
iTrooz committed Oct 19, 2023
1 parent 2a3fe44 commit 107da8d
Showing 1 changed file with 77 additions and 1 deletion.
78 changes: 77 additions & 1 deletion efiboot/src/cli/boot/tests/next.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use clap::Parser;
use efivar::{efi::Variable, store::MemoryStore, utils, VarReader};
use efivar::{
efi::{Variable, VariableFlags},
store::MemoryStore,
utils, VarReader, VarWriter,
};

use crate::{
cli::{boot::tests::add_entry, Command},
Expand Down Expand Up @@ -38,3 +42,75 @@ fn set_inexistent_next() {

assert!(!manager.exists(&Variable::new("BootNext")).unwrap());
}

#[test]
fn unset_next() {
let manager = &mut MemoryStore::new();

manager
.write(
&Variable::new("BootNext"),
VariableFlags::default(),
&utils::u16_to_u8(&[0x0001]),
)
.unwrap();

assert_eq!(
ExitCode::SUCCESS,
crate::run(
Command::parse_from(["efiboot", "boot", "next", "unset"]),
manager,
)
);

assert!(!manager.exists(&Variable::new("BootNext")).unwrap());
}

#[test]
fn unset_inexistent_next() {
let manager = &mut MemoryStore::new();

assert_eq!(
ExitCode::FAILURE,
crate::run(
Command::parse_from(["efiboot", "boot", "next", "unset"]),
manager,
)
);

assert!(!manager.exists(&Variable::new("BootNext")).unwrap());
}

#[test]
fn get_next() {
let manager = &mut MemoryStore::new();

manager
.write(
&Variable::new("BootNext"),
VariableFlags::default(),
&utils::u16_to_u8(&[0x0001]),
)
.unwrap();

assert_eq!(
ExitCode::SUCCESS,
crate::run(
Command::parse_from(["efiboot", "boot", "next", "get"]),
manager,
)
);
}

#[test]
fn get_inexistent_next() {
let manager = &mut MemoryStore::new();

assert_eq!(
ExitCode::FAILURE,
crate::run(
Command::parse_from(["efiboot", "boot", "next", "get"]),
manager,
)
);
}

0 comments on commit 107da8d

Please sign in to comment.