mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-07-07 10:15:45 +00:00
tests: Port test_virtio_pmem to new methodology
Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
7b621bde4f
commit
4983e5c322
@ -1684,7 +1684,6 @@ mod tests {
|
||||
}
|
||||
|
||||
fn test_virtio_pmem(discard_writes: bool, specify_size: bool) {
|
||||
test_block!(tb, "", {
|
||||
let mut focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
||||
let guest = Guest::new(&mut focal);
|
||||
|
||||
@ -1722,14 +1721,14 @@ mod tests {
|
||||
)
|
||||
.as_str(),
|
||||
])
|
||||
.capture_output()
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(std::time::Duration::new(20, 0));
|
||||
|
||||
let r = std::panic::catch_unwind(|| {
|
||||
// Check for the presence of /dev/pmem0
|
||||
aver_eq!(
|
||||
tb,
|
||||
assert_eq!(
|
||||
guest
|
||||
.ssh_command("ls /dev/pmem0")
|
||||
.unwrap_or_default()
|
||||
@ -1738,17 +1737,13 @@ mod tests {
|
||||
);
|
||||
|
||||
// Check changes persist after reboot
|
||||
aver_eq!(
|
||||
tb,
|
||||
guest.ssh_command("sudo mount /dev/pmem0 /mnt").unwrap(),
|
||||
""
|
||||
);
|
||||
aver_eq!(tb, guest.ssh_command("ls /mnt").unwrap(), "lost+found\n");
|
||||
assert_eq!(guest.ssh_command("sudo mount /dev/pmem0 /mnt").unwrap(), "");
|
||||
assert_eq!(guest.ssh_command("ls /mnt").unwrap(), "lost+found\n");
|
||||
guest
|
||||
.ssh_command("echo test123 | sudo tee /mnt/test")
|
||||
.unwrap();
|
||||
aver_eq!(tb, guest.ssh_command("sudo umount /mnt").unwrap(), "");
|
||||
aver_eq!(tb, guest.ssh_command("ls /mnt").unwrap(), "");
|
||||
assert_eq!(guest.ssh_command("sudo umount /mnt").unwrap(), "");
|
||||
assert_eq!(guest.ssh_command("ls /mnt").unwrap(), "");
|
||||
|
||||
guest.ssh_command("sudo reboot").unwrap();
|
||||
thread::sleep(std::time::Duration::new(30, 0));
|
||||
@ -1758,26 +1753,21 @@ mod tests {
|
||||
.trim()
|
||||
.parse::<u32>()
|
||||
.unwrap_or_default();
|
||||
aver_eq!(tb, reboot_count, 1);
|
||||
aver_eq!(
|
||||
tb,
|
||||
guest.ssh_command("sudo mount /dev/pmem0 /mnt").unwrap(),
|
||||
""
|
||||
);
|
||||
aver_eq!(
|
||||
tb,
|
||||
assert_eq!(reboot_count, 1);
|
||||
assert_eq!(guest.ssh_command("sudo mount /dev/pmem0 /mnt").unwrap(), "");
|
||||
assert_eq!(
|
||||
guest
|
||||
.ssh_command("sudo cat /mnt/test")
|
||||
.unwrap_or_default()
|
||||
.trim(),
|
||||
if discard_writes { "" } else { "test123" }
|
||||
);
|
||||
});
|
||||
|
||||
let _ = child.kill();
|
||||
let _ = child.wait();
|
||||
let output = child.wait_with_output().unwrap();
|
||||
|
||||
Ok(())
|
||||
});
|
||||
handle_child_output(r, &output);
|
||||
}
|
||||
|
||||
fn get_fd_count(pid: u32) -> usize {
|
||||
|
Loading…
Reference in New Issue
Block a user