Skip to content

Commit 910f0c5

Browse files
committed
test(signal): sleep to avoid race condition
The unit test is asserting that the metrics are increased, however the signal delivery is asynchronous so it could sometimes happen that a metric (usually the last one) isn't increased it. By adding a 100ms wait, it would be very unlikely to happen. Signed-off-by: Riccardo Mancini <[email protected]>
1 parent 181d8dd commit 910f0c5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/vmm/src/signal_handler.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ pub fn register_signal_handlers() -> vmm_sys_util::errno::Result<()> {
174174
#[cfg(test)]
175175
mod tests {
176176
#![allow(clippy::undocumented_unsafe_blocks)]
177+
use std::time::Duration;
177178
use std::{process, thread};
178179

179180
use libc::syscall;
@@ -229,6 +230,9 @@ mod tests {
229230
});
230231
child.join().unwrap();
231232

233+
// signal delivery is asynchronous so wait a little to avoid race conditions
234+
thread::sleep(Duration::from_millis(100));
235+
232236
assert!(METRICS.signals.sigbus.fetch() >= 1);
233237
assert!(METRICS.signals.sigsegv.fetch() >= 1);
234238
assert!(METRICS.signals.sigxfsz.fetch() >= 1);

0 commit comments

Comments
 (0)