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
39 brief_test_summary=false
43 # start the initialisation work now
46 export MSGVERB="text:action"
47 export QA_CHECK_FS=${QA_CHECK_FS:=true}
49 # number of diff lines from a failed test, 0 for whole output
50 export DIFF_LENGTH=${DIFF_LENGTH:=10}
52 # by default don't output timestamps
53 timestamp=${TIMESTAMP:=false}
55 rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist
57 SRC_GROUPS="generic shared"
58 export SRC_DIR="tests"
62 echo "Usage: $0 [options] [testlist]"'
70 -udiff show unified diff (default)
71 -n show me, do not run tests
73 -r randomize test order
74 -d dump test output to stdout
76 --large-fs optimise scratch device for large filesystems
77 -s section run only specified section from config file
78 -S section exclude the specified section from the config file
81 -g group[,group...] include tests from these groups
82 -x group[,group...] exclude tests from these groups
83 -X file exclude individual tests
84 -E external_file exclude individual tests
85 [testlist] include tests matching names in testlist
95 test -s "$SRC_DIR/$d/group" || return 1
97 local grpl=$(sed -n < $SRC_DIR/$d/group \
100 -e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
109 for d in $SRC_GROUPS $FSTYP; do
110 if ! test -d "$SRC_DIR/$d" ; then
113 grpl="$grpl $(get_sub_group_list $d $grp)"
118 # Find all tests, excluding files that are test metadata such as group files.
119 # It matches test names against $VALID_TEST_NAME defined in common/rc
123 for d in $SRC_GROUPS $FSTYP; do
124 if ! test -d "$SRC_DIR/$d" ; then
129 grep "^$SRC_DIR/$d/$VALID_TEST_NAME"| \
130 grep -v "group\|Makefile" >> $tmp.list 2>/dev/null
134 # takes the list of tests to run in $tmp.list, and removes the tests passed to
135 # the function from that list.
144 if [ $numsed -gt 100 ]; then
145 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
146 mv $tmp.tmp $tmp.list
150 echo "^$t\$" >>$tmp.grep
151 numsed=`expr $numsed + 1`
153 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
154 mv $tmp.tmp $tmp.list
172 # Tests specified on the command line
173 if [ -s $tmp.arglist ]; then
174 cat $tmp.arglist > $tmp.list
179 # Specified groups to include
180 for group in $GROUP_LIST; do
181 list=$(get_group_list $group)
182 if [ -z "$list" ]; then
183 echo "Group \"$group\" is empty or not defined?"
188 grep -s "^$t\$" $tmp.list >/dev/null || \
189 echo "$t" >>$tmp.list
193 if ! $have_test_arg && [ -z "$GROUP_LIST" ]; then
194 # no test numbers, do everything
198 # Specified groups to exclude
199 for xgroup in $XGROUP_LIST; do
200 list=$(get_group_list $xgroup)
201 if [ -z "$list" ]; then
202 echo "Group \"$xgroup\" is empty or not defined?"
209 # sort the list of tests into numeric order
210 list=`sort -n $tmp.list | uniq`
211 rm -f $tmp.list $tmp.tmp $tmp.grep
215 list=`echo $list | awk -f randomize.awk`
219 # Process command arguments first.
220 while [ $# -gt 0 ]; do
222 -\? | -h | --help) usage ;;
226 -overlay) FSTYP=overlay ;;
227 -tmpfs) FSTYP=tmpfs ;;
229 -g) group=$2 ; shift ;
230 GROUP_LIST="$GROUP_LIST ${group//,/ }"
233 -x) xgroup=$2 ; shift ;
234 XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }"
237 -X) xfile=$2; shift ;
238 for d in $SRC_GROUPS $FSTYP; do
239 [ -f $SRC_DIR/$d/$xfile ] || continue
240 for f in `sed "s/#.*$//" $SRC_DIR/$d/$xfile`; do
241 echo $d/$f >> $tmp.xlist
245 -E) xfile=$2; shift ;
246 if [ -f $xfile ]; then
247 sed "s/#.*$//" "$xfile" >> $tmp.xlist
250 -s) RUN_SECTION="$RUN_SECTION $2"; shift ;;
251 -S) EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
253 -udiff) diff="$diff -u" ;;
256 -r) randomize=true ;;
258 -T) timestamp=true ;;
259 -d) DUMP_OUTPUT=true ;;
260 -b) brief_test_summary=true;;
262 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
263 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
266 *) # not an argument, we've got tests now.
267 have_test_arg=true ;;
270 # if we've found a test specification, the break out of the processing
271 # loop before we shift the arguments so that this is the first argument
272 # that we process in the test arg loop below.
273 if $have_test_arg; then
280 # we need common/config, source it after processing args, overlay needs FSTYP
281 # set before sourcing common/config
282 if ! . ./common/config; then
283 echo "$iam: failed to source common/config"
287 # Process tests from command line now.
288 if $have_test_arg; then
289 while [ $# -gt 0 ]; do
291 -*) echo "Arguments before tests, please!"
295 *) # Expand test pattern (e.g. xfs/???, *fs/001)
296 list=$(cd $SRC_DIR; echo $1)
298 test_dir=`dirname $t`
299 test_dir=${test_dir#$SRC_DIR/*}
300 test_name=`basename $t`
301 group_file=$SRC_DIR/$test_dir/group
303 if egrep -q "^$test_name" $group_file; then
304 # in group file ... OK
305 echo $SRC_DIR/$test_dir/$test_name \
309 echo "$t - unknown test, ignored"
322 echo "check: failed to source common/rc"
328 echo "check: QA must be run as root"
342 check="$RESULT_BASE/check"
347 if [ -f $check.time -a -f $tmp.time ]; then
348 cat $check.time $tmp.time \
353 for (i in t) print i " " t[i]
357 mv $tmp.out $check.time
363 echo "SECTION -- $section" >>$tmp.summary
364 echo "=========================" >>$tmp.summary
365 if [ ! -z "$n_try" -a $n_try != 0 ]; then
366 if [ $brief_test_summary == "false" ]; then
368 echo "Ran:$try" >>$tmp.summary
370 echo "Ran:$try" >>$check.log
373 $interrupt && echo "Interrupted!" >>$check.log
375 if [ ! -z "$notrun" ]; then
376 if [ $brief_test_summary == "false" ]; then
377 echo "Not run:$notrun"
378 echo "Not run:$notrun" >>$tmp.summary
380 echo "Not run:$notrun" >>$check.log
383 if [ ! -z "$n_bad" -a $n_bad != 0 ]; then
385 echo "Failed $n_bad of $n_try tests"
386 echo "Failures:$bad" >>$check.log
387 echo "Failed $n_bad of $n_try tests" >>$check.log
388 echo "Failures:$bad" >>$tmp.summary
389 echo "Failed $n_bad of $n_try tests" >>$tmp.summary
391 echo "Passed all $n_try tests"
392 echo "Passed all $n_try tests" >>$check.log
393 echo "Passed all $n_try tests" >>$tmp.summary
395 echo "" >>$tmp.summary
399 sum_bad=`expr $sum_bad + $n_bad`
401 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
402 if ! $OPTIONS_HAVE_SECTIONS; then
413 count=`wc -L $tmp.summary | cut -f1 -d" "`
422 if [ -f ${RESULT_DIR}/require_test ]; then
423 _check_test_fs || err=true
424 rm -f ${RESULT_DIR}/require_test*
426 if [ -f ${RESULT_DIR}/require_scratch ]; then
427 _check_scratch_fs || err=true
428 rm -f ${RESULT_DIR}/require_scratch*
434 if $OPTIONS_HAVE_SECTIONS; then
435 trap "_summary; exit \$status" 0 1 2 3 15
437 trap "_wrapup; exit \$status" 0 1 2 3 15
440 for section in $HOST_OPTIONS_SECTIONS; do
442 OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
443 get_next_config $section
445 # Do we need to run only some sections ?
446 if [ ! -z "$RUN_SECTION" ]; then
448 for s in $RUN_SECTION; do
449 if [ $section == $s ]; then
459 # Did this section get excluded?
460 if [ ! -z "$EXCLUDE_SECTION" ]; then
462 for s in $EXCLUDE_SECTION; do
463 if [ $section == $s ]; then
473 mkdir -p $RESULT_BASE
474 if [ ! -d $RESULT_BASE ]; then
475 echo "failed to create results directory $RESULT_BASE"
480 if $OPTIONS_HAVE_SECTIONS; then
481 echo "SECTION -- $section"
484 if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
485 echo "RECREATING -- $FSTYP on $TEST_DEV"
486 _test_unmount 2> /dev/null
487 if ! _test_mkfs >$tmp.err 2>&1
489 echo "our local _test_mkfs routine ..."
491 echo "check: failed to mkfs \$TEST_DEV using specified options"
495 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
496 if [ $? -ne 1 ]; then
502 elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
503 _test_unmount 2> /dev/null
504 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
505 if [ $? -ne 1 ]; then
515 check="$RESULT_BASE/check"
517 # don't leave old full output behind on a clean run
520 [ -f $check.time ] || touch $check.time
522 # print out our test configuration
523 echo "FSTYP -- `_full_fstyp_details`"
524 echo "PLATFORM -- `_full_platform_details`"
525 if [ ! -z "$SCRATCH_DEV" ]; then
526 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
527 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
532 if [ ! -z "$SCRATCH_DEV" ]; then
533 _scratch_unmount 2> /dev/null
534 # call the overridden mkfs - make sure the FS is built
535 # the same as we'll create it later.
537 if ! _scratch_mkfs >$tmp.err 2>&1
539 echo "our local _scratch_mkfs routine ..."
541 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
546 # call the overridden mount - make sure the FS mounts with
547 # the same options that we'll mount with later.
548 if ! _scratch_mount >$tmp.err 2>&1
550 echo "our local mount routine ..."
552 echo "check: failed to mount \$SCRATCH_DEV using specified options"
564 if [ ! -f $seq ]; then
565 # Try to get full name in case the user supplied only seq id
566 # and the test has a name. A bit of hassle to find really
567 # the test and not its sample output or helping files.
568 bname=$(basename $seq)
569 full_seq=$(find $(dirname $seq) -name $bname* -executable |
570 awk '(NR == 1 || length < length(shortest)) { shortest = $0 }\
571 END { print shortest }')
572 if [ -f $full_seq ] \
573 && [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
578 # the filename for the test and the name output are different.
579 # we don't include the tests/ directory in the name output.
580 export seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
582 # Similarly, the result directory needs to replace the tests/
583 # part of the test location.
585 if $OPTIONS_HAVE_SECTIONS; then
586 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;${RESULT_BASE}/$section;"`
587 seqres="$RESULT_BASE/$section/$seqnum"
589 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
590 seqres="$RESULT_BASE/$seqnum"
602 if [ ! -f $seq ]; then
603 echo " - no such test?"
605 # really going to try and run this one
607 rm -f $seqres.out.bad
609 # check if we really should run it
610 if [ -s $tmp.xlist ]; then
611 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
617 # slashes now in names, sed barfs on them so use grep
618 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
619 if [ "X$lasttime" != X ]; then
620 echo -n " ${lasttime}s ..."
622 echo -n " " # prettier output with timestamps.
624 rm -f core $seqres.notrun
627 $timestamp && echo -n " ["`date "+%T"`"]"
628 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
629 $LOGGER_PROG "run xfstest $seqnum"
630 if [ -w /dev/kmsg ]; then
631 export date_time=`date +"%F %T"`
632 echo "run fstests $seqnum at $date_time" > /dev/kmsg
633 # _check_dmesg depends on this log in dmesg
634 touch ${RESULT_DIR}/check_dmesg
636 if [ "$DUMP_OUTPUT" = true ]; then
637 ./$seq 2>&1 | tee $tmp.rawout
638 # Because $? would get tee's return code
641 ./$seq >$tmp.rawout 2>&1
644 $timestamp && _timestamp
647 _fix_malloc <$tmp.rawout >$tmp.out
652 echo -n " [dumped core]"
653 mv core $RESULT_BASE/$seqnum.core
657 if [ -f $seqres.notrun ]
659 $timestamp || echo -n " [not run] "
660 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
662 notrun="$notrun $seqnum"
666 echo -n " [failed, exit status $sts]"
671 echo " - no qualified output"
675 # coreutils 8.16+ changed quote formats in error messages from
676 # `foo' to 'foo'. Filter old versions to match the new version.
677 sed -i "s/\`/\'/g" $tmp.out
678 if diff $seq.out $tmp.out >/dev/null 2>&1
684 echo "$seqnum `expr $stop - $start`" >>$tmp.time
685 echo -n " `expr $stop - $start`s"
689 echo " - output mismatch (see $seqres.out.bad)"
690 mv $tmp.out $seqres.out.bad
691 $diff $seq.out $seqres.out.bad | {
692 if test "$DIFF_LENGTH" -le 0; then
695 head -n "$DIFF_LENGTH"
697 echo "(Run '$diff $seq.out $seqres.out.bad'" \
698 " to see the entire diff)"
700 sed -e 's/^\(.\)/ \1/'
705 n_try=`expr $n_try + 1`
707 _check_dmesg || err=true
712 # come here for each test, except when $showme is true
717 n_bad=`expr $n_bad + 1`
726 _test_unmount 2> /dev/null
727 _scratch_unmount 2> /dev/null
731 status=`expr $sum_bad`