tests: Port test_virtio_console to the new methodology
@@ -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));
+ 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"))]
- aver!(
- tb,
- guest
+ assert!(guest
.does_device_vendor_pair_match("0x1043", "0x1af4")
- .unwrap_or_default()
- );
+ .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)?;
+ 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)]
