mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-30 16:35:31 +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:
parent
f21d54f6b0
commit
cc7a96e9d3
@ -79,14 +79,16 @@ if [ ! -f "$VMLINUX_IMAGE" ]; then
|
||||
fi
|
||||
|
||||
VIRTIOFSD="$WORKLOADS_DIR/virtiofsd"
|
||||
VUBRIDGE="$WORKLOADS_DIR/vubridge"
|
||||
QEMU_DIR="qemu_build"
|
||||
if [ ! -f "$VIRTIOFSD" ]; then
|
||||
if [ ! -f "$VIRTIOFSD" || ! -f "$VUBRIDGE" ]; then
|
||||
pushd $WORKLOADS_DIR
|
||||
git clone --depth 1 "https://github.com/sboeuf/qemu.git" -b "virtio-fs" $QEMU_DIR
|
||||
pushd $QEMU_DIR
|
||||
./configure --prefix=$PWD --target-list=x86_64-softmmu
|
||||
make virtiofsd -j `nproc`
|
||||
make virtiofsd tests/vhost-user-bridge -j `nproc`
|
||||
cp virtiofsd $VIRTIOFSD
|
||||
cp tests/vhost-user-bridge $VUBRIDGE
|
||||
popd
|
||||
rm -rf $QEMU_DIR
|
||||
sudo setcap cap_dac_override,cap_sys_admin+epi "virtiofsd"
|
||||
|
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, "", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user