blob: cf959e26e8731a6ddd1101cb2449e958a2e99163 [file] [log] [blame]
plars865695b2001-08-27 22:15:12 +00001#! /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:
iyermanojcf5a2f62003-06-06 22:11:30 +000029# 06/06/03 Manoj Iyer manjo@mail.utexas.edu
30# - Modified testcase to use test APIs and also fixed minor bugs
plars865695b2001-08-27 22:15:12 +000031# 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
iyermanojcf5a2f62003-06-06 22:11:30 +000040
plars865695b2001-08-27 22:15:12 +000041TC=ping
42
43RHOST=${RHOST:-`hostname`}
44COUNT=${COUNT:-5}
45SLEEPTIME=${SLEEPTIME:-1}
46PACKETSIZES=${PACKETSIZES:-"8 16 32 64 128 256 512 1024 2048 4064"}
47
48#-----------------------------------------------------------------------
49#
iyermanojcf5a2f62003-06-06 22:11:30 +000050# FUNCTION: exists
51#
52#-----------------------------------------------------------------------
53
54exists()
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#
plars865695b2001-08-27 22:15:12 +000070# FUNCTION: do_test
71# PURPOSE: Executes the testcases.
72#
73#-----------------------------------------------------------------------
74
75do_test()
76{
77 $trace_logic
iyermanojcf5a2f62003-06-06 22:11:30 +000078 tst_resm TINFO "ping with 8 16 32 64 128 256 512 1024 2048 4064 ICMP packets"
plars865695b2001-08-27 22:15:12 +000079 for packetsize in $PACKETSIZES
80 do
iyermanojcf5a2f62003-06-06 22:11:30 +000081 tst_resm TINFO "calling ping with packet size = $packetsize"
82 ping -R -c $COUNT -s $packetsize $RHOST 2>&1 1>/dev/null
robbiew21084802003-04-07 18:54:03 +000083 [ $? -eq 0 ] || end_testcase "failed: ping -c $COUNT -s $packetsize $RHOST"
plars865695b2001-08-27 22:15:12 +000084 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
98end_testcase()
99{
100 $trace_logic
101
iyermanojcf5a2f62003-06-06 22:11:30 +0000102 [ $# -eq 0 ] && { tst_resm TPASS "Test Successful"; exit 0; }
103 tst_resm TFAIL "Test Failed: $@"
plars865695b2001-08-27 22:15:12 +0000104 exit 1
105}
106
107#*******************************************************************************
108#
109# FUNCTION: MAIN
110#
111#*******************************************************************************
iyermanojcf5a2f62003-06-06 22:11:30 +0000112export TCID="ping01"
113export TST_TOTAL=1
114export TST_COUNT=1
115exists "ping"
plars865695b2001-08-27 22:15:12 +0000116do_test
117end_testcase