mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-24 00:00:11 +02:00
* Cargo runs each integration-style-test in its own process. Since the tests use global data structures specific to the process, we should run them in an isolated manner to avoid having cross-test interactions * Fixes alexcrichton/tokio-signal#39
29 lines
674 B
Rust
29 lines
674 B
Rust
#![cfg(unix)]
|
|
|
|
extern crate futures;
|
|
extern crate libc;
|
|
extern crate tokio;
|
|
extern crate tokio_core;
|
|
extern crate tokio_signal;
|
|
|
|
use std::time::Duration;
|
|
|
|
use tokio_core::reactor::{Core, Timeout};
|
|
use tokio_signal::unix::Signal;
|
|
|
|
#[test]
|
|
fn drop_then_get_a_signal() {
|
|
let mut lp = Core::new().unwrap();
|
|
let handle = lp.handle();
|
|
let signal = lp.run(Signal::with_handle(
|
|
libc::SIGUSR1,
|
|
&handle.new_tokio_handle(),
|
|
)).unwrap();
|
|
drop(signal);
|
|
unsafe {
|
|
assert_eq!(libc::kill(libc::getpid(), libc::SIGUSR1), 0);
|
|
}
|
|
let timeout = Timeout::new(Duration::from_millis(1), &lp.handle()).unwrap();
|
|
lp.run(timeout).unwrap();
|
|
}
|