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 Linux) dfOpts="-P" ;;
264 Files_To_Remove="$Files_To_Remove $file"
273 while (( n < ${#szcache[*]} ))
275 if [[ szcache[$n] = $dir ]]; then
281 if (( n < ${#szcache[*]} ))
285 blks=$(df $dfOpts $dir |
286 (while read fs blks used avail cap mountpoint
288 #echo $fs $blks $used $avail >&2
294 Linux) blks=$( expr $blks / 2 ) ;;
297 szcache[${#szcache[*]}+1]=$dir
298 szblks[${#szblks[*]}+1]=$blks
308 sz=$(expr \( $blks '*' $size \) / 100)
310 if [[ $sz -gt $max ]]
321 if [[ -z ${dOpts} ]]; then
325 if [[ -n "$opt_F" ]]; then
331 [[ -n "$here" ]] || here=`pwd`
332 if [[ -x ${LTPROOT}/testcases/bin/iogen ]]; then
333 IOgen=${LTPROOT}/testcases/bin/iogen
334 elif [[ -x ${here}/ltp/iogen ]]; then
335 IOgen=$here/ltp/iogen
336 elif [[ -x ./iogen ]]; then
339 echo Cannot find iogen command
342 if [[ -x ${LTPROOT}/testcases/bin/doio ]]; then
343 doIO=${LTPROOT}/testcases/bin/doio
344 elif [[ -x ${here}/ltp/doio ]]; then
346 elif [[ -x ./doio ]]; then
349 echo Cannot find doio command
353 cmd="$IOgen ${iOpts} ${Files} | $MPPrun $doIO ${dOpts}"
355 if [[ -z "$Quiet" ]]; then
360 trap "cleanup_and_exit 2" HUP
362 ( $IOgen ${iOpts} ${Files}
366 echo "$Prog$Name : iogen reported errors (r=$r)" >&2
369 ) | $MPPrun $doIO ${dOpts}
373 echo "$Prog$Name : doio reported errors (r=$r)" >&2