aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/test/ssh_connection_SUITE.erl
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2012-10-18 21:18:14 +0200
committerIngela Anderton Andin <[email protected]>2012-10-19 14:37:16 +0200
commit9195d8d2ee6e779df80b5abd0b30d841a3417af6 (patch)
treebd203bf473ca2055ad06a820acad3169f92bd983 /lib/ssh/test/ssh_connection_SUITE.erl
parent16d74de34df5fcfed25c55f0ee52cbb01e4169cb (diff)
downloadotp-9195d8d2ee6e779df80b5abd0b30d841a3417af6.tar.gz
otp-9195d8d2ee6e779df80b5abd0b30d841a3417af6.tar.bz2
otp-9195d8d2ee6e779df80b5abd0b30d841a3417af6.zip
ssh: Modernized test suites to use only Common Test
Diffstat (limited to 'lib/ssh/test/ssh_connection_SUITE.erl')
-rw-r--r--lib/ssh/test/ssh_connection_SUITE.erl71
1 files changed, 36 insertions, 35 deletions
diff --git a/lib/ssh/test/ssh_connection_SUITE.erl b/lib/ssh/test/ssh_connection_SUITE.erl
index 43a899f974..acaf3d6eeb 100644
--- a/lib/ssh/test/ssh_connection_SUITE.erl
+++ b/lib/ssh/test/ssh_connection_SUITE.erl
@@ -28,23 +28,24 @@
-define(EXEC_TIMEOUT, 10000).
%%--------------------------------------------------------------------
+%% Common Test interface functions -----------------------------------
+%%--------------------------------------------------------------------
+
suite() ->
[{ct_hooks,[ts_install_cth]}].
all() ->
[
- {group, erlang_client},
+ {group, openssh_payload},
interrupted_send
].
groups() ->
- [{erlang_client, [], [simple_exec,
- small_cat,
- big_cat,
- send_after_exit
- ]}].
-
+ [{openssh_payload, [], [simple_exec,
+ small_cat,
+ big_cat,
+ send_after_exit
+ ]}].
%%--------------------------------------------------------------------
-
init_per_suite(Config) ->
case catch crypto:start() of
ok ->
@@ -54,15 +55,15 @@ init_per_suite(Config) ->
end.
end_per_suite(_Config) ->
- crypto:stop(),
- ok.
+ crypto:stop().
+
%%--------------------------------------------------------------------
-init_per_group(erlang_client, Config) ->
+init_per_group(openssh_payload, _Config) ->
case gen_tcp:connect("localhost", 22, []) of
{error,econnrefused} ->
{skip,"No openssh deamon"};
- _ ->
- Config
+ {ok, Socket} ->
+ gen_tcp:close(Socket)
end;
init_per_group(_, Config) ->
Config.
@@ -76,10 +77,10 @@ init_per_testcase(_TestCase, Config) ->
Config.
end_per_testcase(_Config) ->
- ssh:stop(),
- ok.
+ ssh:stop().
-%%% TEST cases starts here.
+%%--------------------------------------------------------------------
+%% Test Cases --------------------------------------------------------
%%--------------------------------------------------------------------
simple_exec(doc) ->
["Simple openssh connectivity test for ssh_connection:exec"];
@@ -163,7 +164,7 @@ big_cat(Config) when is_list(Config) ->
%% pre-adjust receive window so the other end doesn't block
ssh_connection:adjust_window(ConnectionRef, ChannelId0, size(Data)),
- test_server:format("sending ~p byte binary~n",[size(Data)]),
+ ct:pal("sending ~p byte binary~n",[size(Data)]),
ok = ssh_connection:send(ConnectionRef, ChannelId0, Data, 10000),
ok = ssh_connection:send_eof(ConnectionRef, ChannelId0),
@@ -174,10 +175,10 @@ big_cat(Config) when is_list(Config) ->
{ok, Other} ->
case size(Data) =:= size(Other) of
true ->
- test_server:format("received and sent data are same"
+ ct:pal("received and sent data are same"
"size but do not match~n",[]);
false ->
- test_server:format("sent ~p but only received ~p~n",
+ ct:pal("sent ~p but only received ~p~n",
[size(Data), size(Other)])
end,
ct:fail(receive_data_mismatch);
@@ -195,21 +196,6 @@ big_cat(Config) when is_list(Config) ->
ok
end.
-big_cat_rx(ConnectionRef, ChannelId) ->
- big_cat_rx(ConnectionRef, ChannelId, []).
-
-big_cat_rx(ConnectionRef, ChannelId, Acc) ->
- receive
- {ssh_cm, ConnectionRef, {data, ChannelId, 0, Data}} ->
- %% ssh_connection:adjust_window(ConnectionRef, ChannelId, size(Data)),
- %% window was pre-adjusted, don't adjust again here
- big_cat_rx(ConnectionRef, ChannelId, [Data | Acc]);
- {ssh_cm, ConnectionRef, {eof, ChannelId}} ->
- {ok, iolist_to_binary(lists:reverse(Acc))}
- after ?EXEC_TIMEOUT ->
- timeout
- end.
-
%%--------------------------------------------------------------------
send_after_exit(doc) ->
["Send channel data after the channel has been closed."];
@@ -292,8 +278,23 @@ interrupted_send(Config) when is_list(Config) ->
ssh:close(ConnectionRef),
ssh:stop_daemon(Pid).
+%%--------------------------------------------------------------------
+%% Internal functions ------------------------------------------------
+%%--------------------------------------------------------------------
+big_cat_rx(ConnectionRef, ChannelId) ->
+ big_cat_rx(ConnectionRef, ChannelId, []).
-%% Internal funtions ------------------------------------------------------------------
+big_cat_rx(ConnectionRef, ChannelId, Acc) ->
+ receive
+ {ssh_cm, ConnectionRef, {data, ChannelId, 0, Data}} ->
+ %% ssh_connection:adjust_window(ConnectionRef, ChannelId, size(Data)),
+ %% window was pre-adjusted, don't adjust again here
+ big_cat_rx(ConnectionRef, ChannelId, [Data | Acc]);
+ {ssh_cm, ConnectionRef, {eof, ChannelId}} ->
+ {ok, iolist_to_binary(lists:reverse(Acc))}
+ after ?EXEC_TIMEOUT ->
+ timeout
+ end.
receive_data(ExpectedData, ConnectionRef, ChannelId) ->
ExpectedData = collect_data(ConnectionRef, ChannelId).