1 #!/bin/sh 2 #*********************************************************************** 3 # Copyright (c) International Business Machines Corp., 2000 4 # 5 # This program is free software; you can redistribute it and/or modify 6 # it under the terms of the GNU General Public License as published by 7 # the Free Software Foundation; either version 2 of the License, or 8 # (at your option) any later version. 9 # 10 # This program is distributed in the hope that it will be useful, 11 # but WITHOUT ANY WARRANTY; without even the implied warranty of 12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 13 # the GNU General Public License for more details. 14 # 15 # You should have received a copy of the GNU General Public License 16 # along with this program; if not, write to the Free Software 17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18 # 19 # 20 # 21 # FILE : host 22 # 23 # PURPOSE: To test the basic functionality of the `netstat` command. 24 # 25 # HISTORY: 26 # 06/06/03 Manoj Iyer manjo (at] mail.utexas.edu 27 # - Modified test to use LTP harness API 28 # - Fixed bugs. 29 # 03/01 Robbie Williamson (robbiew (at] us.ibm.com) 30 # -Ported 31 # 32 # 33 #----------------------------------------------------------------------- 34 35 do_setup() 36 { 37 NUMLOOPS=${NUMLOOPS:-1} 38 SLEEPTIME=${SLEEPTIME:-0} 39 40 tst_setup 41 42 exists netstat 43 } 44 45 #------------------------------------------------------------------------- 46 # FUNCTION: do_test 47 # PURPOSE: 48 # To loop for LOOPCOUNT times 49 # If MAXCOUNT is "-1" the "while" 50 # loop will execute until terminated by "intr" signal. 51 # INPUT: None. 52 # OUTPUT: Informational messages are logged into the run log. 53 # 54 #----------------------------------------------------------------------- 55 56 do_test() { 57 58 while [ $TST_COUNT -le $NUMLOOPS ]; do 59 60 for flag in "-s" "-rn" "-i" "-gn" "-apn"; do 61 if ! netstat $flag 1>/dev/null 2>&1; then 62 end_testcase "netstat $flag failed" 63 fi 64 done 65 66 incr_tst_count 67 68 sleep $SLEEPTIME 69 70 done 71 72 } 73 74 #----------------------------------------------------------------------- 75 # 76 # FUNCTION: MAIN 77 # PURPOSE: To invoke functions that perform the tasks as described in 78 # the design in the prolog above. 79 # INPUT: See SETUP in the prolog above. 80 # OUTPUT: Logged run results written to testcase run log 81 # 82 #----------------------------------------------------------------------- 83 . net_cmdlib.sh 84 85 read_opts $* 86 do_setup 87 do_test 88 end_testcase 89