1#!/bin/sh 2# Copyright (c) 2015 Oracle and/or its affiliates. All Rights Reserved. 3# Copyright (c) International Business Machines Corp., 2000 4# 5# This program is free software; you can redistribute it and/or 6# modify it under the terms of the GNU General Public License as 7# published by the Free Software Foundation; either version 2 of 8# the License, or (at your option) any later version. 9# 10# This program is distributed in the hope that it would be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# 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 the Free Software Foundation, 17# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18# 19# TEST DESCRIPTION : To verify that two of the new options for level IPPROTO_IP 20# Service Interface allow the list of host group memberships 21# to be updated properly in response to the JoinHostGroup and 22# LeaveHostGroup requests. To test boundary conditions while 23# exercising IP Multicast JoinHostGroup and LeaveHostGroup 24# Service Interfaces. 25# 26# HISTORY: 03/26/01 Robbie Williamson ([email protected]) Ported 27 28GLIST=${GLIST:-$LTPROOT/testcases/data/mc_member/ManyGroups} 29TooManyGLIST=${TooManyGLIST:-$LTPROOT/testcases/data/mc_member/TooManyGroups} 30ERRFILE=${ERRFILE:-errors} 31 32TCID=mc_member 33TST_TOTAL=1 34TST_COUNT=1 35TST_CLEANUP=do_cleanup 36TST_USE_LEGACY_API=1 37 38setup() 39{ 40 tst_require_cmds netstat 41 tst_tmpdir 42} 43 44get_address() 45{ 46 DIGIT=`ps -ef | grep mc_member.sh | grep -v grep | wc -l` 47 ADDRESS=$DIGIT.$DIGIT.$DIGIT.$DIGIT 48} 49 50do_test() 51{ 52 tst_resm TINFO "doing test." 53 local ipaddr=$(tst_ipaddr) 54 COUNT=1 55 while [ $COUNT -le 2 ] 56 do 57 # Run setsockopt test with bogus network 58 get_address 59 tst_resm TINFO "Running mc_member_e on $ADDRESS" 60 mc_member_test -j -g $GLIST -s 30 -i $ADDRESS >/dev/null 2>&1 61 62 # Run setsockopt/getsockopt test 63 mc_member_test -g $GLIST -s 80 -i $ipaddr > $ERRFILE 2>&1 & 64 65 # Join twice and leave once and see if the groups are still 66 # joined on all specified interfaces. 67 for agroup in `cat $GLIST` 68 do 69 tst_resm TINFO "Running (1st) member on $ipaddr" 70 mc_member_test -j -g $GLIST -s 30 -i $ipaddr \ 71 > $ERRFILE 2>&1 & 72 sleep 5 73 grep "cannot join group" $ERRFILE 74 if [ $? -eq 0 ]; then 75 tst_brkm TFAIL "MC group could NOT join "\ 76 "$ipaddr" 77 fi 78 79 tst_resm TINFO "Running (2nd) member on $ipaddr" 80 mc_member_test -g $GLIST -s 60 -i $ipaddr \ 81 > $ERRFILE 2>&1 & 82 sleep 5 83 grep "cannot join group" $ERRFILE 84 if [ $? -eq 0 ]; then 85 tst_brkm TFAIL "MC group could NOT join "\ 86 "$ipaddr" 87 fi 88 done 89 90 # See if the groups are joined 91 for agroup in `cat $GLIST` 92 do 93 netstat -gn | grep $agroup 94 if [ $? -ne 0 ]; then 95 tst_brkm TFAIL "$agroup NOT joined to $ipaddr" 96 fi 97 done 98 99 tst_resm TINFO "Waiting 60 seconds! Do not interrupt!" 100 sleep 60 # Make sure the first process has stopped 101 102 for agroup in `cat $GLIST` 103 do 104 netstat -gn | grep $agroup 105 if [ $? -ne 1 ]; then 106 tst_brkm TFAIL "$agroup still joined on "\ 107 "$ipaddr" 108 fi 109 done 110 111 # Test the membership boundaries 112 tst_resm TINFO "Running member on too many groups over "\ 113 "$ipaddr" 114 mc_member_test -j -g $TooManyGLIST -i $ipaddr \ 115 > $ERRFILE 2>&1 & 116 117 count=`grep 105 $ERRFILE | wc -l` 118 if [ $count -gt 3 ]; then 119 tst_brkm TFAIL "Could not join members!" 120 fi 121 122 COUNT=$(( $COUNT + 1 )) 123 124 done 125 126 tst_resm TPASS "Test Successful" 127 tst_exit 128} 129 130do_cleanup() 131{ 132 tst_rmdir 133} 134 135. tst_net.sh 136setup 137do_test 138