summaryrefslogtreecommitdiff
path: root/lib/kernel
diff options
context:
space:
mode:
authorMicael Karlberg <bmk@erlang.org>2021-04-30 16:01:29 +0200
committerMicael Karlberg <bmk@erlang.org>2021-04-30 16:01:29 +0200
commit34c0932472c1834152291f21c0faff73f7f1e41f (patch)
treebdf06c44f2e8741d2b118fa296f973184e2b8b76 /lib/kernel
parentaa727629cc63d7f7934cc5c08e9e5f74d31791bd (diff)
parent2dbad39ff739c857bf7b7553b8a3ea9d8e8c7d12 (diff)
downloaderlang-34c0932472c1834152291f21c0faff73f7f1e41f.tar.gz
Merge branch 'bmk/kernel/20210426/test_tweaking'
Diffstat (limited to 'lib/kernel')
-rw-r--r--lib/kernel/test/gen_tcp_misc_SUITE.erl47
-rw-r--r--lib/kernel/test/kernel_test_lib.hrl2
-rw-r--r--lib/kernel/test/socket_SUITE.erl46
-rw-r--r--lib/kernel/test/socket_test_lib.erl14
4 files changed, 80 insertions, 29 deletions
diff --git a/lib/kernel/test/gen_tcp_misc_SUITE.erl b/lib/kernel/test/gen_tcp_misc_SUITE.erl
index 8cd7d1f21e..0a825d2edf 100644
--- a/lib/kernel/test/gen_tcp_misc_SUITE.erl
+++ b/lib/kernel/test/gen_tcp_misc_SUITE.erl
@@ -4659,10 +4659,15 @@ do_accept_system_limit(Config) ->
{error, eaddrnotavail = Reason} ->
?SKIPT(listen_failed_str(Reason))
end,
- {ok, TcpPort} = inet:port(LS),
+ {ok, {Addr, Port}} = inet:sockname(LS),
+ ?P("listen socket \"bound\" to:"
+ "~n Address: ~p"
+ "~n Port: ~p", [Addr, Port]),
Me = self(),
?P("create connector"),
- Connector = spawn_link(fun () -> connector(Config, TcpPort, Me) end),
+ Connector = spawn_link(fun() ->
+ connector(Config, Port, Me)
+ end),
?P("sync with connector (~p)", [Connector]),
receive {Connector, sync} -> Connector ! {self(), continue} end,
?P("begin accepting"),
@@ -4679,33 +4684,43 @@ acceptor(Connector, LS, GotSL, A) ->
{error, eaddrnotavail = Reason} ->
?SKIPE(accept_failed_str(Reason));
{error, system_limit} ->
- ?P("acceptor: system limit => *almost* done (~w)", [length(A)]),
+ ?P("acceptor: "
+ "system limit => *almost* done (~w)", [length(A)]),
acceptor(Connector, LS, true, A);
{error, timeout} when GotSL ->
?P("acceptor: timeout (with system limit) => done (~w)",
- [length(A)]),
+ [length(A)]),
ok;
{error, timeout} ->
+ ?P("acceptor: timeout *without* system limit => failure"
+ "~n Number of Accepted: ~w",
+ [length(A)]),
error
end.
-connector(Config, TcpPort, Tester) ->
+connector(Config, AccPort, Tester) ->
?P("[connector] start"),
ManyPorts = open_ports([]),
+ ?P("[connector] length(ManyPorts): ~p", [length(ManyPorts)]),
Tester ! {self(), sync},
- ?P("[connector] sync with tester (~p)", [Tester]),
+ ?P("[connector] await continute from tester (~p)", [Tester]),
receive {Tester, continue} -> timer:sleep(100) end,
?P("[connector] begin connecting"),
- ConnF = fun (Port) ->
- case (catch ?CONNECT(Config, {127,0,0,1}, TcpPort, [])) of
- {ok, Sock} ->
- Sock;
- {error, eaddrnotavail = Reason} ->
- ?SKIPE(connect_failed_str(Reason));
- _Error ->
- port_close(Port)
- end
- end,
+ ConnF =
+ fun(Port) ->
+ case (catch ?CONNECT(Config, {127,0,0,1}, AccPort)) of
+ {ok, Sock} ->
+ ?P("[connector] success: "
+ "~n ~p", [Sock]),
+ Sock;
+ {error, eaddrnotavail = Reason} ->
+ ?SKIPE(connect_failed_str(Reason));
+ _Error ->
+ ?P("[connector] failure: "
+ "~n ~p", [_Error]),
+ port_close(Port)
+ end
+ end,
R = [ConnF(Port) || Port <- lists:sublist(ManyPorts, 10)],
?P("[connector] await stop"),
receive stop -> ?P("[connector] stop (~w)", [length(R)]), R end.
diff --git a/lib/kernel/test/kernel_test_lib.hrl b/lib/kernel/test/kernel_test_lib.hrl
index 9dc99fdd22..3a8282971f 100644
--- a/lib/kernel/test/kernel_test_lib.hrl
+++ b/lib/kernel/test/kernel_test_lib.hrl
@@ -37,6 +37,8 @@
-define(LISTEN(C), ?LIB:listen(C, 0, [])).
-define(LISTEN(C, P), ?LIB:listen(C, P, [])).
-define(LISTEN(C, P, O), ?LIB:listen(C, P, O)).
+-define(CONNECT(__C__, __H__, __P__),
+ ?LIB:connect(__C__, __H__, __P__, [])).
-define(CONNECT(__C__, __H__, __P__, __O__),
?LIB:connect(__C__, __H__, __P__, __O__)).
-define(CONNECT(__C__, __H__, __P__, __O__, __T__),
diff --git a/lib/kernel/test/socket_SUITE.erl b/lib/kernel/test/socket_SUITE.erl
index 9efe99229a..b384809661 100644
--- a/lib/kernel/test/socket_SUITE.erl
+++ b/lib/kernel/test/socket_SUITE.erl
@@ -674,6 +674,8 @@
-define(TT(T), ct:timetrap(T)).
-define(F(F, A), ?LIB:f(F, A)).
+-define(P(F), ?LIB:print(F)).
+-define(P(F, A), ?LIB:print(F, A)).
-define(TPP_SMALL, lists:seq(1, 8)).
@@ -25352,10 +25354,24 @@ reg_s_single_open_and_close_and_count() ->
] ++
case SupportsSCTP of
true ->
- [
- {inet, seqpacket, sctp},
- {inet, seqpacket, sctp}
- ];
+ %% On some platforms this is not enough,
+ %% we need to actually check this "by doing it"...
+ ?P("test open sctp socket"),
+ case socket:open(inet,
+ seqpacket,
+ sctp,
+ #{use_registry => false}) of
+ {ok, S} ->
+ ?P("test open sctp socket: success"),
+ (catch socket:close(S)),
+ [
+ {inet, seqpacket, sctp},
+ {inet, seqpacket, sctp}
+ ];
+ {error, _} ->
+ ?P("test open sctp socket: failed"),
+ []
+ end;
false ->
[]
end ++
@@ -25365,10 +25381,24 @@ reg_s_single_open_and_close_and_count() ->
] ++
case SupportsSCTP andalso SupportsIPV6 of
true ->
- [
- {inet6, seqpacket, sctp},
- {inet6, seqpacket, sctp}
- ];
+ %% On some platforms this is not enough,
+ %% we need to actually check this "by doing it"...
+ ?P("test open sctp socket"),
+ case socket:open(inet6,
+ seqpacket,
+ sctp,
+ #{use_registry => false}) of
+ {ok, S6} ->
+ ?P("test open sctp socket: success"),
+ (catch socket:close(S6)),
+ [
+ {inet6, seqpacket, sctp},
+ {inet6, seqpacket, sctp}
+ ];
+ {error, _} ->
+ ?P("test open sctp socket: failed"),
+ []
+ end;
false ->
[]
end,
diff --git a/lib/kernel/test/socket_test_lib.erl b/lib/kernel/test/socket_test_lib.erl
index 01b69953bc..1991c3c28a 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-2020. All Rights Reserved.
+%% Copyright Ericsson AB 2018-2021. 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.
@@ -35,6 +35,7 @@
%% String and format
f/2,
+ print/1, print/2,
%% Generic 'has support' test function(s)
has_support_ipv6/0,
@@ -101,11 +102,7 @@ formated_timestamp() ->
format_timestamp({_N1, _N2, _N3} = TS) ->
{_Date, Time} = calendar:now_to_local_time(TS),
- %% {YYYY,MM,DD} = Date,
{Hour,Min,Sec} = Time,
- %% FormatTS =
- %% io_lib:format("~.4w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w.~w",
- %% [YYYY, MM, DD, Hour, Min, Sec, N3]),
FormatTS = io_lib:format("~.2.0w:~.2.0w:~.2.0w", [Hour, Min, Sec]),
lists:flatten(FormatTS).
@@ -116,6 +113,13 @@ f(F, A) ->
lists:flatten(io_lib:format(F, A)).
+print(F) ->
+ print(F, []).
+
+print(F, A) ->
+ io:format("~s ~p " ++ F ++ "~n", [formated_timestamp(), self() | A]).
+
+
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
has_support_ipv6() ->