mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-01-12 15:42:57 +00:00
tests: Add Windows guest integration test
This is a new integration test running Windows as a guest with Cloud Hypervisor. Once the VM is booted, the test connects to the guest through SSH and shutdown the VM. If this succeeds, this means the VM was properly booted to userspace and that the network was functional. Important to note that because this test generates lots of logs, it requires a large pipe size for both stdout and stderr. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
0eabc00b27
commit
d598341534
@ -5346,6 +5346,66 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
mod windows {
|
||||
use crate::tests::*;
|
||||
|
||||
#[test]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn test_windows_guest() {
|
||||
let mut workload_path = dirs::home_dir().unwrap();
|
||||
workload_path.push("workloads");
|
||||
|
||||
let mut ovmf_path = workload_path.clone();
|
||||
ovmf_path.push("OVMF.fd");
|
||||
|
||||
let mut osdisk_path = workload_path;
|
||||
osdisk_path.push("windows-server-2019.raw");
|
||||
|
||||
let mut child = Command::new(clh_command("cloud-hypervisor"))
|
||||
.args(&["--cpus", "boot=2,kvm_hyperv=on,max_phys_bits=39"])
|
||||
.args(&["--memory", "size=4G"])
|
||||
.args(&["--kernel", ovmf_path.to_str().unwrap()])
|
||||
.args(&["--disk", &format!("path={}", osdisk_path.to_str().unwrap())])
|
||||
.args(&["--serial", "tty"])
|
||||
.args(&["--console", "off"])
|
||||
.args(&["--net", "tap="])
|
||||
.stderr(Stdio::piped())
|
||||
.stdout(Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
let fd = child.stdout.as_ref().unwrap().as_raw_fd();
|
||||
let pipesize = unsafe { libc::fcntl(fd, libc::F_SETPIPE_SZ, PIPE_SIZE * 100) };
|
||||
let fd = child.stderr.as_ref().unwrap().as_raw_fd();
|
||||
let pipesize1 = unsafe { libc::fcntl(fd, libc::F_SETPIPE_SZ, PIPE_SIZE * 100) };
|
||||
|
||||
assert!(pipesize >= PIPE_SIZE * 100 && pipesize1 >= PIPE_SIZE * 100);
|
||||
|
||||
thread::sleep(std::time::Duration::new(40, 0));
|
||||
let auth = PasswordAuth {
|
||||
username: String::from("administrator"),
|
||||
password: String::from("Admin123"),
|
||||
};
|
||||
|
||||
let r = std::panic::catch_unwind(|| {
|
||||
ssh_command_ip_with_auth(
|
||||
"shutdown /s",
|
||||
&auth,
|
||||
"192.168.249.2",
|
||||
DEFAULT_SSH_RETRIES,
|
||||
DEFAULT_SSH_TIMEOUT,
|
||||
)
|
||||
.unwrap();
|
||||
thread::sleep(std::time::Duration::new(40, 0));
|
||||
});
|
||||
|
||||
let _ = child.kill();
|
||||
let output = child.wait_with_output().unwrap();
|
||||
|
||||
handle_child_output(r, &output);
|
||||
}
|
||||
}
|
||||
|
||||
mod sgx {
|
||||
use crate::tests::*;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user