aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_test_lib.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2016-04-13 13:19:10 +0200
committerHans Nilsson <[email protected]>2016-04-29 13:17:52 +0200
commit020e62c9619b518620d216cf0caef55fe129d4c3 (patch)
tree8249e590918f2ffc6ef256b2a691be9a9b09983d /lib/ssh/test/ssh_test_lib.erl
parent223b123f576e726c18bcd38fa2b866d23f1a14a3 (diff)
downloadotp-020e62c9619b518620d216cf0caef55fe129d4c3.tar.gz
otp-020e62c9619b518620d216cf0caef55fe129d4c3.tar.bz2
otp-020e62c9619b518620d216cf0caef55fe129d4c3.zip
ssh: centralize and adjust port spawning for test_suites into ssh_test_lib
Diffstat (limited to 'lib/ssh/test/ssh_test_lib.erl')
-rw-r--r--lib/ssh/test/ssh_test_lib.erl35
1 files changed, 30 insertions, 5 deletions
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl
index 15f10fa1ae..927c9343d1 100644
--- a/lib/ssh/test/ssh_test_lib.erl
+++ b/lib/ssh/test/ssh_test_lib.erl
@@ -201,16 +201,27 @@ rcv_expected(Expect, SshPort, Timeout) ->
{SshPort, Expect} ->
ct:log("Got expected ~p from ~p",[Expect,SshPort]),
catch port_close(SshPort),
- ok;
+ rcv_lingering(50);
Other ->
- ct:log("Got UNEXPECTED ~p",[Other]),
- rcv_expected(SshPort, Expect, Timeout)
+ ct:log("Got UNEXPECTED ~p~nExpect ~p",[Other, {SshPort,Expect}]),
+ rcv_expected(Expect, SshPort, Timeout)
after Timeout ->
catch port_close(SshPort),
ct:fail("Did not receive answer")
end.
+rcv_lingering(Timeout) ->
+ receive
+ Msg ->
+ ct:log("Got LINGERING ~p",[Msg]),
+ rcv_lingering(Timeout)
+
+ after Timeout ->
+ ct:log("No more lingering messages",[]),
+ ok
+ end.
+
receive_exec_result(Msg) ->
ct:log("Expect data! ~p", [Msg]),
@@ -481,8 +492,9 @@ openssh_supports(ClientOrServer, Tag, Alg) when ClientOrServer == sshc ;
%% Check if we have a "newer" ssh client that supports these test cases
ssh_client_supports_Q() ->
- ErlPort = open_port({spawn, "ssh -Q cipher"}, [exit_status, stderr_to_stdout]),
- 0 == check_ssh_client_support2(ErlPort).
+ 0 == check_ssh_client_support2(
+ ?MODULE:open_port({spawn, "ssh -Q cipher"})
+ ).
check_ssh_client_support2(P) ->
receive
@@ -701,3 +713,16 @@ has_inet6_address() ->
catch
throw:6 -> true
end.
+
+%%%----------------------------------------------------------------
+open_port(Arg1) ->
+ ?MODULE:open_port(Arg1, []).
+
+open_port(Arg1, ExtraOpts) ->
+ erlang:open_port(Arg1,
+ [binary,
+ stderr_to_stdout,
+ exit_status,
+ use_stdio,
+ overlapped_io, hide %only affects windows
+ | ExtraOpts]).