Skip to contentSkip to conversation

rwho01: fix getting hostnames from command output and a typo

PATCH Superseded Simon Xu 2 participants 6 messages Oct 31, 2013 – Nov 6, 2013 1 message not in the archive

lore
Share & tools
lore

Simon Xu

author
#0 lore raw

PATCH 1/1 rwho01: fix getting hostnames from command output and a typo

Fix the way the script gets hostnames from rwho/ruptime command output, and the mistake that $COUNT is used instead of $TST_COUNT in do_test().

---
 testcases/network/tcp_cmds/rwho/rwho01 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
testcases/network/tcp_cmds/rwho/rwho01 +5 -5
index 2c82ef1..eb31642 100755
@@ -106,18 +106,18 @@ do_test()
 
     while [ $TST_COUNT -le $NUMLOOPS ]; do
         rwho -a > $OUTFILE
-        HOST=`awk "\\$2 ~ /$LHOST>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
         [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in rwho outfile"
-        HOST=`awk "\\$2 ~ /$RHOSTNAME>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
         [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in rwho outfile"
 
         ruptime -a > $OUTFILE
-        HOST=`awk "\\$1 ~ /$LHOST>/" $OUTFILE | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/ .*//' | uniq`
         [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in ruptime outfile"
-        HOST=`awk "\\$1 ~ /$RHOSTNAME>/" $OUTFILE | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/ .*//' | uniq`
         [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in ruptime outfile"
 
-        tst_resm TINFO "Test $COUNT of $NUMLOOPS complete"
+        tst_resm TINFO "Test $TST_COUNT of $NUMLOOPS complete"
         incr_tst_count
     done
 }
Signature · 13 lines
1.8.4


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#1 lore raw

Could anyone review this?

Thanks
Simon

Quoted 24 lines · Simon Xu

Fix the way the script gets hostnames from rwho/ruptime command output, and the mistake that $COUNT is used instead of $TST_COUNT in do_test().

---
  testcases/network/tcp_cmds/rwho/rwho01 | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
testcases/network/tcp_cmds/rwho/rwho01 +3 -3
index 2c82ef1..eb31642 100755
@@ -106,18 +106,18 @@ do_test()
 
      while [ $TST_COUNT -le $NUMLOOPS ]; do
          rwho -a > $OUTFILE
-        HOST=`awk "\\$2 ~ /$LHOST>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
          [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in rwho outfile"
-        HOST=`awk "\\$2 ~ /$RHOSTNAME>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
          [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in rwho outfile"
 
          ruptime -a > $OUTFILE
-        HOST=`awk "\\$1 ~ /$LHOST>/" $OUTFILE | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/ .*//' | uniq`

testcases/network/tcp_cmds/rwho/rwho01 do_test() · line 123

Quoted 10 lines
testcases/network/tcp_cmds/rwho/rwho01 +2 -2
          [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in ruptime outfile"
-        HOST=`awk "\\$1 ~ /$RHOSTNAME>/" $OUTFILE | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/ .*//' | uniq`
          [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in ruptime outfile"
 
-        tst_resm TINFO "Test $COUNT of $NUMLOOPS complete"
+        tst_resm TINFO "Test $TST_COUNT of $NUMLOOPS complete"
          incr_tst_count
      done
  }

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

author
#2 lore raw

PATCH v2 1/1 rwho01: fix getting hostnames from command output and $COUNT

Fix the way the script gets hostnames from rwho/ruptime command output, and the mistake that $COUNT is used instead of $TST_COUNT in do_test().

---
 testcases/network/tcp_cmds/rwho/rwho01 | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
testcases/network/tcp_cmds/rwho/rwho01 +5 -5
index 2c82ef1..eb31642 100755
@@ -106,18 +106,18 @@ do_test()
 
     while [ $TST_COUNT -le $NUMLOOPS ]; do
         rwho -a > $OUTFILE
-        HOST=`awk "\\$2 ~ /$LHOST>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
         [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in rwho outfile"
-        HOST=`awk "\\$2 ~ /$RHOSTNAME>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
         [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in rwho outfile"
 
         ruptime -a > $OUTFILE
-        HOST=`awk "\\$1 ~ /$LHOST>/" $OUTFILE | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/ .*//' | uniq`
         [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in ruptime outfile"
-        HOST=`awk "\\$1 ~ /$RHOSTNAME>/" $OUTFILE | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/ .*//' | uniq`
         [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in ruptime outfile"
 
-        tst_resm TINFO "Test $COUNT of $NUMLOOPS complete"
+        tst_resm TINFO "Test $TST_COUNT of $NUMLOOPS complete"
         incr_tst_count
     done
 }
Signature · 13 lines
1.8.4.2


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#3 lore raw

Re: [LTP] [PATCH V2] rwho01: fix getting hostnames from command output and $COUNT

Hi!

Quoted 2 lines

Fix the way the script gets hostnames from rwho/ruptime command output, and the mistake that $COUNT is used instead of $TST_COUNT in do_test().

The change from COUNT to TST_COUNT is pretty straightforward. Can you please describe more verbosely why is the second change needed? Has the output from rwho and ruptime changed over the time?

Quoted 36 lines

while [ $TST_COUNT -le $NUMLOOPS ]; do
rwho -a > $OUTFILE

testcases/network/tcp_cmds/rwho/rwho01 +5 -5
-        HOST=`awk "\\$2 ~ /$LHOST>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
         [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in rwho outfile"
-        HOST=`awk "\\$2 ~ /$RHOSTNAME>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
         [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in rwho outfile"
 
         ruptime -a > $OUTFILE
-        HOST=`awk "\\$1 ~ /$LHOST>/" $OUTFILE | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/ .*//' | uniq`
         [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in ruptime outfile"
-        HOST=`awk "\\$1 ~ /$RHOSTNAME>/" $OUTFILE | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/ .*//' | uniq`
         [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in ruptime outfile"
 
-        tst_resm TINFO "Test $COUNT of $NUMLOOPS complete"
+        tst_resm TINFO "Test $TST_COUNT of $NUMLOOPS complete"
         incr_tst_count
     done
 }
Signature · 13 lines
1.8.4.2


------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that
developers love is also attractive to malware creators. Download this white
paper to learn more about secure code signing practices that can help keep
Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
author
#5 lore raw

Re: [LTP] [PATCH V2] rwho01: fix getting hostnames from command output and $COUNT

In reply to a message not in the archive

Could anyone help to review this and other LTP network test patches?

Thanks
Simon

Quoted 52 lines · Simon Xu
Quoted 6 lines · On 2013/11/5 01:20, [email protected] wrote:

Hi!

Quoted 2 lines

Fix the way the script gets hostnames from rwho/ruptime command output, and the mistake that $COUNT is used instead of $TST_COUNT in do_test().

The change from COUNT to TST_COUNT is pretty straightforward. Can you please describe more verbosely why is the second change needed? Has the output from rwho and ruptime changed over the time?

rwho and ruptime are pretty old stuff, their output are not likely to have changed. The author intended to use the awk commands to get the line containing the hostname, but the output of the awk commands are all empty strings.

Thanks
Simon

Quoted 26 lines
Quoted 26 lines

while [ $TST_COUNT -le $NUMLOOPS ]; do
rwho -a > $OUTFILE

testcases/network/tcp_cmds/rwho/rwho01 +5 -5
-        HOST=`awk "\\$2 ~ /$LHOST>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
           [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in rwho outfile"
-        HOST=`awk "\\$2 ~ /$RHOSTNAME>/" $OUTFILE | cut -f1 -d: | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/[^ ]* *//; s/:.*//' | uniq`
           [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in rwho outfile"
 
           ruptime -a > $OUTFILE
-        HOST=`awk "\\$1 ~ /$LHOST>/" $OUTFILE | sort -u`
+        HOST=`grep $LHOST $OUTFILE | sed 's/ .*//' | uniq`
           [ "$HOST" = "$LHOST" ] || end_testcase "$LHOST is not in ruptime outfile"
-        HOST=`awk "\\$1 ~ /$RHOSTNAME>/" $OUTFILE | sort -u`
+        HOST=`grep $RHOSTNAME $OUTFILE | sed 's/ .*//' | uniq`
           [ "$HOST" = "$RHOSTNAME" ] || end_testcase "$RHOSTNAME is not in ruptime outfile"
 
-        tst_resm TINFO "Test $COUNT of $NUMLOOPS complete"
+        tst_resm TINFO "Test $TST_COUNT of $NUMLOOPS complete"
           incr_tst_count
       done
   }
Signature · 1 line
1.8.4.2
Quoted 10 lines
Quoted 10 lines

------------------------------------------------------------------------------
Android is increasing in popularity, but the open development platform that developers love is also attractive to malware creators. Download this white paper to learn more about secure code signing practices that can help keep Android apps secure.
http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

Quoted 10 lines

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore techniques for threading, error checking, porting, and tuning. Get the most from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list

#6 lore raw

Re: [LTP] [PATCH V2] rwho01: fix getting hostnames from command output and $COUNT

In reply to a message not in the archive

Hi!

Quoted 4 lines

rwho and ruptime are pretty old stuff, their output are not likely to have changed. The author intended to use the awk commands to get the line containing the hostname, but the output of the awk commands are all empty strings.

Ok, pushed, thanks.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
November Webinars for C, C++, Fortran Developers
Accelerate application performance with scalable programming models. Explore
techniques for threading, error checking, porting, and tuning. Get the most 
from the latest Intel processors and coprocessors. See abstracts and register
http://pubads.g.doubleclick.net/gampad/clk?id=60136231&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list