mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-01 17:35:19 +00:00
tests: Port test_reboot to the new methodology
Signed-off-by: Bo Chen <chen.bo@intel.com>
This commit is contained in:
parent
d03a48162f
commit
cb2f11724a
@ -3775,7 +3775,6 @@ mod tests {
|
||||
#[cfg_attr(not(feature = "mmio"), test)]
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
fn test_reboot() {
|
||||
test_block!(tb, "", {
|
||||
let mut bionic = UbuntuDiskConfig::new(BIONIC_IMAGE_NAME.to_string());
|
||||
let mut focal = UbuntuDiskConfig::new(FOCAL_IMAGE_NAME.to_string());
|
||||
|
||||
@ -3794,11 +3793,13 @@ mod tests {
|
||||
.default_raw_disks()
|
||||
.default_net()
|
||||
.args(&["--serial", "tty", "--console", "off"])
|
||||
.capture_output()
|
||||
.spawn()
|
||||
.unwrap();
|
||||
|
||||
thread::sleep(std::time::Duration::new(20, 0));
|
||||
|
||||
let r = std::panic::catch_unwind(|| {
|
||||
let reboot_count = guest
|
||||
.ssh_command("sudo journalctl | grep -c -- \"-- Reboot --\"")
|
||||
.unwrap_or_default()
|
||||
@ -3807,7 +3808,7 @@ mod tests {
|
||||
.unwrap_or(1);
|
||||
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").unwrap_or_default();
|
||||
|
||||
thread::sleep(std::time::Duration::new(20, 0));
|
||||
@ -3818,20 +3819,25 @@ mod tests {
|
||||
.parse::<u32>()
|
||||
.unwrap_or_default();
|
||||
let fd_count_2 = get_fd_count(child.id());
|
||||
aver_eq!(tb, reboot_count, 1);
|
||||
aver_eq!(tb, fd_count_1, fd_count_2);
|
||||
assert_eq!(reboot_count, 1);
|
||||
assert_eq!(fd_count_1, fd_count_2);
|
||||
|
||||
guest
|
||||
.ssh_command("sudo shutdown -h now")
|
||||
.unwrap_or_default();
|
||||
|
||||
// Check that the cloud-hypervisor binary actually terminated
|
||||
if let Ok(status) = child.wait() {
|
||||
aver_eq!(tb, status.success(), true);
|
||||
}
|
||||
let _ = child.wait();
|
||||
thread::sleep(std::time::Duration::new(20, 0));
|
||||
});
|
||||
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);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user