mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-07 10:15:45 +00:00
tests: Port test_virtio_console to the new methodology
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
aac0cba0d1
commit
a4abb7f8e5
@ -3275,53 +3275,50 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_virtio_console() {
|
fn test_virtio_console() {
|
||||||
test_block!(tb, "", {
|
let mut focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
||||||
let mut focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
let guest = Guest::new(&mut focal);
|
||||||
let guest = Guest::new(&mut focal);
|
|
||||||
|
|
||||||
let mut workload_path = dirs::home_dir().unwrap();
|
let mut workload_path = dirs::home_dir().unwrap();
|
||||||
workload_path.push("workloads");
|
workload_path.push("workloads");
|
||||||
|
|
||||||
let kernel_path = direct_kernel_boot_path().unwrap();
|
let kernel_path = direct_kernel_boot_path().unwrap();
|
||||||
|
|
||||||
let mut child = GuestCommand::new(&guest)
|
let mut child = GuestCommand::new(&guest)
|
||||||
.args(&["--cpus", "boot=1"])
|
.args(&["--cpus", "boot=1"])
|
||||||
.args(&["--memory", "size=512M"])
|
.args(&["--memory", "size=512M"])
|
||||||
.args(&["--kernel", kernel_path.to_str().unwrap()])
|
.args(&["--kernel", kernel_path.to_str().unwrap()])
|
||||||
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
||||||
.default_disks()
|
.default_disks()
|
||||||
.default_net()
|
.default_net()
|
||||||
.args(&["--console", "tty"])
|
.args(&["--console", "tty"])
|
||||||
.args(&["--serial", "null"])
|
.args(&["--serial", "null"])
|
||||||
.capture_output()
|
.capture_output()
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
thread::sleep(std::time::Duration::new(20, 0));
|
thread::sleep(std::time::Duration::new(20, 0));
|
||||||
|
|
||||||
|
let text = String::from("On a branch floating down river a cricket, singing.");
|
||||||
|
let cmd = format!("echo {} | sudo tee /dev/hvc0", text);
|
||||||
|
|
||||||
|
let r = std::panic::catch_unwind(|| {
|
||||||
#[cfg(all(not(feature = "mmio"), feature = "acpi"))]
|
#[cfg(all(not(feature = "mmio"), feature = "acpi"))]
|
||||||
aver!(
|
assert!(guest
|
||||||
tb,
|
.does_device_vendor_pair_match("0x1043", "0x1af4")
|
||||||
guest
|
.unwrap_or_default());
|
||||||
.does_device_vendor_pair_match("0x1043", "0x1af4")
|
|
||||||
.unwrap_or_default()
|
|
||||||
);
|
|
||||||
|
|
||||||
let text = String::from("On a branch floating down river a cricket, singing.");
|
guest.ssh_command(&cmd).unwrap();
|
||||||
let cmd = format!("echo {} | sudo tee /dev/hvc0", text);
|
|
||||||
guest.ssh_command(&cmd)?;
|
|
||||||
|
|
||||||
let _ = child.kill();
|
|
||||||
|
|
||||||
match child.wait_with_output() {
|
|
||||||
Ok(out) => {
|
|
||||||
aver!(tb, String::from_utf8_lossy(&out.stdout).contains(&text));
|
|
||||||
}
|
|
||||||
Err(_) => aver!(tb, false),
|
|
||||||
}
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let _ = child.kill();
|
||||||
|
let output = child.wait_with_output().unwrap();
|
||||||
|
handle_child_output(r, &output);
|
||||||
|
|
||||||
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
assert!(String::from_utf8_lossy(&output.stdout).contains(&text));
|
||||||
|
});
|
||||||
|
|
||||||
|
handle_child_output(r, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(not(feature = "mmio"), test)]
|
#[cfg_attr(not(feature = "mmio"), test)]
|
||||||
|
Loading…
Reference in New Issue
Block a user