public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
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: Tue, 27 Jan 2015 19:19:20 +0300	[thread overview]
Message-ID: <54C7BA88.6060103@oracle.com> (raw)
In-Reply-To: <1422344483.1619.52.camel@G08JYZSD130126.localdomain>

Hi!
On 01/27/2015 10:41 AM, Zeng Linggang wrote:
> Hi!
> On Fri, 2015-01-23 at 14:01 +0300, Alexey Kodanev wrote:
>> 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>
>>> ---
>>> -} else {
>>> -   set LOOPCOUNT 25
>>> +	if [ -z $LOOPCOUNT ]; then
>>> +		LOOTCOUNT=25
>>                                              ^
>>                                              should be 'P' here
>>
> What is the 'P' mean?

sorry, pointed to the wrong (empty) place... "LOOPCOUNT=25", not 
"LOOTCOUNT=25"

>>> +	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@"
>>
>>
> Good idea. Thanks.
>
>>> +		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.
>>
> Thank you. I have found the patch.
>
>>> +		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"
>>
> Yep.
>
>>> +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?
>>
> It is not bad, but we could not sure whether the test is being run when
> we wait.

For example, it could be the below messages on each step or something 
more informative.

tst_resm TINFO "login with telnet, step $i"

expect ...

tst_resm TINFO "checking telnet status"
...

Best regards,
Alexey

------------------------------------------------------------------------------
Dive into the World of Parallel Programming. The Go Parallel Website,
sponsored by Intel and developed in partnership with Slashdot Media, is your
hub for all things parallel software development, from weekly thought
leadership blogs to news, videos, case studies, tutorials and more. Take a
look and join the conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2015-01-27 16:17 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
2015-01-27  7:41         ` Zeng Linggang
2015-01-27 16:19           ` Alexey Kodanev [this message]
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=54C7BA88.6060103@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox