1#!/bin/sh
2
3################################################################################
4##                                                                            ##
5## Copyright (c) International Business Machines  Corp., 2005                 ##
6##                                                                            ##
7## This program is free software;  you can redistribute it and#or modify      ##
8## it under the terms of the GNU General Public License as published by       ##
9## the Free Software Foundation; either version 2 of the License, or          ##
10## (at your option) any later version.                                        ##
11##                                                                            ##
12## This program is distributed in the hope that it will be useful, but        ##
13## WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY ##
14## or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License   ##
15## for more details.                                                          ##
16##                                                                            ##
17## You should have received a copy of the GNU General Public License          ##
18## along with this program;  if not, write to the Free Software               ##
19## Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA    ##
20##                                                                            ##
21##                                                                            ##
22################################################################################
23#
24# File:
25#   check_netem
26#
27# Description:
28#   Check the remote host has netem functionality
29#
30# Arguments:
31#   None
32#
33# Returns:
34#   0: netem functionality is available
35#   1: not avaialble
36#
37# Author:
38#   Mitsuru Chinen <mitch@jp.ibm.com>
39#
40# History:
41#   Oct 19 2005 - Created (Mitsuru Chinen)
42#
43#-----------------------------------------------------------------------
44#Uncomment line below for debug output.
45#trace_logic=${trace_logic:-"set -x"}
46$trace_logic
47
48# Make sure the value of LTPROOT
49LTPROOT=${LTPROOT:-`(cd ../../../../ ; pwd)`}
50export LTPROOT
51
52# Check the environmanet variable for the test
53. check_envval || exit 1
54
55# Check the tc command is available
56ret=`$LTP_RSH $RHOST 'PATH=/sbin:/usr/sbin:$PATH which tc >/dev/null 2>&1 ; echo $?'`
57if [ $ret -ne 0 ]; then
58    echo "The remote host does not have tc command"
59    exit 1
60fi
61
62# Check the netem functionality
63ofile=`mktemp -p $TMPDIR`
64$LTP_RSH $RHOST "PATH=/sbin:/usr/sbin:$PATH tc qdisc add dev eth0 root netem help" >$ofile 2>&1
65grep -l "Usage:.*netem" $ofile >/dev/null 2>&1
66if [ $? -ne 0 ]; then
67    echo "The remote host does not have netem functionality"
68    rm -f $ofile
69    exit 1
70else
71    rm -f $ofile
72    exit 0
73fi
74