aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-12-21 16:04:06 +0100
committerMicael Karlberg <[email protected]>2018-12-21 16:04:06 +0100
commit103a19f7dbfc05487bf5dac1ed254752e79dfe8e (patch)
treec963596c9f28fbe13fd3893fd87416f4273b2c87
parent6a0772d1af0cd36915736ff65a450a618209fec1 (diff)
parent5cb57ba153b9febfca17f90166791e104262615e (diff)
downloadotp-103a19f7dbfc05487bf5dac1ed254752e79dfe8e.tar.gz
otp-103a19f7dbfc05487bf5dac1ed254752e79dfe8e.tar.bz2
otp-103a19f7dbfc05487bf5dac1ed254752e79dfe8e.zip
Merge branch 'bmk/20181219/nififying_inet_openbsd63/OTP-14831' into bmk/20180918/nififying_inet/OTP-14831
-rw-r--r--.gitignore1
-rw-r--r--erts/emulator/nifs/common/socket_nif.c6
-rw-r--r--erts/emulator/test/socket_SUITE.erl69
-rw-r--r--erts/emulator/test/socket_test_evaluator.erl14
-rw-r--r--lib/erl_interface/src/Makefile.in2
5 files changed, 76 insertions, 16 deletions
diff --git a/.gitignore b/.gitignore
index 4bd743f83a..daeff7ad22 100644
--- a/.gitignore
+++ b/.gitignore
@@ -38,6 +38,7 @@ sparc-sun-solaris[0-9]*.[0-9]*
i386-pc-solaris[0-9]*.[0-9]*
i386-unknown-freebsd[0-9]*.[0-9]*
x86_64-unknown-freebsd[0-9]*.[0-9]*
+x86_64-unknown-openbsd[0-9]*.[0-9]*
tile-tilera-linux-gnu
powerpc-unknown-linux-gnu
aarch64-unknown-linux-gnu
diff --git a/erts/emulator/nifs/common/socket_nif.c b/erts/emulator/nifs/common/socket_nif.c
index 80903c487f..6dcd4ae623 100644
--- a/erts/emulator/nifs/common/socket_nif.c
+++ b/erts/emulator/nifs/common/socket_nif.c
@@ -15198,9 +15198,11 @@ char* encode_cmsghdr_data_ip(ErlNifEnv* env,
case IPTOS_RELIABILITY:
*eCMsgHdrData = esock_atom_reliability;
break;
+#if defined(IPTOS_MINCOST)
case IPTOS_MINCOST:
*eCMsgHdrData = esock_atom_mincost;
break;
+#endif
default:
*eCMsgHdrData = MKUI(env, tos);
break;
@@ -15467,9 +15469,11 @@ BOOLEAN_T decode_ip_tos(ErlNifEnv* env, ERL_NIF_TERM eVal, int* val)
} else if (COMPARE(eVal, esock_atom_reliability) == 0) {
*val = IPTOS_RELIABILITY;
result = TRUE;
+#if defined(IPTOS_MINCOST)
} else if (COMPARE(eVal, esock_atom_mincost) == 0) {
*val = IPTOS_MINCOST;
result = TRUE;
+#endif
} else {
*val = -1;
result = FALSE;
@@ -15781,9 +15785,11 @@ ERL_NIF_TERM encode_ip_tos(ErlNifEnv* env, int val)
result = esock_make_ok2(env, esock_atom_reliability);
break;
+#if defined(IPTOS_MINCOST)
case IPTOS_MINCOST:
result = esock_make_ok2(env, esock_atom_mincost);
break;
+#endif
default:
result = esock_make_ok2(env, MKI(env, val));
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl
index 9ad15f06dc..3adda52e1e 100644
--- a/erts/emulator/test/socket_SUITE.erl
+++ b/erts/emulator/test/socket_SUITE.erl
@@ -18,7 +18,14 @@
%% %CopyrightEnd%
%%
+%% Run the entire test suite:
%% ts:run(emulator, socket_SUITE, [batch]).
+%%
+%% Run a specific group:
+%% ts:run(emulator, socket_SUITE, {group, foo}, [batch]).
+%%
+%% Run a specific test case:
+%% ts:run(emulator, socket_SUITE, foo, [batch]).
-module(socket_SUITE).
@@ -433,9 +440,9 @@
-define(TPP_MEDIUM, lists:flatten(lists:duplicate(1024, ?TPP_SMALL))).
-define(TPP_LARGE, lists:flatten(lists:duplicate(1024, ?TPP_MEDIUM))).
--define(TPP_SMALL_NUM, 100000).
--define(TPP_MEDIUM_NUM, 100000).
--define(TPP_LARGE_NUM, 1000).
+-define(TPP_SMALL_NUM, 10000).
+-define(TPP_MEDIUM_NUM, 1000).
+-define(TPP_LARGE_NUM, 100).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -1444,11 +1451,20 @@ api_b_open_and_close(InitState) ->
end},
#{desc => "get protocol",
cmd => fun(#{socket := Sock} = State) ->
- Res = socket:getopt(Sock, socket, protocol),
- {ok, {State, Res}}
+ case socket:supports(options, socket, protocol) of
+ true ->
+ Res = socket:getopt(Sock, socket, protocol),
+ {ok, {State, Res}};
+ false ->
+ {ok, {State, not_supported}}
+ end
end},
#{desc => "validate protocol",
- cmd => fun({#{protocol := Protocol} = State, {ok, Protocol}}) ->
+ cmd => fun({State, not_supported}) ->
+ ?SEV_IPRINT("socket option 'protocol' "
+ "not supported"),
+ {ok, State};
+ ({#{protocol := Protocol} = State, {ok, Protocol}}) ->
{ok, State};
({#{protocol := ExpProtocol}, {ok, Protocol}}) ->
{error, {unexpected_type, ExpProtocol, Protocol}};
@@ -2727,6 +2743,7 @@ api_to_connect_tcp(InitState) ->
end},
#{desc => "create node",
cmd => fun(#{host := Host} = State) ->
+ ?SEV_IPRINT("try create node on ~p", [Host]),
case start_node(Host, client) of
{ok, Node} ->
?SEV_IPRINT("client node ~p started",
@@ -9466,14 +9483,34 @@ traffic_ping_pong_sendmsg_and_recvmsg_tcp(InitState) ->
traffic_ping_pong_send_and_receive_tcp(#{msg := Msg} = InitState) ->
Fun = fun(Sock) ->
{ok, RcvSz} = socket:getopt(Sock, socket, rcvbuf),
+ ?SEV_IPRINT("RcvBuf is ~p (needs atleast ~p)",
+ [RcvSz, 16+size(Msg)]),
if (RcvSz < size(Msg)) ->
- ok = socket:setopt(Sock, socket, rcvbuf, 1024+size(Msg));
+ case socket:setopt(Sock,
+ socket, rcvbuf, 1024+size(Msg)) of
+ ok ->
+ ok;
+ {error, enobufs} ->
+ skip({failed_change, rcvbuf});
+ {error, Reason1} ->
+ ?FAIL({rcvbuf, Reason1})
+ end;
true ->
ok
end,
{ok, SndSz} = socket:getopt(Sock, socket, sndbuf),
+ ?SEV_IPRINT("SndBuf is ~p (needs atleast ~p)",
+ [SndSz, 16+size(Msg)]),
if (SndSz < size(Msg)) ->
- ok = socket:setopt(Sock, socket, sndbuf, 1024+size(Msg));
+ case socket:setopt(Sock,
+ socket, sndbuf, 1024+size(Msg)) of
+ ok ->
+ ok;
+ {error, enobufs} ->
+ skip({failed_change, sndbuf});
+ {error, Reason2} ->
+ ?FAIL({sndbuf, Reason2})
+ end;
true ->
ok
end,
@@ -9915,7 +9952,7 @@ traffic_ping_pong_send_and_receive_tcp2(InitState) ->
Result2 = erlang:delete_element(1, Result),
{ok, State#{server_result => Result2}};
{ok, BadResult} ->
- ?SEV_EPRINT("bad sever result: "
+ ?SEV_EPRINT("bad server result: "
"~n ~p", [BadResult]),
{error, {invalid_server_result, BadResult}};
{error, _} = ERROR ->
@@ -10157,10 +10194,10 @@ tpp_tcp_client_await_continue(Parent, Slogan) ->
?SEV_IPRINT("await continue (~p)", [Slogan]),
case ?SEV_AWAIT_CONTINUE(Parent, parent, Slogan) of
ok ->
- %% ?SEV_IPRINT("continue (~p): ok", [Slogan]),
+ ?SEV_IPRINT("continue (~p): ok", [Slogan]),
ok;
{ok, Data} ->
- %% ?SEV_IPRINT("continue (~p): ok with data", [Slogan]),
+ ?SEV_IPRINT("continue (~p): ok with data", [Slogan]),
Data;
{error, Reason} ->
?SEV_EPRINT("continue (~p): error"
@@ -16517,7 +16554,11 @@ sock_close(Sock) ->
local_host() ->
try net_adm:localhost() of
Host when is_list(Host) ->
- list_to_atom(Host)
+ %% Convert to shortname if long
+ case string:tokens(Host, [$.]) of
+ [H|_] ->
+ list_to_atom(H)
+ end
catch
C:E:S ->
erlang:raise(C, E, S)
@@ -16537,7 +16578,9 @@ which_local_addr(Domain) ->
which_addr(_Domain, []) ->
?FAIL(no_address);
-which_addr(Domain, [{Name, IFO}|_IFL]) when (Name =/= "lo") ->
+which_addr(Domain, [{"lo" ++ _, _}|IFL]) ->
+ which_addr(Domain, IFL);
+which_addr(Domain, [{_Name, IFO}|_IFL]) ->
which_addr2(Domain, IFO);
which_addr(Domain, [_|IFL]) ->
which_addr(Domain, IFL).
diff --git a/erts/emulator/test/socket_test_evaluator.erl b/erts/emulator/test/socket_test_evaluator.erl
index deea7e5d36..fe6a6ff70a 100644
--- a/erts/emulator/test/socket_test_evaluator.erl
+++ b/erts/emulator/test/socket_test_evaluator.erl
@@ -130,6 +130,10 @@ loop(ID, [#{desc := Desc,
"~n Reason: ~p", [ID, Reason]),
exit({command_failed, ID, Reason, State})
catch
+ throw:{skip, R} = E:_ ->
+ eprint("command ~w skip: "
+ "~n Skip Reason: ~p", [ID, R]),
+ exit(E);
C:E:S ->
eprint("command ~w crashed: "
"~n Class: ~p"
@@ -150,6 +154,8 @@ await_finish(Evs) ->
await_finish([], []) ->
ok;
await_finish([], Fails) ->
+ ?SEV_EPRINT("Fails: "
+ "~n ~p", [Fails]),
Fails;
await_finish(Evs, Fails) ->
receive
@@ -443,8 +449,12 @@ await(ExpPid, Name, Announcement, Slogan, OtherPids)
ok;
{Announcement, Pid, Slogan, Extra} when (Pid =:= ExpPid) ->
{ok, Extra};
+ {'DOWN', _, process, Pid, {skip, SkipReason}} when (Pid =:= ExpPid) ->
+ iprint("Unexpected SKIP from ~w (~p): "
+ "~n ~p", [Name, Pid, SkipReason]),
+ ?LIB:skip({Name, SkipReason});
{'DOWN', _, process, Pid, Reason} when (Pid =:= ExpPid) ->
- eprint("Unexpected DOWN regarding ~w ~p: "
+ eprint("Unexpected DOWN from ~w (~p): "
"~n ~p", [Name, Pid, Reason]),
{error, {unexpected_exit, Name}};
{'DOWN', _, process, OtherPid, Reason} ->
@@ -476,7 +486,7 @@ pi(Pid, Item) ->
check_down(Pid, DownReason, Pids) ->
case lists:keymember(Pid, 1, Pids) of
{value, {_, Name}} ->
- eprint("Unexpected DOWN regarding ~w ~p: "
+ eprint("Unexpected DOWN from ~w (~p): "
"~n ~p", [Name, Pid, DownReason]),
{error, {unexpected_exit, Name}};
false ->
diff --git a/lib/erl_interface/src/Makefile.in b/lib/erl_interface/src/Makefile.in
index 614e7325a9..30e7c04289 100644
--- a/lib/erl_interface/src/Makefile.in
+++ b/lib/erl_interface/src/Makefile.in
@@ -31,7 +31,7 @@
.PHONY : debug opt release clean distclean depend
-TARGET = @TARGET@
+include $(ERL_TOP)/make/target.mk
# ----------------------------------------------------
# Application version and release dir specification