Skip to content

Commit

Permalink
Add HUP test
Browse files Browse the repository at this point in the history
  • Loading branch information
Finomnis committed Dec 2, 2023
1 parent bec0885 commit 43e16a6
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions tests/integration_test_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,44 @@ async fn shutdown_through_signal_2() {
);
}

#[cfg(unix)]
#[tokio::test]
#[traced_test]
async fn shutdown_through_signal_3() {
use nix::sys::signal::{self, Signal};
use nix::unistd::Pid;
use tokio_graceful_shutdown::FutureExt;

let subsystem = |subsys: SubsystemHandle| async move {
subsys.on_shutdown_requested().await;
sleep(Duration::from_millis(200)).await;
BoxedResult::Ok(())
};

tokio::join!(
async {
sleep(Duration::from_millis(100)).await;

// Send SIGINT to ourselves.
signal::kill(Pid::this(), Signal::SIGHUP).unwrap();
},
async {
let result = Toplevel::new(move |s| async move {
s.start(SubsystemBuilder::new("subsys", subsystem));
assert!(sleep(Duration::from_millis(1000))
.cancel_on_shutdown(&s)
.await
.is_err());
assert!(s.is_shutdown_requested());
})
.catch_signals()
.handle_shutdown_requests(Duration::from_millis(400))
.await;
assert!(result.is_ok());
},
);
}

#[tokio::test]
#[traced_test]
async fn cancellation_token() {
Expand Down

0 comments on commit 43e16a6

Please sign in to comment.