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 -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
64 if [ -z "$group_list" ]
66 echo "Group \"$r\" is empty or not defined?"
69 [ ! -s $tmp.list ] && touch $tmp.list
72 if grep -s "^$t\$" $tmp.list >/dev/null
85 [ ! -s $tmp.list ] && ls [0-9][0-9][0-9] [0-9][0-9][0-9][0-9] >$tmp.list 2>/dev/null
86 group_list=`sed -n <group -e 's/$/ /' -e "/^[0-9][0-9][0-9].* $r /"'{
89 if [ -z "$group_list" ]
91 echo "Group \"$r\" is empty or not defined?"
98 if [ $numsed -gt 100 ]
100 sed -f $tmp.sed <$tmp.list >$tmp.tmp
101 mv $tmp.tmp $tmp.list
105 echo "/^$t\$/d" >>$tmp.sed
106 numsed=`expr $numsed + 1`
108 sed -f $tmp.sed <$tmp.list >$tmp.tmp
109 mv $tmp.tmp $tmp.list
118 -\? | -h | --help) # usage
119 echo "Usage: $0 [options] [testlist]"'
125 -xfs test XFS (default)
129 -xdiff graphical mode diff
130 -udiff show unified diff (default)
131 -n show me, do not run tests
132 -q quick [deprecated]
134 -r randomize test order
137 -g group[,group...] include tests from these groups
138 -x group[,group...] exclude tests from these groups
140 NNN-NNN include test range (eg. 012-021)
145 -udf) # -udf ... set FSTYP to udf
150 -xfs) # -xfs ... set FSTYP to xfs
155 -nfs) # -nfs ... set FSTYP to nfs
160 -g) # -g group ... pick from group file
165 -l) # line mode for diff, was default before
170 -xdiff) # graphical diff mode
173 if [ ! -z "$DISPLAY" ]
175 which xdiff >/dev/null 2>&1 && diff=xdiff
176 which gdiff >/dev/null 2>&1 && diff=gdiff
177 which tkdiff >/dev/null 2>&1 && diff=tkdiff
178 which xxdiff >/dev/null 2>&1 && diff=xxdiff
182 -udiff) # show a unified diff, default now, keep for backward compat
187 -q) # "quick", no longer used - always quick :-)
191 -n) # show me, don't do it
195 -r) # randomize test order
200 -T) # turn on timestamp output
209 -x) # -x group ... exclude from group file
213 '[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]')
220 eval `echo $r | sed -e 's/^/start=/' -e 's/-/ end=/'`
224 eval `echo $r | sed -e 's/^/start=/' -e 's/-//'`
225 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/.* //'`
228 echo "No tests in range \"$r\"?"
241 # get rid of leading 0s as can be interpreted as octal
242 start=`echo $start | sed 's/^0*//'`
243 end=`echo $end | sed 's/^0*//'`
248 $AWK_PROG </dev/null '
249 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
252 if grep -s "^$id " group >/dev/null
254 # in group file ... OK
257 if [ -f expunged ] && $expunge && egrep "^$id([ ]|\$)" expunged >/dev/null
259 # expunged ... will be reported, but not run, later
263 echo "$id - unknown test, ignored"
273 # found some valid test numbers ... this is good
278 # had test numbers, but none in group file ... do nothing
281 # no test numbers, do everything from group file
282 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
286 # should be sort -n, but this did not work for Linux when this
287 # was ported from IRIX
289 list=`sort $tmp.list`
290 rm -f $tmp.list $tmp.tmp $tmp.sed
294 list=`echo $list | awk -f randomize.awk`
299 [ "$XFS_LOGPRINT_PROG" = "" ] && _fatal "xfs_logprint not found"
300 [ "$XFS_REPAIR_PROG" = "" ] && _fatal "xfs_repair not found"
301 [ "$XFS_CHECK_PROG" = "" ] && _fatal "xfs_check not found"
302 [ "$XFS_DB_PROG" = "" ] && _fatal "xfs_db not found"
303 [ "$MKFS_XFS_PROG" = "" ] && _fatal "mkfs_xfs not found"
306 [ "$MKFS_UDF_PROG" = "" ] && _fatal "mkfs_udf/mkudffs not found"