diff options
author | Micael Karlberg <[email protected]> | 2019-06-26 14:35:38 +0200 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2019-06-26 15:06:16 +0200 |
commit | 79da9de4d091c67d6915b1ccc0703c684836f90d (patch) | |
tree | 2d8d4a0b4115173030efe0de09da28ff4d36b793 /erts/emulator/test/socket_SUITE.erl | |
parent | 64cdec60d31e50f6db39452ec028c2f378f017b0 (diff) | |
download | otp-79da9de4d091c67d6915b1ccc0703c684836f90d.tar.gz otp-79da9de4d091c67d6915b1ccc0703c684836f90d.tar.bz2 otp-79da9de4d091c67d6915b1ccc0703c684836f90d.zip |
[esock|test] Add (traffic) counter (tcp) 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 tcp and one for unix-domain-socket stream (tcp).
OTP-15818
Diffstat (limited to 'erts/emulator/test/socket_SUITE.erl')
-rw-r--r-- | erts/emulator/test/socket_SUITE.erl | 72 |
1 files changed, 71 insertions, 1 deletions
diff --git a/erts/emulator/test/socket_SUITE.erl b/erts/emulator/test/socket_SUITE.erl index 6fd3ff2e45..e7413ba8aa 100644 --- a/erts/emulator/test/socket_SUITE.erl +++ b/erts/emulator/test/socket_SUITE.erl @@ -171,8 +171,10 @@ %% *** Traffic *** traffic_send_and_recv_counters_tcp4/1, - traffic_sendto_and_recvfrom_counters_udp4/1, traffic_send_and_recv_counters_tcpL/1, + traffic_sendmsg_and_recvmsg_counters_tcp4/1, + traffic_sendmsg_and_recvmsg_counters_tcpL/1, + traffic_sendto_and_recvfrom_counters_udp4/1, traffic_sendto_and_recvfrom_counters_udpL/1, traffic_send_and_recv_chunks_tcp4/1, @@ -831,6 +833,8 @@ traffic_counters_cases() -> [ traffic_send_and_recv_counters_tcp4, traffic_send_and_recv_counters_tcpL, + traffic_sendmsg_and_recvmsg_counters_tcp4, + traffic_sendmsg_and_recvmsg_counters_tcpL, traffic_sendto_and_recvfrom_counters_udp4, traffic_sendto_and_recvfrom_counters_udpL ]. @@ -13602,6 +13606,72 @@ traffic_send_and_recv_counters_tcpL(_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 TCP on IPv4. + +traffic_sendmsg_and_recvmsg_counters_tcp4(suite) -> + []; +traffic_sendmsg_and_recvmsg_counters_tcp4(doc) -> + []; +traffic_sendmsg_and_recvmsg_counters_tcp4(_Config) when is_list(_Config) -> + ?TT(?SECS(15)), + tc_try(traffic_sendmsg_and_recvmsg_counters_tcp4, + fun() -> + InitState = #{domain => inet, + proto => tcp, + recv => fun(S) -> + case socket:recvmsg(S) of + {ok, #{addr := _Source, + iov := [Data]}} -> + {ok, Data}; + {error, _} = ERROR -> + ERROR + end + end, + send => fun(S, Data) -> + MsgHdr = #{iov => [Data]}, + socket:sendmsg(S, MsgHdr) + end}, + ok = traffic_send_and_recv_tcp(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 (TCP) on local. + +traffic_sendmsg_and_recvmsg_counters_tcpL(suite) -> + []; +traffic_sendmsg_and_recvmsg_counters_tcpL(doc) -> + []; +traffic_sendmsg_and_recvmsg_counters_tcpL(_Config) when is_list(_Config) -> + ?TT(?SECS(15)), + tc_try(traffic_sendmsg_and_recvmsg_counters_tcpL, + fun() -> + InitState = #{domain => local, + proto => default, + recv => fun(S) -> + case socket:recvmsg(S) of + {ok, #{addr := _Source, + iov := [Data]}} -> + {ok, Data}; + {error, _} = ERROR -> + ERROR + end + end, + send => fun(S, Data) -> + MsgHdr = #{iov => [Data]}, + socket:sendmsg(S, MsgHdr) + end}, + ok = traffic_send_and_recv_tcp(InitState) + end). + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% traffic_send_and_recv_tcp(InitState) -> ServerSeq = |