blob: cf959e26e8731a6ddd1101cb2449e958a2e99163 [file] [log] [blame]
#! /bin/sh
#***********************************************************************
#
# Copyright (c) International Business Machines Corp., 2000
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
# the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this pronram; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
# FILE : ping
#
# PURPOSE: To test the basic functionality of the `ping` command.
#
# SETUP: If "RHOST" is not exported, then the local hostname is used.
#
# HISTORY:
# 06/06/03 Manoj Iyer manjo@mail.utexas.edu
# - Modified testcase to use test APIs and also fixed minor bugs
# 03/01 Robbie Williamson (robbiew@us.ibm.com)
# -Ported
#
#
#***********************************************************************
# Uncomment line below for debug output
#trace_logic=${trace_logic:-"set -x"}
$trace_logic
TC=ping
RHOST=${RHOST:-`hostname`}
COUNT=${COUNT:-5}
SLEEPTIME=${SLEEPTIME:-1}
PACKETSIZES=${PACKETSIZES:-"8 16 32 64 128 256 512 1024 2048 4064"}
#-----------------------------------------------------------------------
#
# 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
# PURPOSE: Executes the testcases.
#
#-----------------------------------------------------------------------
do_test()
{
$trace_logic
tst_resm TINFO "ping with 8 16 32 64 128 256 512 1024 2048 4064 ICMP packets"
for packetsize in $PACKETSIZES
do
tst_resm TINFO "calling ping with packet size = $packetsize"
ping -R -c $COUNT -s $packetsize $RHOST 2>&1 1>/dev/null
[ $? -eq 0 ] || end_testcase "failed: ping -c $COUNT -s $packetsize $RHOST"
sleep $SLEEPTIME
done
}
#=============================================================================
# FUNCTION NAME: end_testcase
#
# FUNCTION DESCRIPTION: Clean up
#
# PARAMETERS: string, IF AND ONLY IF the testcase fails
#
# RETURNS: None.
#=============================================================================
end_testcase()
{
$trace_logic
[ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
tst_resm TFAIL "Test Failed: $@"
exit 1
}
#*******************************************************************************
#
# FUNCTION: MAIN
#
#*******************************************************************************
export TCID="ping01"
export TST_TOTAL=1
export TST_COUNT=1
exists "ping"
do_test
end_testcase