mirror of
https://github.com/tokio-rs/tokio.git
synced 2025-09-28 12:10:37 +00:00
tokio: gate some panicking tests with #[cfg(panic = "unwind")] (#6115)
This commit is contained in:
parent
cc86fef9c0
commit
d8a4a5f24b
@ -64,6 +64,7 @@ enum CombiAbortSource {
|
||||
AbortHandle,
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn test_combinations() {
|
||||
let mut rt = &[
|
||||
|
@ -36,6 +36,7 @@ fn wake_without_register() {
|
||||
assert!(!waker.is_woken());
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
#[cfg(not(target_family = "wasm"))] // wasm currently doesn't support unwinding
|
||||
fn atomic_waker_panic_safe() {
|
||||
|
@ -54,6 +54,7 @@ mod unix {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn read_buf_initialize_unfilled_to_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -69,6 +70,7 @@ fn read_buf_initialize_unfilled_to_panic_caller() -> Result<(), Box<dyn Error>>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn read_buf_advance_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -84,6 +86,7 @@ fn read_buf_advance_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn read_buf_set_filled_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -99,6 +102,7 @@ fn read_buf_set_filled_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn read_buf_put_slice_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -116,6 +120,7 @@ fn read_buf_put_slice_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn unsplit_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
|
@ -9,6 +9,7 @@ impl Drop for PanicsOnDrop {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[tokio::test]
|
||||
async fn test_panics_do_not_propagate_when_dropping_join_handle() {
|
||||
let join_handle = tokio::spawn(async move { PanicsOnDrop });
|
||||
|
@ -10,6 +10,7 @@ mod support {
|
||||
}
|
||||
use support::panic::test_panic;
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn udp_socket_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
use std::net::SocketAddr;
|
||||
@ -32,6 +33,7 @@ fn udp_socket_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn tcp_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let std_listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
@ -50,6 +52,7 @@ fn tcp_listener_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn tcp_stream_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let std_listener = std::net::TcpListener::bind("127.0.0.1:0").unwrap();
|
||||
@ -163,6 +166,7 @@ fn unix_datagram_from_std_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
#[cfg(windows)]
|
||||
fn server_options_max_instances_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
use tokio::runtime::Runtime;
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn basic_enter() {
|
||||
let rt1 = rt();
|
||||
@ -15,6 +16,7 @@ fn basic_enter() {
|
||||
drop(enter1);
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn interleave_enter_different_rt() {
|
||||
@ -28,6 +30,7 @@ fn interleave_enter_different_rt() {
|
||||
drop(enter2);
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
#[should_panic]
|
||||
fn interleave_enter_same_rt() {
|
||||
@ -41,6 +44,7 @@ fn interleave_enter_same_rt() {
|
||||
drop(enter3);
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
#[cfg(not(target_os = "wasi"))]
|
||||
fn interleave_then_enter() {
|
||||
|
@ -11,6 +11,7 @@ mod support {
|
||||
}
|
||||
use support::panic::test_panic;
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn current_handle_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -23,6 +24,7 @@ fn current_handle_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn into_panic_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(move || {
|
||||
@ -45,6 +47,7 @@ fn into_panic_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -57,6 +60,7 @@ fn builder_worker_threads_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn builder_max_blocking_threads_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
|
@ -12,6 +12,7 @@ mod support {
|
||||
}
|
||||
use support::panic::test_panic;
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn broadcast_channel_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -24,6 +25,7 @@ fn broadcast_channel_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn mutex_blocking_lock_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -40,6 +42,7 @@ fn mutex_blocking_lock_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn oneshot_blocking_recv_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -56,6 +59,7 @@ fn oneshot_blocking_recv_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn rwlock_with_max_readers_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -68,6 +72,7 @@ fn rwlock_with_max_readers_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn rwlock_blocking_read_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -84,6 +89,7 @@ fn rwlock_blocking_read_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn rwlock_blocking_write_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -100,6 +106,7 @@ fn rwlock_blocking_write_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn mpsc_bounded_channel_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -112,6 +119,7 @@ fn mpsc_bounded_channel_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn mpsc_bounded_receiver_blocking_recv_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -128,6 +136,7 @@ fn mpsc_bounded_receiver_blocking_recv_panic_caller() -> Result<(), Box<dyn Erro
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn mpsc_bounded_sender_blocking_send_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -144,6 +153,7 @@ fn mpsc_bounded_sender_blocking_send_panic_caller() -> Result<(), Box<dyn Error>
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn mpsc_unbounded_receiver_blocking_recv_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -160,6 +170,7 @@ fn mpsc_unbounded_receiver_blocking_recv_panic_caller() -> Result<(), Box<dyn Er
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn semaphore_merge_unrelated_owned_permits() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -176,6 +187,7 @@ fn semaphore_merge_unrelated_owned_permits() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn semaphore_merge_unrelated_permits() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
|
@ -289,6 +289,7 @@ async fn unawaited_blocking_task_wakes_paused_runtime() {
|
||||
);
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[cfg(feature = "test-util")]
|
||||
#[tokio::test(start_paused = true)]
|
||||
async fn panicking_blocking_task_wakes_paused_runtime() {
|
||||
|
@ -12,6 +12,7 @@ mod support {
|
||||
}
|
||||
use support::panic::test_panic;
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn block_in_place_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -27,6 +28,7 @@ fn block_in_place_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn local_set_spawn_local_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -41,6 +43,7 @@ fn local_set_spawn_local_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn local_set_block_on_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -58,6 +61,7 @@ fn local_set_block_on_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn spawn_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -70,6 +74,7 @@ fn spawn_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn local_key_sync_scope_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
tokio::task_local! {
|
||||
@ -90,6 +95,7 @@ fn local_key_sync_scope_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn local_key_with_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
tokio::task_local! {
|
||||
@ -106,6 +112,7 @@ fn local_key_with_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn local_key_get_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
tokio::task_local! {
|
||||
|
@ -12,6 +12,7 @@ mod support {
|
||||
}
|
||||
use support::panic::test_panic;
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn pause_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -29,6 +30,7 @@ fn pause_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn resume_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -45,6 +47,7 @@ fn resume_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -57,6 +60,7 @@ fn interval_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn interval_at_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
@ -69,6 +73,7 @@ fn interval_at_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[test]
|
||||
fn timeout_panic_caller() -> Result<(), Box<dyn Error>> {
|
||||
let panic_location_file = test_panic(|| {
|
||||
|
@ -36,6 +36,7 @@ async fn pause_time_in_main_threads() {
|
||||
tokio::time::pause();
|
||||
}
|
||||
|
||||
#[cfg(panic = "unwind")]
|
||||
#[cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support threads
|
||||
#[tokio::test(flavor = "multi_thread", worker_threads = 1)]
|
||||
async fn pause_time_in_spawn_threads() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user