Repository navigation
Test on OS X, Ubuntu, OCaml 4.01-4.03 in Travis. - #240
Conversation
|
Is it usable with MacPorts in Travis? Also, AFAIK, depext is not (yet) so commonly used, so I put some value on testing a build/install process that doesn't use it. |
|
depext is optional, for the rest, read the travis/appveyor readme. |
|
I believe the script and the |
|
@nojb ideas for resolving this failure, besides assigning different ports to each test case or introducing delays? https://travis-ci.org/ocsigen/lwt/jobs/128587022#L448 Occurs sporadically on both Linux and OS X. |
|
Hi sorry for the delay - will get back after I take a look today . |
|
I don't manage to reproduce this locally. Any ideas/guess what could be the reason ? It looks like setting |
|
Hi @aantron, I reworked the tests to make them more deterministic. Could you apply the diff below and check to see if the issue persists ? Thanks! diff --git a/tests/unix/test_mcast.ml b/tests/unix/test_mcast.ml
index 184c95e..cc40699 100644
--- a/tests/unix/test_mcast.ml
+++ b/tests/unix/test_mcast.ml
@@ -23,21 +23,19 @@
open Lwt.Infix
open Test
+let debug = false
let hello = Bytes.unsafe_of_string "Hello, World!"
let mcast_addr = "225.0.0.1"
let mcast_port = 4321
-let with_fd f =
- let fd = Lwt_unix.(socket PF_INET SOCK_DGRAM 0) in
- Lwt.finalize (fun () -> f fd) (fun () -> Lwt_unix.close fd)
-
let child join fd =
(* Lwt_unix.setsockopt fd Lwt_unix.SO_REUSEADDR true; *)
Lwt_unix.(bind fd (ADDR_INET (Unix.inet_addr_any, mcast_port)));
if join then Lwt_unix.mcast_add_membership fd (Unix.inet_addr_of_string mcast_addr);
let buf = Bytes.create 50 in
- Lwt_unix.read fd buf 0 50 >>= fun n ->
- (* Printf.printf "\nReceived multicast message %S\n%!" (Bytes.unsafe_to_string (Bytes.sub buf 0 n)); *)
+ Lwt_unix.with_timeout 0.1 (fun () -> Lwt_unix.read fd buf 0 (Bytes.length buf)) >>= fun n ->
+ if debug then
+ Printf.printf "\nReceived multicast message %S\n%!" (Bytes.unsafe_to_string (Bytes.sub buf 0 n));
if Bytes.sub buf 0 n <> hello then
Lwt.fail (Failure "unexpected multicast message")
else
@@ -45,26 +43,33 @@ let child join fd =
let parent set_loop fd =
Lwt_unix.mcast_set_loop fd set_loop;
- let rec loop () =
- Lwt_unix.(sendto fd hello 0 (Bytes.length hello) []
- (ADDR_INET (Unix.inet_addr_of_string mcast_addr, mcast_port))) >>= fun _ ->
- (* Printf.printf "\nSending multicast message %S to %s:%d\n%!" (Bytes.unsafe_to_string hello) *)
- (* mcast_addr mcast_port; *)
- Lwt_unix.sleep 0.2 >>= loop
- in
- loop ()
+ let addr = Lwt_unix.ADDR_INET (Unix.inet_addr_of_string mcast_addr, mcast_port) in
+ Lwt_unix.sendto fd hello 0 (Bytes.length hello) [] addr >>= fun _ ->
+ if debug then
+ Printf.printf "\nSending multicast message %S to %s:%d\n%!" (Bytes.unsafe_to_string hello)
+ mcast_addr mcast_port;
+ Lwt.return_unit
let test_mcast join set_loop =
let should_timeout = not join || not set_loop in
- let t = Lwt_unix.with_timeout 0.5 (fun () -> Lwt.pick [ with_fd (child join); with_fd (parent set_loop) ]) in
- Lwt.catch (fun () -> t >>= fun x -> Lwt.return (`Ok x)) (fun e -> Lwt.return (`Fail e)) >>= function
- | `Fail Lwt_unix.Timeout ->
- Lwt.return should_timeout
- | `Fail e ->
- Printf.eprintf "\ntest_mcast: unexpected failure: %S\n%!" (Printexc.to_string e);
- Lwt.return false
- | `Ok () ->
- Lwt.return true
+ let fd1 = Lwt_unix.(socket PF_INET SOCK_DGRAM 0) in
+ let fd2 = Lwt_unix.(socket PF_INET SOCK_DGRAM 0) in
+ let t () =
+ Lwt.catch
+ (fun () ->
+ let t1 = child join fd1 in
+ let t2 = parent set_loop fd2 in
+ Lwt.join [t1; t2] >>= fun () -> Lwt.return true
+ )
+ (function
+ | Lwt_unix.Timeout ->
+ Lwt.return should_timeout
+ | e ->
+ Printf.eprintf "\ntest_mcast: unexpected failure: %S\n%!" (Printexc.to_string e);
+ Lwt.return false
+ )
+ in
+ Lwt.finalize t (fun () -> Lwt.join [Lwt_unix.close fd1; Lwt_unix.close fd2])
let suite =
suite "unix_mcast" |
|
Thanks! I turned your diff into a commit – hope that is okay. I also hadn't been able to reproduce it locally. If this fails, I will restore the |
|
Okay, looks like your patch did it. Thanks again! |
No description provided.