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

1.1.1.1
date     2003.12.31.09.00.22;  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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
#
#
#  FILE   : nfslock
#
#  PURPOSE:
#           Two processes open FLOCK_IDATA file simultaneously
#           each one locks odd and even lines of the file simultaneously
#           and fill them with '0's and '1's. After they find eof, the 
#           datafiles are compared. 
#
#  HISTORY:
#    04/25/01 Robbie Williamson (robbiew@@us.ibm.com)
#      -Ported
#
#***********************************************************************

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

$trace_logic

TC=nfslock
TCbin=${TCbin:=`pwd`}
TCtmp=${TCtmp:=$TCbin/$TC$$}
TCsrc=${TCsrc:=$TCbin}
TClog=${TClog:=$TCtmp}

mkdir $TCtmp >/dev/null 2>&1

CLEANUP=${CLEANUP:=ON}
LUSER=${LUSER:=root}

FLOCK_DATA=$TClog/nfs_flock_data
FLOCK_IDATA=$TClog/nfs_flock_idata
FLOCK_ODATA=$TClog/nfs_flock_odata

FLOCK_EXEC=$TCsrc/nfs_flock
FLOCK_DGEN=$TCsrc/nfs_flock_dgen
FLOCK_FRK=$TCsrc/nfs_flock_frk

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

   $FLOCK_DGEN $FLOCK_DATA 63 16384 0
   $FLOCK_DGEN $FLOCK_ODATA 63 16384 1
   
   [ `wc -c $FLOCK_DATA | awk '{print $1}'` -ne 1048576 ] && { \
      echo "abort - could not create $FLOCK_DATA"; exit 99; }
   [ `wc -c $FLOCK_ODATA | awk '{print $1}'` -ne 1048576 ] && { \
      echo "abort - could not create $FLOCK_ODATA"; exit 99; }
}

#----------------------------------------------------------------------
# FUNCTION: do_cleanup
# PURPOSE:  To delete all the files created to run this test.
# INPUT:    None.
# OUTPUT:   None.
#----------------------------------------------------------------------
do_cleanup()
{
$trace_logic
   sleep 5
   rm -rf $TCtmp
}

#----------------------------------------------------------------------
# FUNCTION: do_test
# PURPOSE:  Perform the necessary steps to complete the test.
# INPUT:    None.
# OUPUT:    Error messages are logged if any of the tests fail.
#----------------------------------------------------------------------
do_test()
{
$trace_logic
   echo "Testing locking"

   cp $FLOCK_DATA $FLOCK_IDATA

   echo "locking $FLOCK_IDATA file and writing data"
   $FLOCK_FRK $FLOCK_EXEC $FLOCK_IDATA 
   [ $? = 0 ] || end_testcase "Errors in do_test $TC"
   sleep 1
   diff $FLOCK_ODATA $FLOCK_IDATA > /dev/null 2>&1
   [ $? = 0 ] || end_testcase "$FLOCK_ODATA is different than $FLOCK_IDATA"   

}

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

end_testcase()
{
   $trace_logic
   echo "$this_file: doing $0."
   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_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
@@
