diff --git a/tests/integration.rs b/tests/integration.rs index bb282fc13..496742a4b 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -2087,8 +2087,10 @@ mod tests { guest.ssh_command("sudo shutdown -h now")?; - thread::sleep(std::time::Duration::new(10, 0)); - + // Check that the cloud-hypervisor binary actually terminated + if let Ok(status) = child.wait() { + aver_eq!(tb, status.success(), true); + } // Do this check after shutdown of the VM as an easy way to ensure // all writes are flushed to disk let mut f = std::fs::File::open(serial_path)?; @@ -2096,9 +2098,6 @@ mod tests { f.read_to_string(&mut buf)?; aver!(tb, buf.contains("cloud login:")); - let _ = child.kill(); - let _ = child.wait(); - Ok(()) }); } @@ -2170,8 +2169,11 @@ mod tests { thread::sleep(std::time::Duration::new(20, 0)); guest.ssh_command("sudo shutdown -h now")?; - thread::sleep(std::time::Duration::new(10, 0)); + // Check that the cloud-hypervisor binary actually terminated + if let Ok(status) = child.wait() { + aver_eq!(tb, status.success(), true); + } // Do this check after shutdown of the VM as an easy way to ensure // all writes are flushed to disk let mut f = std::fs::File::open(console_path)?; @@ -2179,9 +2181,6 @@ mod tests { f.read_to_string(&mut buf)?; aver!(tb, buf.contains("cloud login:")); - let _ = child.kill(); - let _ = child.wait(); - Ok(()) }); }