3 # Control script for QA
5 # Copyright (c) 2000-2002,2006 Silicon Graphics, Inc. All Rights Reserved.
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation.
11 # This program is distributed in the hope that it would be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write the Free Software Foundation,
18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
38 SUPPORTED_TESTS="[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]"
39 TEST_GROUP_DIR="tests"
40 GENERIC_GROUP_DIR="$TEST_GROUP_DIR/generic"
42 # generic initialization
45 export QA_CHECK_FS=${QA_CHECK_FS:=true}
47 # by default don't output timestamps
48 timestamp=${TIMESTAMP:=false}
50 # number of diff lines from a failed test, 0 for whole output
51 export DIFF_LENGTH=${DIFF_LENGTH:=10}
53 # by default don't output timestamps
54 timestamp=${TIMESTAMP:=false}
58 echo "Usage: $0 [options] [testlist]"'
61 -xfs test XFS (default)
65 -udiff show unified diff (default)
66 -n show me, do not run tests
68 -r randomize test order
69 --large-fs optimise scratch device for large filesystems
72 -g group[,group...] include tests from these groups
73 -x group[,group...] exclude tests from these groups
75 NNN-NNN include test range (eg. 012-021)
89 dirs=". $GENERIC_GROUP_DIR"
92 l=$(sed -n < $d/group \
95 -e "s;\(^[0-9][0-9][0-9]\).* $grp .*;$d/\1;p")
101 expand_test_numbers()
103 # strip leading zeros, could be considered octal.
104 start=`echo $1 | sed 's/^0*//'`
105 end=`echo $2 | sed 's/^0*//'`
107 $AWK_PROG </dev/null '
108 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
111 if grep -s "^$id " group >/dev/null ; then
112 # in group file ... OK
116 echo "$id - unknown test, ignored"
123 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
132 # start the initialisation work now
135 rm -f $tmp.list $tmp.tmp $tmp.sed $here/$iam.out
137 # Autodetect fs type based on what's on $TEST_DEV
138 if [ "$HOSTOS" == "Linux" ]; then
139 FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
143 # we need common.config
144 if ! . ./common.config
146 echo "$iam: failed to source common.config"
150 while [ $# -gt 0 ]; do
152 -\? | -h | --help) usage ;;
158 -g) group=$2 ; shift ;
159 group_list=$(get_group_list $group)
160 if [ -z "$group_list" ]; then
161 echo "Group \"$group\" is empty or not defined?"
165 [ ! -s $tmp.list ] && touch $tmp.list
166 for t in $group_list; do
167 grep -s "^$t\$" $tmp.list >/dev/null || \
168 echo "$t" >>$tmp.list
173 -x) xgroup=$2 ; shift ;
174 [ ! -s $tmp.list ] && ls $SUPPORTED_TESTS >$tmp.list 2>/dev/null
175 group_list=$(get_group_list $xgroup)
176 if [ -z "$group_list" ]; then
177 echo "Group \"$xgroup\" is empty or not defined?"
185 if [ $numsed -gt 100 ]; then
186 sed -f $tmp.sed <$tmp.list >$tmp.tmp
187 mv $tmp.tmp $tmp.list
191 echo "/^$t\$/d" >>$tmp.sed
192 numsed=`expr $numsed + 1`
194 sed -f $tmp.sed <$tmp.list >$tmp.tmp
195 mv $tmp.tmp $tmp.list
199 -udiff) diff="$diff -u" ;;
202 -r) randomize=true ;;
204 -T) timestamp=true ;;
213 eval `echo $1 | sed -e 's/^/start=/' -e 's/-/ end=/'`
214 expand_test_numbers $start $end
219 eval `echo $1 | sed -e 's/^/start=/' -e 's/-//'`
220 end=`echo $SUPPORTED_TESTS | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'`
221 if [ -z "$end" ]; then
222 echo "No tests in range \"$1\"?"
226 expand_test_numbers $start $end
230 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
231 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
234 *) expand_test_numbers $1 $1 ;
242 if [ -s $tmp.list ]; then
243 # found some valid test numbers ... this is good
245 elif $have_test_arg; then
246 # had test numbers, but none in group file ... do nothing
249 # no test numbers, do everything from group file
250 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
253 # sort the list of tests into numeric order
254 list=`sort -n $tmp.list`
255 rm -f $tmp.list $tmp.tmp $tmp.sed
259 list=`echo $list | awk -f randomize.awk`
265 echo "check: failed to source common.rc"
271 echo "check: QA must be run as root"
275 # Ok, time to start running...
284 if [ -f check.time -a -f $tmp.time ]
286 cat check.time $tmp.time \
290 for (i in t) print i " " t[i]
294 mv $tmp.out check.time
299 echo $list | fmt | sed -e 's/^/ /' -e 's;tests/;;g' >>check.log
300 $interrupt && echo "Interrupted!" >>check.log
302 if [ ! -z "$n_try" -a $n_try != 0 ]
307 if [ ! -z "$notrun" ]
309 echo "Not run:$notrun"
310 echo "Not run:$notrun" >>check.log
313 if [ ! -z "$n_bad" -a $n_bad != 0 ]
316 echo "Failed $n_bad of $n_try tests"
317 echo "Failures:$bad" | fmt >>check.log
318 echo "Failed $n_bad of $n_try tests" >>check.log
320 echo "Passed all $n_try tests"
321 echo "Passed all $n_try tests" >>check.log
326 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
330 trap "_wrapup; exit \$status" 0 1 2 3 15
332 # don't leave old full output behind on a clean run
335 [ -f check.time ] || touch check.time
337 # print out our test configuration
338 echo "FSTYP -- `_full_fstyp_details`"
339 echo "PLATFORM -- `_full_platform_details`"
340 if [ ! -z "$SCRATCH_DEV" ]; then
341 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
342 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
347 if [ ! -z "$SCRATCH_DEV" ]; then
348 umount $SCRATCH_DEV 2>/dev/null
349 # call the overridden mkfs - make sure the FS is built
350 # the same as we'll create it later.
352 if ! _scratch_mkfs $flag >$tmp.err 2>&1
354 echo "our local _scratch_mkfs routine ..."
356 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
360 # call the overridden mount - make sure the FS mounts with
361 # the same options that we'll mount with later.
362 if ! _scratch_mount >$tmp.err 2>&1
364 echo "our local mount routine ..."
366 echo "check: failed to mount \$SCRATCH_DEV using specified options"
378 # the filename for the test and the name output are different.
379 # we don't include the tests/ directory in the name output.
380 seqnum=`echo $seq | sed -e 's;tests/;;'`
390 echo " - no such test?"
392 # really going to try and run this one
396 # slashes now in names, sed barfs on them so use grep
397 lasttime=`grep -w ^$seq check.time | awk '// {print $2}'`
398 if [ "X$lasttime" != X ]; then
399 echo -n " ${lasttime}s ..."
401 echo -n " " # prettier output with timestamps.
403 rm -f core $seq.notrun
406 $timestamp && echo -n " ["`date "+%T"`"]"
407 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
408 $LOGGER_PROG "run xfstest $seqnum"
409 ./$seq >$tmp.rawout 2>&1
411 $timestamp && _timestamp
414 _fix_malloc <$tmp.rawout >$tmp.out
419 echo -n " [dumped core]"
424 if [ -f $seq.notrun ]
426 $timestamp || echo -n " [not run] "
427 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
429 notrun="$notrun $seqnum"
433 echo -n " [failed, exit status $sts]"
438 echo " - no qualified output"
441 if diff $seq.out $tmp.out >/dev/null 2>&1
447 echo "$seqnum `expr $stop - $start`" >>$tmp.time
448 echo -n " `expr $stop - $start`s"
452 echo " - output mismatch (see $seq.out.bad)"
453 mv $tmp.out $seq.out.bad
454 $diff $seq.out $seq.out.bad | {
455 if test "$DIFF_LENGTH" -le 0; then
458 head -n "$DIFF_LENGTH"
460 sed -e 's/^\(.\)/ \1/'
462 echo " (Run '$diff $seq.out $seq.out.bad' to see the" \
471 # come here for each test, except when $showme is true
476 n_bad=`expr $n_bad + 1`
479 if [ ! -f $seq.notrun ]
482 n_try=`expr $n_try + 1`