mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-05 13:05:45 +00:00
tests: Port test_bzimage_reboot to the new methodology
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
ded376c6e1
commit
4392a1484c
@ -3713,7 +3713,6 @@ mod tests {
|
|||||||
#[cfg_attr(not(feature = "mmio"), test)]
|
#[cfg_attr(not(feature = "mmio"), test)]
|
||||||
#[cfg(target_arch = "x86_64")]
|
#[cfg(target_arch = "x86_64")]
|
||||||
fn test_bzimage_reboot() {
|
fn test_bzimage_reboot() {
|
||||||
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();
|
||||||
@ -3729,11 +3728,13 @@ mod tests {
|
|||||||
.default_disks()
|
.default_disks()
|
||||||
.default_net()
|
.default_net()
|
||||||
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
.args(&["--cmdline", DIRECT_KERNEL_BOOT_CMDLINE])
|
||||||
|
.capture_output()
|
||||||
.spawn()
|
.spawn()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
thread::sleep(std::time::Duration::new(20, 0));
|
thread::sleep(std::time::Duration::new(20, 0));
|
||||||
|
|
||||||
|
let r = std::panic::catch_unwind(|| {
|
||||||
let reboot_count = guest
|
let reboot_count = guest
|
||||||
.ssh_command("journalctl | grep -c -- \"-- Reboot --\"")
|
.ssh_command("journalctl | grep -c -- \"-- Reboot --\"")
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
@ -3742,8 +3743,8 @@ mod tests {
|
|||||||
.unwrap_or(1);
|
.unwrap_or(1);
|
||||||
let fd_count_1 = get_fd_count(child.id());
|
let fd_count_1 = get_fd_count(child.id());
|
||||||
|
|
||||||
aver_eq!(tb, reboot_count, 0);
|
assert_eq!(reboot_count, 0);
|
||||||
guest.ssh_command("sudo reboot")?;
|
guest.ssh_command("sudo reboot").unwrap();
|
||||||
|
|
||||||
thread::sleep(std::time::Duration::new(20, 0));
|
thread::sleep(std::time::Duration::new(20, 0));
|
||||||
let reboot_count = guest
|
let reboot_count = guest
|
||||||
@ -3753,19 +3754,23 @@ mod tests {
|
|||||||
.parse::<u32>()
|
.parse::<u32>()
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
let fd_count_2 = get_fd_count(child.id());
|
let fd_count_2 = get_fd_count(child.id());
|
||||||
aver_eq!(tb, reboot_count, 1);
|
assert_eq!(reboot_count, 1);
|
||||||
aver_eq!(tb, fd_count_1, fd_count_2);
|
assert_eq!(fd_count_1, fd_count_2);
|
||||||
|
|
||||||
guest.ssh_command("sudo shutdown -h now")?;
|
guest.ssh_command("sudo shutdown -h now").unwrap();
|
||||||
thread::sleep(std::time::Duration::new(20, 0));
|
thread::sleep(std::time::Duration::new(20, 0));
|
||||||
|
|
||||||
// Check that the cloud-hypervisor binary actually terminated
|
|
||||||
if let Ok(status) = child.wait() {
|
|
||||||
aver_eq!(tb, status.success(), true);
|
|
||||||
}
|
|
||||||
let _ = child.wait();
|
|
||||||
Ok(())
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let _ = child.kill();
|
||||||
|
let output = child.wait_with_output().unwrap();
|
||||||
|
handle_child_output(r, &output);
|
||||||
|
|
||||||
|
let r = std::panic::catch_unwind(|| {
|
||||||
|
// Check that the cloud-hypervisor binary actually terminated
|
||||||
|
assert_eq!(output.status.success(), true);
|
||||||
|
});
|
||||||
|
|
||||||
|
handle_child_output(r, &output);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user