mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
tests: extract _test_memory_overhead to tests_wrappers
Extract test logic from test_memory_overhead into a shared _test_memory_overhead wrapper function in tests_wrappers.rs. The custom memory size is set in the parent test case via with_memory(). The wrapper uses default_kernel_cmdline() and default_memory() for setup. Signed-off-by: Muminul Islam <muislam@microsoft.com>
This commit is contained in:
committed by
Rob Bradford
parent
b478fa0ffd
commit
af7fabd2c6
@@ -2552,3 +2552,28 @@ pub(crate) fn _test_pci_bar_reprogramming(guest: &Guest) {
|
|||||||
|
|
||||||
handle_child_output(r, &output);
|
handle_child_output(r, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(crate) fn _test_memory_overhead(guest: &Guest, guest_memory_size_kb: u32) {
|
||||||
|
let mut child = GuestCommand::new(guest)
|
||||||
|
.default_cpus()
|
||||||
|
.default_memory()
|
||||||
|
.default_kernel_cmdline()
|
||||||
|
.default_net()
|
||||||
|
.default_disks()
|
||||||
|
.capture_output()
|
||||||
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
guest.wait_vm_boot().unwrap();
|
||||||
|
|
||||||
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
let overhead = get_vmm_overhead(child.id(), guest_memory_size_kb);
|
||||||
|
eprintln!("Guest memory overhead: {overhead} vs {MAXIMUM_VMM_OVERHEAD_KB}");
|
||||||
|
assert!(overhead <= MAXIMUM_VMM_OVERHEAD_KB);
|
||||||
|
});
|
||||||
|
|
||||||
|
kill_child(&mut child);
|
||||||
|
let output = child.wait_with_output().unwrap();
|
||||||
|
|
||||||
|
handle_child_output(r, &output);
|
||||||
|
}
|
||||||
|
|||||||
@@ -2852,36 +2852,10 @@ mod common_parallel {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_memory_overhead() {
|
fn test_memory_overhead() {
|
||||||
let disk_config = UbuntuDiskConfig::new(JAMMY_IMAGE_NAME.to_string());
|
let guest_memory_size_kb: u32 = 512 * 1024;
|
||||||
let guest = Guest::new(Box::new(disk_config));
|
let guest =
|
||||||
|
basic_regular_guest!(JAMMY_IMAGE_NAME).with_memory(&format!("{guest_memory_size_kb}K"));
|
||||||
let kernel_path = direct_kernel_boot_path();
|
_test_memory_overhead(&guest, guest_memory_size_kb);
|
||||||
|
|
||||||
let guest_memory_size_kb = 512 * 1024;
|
|
||||||
|
|
||||||
let mut child = GuestCommand::new(&guest)
|
|
||||||
.default_cpus()
|
|
||||||
.args(["--memory", format!("size={guest_memory_size_kb}K").as_str()])
|
|
||||||
.args(["--kernel", kernel_path.to_str().unwrap()])
|
|
||||||
.args(["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
|
||||||
.default_net()
|
|
||||||
.default_disks()
|
|
||||||
.capture_output()
|
|
||||||
.spawn()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
guest.wait_vm_boot().unwrap();
|
|
||||||
|
|
||||||
let r = std::panic::catch_unwind(|| {
|
|
||||||
let overhead = get_vmm_overhead(child.id(), guest_memory_size_kb);
|
|
||||||
eprintln!("Guest memory overhead: {overhead} vs {MAXIMUM_VMM_OVERHEAD_KB}");
|
|
||||||
assert!(overhead <= MAXIMUM_VMM_OVERHEAD_KB);
|
|
||||||
});
|
|
||||||
|
|
||||||
kill_child(&mut child);
|
|
||||||
let output = child.wait_with_output().unwrap();
|
|
||||||
|
|
||||||
handle_child_output(r, &output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user