From c05ae5552609f7036cace09e3a4b54c01082d201 Mon Sep 17 00:00:00 2001 From: Markus Legner Date: Fri, 17 May 2024 11:01:35 +0200 Subject: [PATCH] test: add timeouts to async tests --- crates/scion/src/socket/udp.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/scion/src/socket/udp.rs b/crates/scion/src/socket/udp.rs index eff3488..d44663e 100644 --- a/crates/scion/src/socket/udp.rs +++ b/crates/scion/src/socket/udp.rs @@ -427,12 +427,15 @@ mod tests { } macro_rules! async_test_case { - ($name:ident: $func:ident($($arg:expr),*)) => { + ($name:ident($timeout:expr): $func:ident($($arg:expr),*)) => { #[tokio::test] async fn $name() -> TestResult { - $func($($arg,)*).await + tokio::time::timeout(std::time::Duration::from_secs($timeout),$func($($arg,)*)).await.unwrap() } }; + ($name:ident: $($tail:tt)*) => { + async_test_case!($name(1): $($tail)*); + }; } const MESSAGE: &[u8] = b"Hello World! Hello World! Hello World!";