plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | #*********************************************************************** |
| 3 | # |
| 4 | # Copyright (c) International Business Machines Corp., 2000 |
| 5 | # |
| 6 | # This program is free software; you can redistribute it and/or modify |
| 7 | # it under the terms of the GNU General Public License as published by |
| 8 | # the Free Software Foundation; either version 2 of the License, or |
| 9 | # (at your option) any later version. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 14 | # the GNU General Public License for more details. |
| 15 | # |
| 16 | # You should have received a copy of the GNU General Public License |
| 17 | # along with this pronram; if not, write to the Free Software |
| 18 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | # |
| 20 | # |
| 21 | # |
| 22 | # FILE : ping |
| 23 | # |
| 24 | # PURPOSE: To test the basic functionality of the `ping` command. |
| 25 | # |
| 26 | # SETUP: If "RHOST" is not exported, then the local hostname is used. |
| 27 | # |
| 28 | # HISTORY: |
iyermanoj | cf5a2f6 | 2003-06-06 22:11:30 +0000 | [diff] [blame^] | 29 | # 06/06/03 Manoj Iyer manjo@mail.utexas.edu |
| 30 | # - Modified testcase to use test APIs and also fixed minor bugs |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 31 | # 03/01 Robbie Williamson (robbiew@us.ibm.com) |
| 32 | # -Ported |
| 33 | # |
| 34 | # |
| 35 | #*********************************************************************** |
| 36 | # Uncomment line below for debug output |
| 37 | #trace_logic=${trace_logic:-"set -x"} |
| 38 | $trace_logic |
| 39 | |
iyermanoj | cf5a2f6 | 2003-06-06 22:11:30 +0000 | [diff] [blame^] | 40 | |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 41 | TC=ping |
| 42 | |
| 43 | RHOST=${RHOST:-`hostname`} |
| 44 | COUNT=${COUNT:-5} |
| 45 | SLEEPTIME=${SLEEPTIME:-1} |
| 46 | PACKETSIZES=${PACKETSIZES:-"8 16 32 64 128 256 512 1024 2048 4064"} |
| 47 | |
| 48 | #----------------------------------------------------------------------- |
| 49 | # |
iyermanoj | cf5a2f6 | 2003-06-06 22:11:30 +0000 | [diff] [blame^] | 50 | # FUNCTION: exists |
| 51 | # |
| 52 | #----------------------------------------------------------------------- |
| 53 | |
| 54 | exists() |
| 55 | { |
| 56 | for cmd in $1 |
| 57 | do |
| 58 | which $cmd 2>&1 1>/dev/null |
| 59 | if [ $? -ne 0 ] |
| 60 | then |
| 61 | tst_resm TBROK "Test broke: command $cmd not found" |
| 62 | exit 1 |
| 63 | fi |
| 64 | done |
| 65 | } |
| 66 | |
| 67 | |
| 68 | #----------------------------------------------------------------------- |
| 69 | # |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 70 | # FUNCTION: do_test |
| 71 | # PURPOSE: Executes the testcases. |
| 72 | # |
| 73 | #----------------------------------------------------------------------- |
| 74 | |
| 75 | do_test() |
| 76 | { |
| 77 | $trace_logic |
iyermanoj | cf5a2f6 | 2003-06-06 22:11:30 +0000 | [diff] [blame^] | 78 | tst_resm TINFO "ping with 8 16 32 64 128 256 512 1024 2048 4064 ICMP packets" |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 79 | for packetsize in $PACKETSIZES |
| 80 | do |
iyermanoj | cf5a2f6 | 2003-06-06 22:11:30 +0000 | [diff] [blame^] | 81 | tst_resm TINFO "calling ping with packet size = $packetsize" |
| 82 | ping -R -c $COUNT -s $packetsize $RHOST 2>&1 1>/dev/null |
robbiew | 2108480 | 2003-04-07 18:54:03 +0000 | [diff] [blame] | 83 | [ $? -eq 0 ] || end_testcase "failed: ping -c $COUNT -s $packetsize $RHOST" |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 84 | sleep $SLEEPTIME |
| 85 | done |
| 86 | } |
| 87 | |
| 88 | #============================================================================= |
| 89 | # FUNCTION NAME: end_testcase |
| 90 | # |
| 91 | # FUNCTION DESCRIPTION: Clean up |
| 92 | # |
| 93 | # PARAMETERS: string, IF AND ONLY IF the testcase fails |
| 94 | # |
| 95 | # RETURNS: None. |
| 96 | #============================================================================= |
| 97 | |
| 98 | end_testcase() |
| 99 | { |
| 100 | $trace_logic |
| 101 | |
iyermanoj | cf5a2f6 | 2003-06-06 22:11:30 +0000 | [diff] [blame^] | 102 | [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; } |
| 103 | tst_resm TFAIL "Test Failed: $@" |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 104 | exit 1 |
| 105 | } |
| 106 | |
| 107 | #******************************************************************************* |
| 108 | # |
| 109 | # FUNCTION: MAIN |
| 110 | # |
| 111 | #******************************************************************************* |
iyermanoj | cf5a2f6 | 2003-06-06 22:11:30 +0000 | [diff] [blame^] | 112 | export TCID="ping01" |
| 113 | export TST_TOTAL=1 |
| 114 | export TST_COUNT=1 |
| 115 | exists "ping" |
plars | 865695b | 2001-08-27 22:15:12 +0000 | [diff] [blame] | 116 | do_test |
| 117 | end_testcase |