3 # Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of version 2 of the GNU General Public License as
7 # published by the Free Software Foundation.
9 # This program is distributed in the hope that it would be useful, but
10 # WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 # Further, this software is distributed without any warranty that it is
14 # free of the rightful claim of any third person regarding infringement
15 # or the like. Any license provided herein, whether implied or
16 # otherwise, applies only to this software file. Patent licenses, if
17 # any, provided herein do not apply to combinations of this program with
18 # other software, or any other product whatsoever.
20 # You should have received a copy of the GNU General Public License along
21 # with this program; if not, write the Free Software Foundation, Inc., 59
22 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
24 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
25 # Mountain View, CA 94043, or:
29 # For further information regarding this notice, see:
31 # http://oss.sgi.com/projects/GenInfo/NoticeExplan/
34 # rwtest - a shell wrapper around iogen and doio
37 trap "exit 0" INT # Until the smarter signal handler is engaged, below.
52 echo "$Prog: [-chq] [-N name] [ iogen options ] [ doio options ] files" >&2
58 -c Cleanup test files created by this invocation on exit.
59 Default is to leave them.
60 -h This help - ignore all other options/arguments
61 -F Only process filenames - does not run iogen & doio.
63 -S Scenario Execute an internal scenario.
64 -N Name Pan-style name to be printed with error messages.
66 Options passed through to iogen:
69 -q Set rwtest to be quiet and pass the flag on to iogen.
71 Options passed through to doio:
74 -n nprocs # procs to do simultanious io to the test files.
75 Default is 1. If -n is non-zero, doio's -k option (use
76 file locking) is forced.
78 files Files to test on. File names have the following fomat:
80 [ free% [ max size ] : ] path
81 If no size is specified, the files must exist
82 and the contents will be overwritten if testing write or
83 writea system calls. If a size is supplied, an attempt to
84 create/grow/shrink path to the desired size will be made.
85 size is an integer which defaults to bytes, but may be
86 suffixed by 'b', 'k', or 'm' for blocks (4096 byte units),
87 kilobytes (1024 byte units), or megabytes (2^20 byte units).
89 If the size is a percentage, df is used to find how much
90 free space there is (in blocks), and uses that. The maximum
91 size is implied to be in blocks.
108 if [ -n "$Remove_Test_Files" ]
110 if [ -n "$Files_To_Remove" ]
112 rm -f $Files_To_Remove
121 -c) Remove_Test_Files=yes
133 opt_F="-F" # only process filenames
152 # iogen Options to pass thru ... options with an argument
158 # iogen Options to pass thru ... just the option
163 # iogen options to look at
169 # doio Options to pass thru ... options with an argument
172 dOpts="$dOpts -$o $2"
176 # doio options to pass thru ... just the options
182 # doio options to look at
185 # force file locking with > 1 process
195 echo "$Prog: Illegal option $1" >&2
206 if [[ $TOUTPUT = "NOPASS" ]]; then
212 # Hard-Coded Scenario Specifications
214 # FSA RAW I/O via FSA
215 # MPPnnn Run as a <nnn> sized MPP application
216 # userstripe create files using user striping
231 # use mpprun... to cooperate with a batch system, this
232 # requires scanning mppview, etc.
235 MPPrun=" mpprun -n $NPE "
238 #create files using user striping
239 Oflags=O_PLACE,0xffffffffffffffff,1000
243 FSIZE=${Scenario#places-}
249 # "this isn't supposed to happen"
250 Files="25%:rwtest.$$"
256 f="$f "${FSIZE}":"${p}"/rwtest$$"
265 # If no files are specified ...
266 # check if PLACES is set; if so, put one file in each place
267 # otherwise generate one filename in the current directory.
272 # put one file in each of $PLACES
273 Files="25%:rwtest.file"
279 # use 'df -PB' to see how many blocks are available, apply a hard limit of
280 # 1,000,000 blocks if no limit is specified
284 IRIX | IRIX64 ) dfOpts="-Pb" ;;
285 Linux) dfOpts="-P" ;;
294 Files_To_Remove="$Files_To_Remove $file"
303 while (( n < ${#szcache[*]} ))
305 if [[ szcache[$n] = $dir ]]; then
311 if (( n < ${#szcache[*]} ))
315 blks=$(df $dfOpts $dir |
316 (while read fs blks used avail cap mountpoint
318 #echo $fs $blks $used $avail >&2
324 Linux) blks=$( expr $blks / 2 ) ;;
327 szcache[${#szcache[*]}+1]=$dir
328 szblks[${#szblks[*]}+1]=$blks
341 #sz=$( perl -le 'print int( "$blke" * "$size" / 100 )' )
344 #sz=$(expr \( $blks '*' $size \) / 100)
348 if [[ $sz -gt $max ]]
359 if [[ -z ${dOpts} ]]; then
363 if [[ -n "$opt_F" ]]; then
369 [[ -n "$here" ]] || here=`pwd`
370 if [[ -x ${LTPROOT}/testcases/bin/iogen ]]; then
371 IOgen=${LTPROOT}/testcases/bin/iogen
372 elif [[ -x ${here}/ltp/iogen ]]; then
373 IOgen=$here/ltp/iogen
374 elif [[ -x ./iogen ]]; then
377 echo Cannot find iogen command
380 if [[ -x ${LTPROOT}/testcases/bin/doio ]]; then
381 doIO=${LTPROOT}/testcases/bin/doio
382 elif [[ -x ${here}/ltp/doio ]]; then
384 elif [[ -x ./doio ]]; then
387 echo Cannot find doio command
391 cmd="$IOgen ${iOpts} ${Files} | $MPPrun $doIO ${dOpts}"
393 if [[ -z "$Quiet" ]]; then
398 trap "cleanup_and_exit 2" HUP
400 ( $IOgen ${iOpts} ${Files}
404 echo "$Prog$Name : iogen reported errors (r=$r)" >&2
407 ) | $MPPrun $doIO ${dOpts}
411 echo "$Prog$Name : doio reported errors (r=$r)" >&2