aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test/gen_tcp_api_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'lib/kernel/test/gen_tcp_api_SUITE.erl')
-rw-r--r--lib/kernel/test/gen_tcp_api_SUITE.erl100
1 files changed, 62 insertions, 38 deletions
diff --git a/lib/kernel/test/gen_tcp_api_SUITE.erl b/lib/kernel/test/gen_tcp_api_SUITE.erl
index 94637290a1..fd4685cdad 100644
--- a/lib/kernel/test/gen_tcp_api_SUITE.erl
+++ b/lib/kernel/test/gen_tcp_api_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2010. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2011. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -22,30 +22,52 @@
%% are not tested here, because they are tested indirectly in this and
%% and other test suites.
--include("test_server.hrl").
+-include_lib("test_server/include/test_server.hrl").
-include_lib("kernel/include/inet.hrl").
--export([all/1, init_per_testcase/2, fin_per_testcase/2,
- t_accept/1, t_connect_timeout/1, t_accept_timeout/1,
- t_connect/1, t_connect_bad/1,
- t_recv/1, t_recv_timeout/1, t_recv_eof/1,
+-export([all/0, suite/0,groups/0,init_per_suite/1, end_per_suite/1,
+ init_per_group/2,end_per_group/2,
+ init_per_testcase/2, end_per_testcase/2,
+ t_connect_timeout/1, t_accept_timeout/1,
+ t_connect_bad/1,
+ t_recv_timeout/1, t_recv_eof/1,
t_shutdown_write/1, t_shutdown_both/1, t_shutdown_error/1,
t_fdopen/1, t_implicit_inet6/1]).
-all(suite) -> [t_accept, t_connect, t_recv, t_shutdown_write,
- t_shutdown_both, t_shutdown_error, t_fdopen,
- t_implicit_inet6].
+suite() -> [{ct_hooks,[ts_install_cth]}].
+
+all() ->
+ [{group, t_accept}, {group, t_connect}, {group, t_recv},
+ t_shutdown_write, t_shutdown_both, t_shutdown_error,
+ t_fdopen, t_implicit_inet6].
+
+groups() ->
+ [{t_accept, [], [t_accept_timeout]},
+ {t_connect, [], [t_connect_timeout, t_connect_bad]},
+ {t_recv, [], [t_recv_timeout, t_recv_eof]}].
+
+init_per_suite(Config) ->
+ Config.
+
+end_per_suite(_Config) ->
+ ok.
+
+init_per_group(_GroupName, Config) ->
+ Config.
+
+end_per_group(_GroupName, Config) ->
+ Config.
+
init_per_testcase(_Func, Config) ->
Dog = test_server:timetrap(test_server:seconds(60)),
[{watchdog, Dog}|Config].
-fin_per_testcase(_Func, Config) ->
+end_per_testcase(_Func, Config) ->
Dog = ?config(watchdog, Config),
test_server:timetrap_cancel(Dog).
%%% gen_tcp:accept/1,2
-t_accept(suite) -> [t_accept_timeout].
t_accept_timeout(doc) -> "Test that gen_tcp:accept/2 (with timeout) works.";
t_accept_timeout(suite) -> [];
@@ -55,7 +77,6 @@ t_accept_timeout(Config) when is_list(Config) ->
%%% gen_tcp:connect/X
-t_connect(suite) -> [t_connect_timeout, t_connect_bad].
t_connect_timeout(doc) -> "Test that gen_tcp:connect/4 (with timeout) works.";
t_connect_timeout(Config) when is_list(Config) ->
@@ -84,7 +105,6 @@ t_connect_bad(Config) when is_list(Config) ->
%%% gen_tcp:recv/X
-t_recv(suite) -> [t_recv_timeout, t_recv_eof].
t_recv_timeout(doc) -> "Test that gen_tcp:recv/3 (with timeout works).";
t_recv_timeout(suite) -> [];
@@ -160,34 +180,38 @@ t_fdopen(Config) when is_list(Config) ->
%%% implicit inet6 option to api functions
t_implicit_inet6(Config) when is_list(Config) ->
- ?line Hostname = ok(inet:gethostname()),
+ ?line Host = ok(inet:gethostname()),
+ ?line
+ case inet:getaddr(Host, inet6) of
+ {ok,Addr} ->
+ ?line t_implicit_inet6(Host, Addr);
+ {error,Reason} ->
+ {skip,
+ "Can not look up IPv6 address: "
+ ++atom_to_list(Reason)}
+ end.
+
+t_implicit_inet6(Host, Addr) ->
?line
case gen_tcp:listen(0, [inet6]) of
{ok,S1} ->
- ?line
- case inet:getaddr(Hostname, inet6) of
- {ok,Host} ->
- ?line Loopback = {0,0,0,0,0,0,0,1},
- ?line io:format("~s ~p~n", ["Loopback",Loopback]),
- ?line implicit_inet6(S1, Loopback),
- ?line ok = gen_tcp:close(S1),
- %%
- ?line Localhost =
- ok(inet:getaddr("localhost", inet6)),
- ?line io:format("~s ~p~n", ["localhost",Localhost]),
- ?line S2 = ok(gen_tcp:listen(0, [{ip,Localhost}])),
- ?line implicit_inet6(S2, Localhost),
- ?line ok = gen_tcp:close(S2),
- %%
- ?line io:format("~s ~p~n", [Hostname,Host]),
- ?line S3 = ok(gen_tcp:listen(0, [{ifaddr,Host}])),
- ?line implicit_inet6(S3, Host),
- ?line ok = gen_tcp:close(S1);
- {error,eafnosupport} ->
- ?line ok = gen_tcp:close(S1),
- {skip,"Can not look up IPv6 address"}
- end;
- _ ->
+ ?line Loopback = {0,0,0,0,0,0,0,1},
+ ?line io:format("~s ~p~n", ["::1",Loopback]),
+ ?line implicit_inet6(S1, Loopback),
+ ?line ok = gen_tcp:close(S1),
+ %%
+ ?line Localhost = "localhost",
+ ?line Localaddr = ok(inet:getaddr(Localhost, inet6)),
+ ?line io:format("~s ~p~n", [Localhost,Localaddr]),
+ ?line S2 = ok(gen_tcp:listen(0, [{ip,Localaddr}])),
+ ?line implicit_inet6(S2, Localaddr),
+ ?line ok = gen_tcp:close(S2),
+ %%
+ ?line io:format("~s ~p~n", [Host,Addr]),
+ ?line S3 = ok(gen_tcp:listen(0, [{ifaddr,Addr}])),
+ ?line implicit_inet6(S3, Addr),
+ ?line ok = gen_tcp:close(S3);
+ {error,_} ->
{skip,"IPv6 not supported"}
end.