#!/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_envval
#
# Description:
#   Check the environment variable for the network stress test
#
# Returns:
#   0: All necessary environment variables are set.
#   1: Some variables are not set
#
# 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

. cmdlib.sh

exists cut locale rsh

# Unset the locale cocerned variables
for env in `locale | cut -f 1 -d '='` ; do
    unset $env
done
unset LANGUAGE

# RHOST
RHOST=${RHOST:=127.0.0.1}
if [ x${RHOST} = x ]; then
    tst_resm TBROK "Environment variable RHOST is not set."
    exit 1
fi

# LHOST_HWADDRS
LHOST_HWADDRS=${LHOST_HWADDRS:=}
if [ x"${LHOST_HWADDRS}" = x ]; then
    tst_resm TBROK "Environment variable LHOST_HWADDRS is not set."
    exit 1
fi

# RHOST_HWADDRS
RHOST_HWADDRS=${RHOST_HWADDRS:=}
if [ x"${RHOST_HWADDRS}" = x ]; then
    tst_resm TBROK "Environment variable RHOST_HWADDRS is not set."
    exit 1
fi

# LTP_RSH
LTP_RSH=${LTP_RSH:=}
if [ x"${LTP_RSH}" = x ]; then
    LTP_RSH="rsh -n"
elif [ "$LTP_RSH" = "rsh" ]; then
    LTP_RSH="rsh -n"
fi

# TMPDIR
TMPDIR=${TMPDIR:=}
if [ x"${TMPDIR}" = x ]; then
    TMPDIR=/tmp
fi