diff --git a/cloud-hypervisor/tests/integration.rs b/cloud-hypervisor/tests/integration.rs index fd102cd50..096e6ea9a 100644 --- a/cloud-hypervisor/tests/integration.rs +++ b/cloud-hypervisor/tests/integration.rs @@ -6442,9 +6442,10 @@ mod common_parallel { ); } - // Check the source vm has been terminated successful (give it '3s' to settle) - thread::sleep(std::time::Duration::new(3, 0)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child, @@ -6581,9 +6582,10 @@ mod common_parallel { ); } - // Check the source vm has been terminated successful (give it '3s' to settle) - thread::sleep(std::time::Duration::new(3, 0)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child, @@ -6807,9 +6809,10 @@ mod common_parallel { ); } - // Check the source vm has been terminated successful (give it '3s' to settle) - thread::sleep(std::time::Duration::new(3, 0)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child, @@ -7191,9 +7194,10 @@ mod common_parallel { ); } - // Check the source vm has been terminated successfully (give it '3s' to settle) - thread::sleep(Duration::from_secs(3)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child, @@ -7531,9 +7535,10 @@ mod ivshmem { ); } - // Check the source vm has been terminated successful (give it '3s' to settle) - thread::sleep(std::time::Duration::new(3, 0)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child, @@ -9043,9 +9048,10 @@ mod common_sequential { ); } - // Check the source vm has been terminated successful (give it '3s' to settle) - thread::sleep(std::time::Duration::new(3, 0)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child, @@ -9270,9 +9276,10 @@ mod common_sequential { ); } - // Check the source vm has been terminated successful (give it '3s' to settle) - thread::sleep(std::time::Duration::new(3, 0)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child, @@ -9404,9 +9411,10 @@ mod common_sequential { ); } - // Check the source vm has been terminated successful (give it '3s' to settle) - thread::sleep(std::time::Duration::new(3, 0)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child, @@ -9683,9 +9691,10 @@ mod common_sequential { ); } - // Check the source vm has been terminated successful (give it '3s' to settle) - thread::sleep(std::time::Duration::new(3, 0)); - if !src_child.try_wait().unwrap().is_some_and(|s| s.success()) { + let src_exited_ok = wait_until(Duration::from_secs(30), || { + matches!(src_child.try_wait(), Ok(Some(_))) + }) && src_child.try_wait().unwrap().is_some_and(|s| s.success()); + if !src_exited_ok { print_and_panic( src_child, dest_child,