aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/acceptor_SUITE.erl17
-rw-r--r--test/check_tcp_options.erl15
2 files changed, 31 insertions, 1 deletions
diff --git a/test/acceptor_SUITE.erl b/test/acceptor_SUITE.erl
index f4789c8..6325055 100644
--- a/test/acceptor_SUITE.erl
+++ b/test/acceptor_SUITE.erl
@@ -37,6 +37,7 @@
-export([tcp_accept_socket/1]).
-export([tcp_active_echo/1]).
-export([tcp_echo/1]).
+-export([tcp_inherit_options/1]).
-export([tcp_max_connections/1]).
-export([tcp_max_connections_and_beyond/1]).
-export([tcp_set_max_connections/1]).
@@ -66,7 +67,8 @@ groups() ->
tcp_max_connections_and_beyond,
tcp_set_max_connections,
tcp_clean_set_max_connections,
- tcp_upgrade
+ tcp_upgrade,
+ tcp_inherit_options
]}, {ssl, [
ssl_accept_error,
ssl_accept_socket,
@@ -370,6 +372,19 @@ tcp_upgrade(_) ->
receive upgraded -> ok after 1000 -> error(timeout) end,
ranch:stop_listener(Name).
+tcp_inherit_options(_) ->
+ Name = tcp_inherit_options,
+ TcpOptions = [{nodelay, false}, {send_timeout_close, false}],
+ {ok, _} = ranch:start_listener(Name, 4, ranch_tcp,
+ [{port, 0} | TcpOptions],
+ check_tcp_options, [{pid, self()} | TcpOptions]),
+ Port = ranch:get_port(Name),
+ {ok, Socket} = gen_tcp:connect("localhost", Port,
+ [binary, {active, true}, {packet, raw}]),
+ receive checked -> ok after 1000 -> error(timeout) end,
+ ok = gen_tcp:close(Socket),
+ ranch:stop_listener(Name).
+
%% Supervisor tests
supervisor_clean_restart(_) ->
diff --git a/test/check_tcp_options.erl b/test/check_tcp_options.erl
new file mode 100644
index 0000000..18432ac
--- /dev/null
+++ b/test/check_tcp_options.erl
@@ -0,0 +1,15 @@
+-module(check_tcp_options).
+-behaviour(ranch_protocol).
+
+-export([start_link/4]).
+-export([init/3]).
+
+start_link(_, Socket, _, [{pid, TestPid}|TcpOptions]) ->
+ {ok, RealTcpOptions} =
+ inet:getopts(Socket, [Key || {Key, _} <- TcpOptions]),
+ Pid = spawn_link(?MODULE, init, [TestPid, RealTcpOptions, TcpOptions]),
+ {ok, Pid}.
+
+init(Pid, TcpOptions, TcpOptions) ->
+ Pid ! checked,
+ receive after 2500 -> ok end.