1#![warn(rust_2018_idioms)]
2#![cfg(feature = "full")]
3#![cfg(unix)]
4
5mod support {
6 pub mod signal;
7}
8use support::signal::send_signal;
9
10use tokio::signal;
11use tokio::sync::oneshot;
12use tokio_test::assert_ok;
13
14#[tokio::test]
15async fn ctrl_c() {
16 let ctrl_c = signal::ctrl_c();
17
18 let (fire, wait) = oneshot::channel();
19
20 // NB: simulate a signal coming in by exercising our signal handler
21 // to avoid complications with sending SIGINT to the test process
22 tokio::spawn(async {
23 wait.await.expect("wait failed");
24 send_signal(libc::SIGINT);
25 });
26
27 let _ = fire.send(());
28
29 assert_ok!(ctrl_c.await);
30}
31