killall_udp_traffic 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #!/bin/sh
  2. ################################################################################
  3. ## ##
  4. ## Copyright (c) International Business Machines Corp., 2005 ##
  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, but ##
  12. ## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
  13. ## or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License ##
  14. ## for more details. ##
  15. ## ##
  16. ## You should have received a copy of the GNU General Public License ##
  17. ## along with this program; if not, write to the Free Software ##
  18. ## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ##
  19. ## ##
  20. ## ##
  21. ################################################################################
  22. #
  23. # File:
  24. # killall_udp_traffic
  25. #
  26. # Description:
  27. # Kill all of the udp traffic utilities (ns-udpserver, ns-udpclient)
  28. #
  29. # Arguments:
  30. # None
  31. #
  32. # Returns:
  33. # None
  34. #
  35. # Author:
  36. # Mitsuru Chinen <mitch@jp.ibm.com>
  37. #
  38. # History:
  39. # Oct 19 2005 - Created (Mitsuru Chinen)
  40. #
  41. #-----------------------------------------------------------------------
  42. #Uncomment line below for debug output.
  43. #trace_logic=${trace_logic:-"set -x"}
  44. $trace_logic
  45. # Make sure the value of LTPROOT
  46. LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
  47. export LTPROOT
  48. # Check the environmanet variable for the test
  49. . check_envval || exit 1
  50. # Waiting time before outputting a warning message [sec]
  51. WARN_WAIT=300
  52. # Send SIGHUP both server and client
  53. killall -SIGHUP ns-udpserver >/dev/null 2>&1
  54. $LTP_RSH $RHOST "killall -SIGHUP ns-udpclient" >/dev/null 2>&1
  55. # Verify the server is dead.
  56. start_epoc=`date +%s`
  57. while true ; do
  58. ps auxw | fgrep -v grep | fgrep -l ns-udpserver >/dev/null 2>&1
  59. if [ $? -ne 0 ]; then
  60. break
  61. fi
  62. current_epoc=`date +%s`
  63. elapse_epoc=`expr $current_epoc - $start_epoc`
  64. if [ $elapse_epoc -ge $WARN_WAIT ]; then
  65. tst_resm TINFO "UDP traffic server is not dead over $WARN_WAIT sec" >&2
  66. fi
  67. killall -SIGHUP ns-udpserver >/dev/null 2>&1
  68. sleep 1
  69. done
  70. # Verify the client is dead.
  71. start_epoc=`date +%s`
  72. while true ; do
  73. #ret=`$LTP_RSH $RHOST 'ps auxw | fgrep -v grep | grep -l '[[:blank:]]ns-udpclient[[:blank:]]' >/dev/null 2>&1; echo $?'`
  74. ret=`$LTP_RSH $RHOST 'ps auxw | fgrep -v grep | grep -l '/ns-udpclient[[:blank:]]' >/dev/null 2>&1; echo $?'`
  75. if [ -z $ret ]; then
  76. continue
  77. fi
  78. if [ $ret -ne 0 ]; then
  79. break
  80. fi
  81. current_epoc=`date +%s`
  82. elapse_epoc=`expr $current_epoc - $start_epoc`
  83. if [ $elapse_epoc -ge $WARN_WAIT ]; then
  84. tst_resm TINFO "UDP traffic client is not dead over $WARN_WAIT sec" >&2
  85. fi
  86. $LTP_RSH $RHOST "killall -SIGHUP ns-udpclient" >/dev/null 2>&1
  87. sleep 1
  88. done