aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2018-10-04 12:03:35 +0200
committerMicael Karlberg <[email protected]>2018-10-04 12:03:35 +0200
commite698436942c7aaf4f2872c19df2555275be169d1 (patch)
tree6ccc97e78aaafef121efad5bb2e51eebe5816286
parent6b43b24610329f9b1201c36cc4dfcb346ed0317c (diff)
downloadotp-e698436942c7aaf4f2872c19df2555275be169d1.tar.gz
otp-e698436942c7aaf4f2872c19df2555275be169d1.tar.bz2
otp-e698436942c7aaf4f2872c19df2555275be169d1.zip
[socket-nif|test] Updated test case for connect timeout
The connect timeout test case uses the listen backlog argument to test connect timeout (its set to 1). The idea is that when the server backlog is full, it should not reply. The client attempting to connect will then get a timeout. But as it turns out, this behaviour is not "set in stone". On FreeBSD 11.2, the result is instead a 'econnreset'. It should also be noted that this local connections. That is, both end of the connection is on the same machine. So, test case has been updated to also accept a econnreset (even though that is not what it is testing). OTP-14831
-rw-r--r--lib/kernel/test/socket_SUITE.erl18
1 files changed, 17 insertions, 1 deletions
diff --git a/lib/kernel/test/socket_SUITE.erl b/lib/kernel/test/socket_SUITE.erl
index d4cd144168..f3a7d84e81 100644
--- a/lib/kernel/test/socket_SUITE.erl
+++ b/lib/kernel/test/socket_SUITE.erl
@@ -203,7 +203,15 @@ api_b_open_and_close(Domain, Type, Proto) ->
{error, Reason} ->
?FAIL({open, Reason})
end,
- {ok, Domain} = socket:getopt(Socket, socket, domain),
+ %% Domain is not available on all platforms:
+ case socket:getopt(Socket, socket, domain) of
+ {ok, Domain} ->
+ ok;
+ {error, einval} ->
+ ok;
+ Else ->
+ ?FAIL({getopt, domain, Else})
+ end,
{ok, Type} = socket:getopt(Socket, socket, type),
{ok, Proto} = socket:getopt(Socket, socket, protocol),
Self = self(),
@@ -558,6 +566,11 @@ api_to_connect_tcp6(_Config) when is_list(_Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% We use the backlog (listen) argument to test this.
+%% Note that the behaviour of the TCP "server side" can vary when
+%% a client connect to a "busy" server (full backlog).
+%% For instance, on FreeBSD (11.2) the reponse when the backlog is full
+%% is a econreset.
api_to_connect_tcp(Domain) ->
process_flag(trap_exit, true),
@@ -621,6 +634,9 @@ api_to_connect_tcp_await_timeout([Sock|Socks], ServerSA, ID) ->
{error, timeout} ->
p("expected timeout (~w)", [ID]),
ok;
+ {error, econnreset = Reason} ->
+ p("failed connecting: ~p - giving up", [Reason]),
+ ok;
{error, Reason} ->
p("failed connecting: ~p", [Reason]),
?FAIL({recv, Reason});