public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Simon Xu <xu.simon@oracle.com>
To: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH] rwho01: fix mistakes
Date: Wed, 25 Dec 2013 09:45:17 +0800	[thread overview]
Message-ID: <52BA38AD.7050500@oracle.com> (raw)
In-Reply-To: <1387435409-557-1-git-send-email-xu.simon@oracle.com>

Could anyone help to review this?

Thanks
Simon

On 2013/12/19 14:43, Simon Xu wrote:
> 1) fix the way it checks whether rwhod is running
> 2) fix the way it checks whether rwhod is started on remote host
> 3) fix do_cleanup, and no need to call tst_cleanup() in do_cleanup()
>     because it's called in end_testcase anyways
> 4) call do_cleanup() after do_test()
> 5) shorten sleep time to 5 seconds as 20 seconds are not necessary
>
> Signed-off-by: Simon Xu <xu.simon@oracle.com>
> ---
>   testcases/network/tcp_cmds/rwho/rwho01 | 31 ++++++++++++-------------------
>   1 file changed, 12 insertions(+), 19 deletions(-)
>
> diff --git a/testcases/network/tcp_cmds/rwho/rwho01 b/testcases/network/tcp_cmds/rwho/rwho01
> index eb31642..5f507ea 100755
> --- a/testcases/network/tcp_cmds/rwho/rwho01
> +++ b/testcases/network/tcp_cmds/rwho/rwho01
> @@ -48,14 +48,14 @@
>   #
>   #-----------------------------------------------------------------------
>   
> +LHOST_PID=""
> +RHOST_PID=""
> +
>   do_setup()
>   {
> -
>       TCtmp=${TCtmp:-$LTPROOT/testcases/bin/$TC${EXEC_SUFFIX}$$}
>   
> -    PID=0
> -    RHOST_PID=0
> -    SLEEPTIME=${SLEEPTIME:-20}
> +    SLEEPTIME=${SLEEPTIME:-5}
>       NUMLOOPS=${NUMLOOPS:-25}
>       OUTFILE=${OUTFILE:-$TCtmp/${TC}.out}
>   
> @@ -68,21 +68,18 @@ do_setup()
>   
>       trap do_cleanup EXIT
>   
> -    if ! ps -ef | awk '/rwhod/ && $0 !~ /awk/'; then
> +    if ! pgrep -x rwhod > /dev/null; then
>           tst_resm TINFO "Starting rwhod on $LHOST"
>           rwhod || end_testcase "Unable to start rwhod on $LHOST"
> -        PID=1
> +        LHOST_PID=$(pgrep -x rwhod)
>           sleep $SLEEPTIME
>       fi
>   
> -    if ! rsh -n -l root $RHOST ps -ef | awk '/rwhod/ && $0 !~ /awk/'; then
> +    if [ "$(rsh -n -l root $RHOST pgrep -x rwhod)" == "" ]; then
>           tst_resm TINFO "Starting rwhod on $RHOST"
> -        if ! rsh -n -l root $RHOST /usr/sbin/rwhod; then
> -            end_testcase "Unable to start rwhod on $RHOST"
> -        fi
> -        RHOST_PID=$(rsh -n -l root $RHOST ps -ef | awk '/rwhod/ && $0 !~ /awk/ {print $2 ; exit}')
> +        rsh -n -l root $RHOST /usr/sbin/rwhod
> +        RHOST_PID=$(rsh -n -l root $RHOST pgrep -x rwhod)
>           if [ -z "$RHOST_PID" ]; then
> -            RHOST_PID=0
>               end_testcase "Unable to start rwhod on $RHOST"
>           fi
>           sleep $SLEEPTIME
> @@ -92,7 +89,6 @@ do_setup()
>       if [ -z "$RHOSTNAME" ]; then
>           end_testcase "Unable to determine RHOSTNAME"
>       fi
> -
>   }
>   
>   #-----------------------------------------------------------------------
> @@ -103,7 +99,6 @@ do_setup()
>   
>   do_test()
>   {
> -
>       while [ $TST_COUNT -le $NUMLOOPS ]; do
>           rwho -a > $OUTFILE
>           HOST=`grep $LHOST $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
> @@ -130,18 +125,15 @@ do_test()
>   
>   do_cleanup()
>   {
> -    if [ $PID -ne 0 ]; then
> +    if [ -n "$LHOST_PID" ]; then
>           tst_resm TINFO "Stopping rwhod on $LHOST"
>           killall rwhod
>       fi
>   
> -    if [ $RHOST_PID -ne 0 ]; then
> +    if [ -n "$RHOST_PID" ]; then
>           tst_resm TINFO "Stopping rwhod on $RHOST"
>           rsh -n -l root $RHOST "killall rwhod"
>       fi
> -
> -    tst_cleanup
> -
>   }
>   
>   #-----------------------------------------------------------------------
> @@ -154,4 +146,5 @@ do_cleanup()
>   read_opts $*
>   do_setup
>   do_test
> +do_cleanup
>   end_testcase


------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

  reply	other threads:[~2013-12-25  1:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-19  6:43 [LTP] [PATCH] rwho01: fix mistakes Simon Xu
2013-12-25  1:45 ` Simon Xu [this message]
2014-01-21  1:44   ` Simon Xu
2014-01-30 11:25     ` Jan Stancek
2014-02-11  3:00       ` Simon Xu
2014-02-11 16:27 ` chrubis

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=52BA38AD.7050500@oracle.com \
    --to=xu.simon@oracle.com \
    --cc=ltp-list@lists.sourceforge.net \
    /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