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 # start the initialisation work now
41 export MSGVERB="text:action"
42 export QA_CHECK_FS=${QA_CHECK_FS:=true}
44 # number of diff lines from a failed test, 0 for whole output
45 export DIFF_LENGTH=${DIFF_LENGTH:=10}
47 # by default don't output timestamps
48 timestamp=${TIMESTAMP:=false}
50 rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist
52 # we need common/config
53 if ! . ./common/config
55 echo "$iam: failed to source common/config"
59 # Autodetect fs type based on what's on $TEST_DEV unless it's been set
61 if [ -z "$FSTYP" -a "$HOSTOS" == "Linux" ]; then
62 FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
67 SUPPORTED_TESTS="[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]"
68 SRC_GROUPS="generic shared"
69 export SRC_DIR="tests"
73 echo "Usage: $0 [options] [testlist]"'
79 -udiff show unified diff (default)
80 -n show me, do not run tests
82 -r randomize test order
83 --large-fs optimise scratch device for large filesystems
86 -g group[,group...] include tests from these groups
87 -x group[,group...] exclude tests from these groups
88 -X file exclude individual tests
89 [testlist] include tests matching names in testlist
98 for d in $SRC_GROUPS $FSTYP; do
99 l=$(sed -n < $SRC_DIR/$d/group \
102 -e "s;\(^[0-9][0-9][0-9]\).* $grp .*;$SRC_DIR/$d/\1;p")
108 # find all tests, excluding files that are test metadata such as group files.
109 # This assumes that tests are defined purely by alphanumeric filenames with no
110 # ".xyz" extensions in the name.
114 for d in $SRC_GROUPS $FSTYP; do
117 grep -v "group\|Makefile" >> $tmp.list 2>/dev/null
121 # takes the list of tests to run in $tmp.list, and removes the tests passed to
122 # the function from that list.
131 if [ $numsed -gt 100 ]; then
132 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
133 mv $tmp.tmp $tmp.list
137 echo "^$t\$" >>$tmp.grep
138 numsed=`expr $numsed + 1`
140 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
141 mv $tmp.tmp $tmp.list
147 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
159 # Tests specified on the command line
160 if [ -s $tmp.arglist ]; then
161 cat $tmp.arglist > $tmp.list
166 # Specified groups to include
167 for group in $GROUP_LIST; do
168 list=$(get_group_list $group)
169 if [ -z "$list" ]; then
170 echo "Group \"$group\" is empty or not defined?"
175 grep -s "^$t\$" $tmp.list >/dev/null || \
176 echo "$t" >>$tmp.list
180 if ! $have_test_arg && [ -z "$GROUP_LIST" ]; then
181 # no test numbers, do everything
185 # Specified groups to exclude
186 for xgroup in $XGROUP_LIST; do
187 list=$(get_group_list $xgroup)
188 if [ -z "$list" ]; then
189 echo "Group \"$xgroup\" is empty or not defined?"
196 # sort the list of tests into numeric order
197 list=`sort -n $tmp.list | uniq`
198 rm -f $tmp.list $tmp.tmp $tmp.grep
202 list=`echo $list | awk -f randomize.awk`
206 # Process command arguments first.
207 while [ $# -gt 0 ]; do
209 -\? | -h | --help) usage ;;
212 -tmpfs) FSTYP=tmpfs ;;
214 -g) group=$2 ; shift ;
215 GROUP_LIST="$GROUP_LIST $group"
218 -x) xgroup=$2 ; shift ;
219 XGROUP_LIST="$XGROUP_LIST $xgroup"
222 -X) xfile=$2; shift ;
223 for d in $SRC_GROUPS $FSTYP; do
224 [ -f $SRC_DIR/$d/$xfile ] || continue
225 for f in `cat $SRC_DIR/$d/$xfile`; do
226 echo $d/$f >> $tmp.xlist
232 -udiff) diff="$diff -u" ;;
235 -r) randomize=true ;;
237 -T) timestamp=true ;;
239 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
240 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
243 *) # not an argument, we've got tests now.
244 have_test_arg=true ;;
247 # if we've found a test specification, the break out of the processing
248 # loop before we shift the arguments so that this is the first argument
249 # that we process in the test arg loop below.
250 if $have_test_arg; then
257 # Process tests from command line now.
258 if $have_test_arg; then
259 while [ $# -gt 0 ]; do
261 -*) echo "Argments before tests, please!"
265 *) test_dir=`dirname $1`
266 test_dir=${test_dir#$SRC_DIR/*}
267 test_name=`basename $1`
268 group_file=$SRC_DIR/$test_dir/group
270 if egrep "^$test_name" $group_file >/dev/null ; then
271 # in group file ... OK
272 echo $SRC_DIR/$test_dir/$test_name >>$tmp.arglist
275 echo "$1 - unknown test, ignored"
289 echo "check: failed to source common/rc"
295 echo "check: QA must be run as root"
299 # Ok, time to start running...
304 check="$RESULT_BASE/check"
311 if [ -f $check.time -a -f $tmp.time ]
313 cat $check.time $tmp.time \
317 for (i in t) print i " " t[i]
321 mv $tmp.out $check.time
326 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>$check.log
327 $interrupt && echo "Interrupted!" >>$check.log
329 if [ ! -z "$n_try" -a $n_try != 0 ]
334 if [ ! -z "$notrun" ]
336 echo "Not run:$notrun"
337 echo "Not run:$notrun" >>$check.log
340 if [ ! -z "$n_bad" -a $n_bad != 0 ]
343 echo "Failed $n_bad of $n_try tests"
344 echo "Failures:$bad" | fmt >>$check.log
345 echo "Failed $n_bad of $n_try tests" >>$check.log
347 echo "Passed all $n_try tests"
348 echo "Passed all $n_try tests" >>$check.log
353 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
357 trap "_wrapup; exit \$status" 0 1 2 3 15
359 mkdir -p $RESULT_BASE
360 if [ ! -d $RESULT_BASE ]; then
361 echo "failed to create results directory $RESULTS_BASE"
366 check="$RESULT_BASE/check"
368 # don't leave old full output behind on a clean run
371 [ -f $check.time ] || touch $check.time
373 # print out our test configuration
374 echo "FSTYP -- `_full_fstyp_details`"
375 echo "PLATFORM -- `_full_platform_details`"
376 if [ ! -z "$SCRATCH_DEV" ]; then
377 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
378 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
383 if [ ! -z "$SCRATCH_DEV" ]; then
384 umount $SCRATCH_DEV 2>/dev/null
385 # call the overridden mkfs - make sure the FS is built
386 # the same as we'll create it later.
388 if ! _scratch_mkfs $flag >$tmp.err 2>&1
390 echo "our local _scratch_mkfs routine ..."
392 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
396 # call the overridden mount - make sure the FS mounts with
397 # the same options that we'll mount with later.
398 if ! _scratch_mount >$tmp.err 2>&1
400 echo "our local mount routine ..."
402 echo "check: failed to mount \$SCRATCH_DEV using specified options"
414 # the filename for the test and the name output are different.
415 # we don't include the tests/ directory in the name output.
416 seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
418 # Similarly, the result directory needs to replace the tests/
419 # part of the test location.
421 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
423 seqres="$RESULT_BASE/$seqnum"
433 echo " - no such test?"
435 # really going to try and run this one
437 rm -f $seqres.out.bad
439 # check if we really should run it
440 if [ -s $tmp.xlist ]; then
441 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
447 # slashes now in names, sed barfs on them so use grep
448 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
449 if [ "X$lasttime" != X ]; then
450 echo -n " ${lasttime}s ..."
452 echo -n " " # prettier output with timestamps.
454 rm -f core $seqres.notrun
457 $timestamp && echo -n " ["`date "+%T"`"]"
458 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
459 $LOGGER_PROG "run xfstest $seqnum"
460 ./$seq >$tmp.rawout 2>&1
462 $timestamp && _timestamp
465 _fix_malloc <$tmp.rawout >$tmp.out
470 echo -n " [dumped core]"
471 mv core $RESULT_BASE/$seqnum.core
475 if [ -f $seqres.notrun ]
477 $timestamp || echo -n " [not run] "
478 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
480 notrun="$notrun $seqnum"
484 echo -n " [failed, exit status $sts]"
489 echo " - no qualified output"
493 # coreutils 8.16+ changed quote formats in error messages from
494 # `foo' to 'foo'. Filter old versions to match the new version.
495 sed -i "s/\`/\'/g" $tmp.out
496 if diff $seq.out $tmp.out >/dev/null 2>&1
502 echo "$seqnum `expr $stop - $start`" >>$tmp.time
503 echo -n " `expr $stop - $start`s"
507 echo " - output mismatch (see $seqres.out.bad)"
508 mv $tmp.out $seqres.out.bad
509 $diff $seq.out $seqres.out.bad | {
510 if test "$DIFF_LENGTH" -le 0; then
513 head -n "$DIFF_LENGTH"
515 echo "(Run '$diff $seq.out $seqres.out.bad'" \
516 " to see the entire diff)"
518 sed -e 's/^\(.\)/ \1/'
526 # come here for each test, except when $showme is true
531 n_bad=`expr $n_bad + 1`
534 if [ ! -f $seqres.notrun ]
537 n_try=`expr $n_try + 1`