From 619ba4717029a71c72f8bdd9a2f2b92f5c2549a0 Mon Sep 17 00:00:00 2001 From: Micael Karlberg Date: Thu, 30 Mar 2023 18:03:45 +0200 Subject: [erts|esock] Fixed 'pending' recvmsg OTP-18029 --- lib/kernel/test/socket_SUITE.erl | 107 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) (limited to 'lib/kernel') diff --git a/lib/kernel/test/socket_SUITE.erl b/lib/kernel/test/socket_SUITE.erl index e2d382dd69..653bb91d50 100644 --- a/lib/kernel/test/socket_SUITE.erl +++ b/lib/kernel/test/socket_SUITE.erl @@ -68,8 +68,13 @@ %% Run a specific test case: %% ts:run(emulator, socket_SUITE, foo, [batch]). %% +%% S = fun() -> ts:run(kernel, socket_SUITE, [batch]) end. +%% S = fun() -> ct:run_test([{suite, socket_SUITE}]) end. %% T = fun(TC) -> ts:run(kernel, socket_SUITE, TC, [batch]) end. +%% T = fun(TC) -> ct:run_test([{suite, socket_SUITE}, {testcase, TC}]) end. %% G = fun(GROUP) -> ts:run(kernel, socket_SUITE, {group, GROUP}, [batch]) end. +%% G = fun(GROUP) -> ct:run_test([{suite, socket_SUITE}, {group, GROUP}]) end. + -module(socket_SUITE). @@ -93,6 +98,10 @@ api_m_error_bind/1, %% *** API Basic *** + api_b_simple_open_and_close_udp4/1, + api_b_simple_open_and_close_udp6/1, + api_b_simple_open_and_close_tcp4/1, + api_b_simple_open_and_close_tcp6/1, api_b_open_and_info_udp4/1, api_b_open_and_info_udp6/1, api_b_open_and_info_tcp4/1, @@ -922,6 +931,10 @@ api_misc_cases() -> api_basic_cases() -> [ + api_b_simple_open_and_close_udp4, + api_b_simple_open_and_close_udp6, + api_b_simple_open_and_close_tcp4, + api_b_simple_open_and_close_tcp6, api_b_open_and_info_udp4, api_b_open_and_info_udp6, api_b_open_and_info_tcp4, @@ -2583,6 +2596,100 @@ api_m_error_bind(Config) when is_list(Config) -> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% Basically open (create) and then close. +api_b_simple_open_and_close_udp4(_Config) when is_list(_Config) -> + ?TT(?SECS(5)), + tc_try(?FUNCTION_NAME, + fun() -> + InitState = #{domain => inet, + type => dgram, + protocol => udp}, + ok = api_b_simple_open_and_close(InitState) + end). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% Basically open (create) and then close. +api_b_simple_open_and_close_udp6(_Config) when is_list(_Config) -> + ?TT(?SECS(5)), + tc_try(?FUNCTION_NAME, + fun() -> has_support_ipv6() end, + fun() -> + InitState = #{domain => inet6, + type => dgram, + protocol => udp}, + ok = api_b_simple_open_and_close(InitState) + end). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% Basically open (create) and then close. +api_b_simple_open_and_close_tcp4(_Config) when is_list(_Config) -> + ?TT(?SECS(5)), + tc_try(?FUNCTION_NAME, + fun() -> + InitState = #{domain => inet, + type => stream, + protocol => tcp}, + ok = api_b_simple_open_and_close(InitState) + end). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%% Basically open (create) and then close. +api_b_simple_open_and_close_tcp6(_Config) when is_list(_Config) -> + ?TT(?SECS(5)), + tc_try(?FUNCTION_NAME, + fun() -> has_support_ipv6() end, + fun() -> + InitState = #{domain => inet6, + type => stream, + protocol => tcp}, + ok = api_b_simple_open_and_close(InitState) + end). + + + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +api_b_simple_open_and_close(InitState) -> + Seq = + [ + #{desc => "open", + cmd => fun(#{domain := Domain, + type := Type, + protocol := Protocol} = State) -> + case socket:open(Domain, Type, Protocol) of + {ok, Sock} -> + {ok, State#{sock => Sock}}; + {error, _} = ERROR -> + ERROR + end + end}, + + ?SEV_SLEEP(?SECS(1)), + + #{desc => "close socket", + cmd => fun(#{sock := Sock} = _State) -> + socket:close(Sock) + end}, + + %% *** We are done *** + ?SEV_FINISH_NORMAL + ], + Evaluator = ?SEV_START("tester", Seq, InitState), + ok = ?SEV_AWAIT_FINISH([Evaluator]). + + + %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% Basically open (create) and info of an IPv4 UDP (dgram) socket. -- cgit v1.2.1