Skip to content

Commit d46de2b

Browse files
committed
Add hard deadline to cancelation test
1 parent d1413c9 commit d46de2b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/test_sync.ml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ let test_mutex_and_condition_cancelation () =
127127
let some_false = Some false in
128128

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

131132
let main i () =
132133
Fun.protect ~finally:(fun () -> Atomic.decr exit) @@ fun () ->
@@ -145,7 +146,8 @@ let test_mutex_and_condition_cancelation () =
145146
Domain.spawn (fun () ->
146147
let state = Random.State.make_self_init () in
147148
while Atomic.get exit <> 0 do
148-
Domain.cpu_relax ();
149+
if hard_deadline < Unix.gettimeofday () then Stdlib.exit 4
150+
else Domain.cpu_relax ();
149151
let (Packed computation) =
150152
computations.(Random.State.bits state land (n - 1))
151153
in
@@ -155,7 +157,8 @@ let test_mutex_and_condition_cancelation () =
155157
in
156158
let state = Random.State.make_self_init () in
157159
while Atomic.get exit <> 0 do
158-
Domain.cpu_relax ();
160+
if hard_deadline < Unix.gettimeofday () then Stdlib.exit 3
161+
else Domain.cpu_relax ();
159162
if Random.State.bool state then Condition.broadcast condition
160163
else Condition.signal condition
161164
done;

0 commit comments

Comments
 (0)