From c94e95482643fde42cb1a017a2bafc895381253a Mon Sep 17 00:00:00 2001 From: ComanderP <8596680+ComanderP@users.noreply.github.com> Date: Thu, 9 May 2024 23:05:41 +0200 Subject: [PATCH] Add simple eio send_all/receive_all test --- zmq-eio/test/test.ml | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/zmq-eio/test/test.ml b/zmq-eio/test/test.ml index b9e7253..292109e 100644 --- a/zmq-eio/test/test.ml +++ b/zmq-eio/test/test.ml @@ -38,6 +38,16 @@ let send env ?(delay = 0.0) s count = in fun () -> inner count +let send_all env ?(delay = 0.0) s count = + let rec inner = function + | 0 -> () + | n -> + Zmq_eio.Socket.send_all s ["test1"; "test2"; "test3"]; + sleepf env delay; + inner (n - 1) + in + fun () -> inner count + let recv env ?(delay = 0.0) s count = let rec inner = function | 0 -> () @@ -48,6 +58,16 @@ let recv env ?(delay = 0.0) s count = in fun () -> inner count +let recv_all env ?(delay = 0.0) s count = + let rec inner = function + | 0 -> () + | n -> + let _ = Zmq_eio.Socket.recv_all s in + sleepf env delay; + inner (n - 1) + in + fun () -> inner count + (** Test functions *) let test_setup_teardown ~sw:_ _env _s = () @@ -59,6 +79,12 @@ let test_send_receive ~sw:_ env (_, s1, s2) = recv env s1 count; ] +let test_send_receive_all ~sw:_ env (_, s1, s2) = + all_ok [ + send_all env s2 count; + recv_all env s1 count; + ] + let test_msend_mreceive ~sw:_ env (_, s1, s2) = all_ok [ send env s2 count; send env s2 count; send env s2 count; send env s2 count; @@ -124,15 +150,15 @@ let suite () = in __MODULE__ >::: [ - "test_setup_teardown" >:: bracket test_setup_teardown; - "test_send_receive" >:: bracket test_send_receive; - "test_msend_mreceive" >:: bracket test_msend_mreceive; - "test_mix" >:: bracket test_mix; - "test_slow_send" >:: bracket test_slow_send; - "test_slow_receive" >:: bracket test_slow_receive; - "test_slow_mix" >:: bracket test_slow_mix1; - "test_slow_mix" >:: bracket test_slow_mix2; - "test_send_receive" >:: bracket test_send_receive; + "test_setup_teardown" >:: bracket test_setup_teardown; + "test_send_receive" >:: bracket test_send_receive; + "test_msend_mreceive" >:: bracket test_msend_mreceive; + "test_mix" >:: bracket test_mix; + "test_slow_send" >:: bracket test_slow_send; + "test_slow_receive" >:: bracket test_slow_receive; + "test_slow_mix" >:: bracket test_slow_mix1; + "test_slow_mix" >:: bracket test_slow_mix2; + "test_send_receive_all" >:: bracket test_send_receive_all; ]