File 1117-ssl-Add-whitebox-test-for-supervisor-shutdown.patch of Package erlang

From 63c44ba0c3bddd7ed68a8de1d39c0a89159eca1b Mon Sep 17 00:00:00 2001
From: Ingela Anderton Andin <ingela@erlang.org>
Date: Wed, 23 Oct 2024 15:55:37 +0200
Subject: [PATCH 2/2] ssl: Add whitebox test for supervisor shutdown

---
 lib/ssl/test/tls_api_SUITE.erl | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/lib/ssl/test/tls_api_SUITE.erl b/lib/ssl/test/tls_api_SUITE.erl
index ccba623861..93ce7c04e5 100644
--- a/lib/ssl/test/tls_api_SUITE.erl
+++ b/lib/ssl/test/tls_api_SUITE.erl
@@ -62,6 +62,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,
@@ -161,6 +163,7 @@ api_tests() ->
      tls_shutdown_write,
      tls_shutdown_both,
      tls_shutdown_error,
+     tls_sup_shutdown,
      tls_password_correct,
      tls_password_incorrect,
      tls_password_badarg,
@@ -784,6 +787,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"}].
-- 
2.43.0

openSUSE Build Service is sponsored by