From 8b2366402a6115686cd68fe617f8933a4febf5b5 Mon Sep 17 00:00:00 2001 From: Hans Nilsson Date: Fri, 27 May 2016 10:40:10 +0200 Subject: ssh: TC ssh_connection_SUITE:small_iterrupted_send --- lib/ssh/test/ssh_connection_SUITE.erl | 25 +++++++++++++++++-------- lib/ssh/test/ssh_echo_server.erl | 2 +- 2 files changed, 18 insertions(+), 9 deletions(-) (limited to 'lib/ssh/test') diff --git a/lib/ssh/test/ssh_connection_SUITE.erl b/lib/ssh/test/ssh_connection_SUITE.erl index f453061935..3d38bc1a66 100644 --- a/lib/ssh/test/ssh_connection_SUITE.erl +++ b/lib/ssh/test/ssh_connection_SUITE.erl @@ -43,6 +43,7 @@ suite() -> all() -> [ {group, openssh}, + small_interrupted_send, interrupted_send, start_shell, start_shell_exec, @@ -361,12 +362,20 @@ ptty_alloc_pixel(Config) when is_list(Config) -> ssh:close(ConnectionRef). %%-------------------------------------------------------------------- +small_interrupted_send(Config) -> + K = 1024, + M = K*K, + do_interrupted_send(Config, 10*M, 4*K). interrupted_send(Config) -> + M = 1024*1024, + do_interrupted_send(Config, 10*M, 4*M). + +do_interrupted_send(Config, SendSize, EchoSize) -> PrivDir = proplists:get_value(priv_dir, Config), UserDir = filename:join(PrivDir, nopubkey), % to make sure we don't use public-key-auth file:make_dir(UserDir), SysDir = proplists:get_value(data_dir, Config), - EchoSS_spec = {ssh_echo_server, [4000000,[{dbg,true}]]}, + EchoSS_spec = {ssh_echo_server, [EchoSize,[{dbg,true}]]}, {Pid, Host, Port} = ssh_test_lib:daemon([{system_dir, SysDir}, {user_dir, UserDir}, {password, "morot"}, @@ -380,11 +389,11 @@ interrupted_send(Config) -> {user_dir, UserDir}]), ct:log("connected", []), - %% build 10MB binary - Data = << <> || X <- lists:seq(1,2500000)>>, + %% build big binary + Data = << <> || X <- lists:seq(1,SendSize div 4)>>, - %% expect remote end to send us 4MB back - <> = Data, + %% expect remote end to send us EchoSize back + <> = Data, %% Spawn listener. Otherwise we could get a deadlock due to filled buffers Parent = self(), @@ -421,7 +430,7 @@ interrupted_send(Config) -> ssh_connection:adjust_window(ConnectionRef, ChannelId, size(ExpectedData) + 1), ct:log("going to send ~p bytes", [size(Data)]), - case ssh_connection:send(ConnectionRef, ChannelId, Data, 10000) of + case ssh_connection:send(ConnectionRef, ChannelId, Data, 30000) of {error, closed} -> ct:log("{error,closed} - That's what we expect :)", []), ok; @@ -429,10 +438,10 @@ interrupted_send(Config) -> ct:log("Got ~p - that's bad, very bad indeed",[Msg]), ct:fail({expected,{error,closed}, got, Msg}) end, - ct:log("going to receive result", []), + ct:log("going to check the result (if it is available)", []), receive {ResultPid, Result} -> - ct:log("back from receive data: ~p", [Result]), + ct:log("Got result: ~p", [Result]), ssh:close(ConnectionRef), ssh:stop_daemon(Pid), Result diff --git a/lib/ssh/test/ssh_echo_server.erl b/lib/ssh/test/ssh_echo_server.erl index 3702630cb4..5387d21efd 100644 --- a/lib/ssh/test/ssh_echo_server.erl +++ b/lib/ssh/test/ssh_echo_server.erl @@ -61,7 +61,7 @@ handle_ssh_msg({ssh_cm, CM, {data, ChannelId, 0, Data}}, #state{n = N} = State) {ok, State#state{n = M}}; false -> <> = Data, - ?DBG(State, "ssh_cm data Cid=~p size(Data)=~p M=~p size(SendData)=~p",[ChannelId,size(Data),M,size(SendData)]), + ?DBG(State, "ssh_cm data Cid=~p size(Data)=~p M=~p size(SendData)=~p~nSend eof",[ChannelId,size(Data),M,size(SendData)]), ssh_connection:send(CM, ChannelId, SendData), ssh_connection:send_eof(CM, ChannelId), {stop, ChannelId, State} -- cgit v1.2.3