mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
main: Add integration test
Use qemu/tests/vhost-user-bridge as the backend for integration test for vhost-user-net. Signed-off-by: Cathy Zhang <cathy.zhang@intel.com>
This commit is contained in:
committed by
Rob Bradford
parent
f21d54f6b0
commit
cc7a96e9d3
66
src/main.rs
66
src/main.rs
@@ -1097,6 +1097,72 @@ mod tests {
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_vhost_user_net() {
|
||||
test_block!(tb, "", {
|
||||
let mut clear = ClearDiskConfig::new();
|
||||
let guest = Guest::new(&mut clear);
|
||||
|
||||
let mut workload_path = dirs::home_dir().unwrap();
|
||||
workload_path.push("workloads");
|
||||
|
||||
let mut vubridge_path = workload_path.clone();
|
||||
vubridge_path.push("vubridge");
|
||||
let vubridge_path = String::from(vubridge_path.to_str().unwrap());
|
||||
|
||||
// Start the daemon
|
||||
let mut daemon_child = Command::new(vubridge_path.as_str()).spawn().unwrap();
|
||||
|
||||
let mut cloud_child = Command::new("target/debug/cloud-hypervisor")
|
||||
.args(&["--cpus", "4"])
|
||||
.args(&["--memory", "size=512M,file=/dev/shm"])
|
||||
.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(&[
|
||||
"--vhost-user-net",
|
||||
"mac=52:54:00:02:d9:01,sock=/tmp/vubr.sock",
|
||||
])
|
||||
.args(&["--net", guest.default_net_string().as_str()])
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
// 2 network interfaces + default localhost ==> 3 interfaces
|
||||
aver_eq!(
|
||||
tb,
|
||||
guest
|
||||
.ssh_command("ip -o link | wc -l")
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
.unwrap_or_default(),
|
||||
3
|
||||
);
|
||||
|
||||
thread::sleep(std::time::Duration::new(5, 0));
|
||||
let _ = daemon_child.kill();
|
||||
let _ = daemon_child.wait();
|
||||
|
||||
guest.ssh_command("sudo reboot")?;
|
||||
thread::sleep(std::time::Duration::new(5, 0));
|
||||
let _ = cloud_child.kill();
|
||||
let _ = cloud_child.wait();
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_split_irqchip() {
|
||||
test_block!(tb, "", {
|
||||
|
||||
Reference in New Issue
Block a user