74 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Bash
		
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			2.8 KiB
		
	
	
	
		
			Bash
		
	
	
	
#!/bin/sh
 | 
						|
 | 
						|
################################################################################
 | 
						|
##                                                                            ##
 | 
						|
## Copyright (c) International Business Machines  Corp., 2005                 ##
 | 
						|
##                                                                            ##
 | 
						|
## This program is free software;  you can redistribute it and#or modify      ##
 | 
						|
## it under the terms of the GNU General Public License as published by       ##
 | 
						|
## the Free Software Foundation; either version 2 of the License, or          ##
 | 
						|
## (at your option) any later version.                                        ##
 | 
						|
##                                                                            ##
 | 
						|
## This program is distributed in the hope that it will be useful, but        ##
 | 
						|
## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
 | 
						|
## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
 | 
						|
## for more details.                                                          ##
 | 
						|
##                                                                            ##
 | 
						|
## You should have received a copy of the GNU General Public License          ##
 | 
						|
## along with this program;  if not, write to the Free Software               ##
 | 
						|
## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
 | 
						|
##                                                                            ##
 | 
						|
##                                                                            ##
 | 
						|
################################################################################
 | 
						|
#
 | 
						|
# File:
 | 
						|
#   check_netem
 | 
						|
#
 | 
						|
# Description:
 | 
						|
#   Check the remote host has netem functionality
 | 
						|
#
 | 
						|
# Arguments:
 | 
						|
#   None
 | 
						|
#
 | 
						|
# Returns:
 | 
						|
#   0: netem functionality is available
 | 
						|
#   1: not avaialble
 | 
						|
#
 | 
						|
# Author:
 | 
						|
#   Mitsuru Chinen <mitch@jp.ibm.com>
 | 
						|
#
 | 
						|
# History:
 | 
						|
#   Oct 19 2005 - Created (Mitsuru Chinen)
 | 
						|
#
 | 
						|
#-----------------------------------------------------------------------
 | 
						|
#Uncomment line below for debug output.
 | 
						|
#trace_logic=${trace_logic:-"set -x"}
 | 
						|
$trace_logic
 | 
						|
 | 
						|
# Make sure the value of LTPROOT
 | 
						|
LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
 | 
						|
export LTPROOT
 | 
						|
 | 
						|
# Check the environmanet variable for the test
 | 
						|
. check_envval || exit 1
 | 
						|
 | 
						|
# Check the tc command is available
 | 
						|
ret=`$LTP_RSH $RHOST 'PATH=/sbin:/usr/sbin:$PATH which tc >/dev/null 2>&1 ; echo $?'`
 | 
						|
if [ $ret -ne 0 ]; then
 | 
						|
    echo "The remote host does not have tc command"
 | 
						|
    exit 1
 | 
						|
fi
 | 
						|
 | 
						|
# Check the netem functionality
 | 
						|
ofile=`mktemp -p $TMPDIR`
 | 
						|
$LTP_RSH $RHOST "PATH=/sbin:/usr/sbin:$PATH tc qdisc add dev eth0 root netem help" >$ofile 2>&1
 | 
						|
grep -l "Usage:.*netem" $ofile >/dev/null 2>&1
 | 
						|
if [ $? -ne 0 ]; then
 | 
						|
    echo "The remote host does not have netem functionality"
 | 
						|
    rm -f $ofile
 | 
						|
    exit 1
 | 
						|
else
 | 
						|
    rm -f $ofile
 | 
						|
    exit 0
 | 
						|
fi
 |