mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-27 00:00:12 +02:00
signal: remove oneshot channels from tests (#7015)
This commit is contained in:
@@ -9,23 +9,15 @@ mod support {
|
|||||||
use support::signal::send_signal;
|
use support::signal::send_signal;
|
||||||
|
|
||||||
use tokio::signal;
|
use tokio::signal;
|
||||||
use tokio::sync::oneshot;
|
|
||||||
use tokio_test::assert_ok;
|
use tokio_test::assert_ok;
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn ctrl_c() {
|
async fn ctrl_c() {
|
||||||
let ctrl_c = signal::ctrl_c();
|
let ctrl_c = signal::ctrl_c();
|
||||||
|
|
||||||
let (fire, wait) = oneshot::channel();
|
|
||||||
|
|
||||||
// NB: simulate a signal coming in by exercising our signal handler
|
|
||||||
// to avoid complications with sending SIGINT to the test process
|
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {
|
||||||
wait.await.expect("wait failed");
|
|
||||||
send_signal(libc::SIGINT);
|
send_signal(libc::SIGINT);
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = fire.send(());
|
|
||||||
|
|
||||||
assert_ok!(ctrl_c.await);
|
assert_ok!(ctrl_c.await);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,24 +17,16 @@ use support::signal::send_signal;
|
|||||||
|
|
||||||
use tokio::signal;
|
use tokio::signal;
|
||||||
use tokio::signal::unix::SignalKind;
|
use tokio::signal::unix::SignalKind;
|
||||||
use tokio::sync::oneshot;
|
|
||||||
use tokio::time::{timeout, Duration};
|
use tokio::time::{timeout, Duration};
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn siginfo() {
|
async fn siginfo() {
|
||||||
let mut sig = signal::unix::signal(SignalKind::info()).expect("installed signal handler");
|
let mut sig = signal::unix::signal(SignalKind::info()).expect("installed signal handler");
|
||||||
|
|
||||||
let (fire, wait) = oneshot::channel();
|
|
||||||
|
|
||||||
// NB: simulate a signal coming in by exercising our signal handler
|
|
||||||
// to avoid complications with sending SIGINFO to the test process
|
|
||||||
tokio::spawn(async {
|
tokio::spawn(async {
|
||||||
wait.await.expect("wait failed");
|
|
||||||
send_signal(libc::SIGINFO);
|
send_signal(libc::SIGINFO);
|
||||||
});
|
});
|
||||||
|
|
||||||
let _ = fire.send(());
|
|
||||||
|
|
||||||
// Add a timeout to ensure the test doesn't hang.
|
// Add a timeout to ensure the test doesn't hang.
|
||||||
timeout(Duration::from_secs(5), sig.recv())
|
timeout(Duration::from_secs(5), sig.recv())
|
||||||
.await
|
.await
|
||||||
|
|||||||
Reference in New Issue
Block a user