diff options
author | Loïc Hoguin <[email protected]> | 2018-11-20 16:25:11 +0100 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2018-11-20 16:25:11 +0100 |
commit | 18ba3c7cff00dafd3a773c9ab487bcf0f8d03914 (patch) | |
tree | e6c50ede806d3c3deb29616a2e14459a462b44b2 /test/sys_SUITE.erl | |
parent | 2915c6d98caeaf031f944927941df8668eb20b5a (diff) | |
download | cowboy-18ba3c7cff00dafd3a773c9ab487bcf0f8d03914.tar.gz cowboy-18ba3c7cff00dafd3a773c9ab487bcf0f8d03914.tar.bz2 cowboy-18ba3c7cff00dafd3a773c9ab487bcf0f8d03914.zip |
Silence expected warnings for messages from unknown processes
Diffstat (limited to 'test/sys_SUITE.erl')
-rw-r--r-- | test/sys_SUITE.erl | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/test/sys_SUITE.erl b/test/sys_SUITE.erl index 6909f60..e21669b 100644 --- a/test/sys_SUITE.erl +++ b/test/sys_SUITE.erl @@ -31,10 +31,9 @@ groups() -> [{sys, [parallel], ct_helper:all(?MODULE)}]. init_per_suite(Config) -> - ct:print("This test suite will produce error reports about " - "EXIT signals for unknown processes."), ProtoOpts = #{ - env => #{dispatch => init_dispatch(Config)} + env => #{dispatch => init_dispatch(Config)}, + logger => ?MODULE }, %% Clear listener. {ok, _} = cowboy:start_clear(clear, [{port, 0}], ProtoOpts), @@ -61,6 +60,16 @@ init_dispatch(_) -> {"/ws", ws_echo, []} ]}]). +%% Logger function silencing the expected warnings. + +error(Format, Args) -> + error_logger:error_msg(Format, Args). + +warning("Received EXIT signal " ++ _, [{'EXIT', _, {shutdown, ?MODULE}}|_]) -> + ok; +warning(Format, Args) -> + error_logger:warning_msg(Format, Args). + %% proc_lib. proc_lib_initial_call_clear(Config) -> @@ -318,7 +327,7 @@ trap_exit_parent_exit_h1(Config) -> timer:sleep(100), Pid = get_remote_pid_tcp(Socket), Parent = get_parent_pid(Pid), - Pid ! {'EXIT', Parent, shutdown}, + Pid ! {'EXIT', Parent, {shutdown, ?MODULE}}, {error, closed} = gen_tcp:recv(Socket, 0, 1000), true = is_process_down(Pid), ok. @@ -333,7 +342,7 @@ trap_exit_parent_exit_h2(Config) -> timer:sleep(100), Pid = get_remote_pid_tls(Socket), Parent = get_parent_pid(Pid), - Pid ! {'EXIT', Parent, shutdown}, + Pid ! {'EXIT', Parent, {shutdown, ?MODULE}}, {error, closed} = ssl:recv(Socket, 0, 1000), true = is_process_down(Pid), ok. @@ -357,7 +366,7 @@ trap_exit_parent_exit_ws(Config) -> timer:sleep(100), Pid = get_remote_pid_tcp(Socket), Parent = get_parent_pid(Pid), - Pid ! {'EXIT', Parent, shutdown}, + Pid ! {'EXIT', Parent, {shutdown, ?MODULE}}, {error, closed} = gen_tcp:recv(Socket, 0, 1000), true = is_process_down(Pid), ok. @@ -373,7 +382,7 @@ trap_exit_parent_exit_loop(Config) -> timer:sleep(100), Parent = get_remote_pid_tcp(Socket), [{_, Pid, _, _}] = supervisor:which_children(Parent), - Pid ! {'EXIT', Parent, shutdown}, + Pid ! {'EXIT', Parent, {shutdown, ?MODULE}}, %% We exit normally but didn't send a response. {ok, "HTTP/1.1 204 "} = gen_tcp:recv(Socket, 13, 1000), true = is_process_down(Pid), @@ -386,7 +395,7 @@ trap_exit_other_exit_h1(Config) -> [{active, false}]), timer:sleep(100), Pid = get_remote_pid_tcp(Socket), - Pid ! {'EXIT', self(), shutdown}, + Pid ! {'EXIT', self(), {shutdown, ?MODULE}}, ok = gen_tcp:send(Socket, "GET / HTTP/1.1\r\n" "Host: localhost\r\n" @@ -407,7 +416,7 @@ trap_exit_other_exit_h2(Config) -> {ok, << 0:24, 4:8, 1:8, 0:32 >>} = ssl:recv(Socket, 9, 1000), timer:sleep(100), Pid = get_remote_pid_tls(Socket), - Pid ! {'EXIT', self(), shutdown}, + Pid ! {'EXIT', self(), {shutdown, ?MODULE}}, %% Send a HEADERS frame as a request. {HeadersBlock, _} = cow_hpack:encode([ {<<":method">>, <<"GET">>}, @@ -439,7 +448,7 @@ trap_exit_other_exit_ws(Config) -> {ok, {http_response, {1, 1}, 101, _}, _} = erlang:decode_packet(http, Handshake, []), timer:sleep(100), Pid = get_remote_pid_tcp(Socket), - Pid ! {'EXIT', self(), shutdown}, + Pid ! {'EXIT', self(), {shutdown, ?MODULE}}, %% The process stays alive. {error, timeout} = gen_tcp:recv(Socket, 0, 1000), true = is_process_alive(Pid), @@ -456,7 +465,7 @@ trap_exit_other_exit_loop(Config) -> timer:sleep(100), Parent = get_remote_pid_tcp(Socket), [{_, Pid, _, _}] = supervisor:which_children(Parent), - Pid ! {'EXIT', self(), shutdown}, + Pid ! {'EXIT', self(), {shutdown, ?MODULE}}, %% The process stays alive. {ok, "HTTP/1.1 299 "} = gen_tcp:recv(Socket, 13, 1000), true = is_process_alive(Pid), @@ -889,7 +898,7 @@ sys_terminate_h1(Config) -> {ok, Socket} = gen_tcp:connect("localhost", config(clear_port, Config), [{active, false}]), timer:sleep(100), Pid = get_remote_pid_tcp(Socket), - ok = sys:terminate(Pid, {shutdown, test}), + ok = sys:terminate(Pid, {shutdown, ?MODULE}), {error, closed} = gen_tcp:recv(Socket, 0, 500), ok. @@ -901,7 +910,7 @@ sys_terminate_h2(Config) -> {ok, <<_,_,_,4,_/bits>>} = ssl:recv(Socket, 0, 1000), timer:sleep(100), Pid = get_remote_pid_tls(Socket), - ok = sys:terminate(Pid, {shutdown, test}), + ok = sys:terminate(Pid, {shutdown, ?MODULE}), {error, closed} = ssl:recv(Socket, 0, 500), ok. @@ -922,7 +931,7 @@ sys_terminate_ws(Config) -> {ok, {http_response, {1, 1}, 101, _}, _} = erlang:decode_packet(http, Handshake, []), timer:sleep(100), Pid = get_remote_pid_tcp(Socket), - ok = sys:terminate(Pid, {shutdown, test}), + ok = sys:terminate(Pid, {shutdown, ?MODULE}), {error, closed} = gen_tcp:recv(Socket, 0, 500), ok. @@ -937,7 +946,7 @@ sys_terminate_loop(Config) -> SupPid = get_remote_pid_tcp(Socket), [{_, Pid, _, _}] = supervisor:which_children(SupPid), %% We stop the process normally and therefore get a 204. - ok = sys:terminate(Pid, {shutdown, test}), + ok = sys:terminate(Pid, {shutdown, ?MODULE}), {ok, "HTTP/1.1 204 "} = gen_tcp:recv(Socket, 13, 500), ok. |