diff options
author | Raimo Niskanen <[email protected]> | 2011-03-07 10:57:21 +0100 |
---|---|---|
committer | Raimo Niskanen <[email protected]> | 2011-03-07 10:57:21 +0100 |
commit | 573be65458c5fde3a37184e065812915f3d88015 (patch) | |
tree | 1e95370ed60a7ca61a8111b13a5718ae4042c06d /lib/kernel/test/gen_udp_SUITE.erl | |
parent | 5ef5d6a216815c13ce671df07bd0125b317f5969 (diff) | |
parent | 664c94ce53f21d7c2927ffab60aeaf74b4627049 (diff) | |
download | otp-573be65458c5fde3a37184e065812915f3d88015.tar.gz otp-573be65458c5fde3a37184e065812915f3d88015.tar.bz2 otp-573be65458c5fde3a37184e065812915f3d88015.zip |
Merge branch 'raimo/kernel-implicit_inet6-testcase' into dev
* raimo/kernel-implicit_inet6-testcase:
Improve implicit_inet6 testcase skip conditions
Diffstat (limited to 'lib/kernel/test/gen_udp_SUITE.erl')
-rw-r--r-- | lib/kernel/test/gen_udp_SUITE.erl | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl index ee9288bc75..0ea2d53af0 100644 --- a/lib/kernel/test/gen_udp_SUITE.erl +++ b/lib/kernel/test/gen_udp_SUITE.erl @@ -450,36 +450,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. @@ -500,5 +502,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. |