3 # Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
5 # rwtest - a shell wrapper around iogen and doio
8 trap "exit 0" INT # Until the smarter signal handler is engaged, below.
23 echo "$Prog: [-chq] [-N name] [ iogen options ] [ doio options ] files" >&2
29 -c Cleanup test files created by this invocation on exit.
30 Default is to leave them.
31 -h This help - ignore all other options/arguments
32 -F Only process filenames - does not run iogen & doio.
34 -S Scenario Execute an internal scenario.
35 -N Name Pan-style name to be printed with error messages.
37 Options passed through to iogen:
40 -q Set rwtest to be quiet and pass the flag on to iogen.
42 Options passed through to doio:
45 -n nprocs # procs to do simultanious io to the test files.
46 Default is 1. If -n is non-zero, doio's -k option (use
47 file locking) is forced.
49 files Files to test on. File names have the following fomat:
51 [ free% [ max size ] : ] path
52 If no size is specified, the files must exist
53 and the contents will be overwritten if testing write or
54 writea system calls. If a size is supplied, an attempt to
55 create/grow/shrink path to the desired size will be made.
56 size is an integer which defaults to bytes, but may be
57 suffixed by 'b', 'k', or 'm' for blocks (4096 byte units),
58 kilobytes (1024 byte units), or megabytes (2^20 byte units).
60 If the size is a percentage, df is used to find how much
61 free space there is (in blocks), and uses that. The maximum
62 size is implied to be in blocks.
79 if [ -n "$Remove_Test_Files" ]
81 if [ -n "$Files_To_Remove" ]
83 rm -f $Files_To_Remove
92 -c) Remove_Test_Files=yes
104 opt_F="-F" # only process filenames
123 # iogen Options to pass thru ... options with an argument
129 # iogen Options to pass thru ... just the option
134 # iogen options to look at
140 # doio Options to pass thru ... options with an argument
143 dOpts="$dOpts -$o $2"
147 # doio options to pass thru ... just the options
153 # doio options to look at
156 # force file locking with > 1 process
166 echo "$Prog: Illegal option $1" >&2
177 if [[ $TOUTPUT = "NOPASS" ]]; then
183 # Hard-Coded Scenario Specifications
185 # FSA RAW I/O via FSA
186 # MPPnnn Run as a <nnn> sized MPP application
187 # userstripe create files using user striping
202 # use mpprun... to cooperate with a batch system, this
203 # requires scanning mppview, etc.
206 MPPrun=" mpprun -n $NPE "
209 #create files using user striping
210 Oflags=O_PLACE,0xffffffffffffffff,1000
214 FSIZE=${Scenario#places-}
220 # "this isn't supposed to happen"
221 Files="25%:rwtest.$$"
227 f="$f "${FSIZE}":"${p}"/rwtest$$"
236 # If no files are specified ...
237 # check if PLACES is set; if so, put one file in each place
238 # otherwise generate one filename in the current directory.
243 # put one file in each of $PLACES
244 Files="25%:rwtest.file"
250 # use 'df -PB' to see how many blocks are available, apply a hard limit of
251 # 1,000,000 blocks if no limit is specified
255 IRIX | IRIX64 ) dfOpts="-Pb" ;;
256 Linux) dfOpts="-P" ;;
265 Files_To_Remove="$Files_To_Remove $file"
274 while (( n < ${#szcache[*]} ))
276 if [[ szcache[$n] = $dir ]]; then
282 if (( n < ${#szcache[*]} ))
286 blks=$(df $dfOpts $dir |
287 (while read fs blks used avail cap mountpoint
289 #echo $fs $blks $used $avail >&2
295 Linux) blks=$( expr $blks / 2 ) ;;
298 szcache[${#szcache[*]}+1]=$dir
299 szblks[${#szblks[*]}+1]=$blks
309 sz=$(expr \( $blks '*' $size \) / 100)
311 if [[ $sz -gt $max ]]
322 if [[ -z ${dOpts} ]]; then
326 if [[ -n "$opt_F" ]]; then
332 [[ -n "$here" ]] || here=`pwd`
333 if [[ -x ${LTPROOT}/testcases/bin/iogen ]]; then
334 IOgen=${LTPROOT}/testcases/bin/iogen
335 elif [[ -x ${here}/ltp/iogen ]]; then
336 IOgen=$here/ltp/iogen
337 elif [[ -x ./iogen ]]; then
340 echo Cannot find iogen command
343 if [[ -x ${LTPROOT}/testcases/bin/doio ]]; then
344 doIO=${LTPROOT}/testcases/bin/doio
345 elif [[ -x ${here}/ltp/doio ]]; then
347 elif [[ -x ./doio ]]; then
350 echo Cannot find doio command
354 cmd="$IOgen ${iOpts} ${Files} | $MPPrun $doIO ${dOpts}"
356 if [[ -z "$Quiet" ]]; then
361 trap "cleanup_and_exit 2" HUP
363 ( $IOgen ${iOpts} ${Files}
367 echo "$Prog$Name : iogen reported errors (r=$r)" >&2
370 ) | $MPPrun $doIO ${dOpts}
374 echo "$Prog$Name : doio reported errors (r=$r)" >&2