mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 21:15:45 +00:00
pvh: Add unit tests for start_info and memory map structures
Expand the unit tests to cover the configure_system() code when using the PVH boot protocol. Verify the method for adding memory map table entries in the format specified by PVH boot protocol. Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
This commit is contained in:
parent
9e247c4e06
commit
64941bfcad
@ -441,6 +441,17 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
configure_system(
|
||||||
|
&gm,
|
||||||
|
GuestAddress(0),
|
||||||
|
0,
|
||||||
|
no_vcpus,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
BootProtocol::PvhBoot,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// Now assigning some memory that is equal to the start of the 32bit memory hole.
|
// Now assigning some memory that is equal to the start of the 32bit memory hole.
|
||||||
let mem_size = 3328 << 20;
|
let mem_size = 3328 << 20;
|
||||||
let arch_mem_regions = arch_memory_regions(mem_size);
|
let arch_mem_regions = arch_memory_regions(mem_size);
|
||||||
@ -461,6 +472,17 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
configure_system(
|
||||||
|
&gm,
|
||||||
|
GuestAddress(0),
|
||||||
|
0,
|
||||||
|
no_vcpus,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
BootProtocol::PvhBoot,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
// Now assigning some memory that falls after the 32bit memory hole.
|
// Now assigning some memory that falls after the 32bit memory hole.
|
||||||
let mem_size = 3330 << 20;
|
let mem_size = 3330 << 20;
|
||||||
let arch_mem_regions = arch_memory_regions(mem_size);
|
let arch_mem_regions = arch_memory_regions(mem_size);
|
||||||
@ -480,6 +502,17 @@ mod tests {
|
|||||||
BootProtocol::LinuxBoot,
|
BootProtocol::LinuxBoot,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
configure_system(
|
||||||
|
&gm,
|
||||||
|
GuestAddress(0),
|
||||||
|
0,
|
||||||
|
no_vcpus,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
BootProtocol::PvhBoot,
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -521,4 +554,29 @@ mod tests {
|
|||||||
)
|
)
|
||||||
.is_err());
|
.is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_add_memmap_entry() {
|
||||||
|
let mut memmap: Vec<hvm_memmap_table_entry> = Vec::new();
|
||||||
|
|
||||||
|
let expected_memmap = vec![
|
||||||
|
hvm_memmap_table_entry {
|
||||||
|
addr: 0x0,
|
||||||
|
size: 0x1000,
|
||||||
|
type_: E820_RAM,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
hvm_memmap_table_entry {
|
||||||
|
addr: 0x10000,
|
||||||
|
size: 0xa000,
|
||||||
|
type_: E820_RESERVED,
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
add_memmap_entry(&mut memmap, 0, 0x1000, E820_RAM).unwrap();
|
||||||
|
add_memmap_entry(&mut memmap, 0x10000, 0xa000, E820_RESERVED).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(format!("{:?}", memmap), format!("{:?}", expected_memmap));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user