tests: Add a test to check that the boot vs max cpus work

The easiest way to detect if the kernel is willing to accept hotplug
vCPUs is to check the dmesg output.

Switch the test to bionic as the Clear Cloud image lacks "dmesg."

Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
Rob Bradford 2019-11-25 15:49:41 +00:00
parent 1bbe48b24c
commit ea19bb026f

View File

@ -1119,10 +1119,10 @@ mod tests {
#[cfg_attr(not(feature = "mmio"), test)]
fn test_multi_cpu() {
test_block!(tb, "", {
let mut clear = ClearDiskConfig::new();
let guest = Guest::new(&mut clear);
let mut bionic = UbuntuDiskConfig::new(BIONIC_IMAGE_NAME.to_string());
let guest = Guest::new(&mut bionic);
let mut child = Command::new("target/release/cloud-hypervisor")
.args(&["--cpus", "boot=2"])
.args(&["--cpus", "boot=2,max=4"])
.args(&["--memory", "size=512M"])
.args(&["--kernel", guest.fw_path.as_str()])
.args(&[
@ -1146,6 +1146,14 @@ mod tests {
aver_eq!(tb, guest.get_cpu_count().unwrap_or_default(), 2);
aver_eq!(
tb,
guest
.ssh_command(r#"dmesg | grep "smpboot: Allowing" | sed "s/\[\ *[0-9.]*\] //""#)
.unwrap_or_default()
.trim(),
"smpboot: Allowing 4 CPUs, 2 hotplug CPUs"
);
guest.ssh_command("sudo shutdown -h now")?;
thread::sleep(std::time::Duration::new(10, 0));
let _ = child.kill();