aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_telnet.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2014-03-10 01:40:14 +0100
committerPeter Andersson <[email protected]>2014-03-12 16:00:14 +0100
commit609349f6acac4b03b8cac53eb9ad456a2b2d5536 (patch)
tree73d79e54d48a77b3b711cf19941b6d3c433cc5ff /lib/common_test/src/ct_telnet.erl
parentd6fb44e0575ecd022c30d5c6a7503c8849d98fa9 (diff)
downloadotp-609349f6acac4b03b8cac53eb9ad456a2b2d5536.tar.gz
otp-609349f6acac4b03b8cac53eb9ad456a2b2d5536.tar.bz2
otp-609349f6acac4b03b8cac53eb9ad456a2b2d5536.zip
Get ct_telnet_client to print all data from server to log
Diffstat (limited to 'lib/common_test/src/ct_telnet.erl')
-rw-r--r--lib/common_test/src/ct_telnet.erl35
1 files changed, 18 insertions, 17 deletions
diff --git a/lib/common_test/src/ct_telnet.erl b/lib/common_test/src/ct_telnet.erl
index fc71647edd..096e893720 100644
--- a/lib/common_test/src/ct_telnet.erl
+++ b/lib/common_test/src/ct_telnet.erl
@@ -788,19 +788,14 @@ log(#state{name=Name,teln_pid=TelnPid,host=Host,port=Port},
case ct_util:get_testdata({cth_conn_log,?MODULE}) of
HookMode when HookMode /= undefined, HookMode /= silent,
Silent /= true ->
- {PrintHeader,PreBR} = if Action==undefined ->
- {false,""};
- true ->
- {true,"\n"}
- end,
- error_logger:info_report(#conn_log{header=PrintHeader,
+ error_logger:info_report(#conn_log{header=false,
client=self(),
conn_pid=TelnPid,
address={Host,Port},
name=Name1,
action=Action,
module=?MODULE},
- {PreBR++String,Args});
+ {String,Args});
_ -> %% hook inactive or silence requested
ok
end;
@@ -1027,19 +1022,25 @@ teln_expect1(Name,Pid,Data,Pattern,Acc,EO) ->
NotFinished ->
%% Get more data
Fun = fun() -> get_data1(EO#eo.teln_pid) end,
- case ct_gen_conn:do_within_time(Fun, EO#eo.timeout) of
- {error,Reason} ->
+ case timer:tc(ct_gen_conn, do_within_time, [Fun, EO#eo.timeout]) of
+ {_,{error,Reason}} ->
%% A timeout will occur when the telnet connection
%% is idle for EO#eo.timeout milliseconds.
{error,Reason};
- {ok,Data1} ->
- case NotFinished of
- {nomatch,Rest} ->
- %% One expect
- teln_expect1(Name,Pid,Rest++Data1,Pattern,[],EO);
- {continue,Patterns1,Acc1,Rest} ->
- %% Sequence
- teln_expect1(Name,Pid,Rest++Data1,Patterns1,Acc1,EO)
+ {Elapsed,{ok,Data1}} ->
+ TVal = trunc(EO#eo.timeout - (Elapsed/1000)),
+ if TVal =< 0 ->
+ {error,timeout};
+ true ->
+ EO1 = EO#eo{timeout = TVal},
+ case NotFinished of
+ {nomatch,Rest} ->
+ %% One expect
+ teln_expect1(Name,Pid,Rest++Data1,Pattern,[],EO1);
+ {continue,Patterns1,Acc1,Rest} ->
+ %% Sequence
+ teln_expect1(Name,Pid,Rest++Data1,Patterns1,Acc1,EO1)
+ end
end
end
end.