From: Alexey Kodanev <alexey.kodanev@oracle.com>
To: Zeng Linggang <zenglg.jy@cn.fujitsu.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH v2 2/3] telnet: Cleanup
Date: Fri, 23 Jan 2015 14:01:46 +0300 [thread overview]
Message-ID: <54C22A1A.2050906@oracle.com> (raw)
In-Reply-To: <1421818093-24202-2-git-send-email-zenglg.jy@cn.fujitsu.com>
Hi!
On 21.01.2015 8:28, Zeng Linggang wrote:
> * Add 'TCID' and 'TST_TOTAL'.
> * Use 'test.sh'.
> * Delete some useless comment.
> * Some cleanup.
>
> Signed-off-by: Zeng Linggang<zenglg.jy@cn.fujitsu.com>
> ---
> testcases/network/tcp_cmds/telnet/telnet01 | 143 ++++++++++++-----------------
> 1 file changed, 58 insertions(+), 85 deletions(-)
>
> diff --git a/testcases/network/tcp_cmds/telnet/telnet01 b/testcases/network/tcp_cmds/telnet/telnet01
> index 36ebf12..b006fe9 100755
> --- a/testcases/network/tcp_cmds/telnet/telnet01
> +++ b/testcases/network/tcp_cmds/telnet/telnet01
> @@ -1,5 +1,4 @@
> -#! /usr/bin/expect -f
> -#*********************************************************************
> +#!/bin/bash
> # Copyright (c) International Business Machines Corp., 2000
> #
> # This program is free software; you can redistribute it and/or modify
> @@ -16,102 +15,76 @@
> # along with this program; if not, write to the Free Software
> # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> #
> -#
> -#
> -# FILE : telnet
> -#
> -# PURPOSE: Tests the basic functionality of `telnet`.
> -#
> # SETUP: The program `/usr/bin/expect' MUST be installed.
> # The PASSWD and RHOST variables MUST be set prior to execution.
> #
> -# HISTORY:
> # 03/01 Robbie Williamson (robbiew@us.ibm.com)
> -# -Ported
> -#
> -#*********************************************************************
> -#
> -# telnet perform a telnet session to each host in HOST_LIST with user
> -# RUSER for a count of LOOPCOUNT and does an ls -l /etc/hosts to
> -# verify that the telnet was established.
> -#
> -#*********************************************************************
>
> -set TC telnet
> -set TCtmp "/tmp"
> -set SLEEPTIME 3
> -set TESTLOG "$TCtmp"
> -set PROMPT "Alpha Bravo"
> -
> -if [info exists env(RUSER)] {
> - set RUSER $env(RUSER)
> -} else {
> - set RUSER root
> -}
> +TCID="telnet01"
> +TST_TOTAL=1
> +. test.sh
>
> -if [info exists env(PASSWD)] {
> - set PASSWD $env(PASSWD)
> -} else {
> - set PASSWD .pasroot
> - send_user "PASSWD NOT SET:Using .pasroot as the PASSWD variable for $RUSER. \n"
> -}
> +setup()
> +{
> + if [ -z $RUSER ]; then
> + RUSER=root
> + fi
>
> -if [info exists env(RHOST)] {
> - set RHOST $env(RHOST)
> -} else {
> - send_user "Please set/export the RHOST variable. \n"
> - exit 1
> -}
> + if [ -z $PASSWD ]; then
> + tst_brkm TCONF "Please set PASSWD for $RUSER."
> + fi
>
> -set timeout 90
> + if [ -z $RHOST ]; then
> + tst_brkm TCONF "Please set RHOST."
> + fi
>
> -if [info exists env(LOOPCOUNT)] {
> - set LOOPCOUNT $env(LOOPCOUNT)
> -} else {
> - set LOOPCOUNT 25
> + if [ -z $LOOPCOUNT ]; then
> + LOOTCOUNT=25
^
should be 'P' here
> + fi
> }
>
> -# stty echo
> -send_user " Starting\n"
> -
> -# Do foreach host on command line
> -set count 0
> -while {$count < $LOOPCOUNT} {
> - set count [expr $count+1]
> - foreach HOST $RHOST {
> - send_user "Host: $HOST\n"
> -
> - # telnet to the host
> - spawn telnet $HOST
> - expect -re "login:"
> -
> - send "$RUSER\r"
> - expect -re "Password:"
> +do_test()
> +{
> + tst_resm TINFO "Starting"
>
> - send "$PASSWD\r"
> -
> - send "PS1=\"$PROMPT\"\r"
> - # Wait for shell prompt
> - expect "$PROMPT"
> + for i in $(seq 1 ${LOOPCOUNT})
> + do
> + telnet_test || return 1
> + done
> +}
>
> - # Run passwd command - and respond to its prompts
> - send "LC_ALL=C ls -l /etc/hosts | wc -w > $TESTLOG/$RUSER.$HOST \r"
> - # When shell prompt comes back, logout
> +telnet_test()
> +{
> + expect -c "
> + spawn telnet $RHOST
> + expect -re \"login:\"
> + send \"$RUSER\r\"
> + expect -re \"Password:\"
> + send \"$PASSWD\r\"
> +
> + send \"LC_ALL=C ls -l /etc/hosts | wc -w > $RUSER.$RHOST \r\"
> + expect \"$RUSER@\"
This part needs some extra checking for failed login, e.g. 'incorrect'
password or connection timeout:
expect -re "incorrect" {
exit 1
} -re "$USERS@"
> + exp_send \"logout\r\"
> +
The below part can be changed to:
tst_resm TINFO "checking telnet status"
tst_rhost_run -s -c "grep -q 9 $RUSER.$RHOST"
tst_rhost_run -c "rm -f $RUSER.$RHOST"
Note, 'tst_rhost_run' with '-s' option should exit with TBROK if remote
command returns non-zero exit status, please find the following patch
with the fix:
[PATCH v2] lib/test_net.sh: fix 'tst_rhost_run -s' when errors occur.
> + send_user \"CHECKING TELNET STATUS\n\"
> +
> + set nummatch [exec rsh -n -l $RUSER $RHOST \\
> + \"grep -c 9 $RUSER.$RHOST\"]
> + if {\$nummatch==1} {
> + exec rsh -n -l $RUSER $RHOST \"rm -f $RUSER.$RHOST\"
> + } else {
> + exit 1
> + }
> + "
> +}
>
> - expect "$PROMPT"
> - exp_send "logout\r"
> +setup
>
> - send_user "CHECKING TELNET STATUS\n"
> - set nummatch [exec rsh -n -l $RUSER $HOST "cat $TESTLOG/$RUSER.$HOST|grep -c 9"]
> - if {$nummatch==1} {
> - send_user "$TC interactive Test Successful in LOOP $count\r"
> - exec rsh -n -l $RUSER $HOST "rm -f $TESTLOG/$RUSER.$HOST"
> - } else {
> - send_user "$TC interactive session failed\n"
> - exit 1
> - }
> - }
> -}
> +do_test
> +if [ $? -ne 0 ]; then
> + tst_resm TFAIL "Test $TCID failed."
> +else
> + tst_resm TPASS "Test $TCID successed."
"'succeeded"
> +fi
>
> -send_user "\nTest PASSES\n\n"
> -exit 0
> +tst_exit
Also, there is too much non-standard LTP output, especially if LOOPCOUNT
is big. Could we send it to a file and only if there are some errors,
print it. Any thoughts?
Thanks,
Alexey
------------------------------------------------------------------------------
New Year. New Location. New Benefits. New Data Center in Ashburn, VA.
GigeNET is offering a free month of service with a new server in Ashburn.
Choose from 2 high performing configs, both with 100TB of bandwidth.
Higher redundancy.Lower latency.Increased capacity.Completely compliant.
http://p.sf.net/sfu/gigenet
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2015-01-23 10:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-26 10:58 [LTP] [PATCH 1/3] rlogin: Cleanup Zeng Linggang
2014-12-26 10:58 ` [LTP] [PATCH 2/3] telnet: Cleanup Zeng Linggang
2014-12-26 10:58 ` [LTP] [PATCH 3/3] iptables_tests.sh: Cleanup Zeng Linggang
2015-01-15 15:13 ` [LTP] [PATCH 1/3] rlogin: Cleanup Alexey Kodanev
2015-01-16 7:38 ` Zeng Linggang
2015-01-21 5:28 ` [LTP] [PATCH v2 " Zeng Linggang
2015-01-21 5:28 ` [LTP] [PATCH v2 2/3] telnet: Cleanup Zeng Linggang
2015-01-23 11:01 ` Alexey Kodanev [this message]
2015-01-27 7:41 ` Zeng Linggang
2015-01-27 16:19 ` Alexey Kodanev
2015-01-28 1:17 ` Zeng Linggang
2015-01-21 5:28 ` [LTP] [PATCH v2 3/3] iptables_tests.sh: Cleanup Zeng Linggang
2015-01-26 18:37 ` Alexey Kodanev
2015-01-27 9:16 ` Zeng Linggang
2015-01-27 16:30 ` Alexey Kodanev
2015-01-28 1:19 ` Zeng Linggang
2015-01-29 10:19 ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Zeng Linggang
2015-01-29 10:19 ` [LTP] [PATCH v3 2/3] telnet: Cleanup Zeng Linggang
2015-01-29 10:19 ` [LTP] [PATCH v3 3/3] iptables_tests.sh: Cleanup Zeng Linggang
2015-02-06 12:56 ` [LTP] [PATCH v3 1/3] rlogin: Cleanup Alexey Kodanev
2015-01-23 11:02 ` [LTP] [PATCH v2 " Alexey Kodanev
2015-01-27 7:29 ` Zeng Linggang
-- strict thread matches above, loose matches on Subject: below --
2015-01-19 2:17 Zeng Linggang
2015-01-19 2:17 ` [LTP] [PATCH v2 2/3] telnet: Cleanup Zeng Linggang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=54C22A1A.2050906@oracle.com \
--to=alexey.kodanev@oracle.com \
--cc=ltp-list@lists.sourceforge.net \
--cc=zenglg.jy@cn.fujitsu.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.