aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-07-18 14:48:25 +0200
committerMicael Karlberg <[email protected]>2019-07-18 14:48:25 +0200
commita0181ae41ba32af16501c8a674ab74a7354f11db (patch)
tree6165a1dbbbb48afc311f2499cf46df4b1b2c9de8 /erts
parent138a6b122934dfd63571afda0f45bf8126c541b6 (diff)
downloadotp-a0181ae41ba32af16501c8a674ab74a7354f11db.tar.gz
otp-a0181ae41ba32af16501c8a674ab74a7354f11db.tar.bz2
otp-a0181ae41ba32af16501c8a674ab74a7354f11db.zip
[esock|test] Some platforms does not accept acceptconn for UDP
Some platforms (for example darwin and OpenBSD) does not accept this option for UDP. Will result in 'enoprotoopt'. So, skip that part of the test case (UDP) if this error occurs. OTP-15904
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/test/socket_SUITE.erl49
1 files changed, 38 insertions, 11 deletions
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl
index babf3a0c45..0a2d3dec4c 100644
--- a/erts/emulator/test/socket_SUITE.erl
+++ b/erts/emulator/test/socket_SUITE.erl
@@ -8419,7 +8419,7 @@ api_opt_sock_acceptconn() ->
end},
#{desc => "[get] verify UDP socket (before bind)",
- cmd => fun(#{sock := Sock} = _State) ->
+ cmd => fun(#{sock := Sock} = State) ->
case Get(Sock) of
{ok, false} ->
?SEV_IPRINT("Expected Success: "
@@ -8429,16 +8429,28 @@ api_opt_sock_acceptconn() ->
?SEV_EPRINT("Unexpected Success: "
"Accepting connections"),
{error, {unexpected_success, {Opt, true}}};
+ {error, enoprotoopt = Reason} ->
+ %% On some platforms this is not accepted
+ %% for UDP, so skip this part (UDP).
+ ?SEV_EPRINT("Expected Failure: "
+ "~p => SKIP UDP", [Reason]),
+ (catch socket:close(Sock)),
+ {ok, State#{sock => skip}};
{error, Reason} = ERROR ->
- ?SEV_EPRINT("Unexpected Failure: ~p", [Reason]),
+ ?SEV_EPRINT("Unexpected Failure: ~p",
+ [Reason]),
ERROR
end
end},
#{desc => "[set] verify UDP socket (before bind)",
- cmd => fun(#{sock := Sock} = _State) ->
+ cmd => fun(#{sock := skip} = _State) ->
+ ?SEV_IPRINT("SKIP'ed"),
+ ok;
+ (#{sock := Sock} = _State) ->
case Set(Sock, true) of
{error, Reason} ->
- ?SEV_IPRINT("Expected Failure: ~p", [Reason]),
+ ?SEV_IPRINT("Expected Failure: ~p",
+ [Reason]),
ok;
ok ->
?SEV_EPRINT("Unexpected Success: "
@@ -8448,7 +8460,10 @@ api_opt_sock_acceptconn() ->
end},
#{desc => "bind UDP socket to local address",
- cmd => fun(#{sock := Sock, local_sa := LSA} = _State) ->
+ cmd => fun(#{sock := skip} = _State) ->
+ ?SEV_IPRINT("SKIP'ed"),
+ ok;
+ (#{sock := Sock, local_sa := LSA} = _State) ->
case socket:bind(Sock, LSA) of
{ok, _} ->
ok;
@@ -8460,7 +8475,10 @@ api_opt_sock_acceptconn() ->
?SEV_SLEEP(?SECS(1)),
#{desc => "[get] verify UDP socket (after bind)",
- cmd => fun(#{sock := Sock} = _State) ->
+ cmd => fun(#{sock := skip} = _State) ->
+ ?SEV_IPRINT("SKIP'ed"),
+ ok;
+ (#{sock := Sock} = _State) ->
case Get(Sock) of
{ok, false} ->
?SEV_IPRINT("Expected Success: "
@@ -8471,15 +8489,20 @@ api_opt_sock_acceptconn() ->
"Accepting connections"),
{error, {unexpected_success, {Opt, true}}};
{error, Reason} = ERROR ->
- ?SEV_EPRINT("Unexpected Failure: ~p", [Reason]),
+ ?SEV_EPRINT("Unexpected Failure: ~p",
+ [Reason]),
ERROR
end
end},
#{desc => "[set] verify UDP socket (after bind)",
- cmd => fun(#{sock := Sock} = _State) ->
+ cmd => fun(#{sock := skip} = _State) ->
+ ?SEV_IPRINT("SKIP'ed"),
+ ok;
+ (#{sock := Sock} = _State) ->
case Set(Sock, true) of
{error, Reason} ->
- ?SEV_IPRINT("Expected Failure: ~p", [Reason]),
+ ?SEV_IPRINT("Expected Failure: ~p",
+ [Reason]),
ok;
ok ->
?SEV_EPRINT("Unexpected Success: "
@@ -8489,7 +8512,10 @@ api_opt_sock_acceptconn() ->
end},
#{desc => "close UDP socket",
- cmd => fun(#{sock := Sock} = State) ->
+ cmd => fun(#{sock := skip} = State) ->
+ ?SEV_IPRINT("SKIP'ed (already closed)"),
+ {ok, maps:remove(sock, State)};
+ (#{sock := Sock} = State) ->
socket:close(Sock),
{ok, maps:remove(sock, State)}
end},
@@ -8518,7 +8544,8 @@ api_opt_sock_acceptconn() ->
"Accepting connections"),
{error, {unexpected_success, {Opt, true}}};
{error, Reason} = ERROR ->
- ?SEV_EPRINT("Unexpected Failure: ~p", [Reason]),
+ ?SEV_EPRINT("Unexpected Failure: ~p",
+ [Reason]),
ERROR
end
end},