aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2010-12-07 15:11:07 +0100
committerRaimo Niskanen <[email protected]>2010-12-07 15:11:07 +0100
commit664c94ce53f21d7c2927ffab60aeaf74b4627049 (patch)
treeb5361e647be0521c32cbeac12ac81a9d2cda7037 /lib/kernel/test
parentada2a055fd183082bcefd5e4b94477959e75ebee (diff)
downloadotp-664c94ce53f21d7c2927ffab60aeaf74b4627049.tar.gz
otp-664c94ce53f21d7c2927ffab60aeaf74b4627049.tar.bz2
otp-664c94ce53f21d7c2927ffab60aeaf74b4627049.zip
Improve implicit_inet6 testcase skip conditions
Diffstat (limited to 'lib/kernel/test')
-rw-r--r--lib/kernel/test/gen_tcp_api_SUITE.erl54
-rw-r--r--lib/kernel/test/gen_udp_SUITE.erl55
2 files changed, 57 insertions, 52 deletions
diff --git a/lib/kernel/test/gen_tcp_api_SUITE.erl b/lib/kernel/test/gen_tcp_api_SUITE.erl
index 94637290a1..5f190f3e30 100644
--- a/lib/kernel/test/gen_tcp_api_SUITE.erl
+++ b/lib/kernel/test/gen_tcp_api_SUITE.erl
@@ -160,34 +160,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.
diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl
index 2ff1d7210a..e8470394a4 100644
--- a/lib/kernel/test/gen_udp_SUITE.erl
+++ b/lib/kernel/test/gen_udp_SUITE.erl
@@ -431,36 +431,38 @@ connect(Config) when is_list(Config) ->
ok.
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 implicit_inet6(Host, Addr);
+ {error,Reason} ->
+ {skip,
+ "Can not look up IPv6 address: "
+ ++atom_to_list(Reason)}
+ end.
+
+implicit_inet6(Host, Addr) ->
?line Active = {active,false},
?line
case gen_udp:open(0, [inet6,Active]) 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, Active, Loopback),
- ?line ok = gen_udp:close(S1),
- %%
- ?line Localhost =
- ok(inet:getaddr("localhost", inet6)),
- ?line io:format("~s ~p~n", ["localhost",Localhost]),
- ?line S2 =
- ok(gen_udp:open(0, [{ip,Localhost},Active])),
- ?line implicit_inet6(S2, Active, Localhost),
- ?line ok = gen_udp:close(S2),
- %%
- ?line io:format("~s ~p~n", [Hostname,Host]),
- ?line S3 =
- ok(gen_udp:open(0, [{ifaddr,Host},Active])),
- ?line implicit_inet6(S3, Active, Host),
- ?line ok = gen_udp:close(S1);
- {error,eafnosupport} ->
- ?line ok = gen_udp: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, Active, Loopback),
+ ?line ok = gen_udp:close(S1),
+ %%
+ ?line Localhost = "localhost",
+ ?line Localaddr = ok(inet:getaddr(Localhost, inet6)),
+ ?line io:format("~s ~p~n", [Localhost,Localaddr]),
+ ?line S2 = ok(gen_udp:open(0, [{ip,Localaddr},Active])),
+ ?line implicit_inet6(S2, Active, Localaddr),
+ ?line ok = gen_udp:close(S2),
+ %%
+ ?line io:format("~s ~p~n", [Host,Addr]),
+ ?line S3 = ok(gen_udp:open(0, [{ifaddr,Addr},Active])),
+ ?line implicit_inet6(S3, Active, Addr),
+ ?line ok = gen_udp:close(S3);
_ ->
{skip,"IPv6 not supported"}
end.
@@ -481,5 +483,4 @@ implicit_inet6(S1, Active, Addr) ->
?line {Addr,P2,"pong"} = ok(gen_udp:recv(S1, 1024)),
?line ok = gen_udp:close(S2).
-
ok({ok,V}) -> V.