3 # Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
5 # common procedures for QA scripts
7 # $Header: /disk7/depot/linux/pcp/dev/qa/RCS/common,v 2.52 2000/04/05 18:24:51 kenmcd Exp $
31 rm -f $tmp.list $tmp.tmp $tmp.sed
33 # Autodetect fs type based on what's on $TEST_DEV
34 if [ "$HOSTOS" == "Linux" ]
36 export FSTYP=`blkid -s TYPE -o value $TEST_DEV`
47 group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
50 if [ -z "$group_list" ]
52 echo "Group \"$r\" is empty or not defined?"
55 [ ! -s $tmp.list ] && touch $tmp.list
58 if grep -s "^$t\$" $tmp.list >/dev/null
71 [ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null
72 group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
75 if [ -z "$group_list" ]
77 echo "Group \"$r\" is empty or not defined?"
84 if [ $numsed -gt 100 ]
86 sed -f $tmp.sed <$tmp.list >$tmp.tmp
91 echo "/^$t\$/d" >>$tmp.sed
92 numsed=`expr $numsed + 1`
94 sed -f $tmp.sed <$tmp.list >$tmp.tmp
104 -\? | -h | --help) # usage
105 echo "Usage: $0 [options] [testlist]"'
111 -xfs test XFS (default)
115 -xdiff graphical mode diff
116 -udiff show unified diff (default)
117 -n show me, do not run tests
118 -q quick [deprecated]
120 -r randomize test order
123 -g group[,group...] include tests from these groups
124 -x group[,group...] exclude tests from these groups
126 NNN-NNN include test range (eg. 012-021)
131 -udf) # -udf ... set FSTYP to udf
136 -xfs) # -xfs ... set FSTYP to xfs
141 -nfs) # -nfs ... set FSTYP to nfs
146 -g) # -g group ... pick from group file
151 -l) # line mode for diff, was default before
156 -xdiff) # graphical diff mode
159 if [ ! -z "$DISPLAY" ]
161 which xdiff >/dev/null 2>&1 && diff=xdiff
162 which gdiff >/dev/null 2>&1 && diff=gdiff
163 which tkdiff >/dev/null 2>&1 && diff=tkdiff
164 which xxdiff >/dev/null 2>&1 && diff=xxdiff
168 -udiff) # show a unified diff, default now, keep for backward compat
173 -q) # "quick", no longer used - always quick :-)
177 -n) # show me, don't do it
181 -r) # randomize test order
186 -T) # turn on timestamp output
195 -x) # -x group ... exclude from group file
199 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
206 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
210 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
211 end=`echo [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'`
214 echo "No tests in range \"$r\"?"
227 # get rid of leading 0s as can be interpreted as octal
228 start=`echo $start | sed 's/^0*//'`
229 end=`echo $end | sed 's/^0*//'`
234 $AWK_PROG </dev/null '
235 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
238 if grep -s "^$id " group >/dev/null
240 # in group file ... OK
243 if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null
245 # expunged ... will be reported, but not run, later
249 echo "$id - unknown test, ignored"
259 # found some valid test numbers ... this is good
264 # had test numbers, but none in group file ... do nothing
267 # no test numbers, do everything from group file
268 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
272 # should be sort -n, but this did not work for Linux when this
273 # was ported from IRIX
275 list=`sort $tmp.list`
276 rm -f $tmp.list $tmp.tmp $tmp.sed
280 list=`echo $list | awk -f randomize.awk`
285 [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
286 [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
287 [ "$XFS_CHECK_PROG" = "" ] && _fatal "xfs_check not found"
288 [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
289 [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
292 [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"