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:
Rob Bradford 2020-08-12 12:20:14 +01:00 committed by Sebastien Boeuf
parent 9dd4625fb4
commit dd39aedde1

View File

@ -1881,7 +1881,6 @@ mod tests {
}
fn test_memory_mergeable(mergeable: bool) {
test_block!(tb, "", {
let memory_param = if mergeable {
"mergeable=on"
} else {
@ -1919,6 +1918,7 @@ mod tests {
.default_disks()
.args(&["--net", guest2.default_net_string().as_str()])
.args(&["--serial", "tty", "--console", "off"])
.capture_output()
.spawn()
.unwrap();
@ -1926,7 +1926,7 @@ mod tests {
// 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
let new_pss = get_pss(child1.id());
@ -1937,17 +1937,19 @@ mod tests {
println!("old PSS {}, new PSS {}", old_pss, new_pss);
if mergeable {
aver!(tb, new_pss < (old_pss * 0.95));
assert!(new_pss < (old_pss * 0.95));
} 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 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> {