aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/test/ssh_algorithms_SUITE.erl23
-rw-r--r--lib/ssh/test/ssh_test_lib.erl18
-rw-r--r--lib/ssh/test/ssh_to_openssh_SUITE.erl11
3 files changed, 23 insertions, 29 deletions
diff --git a/lib/ssh/test/ssh_algorithms_SUITE.erl b/lib/ssh/test/ssh_algorithms_SUITE.erl
index e6fc7662f9..3a8eec46a8 100644
--- a/lib/ssh/test/ssh_algorithms_SUITE.erl
+++ b/lib/ssh/test/ssh_algorithms_SUITE.erl
@@ -231,25 +231,10 @@ sshc_simple_exec(Config) ->
" -o StrictHostKeyChecking=no",
" ",Host," 1+1."]),
ct:log("~p",[Cmd]),
- SshPort = open_port({spawn, Cmd}, [binary]),
- Expect = <<"2\n">>,
- rcv_expected(SshPort, Expect).
-
-
-rcv_expected(SshPort, Expect) ->
- receive
- {SshPort, {data,Expect}} ->
- ct:log("Got expected ~p from ~p",[Expect,SshPort]),
- catch port_close(SshPort),
- ok;
- Other ->
- ct:log("Got UNEXPECTED ~p",[Other]),
- rcv_expected(SshPort, Expect)
-
- after ?TIMEOUT ->
- catch port_close(SshPort),
- ct:fail("Did not receive answer")
- end.
+ SshPort = open_port({spawn, Cmd}, [binary, stderr_to_stdout,
+ overlapped_io %only affects windows
+ ]),
+ ssh_test_lib:rcv_expected({data,<<"2\n">>}, SshPort, ?TIMEOUT).
%%--------------------------------------------------------------------
%% Connect to the ssh server of the OS
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl
index 06fddb8dc8..15f10fa1ae 100644
--- a/lib/ssh/test/ssh_test_lib.erl
+++ b/lib/ssh/test/ssh_test_lib.erl
@@ -194,6 +194,24 @@ reply(TestCase, Result) ->
%%ct:log("reply ~p sending ~p ! ~p",[self(), TestCase, Result]),
TestCase ! Result.
+
+
+rcv_expected(Expect, SshPort, Timeout) ->
+ receive
+ {SshPort, Expect} ->
+ ct:log("Got expected ~p from ~p",[Expect,SshPort]),
+ catch port_close(SshPort),
+ ok;
+ Other ->
+ ct:log("Got UNEXPECTED ~p",[Other]),
+ rcv_expected(SshPort, Expect, Timeout)
+
+ after Timeout ->
+ catch port_close(SshPort),
+ ct:fail("Did not receive answer")
+ end.
+
+
receive_exec_result(Msg) ->
ct:log("Expect data! ~p", [Msg]),
receive
diff --git a/lib/ssh/test/ssh_to_openssh_SUITE.erl b/lib/ssh/test/ssh_to_openssh_SUITE.erl
index 6132ff399e..ea057ed8a5 100644
--- a/lib/ssh/test/ssh_to_openssh_SUITE.erl
+++ b/lib/ssh/test/ssh_to_openssh_SUITE.erl
@@ -380,16 +380,7 @@ erlang_server_openssh_client_public_key_X(Config, PubKeyAlg) ->
" " ++ Host ++ " 1+1.",
SshPort = open_port({spawn, Cmd}, [binary, stderr_to_stdout]),
- receive
- {SshPort,{data, <<"2\n">>}} ->
- ok
- after ?TIMEOUT ->
- receive
- X -> ct:fail("Received: ~p",[X])
- after 0 ->
- ct:fail("Did not receive answer")
- end
- end,
+ ssh_test_lib:rcv_expected({data,<<"2\n">>}, SshPort, ?TIMEOUT),
ssh:stop_daemon(Pid).
%%--------------------------------------------------------------------