aboutsummaryrefslogtreecommitdiffstats
path: root/lib/kernel/test
diff options
context:
space:
mode:
authorFilipe David Manana <[email protected]>2011-06-19 21:16:45 +0100
committerFilipe David Manana <[email protected]>2011-08-27 14:10:06 -0700
commitaf8938714416c0b1393a0830fdc6e8a5ab4be87c (patch)
tree52da30ed54ab3831e0e051007f0bd89047236b5d /lib/kernel/test
parent9a52e239698ae62cddbc0d780502c72458867b6f (diff)
downloadotp-af8938714416c0b1393a0830fdc6e8a5ab4be87c.tar.gz
otp-af8938714416c0b1393a0830fdc6e8a5ab4be87c.tar.bz2
otp-af8938714416c0b1393a0830fdc6e8a5ab4be87c.zip
Fix type of Packet arg of gen_tcp:send/2 and gen_udp:send/4
The type is marked as a binary() or a string() but in practice it can be an iodata(). The test suite was updated to confirm the gen_tcp/2 and gen_udp:send/4 functions accept iodata() (iolists) packets.
Diffstat (limited to 'lib/kernel/test')
-rw-r--r--lib/kernel/test/gen_tcp_api_SUITE.erl8
-rw-r--r--lib/kernel/test/gen_udp_SUITE.erl14
2 files changed, 19 insertions, 3 deletions
diff --git a/lib/kernel/test/gen_tcp_api_SUITE.erl b/lib/kernel/test/gen_tcp_api_SUITE.erl
index fd4685cdad..cbaec2d6dd 100644
--- a/lib/kernel/test/gen_tcp_api_SUITE.erl
+++ b/lib/kernel/test/gen_tcp_api_SUITE.erl
@@ -158,6 +158,10 @@ t_shutdown_error(Config) when is_list(Config) ->
t_fdopen(Config) when is_list(Config) ->
?line Question = "Aaaa... Long time ago in a small town in Germany,",
+ ?line Question1 = list_to_binary(Question),
+ ?line Question2 = [<<"Aaaa">>, "... ", $L, <<>>, $o, "ng time ago ",
+ ["in ", [], <<"a small town">>, [" in Germany,", <<>>]]],
+ ?line Question1 = iolist_to_binary(Question2),
?line Answer = "there was a shoemaker, Schumacher was his name.",
?line {ok, L} = gen_tcp:listen(0, [{active, false}]),
?line {ok, Port} = inet:port(L),
@@ -167,6 +171,10 @@ t_fdopen(Config) when is_list(Config) ->
?line {ok, Server} = gen_tcp:fdopen(FD, []),
?line ok = gen_tcp:send(Client, Question),
?line {ok, Question} = gen_tcp:recv(Server, length(Question), 2000),
+ ?line ok = gen_tcp:send(Client, Question1),
+ ?line {ok, Question} = gen_tcp:recv(Server, length(Question), 2000),
+ ?line ok = gen_tcp:send(Client, Question2),
+ ?line {ok, Question} = gen_tcp:recv(Server, length(Question), 2000),
?line ok = gen_tcp:send(Server, Answer),
?line {ok, Answer} = gen_tcp:recv(Client, length(Answer), 2000),
?line ok = gen_tcp:close(Client),
diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl
index b734d7fd98..514deaf065 100644
--- a/lib/kernel/test/gen_udp_SUITE.erl
+++ b/lib/kernel/test/gen_udp_SUITE.erl
@@ -201,13 +201,21 @@ binary_passive_recv(suite) ->
binary_passive_recv(doc) ->
["OTP-3823 gen_udp:recv does not return address in binary mode"];
binary_passive_recv(Config) when is_list(Config) ->
- ?line D = "The quick brown fox jumps over a lazy dog",
- ?line B = list_to_binary(D),
+ ?line D1 = "The quick brown fox jumps over a lazy dog",
+ ?line D2 = list_to_binary(D1),
+ ?line D3 = ["The quick", <<" brown ">>, "fox jumps ", <<"over ">>,
+ <<>>, $a, [[], " lazy ", <<"dog">>]],
+ ?line D2 = iolist_to_binary(D3),
+ ?line B = D2,
?line {ok, R} = gen_udp:open(0, [binary, {active, false}]),
?line {ok, RP} = inet:port(R),
?line {ok, S} = gen_udp:open(0),
?line {ok, SP} = inet:port(S),
- ?line ok = gen_udp:send(S, localhost, RP, D),
+ ?line ok = gen_udp:send(S, localhost, RP, D1),
+ ?line {ok, {{127, 0, 0, 1}, SP, B}} = gen_udp:recv(R, byte_size(B)+1),
+ ?line ok = gen_udp:send(S, localhost, RP, D2),
+ ?line {ok, {{127, 0, 0, 1}, SP, B}} = gen_udp:recv(R, byte_size(B)+1),
+ ?line ok = gen_udp:send(S, localhost, RP, D3),
?line {ok, {{127, 0, 0, 1}, SP, B}} = gen_udp:recv(R, byte_size(B)+1),
?line ok = gen_udp:close(S),
?line ok = gen_udp:close(R),