check_netem 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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. # check_netem
  25. #
  26. # Description:
  27. # Check the remote host has netem functionality
  28. #
  29. # Arguments:
  30. # None
  31. #
  32. # Returns:
  33. # 0: netem functionality is available
  34. # 1: not avaialble
  35. #
  36. # Author:
  37. # Mitsuru Chinen <mitch@jp.ibm.com>
  38. #
  39. # History:
  40. # Oct 19 2005 - Created (Mitsuru Chinen)
  41. #
  42. #-----------------------------------------------------------------------
  43. #Uncomment line below for debug output.
  44. #trace_logic=${trace_logic:-"set -x"}
  45. $trace_logic
  46. # Make sure the value of LTPROOT
  47. LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
  48. export LTPROOT
  49. # Check the environmanet variable for the test
  50. . check_envval || exit 1
  51. # Check the tc command is available
  52. ret=`$LTP_RSH $RHOST 'PATH=/sbin:/usr/sbin:$PATH which tc >/dev/null 2>&1 ; echo $?'`
  53. if [ $ret -ne 0 ]; then
  54. echo "The remote host does not have tc command"
  55. exit 1
  56. fi
  57. # Check the netem functionality
  58. ofile=`mktemp -p $TMPDIR`
  59. $LTP_RSH $RHOST "PATH=/sbin:/usr/sbin:$PATH tc qdisc add dev eth0 root netem help" >$ofile 2>&1
  60. grep -l "Usage:.*netem" $ofile >/dev/null 2>&1
  61. if [ $? -ne 0 ]; then
  62. echo "The remote host does not have netem functionality"
  63. rm -f $ofile
  64. exit 1
  65. else
  66. rm -f $ofile
  67. exit 0
  68. fi