mirror of
https://github.com/c-cube/moonpool.git
synced 2025-12-06 03:05:30 -05:00
fix race conditions in tests
This commit is contained in:
parent
d94a197381
commit
101d15f874
5 changed files with 17 additions and 19 deletions
|
|
@ -4,6 +4,7 @@ module Trace = Trace_core
|
|||
|
||||
let spf = Printf.sprintf
|
||||
let ( let@ ) = ( @@ )
|
||||
let lock_stdout = M.Lock.create ()
|
||||
|
||||
let main ~port ~runner ~n ~n_conn () : unit Lwt.t =
|
||||
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "main" in
|
||||
|
|
@ -39,7 +40,9 @@ let main ~port ~runner ~n ~n_conn () : unit Lwt.t =
|
|||
|
||||
(* read back something *)
|
||||
M_lwt.IO_in.really_input ic buf 0 (String.length s);
|
||||
Printf.printf "read: %s\n%!" (Bytes.sub_string buf 0 (String.length s));
|
||||
(let@ () = M.Lock.with_ lock_stdout in
|
||||
Printf.printf "read: %s\n%!"
|
||||
(Bytes.sub_string buf 0 (String.length s)));
|
||||
Trace.exit_manual_span _sp;
|
||||
()
|
||||
done;
|
||||
|
|
@ -50,7 +53,8 @@ let main ~port ~runner ~n ~n_conn () : unit Lwt.t =
|
|||
(* if we're the last to exit, resolve the promise *)
|
||||
let n_already_done = Atomic.fetch_and_add all_done 1 in
|
||||
if n_already_done = n_conn - 1 then (
|
||||
Printf.printf "all done\n%!";
|
||||
(let@ () = M.Lock.with_ lock_stdout in
|
||||
Printf.printf "all done\n%!");
|
||||
M.Fut.fulfill prom_exit @@ Ok ()
|
||||
)
|
||||
)
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ module Str_tbl = Hashtbl.Make (struct
|
|||
end)
|
||||
|
||||
let ( let@ ) = ( @@ )
|
||||
let lock_stdout = M.Lock.create ()
|
||||
|
||||
let main ~port ~runner ~ext ~dir ~n_conn () : unit Lwt.t =
|
||||
let@ _sp = Trace.with_span ~__FILE__ ~__LINE__ "main" in
|
||||
|
|
@ -39,6 +40,7 @@ let main ~port ~runner ~ext ~dir ~n_conn () : unit Lwt.t =
|
|||
let res =
|
||||
M_lwt.run_in_lwt_and_await (fun () -> Lwt_io.read_line ic)
|
||||
in
|
||||
let@ () = M.Lock.with_ lock_stdout in
|
||||
Printf.printf "%s\n%!" res
|
||||
)
|
||||
else if Sys.is_directory file then (
|
||||
|
|
@ -47,7 +49,8 @@ let main ~port ~runner ~ext ~dir ~n_conn () : unit Lwt.t =
|
|||
~data:(fun () -> [ "d", `String file ])
|
||||
in
|
||||
|
||||
Printf.printf "explore %S\n%!" file;
|
||||
(let@ () = M.Lock.with_ lock_stdout in
|
||||
Printf.printf "explore %S\n%!" file);
|
||||
Str_tbl.add seen file ();
|
||||
let d = Sys.readdir file in
|
||||
Array.sort String.compare d;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,8 @@ run echo client -p 1235 -n 10 --n-conn=2 -j=4
|
|||
listening on port 1235
|
||||
all done
|
||||
connecting to port 1235
|
||||
hello 1
|
||||
read: hello 1
|
||||
read: hello 1
|
||||
read: hello 1
|
||||
read: hello 1
|
||||
read: hello 1
|
||||
|
|
@ -101,4 +102,3 @@ read: hello 9
|
|||
read: hello 9
|
||||
read: hello 9
|
||||
read: hello 9
|
||||
read: read: hello 1
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
run hash client -d ../../src --n-conn=2 -j=4 --ext .ml
|
||||
run hash client -p 1234 -d ../../src --n-conn=2 -j=4 --ext .ml
|
||||
listening on port 1234
|
||||
../../src/core/background_thread.ml: 6d5c624dac304cf82ffa6f738516ec9a97aba297
|
||||
../../src/core/background_thread.ml: 6d5c624dac304cf82ffa6f738516ec9a97aba297
|
||||
|
|
@ -82,8 +82,6 @@ listening on port 1234
|
|||
../../src/fib/handle.ml: d3c9c3c2c414372e8ce6cd7eb113955292cdda5e
|
||||
../../src/fib/handle.pp.ml: d3c9c3c2c414372e8ce6cd7eb113955292cdda5e
|
||||
../../src/fib/handle.pp.ml: d3c9c3c2c414372e8ce6cd7eb113955292cdda5e
|
||||
../../src/forkjoin/moonpool_forkjoin.ml: bc38ed5d228a85465bbd4e67d1e1f227d57b5fe3
|
||||
../../src/forkjoin/moonpool_forkjoin.ml: bc38ed5d228a85465bbd4e67d1e1f227d57b5fe3
|
||||
../../src/lwt/IO.ml: 48fae1816121700314aebbdfcca562979dc3ff06
|
||||
../../src/lwt/IO.ml: 48fae1816121700314aebbdfcca562979dc3ff06
|
||||
../../src/lwt/IO_in.ml: 6badd5ffb8fbbdb53f729b93a478bb007f2494f8
|
||||
|
|
@ -165,14 +163,6 @@ explore "../../src/fib/.moonpool_fib.objs/byte"
|
|||
explore "../../src/fib/.moonpool_fib.objs/byte"
|
||||
explore "../../src/fib/.moonpool_fib.objs/native"
|
||||
explore "../../src/fib/.moonpool_fib.objs/native"
|
||||
explore "../../src/forkjoin"
|
||||
explore "../../src/forkjoin"
|
||||
explore "../../src/forkjoin/.merlin-conf"
|
||||
explore "../../src/forkjoin/.merlin-conf"
|
||||
explore "../../src/forkjoin/.moonpool_forkjoin.objs"
|
||||
explore "../../src/forkjoin/.moonpool_forkjoin.objs"
|
||||
explore "../../src/forkjoin/.moonpool_forkjoin.objs/byte"
|
||||
explore "../../src/forkjoin/.moonpool_forkjoin.objs/byte"
|
||||
explore "../../src/lwt"
|
||||
explore "../../src/lwt"
|
||||
explore "../../src/lwt/.merlin-conf"
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
#!/bin/bash
|
||||
|
||||
./hash_server.exe &
|
||||
PORT=1234
|
||||
./hash_server.exe -p $PORT &
|
||||
|
||||
echo "run hash client $@"
|
||||
echo "run hash client -p $PORT $@"
|
||||
|
||||
export LC_LANG=C
|
||||
export LC_ALL=C
|
||||
./hash_client.exe $@ | sort
|
||||
./hash_client.exe -p $PORT $@ | sort
|
||||
|
||||
kill %1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue