blob: 8882d4cb6d5d3aacd4f9fd54fc8096631581956e [file] [log] [blame]
#!/bin/sh
unset LIBPATH
#
# 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 program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
# FILE : mc_commo
#
# TEST DESCRIPTION : To verify that IP Multicast can be used to send UDP datagrams
# between two or more nodes on the same subnetwork using
# a specific IP Multicast group and a specific port address.
#
# HISTORY:
# 03/26/01 Robbie Williamson (robbiew@us.ibm.com)
# -Ported
# 08/01/06 Michael Reed mreedltp@vnet.ibm.com
# - The pinging of a specific IP Multicast group has been bypassed
# for SLES
#
#******************************************************************************
#Uncomment line below for debug output.
#trace_logic=${trace_logic:-"set -x"}
$trace_logic
TC=mc_commo
TCtmp=${TCtmp:-"/tmp/mc_commo.$$"}
CLEANUP=${CLEANUP:-ON}
EXECUTABLES="mc_recv"
REMOTE_EXEC="mc_send"
LTPROOT=${LTPROOT:-../../../..}
TTL=10
PORT=3333
RHOST=${RHOST:-`hostname`}
OUTFILE=$TCtmp/mc_commo_out
NUMLOOPS=${NUMLOOPS:-2}
INTERFACE=${INTERFACE:-$("$LTPROOT/bin/gethost" `hostname` | grep addresses: | awk '{print $2}')}
this_file=${0##*/}
trap "interrupt_test" 2
do_setup() {
mkdir -p $TCtmp
OCTET=`ps -ewf | grep [m]c_commo | wc -l | awk '{print $1}'`
GROUP_ADDR=224.0.0.$OCTET
}
#*******************************************************************************
#
# FUNCTION: do_test
# PURPOSE: Executes the testcases.
# INPUT: Number of iterations
# OUTPUT: Error messages are logged when any verification test
# fails.
#
#-----------------------------------------------------------------------
do_test ()
{
$trace_logic
echo "$this_file: doing $0."
COUNT=1
while [ $COUNT -le $NUMLOOPS ]
do
# Run setsockopt/getsockopt test
# Start up the recv on local host
echo "Starting mc_recv on $GROUP_ADDR $INTERFACE $PORT"
"$LTPROOT/testcases/bin/$EXECUTABLES" $GROUP_ADDR $INTERFACE $PORT \
>> $OUTFILE &
SERVER_PID=$!
sleep 5
ps -ewf | grep mc_recv | grep -v grep
[ $? = 0 ] || end_testcase "Could NOT start mc_recv on `hostname`"
grep -q "cannot join group" $OUTFILE
[ $? = 0 ] && end_testcase "Membership NOT set"
netstat -ng | grep -q $GROUP_ADDR
[ $? = 0 ] || end_testcase "membership not set for $GROUP_ADDR"
# This eliminates the ping test but does not compromise the execution of the
# test
# distro_version=""
# distro_name=""
# distro_version=`cat /etc/issue | awk {'print $7'}`
# distro_name=`cat /etc/issue | awk {'print $3'}`
# if [ $distro_version -ge 9 -a $distro_name = SUSE ]; then
# echo "Ping test skipped"
# else
# echo "Running ping to verify group can be reached "
# ping -c5 -I $INTERFACE $GROUP_ADDR > /dev/null
# [ $? = 0 ] || end_testcase "failed: ping -c5 -I $INTERFACE $GROUP_ADDR"
# fi
# Flood the interface in an attempt to overload the sends and
# recvs to and from the host.
#ping -f -s 4800 -I $INTERFACE $GROUP_ADDR >$TCtmp/pingfile 2>&1 &
#PING_PID=$!
#sleep 2
#kill -9 $PING_PID >/dev/null 2>&1
#cat $TCtmp/pingfile | grep "Message too long"
#[ $? = 0 ] || end_testcase "ping -f -s 4088 -c 1000 -I $INTERFACE $GROUP_ADDR should return an error regarding message being too long"
for HOST in $RHOST
do
echo "Running on $HOST mc_send $GROUP_ADDR $HOST $PORT $TTL"
rsh -n -l root $HOST "$LTPROOT/testcases/bin/$REMOTE_EXEC" $GROUP_ADDR \
$HOST $PORT $TTL >/dev/null &
sleep 10
rsh -n -l root $HOST "ps -ewf | grep mc_send | grep -v grep"
[ $? = 0 ] || end_testcase "Could NOT start mc_send on $HOST"
done
echo "Waiting for 100 sec.! Do not interrupt."
sleep 100 #wait until datagrams are received in $STATUS
COUNT=$(( $COUNT + 1 ))
done
#test if datagrams has been sent
for HOST in $RHOST
do
grep -q "$HOST [0-9] [0-9]" $OUTFILE
[ $? = 0 ] || end_testcase "NO Datagrams received from $HOST"
done
}
#-----------------------------------------------------------------------
#
# FUNCTION: do_cleanup
# PURPOSE: Called when the testcase is interrupted by the user
# or by interrupt_testcase() when time limit expired
# INPUT: None.
# OUTPUT: None.
#
#-----------------------------------------------------------------------
do_cleanup()
{
$trace_logic
echo "$this_file: doing $0."
# Kill all recv processes
echo "Killing all recv processes!!"
kill -9 $SERVER_PID
#PIDLIST=`ps -ef |grep "ping -f -s 4800" |awk '{print $2}'`
#for PID in $PIDLIST
#do
# kill -9 $PID > /dev/null 2>>/dev/null
#done
rm -rf $TCtmp/pingfile
rm -rf $TCtmp/mc_commo_out
rm -rf $TCtmp
}
#=============================================================================
# FUNCTION NAME: end_testcase
#
# FUNCTION DESCRIPTION: Clean up
#
# PARAMETERS: string, IF AND ONLY IF the testcase fails
#
# RETURNS: None.
#=============================================================================
end_testcase()
{
$trace_logic
echo "$this_file: doing $0."
# Call other cleanup functions
[ $CLEANUP = "ON" ] && do_cleanup
[ $# = 0 ] && { echo "Test Successful"; exit 0; }
echo "Test Failed: $@"
exit 1
}
#*****************************************************************************
#
# FUNCTION: interrupt_test
# PURPOSE: Handle process interrupts set by trap.
# INPUT: none
# OUTPUT: none
#
#*****************************************************************************
interrupt_test()
{
echo "test interrupted"
end_testcase
}
#******************************************************************************
#
# FUNCTION: MAIN
# PURPOSE: To invoke functions that perform the tasks as described in
# the design in the prolog above.
# INPUT: See SETUP in the prolog above.
# OUTPUT: Logged run results written to testcase run log
#
#******************************************************************************
do_setup
do_test
end_testcase