mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-06 00:00:10 +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:
+11
-11
@@ -1,20 +1,20 @@
|
||||
#![cfg(unix)]
|
||||
|
||||
extern crate futures;
|
||||
extern crate libc;
|
||||
extern crate tokio_core;
|
||||
extern crate tokio_signal;
|
||||
|
||||
use futures::stream::Stream;
|
||||
use tokio_core::reactor::Core;
|
||||
use tokio_signal::unix::Signal;
|
||||
pub mod support;
|
||||
use support::*;
|
||||
|
||||
#[test]
|
||||
fn simple() {
|
||||
let mut lp = Core::new().unwrap();
|
||||
let signal = lp.run(Signal::new(libc::SIGUSR1)).unwrap();
|
||||
unsafe {
|
||||
assert_eq!(libc::kill(libc::getpid(), libc::SIGUSR1), 0);
|
||||
}
|
||||
lp.run(signal.into_future()).ok().unwrap();
|
||||
|
||||
let signal = run_core_with_timeout(&mut lp, Signal::new(libc::SIGUSR1))
|
||||
.expect("failed to create signal");
|
||||
|
||||
send_signal(libc::SIGUSR1);
|
||||
|
||||
run_core_with_timeout(&mut lp, signal.into_future())
|
||||
.ok()
|
||||
.expect("failed to get signal");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user