aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/test/telnet_server.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2014-03-22 00:05:53 +0100
committerPeter Andersson <[email protected]>2014-03-22 00:08:08 +0100
commit1acc2ed6ebb2837e66419b357f88a1709fa2c0f1 (patch)
tree1ff6b87a9a6f2827d05a77fa1c27ac975193ec5e /lib/common_test/test/telnet_server.erl
parent72f9cd7ce17eaa9e6b69b380b74b0860a614ce4f (diff)
downloadotp-1acc2ed6ebb2837e66419b357f88a1709fa2c0f1.tar.gz
otp-1acc2ed6ebb2837e66419b357f88a1709fa2c0f1.tar.bz2
otp-1acc2ed6ebb2837e66419b357f88a1709fa2c0f1.zip
Add test cases
Diffstat (limited to 'lib/common_test/test/telnet_server.erl')
-rw-r--r--lib/common_test/test/telnet_server.erl19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/common_test/test/telnet_server.erl b/lib/common_test/test/telnet_server.erl
index 3b0c3cbcb5..ae56787819 100644
--- a/lib/common_test/test/telnet_server.erl
+++ b/lib/common_test/test/telnet_server.erl
@@ -211,6 +211,11 @@ do_handle_data("echo_ml_no_prompt " ++ Data,State) ->
ReturnData = string:join(Lines,"\n"),
send(ReturnData,State),
{ok,State};
+do_handle_data("echo_loop " ++ Data,State) ->
+ [TStr|Lines] = string:tokens(Data," "),
+ ReturnData = string:join(Lines,"\n"),
+ send_loop(list_to_integer(TStr),ReturnData,State),
+ {ok,State};
do_handle_data("disconnect_after " ++WaitStr,State) ->
Wait = list_to_integer(string:strip(WaitStr,right,$\n)),
dbg("Server will close connection in ~w ms...", [Wait]),
@@ -251,6 +256,20 @@ send(Data,State) ->
throw({error,send,Error})
end.
+send_loop(T,Data,State) ->
+ dbg("Server sending ~p in loop for ~w ms...~n",[Data,T]),
+ send_loop(now(),T,Data,State).
+
+send_loop(T0,T,Data,State) ->
+ ElapsedMS = trunc(timer:now_diff(now(),T0)/1000),
+ if ElapsedMS >= T ->
+ ok;
+ true ->
+ send(Data,State),
+ timer:sleep(500),
+ send_loop(T0,T,Data,State)
+ end.
+
get_line([$\r,$\n|Rest],Acc) ->
{lists:reverse(Acc),Rest};
get_line([$\r,0|Rest],Acc) ->