From f7378bc0923cc0038a26894b5bf154cb64daddfc Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Tue, 4 Feb 2020 16:47:21 +0000 Subject: [PATCH] tests: Add self spawning vhost-user-block test Also rename the net self spawning test to differentiate it from the the block one. Signed-off-by: Rob Bradford --- src/main.rs | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 86e3dc81a..617f72133 100755 --- a/src/main.rs +++ b/src/main.rs @@ -2779,7 +2779,7 @@ mod tests { } #[cfg_attr(not(feature = "mmio"), test)] - fn test_vhost_user_self_spawning() { + fn test_vhost_user_net_self_spawning() { test_block!(tb, "", { let mut clear = ClearDiskConfig::new(); let guest = Guest::new(&mut clear); @@ -2952,6 +2952,44 @@ mod tests { }); } + #[cfg_attr(not(feature = "mmio"), test)] + fn test_vhost_user_blk_self_spawning() { + test_block!(tb, "", { + let mut clear = ClearDiskConfig::new(); + let guest = Guest::new(&mut clear); + + let mut cloud_child = Command::new("target/release/cloud-hypervisor") + .args(&["--cpus", "boot=2"]) + .args(&["--memory", "size=512M,file=/dev/shm"]) + .args(&["--kernel", guest.fw_path.as_str()]) + .args(&[ + "--disk", + format!( + "path={},vhost_user=true", + guest.disk_config.disk(DiskType::OperatingSystem).unwrap() + ) + .as_str(), + format!( + "path={},vhost_user=true", + 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)); + + guest.ssh_command("sudo shutdown -h now")?; + thread::sleep(std::time::Duration::new(5, 0)); + let _ = cloud_child.kill(); + let _ = cloud_child.wait(); + + Ok(()) + }); + } + #[cfg_attr(not(feature = "mmio"), test)] fn test_vhost_user_blk_readonly() { test_block!(tb, "", {