From c98949bdd3b3c35f65094470015ee68fec93704a Mon Sep 17 00:00:00 2001 From: Rob Bradford Date: Thu, 27 Feb 2020 13:56:25 +0000 Subject: [PATCH] tests: Wait for VMM to exit in test_serial_file/test_console_file This should address any flakiness as the VMM process will have completely terminated and all files closed. Signed-off-by: Rob Bradford --- tests/integration.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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(()) }); }