Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:24
erlang
4743-kernel-test-gen-udp-Tweaked-the-implicit-i...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4743-kernel-test-gen-udp-Tweaked-the-implicit-inet6-test-.patch of Package erlang
From 21a33a59affe08029effecc5e10d79b3519da166 Mon Sep 17 00:00:00 2001 From: Micael Karlberg <bmk@erlang.org> Date: Thu, 3 Nov 2022 17:18:22 +0100 Subject: [PATCH 3/3] [kernel|test|gen-udp] Tweaked the 'implicit inet6' test case --- lib/kernel/test/gen_udp_SUITE.erl | 51 ++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 11 deletions(-) diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl index 13c8640448..c320b71ca0 100644 --- a/lib/kernel/test/gen_udp_SUITE.erl +++ b/lib/kernel/test/gen_udp_SUITE.erl @@ -1814,7 +1814,7 @@ do_implicit_inet6(Config) -> end. implicit_inet6(Config, Host, Addr) -> - Active = {active,false}, + Active = {active,false}, Loopback = {0,0,0,0,0,0,0,1}, ?P("try 1 with explicit inet6 on loopback"), S1 = case ?OPEN(Config, 0, [inet6, Active, {ip, Loopback}]) of @@ -1827,6 +1827,7 @@ implicit_inet6(Config, Host, Addr) -> end, implicit_inet6(Config, S1, Active, Loopback), ok = gen_udp:close(S1), + %% Localaddr = ok(get_localaddr()), ?P("try 2 on local addr (~p)", [Localaddr]), @@ -1838,6 +1839,7 @@ implicit_inet6(Config, Host, Addr) -> end, implicit_inet6(Config, S2, Active, Localaddr), ok = gen_udp:close(S2), + %% ?P("try 3 on addr ~p (~p)", [Addr, Host]), S3 = case ?OPEN(Config, 0, [{ifaddr, Addr}, Active]) of @@ -1875,16 +1877,43 @@ implicit_inet6(Config, S1, Active, Addr) -> ?P("sockname of \"remote\" socket"), {Addr,P2} = ok(inet:sockname(S2)), ?P("send ping on \"local\" socket (to ~p:~p)", [Addr, P2]), - ok = gen_udp:send(S1, Addr, P2, "ping"), - ?P("recv ping on \"remote\" socket (from ~p:~p)", [Addr, P1]), - {Addr,P1,"ping"} = ok(gen_udp:recv(S2, 1024, 1000)), - ?P("send pong on \"remote\" socket (to ~p:~p)", [Addr, P1]), - ok = gen_udp:send(S2, Addr, P1, "pong"), - ?P("recv ping on \"local\" socket (from ~p:~p)", [Addr, P2]), - {Addr,P2,"pong"} = ok(gen_udp:recv(S1, 1024)), - ?P("close \"remote\" socket"), - ok = gen_udp:close(S2), - ok. + %% On some platforms its allowed to specify address and port + %% (that is; when useing sendto) *even* if the socket is connected + %% (assuming the send destination is the same as connected destination). + %% But on other platforms, e.g. FreeBSD, this is *not* allowed! + %% Linux: + %% EISCONN + %% The connection-mode socket was connected already but a recipient + %% was specified. (Now either this error is returned, or the re- + %% cipient specification is ignored.) + %% FreeBSD: + %% [EISCONN] A destination address was specified and the socket is + %% already connected. + case gen_udp:send(S1, Addr, P2, "ping") of + ok -> + ?P("recv ping on \"remote\" socket (from ~p:~p)", [Addr, P1]), + {Addr,P1,"ping"} = ok(gen_udp:recv(S2, 1024, 1000)), + ?P("send pong on \"remote\" socket (to ~p:~p)", [Addr, P1]), + ok = gen_udp:send(S2, Addr, P1, "pong"), + ?P("recv ping on \"local\" socket (from ~p:~p)", [Addr, P2]), + {Addr,P2,"pong"} = ok(gen_udp:recv(S1, 1024)), + ?P("close \"remote\" socket"), + ok = gen_udp:close(S2), + ok; + {error, eisconn} -> + ?P("socket is connect => *not* allowed to use sendto"), + ok = gen_udp:send(S1, "ping"), + %% Not allowed to specify address *at all* for a connected socket + ?P("recv ping on \"remote\" socket (from ~p:~p)", [Addr, P1]), + {Addr,P1,"ping"} = ok(gen_udp:recv(S2, 1024, 1000)), + ?P("send pong on \"remote\" socket (to ~p:~p)", [Addr, P1]), + ok = gen_udp:send(S2, "pong"), + ?P("recv ping on \"local\" socket (from ~p:~p)", [Addr, P2]), + {Addr,P2,"pong"} = ok(gen_udp:recv(S1, 1024)), + ?P("close \"remote\" socket"), + ok = gen_udp:close(S2), + ok + end. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor