From: <iye...@us...> - 2003-06-06 17:02:15
|
Update of /cvsroot/ltp/ltp/testcases/network/tcp_cmds/host In directory sc8-pr-cvs1:/tmp/cvs-serv29423 Modified Files: host01 Log Message: modified to use LTP test apis Index: host01 =================================================================== RCS file: /cvsroot/ltp/ltp/testcases/network/tcp_cmds/host/host01,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- host01 7 Apr 2003 21:39:55 -0000 1.3 +++ host01 6 Jun 2003 17:02:12 -0000 1.4 @@ -25,6 +25,8 @@ # SETUP: If "RHOST" is not exported, then the local hostname is used. # # HISTORY: +# 06/06/03 Manoj Iyer ma...@ma... +# - Modified to use LTP tests APIs # 03/01 Robbie Williamson (ro...@us...) # -Ported # @@ -38,6 +40,26 @@ NUMLOOPS=${NUMLOOPS:-20} SLEEPTIME=${SLEEPTIME:-0} +this_file=${0##*/} +#----------------------------------------------------------------------- +# +# FUNCTION: exists +# +#----------------------------------------------------------------------- + +exists() +{ + for cmd in $1 + do + which $cmd 2>&1 1>/dev/null + if [ $? -ne 0 ] + then + tst_resm TBROK "Test broke: command $cmd not found" + exit 1 + fi + done +} + #----------------------------------------------------------------------- # # FUNCTION: do_test @@ -47,15 +69,16 @@ do_test() { $trace_logic - echo "$this_file: doing $0." + tst_resm TINFO "$this_file: test the basic functionality of the `host` command." count=0 while [ $count -lt $NUMLOOPS ] do host $RHOST if [ $? -eq 0 ]; then - rhost_addr=`host $RHOST | tr -s ',' ' ' | awk '{print $4}'` - host $rhost_addr + rhost_addr=`host $RHOST | tr -s ',' ' ' | awk '{print $4}'` 2>&1 \ + >/dev/null + host $rhost_addr 2>&1 >/dev/null [ $? -eq 0 ] || end_testcase "host can not do a reverse lookup" else end_testcase "host $RHOST on local machine failed" @@ -78,15 +101,19 @@ end_testcase() { $trace_logic - echo "$this_file: doing $0." + tst_resm TINFO "$this_file: doing $0." - [ $# -eq 0 ] && { echo "Test Successful"; exit 0; } - echo "Test Failed: $@" + [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; } + tst_resm TFAIL "Test Failed: $@" exit 1 } #----------------------------------------------------------------------- # FUNCTION: MAIN #----------------------------------------------------------------------- +export TCID="host01" +export TST_TOTAL=1 +export TST_COUNT=1 +exists "host awk" do_test end_testcase |