From 5f0337c21d1beb64f6163c66ee941f4c3c2f9f70 Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 19 Sep 2019 10:46:53 +0100 Subject: [PATCH] tests: Add a "huge" memory test Now that we have expanded our address space we should add automated testing to try VMs that use a large amount of RAM. As the hypervisor does an anonymous mmap() for the backing of memory and during a typical test boot the guest will not touch it all it should be possible to test large RAM VMs even if that exceeds the RAM of the host machine. Signed-off-by: Rob Bradford --- src/main.rs | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/main.rs b/src/main.rs index 298c49f9b..4480f8155 100755 --- a/src/main.rs +++ b/src/main.rs @@ -948,6 +948,47 @@ mod tests { }); } + #[cfg_attr(not(feature = "mmio"), test)] + fn test_huge_memory() { + test_block!(tb, "", { + let mut clear = ClearDiskConfig::new(); + let guest = Guest::new(&mut clear); + let mut child = Command::new("target/debug/cloud-hypervisor") + .args(&["--cpus", "1"]) + .args(&["--memory", "size=128G"]) + .args(&["--kernel", guest.fw_path.as_str()]) + .args(&[ + "--disk", + guest + .disk_config + .disk(DiskType::OperatingSystem) + .unwrap() + .as_str(), + guest + .disk_config + .disk(DiskType::CloudInit) + .unwrap() + .as_str(), + ]) + .args(&["--net", guest.default_net_string().as_str()]) + .spawn() + .unwrap(); + + thread::sleep(std::time::Duration::new(20, 0)); + + aver!( + tb, + guest.get_total_memory().unwrap_or_default() > 128_000_000 + ); + + guest.ssh_command("sudo shutdown -h now")?; + thread::sleep(std::time::Duration::new(10, 0)); + let _ = child.kill(); + let _ = child.wait(); + Ok(()) + }); + } + #[cfg_attr(not(feature = "mmio"), test)] fn test_pci_msi() { test_block!(tb, "", {