1#! /bin/sh 2# 3# Copyright (c) International Business Machines Corp., 2001 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 implie; 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 : fsx.sh 22# 23# PURPOSE: Runs the fsx-linux tool with a 50000 iterations setting to 24# attempt to uncover the "doread:read input/output" error 25# received if the latest NFS patches for 2.4.17 from Trond 26# are not applied. http://nfs.sf.net 27# 28# 29# SETUP: The home directory of root on the machine exported as "RHOST" 30# MUST have a ".rhosts" file with the hostname of the machine 31# where the test is executed. 32# 33# 34# HISTORY: 35# 12/18/01 Robbie Williamson (robbiew@us.ibm.com) 36# -Written 37# 38#*********************************************************************** 39 40#Uncomment line below for debug output. 41#trace_logic=${trace_logic:-"set -x"} 42 43$trace_logic 44 45#----------------------------------------------------------------------- 46# Initialize local variables 47#----------------------------------------------------------------------- 48TC=${TC:=fsx} 49TCbin=${TCbin:=`pwd`} 50TCdat=${TCdat:=$TCbin} 51TCsrc=${TCsrc:=$TCbin} 52TCtmp=${TCtmp:=$TCbin/$TC$$} 53TCdump=${TCdump:=$TCbin} 54export TCID=$TC 55export TST_TOTAL=1 56export TST_COUNT=1 57 58# If CLEANUP is not set; set it to "ON" 59CLEANUP=${CLEANUP:="ON"} 60 61# If EXECUTABLES is not set; set it to default executables 62EXECUTABLES=${EXECUTABLES:="fsx-linux"} 63 64 65#============================================================================= 66# FUNCTION NAME: setup_testcase 67# 68# FUNCTION DESCRIPTION: Perform the setup function for the testcase. 69# 70# PARAMETERS: None. 71# 72# RETURNS: None. 73#============================================================================= 74 75setup_testcase() 76{ 77$trace_logic 78 79 PID=$$ 80 81 VERSION=${VERSION:=3} 82 RHOST=${RHOST:=`hostname`} 83 ITERATIONS=${ITERATIONS:=50000} 84 SOCKET_TYPE=${SOCKET_TYPE:=udp} 85 TESTDIR=${TESTDIR:=/tmp/$TC$PID.testdir} 86 NFS_TYPE=${NFS_TYPE:=nfs} 87 88 echo "" 89 echo "Test Options:" 90 echo " VERSION: $VERSION" 91 echo " RHOST: $RHOST" 92 echo " ITERATIONS: $ITERATIONS" 93 echo " SOCKET_TYPE: $SOCKET_TYPE" 94 echo " NFS_TYPE: $NFS_TYPE" 95 96 if [ "x$NFS_TYPE" != "xnfs4" ]; then 97 OPTS=${OPTS:="-o proto=$SOCKET_TYPE,vers=$VERSION "} 98 fi 99 100 REMOTE_DIR=${RHOST}:${TESTDIR} 101 LUSER=${LUSER:=root} 102 mkdir -p $TCtmp || end_testcase "Could not create $TCtmp" 103 chmod 777 $TCtmp 104 105 echo "Setting up remote machine: $RHOST" 106 rsh -n $RHOST "mkdir $TESTDIR" 107 [ $? = 0 ] || end_testcase "Could not create remote directory" 108 rsh -n $RHOST "touch $TESTDIR/testfile" 109 [ $? = 0 ] || end_testcase "Could not create testfile in remote directory" 110 111 if [ "x$NFS_TYPE" = "xnfs4" ]; then 112 rsh -n $RHOST "mkdir -p /export$TESTDIR" 113 [ $? = 0 ] || end_testcase "Could not create /export$TESTDIR on server" 114 rsh -n $RHOST "mount --bind $TESTDIR /export$TESTDIR" 115 [ $? = 0 ] || end_testcase "Could not bind $TESTDIR to export on server" 116 rsh -n $RHOST "/usr/sbin/exportfs -o no_root_squash,rw,nohide,insecure,no_subtree_check *:$TESTDIR" 117 [ $? = 0 ] || end_testcase "Could not export remote directory" 118 else 119 rsh -n $RHOST "/usr/sbin/exportfs -i -o no_root_squash,rw *:$TESTDIR" 120 [ $? = 0 ] || end_testcase "Could not export remote directory" 121 fi 122 123 echo "Mounting NFS filesystem $REMOTE_DIR on $TCtmp with options '$OPTS'" 124 mount -t $NFS_TYPE $OPTS $REMOTE_DIR $TCtmp || end_testcase "Cannot mount $TCtmp" 125 [ $? = 0 ] || end_testcase "Could not mount $REMOTE_DIR" 126} 127 128 129#============================================================================= 130# FUNCTION NAME: do_test 131# 132# FUNCTION DESCRIPTION: Perform the test 133# 134# PARAMETERS: None. 135# 136# RETURNS: None. 137#============================================================================= 138do_test() 139{ 140$trace_logic 141 for executable in $EXECUTABLES 142 do 143 144 cd $TCbin 145 echo "${executable} -N $ITERATIONS $TCtmp/testfile Starting" 146 ./${executable} -N $ITERATIONS $TCtmp/testfile 2>&1 147 retval=$? 148 echo "${executable} -N $ITERATIONS $TCtmp/testfile Finished" 149 150 if [ "$retval" != 0 ]; then 151 end_testcase "Errors have resulted from this test" 152 fi 153 154 done 155} 156 157 158#============================================================================= 159# FUNCTION NAME: end_testcase 160# 161# FUNCTION DESCRIPTION: Clean up 162# 163# PARAMETERS: None. 164# 165# RETURNS: None. 166#============================================================================= 167end_testcase() 168{ 169$trace_logic 170 if [ "$CLEANUP" = "ON" ]; then 171 cd \ 172 173 echo "Cleaning up testcase" 174 cd $HOME 175 echo "Unmounting $TCtmp" 176 sleep 2 177 umount $TCtmp || { echo "Cannot umount $TCtmp"; exit 1; } 178 rm -rf $TCtmp || echo "Cannot remove $TCtmp" 179 rsh -n $RHOST "/usr/sbin/exportfs -u *:$TESTDIR" 180 rsh -n $RHOST "rm -rf $TESTDIR" 181 fi 182 183 [ $# = 0 ] && { tst_resm TPASS "Test Successful"; exit 0; } 184 tst_resm TFAIL "Test Failed: $@" 185 exit 1 186} 187 188#============================================================================= 189# MAIN PROCEDURE 190#============================================================================= 191 192setup_testcase 193do_test 194end_testcase 195