diff options
Diffstat (limited to 'lib/kernel/test')
-rw-r--r-- | lib/kernel/test/disk_log_SUITE.erl | 2 | ||||
-rw-r--r-- | lib/kernel/test/gen_sctp_SUITE.erl | 13 | ||||
-rw-r--r-- | lib/kernel/test/gen_tcp_api_SUITE.erl | 33 | ||||
-rw-r--r-- | lib/kernel/test/gen_udp_SUITE.erl | 39 | ||||
-rw-r--r-- | lib/kernel/test/inet_SUITE.erl | 18 | ||||
-rw-r--r-- | lib/kernel/test/logger_disk_log_h_SUITE.erl | 22 | ||||
-rw-r--r-- | lib/kernel/test/logger_std_h_SUITE.erl | 2 | ||||
-rw-r--r-- | lib/kernel/test/logger_stress_SUITE.erl | 2 | ||||
-rw-r--r-- | lib/kernel/test/socket_SUITE.erl | 224 | ||||
-rw-r--r-- | lib/kernel/test/socket_test_evaluator.erl | 2 | ||||
-rw-r--r-- | lib/kernel/test/socket_test_lib.erl | 2 | ||||
-rw-r--r-- | lib/kernel/test/socket_test_ttest_tcp_socket.erl | 2 |
12 files changed, 279 insertions, 82 deletions
diff --git a/lib/kernel/test/disk_log_SUITE.erl b/lib/kernel/test/disk_log_SUITE.erl index d80201679c..dc4b6c4862 100644 --- a/lib/kernel/test/disk_log_SUITE.erl +++ b/lib/kernel/test/disk_log_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2022. All Rights Reserved. +%% Copyright Ericsson AB 1997-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/lib/kernel/test/gen_sctp_SUITE.erl b/lib/kernel/test/gen_sctp_SUITE.erl index 297c824965..7b0dbb0d2e 100644 --- a/lib/kernel/test/gen_sctp_SUITE.erl +++ b/lib/kernel/test/gen_sctp_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2007-2022. All Rights Reserved. +%% Copyright Ericsson AB 2007-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -16,7 +16,7 @@ %% limitations under the License. %% %% %CopyrightEnd% -%% +%% -module(gen_sctp_SUITE). -include_lib("common_test/include/ct.hrl"). @@ -770,6 +770,15 @@ api_listen(Config) when is_list(Config) -> {ok,Sb} = gen_sctp:open(Pb), {ok,Sa} = gen_sctp:open(), + + element(1, os:type()) =:= unix andalso + begin + {error, nxdomain} = gen_sctp:connect(Sa, "", 65535, []), + {error, nxdomain} = gen_sctp:connect(Sa, '', 65535, []) + end, + {error, nxdomain} = gen_sctp:connect(Sa, ".", 65535, []), + {error, nxdomain} = gen_sctp:connect(Sa, '.', 65535, []), + case gen_sctp:connect(Sa, localhost, Pb, []) of {error,econnrefused} -> {ok,{Localhost, diff --git a/lib/kernel/test/gen_tcp_api_SUITE.erl b/lib/kernel/test/gen_tcp_api_SUITE.erl index 8199e42e42..c2ab0c3df6 100644 --- a/lib/kernel/test/gen_tcp_api_SUITE.erl +++ b/lib/kernel/test/gen_tcp_api_SUITE.erl @@ -1,8 +1,8 @@ %% %% %CopyrightBegin% -%% -%% Copyright Ericsson AB 1998-2022. All Rights Reserved. -%% +%% +%% Copyright Ericsson AB 1998-2023. All Rights Reserved. +%% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. %% You may obtain a copy of the License at @@ -14,7 +14,7 @@ %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %% See the License for the specific language governing permissions and %% limitations under the License. -%% +%% %% %CopyrightEnd% %% -module(gen_tcp_api_SUITE). @@ -353,15 +353,22 @@ t_connect_src_port(Config) when is_list(Config) -> %% invalid things. t_connect_bad(Config) when is_list(Config) -> NonExistingPort = 45638, % Not in use, I hope. - {error, Reason1} = gen_tcp:connect(localhost, NonExistingPort, - ?INET_BACKEND_OPTS(Config)), - io:format("Error for connection attempt to port not in use: ~p", - [Reason1]), - - {error, Reason2} = gen_tcp:connect("non-existing-host-xxx", 7, - ?INET_BACKEND_OPTS(Config)), - io:format("Error for connection attempt to non-existing host: ~p", - [Reason2]), + t_connect_bad(Config, localhost, NonExistingPort, "port not in use"), + t_connect_bad(Config, "non-existing-host-xxx", 7, "non-existing host"), + element(1, os:type()) =:= unix andalso + begin + t_connect_bad(Config, "", 7, "empty host string"), + t_connect_bad(Config, '', 7, "empty host atom") + end, + t_connect_bad(Config, ".", 7, "root domain string"), + t_connect_bad(Config, '.', 7, "root domain atom"). + +t_connect_bad(Config, Host, Port, Descr) -> + {error, Reason} = + gen_tcp:connect(Host, Port,?INET_BACKEND_OPTS(Config)), + io:format( + "Error for connection attempt to " ++ Descr ++ ": ~p~n", + [Reason]), ok. diff --git a/lib/kernel/test/gen_udp_SUITE.erl b/lib/kernel/test/gen_udp_SUITE.erl index d37948db28..4aefee8a79 100644 --- a/lib/kernel/test/gen_udp_SUITE.erl +++ b/lib/kernel/test/gen_udp_SUITE.erl @@ -1,8 +1,8 @@ %% %% %CopyrightBegin% -%% +%% %% Copyright Ericsson AB 1998-2023. All Rights Reserved. -%% +%% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. %% You may obtain a copy of the License at @@ -14,7 +14,7 @@ %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %% See the License for the specific language governing permissions and %% limitations under the License. -%% +%% %% %CopyrightEnd% %% @@ -37,7 +37,7 @@ init_per_testcase/2, end_per_testcase/2]). -export([ - send_to_closed/1, active_n/1, + send_to_closed/1, send_to_empty/1, active_n/1, buffer_size/1, binary_passive_recv/1, max_buffer_size/1, bad_address/1, read_packets/1, recv_poll_after_active_once/1, open_fd/1, connect/1, reconnect/1, implicit_inet6/1, @@ -118,6 +118,7 @@ inet_backend_socket_cases() -> all_cases() -> [ send_to_closed, + send_to_empty, buffer_size, binary_passive_recv, max_buffer_size, @@ -340,6 +341,23 @@ do_send_to_closed(Config) -> %%------------------------------------------------------------- +%% Send to the empty host name + +send_to_empty(Config) when is_list(Config) -> + ?TC_TRY(?FUNCTION_NAME, fun() -> do_send_to_empty(Config) end). + +do_send_to_empty(Config) -> + {ok, Sock} = ?OPEN(Config, 0), + element(1, os:type()) =:= unix andalso + begin + {error, nxdomain} = gen_udp:send(Sock, "", ?CLOSED_PORT, "xXx"), + {error, nxdomain} = gen_udp:send(Sock, '', ?CLOSED_PORT, "xXx") + end, + {error, nxdomain} = gen_udp:send(Sock, ".", ?CLOSED_PORT, "xXx"), + {error, nxdomain} = gen_udp:send(Sock, '.', ?CLOSED_PORT, "xXx"), + ok. + +%%------------------------------------------------------------- %% Test that the UDP socket buffer sizes are settable %% Test UDP buffer size setting. @@ -1744,6 +1762,11 @@ do_connect(Config) when is_list(Config) -> ?P("sleep some"), ct:sleep({seconds, 5}), + ?P("try some doomed connect targets: ~p", [P1]), + {error, nxdomain} = gen_udp:connect(S2, "", ?CLOSED_PORT), + {error, nxdomain} = gen_udp:connect(S2, '', ?CLOSED_PORT), + {error, nxdomain} = gen_udp:connect(S2, ".", ?CLOSED_PORT), + {error, nxdomain} = gen_udp:connect(S2, '.', ?CLOSED_PORT), ?P("try connect second socket to: ~p, ~p", [Addr, P1]), ok = gen_udp:connect(S2, Addr, P1), ?P("try send on second socket"), @@ -2616,6 +2639,10 @@ do_simple_sockaddr_send_recv(#{family := _Fam} = SockAddr, _) -> ?P("[server] send failed: ~p", [Reason1]), exit({skip, Reason1}); + {error, enetunreach = Reason1} -> + ?P("[server] send failed: ~p", + [Reason1]), + exit({skip, Reason1}); {error, Reason1} -> exit({send_failed, Reason1}) end @@ -2641,6 +2668,10 @@ do_simple_sockaddr_send_recv(#{family := _Fam} = SockAddr, _) -> ?P("[server] send failed: ~p", [Reason2]), exit({skip, Reason2}); + {error, enetunreach = Reason2} -> + ?P("[server] send failed: ~p", + [Reason2]), + exit({skip, Reason2}); {error, Reason2} -> exit({send_failed, Reason2}) end diff --git a/lib/kernel/test/inet_SUITE.erl b/lib/kernel/test/inet_SUITE.erl index 6298130a09..9061b67be1 100644 --- a/lib/kernel/test/inet_SUITE.erl +++ b/lib/kernel/test/inet_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 1997-2022. All Rights Reserved. +%% Copyright Ericsson AB 1997-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ t_gethostbyaddr/0, t_gethostbyaddr/1, t_getaddr/0, t_getaddr/1, - t_gethostbyname/0, t_gethostbyname/1, + t_gethostbyname/0, t_gethostbyname/1, t_gethostbyname_empty/1, t_gethostbyaddr_v6/0, t_gethostbyaddr_v6/1, t_getaddr_v6/0, t_getaddr_v6/1, t_gethostbyname_v6/0, t_gethostbyname_v6/1, @@ -70,7 +70,7 @@ suite() -> all() -> [ - t_gethostbyaddr, t_gethostbyname, t_getaddr, + t_gethostbyaddr, t_gethostbyname, t_gethostbyname_empty, t_getaddr, t_gethostbyaddr_v6, t_gethostbyname_v6, t_getaddr_v6, ipv4_to_ipv6, host_and_addr, is_ip_address, {group, parse}, t_gethostnative, gethostnative_parallell, cname_loop, @@ -367,6 +367,18 @@ do_gethostbyname(Config) when is_list(Config) -> {error,nxdomain} = inet:gethostbyname(IP_46_Str), ok. + +t_gethostbyname_empty(Config) when is_list(Config) -> + element(1, os:type()) =:= unix andalso + begin + {error,nxdomain} = inet:gethostbyname(""), + {error,nxdomain} = inet:gethostbyname('') + end, + {error,nxdomain} = inet:gethostbyname("."), + {error,nxdomain} = inet:gethostbyname('.'), + ok. + + t_gethostbyname_v6() -> required(v6). %% Test the inet:gethostbyname/1 inet6 function. t_gethostbyname_v6(Config) when is_list(Config) -> diff --git a/lib/kernel/test/logger_disk_log_h_SUITE.erl b/lib/kernel/test/logger_disk_log_h_SUITE.erl index 08908b8b7a..fab125e5ae 100644 --- a/lib/kernel/test/logger_disk_log_h_SUITE.erl +++ b/lib/kernel/test/logger_disk_log_h_SUITE.erl @@ -674,7 +674,7 @@ sync(Config) -> check_tracer(100), ok. sync(cleanup,_Config) -> - dbg:stop_clear(), + dbg:stop(), logger:remove_handler(?MODULE). disk_log_wrap(Config) -> @@ -720,7 +720,7 @@ disk_log_wrap(Config) -> %% wait for trace messages timer:sleep(1000), - dbg:stop_clear(), + dbg:stop(), Received = lists:flatmap(fun({trace,_M,handle_info, [_,{disk_log,_Node,_Name,What},_]}) -> [{trace,What}]; @@ -732,7 +732,7 @@ disk_log_wrap(Config) -> ok. disk_log_wrap(cleanup,_Config) -> - dbg:stop_clear(), + dbg:stop(), logger:remove_handler(?MODULE). disk_log_full(Config) -> @@ -766,7 +766,7 @@ disk_log_full(Config) -> %% wait for trace messages timer:sleep(2000), - dbg:stop_clear(), + dbg:stop(), Received = lists:flatmap(fun({trace,_M,handle_info, [_,{disk_log,_Node,_Name,What},_]}) -> [{trace,What}]; @@ -782,7 +782,7 @@ disk_log_full(Config) -> %% {trace,{error_status,{error,{full,_}}}}] = Received, ok. disk_log_full(cleanup, _Config) -> - dbg:stop_clear(), + dbg:stop(), logger:remove_handler(?MODULE). disk_log_events(_Config) -> @@ -816,7 +816,7 @@ disk_log_events(_Config) -> [whereis(h_proc_name()) ! E || E <- Events], %% wait for trace messages timer:sleep(2000), - dbg:stop_clear(), + dbg:stop(), Received = lists:map(fun({trace,_M,handle_info, [_,Got,_]}) -> Got end, test_server:messages_get()), @@ -828,7 +828,7 @@ disk_log_events(_Config) -> end, Received), ok. disk_log_events(cleanup, _Config) -> - dbg:stop_clear(), + dbg:stop(), logger:remove_handler(?MODULE). write_failure(Config) -> @@ -1603,7 +1603,7 @@ tpl([{{M,F,A},MS}|Trace]) -> {_,_,1} -> ok; _ -> - dbg:stop_clear(), + dbg:stop(), throw({skip,"Can't trace "++atom_to_list(M)++":"++ atom_to_list(F)++"/"++integer_to_list(A)}) end, @@ -1636,13 +1636,13 @@ maybe_tracer_done(Pid,Expected,Got,Caller) -> check_tracer(T) -> receive tracer_done -> - dbg:stop_clear(), + dbg:stop(), ok; {tracer_got_unexpected,Got,Expected} -> - dbg:stop_clear(), + dbg:stop(), ct:fail({tracer_got_unexpected,Got,Expected}) after T -> - dbg:stop_clear(), + dbg:stop(), ct:fail({timeout,tracer}) end. diff --git a/lib/kernel/test/logger_std_h_SUITE.erl b/lib/kernel/test/logger_std_h_SUITE.erl index ead4418d0d..88aac32f6f 100644 --- a/lib/kernel/test/logger_std_h_SUITE.erl +++ b/lib/kernel/test/logger_std_h_SUITE.erl @@ -2219,7 +2219,7 @@ tpl([]) -> ok. stop_clear() -> - dbg:stop_clear(), + dbg:stop(), %% Remove tracer from all processes in order to eliminate %% race conditions. erlang:trace(all,false,[all]). diff --git a/lib/kernel/test/logger_stress_SUITE.erl b/lib/kernel/test/logger_stress_SUITE.erl index 7fe12ca823..9209026322 100644 --- a/lib/kernel/test/logger_stress_SUITE.erl +++ b/lib/kernel/test/logger_stress_SUITE.erl @@ -343,7 +343,7 @@ cascade({PNode,PMFA,_PStatProcs},{CNode,CMFA,_CStatProcs},TestFun) -> after TO -> All = ets:lookup_element(Tab,producer,2), Written = ets:lookup_element(Tab,consumer,2), - dbg:stop_clear(), + dbg:stop(), ?COLLECT_STATS(All, [{PNode,P,Id} || {Id,P} <- _PStatProcs] ++ [{CNode,P,Id} || {Id,P} <- _CStatProcs]), diff --git a/lib/kernel/test/socket_SUITE.erl b/lib/kernel/test/socket_SUITE.erl index 62fcd6cfb2..196af34521 100644 --- a/lib/kernel/test/socket_SUITE.erl +++ b/lib/kernel/test/socket_SUITE.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2018-2022. All Rights Reserved. +%% Copyright Ericsson AB 2018-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. @@ -744,8 +744,11 @@ -define(TPP_LARGE_NUM, 50). -define(TPP_NUM(Config, Base), (Base) div lookup(kernel_factor, 1, Config)). +-define(WINDOWS, {win32,nt}). + -define(TTEST_RUNTIME, ?SECS(1)). -define(TTEST_MIN_FACTOR, 3). +-define(TTEST_MIN_FACTOR_WIN, ?TTEST_MIN_FACTOR-1). -define(TTEST_DEFAULT_SMALL_MAX_OUTSTANDING, 50). -define(TTEST_DEFAULT_MEDIUM_MAX_OUTSTANDING, ?TTEST_MK_DEFAULT_MAX_OUTSTANDING( @@ -1404,7 +1407,12 @@ traffic_pp_sendmsg_recvmsg_cases() -> %% No point in running these cases unless the machine is %% reasonably fast. ttest_condition(Config) -> + OsType = os:type(), case ?config(kernel_factor, Config) of + Factor when (OsType =:= ?WINDOWS) andalso + is_integer(Factor) andalso + (Factor =< ?TTEST_MIN_FACTOR_WIN) -> + ok; Factor when is_integer(Factor) andalso (Factor =< ?TTEST_MIN_FACTOR) -> ok; Factor when is_integer(Factor) -> @@ -3492,7 +3500,10 @@ api_b_send_and_recv_seqpL(_Config) when is_list(_Config) -> api_b_sendmsg_and_recvmsg_tcp4(_Config) when is_list(_Config) -> ?TT(?SECS(10)), tc_try(api_b_sendmsg_and_recvmsg_tcp4, - fun() -> has_support_ipv4() end, + fun() -> + is_not_windows(), + has_support_ipv4() + end, fun() -> Send = fun(Sock, Data) -> Msg = #{iov => [Data]}, @@ -6926,7 +6937,8 @@ api_a_connect_tcp(InitState) -> {ok, State#{asynch_tag => select, connect_tag => ST}}; - {completion, {completion_info, CT, CompletionRef}} + {completion, + {completion_info, CT, CompletionRef}} when SR =:= nowait -> ?SEV_IPRINT("completion nowait ->" "~n tag: ~p" @@ -6935,7 +6947,8 @@ api_a_connect_tcp(InitState) -> {ok, State#{asynch_tag => completion, connect_tag => CT, connect_ref => CompletionRef}}; - {completion, {completion_info, CT, CR}} + {completion, + {completion_info, CT, CR}} when is_reference(CR) -> ?SEV_IPRINT("completion ref ->" "~n tag: ~p" @@ -7988,7 +8001,10 @@ api_a_sendmsg_and_recvmsg_tcp4(Config) when is_list(Config) -> ?TT(?SECS(10)), Nowait = nowait(Config), tc_try(api_a_sendmsg_and_recvmsg_tcp4, - fun() -> has_support_ipv4() end, + fun() -> + is_not_windows(), + has_support_ipv4() + end, fun() -> Send = fun(Sock, Data) -> Msg = #{iov => [Data]}, @@ -9488,6 +9504,7 @@ api_a_recv_cancel_tcp(InitState) -> cmd => fun(#{tester := Tester} = _State) -> ?SEV_AWAIT_CONTINUE(Tester, tester, recv) end}, + #{desc => "try recv request (with nowait, expect select|completion)", cmd => fun(#{csock := Sock, recv := Recv, @@ -9506,13 +9523,15 @@ api_a_recv_cancel_tcp(InitState) -> "~n Ref: ~p", [T, Ref]), {ok, State#{recv_select_info => SI}}; - {completion, {completion_info, T, R} = CI} + {completion, + {completion_info, T, R} = CI} when Ref =:= nowait -> ?SEV_IPRINT("recv completion nowait: " "~n Tag: ~p" "~n Ref: ~p", [T, R]), {ok, State#{recv_completion_info => CI}}; - {completion, {completion_info, T, Ref} = CI} + {completion, + {completion_info, T, Ref} = CI} when is_reference(Ref) -> ?SEV_IPRINT("recv completion ref: " "~n Tag: ~p" @@ -10913,6 +10932,7 @@ api_a_mrecvmsg_cancel_tcp4(Config) when is_list(Config) -> Nowait = nowait(Config), tc_try(?FUNCTION_NAME, fun() -> + is_not_windows(), has_support_ipv4() end, fun() -> @@ -10937,7 +10957,10 @@ api_a_mrecvmsg_cancel_tcp6(Config) when is_list(Config) -> ?TT(?SECS(20)), Nowait = nowait(Config), tc_try(?FUNCTION_NAME, - fun() -> has_support_ipv6() end, + fun() -> + is_not_windows(), + has_support_ipv6() + end, fun() -> Recv = fun(Sock) -> socket:recvmsg(Sock, Nowait) @@ -14034,6 +14057,10 @@ api_opt_sock_broadcast() -> ?SEV_IPRINT("Expected Success: " "broadcast message sent"), ok; + {error, eaddrnotavail = Reason} -> + ?SEV_EPRINT("Unexpected Failure: ~p => SKIP", + [Reason]), + {skip, Reason}; {error, eacces = Reason} -> ?SEV_EPRINT("Unexpected Failure: ~p => SKIP", [Reason]), @@ -21126,6 +21153,37 @@ api_opt_ip_recvttl_udp(InitState) -> {skip, ?F("Cannot send with TTL: ~p", [Info])}; + {error, + {completion_status, + #{file := File, + function := Function, + line := Line, + raw_info := RawInfo, + info := invalid_parameter = Info}}} -> + %% IF we can't send it the test will not work + ?SEV_EPRINT("Cannot send TTL: " + "~p => SKIP: " + "~n File: ~s" + "~n Function: ~s" + "~n Line: ~p" + "~n Raw Info: ~p", + [Info, + File, Function, Line, + RawInfo]), + (catch socket:close(SSock)), + (catch socket:close(DSock)), + {skip, + ?F("Cannot send with TTL: ~p", [Info])}; + {error, {completion_status, + invalid_parameter = Info}} -> + %% IF we can't send it the test will not work + ?SEV_EPRINT("Cannot send TTL: " + "~p => SKIP", [Info]), + (catch socket:close(SSock)), + (catch socket:close(DSock)), + {skip, + ?F("Cannot send with TTL: ~p", [Info])}; + {error, _Reason} = ERROR -> ERROR end @@ -23420,7 +23478,7 @@ api_opt_ipv6_tclass_udp(InitState) -> #{desc => "send req (to dst) (w explicit tc = 1)", cmd => fun(#{sock_src := Sock, sa_dst := Dst, send := Send}) -> case Send(Sock, ?BASIC_REQ, Dst, 1) of - {error, + {error, {get_overlapped_result, #{file := File, function := Function, @@ -23449,6 +23507,35 @@ api_opt_ipv6_tclass_udp(InitState) -> {skip, ?F("Cannot send with TClass: ~p", [Info])}; + {error, + {completion_status, + #{file := File, + function := Function, + line := Line, + raw_info := RawInfo, + info := invalid_parameter = Info}}} -> + %% IF we can't send it the test will not work + ?SEV_EPRINT("Cannot send TClass: " + "~p => SKIP: " + "~n File: ~s" + "~n Function: ~s" + "~n Line: ~p" + "~n Raw Info: ~p", + [Info, + File, Function, Line, + RawInfo]), + (catch socket:close(Sock)), + {skip, + ?F("Cannot send with TClass: ~p", [Info])}; + {error, {completion_status, + invalid_parameter = Info}} -> + %% IF we can't send it the test will not work + ?SEV_EPRINT("Cannot send TClass: " + "~p => SKIP", [Info]), + (catch socket:close(Sock)), + {skip, + ?F("Cannot send with TClass: ~p", [Info])}; + Other -> Other end @@ -32985,8 +33072,11 @@ sc_lc_receive_response_udp(InitState) -> sc_lc_recvmsg_response_tcp4(_Config) when is_list(_Config) -> ?TT(?SECS(10)), - tc_try(sc_lc_recvmsg_response_tcp4, - fun() -> has_support_ipv4() end, + tc_try(?FUNCTION_NAME, + fun() -> + is_not_windows(), + has_support_ipv4() + end, fun() -> Recv = fun(Sock) -> socket:recvmsg(Sock) end, InitState = #{domain => inet, @@ -33003,8 +33093,11 @@ sc_lc_recvmsg_response_tcp4(_Config) when is_list(_Config) -> sc_lc_recvmsg_response_tcp6(_Config) when is_list(_Config) -> ?TT(?SECS(10)), - tc_try(sc_recvmsg_response_tcp6, - fun() -> has_support_ipv6() end, + tc_try(?FUNCTION_NAME, + fun() -> + is_not_windows(), + has_support_ipv6() + end, fun() -> Recv = fun(Sock) -> socket:recvmsg(Sock) end, InitState = #{domain => inet6, @@ -36503,7 +36596,10 @@ traffic_send_and_recv_counters_tcpL(_Config) when is_list(_Config) -> traffic_sendmsg_and_recvmsg_counters_tcp4(_Config) when is_list(_Config) -> ?TT(?SECS(15)), tc_try(traffic_sendmsg_and_recvmsg_counters_tcp4, - fun() -> has_support_ipv4() end, + fun() -> + is_not_windows(), + has_support_ipv4() + end, fun() -> InitState = #{domain => inet, proto => tcp, @@ -36532,7 +36628,10 @@ traffic_sendmsg_and_recvmsg_counters_tcp4(_Config) when is_list(_Config) -> traffic_sendmsg_and_recvmsg_counters_tcp6(_Config) when is_list(_Config) -> ?TT(?SECS(15)), tc_try(traffic_sendmsg_and_recvmsg_counters_tcp6, - fun() -> has_support_ipv6() end, + fun() -> + is_not_windows(), + has_support_ipv6() + end, fun() -> InitState = #{domain => inet6, proto => tcp, @@ -48842,7 +48941,7 @@ otp16359_maccept_tcp(InitState) -> %% This test case is to verify that we do not leak monitors. otp18240_accept_mon_leak_tcp4(Config) when is_list(Config) -> - ?TT(?SECS(10)), + ?TT(?SECS(30)), tc_try(?FUNCTION_NAME, fun() -> has_support_ipv4() end, fun() -> @@ -48857,7 +48956,7 @@ otp18240_accept_mon_leak_tcp4(Config) when is_list(Config) -> %% This test case is to verify that we do not leak monitors. otp18240_accept_mon_leak_tcp6(Config) when is_list(Config) -> - ?TT(?SECS(10)), + ?TT(?SECS(30)), tc_try(?FUNCTION_NAME, fun() -> has_support_ipv6() end, fun() -> @@ -48883,26 +48982,42 @@ otp18240_accept_tcp(#{domain := Domain, otp18240_await_acceptor(Pid, Mon) -> receive - {'DOWN', Mon, process, Pid, Info} -> - i("acceptor terminated: " - "~n ~p", [Info]) + {'DOWN', Mon, process, Pid, ok} -> + i("acceptor successfully terminated"), + ok; + {'DOWN', Mon, process, Pid, {skip, _} = SKIP} -> + i("acceptor successfully terminated"), + exit(SKIP); + {'DOWN', Mon, process, Pid, Info} -> + i("acceptor unexpected termination: " + "~n ~p", [Info]), + exit({unexpected_result, Info}) after 5000 -> - i("acceptor info" + i("acceptor process (~p) info" "~n Refs: ~p" "~n Info: ~p", - [monitored_by(Pid), erlang:process_info(Pid)]), + [Pid, monitored_by(Pid), erlang:process_info(Pid)]), otp18240_await_acceptor(Pid, Mon) end. otp18240_acceptor(Parent, Domain, Proto, NumSocks) -> i("[acceptor] begin with: " + "~n Parent: ~p" "~n Domain: ~p" - "~n Protocol: ~p", [Domain, Proto]), + "~n Protocol: ~p", [Parent, Domain, Proto]), MonitoredBy0 = monitored_by(), - {ok, LSock} = socket:open(Domain, stream, Proto, - #{use_registry => false}), - ok = socket:bind(LSock, #{family => Domain, port => 0, addr => any}), + ?SLEEP(?SECS(5)), + Addr = case ?LIB:which_local_host_info(Domain) of + {ok, #{addr := A}} -> + A; + {error, Reason} -> + exit({skip, Reason}) + end, + {ok, LSock} = socket:open(Domain, stream, Proto, + #{use_registry => false}), + ok = socket:bind(LSock, #{family => Domain, addr => Addr, port => 0}), ok = socket:listen(LSock, NumSocks), + ?SLEEP(?SECS(5)), MonitoredBy1 = monitored_by(), i("[acceptor]: listen socket created" "~n 'Montored By' before listen socket: ~p" @@ -48922,7 +49037,7 @@ otp18240_acceptor(Parent, Domain, Proto, NumSocks) -> _Clients = [spawn_link(fun() -> otp18240_client(CID, Domain, Proto, - Port) + Addr, Port) end) || CID <- lists:seq(1, NumSocks)], i("[acceptor] accept ~w connections", [NumSocks]), @@ -48956,26 +49071,49 @@ otp18240_acceptor(Parent, Domain, Proto, NumSocks) -> end. -otp18240_client(ID, Domain, Proto, PortNo) -> +otp18240_client(ID, Domain, Proto, Addr, PortNo) -> i("[connector ~w] try create connector socket", [ID]), {ok, Sock} = socket:open(Domain, stream, Proto, #{use_registry => false}), - ok = socket:bind(Sock, #{family => Domain, port => 0, addr => any}), + ok = socket:bind(Sock, #{family => Domain, addr => Addr, port => 0}), %% ok = socket:setopt(Sock, otp, debug, true), i("[connector ~w] try connect", [ID]), - ok = socket:connect(Sock, #{family => Domain, addr => any, port => PortNo}), - i("[connector ~w] connected - now try recv", [ID]), - case socket:recv(Sock) of - {ok, Data} -> - i("[connector ~w] received unexpected data: " - "~n ~p", [ID, Data]), - (catch socket:close(Sock)), - exit('unexpected data'); - {error, closed} -> - i("[connector ~w] expected socket close", [ID]); - {error, Reason} -> - i("[connector ~w] unexpected error when reading: " - "~n ~p", [ID, Reason]), - (catch socket:close(Sock)) + case socket:connect(Sock, + #{family => Domain, addr => Addr, port => PortNo}) of + ok -> + i("[connector ~w] connected - now try recv", [ID]), + case socket:recv(Sock) of + {ok, Data} -> + i("[connector ~w] received unexpected data: " + "~n ~p", [ID, Data]), + (catch socket:close(Sock)), + exit('unexpected data'); + {error, closed} -> + i("[connector ~w] expected socket close", [ID]); + {error, Reason} -> + i("[connector ~w] unexpected error when reading: " + "~n ~p", [ID, Reason]), + (catch socket:close(Sock)) + end; + {error, {completion_status, #{info := invalid_netname = R} = Reason}} -> + i("[connector ~w] failed connecting: " + "~n ~p", [ID, Reason]), + (catch socket:close(Sock)), + exit({skip, R}); + {error, {completion_status, invalid_netname = Reason}} -> + i("[connector ~w] failed connecting: " + "~n ~p", [ID, Reason]), + (catch socket:close(Sock)), + exit({skip, Reason}); + {error, enetunreach = Reason} -> + i("[connector ~w] failed connecting: " + "~n ~p", [ID, Reason]), + (catch socket:close(Sock)), + exit({skip, Reason}); + + {error, Reason} -> + i("[connector ~w] failed connecting: " + "~n ~p", [ID, Reason]), + (catch socket:close(Sock)) end, i("[connector ~w] done", [ID]), ok. diff --git a/lib/kernel/test/socket_test_evaluator.erl b/lib/kernel/test/socket_test_evaluator.erl index 962c47a64e..49b529461f 100644 --- a/lib/kernel/test/socket_test_evaluator.erl +++ b/lib/kernel/test/socket_test_evaluator.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2018-2022. All Rights Reserved. +%% Copyright Ericsson AB 2018-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/lib/kernel/test/socket_test_lib.erl b/lib/kernel/test/socket_test_lib.erl index 21024fd6d2..da36943461 100644 --- a/lib/kernel/test/socket_test_lib.erl +++ b/lib/kernel/test/socket_test_lib.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2018-2022. All Rights Reserved. +%% Copyright Ericsson AB 2018-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. diff --git a/lib/kernel/test/socket_test_ttest_tcp_socket.erl b/lib/kernel/test/socket_test_ttest_tcp_socket.erl index 467f54113a..7a084a445d 100644 --- a/lib/kernel/test/socket_test_ttest_tcp_socket.erl +++ b/lib/kernel/test/socket_test_ttest_tcp_socket.erl @@ -1,7 +1,7 @@ %% %% %CopyrightBegin% %% -%% Copyright Ericsson AB 2018-2022. All Rights Reserved. +%% Copyright Ericsson AB 2018-2023. All Rights Reserved. %% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. |