File 2202-ssh-test-cases-changed-for-port-0-as-arg-to-ssh-daem.patch of Package erlang

From 6282a81eca93e015445e04d09be9ac7854bb96d6 Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Thu, 7 Apr 2016 18:03:42 +0200
Subject: [PATCH 2/2] ssh: test cases changed for port 0 as arg to ssh:daemon

---
 lib/ssh/test/ssh_sftpd_SUITE.erl |  7 ++++---
 lib/ssh/test/ssh_test_lib.erl    | 16 ++++++++++++----
 2 files changed, 16 insertions(+), 7 deletions(-)

diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index fb1a968..9385bd1 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -105,7 +105,6 @@ init_per_testcase(TestCase, Config) ->
     ClientUserDir = filename:join(PrivDir, nopubkey),
     SystemDir = filename:join(?config(priv_dir, Config), system),
 
-    Port = ssh_test_lib:inet_port(node()),
     Options = [{system_dir, SystemDir},
 	       {user_dir, PrivDir},
 	       {user_passwords,[{?USER, ?PASSWD}]},
@@ -113,11 +112,13 @@ init_per_testcase(TestCase, Config) ->
     {ok, Sftpd} = case TestCase of
 		      ver6_basic ->
 			  SubSystems = [ssh_sftpd:subsystem_spec([{sftpd_vsn, 6}])],
-			  ssh:daemon(Port, [{subsystems, SubSystems}|Options]);
+			  ssh:daemon(0, [{subsystems, SubSystems}|Options]);
 		      _ ->
 			  SubSystems = [ssh_sftpd:subsystem_spec([])],
-			  ssh:daemon(Port, [{subsystems, SubSystems}|Options])
+			  ssh:daemon(0, [{subsystems, SubSystems}|Options])
 		  end,
+    {ok,Dinf} = ssh:daemon_info(Sftpd),
+    Port = proplists:get_value(port, Dinf),
     
     Cm = ssh_test_lib:connect(Port,
 			      [{user_dir, ClientUserDir},
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl
index 4db7d09..0e3500e 100644
--- a/lib/ssh/test/ssh_test_lib.erl
+++ b/lib/ssh/test/ssh_test_lib.erl
@@ -49,23 +49,31 @@ connect(Host, Port, Options) ->
     ConnectionRef.
 
 daemon(Options) ->
-    daemon(any, inet_port(), Options).
+    daemon(any, 0, Options).
 
 daemon(Port, Options) when is_integer(Port) ->
     daemon(any, Port, Options);
 daemon(Host, Options) ->
-    daemon(Host, inet_port(), Options).
+    daemon(Host, 0, Options).
+
 
 daemon(Host, Port, Options) ->
     case ssh:daemon(Host, Port, Options) of
 	{ok, Pid} when Host == any ->
-	    {Pid, hostname(), Port};
+	    ct:log("ssh:daemon ok (1)",[]),
+	    {Pid, hostname(), daemon_port(Port,Pid)};
 	{ok, Pid} ->
-	    {Pid, Host, Port};
+	    ct:log("ssh:daemon ok (2)",[]),
+	    {Pid, Host, daemon_port(Port,Pid)};
 	Error ->
 	    Error
     end.
 
+daemon_port(0, Pid) -> {ok,Dinf} = ssh:daemon_info(Pid),
+		       proplists:get_value(port, Dinf);
+daemon_port(Port, _) -> Port.
+    
+
 
 std_daemon(Config, ExtraOpts) ->
     PrivDir = ?config(priv_dir, Config),
-- 
2.1.4

openSUSE Build Service is sponsored by