Skip to content

Commit 80b751e

Browse files
committed
Retry timeout test a few times
1 parent bae7cb3 commit 80b751e

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

Diff for: test/kcas/test.ml

+9-8
Original file line numberDiff line numberDiff line change
@@ -576,15 +576,16 @@ let test_timeout () =
576576
Domain_local_timeout.set_system (module Thread) (module Unix);
577577

578578
let check (op : ?timeoutf:float -> bool Loc.t -> unit) () =
579-
let x = Loc.make false in
580-
let finally =
581-
Domain_local_timeout.set_timeoutf 0.3 @@ fun () -> Loc.set x true
579+
let rec loop n =
580+
let x = Loc.make false in
581+
let (_ : unit -> unit) =
582+
Domain_local_timeout.set_timeoutf 0.3 @@ fun () -> Loc.set x true
583+
in
584+
match op ~timeoutf:0.01 x with
585+
| () -> if 0 < n then loop (n - 1) else assert false
586+
| exception Timeout.Timeout -> op ~timeoutf:1.0 x
582587
in
583-
Fun.protect ~finally @@ fun () ->
584-
(match op ~timeoutf:0.01 x with
585-
| () -> assert false
586-
| exception Timeout.Timeout -> ());
587-
op ~timeoutf:1.0 x
588+
loop 5
588589
in
589590
run_domains
590591
[

0 commit comments

Comments
 (0)