File 0970-ssh-escalate-sanity-related-test-skips.patch of Package erlang

From 2ff6e8730e17e53571adbb781d31b23c93756275 Mon Sep 17 00:00:00 2001
From: Jakub Witczak <kuba@erlang.org>
Date: Fri, 2 Feb 2024 16:56:20 +0100
Subject: [PATCH] ssh: escalate sanity related test skips

---
 lib/ssh/test/ssh_connection_SUITE.erl |  2 +-
 lib/ssh/test/ssh_test_lib.erl         | 26 +++++++++++++++++++++++---
 lib/ssh/test/ssh_to_openssh_SUITE.erl | 10 +++++++---
 3 files changed, 31 insertions(+), 7 deletions(-)

diff --git a/lib/ssh/test/ssh_connection_SUITE.erl b/lib/ssh/test/ssh_connection_SUITE.erl
index 5e426cd8fc..774133b284 100644
--- a/lib/ssh/test/ssh_connection_SUITE.erl
+++ b/lib/ssh/test/ssh_connection_SUITE.erl
@@ -228,7 +228,7 @@ init_per_testcase(_TestCase, Config) ->
     %% end_per_testcase will be run!
     end_per_testcase(any, Config),
     ssh:start(),
-    Config.
+    ssh_test_lib:verify_sanity_check(Config).
 
 end_per_testcase(_TestCase, _Config) ->
     ssh:stop().
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl
index f7355ba6a4..7839651e65 100644
--- a/lib/ssh/test/ssh_test_lib.erl
+++ b/lib/ssh/test/ssh_test_lib.erl
@@ -64,6 +64,7 @@ del_dirs/1,
 del_dir_contents/1,
 do_del_files/2,
 openssh_sanity_check/1,
+verify_sanity_check/1,
 default_algorithms/1,
 default_algorithms/3,
 default_algorithms/2,
@@ -133,6 +134,13 @@ event_logged/3
 -include_lib("kernel/include/file.hrl").
 -include("ssh_test_lib.hrl").
 
+-define(SANITY_CHECK_NOTE,
+        "For enabling test, make sure following commands work:~n"
+        "ok = ssh:start(), "
+        "{ok, _} = ssh:connect(\"localhost\", 22, "
+        "[{password,\"\"},{silently_accept_hosts, true}, "
+        "{save_accepted_host, false}, {user_interaction, false}]).").
+
 %%%----------------------------------------------------------------
 connect(Port, Options) when is_integer(Port) ->
     connect(hostname(), Port, Options).
@@ -566,7 +574,6 @@ do_del_files(Dir, Files) ->
                           end
                   end, Files).
 
-
 openssh_sanity_check(Config) ->
     ssh:start(),
     case ssh:connect("localhost", ?SSH_DEFAULT_PORT,
@@ -578,11 +585,24 @@ openssh_sanity_check(Config) ->
 	{ok, Pid} ->
 	    ssh:close(Pid),
 	    ssh:stop(),
-	    Config;
+	    [{sanity_check_result, ok} | Config];
 	Err ->
 	    Str = lists:append(io_lib:format("~p", [Err])),
+            ct:log("Error = ~p", [Err]),
+            ct:log(?SANITY_CHECK_NOTE),
 	    ssh:stop(),
-	    {skip, Str}
+	    [{sanity_check_result, Str} | Config]
+    end.
+
+verify_sanity_check(Config) ->
+    SanityCheckResult = proplists:get_value(sanity_check_result, Config, ok),
+    case SanityCheckResult of
+        ok ->
+            Config;
+        Err ->
+            ct:log("Error = ~p", [Err]),
+            ct:log(?SANITY_CHECK_NOTE),
+            {fail, passwordless_connection_failed}
     end.
 
 %%%--------------------------------------------------------------------
diff --git a/lib/ssh/test/ssh_to_openssh_SUITE.erl b/lib/ssh/test/ssh_to_openssh_SUITE.erl
index 524e9d98bb..22cb4780c2 100644
--- a/lib/ssh/test/ssh_to_openssh_SUITE.erl
+++ b/lib/ssh/test/ssh_to_openssh_SUITE.erl
@@ -131,12 +131,15 @@ end_per_group(_, Config) ->
 
 init_per_testcase(erlang_server_openssh_client_renegotiate, Config) ->
     case os:type() of
-	{unix,_} -> ssh:start(), Config;
-	Type -> {skip, io_lib:format("Unsupported test on ~p",[Type])}
+	{unix,_} ->
+            ssh:start(),
+            ssh_test_lib:verify_sanity_check(Config);
+	Type ->
+            {skip, io_lib:format("Unsupported test on ~p",[Type])}
     end;
 init_per_testcase(_TestCase, Config) ->
     ssh:start(),
-    Config.
+    ssh_test_lib:verify_sanity_check(Config).
 
 end_per_testcase(_TestCase, _Config) ->
     ssh:stop(),
@@ -623,3 +626,4 @@ check_kex_strict(Sock) ->
             ct:log("KEX strict supported by local OpenSSH"),
             true
     end.
+
-- 
2.35.3

openSUSE Build Service is sponsored by