• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 (robbiew@us.ibm.com) 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
35
36TST_USE_LEGACY_API=1
37. tst_net.sh
38
39setup()
40{
41	tst_require_cmds netstat
42	tst_tmpdir
43}
44
45get_address()
46{
47	DIGIT=`ps -ef | grep mc_member.sh | grep -v grep | wc -l`
48	ADDRESS=$DIGIT.$DIGIT.$DIGIT.$DIGIT
49}
50
51do_test()
52{
53	tst_resm TINFO "doing test."
54	local ipaddr=$(tst_ipaddr)
55	COUNT=1
56	while [ $COUNT -le 2 ]
57	do
58		# Run setsockopt test with bogus network
59		get_address
60		tst_resm TINFO "Running mc_member_e on $ADDRESS"
61		mc_member_test -j -g $GLIST -s 30 -i $ADDRESS >/dev/null 2>&1
62
63		# Run setsockopt/getsockopt test
64		mc_member_test -g $GLIST -s 80 -i $ipaddr > $ERRFILE 2>&1 &
65
66		# Join twice and leave once and see if the groups are still
67		# joined on all specified interfaces.
68		for agroup in `cat $GLIST`
69		do
70			tst_resm TINFO "Running (1st) member on $ipaddr"
71			mc_member_test -j -g $GLIST -s 30 -i $ipaddr \
72				       > $ERRFILE 2>&1 &
73			sleep 5
74			grep "cannot join group" $ERRFILE
75			if [ $? -eq 0 ]; then
76				tst_brkm TFAIL "MC group could NOT join "\
77					      "$ipaddr"
78			fi
79
80			tst_resm TINFO "Running (2nd) member on $ipaddr"
81			mc_member_test -g $GLIST -s 60 -i $ipaddr \
82				       > $ERRFILE 2>&1 &
83			sleep 5
84			grep "cannot join group" $ERRFILE
85			if [ $? -eq 0 ]; then
86				tst_brkm TFAIL "MC group could NOT join "\
87					      "$ipaddr"
88			fi
89		done
90
91		# See if the groups are joined
92		for agroup in `cat $GLIST`
93		do
94			netstat -gn | grep $agroup
95			if [ $? -ne 0 ]; then
96				tst_brkm TFAIL "$agroup NOT joined to $ipaddr"
97			fi
98		done
99
100		tst_resm TINFO "Waiting 60 seconds! Do not interrupt!"
101		sleep 60 # Make sure the first process has stopped
102
103		for agroup in `cat $GLIST`
104		do
105			netstat -gn | grep $agroup
106			if [ $? -ne 1 ]; then
107				tst_brkm TFAIL "$agroup still joined on "\
108					      "$ipaddr"
109			fi
110		done
111
112		# Test the membership boundaries
113		tst_resm TINFO "Running member on too many groups over "\
114			       "$ipaddr"
115		mc_member_test -j -g $TooManyGLIST -i $ipaddr \
116			       > $ERRFILE 2>&1 &
117
118		count=`grep 105 $ERRFILE | wc -l`
119		if [ $count -gt 3 ]; then
120			tst_brkm TFAIL "Could not join members!"
121		fi
122
123		COUNT=$(( $COUNT + 1 ))
124
125	done
126
127	tst_resm TPASS "Test Successful"
128	tst_exit
129}
130
131do_cleanup()
132{
133	tst_rmdir
134}
135
136setup
137TST_CLEANUP=do_cleanup
138
139do_test
140