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
78 -g group[,group...] include tests from these groups
79 -x group[,group...] exclude tests from these groups
80 -X file exclude individual tests
81 -E external_file exclude individual tests
82 [testlist] include tests matching names in testlist
91 for d in $SRC_GROUPS $FSTYP; do
92 l=$(sed -n < $SRC_DIR/$d/group \
95 -e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
101 # Find all tests, excluding files that are test metadata such as group files.
102 # It matches test names against $VALID_TEST_NAME defined in common/rc
106 for d in $SRC_GROUPS $FSTYP; do
109 grep "^$SRC_DIR/$d/$VALID_TEST_NAME"| \
110 grep -v "group\|Makefile" >> $tmp.list 2>/dev/null
114 # takes the list of tests to run in $tmp.list, and removes the tests passed to
115 # the function from that list.
124 if [ $numsed -gt 100 ]; then
125 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
126 mv $tmp.tmp $tmp.list
130 echo "^$t\$" >>$tmp.grep
131 numsed=`expr $numsed + 1`
133 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
134 mv $tmp.tmp $tmp.list
152 # Tests specified on the command line
153 if [ -s $tmp.arglist ]; then
154 cat $tmp.arglist > $tmp.list
159 # Specified groups to include
160 for group in $GROUP_LIST; do
161 list=$(get_group_list $group)
162 if [ -z "$list" ]; then
163 echo "Group \"$group\" is empty or not defined?"
168 grep -s "^$t\$" $tmp.list >/dev/null || \
169 echo "$t" >>$tmp.list
173 if ! $have_test_arg && [ -z "$GROUP_LIST" ]; then
174 # no test numbers, do everything
178 # Specified groups to exclude
179 for xgroup in $XGROUP_LIST; do
180 list=$(get_group_list $xgroup)
181 if [ -z "$list" ]; then
182 echo "Group \"$xgroup\" is empty or not defined?"
189 # sort the list of tests into numeric order
190 list=`sort -n $tmp.list | uniq`
191 rm -f $tmp.list $tmp.tmp $tmp.grep
195 list=`echo $list | awk -f randomize.awk`
199 # Process command arguments first.
200 while [ $# -gt 0 ]; do
202 -\? | -h | --help) usage ;;
206 -overlay) FSTYP=overlay ;;
207 -tmpfs) FSTYP=tmpfs ;;
209 -g) group=$2 ; shift ;
210 GROUP_LIST="$GROUP_LIST ${group//,/ }"
213 -x) xgroup=$2 ; shift ;
214 XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }"
217 -X) xfile=$2; shift ;
218 for d in $SRC_GROUPS $FSTYP; do
219 [ -f $SRC_DIR/$d/$xfile ] || continue
220 for f in `cat $SRC_DIR/$d/$xfile`; do
221 echo $d/$f >> $tmp.xlist
225 -E) xfile=$2; shift ;
226 if [ -f $xfile ]; then
227 cat "$xfile" >> $tmp.xlist
230 -s) RUN_SECTION="$RUN_SECTION $2"; shift ;;
232 -udiff) diff="$diff -u" ;;
235 -r) randomize=true ;;
237 -T) timestamp=true ;;
238 -d) DUMP_OUTPUT=true ;;
240 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
241 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
244 *) # not an argument, we've got tests now.
245 have_test_arg=true ;;
248 # if we've found a test specification, the break out of the processing
249 # loop before we shift the arguments so that this is the first argument
250 # that we process in the test arg loop below.
251 if $have_test_arg; then
258 # we need common/config, source it after processing args, overlay needs FSTYP
259 # set before sourcing common/config
260 if ! . ./common/config; then
261 echo "$iam: failed to source common/config"
265 # Process tests from command line now.
266 if $have_test_arg; then
267 while [ $# -gt 0 ]; do
269 -*) echo "Arguments before tests, please!"
273 *) test_dir=`dirname $1`
274 test_dir=${test_dir#$SRC_DIR/*}
275 test_name=`basename $1`
276 group_file=$SRC_DIR/$test_dir/group
278 if egrep "^$test_name" $group_file >/dev/null ; then
279 # in group file ... OK
280 echo $SRC_DIR/$test_dir/$test_name >>$tmp.arglist
283 echo "$1 - unknown test, ignored"
295 echo "check: failed to source common/rc"
301 echo "check: QA must be run as root"
315 check="$RESULT_BASE/check"
322 if [ -f $check.time -a -f $tmp.time ]
324 cat $check.time $tmp.time \
328 for (i in t) print i " " t[i]
332 mv $tmp.out $check.time
337 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>$check.log
338 $interrupt && echo "Interrupted!" >>$check.log
340 echo "SECTION -- $section" >>$tmp.summary
341 echo "=========================" >>$tmp.summary
342 if [ ! -z "$n_try" -a $n_try != 0 ]
345 echo "Ran:$try" >>$tmp.summary
348 if [ ! -z "$notrun" ]
350 echo "Not run:$notrun"
351 echo "Not run:$notrun" >>$check.log
352 echo "Not run:$notrun" >>$tmp.summary
355 if [ ! -z "$n_bad" -a $n_bad != 0 ]
358 echo "Failed $n_bad of $n_try tests"
359 echo "Failures:$bad" | fmt >>$check.log
360 echo "Failed $n_bad of $n_try tests" >>$check.log
361 echo "Failures:$bad" >>$tmp.summary
362 echo "Failed $n_bad of $n_try tests" >>$tmp.summary
364 echo "Passed all $n_try tests"
365 echo "Passed all $n_try tests" >>$check.log
366 echo "Passed all $n_try tests" >>$tmp.summary
368 echo "" >>$tmp.summary
372 sum_bad=`expr $sum_bad + $n_bad`
374 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
375 if ! $OPTIONS_HAVE_SECTIONS; then
386 count=`wc -L $tmp.summary | cut -f1 -d" "`
395 if [ -f ${RESULT_DIR}/require_test ]; then
396 _check_test_fs || err=true
397 rm -f ${RESULT_DIR}/require_test
399 if [ -f ${RESULT_DIR}/require_scratch ]; then
400 _check_scratch_fs || err=true
401 rm -f ${RESULT_DIR}/require_scratch
407 if $OPTIONS_HAVE_SECTIONS; then
408 trap "_summary; exit \$status" 0 1 2 3 15
410 trap "_wrapup; exit \$status" 0 1 2 3 15
413 for section in $HOST_OPTIONS_SECTIONS; do
415 OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
416 get_next_config $section
418 # Do we need to run only some sections ?
419 if [ ! -z "$RUN_SECTION" ]; then
421 for s in $RUN_SECTION; do
422 if [ $section == $s ]; then
431 mkdir -p $RESULT_BASE
432 if [ ! -d $RESULT_BASE ]; then
433 echo "failed to create results directory $RESULT_BASE"
438 if $OPTIONS_HAVE_SECTIONS; then
439 echo "SECTION -- $section"
442 if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
443 echo "RECREATING -- $FSTYP on $TEST_DEV"
444 _test_unmount 2> /dev/null
445 if ! _test_mkfs >$tmp.err 2>&1
447 echo "our local _test_mkfs routine ..."
449 echo "check: failed to mkfs \$TEST_DEV using specified options"
453 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
454 if [ $? -ne 1 ]; then
460 elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
461 _test_unmount 2> /dev/null
462 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
463 if [ $? -ne 1 ]; then
473 check="$RESULT_BASE/check"
475 # don't leave old full output behind on a clean run
478 [ -f $check.time ] || touch $check.time
480 # print out our test configuration
481 echo "FSTYP -- `_full_fstyp_details`"
482 echo "PLATFORM -- `_full_platform_details`"
483 if [ ! -z "$SCRATCH_DEV" ]; then
484 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
485 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
490 if [ ! -z "$SCRATCH_DEV" ]; then
491 _scratch_unmount 2> /dev/null
492 # call the overridden mkfs - make sure the FS is built
493 # the same as we'll create it later.
495 if ! _scratch_mkfs >$tmp.err 2>&1
497 echo "our local _scratch_mkfs routine ..."
499 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
504 # call the overridden mount - make sure the FS mounts with
505 # the same options that we'll mount with later.
506 if ! _scratch_mount >$tmp.err 2>&1
508 echo "our local mount routine ..."
510 echo "check: failed to mount \$SCRATCH_DEV using specified options"
523 # the filename for the test and the name output are different.
524 # we don't include the tests/ directory in the name output.
525 export seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
527 # Similarly, the result directory needs to replace the tests/
528 # part of the test location.
530 if $OPTIONS_HAVE_SECTIONS; then
531 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;${RESULT_BASE}/$section;"`
532 seqres="$RESULT_BASE/$section/$seqnum"
534 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
535 seqres="$RESULT_BASE/$seqnum"
545 elif [ ! -f $seq ]; then
546 # Try to get full name in case the user supplied only seq id
547 # and the test has a name. A bit of hassle to find really
548 # the test and not its sample output or helping files.
549 bname=$(basename $seq)
550 full_seq=$(find $(dirname $seq) -name $bname* -executable |
551 awk '(NR == 1 || length < length(shortest)) { shortest = $0 }\
552 END { print shortest }')
553 if [ -f $full_seq ] \
554 && [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
556 seqnum=${full_seq#*/}
560 if [ ! -f $seq ]; then
561 echo " - no such test?"
563 # really going to try and run this one
565 rm -f $seqres.out.bad
567 # check if we really should run it
568 if [ -s $tmp.xlist ]; then
569 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
575 # slashes now in names, sed barfs on them so use grep
576 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
577 if [ "X$lasttime" != X ]; then
578 echo -n " ${lasttime}s ..."
580 echo -n " " # prettier output with timestamps.
582 rm -f core $seqres.notrun
585 $timestamp && echo -n " ["`date "+%T"`"]"
586 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
587 $LOGGER_PROG "run xfstest $seqnum"
588 if [ -w /dev/kmsg ]; then
589 export date_time=`date +"%F %T"`
590 echo "run fstests $seqnum at $date_time" > /dev/kmsg
591 # _check_dmesg depends on this log in dmesg
592 touch ${RESULT_DIR}/check_dmesg
594 if [ "$DUMP_OUTPUT" = true ]; then
595 ./$seq 2>&1 | tee $tmp.rawout
596 # Because $? would get tee's return code
599 ./$seq >$tmp.rawout 2>&1
602 $timestamp && _timestamp
605 _fix_malloc <$tmp.rawout >$tmp.out
610 echo -n " [dumped core]"
611 mv core $RESULT_BASE/$seqnum.core
615 if [ -f $seqres.notrun ]
617 $timestamp || echo -n " [not run] "
618 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
620 notrun="$notrun $seqnum"
624 echo -n " [failed, exit status $sts]"
629 echo " - no qualified output"
633 # coreutils 8.16+ changed quote formats in error messages from
634 # `foo' to 'foo'. Filter old versions to match the new version.
635 sed -i "s/\`/\'/g" $tmp.out
636 if diff $seq.out $tmp.out >/dev/null 2>&1
642 echo "$seqnum `expr $stop - $start`" >>$tmp.time
643 echo -n " `expr $stop - $start`s"
647 echo " - output mismatch (see $seqres.out.bad)"
648 mv $tmp.out $seqres.out.bad
649 $diff $seq.out $seqres.out.bad | {
650 if test "$DIFF_LENGTH" -le 0; then
653 head -n "$DIFF_LENGTH"
655 echo "(Run '$diff $seq.out $seqres.out.bad'" \
656 " to see the entire diff)"
658 sed -e 's/^\(.\)/ \1/'
663 n_try=`expr $n_try + 1`
665 _check_dmesg || err=true
670 # come here for each test, except when $showme is true
675 n_bad=`expr $n_bad + 1`
684 _test_unmount 2> /dev/null
685 _scratch_unmount 2> /dev/null
689 status=`expr $sum_bad`