1#!/bin/sh 2# 3# Copyright (c) International Business Machines Corp., 2000 4# 5# This program is free software; you can redistribute it and/or modify 6# it under the terms of the GNU General Public License as published by 7# the Free Software Foundation; either version 2 of the License, or 8# (at your option) any later version. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See 13# the GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, write to the Free Software 17# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 18# 19# 20# 21# FILE : host 22# 23# PURPOSE: To test the basic functionality of the `host` command. 24# 25# SETUP: If "RHOST" is not exported, then the local hostname is used. 26# 27# HISTORY: 28# 06/06/03 Manoj Iyer manjo@mail.utexas.edu 29# - Modified to use LTP tests APIs 30# 03/01 Robbie Williamson (robbiew@us.ibm.com) 31# -Ported 32# 33# 34#----------------------------------------------------------------------- 35 36do_setup() 37{ 38 NUMLOOPS=${NUMLOOPS:-1} 39 SLEEPTIME=${SLEEPTIME:-0} 40 41 tst_setup 42 43 exists awk host hostname 44 45 RHOST=${RHOST:-`hostname`} 46 47} 48 49#----------------------------------------------------------------------- 50# 51# FUNCTION: do_test 52# 53#----------------------------------------------------------------------- 54 55do_test() 56{ 57 58 tst_resm TINFO "test basic functionality of the \`$TC' command." 59 60 while [ $TST_COUNT -lt $NUMLOOPS ]; do 61 62 if rhost_addr=$(host $RHOST); then 63 rhost_addr=$(echo "$rhost_addr" | awk -F, '{print $NF}') 2>&1 >/dev/null 64 if ! host $rhost_addr 2>&1 >/dev/null; then 65 end_testcase "reverse lookup with host failed" 66 fi 67 68 else 69 end_testcase "host $RHOST on local machine failed" 70 fi 71 72 incr_tst_count 73 sleep $SLEEPTIME 74 75 done 76 77} 78 79#----------------------------------------------------------------------- 80# FUNCTION: MAIN 81#----------------------------------------------------------------------- 82. net_cmdlib.sh 83 84read_opts $* 85do_setup 86do_test 87end_testcase 88