diff options
author | Micael Karlberg <[email protected]> | 2019-05-14 12:53:38 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-05-29 13:47:40 +0200 |
commit | 5520d83c2677a2dc83c4b15994363d2ddd3b317f (patch) | |
tree | 7ffa9e0fd00219d08eb5b149a4623526f2b5bdaa /erts/emulator/test/socket_SUITE.erl | |
parent | f62837f233cf83b05531138a7328c5026f424600 (diff) | |
download | otp-5520d83c2677a2dc83c4b15994363d2ddd3b317f.tar.gz otp-5520d83c2677a2dc83c4b15994363d2ddd3b317f.tar.bz2 otp-5520d83c2677a2dc83c4b15994363d2ddd3b317f.zip |
[esock|test] Add remote shutdown recvmsg test case for local (stream)
Add remote shutdown(write) recvmsg response test case for
Unix Domain (stream) socket.
OTP-15822
Diffstat (limited to 'erts/emulator/test/socket_SUITE.erl')
-rw-r--r-- | erts/emulator/test/socket_SUITE.erl | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl index 9349b661fc..9fe6016367 100644 --- a/erts/emulator/test/socket_SUITE.erl +++ b/erts/emulator/test/socket_SUITE.erl @@ -146,6 +146,7 @@ sc_rs_recv_send_shutdown_receive_tcpL/1, sc_rs_recvmsg_send_shutdown_receive_tcp4/1, sc_rs_recvmsg_send_shutdown_receive_tcp6/1, + sc_rs_recvmsg_send_shutdown_receive_tcpL/1, %% *** Traffic *** traffic_send_and_recv_chunks_tcp4/1, @@ -715,7 +716,8 @@ sc_rs_cases() -> sc_rs_recv_send_shutdown_receive_tcpL, sc_rs_recvmsg_send_shutdown_receive_tcp4, - sc_rs_recvmsg_send_shutdown_receive_tcp6 + sc_rs_recvmsg_send_shutdown_receive_tcp6, + sc_rs_recvmsg_send_shutdown_receive_tcpL ]. @@ -9389,8 +9391,8 @@ sc_rs_recvmsg_send_shutdown_receive_tcp6(_Config) when is_list(_Config) -> end end, Send = fun(Sock, Data) when is_binary(Data) -> - MsgHdr = #{iov => [Data]}, - socket:sendmsg(Sock, MsgHdr) + MsgHdr = #{iov => [Data]}, + socket:sendmsg(Sock, MsgHdr) end, InitState = #{domain => inet6, proto => tcp, @@ -9402,6 +9404,47 @@ sc_rs_recvmsg_send_shutdown_receive_tcp6(_Config) when is_list(_Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% This test case is intended to test what happens when a socket is +%% remotely closed while the process is calling the recvmsg function. +%% The remote client sends data, then shutdown(write) and then the +%% reader attempts a recv. +%% Socket is UNix Domain (stream) socket. + +sc_rs_recvmsg_send_shutdown_receive_tcpL(suite) -> + []; +sc_rs_recvmsg_send_shutdown_receive_tcpL(doc) -> + []; +sc_rs_recvmsg_send_shutdown_receive_tcpL(_Config) when is_list(_Config) -> + ?TT(?SECS(10)), + tc_try(sc_rs_recvmsg_send_shutdown_receive_tcpL, + fun() -> has_support_unix_domain_socket() end, + fun() -> + {ok, CWD} = file:get_cwd(), + ?SEV_IPRINT("CWD: ~s", [CWD]), + MsgData = ?DATA, + Recv = fun(Sock) -> + case socket:recvmsg(Sock) of + {ok, #{addr := #{family := local}, + iov := [Data]}} -> + {ok, Data}; + {error, _} = ERROR -> + ERROR + end + end, + Send = fun(Sock, Data) when is_binary(Data) -> + MsgHdr = #{iov => [Data]}, + socket:sendmsg(Sock, MsgHdr) + end, + InitState = #{domain => local, + proto => default, + recv => Recv, + send => Send, + data => MsgData}, + ok = sc_rs_send_shutdown_receive_tcp(InitState) + end). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% This test case is intended to test that the send and recv functions %% behave as expected when sending and/or reading chunks. %% First send data in one "big" chunk, and read it in "small" chunks. @@ -18536,7 +18579,8 @@ local_host() -> %% don't clash. mk_unique_path() -> [NodeName | _] = string:tokens(atom_to_list(node()), [$@]), - ?LIB:f("/tmp/socket_~s_~w", [NodeName, erlang:unique_integer()]). + %% ?LIB:f("/tmp/socket_~s_~w", [NodeName, erlang:unique_integer()]). + ?LIB:f("/tmp/socket_~s_~w", [NodeName, erlang:system_time(nanosecond)]). which_local_socket_addr(local = Domain) -> #{family => Domain, |