mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
improve reliability of hang monitor tests
This commit is contained in:
parent
39e3beb35c
commit
256167eff2
2 changed files with 25 additions and 17 deletions
|
@ -33,17 +33,19 @@ impl HangMonitorRegister {
|
||||||
monitoring_enabled: bool,
|
monitoring_enabled: bool,
|
||||||
) -> Box<dyn BackgroundHangMonitorRegister> {
|
) -> Box<dyn BackgroundHangMonitorRegister> {
|
||||||
let (sender, port) = unbounded();
|
let (sender, port) = unbounded();
|
||||||
let _ = thread::Builder::new().spawn(move || {
|
let _ = thread::Builder::new()
|
||||||
let mut monitor = BackgroundHangMonitorWorker::new(
|
.spawn(move || {
|
||||||
constellation_chan,
|
let mut monitor = BackgroundHangMonitorWorker::new(
|
||||||
control_port,
|
constellation_chan,
|
||||||
port,
|
control_port,
|
||||||
monitoring_enabled,
|
port,
|
||||||
);
|
monitoring_enabled,
|
||||||
while monitor.run() {
|
);
|
||||||
// Monitoring until all senders have been dropped...
|
while monitor.run() {
|
||||||
}
|
// Monitoring until all senders have been dropped...
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
.expect("Couldn't start BHM worker.");
|
||||||
Box::new(HangMonitorRegister {
|
Box::new(HangMonitorRegister {
|
||||||
sender,
|
sender,
|
||||||
monitoring_enabled,
|
monitoring_enabled,
|
||||||
|
|
|
@ -197,12 +197,18 @@ fn test_hang_monitoring_exit_signal() {
|
||||||
);
|
);
|
||||||
|
|
||||||
let (exit_sender, exit_receiver) = ipc::channel().expect("Failed to create IPC channel!");
|
let (exit_sender, exit_receiver) = ipc::channel().expect("Failed to create IPC channel!");
|
||||||
|
|
||||||
// Send the exit message.
|
// Send the exit message.
|
||||||
let _ = control_sender.send(BackgroundHangMonitorControlMsg::Exit(exit_sender));
|
if control_sender
|
||||||
|
.send(BackgroundHangMonitorControlMsg::Exit(exit_sender))
|
||||||
|
.is_ok()
|
||||||
|
{
|
||||||
|
// Assert we receive a confirmation back.
|
||||||
|
assert!(exit_receiver.recv().is_ok());
|
||||||
|
|
||||||
// Assert we receive a confirmation back.
|
// Assert we get the exit signal.
|
||||||
assert!(exit_receiver.recv().is_ok());
|
while !closing.load(Ordering::SeqCst) {
|
||||||
|
thread::sleep(Duration::from_millis(10));
|
||||||
// Assert we get the exit signal.
|
}
|
||||||
while !closing.load(Ordering::SeqCst) {}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue