mc_member.sh 3.7 KB

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