signal: Refactor Signal tests

* Added timeouts to all tests that were missing them
 - any issue we have will likely result in deadlocks/starvation so its
   best if all tests quickly timeout rather than require getting killed
   or have the CI timeout itself
* Added a `support` module and put a bunch of helpers there to DRY the
tests
This commit is contained in:
Ivan Petkov
2018-09-10 11:30:06 -07:00
committed by Carl Lerche
parent c9ffd98b1e
commit 266919add6
9 changed files with 160 additions and 106 deletions
+12 -17
View File
@@ -1,32 +1,27 @@
#![cfg(unix)]
extern crate futures;
extern crate libc;
extern crate tokio;
extern crate tokio_core;
extern crate tokio_signal;
use futures::stream::Stream;
use futures::Future;
use tokio_core::reactor::Core;
use tokio_signal::unix::Signal;
pub mod support;
use support::*;
#[test]
fn notify_both() {
let mut lp = Core::new().unwrap();
let handle = lp.handle();
let signal1 = lp.run(Signal::with_handle(
let signal1 = run_core_with_timeout(&mut lp, Signal::with_handle(
libc::SIGUSR2,
&handle.new_tokio_handle(),
)).unwrap();
let signal2 = lp.run(Signal::with_handle(
)).expect("failed to create signal1");
let signal2 = run_core_with_timeout(&mut lp, Signal::with_handle(
libc::SIGUSR2,
&handle.new_tokio_handle(),
)).unwrap();
unsafe {
assert_eq!(libc::kill(libc::getpid(), libc::SIGUSR2), 0);
}
lp.run(signal1.into_future().join(signal2.into_future()))
)).expect("failed to create signal2");
send_signal(libc::SIGUSR2);
run_core_with_timeout(&mut lp, signal1.into_future().join(signal2.into_future()))
.ok()
.unwrap();
.expect("failed to create signal2");
}