aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/test
diff options
context:
space:
mode:
authorMicael Karlberg <[email protected]>2019-05-13 13:07:55 +0200
committerMicael Karlberg <[email protected]>2019-05-29 13:47:40 +0200
commit80e72ee3ddf73119618277c05df724b01ffdf18a (patch)
treee248bafc90302cb45ee5eee2ae3f9052846b6988 /erts/emulator/test
parent39e137878aa5d1f745cf3c343429fe9de47ed1be (diff)
downloadotp-80e72ee3ddf73119618277c05df724b01ffdf18a.tar.gz
otp-80e72ee3ddf73119618277c05df724b01ffdf18a.tar.bz2
otp-80e72ee3ddf73119618277c05df724b01ffdf18a.zip
[esock|test] Add (stream) sendmsg and recvmsg test case for local
Add a sendmsg and recvmsg test case for a unix domain (stream) socket. Found and fixed a bug for the return value for the address field for family 'local' (encoded as 'inet'). OTP-15822
Diffstat (limited to 'erts/emulator/test')
-rw-r--r--erts/emulator/test/socket_SUITE.erl41
1 files changed, 39 insertions, 2 deletions
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl
index 639dfcd14d..d4e0d104e3 100644
--- a/erts/emulator/test/socket_SUITE.erl
+++ b/erts/emulator/test/socket_SUITE.erl
@@ -77,6 +77,7 @@
api_b_send_and_recv_tcp4/1,
api_b_send_and_recv_tcpL/1,
api_b_sendmsg_and_recvmsg_tcp4/1,
+ api_b_sendmsg_and_recvmsg_tcpL/1,
%% *** API Options ***
api_opt_simple_otp_options/1,
@@ -597,7 +598,8 @@ api_basic_cases() ->
api_b_sendmsg_and_recvmsg_udp4,
api_b_send_and_recv_tcp4,
api_b_send_and_recv_tcpL,
- api_b_sendmsg_and_recvmsg_tcp4
+ api_b_sendmsg_and_recvmsg_tcp4,
+ api_b_sendmsg_and_recvmsg_tcpL
].
api_options_cases() ->
@@ -1913,6 +1915,41 @@ api_b_sendmsg_and_recvmsg_tcp4(_Config) when is_list(_Config) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% Basically send and receive using the msg functions (sendmsg and recvmsg)
+%% on an IPv4 TCP (stream) socket.
+api_b_sendmsg_and_recvmsg_tcpL(suite) ->
+ [];
+api_b_sendmsg_and_recvmsg_tcpL(doc) ->
+ [];
+api_b_sendmsg_and_recvmsg_tcpL(_Config) when is_list(_Config) ->
+ ?TT(?SECS(10)),
+ tc_try(api_b_sendmsg_and_recvmsg_tcpL,
+ fun() -> supports_unix_domain_socket() end,
+ fun() ->
+ Send = fun(Sock, Data) ->
+ MsgHdr = #{iov => [Data]},
+ socket:sendmsg(Sock, MsgHdr)
+ end,
+ Recv = fun(Sock) ->
+ case socket:recvmsg(Sock) of
+ {ok, #{addr := #{family := local},
+ iov := [Data]}} ->
+ {ok, Data};
+ {error, _} = ERROR ->
+ ERROR
+ end
+ end,
+ InitState = #{domain => local,
+ type => stream,
+ proto => default,
+ send => Send,
+ recv => Recv},
+ ok = api_b_send_and_recv_tcp(InitState)
+ end).
+
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
api_b_send_and_recv_tcp(InitState) ->
process_flag(trap_exit, true),
ServerSeq =
@@ -2181,7 +2218,7 @@ api_b_send_and_recv_tcp(InitState) ->
ok
end,
ok;
- (#{sock := Sock} = S) ->
+ (#{sock := Sock} = _S) ->
socket:close(Sock)
end},