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
42 # start the initialisation work now
45 export MSGVERB="text:action"
46 export QA_CHECK_FS=${QA_CHECK_FS:=true}
48 # number of diff lines from a failed test, 0 for whole output
49 export DIFF_LENGTH=${DIFF_LENGTH:=10}
51 # by default don't output timestamps
52 timestamp=${TIMESTAMP:=false}
54 rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist
56 SRC_GROUPS="generic shared"
57 export SRC_DIR="tests"
61 echo "Usage: $0 [options] [testlist]"'
69 -udiff show unified diff (default)
70 -n show me, do not run tests
72 -r randomize test order
73 -d dump test output to stdout
74 --large-fs optimise scratch device for large filesystems
75 -s section run only specified section from config file
76 -S section exclude the specified section from the config file
79 -g group[,group...] include tests from these groups
80 -x group[,group...] exclude tests from these groups
81 -X file exclude individual tests
82 -E external_file exclude individual tests
83 [testlist] include tests matching names in testlist
92 for d in $SRC_GROUPS $FSTYP; do
93 if ! test -d "$SRC_DIR/$d" ; then
96 l=$(sed -n < $SRC_DIR/$d/group \
99 -e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
105 # Find all tests, excluding files that are test metadata such as group files.
106 # It matches test names against $VALID_TEST_NAME defined in common/rc
110 for d in $SRC_GROUPS $FSTYP; do
111 if ! test -d "$SRC_DIR/$d" ; then
116 grep "^$SRC_DIR/$d/$VALID_TEST_NAME"| \
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
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 ;;
213 -overlay) FSTYP=overlay ;;
214 -tmpfs) FSTYP=tmpfs ;;
216 -g) group=$2 ; shift ;
217 GROUP_LIST="$GROUP_LIST ${group//,/ }"
220 -x) xgroup=$2 ; shift ;
221 XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }"
224 -X) xfile=$2; shift ;
225 for d in $SRC_GROUPS $FSTYP; do
226 [ -f $SRC_DIR/$d/$xfile ] || continue
227 for f in `cat $SRC_DIR/$d/$xfile`; do
228 echo $d/$f >> $tmp.xlist
232 -E) xfile=$2; shift ;
233 if [ -f $xfile ]; then
234 cat "$xfile" >> $tmp.xlist
237 -s) RUN_SECTION="$RUN_SECTION $2"; shift ;;
238 -S) EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
240 -udiff) diff="$diff -u" ;;
243 -r) randomize=true ;;
245 -T) timestamp=true ;;
246 -d) DUMP_OUTPUT=true ;;
248 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
249 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
252 *) # not an argument, we've got tests now.
253 have_test_arg=true ;;
256 # if we've found a test specification, the break out of the processing
257 # loop before we shift the arguments so that this is the first argument
258 # that we process in the test arg loop below.
259 if $have_test_arg; then
266 # we need common/config, source it after processing args, overlay needs FSTYP
267 # set before sourcing common/config
268 if ! . ./common/config; then
269 echo "$iam: failed to source common/config"
273 # Process tests from command line now.
274 if $have_test_arg; then
275 while [ $# -gt 0 ]; do
277 -*) echo "Arguments before tests, please!"
281 *) test_dir=`dirname $1`
282 test_dir=${test_dir#$SRC_DIR/*}
283 test_name=`basename $1`
284 group_file=$SRC_DIR/$test_dir/group
286 if egrep "^$test_name" $group_file >/dev/null ; then
287 # in group file ... OK
288 echo $SRC_DIR/$test_dir/$test_name >>$tmp.arglist
291 echo "$1 - unknown test, ignored"
303 echo "check: failed to source common/rc"
309 echo "check: QA must be run as root"
323 check="$RESULT_BASE/check"
330 if [ -f $check.time -a -f $tmp.time ]
332 cat $check.time $tmp.time \
336 for (i in t) print i " " t[i]
340 mv $tmp.out $check.time
345 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>$check.log
346 $interrupt && echo "Interrupted!" >>$check.log
348 echo "SECTION -- $section" >>$tmp.summary
349 echo "=========================" >>$tmp.summary
350 if [ ! -z "$n_try" -a $n_try != 0 ]
353 echo "Ran:$try" >>$tmp.summary
356 if [ ! -z "$notrun" ]
358 echo "Not run:$notrun"
359 echo "Not run:$notrun" >>$check.log
360 echo "Not run:$notrun" >>$tmp.summary
363 if [ ! -z "$n_bad" -a $n_bad != 0 ]
366 echo "Failed $n_bad of $n_try tests"
367 echo "Failures:$bad" | fmt >>$check.log
368 echo "Failed $n_bad of $n_try tests" >>$check.log
369 echo "Failures:$bad" >>$tmp.summary
370 echo "Failed $n_bad of $n_try tests" >>$tmp.summary
372 echo "Passed all $n_try tests"
373 echo "Passed all $n_try tests" >>$check.log
374 echo "Passed all $n_try tests" >>$tmp.summary
376 echo "" >>$tmp.summary
380 sum_bad=`expr $sum_bad + $n_bad`
382 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
383 if ! $OPTIONS_HAVE_SECTIONS; then
394 count=`wc -L $tmp.summary | cut -f1 -d" "`
403 if [ -f ${RESULT_DIR}/require_test ]; then
404 _check_test_fs || err=true
405 rm -f ${RESULT_DIR}/require_test
407 if [ -f ${RESULT_DIR}/require_scratch ]; then
408 _check_scratch_fs || err=true
409 rm -f ${RESULT_DIR}/require_scratch
415 if $OPTIONS_HAVE_SECTIONS; then
416 trap "_summary; exit \$status" 0 1 2 3 15
418 trap "_wrapup; exit \$status" 0 1 2 3 15
421 for section in $HOST_OPTIONS_SECTIONS; do
423 OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
424 get_next_config $section
426 # Do we need to run only some sections ?
427 if [ ! -z "$RUN_SECTION" ]; then
429 for s in $RUN_SECTION; do
430 if [ $section == $s ]; then
440 # Did this section get excluded?
441 if [ ! -z "$EXCLUDE_SECTION" ]; then
443 for s in $EXCLUDE_SECTION; do
444 if [ $section == $s ]; then
454 mkdir -p $RESULT_BASE
455 if [ ! -d $RESULT_BASE ]; then
456 echo "failed to create results directory $RESULT_BASE"
461 if $OPTIONS_HAVE_SECTIONS; then
462 echo "SECTION -- $section"
465 if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
466 echo "RECREATING -- $FSTYP on $TEST_DEV"
467 _test_unmount 2> /dev/null
468 if ! _test_mkfs >$tmp.err 2>&1
470 echo "our local _test_mkfs routine ..."
472 echo "check: failed to mkfs \$TEST_DEV using specified options"
476 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
477 if [ $? -ne 1 ]; then
483 elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
484 _test_unmount 2> /dev/null
485 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
486 if [ $? -ne 1 ]; then
496 check="$RESULT_BASE/check"
498 # don't leave old full output behind on a clean run
501 [ -f $check.time ] || touch $check.time
503 # print out our test configuration
504 echo "FSTYP -- `_full_fstyp_details`"
505 echo "PLATFORM -- `_full_platform_details`"
506 if [ ! -z "$SCRATCH_DEV" ]; then
507 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
508 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
513 if [ ! -z "$SCRATCH_DEV" ]; then
514 _scratch_unmount 2> /dev/null
515 # call the overridden mkfs - make sure the FS is built
516 # the same as we'll create it later.
518 if ! _scratch_mkfs >$tmp.err 2>&1
520 echo "our local _scratch_mkfs routine ..."
522 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
527 # call the overridden mount - make sure the FS mounts with
528 # the same options that we'll mount with later.
529 if ! _scratch_mount >$tmp.err 2>&1
531 echo "our local mount routine ..."
533 echo "check: failed to mount \$SCRATCH_DEV using specified options"
546 # the filename for the test and the name output are different.
547 # we don't include the tests/ directory in the name output.
548 export seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
550 # Similarly, the result directory needs to replace the tests/
551 # part of the test location.
553 if $OPTIONS_HAVE_SECTIONS; then
554 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;${RESULT_BASE}/$section;"`
555 seqres="$RESULT_BASE/$section/$seqnum"
557 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
558 seqres="$RESULT_BASE/$seqnum"
568 elif [ ! -f $seq ]; then
569 # Try to get full name in case the user supplied only seq id
570 # and the test has a name. A bit of hassle to find really
571 # the test and not its sample output or helping files.
572 bname=$(basename $seq)
573 full_seq=$(find $(dirname $seq) -name $bname* -executable |
574 awk '(NR == 1 || length < length(shortest)) { shortest = $0 }\
575 END { print shortest }')
576 if [ -f $full_seq ] \
577 && [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
579 seqnum=${full_seq#*/}
583 if [ ! -f $seq ]; then
584 echo " - no such test?"
586 # really going to try and run this one
588 rm -f $seqres.out.bad
590 # check if we really should run it
591 if [ -s $tmp.xlist ]; then
592 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
598 # slashes now in names, sed barfs on them so use grep
599 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
600 if [ "X$lasttime" != X ]; then
601 echo -n " ${lasttime}s ..."
603 echo -n " " # prettier output with timestamps.
605 rm -f core $seqres.notrun
608 $timestamp && echo -n " ["`date "+%T"`"]"
609 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
610 $LOGGER_PROG "run xfstest $seqnum"
611 if [ -w /dev/kmsg ]; then
612 export date_time=`date +"%F %T"`
613 echo "run fstests $seqnum at $date_time" > /dev/kmsg
614 # _check_dmesg depends on this log in dmesg
615 touch ${RESULT_DIR}/check_dmesg
617 if [ "$DUMP_OUTPUT" = true ]; then
618 ./$seq 2>&1 | tee $tmp.rawout
619 # Because $? would get tee's return code
622 ./$seq >$tmp.rawout 2>&1
625 $timestamp && _timestamp
628 _fix_malloc <$tmp.rawout >$tmp.out
633 echo -n " [dumped core]"
634 mv core $RESULT_BASE/$seqnum.core
638 if [ -f $seqres.notrun ]
640 $timestamp || echo -n " [not run] "
641 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
643 notrun="$notrun $seqnum"
647 echo -n " [failed, exit status $sts]"
652 echo " - no qualified output"
656 # coreutils 8.16+ changed quote formats in error messages from
657 # `foo' to 'foo'. Filter old versions to match the new version.
658 sed -i "s/\`/\'/g" $tmp.out
659 if diff $seq.out $tmp.out >/dev/null 2>&1
665 echo "$seqnum `expr $stop - $start`" >>$tmp.time
666 echo -n " `expr $stop - $start`s"
670 echo " - output mismatch (see $seqres.out.bad)"
671 mv $tmp.out $seqres.out.bad
672 $diff $seq.out $seqres.out.bad | {
673 if test "$DIFF_LENGTH" -le 0; then
676 head -n "$DIFF_LENGTH"
678 echo "(Run '$diff $seq.out $seqres.out.bad'" \
679 " to see the entire diff)"
681 sed -e 's/^\(.\)/ \1/'
686 n_try=`expr $n_try + 1`
688 _check_dmesg || err=true
693 # come here for each test, except when $showme is true
698 n_bad=`expr $n_bad + 1`
707 _test_unmount 2> /dev/null
708 _scratch_unmount 2> /dev/null
712 status=`expr $sum_bad`