diff options
author | Micael Karlberg <[email protected]> | 2019-07-16 17:19:12 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-07-17 12:12:38 +0200 |
commit | 96ef9b4a7e97b906a08350e8a7805856b0307cdb (patch) | |
tree | 9b263234e70d28a0ea64b7a4d48164ad2923674a | |
parent | 596d0fd5863ffffb4246814c6f74d75ce68b7791 (diff) | |
download | otp-96ef9b4a7e97b906a08350e8a7805856b0307cdb.tar.gz otp-96ef9b4a7e97b906a08350e8a7805856b0307cdb.tar.bz2 otp-96ef9b4a7e97b906a08350e8a7805856b0307cdb.zip |
[esock|test] Fix broadcast test on FreeBSD
On FreeBSD (for instance) the address "broadcast"
(limited broadcast address = INADDR_BROADCAST)
is not available (=> eaddrnotavail), so that part
of the test is skipped.
OTP-15904
-rw-r--r-- | erts/emulator/test/socket_SUITE.erl | 72 |
1 files changed, 44 insertions, 28 deletions
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl index cbf612948b..ff12ef66a3 100644 --- a/erts/emulator/test/socket_SUITE.erl +++ b/erts/emulator/test/socket_SUITE.erl @@ -9153,6 +9153,11 @@ api_opt_sock_broadcast() -> ?SEV_IPRINT("Expected Success (bound): ~p", [Port]), {ok, State#{sa1 => BSA#{port => Port}}}; + {error, eaddrnotavail = Reason} -> + ?SEV_IPRINT("~p => " + "SKIP limited broadcast test", + [Reason]), + {ok, State#{sa1 => skip}}; {error, Reason} = ERROR -> ?SEV_EPRINT("Unexpected Failure: ~p", [Reason]), @@ -9160,14 +9165,17 @@ api_opt_sock_broadcast() -> end end}, #{desc => "[socket 1] UDP socket sockname", - cmd => fun(#{sock1 := Sock} = _State) -> - case socket:sockname(Sock) of - {ok, SA} -> + cmd => fun(#{sock1 := Sock, sa1 := skip} = _State) -> + ?SEV_IPRINT("SKIP limited broadcast test"), + ok; + (#{sock1 := Sock} = _State) -> + case socket:sockname(Sock) of + {ok, SA} -> ?SEV_IPRINT("SA: ~p", [SA]), - ok; - {error, _} = ERROR -> - ERROR - end + ok; + {error, _} = ERROR -> + ERROR + end end}, ?SEV_SLEEP(?SECS(1)), @@ -9281,17 +9289,17 @@ api_opt_sock_broadcast() -> ERROR end end}, - #{desc => "[socket 3] verify UDP socket (after bind and before set)", + #{desc => "[socket 3] verify UDP socket (after set)", cmd => fun(#{sock3 := Sock} = _State) -> case Get(Sock) of - {ok, false} -> + {ok, true} -> ?SEV_IPRINT("Expected Success: " - "broadcast not allowed"), + "broadcast allowed"), ok; - {ok, true} -> + {ok, false} -> ?SEV_IPRINT("Unexpected Success result: " - "broadcast already allowed"), - ok; + "broadcast not allowed"), + {error, not_allowed}; {error, Reason} = ERROR -> ?SEV_EPRINT("Unexpected Failure: ~p", [Reason]), @@ -9303,23 +9311,31 @@ api_opt_sock_broadcast() -> #{desc => "[socket 3] try send to limited broadcast address", cmd => fun(#{sock3 := Sock, - sa1 := Dest} = _State) -> - Data = list_to_binary("hejsan"), - ?SEV_IPRINT("try send to bradcast address: " - "~n ~p", [Dest]), - case socket:sendto(Sock, Data, Dest) of - ok -> - ?SEV_IPRINT("Expected Success: " - "broadcast message sent"), - ok; - {error, Reason} = ERROR -> - ?SEV_EPRINT("Unexpected Failure: ~p", + sa1 := skip} = _State) -> + ?SEV_IPRINT("SKIP limited broadcast test"), + ok; + (#{sock3 := Sock, + sa1 := Dest} = _State) -> + Data = list_to_binary("hejsan"), + ?SEV_IPRINT("try send to bradcast address: " + "~n ~p", [Dest]), + case socket:sendto(Sock, Data, Dest) of + ok -> + ?SEV_IPRINT("Expected Success: " + "broadcast message sent"), + ok; + {error, Reason} = ERROR -> + ?SEV_EPRINT("Unexpected Failure: ~p", [Reason]), - ERROR - end - end}, + ERROR + end + end}, #{desc => "[socket 1] try recv", - cmd => fun(#{sock1 := Sock} = _State) -> + cmd => fun(#{sock1 := Sock, + sa1 := skip} = _State) -> + ?SEV_IPRINT("SKIP limited broadcast test"), + ok; + (#{sock1 := Sock} = _State) -> case socket:recvfrom(Sock, 0, 5000) of {ok, _} -> ?SEV_IPRINT("Expected Success: " |