mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-07 10:15:45 +00:00
tests: Port test_memory_mergeable to new methodology
As a compromise we only print out the first child's output. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
9dd4625fb4
commit
dd39aedde1
@ -1881,52 +1881,52 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn test_memory_mergeable(mergeable: bool) {
|
fn test_memory_mergeable(mergeable: bool) {
|
||||||
test_block!(tb, "", {
|
let memory_param = if mergeable {
|
||||||
let memory_param = if mergeable {
|
"mergeable=on"
|
||||||
"mergeable=on"
|
} else {
|
||||||
} else {
|
"mergeable=off"
|
||||||
"mergeable=off"
|
};
|
||||||
};
|
|
||||||
|
|
||||||
let mut focal1 = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
let mut focal1 = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
||||||
let mut focal2 = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
let mut focal2 = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
||||||
|
|
||||||
let guest1 = Guest::new(&mut focal1 as &mut dyn DiskConfig);
|
let guest1 = Guest::new(&mut focal1 as &mut dyn DiskConfig);
|
||||||
|
|
||||||
let mut child1 = GuestCommand::new(&guest1)
|
let mut child1 = GuestCommand::new(&guest1)
|
||||||
.args(&["--cpus", "boot=1"])
|
.args(&["--cpus", "boot=1"])
|
||||||
.args(&["--memory", format!("size=512M,{}", memory_param).as_str()])
|
.args(&["--memory", format!("size=512M,{}", memory_param).as_str()])
|
||||||
.args(&["--kernel", guest1.fw_path.as_str()])
|
.args(&["--kernel", guest1.fw_path.as_str()])
|
||||||
.default_disks()
|
.default_disks()
|
||||||
.args(&["--net", guest1.default_net_string().as_str()])
|
.args(&["--net", guest1.default_net_string().as_str()])
|
||||||
.args(&["--serial", "tty", "--console", "off"])
|
.args(&["--serial", "tty", "--console", "off"])
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// Let enough time for the first VM to be spawned, and to make
|
// Let enough time for the first VM to be spawned, and to make
|
||||||
// sure the PSS measurement is accurate.
|
// sure the PSS measurement is accurate.
|
||||||
thread::sleep(std::time::Duration::new(120, 0));
|
thread::sleep(std::time::Duration::new(120, 0));
|
||||||
|
|
||||||
// Get initial PSS
|
// Get initial PSS
|
||||||
let old_pss = get_pss(child1.id());
|
let old_pss = get_pss(child1.id());
|
||||||
|
|
||||||
let guest2 = Guest::new(&mut focal2 as &mut dyn DiskConfig);
|
let guest2 = Guest::new(&mut focal2 as &mut dyn DiskConfig);
|
||||||
|
|
||||||
let mut child2 = GuestCommand::new(&guest2)
|
let mut child2 = GuestCommand::new(&guest2)
|
||||||
.args(&["--cpus", "boot=1"])
|
.args(&["--cpus", "boot=1"])
|
||||||
.args(&["--memory", format!("size=512M,{}", memory_param).as_str()])
|
.args(&["--memory", format!("size=512M,{}", memory_param).as_str()])
|
||||||
.args(&["--kernel", guest2.fw_path.as_str()])
|
.args(&["--kernel", guest2.fw_path.as_str()])
|
||||||
.default_disks()
|
.default_disks()
|
||||||
.args(&["--net", guest2.default_net_string().as_str()])
|
.args(&["--net", guest2.default_net_string().as_str()])
|
||||||
.args(&["--serial", "tty", "--console", "off"])
|
.args(&["--serial", "tty", "--console", "off"])
|
||||||
.spawn()
|
.capture_output()
|
||||||
.unwrap();
|
.spawn()
|
||||||
|
.unwrap();
|
||||||
// Let enough time for the second VM to be spawned, and to make
|
|
||||||
// sure KSM has enough time to merge identical pages between the
|
|
||||||
// 2 VMs.
|
|
||||||
thread::sleep(std::time::Duration::new(60, 0));
|
|
||||||
|
|
||||||
|
// Let enough time for the second VM to be spawned, and to make
|
||||||
|
// sure KSM has enough time to merge identical pages between the
|
||||||
|
// 2 VMs.
|
||||||
|
thread::sleep(std::time::Duration::new(60, 0));
|
||||||
|
let r = std::panic::catch_unwind(|| {
|
||||||
// Get new PSS
|
// Get new PSS
|
||||||
let new_pss = get_pss(child1.id());
|
let new_pss = get_pss(child1.id());
|
||||||
|
|
||||||
@ -1937,17 +1937,19 @@ mod tests {
|
|||||||
println!("old PSS {}, new PSS {}", old_pss, new_pss);
|
println!("old PSS {}, new PSS {}", old_pss, new_pss);
|
||||||
|
|
||||||
if mergeable {
|
if mergeable {
|
||||||
aver!(tb, new_pss < (old_pss * 0.95));
|
assert!(new_pss < (old_pss * 0.95));
|
||||||
} else {
|
} else {
|
||||||
aver!(tb, (old_pss * 0.95) < new_pss && new_pss < (old_pss * 1.05));
|
assert!((old_pss * 0.95) < new_pss && new_pss < (old_pss * 1.05));
|
||||||
}
|
}
|
||||||
|
|
||||||
let _ = child1.kill();
|
|
||||||
let _ = child2.kill();
|
|
||||||
let _ = child1.wait();
|
|
||||||
let _ = child2.wait();
|
|
||||||
Ok(())
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let _ = child1.kill();
|
||||||
|
let _ = child2.kill();
|
||||||
|
|
||||||
|
let output = child1.wait_with_output().unwrap();
|
||||||
|
child2.wait().unwrap();
|
||||||
|
|
||||||
|
handle_child_output(r, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn _get_vmm_overhead(pid: u32, guest_memory_size: u32) -> HashMap<String, u32> {
|
fn _get_vmm_overhead(pid: u32, guest_memory_size: u32) -> HashMap<String, u32> {
|
||||||
|
Loading…
Reference in New Issue
Block a user