diff options
author | Micael Karlberg <[email protected]> | 2019-06-26 14:48:19 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-06-26 15:06:16 +0200 |
commit | d8fd1f6267efd29bcc6a41bb33035f4602fea699 (patch) | |
tree | 0b70a9de662ba2f494f268a47886be10a39627c1 /erts/emulator/test/socket_SUITE.erl | |
parent | 30f85dca70935c830d861c63c0bbb2caf77a8663 (diff) | |
download | otp-d8fd1f6267efd29bcc6a41bb33035f4602fea699.tar.gz otp-d8fd1f6267efd29bcc6a41bb33035f4602fea699.tar.bz2 otp-d8fd1f6267efd29bcc6a41bb33035f4602fea699.zip |
[esock|test] Add (traffic) counter (udp) test cases
Add two simple (traffic) counter test cases, to test counter
actions for normal traffic (send and receive using sendmsg
and recvmsg).
One for IPv4 udp and one for unix-domain-socket stream (udp).
OTP-15818
Diffstat (limited to 'erts/emulator/test/socket_SUITE.erl')
-rw-r--r-- | erts/emulator/test/socket_SUITE.erl | 74 |
1 files changed, 73 insertions, 1 deletions
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl index e7413ba8aa..43a939f122 100644 --- a/erts/emulator/test/socket_SUITE.erl +++ b/erts/emulator/test/socket_SUITE.erl @@ -176,6 +176,8 @@ traffic_sendmsg_and_recvmsg_counters_tcpL/1, traffic_sendto_and_recvfrom_counters_udp4/1, traffic_sendto_and_recvfrom_counters_udpL/1, + traffic_sendmsg_and_recvmsg_counters_udp4/1, + traffic_sendmsg_and_recvmsg_counters_udpL/1, traffic_send_and_recv_chunks_tcp4/1, traffic_send_and_recv_chunks_tcp6/1, @@ -836,7 +838,9 @@ traffic_counters_cases() -> traffic_sendmsg_and_recvmsg_counters_tcp4, traffic_sendmsg_and_recvmsg_counters_tcpL, traffic_sendto_and_recvfrom_counters_udp4, - traffic_sendto_and_recvfrom_counters_udpL + traffic_sendto_and_recvfrom_counters_udpL, + traffic_sendmsg_and_recvmsg_counters_udp4, + traffic_sendmsg_and_recvmsg_counters_udpL ]. traffic_chunks_cases() -> @@ -14586,6 +14590,74 @@ traffic_sendto_and_recvfrom_counters_udpL(_Config) when is_list(_Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% This test case is intended to (simply) test that the counters +%% for both read and write. +%% So that its easy to extend, we use fun's for read and write. +%% We use UDP on IPv4. + +traffic_sendmsg_and_recvmsg_counters_udp4(suite) -> + []; +traffic_sendmsg_and_recvmsg_counters_udp4(doc) -> + []; +traffic_sendmsg_and_recvmsg_counters_udp4(_Config) when is_list(_Config) -> + ?TT(?SECS(15)), + tc_try(traffic_sendmsg_and_recvmsg_counters_udp4, + fun() -> + InitState = #{domain => inet, + proto => udp, + recv => fun(S) -> + case socket:recvmsg(S) of + {ok, #{addr := Source, + iov := [Data]}} -> + {ok, {Source, Data}}; + {error, _} = ERROR -> + ERROR + end + end, + send => fun(S, Data, Dest) -> + MsgHdr = #{addr => Dest, + iov => [Data]}, + socket:sendmsg(S, MsgHdr) + end}, + ok = traffic_send_and_recv_udp(InitState) + end). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% This test case is intended to (simply) test that the counters +%% for both read and write. +%% So that its easy to extend, we use fun's for read and write. +%% We use default (UDP) on local. + +traffic_sendmsg_and_recvmsg_counters_udpL(suite) -> + []; +traffic_sendmsg_and_recvmsg_counters_udpL(doc) -> + []; +traffic_sendmsg_and_recvmsg_counters_udpL(_Config) when is_list(_Config) -> + ?TT(?SECS(15)), + tc_try(traffic_sendmsg_and_recvmsg_counters_udpL, + fun() -> + InitState = #{domain => local, + proto => default, + recv => fun(S) -> + case socket:recvmsg(S) of + {ok, #{addr := Source, + iov := [Data]}} -> + {ok, {Source, Data}}; + {error, _} = ERROR -> + ERROR + end + end, + send => fun(S, Data, Dest) -> + MsgHdr = #{addr => Dest, + iov => [Data]}, + socket:sendmsg(S, MsgHdr) + end}, + ok = traffic_send_and_recv_udp(InitState) + end). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% traffic_send_and_recv_udp(InitState) -> ServerSeq = |