aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/ssh/test/ssh_sftpd_SUITE.erl4
-rw-r--r--lib/ssh/test/ssh_sup_SUITE.erl91
-rw-r--r--lib/ssh/test/ssh_test_lib.erl3
3 files changed, 51 insertions, 47 deletions
diff --git a/lib/ssh/test/ssh_sftpd_SUITE.erl b/lib/ssh/test/ssh_sftpd_SUITE.erl
index b167f98ac8..4dd510fc47 100644
--- a/lib/ssh/test/ssh_sftpd_SUITE.erl
+++ b/lib/ssh/test/ssh_sftpd_SUITE.erl
@@ -151,8 +151,8 @@ init_per_testcase(TestCase, Config) ->
SubSystems = [ssh_sftpd:subsystem_spec([])],
ssh:daemon(0, [{subsystems, SubSystems}|Options])
end,
- {ok,Dinf} = ssh:daemon_info(Sftpd),
- Port = proplists:get_value(port, Dinf),
+
+ Port = ssh_test_lib:daemon_port(Sftpd),
Cm = ssh_test_lib:connect(Port,
[{user_dir, ClientUserDir},
diff --git a/lib/ssh/test/ssh_sup_SUITE.erl b/lib/ssh/test/ssh_sup_SUITE.erl
index 3f08ec4b38..fdeb8186a5 100644
--- a/lib/ssh/test/ssh_sup_SUITE.erl
+++ b/lib/ssh/test/ssh_sup_SUITE.erl
@@ -101,6 +101,7 @@ default_tree(Config) when is_list(Config) ->
?wait_match([], supervisor:which_children(sshc_sup)),
?wait_match([], supervisor:which_children(sshd_sup)).
+%%-------------------------------------------------------------------------
sshc_subtree() ->
[{doc, "Make sure the sshc subtree is correct"}].
sshc_subtree(Config) when is_list(Config) ->
@@ -129,6 +130,7 @@ sshc_subtree(Config) when is_list(Config) ->
ssh:close(Pid2),
?wait_match([], supervisor:which_children(sshc_sup)).
+%%-------------------------------------------------------------------------
sshd_subtree() ->
[{doc, "Make sure the sshd subtree is correct"}].
sshd_subtree(Config) when is_list(Config) ->
@@ -150,6 +152,7 @@ sshd_subtree(Config) when is_list(Config) ->
ct:sleep(?WAIT_FOR_SHUTDOWN),
?wait_match([], supervisor:which_children(sshd_sup)).
+%%-------------------------------------------------------------------------
sshd_subtree_profile() ->
[{doc, "Make sure the sshd subtree using profile option is correct"}].
sshd_subtree_profile(Config) when is_list(Config) ->
@@ -174,43 +177,6 @@ sshd_subtree_profile(Config) when is_list(Config) ->
?wait_match([], supervisor:which_children(sshd_sup)).
%%-------------------------------------------------------------------------
-check_sshd_system_tree(Daemon, Config) ->
- Host = proplists:get_value(host, Config),
- Port = proplists:get_value(port, Config),
- UserDir = proplists:get_value(userdir, Config),
- {ok, Client} = ssh:connect(Host, Port, [{silently_accept_hosts, true},
- {user_interaction, false},
- {user, ?USER}, {password, ?PASSWD},{user_dir, UserDir}]),
-
- ?wait_match([{_,SubSysSup, supervisor,[ssh_subsystem_sup]},
- {{ssh_acceptor_sup,_,_,_}, AccSup, supervisor,[ssh_acceptor_sup]}],
- supervisor:which_children(Daemon),
- [SubSysSup,AccSup]),
-
- ?wait_match([{{server,ssh_connection_sup, _,_},
- ConnectionSup, supervisor,
- [ssh_connection_sup]},
- {{server,ssh_channel_sup,_ ,_},
- ChannelSup,supervisor,
- [ssh_channel_sup]}],
- supervisor:which_children(SubSysSup),
- [ConnectionSup,ChannelSup]),
-
- ?wait_match([{{ssh_acceptor_sup,_,_,_},_,worker,[ssh_acceptor]}],
- supervisor:which_children(AccSup)),
-
- ?wait_match([{_, _, worker,[ssh_connection_handler]}],
- supervisor:which_children(ConnectionSup)),
-
- ?wait_match([], supervisor:which_children(ChannelSup)),
-
- ssh_sftp:start_channel(Client),
-
- ?wait_match([{_, _,worker,[ssh_channel]}],
- supervisor:which_children(ChannelSup)),
- ssh:close(Client).
-
-%%-------------------------------------------------------------------------
killed_acceptor_restarts(Config) ->
Profile = proplists:get_value(profile, Config),
SystemDir = proplists:get_value(data_dir, Config),
@@ -225,12 +191,8 @@ killed_acceptor_restarts(Config) ->
{user_passwords, [{?USER, ?PASSWD}]},
{profile, Profile}]),
- {ok,Dinf} = ssh:daemon_info(DaemonPid),
- Port = proplists:get_value(port, Dinf),
-
- {ok,Dinf2} = ssh:daemon_info(DaemonPid2),
- Port2 = proplists:get_value(port, Dinf2),
-
+ Port = ssh_test_lib:daemon_port(DaemonPid),
+ Port2 = ssh_test_lib:daemon_port(DaemonPid2),
true = (Port /= Port2),
ct:pal("~s",[lists:flatten(ssh_info:string())]),
@@ -279,7 +241,47 @@ killed_acceptor_restarts(Config) ->
{error,closed} = ssh:connection_info(C1,[client_version]),
{error,closed} = ssh:connection_info(C2,[client_version]).
-%%%================================================================
+%%-------------------------------------------------------------------------
+%% Help functions
+%%-------------------------------------------------------------------------
+check_sshd_system_tree(Daemon, Config) ->
+ Host = proplists:get_value(host, Config),
+ Port = proplists:get_value(port, Config),
+ UserDir = proplists:get_value(userdir, Config),
+ {ok, Client} = ssh:connect(Host, Port, [{silently_accept_hosts, true},
+ {user_interaction, false},
+ {user, ?USER},
+ {password, ?PASSWD},
+ {user_dir, UserDir}]),
+
+ ?wait_match([{_,SubSysSup, supervisor,[ssh_subsystem_sup]},
+ {{ssh_acceptor_sup,_,_,_}, AccSup, supervisor,[ssh_acceptor_sup]}],
+ supervisor:which_children(Daemon),
+ [SubSysSup,AccSup]),
+
+ ?wait_match([{{server,ssh_connection_sup, _,_},
+ ConnectionSup, supervisor,
+ [ssh_connection_sup]},
+ {{server,ssh_channel_sup,_ ,_},
+ ChannelSup,supervisor,
+ [ssh_channel_sup]}],
+ supervisor:which_children(SubSysSup),
+ [ConnectionSup,ChannelSup]),
+
+ ?wait_match([{{ssh_acceptor_sup,_,_,_},_,worker,[ssh_acceptor]}],
+ supervisor:which_children(AccSup)),
+
+ ?wait_match([{_, _, worker,[ssh_connection_handler]}],
+ supervisor:which_children(ConnectionSup)),
+
+ ?wait_match([], supervisor:which_children(ChannelSup)),
+
+ ssh_sftp:start_channel(Client),
+
+ ?wait_match([{_, _,worker,[ssh_channel]}],
+ supervisor:which_children(ChannelSup)),
+ ssh:close(Client).
+
acceptor_pid(DaemonPid) ->
Parent = self(),
Pid = spawn(fun() ->
@@ -308,4 +310,3 @@ acceptor_pid(DaemonPid) ->
receive {Pid, supsearch, L} -> {ok,L}
after 2000 -> timeout
end.
-
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl
index 1673f52821..0ada8233a7 100644
--- a/lib/ssh/test/ssh_test_lib.erl
+++ b/lib/ssh/test/ssh_test_lib.erl
@@ -64,6 +64,9 @@ daemon(Host, Port, Options) ->
Error
end.
+daemon_port(Pid) -> daemon_port(0, Pid).
+
+
daemon_port(0, Pid) -> {ok,Dinf} = ssh:daemon_info(Pid),
proplists:get_value(port, Dinf);
daemon_port(Port, _) -> Port.