use std::str::FromStr;
use uuid::Uuid;
use crate::boot::{BootEntry, BootEntryAttributes, EFIHardDrive, FilePath, FilePathList};
#[test]
fn parse() {
let data: [u8; 0x6E] = [
0x01, 0x00, 0x00, 0x00, 0x5E, 0x00, 0x47, 0x00, 0x52, 0x00, 0x55, 0x00, 0x42, 0x00, 0x00,
0x00, 0x04, 0x01, 0x2A, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE3, 0xDC, 0x7C, 0x83, 0xF0,
0x3E, 0x43, 0x49, 0xA8, 0xF2, 0x35, 0xA3, 0xF5, 0x86, 0xC9, 0x0A, 0x02, 0x02, 0x04, 0x04,
0x30, 0x00, 0x5C, 0x00, 0x45, 0x00, 0x46, 0x00, 0x49, 0x00, 0x5C, 0x00, 0x61, 0x00, 0x72,
0x00, 0x63, 0x00, 0x68, 0x00, 0x5C, 0x00, 0x67, 0x00, 0x72, 0x00, 0x75, 0x00, 0x62, 0x00,
0x78, 0x00, 0x36, 0x00, 0x34, 0x00, 0x2E, 0x00, 0x65, 0x00, 0x66, 0x00, 0x69, 0x00, 0x00,
0x00, 0x7F, 0xFF, 0x04, 0x00,
];
let entry = BootEntry::parse(data.to_vec()).unwrap();
assert_eq!(
entry,
BootEntry {
attributes: BootEntryAttributes::LOAD_OPTION_ACTIVE,
description: "GRUB".to_owned(),
file_path_list: Some(FilePathList {
file_path: FilePath {
path: "\\EFI\\arch\\grubx64.efi".into()
},
hard_drive: EFIHardDrive {
partition_number: 1,
partition_start: 10240,
partition_size: 991232,
partition_sig: Uuid::from_str("837cdce3-3ef0-4943-a8f2-35a3f586c90a").unwrap(),
format: 2,
sig_type: crate::boot::EFIHardDriveType::Gpt,
}
}),
optional_data: vec![]
}
);
}