Debian Codegraph @

third_party/rust/tokio/tests/signal_panic.rs

raw
1 #![warn(rust_2018_idioms)]
2 #![cfg(feature = "full")]
3 #![cfg(unix)]
4 #![cfg(panic = "unwind")]
5
6 use std::error::Error;
7 use tokio::runtime::Builder;
8 use tokio::signal::unix::{signal, SignalKind};
9
10 mod support {
11 pub mod panic;
12 }
13 use support::panic::test_panic;
14
15 #[test]
16 fn signal_panic_caller() -> Result<(), Box<dyn Error>> {
17 let panic_location_file = test_panic(|| {
18 let rt = Builder::new_current_thread().build().unwrap();
19
20 rt.block_on(async {
21 let kind = SignalKind::from_raw(-1);
22 let _ = signal(kind);
23 });
24 });
25
26 // The panic location should be in this file
27 assert_eq!(&panic_location_file.unwrap(), file!());
28
29 Ok(())
30 }