From 0953e88b4572459235d692ee8d072ecd289d6446 Mon Sep 17 00:00:00 2001 From: Christian Eltzschig Date: Wed, 20 Dec 2023 12:36:25 +0100 Subject: [PATCH] [#51] Add watchdog to potentially blocking tests and adjust semantics of wait call (was wrong before, corrected but the tests weren't adjusted) --- .../tests/condition_variable_tests.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs b/iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs index 1e3f85972..f9c062933 100644 --- a/iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs +++ b/iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs @@ -42,7 +42,7 @@ fn condition_variable_notify_one_unblocks_one() { while triggered_thread.load(Ordering::Relaxed) < 1 { spin_loop() } - true + false }, |_, _| true, ); @@ -61,7 +61,7 @@ fn condition_variable_notify_one_unblocks_one() { while triggered_thread.load(Ordering::Relaxed) < 2 { spin_loop() } - true + false }, |_, _| true, ); @@ -80,7 +80,7 @@ fn condition_variable_notify_one_unblocks_one() { while triggered_thread.load(Ordering::Relaxed) < 3 { spin_loop() } - true + false }, |_, _| true, ); @@ -109,6 +109,7 @@ fn condition_variable_notify_one_unblocks_one() { #[test] fn condition_variable_notify_all_unblocks_all() { const NUMBER_OF_THREADS: u32 = 5; + let _watchdog = Watchdog::new(Duration::from_secs(10)); let barrier = Barrier::new(NUMBER_OF_THREADS + 1); let sut = ConditionVariable::new(); let mtx = Mutex::new(); @@ -128,7 +129,7 @@ fn condition_variable_notify_all_unblocks_all() { while triggered_thread.load(Ordering::Relaxed) < 1 { spin_loop() } - true + false }, |_, _| true, ); @@ -158,6 +159,7 @@ fn condition_variable_notify_all_unblocks_all() { #[test] fn condition_variable_mutex_is_locked_when_wait_returns() { const NUMBER_OF_THREADS: u32 = 5; + let _watchdog = Watchdog::new(Duration::from_secs(10)); let barrier = Barrier::new(NUMBER_OF_THREADS + 1); let sut = ConditionVariable::new(); let mtx = Mutex::new(); @@ -176,7 +178,7 @@ fn condition_variable_mutex_is_locked_when_wait_returns() { while triggered_thread.load(Ordering::Relaxed) < 1 { spin_loop() } - true + false }, |_, _| true, );