head     1.1;
branch   1.1.1;
access   ;
symbols  LTP_20031204:1.1.1.1 LINUX_TEST_PROJECT:1.1.1;
locks    ; strict;
comment  @# @;


1.1
date     2003.12.31.09.00.28;  author mtm;  state Exp;
branches 1.1.1.1;
next     ;

1.1.1.1
date     2003.12.31.09.00.28;  author mtm;  state Exp;
branches ;
next     ;


desc
@@



1.1
log
@Initial revision
@
text
@#!/bin/sh
#******************************************************************************
#
#   Copyright (c) International Business Machines  Corp., 2000
#
#   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 pronram;  if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
#  FILE   : arp
#
#  PURPOSE: To test the basic functionality of `arp`.
#
#  SETUP: The "RHOST" setting should be exported to be the hostname of
#         another machine on the same subnet.  Otherwise, the hostname
#         of the tested machine will be used.
#
#  HISTORY:
#    06/05/03 Manoj Iyer - manjo@@mail.utexas.edu 
#      - Ported to use LTP test harness API
#    03/01 Robbie Williamson (robbiew@@us.ibm.com)
#      -Ported
#
#-----------------------------------------------------------------------
#Uncomment line below for debug output.
#trace_logic=${trace_logic:-"set -x"}
$trace_logic

RHOST=${RHOST:-`hostname`}
SLEEPTIME=${SLEEPTIME:-1}
NUMLOOPS=${NUMLOOPS:-20}

#-----------------------------------------------------------------------
#
# FUNCTION:  exists
#
#-----------------------------------------------------------------------

exists()
{
   for cmd in $1
   do
       which $cmd 2>&1 1>/dev/null
	   if [ $? -ne 0 ]
	   then
	       tst_resm TBROK "Test broke: command $cmd not found"
		   exit 1
       fi
   done
}

#-----------------------------------------------------------------------
#
# FUNCTION:  do_setup
#
#-----------------------------------------------------------------------

do_setup()
{
   $trace_logic
   export TCID="arp01"
   export TST_TOTAL=1
   export TST_COUNT=1

   exists "arp tr awk ping sleep"

   LUSER=`id | tr -s '()' '  ' | awk '{print $2}'`
   [ "$LUSER" = "root" ] || end_testcase "Must be root to run this test!"
}

#-----------------------------------------------------------------------
#
# FUNCTION:  do_test
#
#-----------------------------------------------------------------------

do_test()
{
   $trace_logic

   COUNT=1
   while [ $COUNT -le $NUMLOOPS ]
   do
      arp -a 2>&1 1>/dev/null
      [ $? -eq 0 ] || end_testcase "arp -a failed"
      COUNT=`expr $COUNT + 1`
   done

   sleep $SLEEPTIME

   # PURPOSE:  stress the automatic creation of arp entries by pinging a host 
   #           and deleting the arp entry again.

   COUNT=1
   while [ $COUNT -le $NUMLOOPS ]
   do
      ping -c1 $RHOST 2>&1 1>/dev/null
      [ $? = 0 ] || end_testcase "ping $RHOST failed"
      arp -a | grep $RHOST 2>&1 1>/dev/null
      [ $? = 0 ] || end_testcase "arp -a failed"
      arp -d $RHOST 2>&1 1>/dev/null
      [ $? = 0 ] || end_testcase "arp -d $RHOST failed"
      COUNT=`expr $COUNT + 1`
      sleep $SLEEPTIME
   done
}

#=============================================================================
# FUNCTION NAME:        end_testcase
#
# FUNCTION DESCRIPTION: Clean up
#
# PARAMETERS:           string, IF AND ONLY IF the testcase fails
#
# RETURNS:              None.
#=============================================================================

end_testcase()
{
   $trace_logic

   [ $# = 0 ] && { echo "Test Successful"; exit 0; }
   tst_resm TFAIL "Test Failed: $@@"
   exit 1
}

#-----------------------------------------------------------------------
# FUNCTION: MAIN
# PURPOSE:  To invoke the functions to perform the tasks outlined in the
#           prologue.
# INPUT:    None.
# OUTPUT:   None.
#-----------------------------------------------------------------------
do_setup
do_test
end_testcase
@


1.1.1.1
log
@Initial import of the Linux Test Project (http://ltp.sourceforge.net).

This import is minus the Posix test suite, which will be imported separately,
and the HPI suite, which doesn't concern us.
@
text
@@
