From 332591f03f7bc4585c8c108c192ab3bba6fec12c Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Wed, 17 Feb 2010 15:59:05 +0000 Subject: OTP-8311: Various updates and fixes in Common Test and Test Server --- lib/common_test/src/unix_telnet.erl | 39 ++++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) (limited to 'lib/common_test/src/unix_telnet.erl') 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 @@ %%%

It requires the following entry in the config file:

%%%
 %%% {unix,[{telnet,HostNameOrIpAddress},
-%%%        {port,PortNum},
+%%%        {port,PortNum},                 % optional
 %%%        {username,UserName},
-%%%        {password,Password}]}.
-%%% 
+%%% {password,Password}, +%%% {keep_alive,Bool}]}. % optional %%% %%%

To talk telnet to the host specified by %%% HostNameOrIpAddress, use the interface functions in @@ -38,8 +38,14 @@ %%%

or

%%%
   ct:require(Name,{unix,[telnet,username,password]}).
%%% +%%%

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 telnet_settings (see ct_telnet).

+%%% %%%

Note that the {port,PortNum} tuple is optional and if -%%% omitted, default telnet port 23 will be used.

+%%% omitted, default telnet port 23 will be used. Also the keep_alive tuple +%%% is optional, and the value defauls to true (enabled).

%%% %%% @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. %%% %%%

Setup telnet connection to a UNIX host.

-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},_} -> -- cgit v1.2.3