mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-29 00:00:11 +02:00
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:
+12
-17
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user