From f04ca2a8671d96ad39d05fdb56f63f2986c5d32a Mon Sep 17 00:00:00 2001 From: Ingela Anderton Andin Date: Wed, 23 Oct 2024 15:55:37 +0200 Subject: [PATCH] ssl: Add whitebox test for supervisor shutdown --- lib/ssl/test/ssl_trace_SUITE.erl | 7 +++++-- lib/ssl/test/tls_api_SUITE.erl | 33 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/lib/ssl/test/ssl_trace_SUITE.erl b/lib/ssl/test/ssl_trace_SUITE.erl index 8fbc0b8efb4b..e8294dfd9ce6 100644 --- a/lib/ssl/test/ssl_trace_SUITE.erl +++ b/lib/ssl/test/ssl_trace_SUITE.erl @@ -204,9 +204,12 @@ tc_api_profile(Config) -> check_trace_map(Ref, TracesAfterConnect, UnhandledTraceCnt1), ssl_test_lib:close(Server), ssl_test_lib:close(Client), + %% terminate_alert will get called twice by both client and + %% server to strip away Details from {shutdown::Reason, Detatils} + %% before matching the Reason UnhandledTraceCnt2 = - #{call => 0, processed => no_trace_received, exception_from => 0, - return_from => 0}, + #{call => 2, processed => no_trace_received, exception_from => 0, + return_from => 2}, check_trace_map(Ref, TracesAfterDisconnect, UnhandledTraceCnt2), ssl_trace:stop(), ok. diff --git a/lib/ssl/test/tls_api_SUITE.erl b/lib/ssl/test/tls_api_SUITE.erl index c3992bfac063..04a1151f0481 100644 --- a/lib/ssl/test/tls_api_SUITE.erl +++ b/lib/ssl/test/tls_api_SUITE.erl @@ -63,6 +63,8 @@ tls_shutdown_both/1, tls_shutdown_error/0, tls_shutdown_error/1, + tls_sup_shutdown/0, + tls_sup_shutdown/1, tls_client_closes_socket/0, tls_client_closes_socket/1, tls_closed_in_active_once/0, @@ -164,6 +166,7 @@ api_tests() -> tls_shutdown_write, tls_shutdown_both, tls_shutdown_error, + tls_sup_shutdown, tls_password_correct, tls_password_incorrect, tls_password_badarg, @@ -782,6 +785,36 @@ tls_tcp_error_propagation_in_active_mode(Config) when is_list(Config) -> ssl_test_lib:check_result(Client, {ssl_closed, SslSocket}). +%%-------------------------------------------------------------------- +tls_sup_shutdown() -> + [{doc,"Test that terminate behaves correctly for exit(shutdown) as done by supervisor at application shutdown"}]. +tls_sup_shutdown(Config) when is_list(Config) -> + ClientOpts = ssl_test_lib:ssl_options(client_rsa_opts, Config), + ServerOpts = ssl_test_lib:ssl_options(server_rsa_opts, Config), + + {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config), + + Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0}, + {from, self()}, + {mfa, {?MODULE, receive_msg, []}}, + {options, ServerOpts}]), + Port = ssl_test_lib:inet_port(Server), + + {_, #sslsocket{pid=[Pid|_]}} = ssl_test_lib:start_client([return_socket, + {node, ClientNode}, {port, Port}, + {host, Hostname}, + {from, self()}, + {mfa, {ssl_test_lib, no_result, []}}, + {options, [{active, false} | ClientOpts]}]), + exit(Pid, shutdown), + + receive + {Server, {ssl_closed, _}} -> + ok; + Msg -> + ct:fail(Msg) + end. + %%-------------------------------------------------------------------- tls_reject_warning_alert_in_initial_hs() -> [{doc,"Test sending warning ALERT instead of client hello"}].