Skip to content

Commit

Permalink
Add hard deadline to cancelation test
Browse files Browse the repository at this point in the history
  • Loading branch information
polytypic committed Aug 19, 2024
1 parent d1413c9 commit d46de2b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/test_sync.ml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ let test_mutex_and_condition_cancelation () =
let some_false = Some false in

let deadline = Unix.gettimeofday () +. 60.0 in
let hard_deadline = Unix.gettimeofday () +. 120.0 in

let main i () =
Fun.protect ~finally:(fun () -> Atomic.decr exit) @@ fun () ->
Expand All @@ -145,7 +146,8 @@ let test_mutex_and_condition_cancelation () =
Domain.spawn (fun () ->
let state = Random.State.make_self_init () in
while Atomic.get exit <> 0 do
Domain.cpu_relax ();
if hard_deadline < Unix.gettimeofday () then Stdlib.exit 4
else Domain.cpu_relax ();
let (Packed computation) =
computations.(Random.State.bits state land (n - 1))
in
Expand All @@ -155,7 +157,8 @@ let test_mutex_and_condition_cancelation () =
in
let state = Random.State.make_self_init () in
while Atomic.get exit <> 0 do
Domain.cpu_relax ();
if hard_deadline < Unix.gettimeofday () then Stdlib.exit 3
else Domain.cpu_relax ();
if Random.State.bool state then Condition.broadcast condition
else Condition.signal condition
done;
Expand Down

0 comments on commit d46de2b

Please sign in to comment.