tests: Port test_virtio_console to the new methodology

Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
Bo Chen 2020-09-02 16:16:38 -07:00 committed by Rob Bradford
parent aac0cba0d1
commit a4abb7f8e5

View File

@ -3275,7 +3275,6 @@ mod tests {
#[test]
fn test_virtio_console() {
test_block!(tb, "", {
let mut focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
let guest = Guest::new(&mut focal);
@ -3299,29 +3298,27 @@ mod tests {
thread::sleep(std::time::Duration::new(20, 0));
#[cfg(all(not(feature = "mmio"), feature = "acpi"))]
aver!(
tb,
guest
.does_device_vendor_pair_match("0x1043", "0x1af4")
.unwrap_or_default()
);
let text = String::from("On a branch floating down river a cricket, singing.");
let cmd = format!("echo {} | sudo tee /dev/hvc0", text);
guest.ssh_command(&cmd)?;
let r = std::panic::catch_unwind(|| {
#[cfg(all(not(feature = "mmio"), feature = "acpi"))]
assert!(guest
.does_device_vendor_pair_match("0x1043", "0x1af4")
.unwrap_or_default());
guest.ssh_command(&cmd).unwrap();
});
let _ = child.kill();
let output = child.wait_with_output().unwrap();
handle_child_output(r, &output);
match child.wait_with_output() {
Ok(out) => {
aver!(tb, String::from_utf8_lossy(&out.stdout).contains(&text));
}
Err(_) => aver!(tb, false),
}
Ok(())
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)]