Skip to content

Commit

Permalink
[#51] Add watchdog to potentially blocking tests and adjust semantics…
Browse files Browse the repository at this point in the history
… of wait call (was wrong before, corrected but the tests weren't adjusted)
  • Loading branch information
elfenpiff committed Dec 20, 2023
1 parent cd408aa commit 0953e88
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions iceoryx2-pal/concurrency-sync/tests/condition_variable_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn condition_variable_notify_one_unblocks_one() {
while triggered_thread.load(Ordering::Relaxed) < 1 {
spin_loop()
}
true
false
},
|_, _| true,
);
Expand All @@ -61,7 +61,7 @@ fn condition_variable_notify_one_unblocks_one() {
while triggered_thread.load(Ordering::Relaxed) < 2 {
spin_loop()
}
true
false
},
|_, _| true,
);
Expand All @@ -80,7 +80,7 @@ fn condition_variable_notify_one_unblocks_one() {
while triggered_thread.load(Ordering::Relaxed) < 3 {
spin_loop()
}
true
false
},
|_, _| true,
);
Expand Down Expand Up @@ -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();
Expand All @@ -128,7 +129,7 @@ fn condition_variable_notify_all_unblocks_all() {
while triggered_thread.load(Ordering::Relaxed) < 1 {
spin_loop()
}
true
false
},
|_, _| true,
);
Expand Down Expand Up @@ -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();
Expand All @@ -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,
);
Expand Down

0 comments on commit 0953e88

Please sign in to comment.