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
+4 -11
View File
@@ -1,17 +1,12 @@
#![cfg(unix)]
extern crate futures;
extern crate libc;
extern crate tokio;
extern crate tokio_core;
extern crate tokio_signal;
use std::sync::mpsc::channel;
use std::thread;
use futures::stream::Stream;
use tokio_core::reactor::Core;
use tokio_signal::unix::Signal;
pub mod support;
use support::*;
#[test]
fn multi_loop() {
@@ -27,7 +22,7 @@ fn multi_loop() {
let mut lp = Core::new().unwrap();
let signal = lp.run(Signal::new(libc::SIGHUP)).unwrap();
sender.send(()).unwrap();
lp.run(signal.into_future()).ok().unwrap();
run_core_with_timeout(&mut lp, signal.into_future()).ok().unwrap();
})
})
.collect();
@@ -36,9 +31,7 @@ fn multi_loop() {
receiver.recv().unwrap();
}
// Send a signal
unsafe {
assert_eq!(libc::kill(libc::getpid(), libc::SIGHUP), 0);
}
send_signal(libc::SIGHUP);
// Make sure the threads terminated correctly
for t in threads {
t.join().unwrap();