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.21;  author mtm;  state Exp;
branches 1.1.1.1;
next     ;

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


desc
@@



1.1
log
@Initial revision
@
text
@#! /bin/sh
#
#   Copyright (c) International Business Machines  Corp., 2001
#
#   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 implie; 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#  FILE   : nfs02
#
#  PURPOSE: Tests NFS copy of various filesizes, file consistency between copies
#           and preservation of write/nowrite permissions.
#
#  SETUP: The home directory of root on the machine exported as "RHOST"
#         MUST have a ".rhosts" file with the hostname of the machine
#         where the test is executed.
#
#
#  HISTORY:
#    05/15/01 Robbie Williamson (robbiew@@us.ibm.com)
#      -Ported
#
#**********************************************************************

#Uncomment line below for debug output.
#trace_logic=${trace_logic:-"set -x"}

$trace_logic

#-----------------------------------------------------------------------
# Initialize local variables
#-----------------------------------------------------------------------

TC=nfs02
TCbin=${TCbin:=`pwd`}
TCdat=${TCdat:=$TCbin/dat}
TCsrc=${TCsrc:=$TCbin}
TCtmp=${TCtmp:=$TCbin/$TC$$}
RHOST=${RHOST:=`hostname`}
VERSION=${VERSION:=2}
SOCKET_TYPE=${SOCKET_TYPE:=udp}
TESTDIR=${TESTDIR:=/mnt/$TC$$}
CLEANUP=${CLEANUP:="ON"}


#---------------------------------------------------------------------#
# FUNCTION: do_setup
# PURPOSE:  To create the necessary files to carry out the test
# INPUT:    None.
# OUTPUT:   None.
#---------------------------------------------------------------------#
do_setup()
{
$trace_logic

   echo "do_setup $TC"

   IAM=${IAM:=`whoami`}
   [ $IAM == "root" ] || end_testcase "Must be root user"
   
   #Setup and Export the data directory on RHOST
   rsh -n $RHOST "mkdir -p $TESTDIR"
   [ $? -eq 0 ] || end_testcase "Could not create $TESTDIR from $RHOST"
   rsh -n $RHOST "/usr/sbin/exportfs -i *:$TESTDIR -o rw,no_root_squash "
   [ $? -eq 0 ] || end_testcase "Could not export $TESTDIR from $RHOST"

   #Verify export
   /usr/sbin/showmount -e $RHOST | grep $TESTDIR
   [ $? -eq 0 ] || end_testcase "$TESTDIR not exported"

   #Create $TCtmp for mount point
   mkdir -p $TCtmp
   [ $? -eq 0 ] || end_testcase "Could not create $TCtmp"

   #Mount $TCdat from RHOST.
   mount -o vers=$VERSION,proto=$SOCKET_TYPE $RHOST:$TESTDIR $TCtmp
   [ $? -eq 0 ] || end_testcase "Could not mount from $RHOST"

}


#---------------------------------------------------------------------#
# FUNCTION: do_test1
# PURPOSE:  Perform the necessary steps to complete the test.
# INPUT:    None.
# OUTPUT:    Error messages are logged if any of the tests fail.
#---------------------------------------------------------------------#
do_test1() 
{
$trace_logic 
  echo "do_test1 $TC "
  cp $TCdat/maxsize.fil $TCtmp &
  wait $!
  echo "compare both maxsize.fils"
  diff $TCtmp/maxsize.fil $TCdat/maxsize.fil 
  [ $? -eq 0 ] || end_testcase "'diff' of maxsize.fil FAILED" 

}

#---------------------------------------------------------------------#
# FUNCTION: do_test2
# PURPOSE:  Perform the necessary steps to complete the test.
# INPUT:    None.
# OUTPUT:    Error messages are logged if any of the tests fail.
#---------------------------------------------------------------------#
do_test2() 
{
$trace_logic
   echo "do_test2 $TC "
   cp $TCdat/smallsize.fil $TCtmp &
   wait $!
   cp $TCdat/medsize.fil $TCtmp &
   wait $!
   cp $TCdat/largesize.fil $TCtmp &
   wait $!

   #small file
   cp $TCtmp/smallsize.fil $TCtmp/smallsize.filcp &
   wait $!
   diff $TCtmp/smallsize.filcp $TCdat/smallsize.fil
   [ $? -eq 0 ] || end_testcase "'diff' of smallsize.fil FAILED" 

   #medium file
   cp $TCtmp/medsize.fil $TCtmp/medsize.filcp &
   wait $!
   diff $TCtmp/medsize.filcp $TCdat/medsize.fil
   [ $? -eq 0 ] || end_testcase "'diff' of medsize.fil FAILED" 

   #large file
   cp $TCtmp/largesize.fil $TCtmp/largesize.filcp &
   wait $!
   diff $TCtmp/largesize.filcp $TCdat/largesize.fil
   [ $? -eq 0 ] || end_testcase "'diff' of largesize.fil FAILED" 

}

#---------------------------------------------------------------------#
# FUNCTION: do_test3
# PURPOSE:  Perform the necessary steps to complete the test.
# INPUT:    None.
# OUTPUT:    Error messages are logged if any of the tests fail.
#---------------------------------------------------------------------#
do_test3()
{
$trace_logic
   echo "do_test3 $TC "
   chmod a-w $TCtmp/smallsize.fil &
   wait $!
   ls -l $TCtmp/smallsize.fil | grep "r--" 
   [ $? -eq 0 ] || end_testcase "Removal of write permissions not honored on smallsize.fil"
   chmod a+w $TCtmp/smallsize.fil
}

#---------------------------------------------------------------------#
# FUNCTION: do_cleanup
# PURPOSE:  To delete all the files created to run this test.
# INPUT:    None.
# OUTPUT:   None.
#---------------------------------------------------------------------#
do_cleanup() 
{
$trace_logic
   echo "do_cleanup $TC "
   rm -f $TCtmp/*.fil*
   cd $TCbin
   umount $TCtmp
   sleep 3
   rmdir $TCtmp
   rsh -n $RHOST "/usr/sbin/exportfs -u *:$TESTDIR" 
   rsh -n $RHOST "rm -rf $TESTDIR"   
}

#=============================================================================
# FUNCTION NAME:        end_testcase
#
# FUNCTION DESCRIPTION: Clean up
#
# PARAMETERS:           None.
#
# RETURNS:              None.
#=============================================================================
end_testcase()
{
$trace_logic
    if [ "$CLEANUP" = "ON" ]; then
       do_cleanup
    fi

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

#=============================================================================
#---------------------------------------------------------------------#
# FUNCTION: MAIN
# PURPOSE:  To invoke the functions to perform the tasks described in
#           the prologue.
# INPUT:    None.
# OUTPUT:   A testcase run log with the results of the execution of this
#           test.
#---------------------------------------------------------------------#
do_setup
do_test1
do_test2
do_test3
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
@@
