3 # Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms 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,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write the Free Software Foundation,
16 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 # common procedures for QA scripts
21 # $Header: /disk7/depot/linux/pcp/dev/qa/RCS/common,v 2.52 2000/04/05 18:24:51 kenmcd Exp $
45 rm -f $tmp.list $tmp.tmp $tmp.sed
47 # Autodetect fs type based on what's on $TEST_DEV
48 if [ "$HOSTOS" == "Linux" ]
50 export FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
61 group_list=$(sed -n < group \
64 -e "/^[0-9][0-9][0-9].* $r /"'{ s/ .*//p }')
65 if [ -z "$group_list" ]
67 echo "Group \"$r\" is empty or not defined?"
70 [ ! -s $tmp.list ] && touch $tmp.list
73 if grep -s "^$t\$" $tmp.list >/dev/null
86 [ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null
87 group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
90 if [ -z "$group_list" ]
92 echo "Group \"$r\" is empty or not defined?"
99 if [ $numsed -gt 100 ]
101 sed -f $tmp.sed <$tmp.list >$tmp.tmp
102 mv $tmp.tmp $tmp.list
106 echo "/^$t\$/d" >>$tmp.sed
107 numsed=`expr $numsed + 1`
109 sed -f $tmp.sed <$tmp.list >$tmp.tmp
110 mv $tmp.tmp $tmp.list
119 -\? | -h | --help) # usage
120 echo "Usage: $0 [options] [testlist]"'
126 -xfs test XFS (default)
130 -xdiff graphical mode diff
131 -udiff show unified diff (default)
132 -n show me, do not run tests
133 -q quick [deprecated]
135 -r randomize test order
138 -g group[,group...] include tests from these groups
139 -x group[,group...] exclude tests from these groups
141 NNN-NNN include test range (eg. 012-021)
146 -udf) # -udf ... set FSTYP to udf
151 -xfs) # -xfs ... set FSTYP to xfs
156 -nfs) # -nfs ... set FSTYP to nfs
161 -g) # -g group ... pick from group file
166 -l) # line mode for diff, was default before
171 -xdiff) # graphical diff mode
174 if [ ! -z "$DISPLAY" ]
176 which xdiff >/dev/null 2>&1 && diff=xdiff
177 which gdiff >/dev/null 2>&1 && diff=gdiff
178 which tkdiff >/dev/null 2>&1 && diff=tkdiff
179 which xxdiff >/dev/null 2>&1 && diff=xxdiff
183 -udiff) # show a unified diff, default now, keep for backward compat
188 -q) # "quick", no longer used - always quick :-)
192 -n) # show me, don't do it
196 -r) # randomize test order
201 -T) # turn on timestamp output
210 -x) # -x group ... exclude from group file
214 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
221 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
225 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
226 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/.* //'`
229 echo "No tests in range \"$r\"?"
242 # get rid of leading 0s as can be interpreted as octal
243 start=`echo $start | sed 's/^0*//'`
244 end=`echo $end | sed 's/^0*//'`
249 $AWK_PROG </dev/null '
250 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
253 if grep -s "^$id " group >/dev/null
255 # in group file ... OK
258 if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null
260 # expunged ... will be reported, but not run, later
264 echo "$id - unknown test, ignored"
274 # found some valid test numbers ... this is good
279 # had test numbers, but none in group file ... do nothing
282 # no test numbers, do everything from group file
283 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
287 # should be sort -n, but this did not work for Linux when this
288 # was ported from IRIX
290 list=`sort $tmp.list`
291 rm -f $tmp.list $tmp.tmp $tmp.sed
295 list=`echo $list | awk -f randomize.awk`
300 [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
301 [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
302 [ "$XFS_CHECK_PROG" = "" ] && _fatal "xfs_check not found"
303 [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
304 [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
307 [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"