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 `sed "s/#.*$//" $SRC_DIR/$d/$xfile`; do
228 echo $d/$f >> $tmp.xlist
232 -E) xfile=$2; shift ;
233 if [ -f $xfile ]; then
234 sed "s/#.*$//" "$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
346 echo "SECTION -- $section" >>$tmp.summary
347 echo "=========================" >>$tmp.summary
348 if [ ! -z "$n_try" -a $n_try != 0 ]
351 echo "Ran:$try" >>$check.log
352 echo "Ran:$try" >>$tmp.summary
355 $interrupt && echo "Interrupted!" >>$check.log
357 if [ ! -z "$notrun" ]
359 echo "Not run:$notrun"
360 echo "Not run:$notrun" >>$check.log
361 echo "Not run:$notrun" >>$tmp.summary
364 if [ ! -z "$n_bad" -a $n_bad != 0 ]
367 echo "Failed $n_bad of $n_try tests"
368 echo "Failures:$bad" >>$check.log
369 echo "Failed $n_bad of $n_try tests" >>$check.log
370 echo "Failures:$bad" >>$tmp.summary
371 echo "Failed $n_bad of $n_try tests" >>$tmp.summary
373 echo "Passed all $n_try tests"
374 echo "Passed all $n_try tests" >>$check.log
375 echo "Passed all $n_try tests" >>$tmp.summary
377 echo "" >>$tmp.summary
381 sum_bad=`expr $sum_bad + $n_bad`
383 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
384 if ! $OPTIONS_HAVE_SECTIONS; then
395 count=`wc -L $tmp.summary | cut -f1 -d" "`
404 if [ -f ${RESULT_DIR}/require_test ]; then
405 _check_test_fs || err=true
406 rm -f ${RESULT_DIR}/require_test
408 if [ -f ${RESULT_DIR}/require_scratch ]; then
409 _check_scratch_fs || err=true
410 rm -f ${RESULT_DIR}/require_scratch
416 if $OPTIONS_HAVE_SECTIONS; then
417 trap "_summary; exit \$status" 0 1 2 3 15
419 trap "_wrapup; exit \$status" 0 1 2 3 15
422 for section in $HOST_OPTIONS_SECTIONS; do
424 OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
425 get_next_config $section
427 # Do we need to run only some sections ?
428 if [ ! -z "$RUN_SECTION" ]; then
430 for s in $RUN_SECTION; do
431 if [ $section == $s ]; then
441 # Did this section get excluded?
442 if [ ! -z "$EXCLUDE_SECTION" ]; then
444 for s in $EXCLUDE_SECTION; do
445 if [ $section == $s ]; then
455 mkdir -p $RESULT_BASE
456 if [ ! -d $RESULT_BASE ]; then
457 echo "failed to create results directory $RESULT_BASE"
462 if $OPTIONS_HAVE_SECTIONS; then
463 echo "SECTION -- $section"
466 if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
467 echo "RECREATING -- $FSTYP on $TEST_DEV"
468 _test_unmount 2> /dev/null
469 if ! _test_mkfs >$tmp.err 2>&1
471 echo "our local _test_mkfs routine ..."
473 echo "check: failed to mkfs \$TEST_DEV using specified options"
477 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
478 if [ $? -ne 1 ]; then
484 elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
485 _test_unmount 2> /dev/null
486 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
487 if [ $? -ne 1 ]; then
497 check="$RESULT_BASE/check"
499 # don't leave old full output behind on a clean run
502 [ -f $check.time ] || touch $check.time
504 # print out our test configuration
505 echo "FSTYP -- `_full_fstyp_details`"
506 echo "PLATFORM -- `_full_platform_details`"
507 if [ ! -z "$SCRATCH_DEV" ]; then
508 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
509 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
514 if [ ! -z "$SCRATCH_DEV" ]; then
515 _scratch_unmount 2> /dev/null
516 # call the overridden mkfs - make sure the FS is built
517 # the same as we'll create it later.
519 if ! _scratch_mkfs >$tmp.err 2>&1
521 echo "our local _scratch_mkfs routine ..."
523 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
528 # call the overridden mount - make sure the FS mounts with
529 # the same options that we'll mount with later.
530 if ! _scratch_mount >$tmp.err 2>&1
532 echo "our local mount routine ..."
534 echo "check: failed to mount \$SCRATCH_DEV using specified options"
546 if [ ! -f $seq ]; then
547 # Try to get full name in case the user supplied only seq id
548 # and the test has a name. A bit of hassle to find really
549 # the test and not its sample output or helping files.
550 bname=$(basename $seq)
551 full_seq=$(find $(dirname $seq) -name $bname* -executable |
552 awk '(NR == 1 || length < length(shortest)) { shortest = $0 }\
553 END { print shortest }')
554 if [ -f $full_seq ] \
555 && [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
560 # the filename for the test and the name output are different.
561 # we don't include the tests/ directory in the name output.
562 export seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
564 # Similarly, the result directory needs to replace the tests/
565 # part of the test location.
567 if $OPTIONS_HAVE_SECTIONS; then
568 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;${RESULT_BASE}/$section;"`
569 seqres="$RESULT_BASE/$section/$seqnum"
571 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
572 seqres="$RESULT_BASE/$seqnum"
584 if [ ! -f $seq ]; then
585 echo " - no such test?"
587 # really going to try and run this one
589 rm -f $seqres.out.bad
591 # check if we really should run it
592 if [ -s $tmp.xlist ]; then
593 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
599 # slashes now in names, sed barfs on them so use grep
600 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
601 if [ "X$lasttime" != X ]; then
602 echo -n " ${lasttime}s ..."
604 echo -n " " # prettier output with timestamps.
606 rm -f core $seqres.notrun
609 $timestamp && echo -n " ["`date "+%T"`"]"
610 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
611 $LOGGER_PROG "run xfstest $seqnum"
612 if [ -w /dev/kmsg ]; then
613 export date_time=`date +"%F %T"`
614 echo "run fstests $seqnum at $date_time" > /dev/kmsg
615 # _check_dmesg depends on this log in dmesg
616 touch ${RESULT_DIR}/check_dmesg
618 if [ "$DUMP_OUTPUT" = true ]; then
619 ./$seq 2>&1 | tee $tmp.rawout
620 # Because $? would get tee's return code
623 ./$seq >$tmp.rawout 2>&1
626 $timestamp && _timestamp
629 _fix_malloc <$tmp.rawout >$tmp.out
634 echo -n " [dumped core]"
635 mv core $RESULT_BASE/$seqnum.core
639 if [ -f $seqres.notrun ]
641 $timestamp || echo -n " [not run] "
642 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
644 notrun="$notrun $seqnum"
648 echo -n " [failed, exit status $sts]"
653 echo " - no qualified output"
657 # coreutils 8.16+ changed quote formats in error messages from
658 # `foo' to 'foo'. Filter old versions to match the new version.
659 sed -i "s/\`/\'/g" $tmp.out
660 if diff $seq.out $tmp.out >/dev/null 2>&1
666 echo "$seqnum `expr $stop - $start`" >>$tmp.time
667 echo -n " `expr $stop - $start`s"
671 echo " - output mismatch (see $seqres.out.bad)"
672 mv $tmp.out $seqres.out.bad
673 $diff $seq.out $seqres.out.bad | {
674 if test "$DIFF_LENGTH" -le 0; then
677 head -n "$DIFF_LENGTH"
679 echo "(Run '$diff $seq.out $seqres.out.bad'" \
680 " to see the entire diff)"
682 sed -e 's/^\(.\)/ \1/'
687 n_try=`expr $n_try + 1`
689 _check_dmesg || err=true
694 # come here for each test, except when $showme is true
699 n_bad=`expr $n_bad + 1`
708 _test_unmount 2> /dev/null
709 _scratch_unmount 2> /dev/null
713 status=`expr $sum_bad`