text
stringlengths
0
601k
let ( ) = add " t " ( fun ( ) -> let s1 = " 2005 - 05 - 25 12 : 46 - 4 : 00 " in let s2 = " 2005 - 05 - 25 12 : 46 : 15 - 4 : 00 " in let s3 = " 2005 - 05 - 25 12 : 46 : 15 . 232 - 4 : 00 " in let s4 = " 2005 - 05 - 25 12 : 46 : 15 . 232338 - 4 : 00 " in let time1 = Time . of_string s1 in let time2 = Time . of_string s...
let ( ) = add " Ofday_string_conversion " ( fun ( ) -> let rand_state = Random . State . make [ | 1 ; 2 ; 3 ; 4 ; 5 ; 6 ; 7 ] | in for _ = 0 to 100_000 do let secs = Random . State . int rand_state 86_400_000 in let ofday = Ofday . of_span_since_start_of_day_exn ( Time . Span . of_ms ( float secs ) ) in let ofday_strin...
let ( ) = add " date " ( fun ( ) -> let zone = ( force Time . Zone . local ) in let start = Time . of_date_ofday ~ zone ( Date . create_exn ~ y : 1999 ~ m : Month . Jan ~ d : 1 ) Ofday . start_of_day in let day = Span . of_day 1 . in let number_of_days = match Word_size . word_size with | W64 -> 100_000 | W32 -> 365 * ...
module Old_date_impl = struct let of_tm tm = Date . create_exn ~ y ( : tm . Unix . tm_year + 1900 ) ~ m ( : Month . of_int_exn ( tm . Unix . tm_mon + 1 ) ) ~ d : tm . Unix . tm_mday ; ; let to_tm t = { Unix . tm_sec = 0 ; tm_min = 0 ; tm_hour = 12 ; tm_mday = Date . day t ; tm_mon = Month . to_int ( Date . month t ) - ...
let ( ) = add " day_of_week " ( fun ( ) -> " exhaustive " @? Old_date_impl . exhaustive_day_of_week_test ( ) )
let ( ) = add " add_days " ( fun ( ) -> " one " @? ( Date . add_days ( Date . of_string " 2008 - 11 - 02 " ) 1 = Date . of_string " 2008 - 11 - 03 " ) ; " two " @? ( Date . add_days ( Date . of_string " 2008 - 11 - 02 " ) 2 = Date . of_string " 2008 - 11 - 04 " ) ; " leap " @? ( Date . add_days ( Date . of_string " 200...
let ( ) = add " add_months " ( fun ( ) -> " zero " @? ( Date . add_months ( Date . of_string " 2009 - 02 - 28 " ) 0 = Date . of_string " 2009 - 02 - 28 " ) ; " one " @? ( Date . add_months ( Date . of_string " 2009 - 01 - 30 " ) 1 = Date . of_string " 2009 - 02 - 28 " ) ; " two " @? ( Date . add_months ( Date . of_stri...
let ( ) = add " add_weekdays_rounding_forward " ( fun ( ) -> let test lbl d1 n d2 = lbl @? ( Date . add_weekdays_rounding_forward ( Date . of_string d1 ) n = Date . of_string d2 ) in test " one " " 2009 - 01 - 01 " 1 " 2009 - 01 - 02 " ; test " one_weekend " " 2009 - 01 - 02 " 1 " 2009 - 01 - 05 " ; test " neg_one " " ...
let ( ) = add " add_weekdays_rounding_backward " ( fun ( ) -> let test lbl d1 n d2 = lbl @? ( Date . add_weekdays_rounding_backward ( Date . of_string d1 ) n = Date . of_string d2 ) in test " one " " 2009 - 01 - 01 " 1 " 2009 - 01 - 02 " ; test " one_weekend " " 2009 - 01 - 02 " 1 " 2009 - 01 - 05 " ; test " neg_one " ...
let ( ) = add " add_business_days_rounding_forward " ( fun ( ) -> let test lbl d1 n d2 = let is_holiday d = List . mem ~ equal : Date . equal ( List . map [ " 2009 - 01 - 01 " ; " 2009 - 03 - 01 " ; " 2009 - 03 - 02 " ; ] ~ f : Date . of_string ) d in let res = Date . add_business_days_rounding_forward ~ is_holiday ( D...
let ( ) = add " add_business_days_rounding_backward " ( fun ( ) -> let test lbl d1 n d2 = let is_holiday d = List . mem ~ equal : Date . equal ( List . map [ " 2009 - 01 - 01 " ; " 2009 - 03 - 01 " ; " 2009 - 03 - 02 " ; ] ~ f : Date . of_string ) d in let res = Date . add_business_days_rounding_backward ~ is_holiday (...
let ( ) = add " span_scale " ( fun ( ) -> " ms " @? speq ( Time . Span . scale ( sec 10 . ) 0 . 001 ) ( Time . Span . of_ms 10 . ) ; " min " @? speq ( Time . Span . scale ( sec 10 . ) 60 . ) ( Time . Span . of_min 10 . ) ; " hr " @? speq ( Time . Span . scale ( sec 10 . ) ( 60 . . * 60 . ) ) ( Time . Span . of_hr 10 . ...
let roundtrip s = let t = Span . of_string s in ( " string roundtrip " ^ s ) @? Span . ( ) = t ( Time . Span . of_string ( Time . Span . to_string t ) ) ; ;
let ( ) = let assert_raises f = try f ( ) ; raise Finished with | Finished -> assert false | _ -> ( ) in let extensions = [ " ms " ; " s " ; " m " ; " h " ] in add " roundtrip span <-> string " ( fun ( ) -> List . iter extensions ~ f ( : fun ext -> let t x = roundtrip ( x ^ ext ) in t " 1 " ; t " 5 " ; t " 1 . 34 " ; )...
let test = " time " >::: ! test_list
module Alco = struct let union_empty ( ) = Alcotest . ( check ( list ( pair span_testable span_testable ) ) ) " same list " [ ] ( Time . union [ ] |> Resolver . resolve |> CCResult . get_exn |> CCList . of_seq ) let inter_empty ( ) = Alcotest . ( check ( list ( pair span_testable span_testable ) ) ) " same list " [ ( C...
module Qc = struct let to_of_sexp = QCheck . Test . make ~ count : 100_000 ~ name " : to_of_sexp " time ( fun t -> let t ' = t |> To_sexp . to_sexp |> Of_sexp . of_sexp in Time . equal t t ' ) let union_order_does_not_matter = QCheck . Test . make ~ count : 10 ~ name " : union_order_does_not_matter " QCheck . ( pair ( ...
let remove_1st key list = let rec remove = function [ ] -> [ ] | a :: l -> if a == key then l else a ( :: remove l ) in remove list
let debug_time_travel = ref false
let insert_checkpoint ( { c_time = time } as checkpoint ) = let rec traverse = function [ ] -> [ checkpoint ] | ( ( { c_time = t } as a ) :: l ) as l ' -> if t > time then a ( :: traverse l ) else if t = time then raise Exit else checkpoint :: l ' in checkpoints := traverse ! checkpoints
let remove_checkpoint checkpoint = checkpoints := remove_1st checkpoint ! checkpoints
let wait_for_connection checkpoint = try Exec . unprotect ( function ( ) -> let old_controller = Input_handling . current_controller ! connection in execute_with_other_controller ( function fd -> old_controller fd ; if checkpoint . c_valid = true then exit_main_loop ( ) ) ! connection main_loop ) with Sys . Break -> ch...
let set_current_checkpoint checkpoint = if ! debug_time_travel then prerr_endline ( " Select : " ^ ( Int . to_string checkpoint . c_pid ) ) ; if not checkpoint . c_valid then wait_for_connection checkpoint ; current_checkpoint := checkpoint ; let dead_frags = List . filter ( fun frag -> not ( List . mem frag checkpoint...
let kill_checkpoint checkpoint = if ! debug_time_travel then prerr_endline ( " Kill : " ^ ( Int . to_string checkpoint . c_pid ) ) ; if checkpoint . c_pid > 0 then ( if not checkpoint . c_valid then wait_for_connection checkpoint ; stop checkpoint . c_fd ; if checkpoint . c_parent . c_pid > 0 then wait_child checkpoint...
let cut t = let rec cut_t = function [ ] -> ( [ ] , [ ] ) | ( { c_time = t ' } as a :: l ) as l ' -> if t ' <= t then ( [ ] , l ' ) else let ( b , e ) = cut_t l in ( a :: b , e ) in cut_t
let cut2 t0 t l = let rec cut2_t0 t = function [ ] -> [ ] | l -> let ( after , before ) = cut ( t0 -- t -- _1 ) l in let l = cut2_t0 ( t ++ t ) before in after :: l in let ( after , before ) = cut ( t0 -- _1 ) l in after ( :: cut2_t0 t before )
let chk_merge2 cont = let rec chk_merge2_cont = function [ ] -> cont | [ a ] -> let ( accepted , rejected ) = cont in ( a :: accepted , rejected ) | a :: l -> let ( accepted , rejected ) = chk_merge2_cont l in ( accepted , a :: rejected ) in chk_merge2_cont
let rec chk_merge = function [ ] -> ( [ ] , [ ] ) | l :: tail -> chk_merge2 ( chk_merge tail ) l
let new_checkpoint_list checkpoint_count accepted rejected = if List . length accepted >= checkpoint_count then let ( k , l ) = list_truncate2 checkpoint_count accepted in ( k , l @ rejected ) else let ( k , l ) = list_truncate2 ( checkpoint_count - List . length accepted ) rejected in ( List . merge ( fun { c_time = t...
let clean_checkpoints time checkpoint_count = let ( after , before ) = cut time ! checkpoints in let ( accepted , rejected ) = chk_merge ( cut2 time ! checkpoint_small_step before ) in let ( kept , lost ) = new_checkpoint_list checkpoint_count accepted after in List . iter kill_checkpoint ( lost @ rejected ) ; checkpoi...
let find_checkpoint_before time = let rec find = function [ ] -> print_string " Can ' t go that far in the past " ; ! print_newline ( ) ; if yes_or_no " Reload program " then begin load_program ( ) ; find ! checkpoints end else raise Toplevel | { c_time = t } as a :: l -> if t > time then find l else a in find ! checkp...
let duplicate_current_checkpoint ( ) = let checkpoint = ! current_checkpoint in if not checkpoint . c_valid then wait_for_connection checkpoint ; let new_checkpoint = { c_time = checkpoint . c_time ; c_pid = 0 ; c_fd = checkpoint . c_fd ; c_valid = false ; c_report = checkpoint . c_report ; c_state = C_stopped ; c_pare...
let interrupted = ref false
let last_breakpoint = ref None
let last_debug_info = ref None
let rec do_go_dynlink steps = match do_go steps with | { rep_type = Code_loaded frag ; rep_event_count = steps } as report -> begin match ! last_debug_info with | Some di -> Symbols . add_symbols frag di ; Symbols . set_all_events frag ; last_debug_info := None | None -> assert false end ; if ! break_on_load then repor...
let rec stop_on_event report = match report with { rep_type = Breakpoint ; rep_program_pointer = pc ; rep_stack_pointer = sp } -> last_breakpoint := Some ( pc , sp ) ; Symbols . update_current_event ( ) ; begin match ! current_event with None -> find_event ( ) | Some _ -> ( ) end | { rep_type = Trap_barrier } -> find_e...
let internal_step duration = match current_report ( ) with Some { rep_type = Exited | Uncaught_exc } -> ( ) | _ -> Exec . protect ( function ( ) -> if ! make_checkpoints then duplicate_current_checkpoint ( ) else remove_checkpoint ! current_checkpoint ; update_breakpoints ( ) ; update_trap_barrier ( ) ; ! current_check...
let new_checkpoint pid fd = let new_checkpoint = { c_time = _0 ; c_pid = pid ; c_fd = fd ; c_valid = true ; c_report = None ; c_state = C_stopped ; c_parent = root ; c_breakpoint_version = 0 ; c_breakpoints = [ ] ; c_trap_barrier = 0 ; c_code_fragments = [ 0 ] } in insert_checkpoint new_checkpoint
let set_file_descriptor pid fd = let rec find = function [ ] -> prerr_endline " Unexpected connection " ; close_io fd ; false | ( { c_pid = pid ' } as checkpoint ) :: l -> if pid <> pid ' then find l else ( checkpoint . c_fd <- fd ; checkpoint . c_valid <- true ; true ) in if ! debug_time_travel then prerr_endline ( " ...
let kill_all_checkpoints ( ) = List . iter kill_checkpoint ( ! current_checkpoint ::! checkpoints )
let forget_process fd pid = let checkpoint = List . find ( function c -> c . c_pid = pid ) ( ! current_checkpoint ::! checkpoints ) in if pid > 0 then begin Printf . eprintf " Lost connection with process % d " pid ; let kont = if checkpoint == ! current_checkpoint then begin Printf . eprintf " ( active process ) \ n "...
let recover ( ) = set_current_checkpoint ( find_checkpoint_before ( current_time ( ) ) )
let rec step_forward duration = if duration > ! checkpoint_small_step then begin let first_step = if duration > ! checkpoint_big_step then ! checkpoint_big_step else ! checkpoint_small_step in internal_step first_step ; if not ! interrupted then step_forward ( duration -- first_step ) end else if duration != _0 then in...
let internal_go_to time = let duration = time -- ( current_time ( ) ) in if duration > _0 then execute_without_breakpoints ( function ( ) -> step_forward duration )
let go_to time = let checkpoint = find_checkpoint_before time in set_current_checkpoint checkpoint ; internal_go_to time
let find_last_breakpoint max_time = let rec find break = let time = current_time ( ) in step_forward ( max_time -- time ) ; match ! last_breakpoint , ! temporary_breakpoint_position with ( Some _ , _ ) when current_time ( ) < max_time -> find ! last_breakpoint | ( Some ( pc , _ ) , Some pc ' ) when pc = pc ' -> ( max_t...
let rec back_to time time_max = let { c_time = t } = find_checkpoint_before ( pre64 time_max ) in go_to ( max time t ) ; let ( new_time , break ) = find_last_breakpoint time_max in if break <> None || ( new_time <= time ) then begin go_to new_time ; interrupted := break <> None ; last_breakpoint := break end else back_...
let step_backward duration = let time = current_time ( ) in if time > _0 then back_to ( max _0 ( time -- duration ) ) time
let rec run ( ) = internal_step ! checkpoint_big_step ; if not ! interrupted then run ( )
let back_run ( ) = if current_time ( ) > _0 then back_to _0 ( current_time ( ) )
let step duration = if duration >= _0 then step_forward duration else step_backward ( _0 -- duration )
let finish ( ) = Symbols . update_current_event ( ) ; match ! current_event with None -> prerr_endline " ` finish ' not meaningful in outermost frame . " ; raise Toplevel | Some { ev_ev { = ev_stacksize } } -> set_initial_frame ( ) ; let ( frame , pc ) = up_frame ev_stacksize in if frame < 0 then begin prerr_endline " ...
let next_1 ( ) = Symbols . update_current_event ( ) ; match ! current_event with None -> step _1 | Some { ev_ev { = ev_stacksize = ev_stacksize1 } } -> let ( frame1 , _pc1 ) = initial_frame ( ) in step _1 ; if not ! interrupted then begin Symbols . update_current_event ( ) ; match ! current_event with None -> ( ) | Som...
let rec next = function 0 -> ( ) | n -> next_1 ( ) ; if not ! interrupted then next ( n - 1 )
let start ( ) = Symbols . update_current_event ( ) ; match ! current_event with None -> prerr_endline " ` start not meaningful in outermost frame . " ; raise Toplevel | Some { ev_ev { = ev_stacksize } } -> let ( frame , _ ) = initial_frame ( ) in let ( frame ' , pc ) = up_frame ev_stacksize in if frame ' < 0 then begin...
let previous_1 ( ) = Symbols . update_current_event ( ) ; match ! current_event with None -> step _minus1 | Some { ev_ev { = ev_stacksize = ev_stacksize1 } } -> let ( frame1 , _pc1 ) = initial_frame ( ) in step _minus1 ; if not ! interrupted then begin Symbols . update_current_event ( ) ; match ! current_event with Non...
let rec previous = function 0 -> ( ) | n -> previous_1 ( ) ; if not ! interrupted then previous ( n - 1 )
type record = { recorded_offsets : int array ; table : table ; }
type typ = | Backed of string | Offset_only of int
type t = { typ : typ ; record : record ; }
type ' a local_result = [ ` None | ` Single of ' a | ` Ambiguous of ' a * ' a ]
let recorded_offsets ( t : t ) : int list = Array . to_list t . record . recorded_offsets |> List . sort_uniq compare
let check_table ( ( starts , entries ) : table ) : bool = let size = Bigarray . Array1 . dim starts in assert ( size = Array . length entries ) ; let has_no_dup = let seen = ref Int64_set . empty in let has_no_dup = ref true in let i = ref 0 in while ! has_no_dup && ! i < size do let start = starts . { ! i } in if Int6...
let process_table ( ( starts , entries ) : table ) : record = let size = Bigarray . Array1 . dim starts in assert ( size = Array . length entries ) ; if size = 0 then failwith " Time zone record table is empty " else let starts , entries = let first_start = starts . { 0 } in let first_entry = entries . ( 0 ) in if Span...
let name t = match t . typ with | Backed name -> name | Offset_only s -> let dur = Span . ( make_small ~ s ( ) |> For_human ' . view ) in if dur . hours = 0 && dur . minutes = 0 then " UTC " else Printf . sprintf " UTC % c % 02d :% 02d " ( match dur . sign with ` Pos -> ' ' + | ` Neg -> ' ' ) - dur . hours dur . minute...
let to_fixed_offset_from_utc t = match t . typ with | Backed _ -> None | Offset_only s -> Some ( Span . make_small ~ s ( ) )
let fixed_offset_name_parser = let open MParser in let open Parser_components in string " UTC " >> ( attempt ( char ' ' + >> return ` Pos <|> ( char ' ' - >> return ` Neg ) >>= fun sign -> attempt ( max_two_digit_nat_zero >>= fun hour -> char ' ' : >> max_two_digit_nat_zero << eof >>= fun minute -> return ( hour , minu...
let fixed_offset_of_name ( s : string ) : Span . t option = match Parser_components . result_of_mparser_result @@ MParser . ( parse_string ( fixed_offset_name_parser << eof ) ) s ( ) with | Ok x -> Some x | Error _ -> None
let equal t1 t2 = ( match ( t1 . typ , t2 . typ ) with | Backed name1 , Backed name2 -> CCString . equal name1 name2 | Offset_only s1 , Offset_only s2 -> CCInt . equal s1 s2 | Backed name , Offset_only offset | Offset_only offset , Backed name -> ( match fixed_offset_of_name name with | Some offset ' -> offset = CCInt6...
let one_day = Span . For_human ' . ( make_exn ~ days : 1 ( ) )
let make_offset_only ( offset : Span . t ) = if Span . abs offset > one_day then None else let offset = CCInt64 . to_int @@ Span . get_s offset in Some { typ = Offset_only offset ; record = process_table ( Bigarray . Array1 . of_array Bigarray . Int64 Bigarray . C_layout [ | Span . get_s Constants . timestamp_min ] , |...
let make_offset_only_exn offset = match make_offset_only offset with | None -> invalid_arg " make_offset_only_span_exn " | Some x -> x
let utc : t = CCOption . get_exn_or " Expected successful construction of UTC " ( make_offset_only Span . zero )
let bsearch_table timestamp ( ( starts , _ ) : table ) = Bigarray_utils . bsearch ~ cmp : Int64 . compare timestamp starts
let lookup_timestamp_utc ( t : t ) timestamp = let table = t . record . table in let entries = snd table in match bsearch_table timestamp table with | ` At i -> Some entries . ( i ) | ` All_lower -> Some entries . ( Array . length entries - 1 ) | ` All_bigger -> None | ` Just_after i -> Some entries . ( i ) | ` Empty -...
let local_interval_of_table ( ( starts , entries ) : table ) ( i : int ) = let size = Bigarray . Array1 . dim starts in let start_utc = starts . { i } in let entry = entries . ( i ) in let end_exc_utc = if i = size - 1 then Span . get_s Constants . timestamp_max else starts . { i + 1 } in ( Int64 . add start_utc ( Int6...
let interval_mem ( t : int64 ) ( ( x , y ) : int64 * int64 ) = x <= t && t < y
let lookup_timestamp_local ( t : t ) timestamp : entry local_result = let table = t . record . table in let starts , entries = table in let size = Bigarray . Array1 . dim starts in let index = match bsearch_table timestamp table with | ` At i -> Some i | ` All_lower -> Some ( size - 1 ) | ` All_bigger -> Some 0 | ` Jus...
module Raw = struct let to_transition_seq ( t : t ) : ( ( int64 * int64 ) * entry ) Seq . t = let table = t . record . table in let starts , entries = table in let size = Bigarray . Array1 . dim starts in let rec aux s = match s ( ) with | Seq . Nil -> Seq . empty | Seq . Cons ( ( k1 , entry1 ) , s ) -> ( match s ( ) w...
let offset_is_recorded offset ( t : t ) = Array . mem ( CCInt64 . to_int @@ Span . get_s offset ) t . record . recorded_offsets
module Compressed_table = struct type relative_entry = { value : int64 ; is_abs : bool ; is_dst : bool ; offset : int ; } let lt_relative_entry ( x : relative_entry ) ( y : relative_entry ) = if x . value < y . value then true else if x . is_abs && not y . is_abs then true else if x . is_dst && not y . is_dst then true...
module Compressed = struct let add_to_buffer ( buffer : Buffer . t ) ( t : t ) : unit = let name = name t in let name_len = String . length name in assert ( name_len <= 0xFF ) ; Buffer . add_uint8 buffer name_len ; Buffer . add_string buffer name ; Compressed_table . add_to_buffer buffer t . record . table let to_strin...
module Sexp = struct let of_sexp ( x : CCSexp . t ) : t option = let open Of_sexp_utils in try match x with | ` List l -> ( match l with | ` Atom " tz " :: ` Atom name :: transitions -> transitions |> List . map ( fun x -> match x with | ` List [ start ; ` List [ ` Atom is_dst ; offset ] ] -> let start = int64_of_sexp ...
module JSON = struct let of_json json : t option = let exception Invalid_data in try match json with | ` Assoc l -> let name = match List . assoc " name " l with | ` String s -> s | _ -> raise Invalid_data in let table_rows = match List . assoc " table " l with | ` List l -> l | _ -> raise Invalid_data in table_rows |>...
module Db = struct type db = table M . t let empty = M . empty let add tz db = M . add ( name tz ) tz . record . table db let find_opt name db = M . find_opt name db |> CCOption . map ( fun table -> Raw . of_table_exn ~ name table ) let remove name db = M . remove name db let add_seq db s : db = Seq . fold_left ( fun d...
let db : table M . t ref = match db with | Some db -> ref db | None -> ref M . empty
let compressed : string M . t = match compressed with | Some s -> Marshal . from_string s 0 | None -> M . empty
let lookup_record name : record option = match M . find_opt name ! db with | Some table -> assert ( check_table table ) ; Some ( process_table table ) | None -> match M . find_opt name compressed with | Some compressed_table -> let table = Compressed_table . of_string_exn compressed_table in assert ( check_table table ...
let make name : t option = match fixed_offset_of_name name with | Some fixed -> make_offset_only fixed | None -> ( match lookup_record name with | Some record -> Some { typ = Backed name ; record } | None -> None )
let make_exn name : t = match make name with Some x -> x | None -> invalid_arg " make_exn "
let available_time_zones = let s0 = M . to_seq ! db |> Seq . map fst |> String_set . of_seq in let s1 = M . to_seq compressed |> Seq . map fst |> String_set . of_seq in String_set . ( union s0 s1 |> to_list )
let local ( ) : t option = match Timedesc_tzlocal . local ( ) with | [ ] -> None | l -> List . fold_left ( fun tz name -> match tz with Some tz -> Some tz | None -> make name ) None l
let local_exn ( ) : t = match local ( ) with | None -> invalid_arg " local_exn : Could not determine the local timezone " | Some x -> x
let startup = timer_ticks ( )
let at n = Int64 . ( add startup ( mul ( of_int step ) ( of_int n ) ) )
let check_after n = let late = Int64 . sub ( timer_ticks ( ) ) ( at n ) in if late < Int64 . zero then failwith ( " Early by " ^ ( Int64 . ( to_string ( neg ( div late ( of_int 1_000_000 ) ) ) ) ) ^ " ms " )
let check_before n = let late = Int64 . sub ( timer_ticks ( ) ) ( at n ) in if late > Int64 . zero then failwith ( " Late by " ^ ( Int64 . ( to_string ( ( div late ( of_int 1_000_000 ) ) ) ) ) ^ " ms " )
let flag = Atomic . make false
let d1 ( ) = critical_section ( fun ( ) -> let r = wait_until ( at ( - 1 ) ) in assert ( r = Timeout ) ) ; check_before 1 ; critical_section ( fun ( ) -> let r = wait_until ( at 1 ) in assert ( r = Timeout ) ) ; check_after 1 ; check_before 2 ; critical_section ( fun ( ) -> let r = wait_for ( Int64 . of_int ( - step ) ...