aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/unix_telnet.erl
diff options
context:
space:
mode:
authorPeter Andersson <peppe@erlang.org>2010-02-17 15:59:05 +0000
committerErlang/OTP <otp@erlang.org>2010-02-17 15:59:05 +0000
commit332591f03f7bc4585c8c108c192ab3bba6fec12c (patch)
treec3d06e8750d53d0f157d61cd4c5f991959a05a51 /lib/common_test/src/unix_telnet.erl
parentf29538e8002cf0e37fa4f988fbf5484c46513bf4 (diff)
downloadotp-332591f03f7bc4585c8c108c192ab3bba6fec12c.tar.gz
otp-332591f03f7bc4585c8c108c192ab3bba6fec12c.tar.bz2
otp-332591f03f7bc4585c8c108c192ab3bba6fec12c.zip
OTP-8311: Various updates and fixes in Common Test and Test Server
Diffstat (limited to 'lib/common_test/src/unix_telnet.erl')
-rw-r--r--lib/common_test/src/unix_telnet.erl39
1 files changed, 23 insertions, 16 deletions
diff --git a/lib/common_test/src/unix_telnet.erl b/lib/common_test/src/unix_telnet.erl
index 14a70e9d22..25b9d4d5d2 100644
--- a/lib/common_test/src/unix_telnet.erl
+++ b/lib/common_test/src/unix_telnet.erl
@@ -1,19 +1,19 @@
%%
%% %CopyrightBegin%
-%%
-%% Copyright Ericsson AB 2004-2009. All Rights Reserved.
-%%
+%%
+%% Copyright Ericsson AB 2004-2010. All Rights Reserved.
+%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
%% compliance with the License. You should have received a copy of the
%% Erlang Public License along with this software. If not, it can be
%% retrieved online at http://www.erlang.org/.
-%%
+%%
%% Software distributed under the License is distributed on an "AS IS"
%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
%% the License for the specific language governing rights and limitations
%% under the License.
-%%
+%%
%% %CopyrightEnd%
%%
@@ -23,10 +23,10 @@
%%% <p>It requires the following entry in the config file:</p>
%%% <pre>
%%% {unix,[{telnet,HostNameOrIpAddress},
-%%% {port,PortNum},
+%%% {port,PortNum}, % optional
%%% {username,UserName},
-%%% {password,Password}]}.
-%%% </pre>
+%%% {password,Password},
+%%% {keep_alive,Bool}]}. % optional</pre>
%%%
%%% <p>To talk telnet to the host specified by
%%% <code>HostNameOrIpAddress</code>, use the interface functions in
@@ -38,8 +38,14 @@
%%% <p>or</p>
%%% <pre> ct:require(Name,{unix,[telnet,username,password]}).</pre>
%%%
+%%% <p>The "keep alive" activity (i.e. that Common Test sends NOP to the server
+%%% every 10 seconds if the connection is idle) may be enabled or disabled for one
+%%% particular connection as described here. It may be disabled for all connections
+%%% using <c>telnet_settings</c> (see <c>ct_telnet</c>).</p>
+%%%
%%% <p>Note that the <code>{port,PortNum}</code> tuple is optional and if
-%%% omitted, default telnet port 23 will be used.</p>
+%%% omitted, default telnet port 23 will be used. Also the <c>keep_alive</c> tuple
+%%% is optional, and the value defauls to true (enabled).</p>
%%%
%%% @see ct
%%% @see ct_telnet
@@ -48,7 +54,7 @@
-compile(export_all).
%% Callbacks for ct_telnet.erl
--export([connect/4,get_prompt_regexp/0]).
+-export([connect/5,get_prompt_regexp/0]).
-import(ct_telnet,[start_log/1,cont_log/2,end_log/0]).
-define(username,"login: ").
@@ -70,10 +76,11 @@ get_prompt_regexp() ->
%%%-----------------------------------------------------------------
%%% @hidden
-%%% @spec connect(Ip,Port,Timeout,Extra) -> {ok,Handle} | {error,Reason}
+%%% @spec connect(Ip,Port,Timeout,KeepAlive,Extra) -> {ok,Handle} | {error,Reason}
%%% Ip = string() | {integer(),integer(),integer(),integer()}
%%% Port = integer()
%%% Timeout = integer()
+%%% KeepAlive = bool()
%%% Extra = {Username,Password}
%%% Username = string()
%%% Password = string()
@@ -82,23 +89,23 @@ get_prompt_regexp() ->
%%% @doc Callback for ct_telnet.erl.
%%%
%%% <p>Setup telnet connection to a UNIX host.</p>
-connect(Ip,Port,Timeout,Extra) ->
+connect(Ip,Port,Timeout,KeepAlive,Extra) ->
case Extra of
{Username,Password} ->
- connect(Ip,Port,Timeout,Username,Password);
+ connect1(Ip,Port,Timeout,KeepAlive,Username,Password);
Name ->
case get_username_and_password(Name) of
{ok,{Username,Password}} ->
- connect(Ip,Port,Timeout,Username,Password);
+ connect1(Ip,Port,Timeout,KeepAlive,Username,Password);
Error ->
Error
end
end.
-connect(Ip,Port,Timeout,Username,Password) ->
+connect1(Ip,Port,Timeout,KeepAlive,Username,Password) ->
start_log("unix_telnet:connect"),
Result =
- case ct_telnet_client:open(Ip,Port,Timeout) of
+ case ct_telnet_client:open(Ip,Port,Timeout,KeepAlive) of
{ok,Pid} ->
case ct_telnet:silent_teln_expect(Pid,[],[prompt],?prx,[]) of
{ok,{prompt,?username},_} ->