aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test/gen_udp_SUITE.erl
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2010-09-06 12:26:47 +0200
committerRaimo Niskanen <[email protected]>2010-09-06 12:26:47 +0200
commit296b3ae4d88c87cdf9638a1dd9cab622c748c5e6 (patch)
treeba62b1f9180a987fb79b8daa063875983e1c10b5 /lib/kernel/test/gen_udp_SUITE.erl
parent8e415cb7094e9ea4287a56daaf227666f2862ed2 (diff)
downloadotp-296b3ae4d88c87cdf9638a1dd9cab622c748c5e6.tar.gz
otp-296b3ae4d88c87cdf9638a1dd9cab622c748c5e6.tar.bz2
otp-296b3ae4d88c87cdf9638a1dd9cab622c748c5e6.zip
Add tests
Conflicts: lib/kernel/test/gen_sctp_SUITE.erl
Diffstat (limited to 'lib/kernel/test/gen_udp_SUITE.erl')
-rw-r--r--lib/kernel/test/gen_udp_SUITE.erl60
1 files changed, 57 insertions, 3 deletions
diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl
index fa1991872b..44dd8607b9 100644
--- a/lib/kernel/test/gen_udp_SUITE.erl
+++ b/lib/kernel/test/gen_udp_SUITE.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 1998-2009. All Rights Reserved.
+%% Copyright Ericsson AB 1998-2010. 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
@@ -34,12 +34,12 @@
-export([send_to_closed/1,
buffer_size/1, binary_passive_recv/1, bad_address/1,
- read_packets/1, open_fd/1, connect/1]).
+ read_packets/1, open_fd/1, connect/1, implicit_inet6/1]).
all(suite) ->
[send_to_closed,
buffer_size, binary_passive_recv, bad_address, read_packets,
- open_fd, connect].
+ open_fd, connect, implicit_inet6].
init_per_testcase(_Case, Config) ->
?line Dog=test_server:timetrap(?default_timeout),
@@ -425,3 +425,57 @@ connect(Config) when is_list(Config) ->
ok = gen_udp:send(S2, <<16#deadbeef:32>>),
{error,econnrefused} = gen_udp:recv(S2, 0, 5),
ok.
+
+implicit_inet6(Config) when is_list(Config) ->
+ ?line Hostname = ok(inet:gethostname()),
+ ?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;
+ _ ->
+ {skip,"IPv6 not supported"}
+ end.
+
+implicit_inet6(S1, Active, Addr) ->
+ ?line P1 = ok(inet:port(S1)),
+ ?line S2 = ok(gen_udp:open(0, [inet6,Active])),
+ ?line P2 = ok(inet:port(S2)),
+ ?line ok = gen_udp:connect(S2, Addr, P1),
+ ?line ok = gen_udp:connect(S1, Addr, P2),
+ ?line {Addr,P2} = ok(inet:peername(S1)),
+ ?line {Addr,P1} = ok(inet:peername(S2)),
+ ?line {Addr,P1} = ok(inet:sockname(S1)),
+ ?line {Addr,P2} = ok(inet:sockname(S2)),
+ ?line ok = gen_udp:send(S1, Addr, P2, "ping"),
+ ?line {Addr,P1,"ping"} = ok(gen_udp:recv(S2, 1024, 1000)),
+ ?line ok = gen_udp:send(S2, Addr, P1, "pong"),
+ ?line {Addr,P2,"pong"} = ok(gen_udp:recv(S1, 1024)),
+ ?line ok = gen_udp:close(S2).
+
+
+ok({ok,V}) -> V.