2018-07-28 12:30:46 -07:00
|
|
|
#![cfg(unix)]
|
2019-05-14 10:27:36 -07:00
|
|
|
#![deny(warnings, rust_2018_idioms)]
|
2018-07-28 12:30:46 -07:00
|
|
|
|
2019-05-14 10:27:36 -07:00
|
|
|
use libc;
|
2018-07-28 12:30:46 -07:00
|
|
|
|
|
|
|
|
pub mod support;
|
2019-05-14 10:27:36 -07:00
|
|
|
use crate::support::*;
|
2018-07-28 12:30:46 -07:00
|
|
|
|
|
|
|
|
const TEST_SIGNAL: libc::c_int = libc::SIGUSR1;
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn dropping_loops_does_not_cause_starvation() {
|
|
|
|
|
let (mut rt, signal) = {
|
2019-02-21 11:56:15 -08:00
|
|
|
let mut first_rt = CurrentThreadRuntime::new().expect("failed to init first runtime");
|
2018-07-28 12:30:46 -07:00
|
|
|
|
|
|
|
|
let first_signal = run_with_timeout(&mut first_rt, Signal::new(TEST_SIGNAL))
|
|
|
|
|
.expect("failed to register first signal");
|
|
|
|
|
|
2019-02-21 11:56:15 -08:00
|
|
|
let mut second_rt = CurrentThreadRuntime::new().expect("failed to init second runtime");
|
2018-07-28 12:30:46 -07:00
|
|
|
|
|
|
|
|
let second_signal = run_with_timeout(&mut second_rt, Signal::new(TEST_SIGNAL))
|
|
|
|
|
.expect("failed to register second signal");
|
|
|
|
|
|
|
|
|
|
drop(first_rt);
|
|
|
|
|
drop(first_signal);
|
|
|
|
|
|
|
|
|
|
(second_rt, second_signal)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
send_signal(TEST_SIGNAL);
|
|
|
|
|
|
2019-07-09 08:48:46 -07:00
|
|
|
let _ = run_with_timeout(&mut rt, signal.into_future());
|
2018-07-28 12:30:46 -07:00
|
|
|
}
|