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
94 for d in $SRC_GROUPS $FSTYP; do
95 if ! test -d "$SRC_DIR/$d" ; then
98 l=$(sed -n < $SRC_DIR/$d/group \
101 -e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
107 # Find all tests, excluding files that are test metadata such as group files.
108 # It matches test names against $VALID_TEST_NAME defined in common/rc
112 for d in $SRC_GROUPS $FSTYP; do
113 if ! test -d "$SRC_DIR/$d" ; then
118 grep "^$SRC_DIR/$d/$VALID_TEST_NAME"| \
119 grep -v "group\|Makefile" >> $tmp.list 2>/dev/null
123 # takes the list of tests to run in $tmp.list, and removes the tests passed to
124 # the function from that list.
133 if [ $numsed -gt 100 ]; then
134 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
135 mv $tmp.tmp $tmp.list
139 echo "^$t\$" >>$tmp.grep
140 numsed=`expr $numsed + 1`
142 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
143 mv $tmp.tmp $tmp.list
161 # Tests specified on the command line
162 if [ -s $tmp.arglist ]; then
163 cat $tmp.arglist > $tmp.list
168 # Specified groups to include
169 for group in $GROUP_LIST; do
170 list=$(get_group_list $group)
171 if [ -z "$list" ]; then
172 echo "Group \"$group\" is empty or not defined?"
177 grep -s "^$t\$" $tmp.list >/dev/null || \
178 echo "$t" >>$tmp.list
182 if ! $have_test_arg && [ -z "$GROUP_LIST" ]; then
183 # no test numbers, do everything
187 # Specified groups to exclude
188 for xgroup in $XGROUP_LIST; do
189 list=$(get_group_list $xgroup)
190 if [ -z "$list" ]; then
191 echo "Group \"$xgroup\" is empty or not defined?"
198 # sort the list of tests into numeric order
199 list=`sort -n $tmp.list | uniq`
200 rm -f $tmp.list $tmp.tmp $tmp.grep
204 list=`echo $list | awk -f randomize.awk`
208 # Process command arguments first.
209 while [ $# -gt 0 ]; do
211 -\? | -h | --help) usage ;;
215 -overlay) FSTYP=overlay ;;
216 -tmpfs) FSTYP=tmpfs ;;
218 -g) group=$2 ; shift ;
219 GROUP_LIST="$GROUP_LIST ${group//,/ }"
222 -x) xgroup=$2 ; shift ;
223 XGROUP_LIST="$XGROUP_LIST ${xgroup//,/ }"
226 -X) xfile=$2; shift ;
227 for d in $SRC_GROUPS $FSTYP; do
228 [ -f $SRC_DIR/$d/$xfile ] || continue
229 for f in `sed "s/#.*$//" $SRC_DIR/$d/$xfile`; do
230 echo $d/$f >> $tmp.xlist
234 -E) xfile=$2; shift ;
235 if [ -f $xfile ]; then
236 sed "s/#.*$//" "$xfile" >> $tmp.xlist
239 -s) RUN_SECTION="$RUN_SECTION $2"; shift ;;
240 -S) EXCLUDE_SECTION="$EXCLUDE_SECTION $2"; shift ;;
242 -udiff) diff="$diff -u" ;;
245 -r) randomize=true ;;
247 -T) timestamp=true ;;
248 -d) DUMP_OUTPUT=true ;;
249 -b) brief_test_summary=true;;
251 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
252 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
255 *) # not an argument, we've got tests now.
256 have_test_arg=true ;;
259 # if we've found a test specification, the break out of the processing
260 # loop before we shift the arguments so that this is the first argument
261 # that we process in the test arg loop below.
262 if $have_test_arg; then
269 # we need common/config, source it after processing args, overlay needs FSTYP
270 # set before sourcing common/config
271 if ! . ./common/config; then
272 echo "$iam: failed to source common/config"
276 # Process tests from command line now.
277 if $have_test_arg; then
278 while [ $# -gt 0 ]; do
280 -*) echo "Arguments before tests, please!"
284 *) # Expand test pattern (e.g. xfs/???, *fs/001)
285 list=$(cd $SRC_DIR; echo $1)
287 test_dir=`dirname $t`
288 test_dir=${test_dir#$SRC_DIR/*}
289 test_name=`basename $t`
290 group_file=$SRC_DIR/$test_dir/group
292 if egrep -q "^$test_name" $group_file; then
293 # in group file ... OK
294 echo $SRC_DIR/$test_dir/$test_name \
298 echo "$t - unknown test, ignored"
311 echo "check: failed to source common/rc"
317 echo "check: QA must be run as root"
331 check="$RESULT_BASE/check"
336 if [ -f $check.time -a -f $tmp.time ]; then
337 cat $check.time $tmp.time \
342 for (i in t) print i " " t[i]
346 mv $tmp.out $check.time
352 echo "SECTION -- $section" >>$tmp.summary
353 echo "=========================" >>$tmp.summary
354 if [ ! -z "$n_try" -a $n_try != 0 ]; then
355 if [ $brief_test_summary == "false" ]; then
357 echo "Ran:$try" >>$tmp.summary
359 echo "Ran:$try" >>$check.log
362 $interrupt && echo "Interrupted!" >>$check.log
364 if [ ! -z "$notrun" ]; then
365 if [ $brief_test_summary == "false" ]; then
366 echo "Not run:$notrun"
367 echo "Not run:$notrun" >>$tmp.summary
369 echo "Not run:$notrun" >>$check.log
372 if [ ! -z "$n_bad" -a $n_bad != 0 ]; then
374 echo "Failed $n_bad of $n_try tests"
375 echo "Failures:$bad" >>$check.log
376 echo "Failed $n_bad of $n_try tests" >>$check.log
377 echo "Failures:$bad" >>$tmp.summary
378 echo "Failed $n_bad of $n_try tests" >>$tmp.summary
380 echo "Passed all $n_try tests"
381 echo "Passed all $n_try tests" >>$check.log
382 echo "Passed all $n_try tests" >>$tmp.summary
384 echo "" >>$tmp.summary
388 sum_bad=`expr $sum_bad + $n_bad`
390 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
391 if ! $OPTIONS_HAVE_SECTIONS; then
402 count=`wc -L $tmp.summary | cut -f1 -d" "`
411 if [ -f ${RESULT_DIR}/require_test ]; then
412 _check_test_fs || err=true
413 rm -f ${RESULT_DIR}/require_test*
415 if [ -f ${RESULT_DIR}/require_scratch ]; then
416 _check_scratch_fs || err=true
417 rm -f ${RESULT_DIR}/require_scratch*
423 if $OPTIONS_HAVE_SECTIONS; then
424 trap "_summary; exit \$status" 0 1 2 3 15
426 trap "_wrapup; exit \$status" 0 1 2 3 15
429 for section in $HOST_OPTIONS_SECTIONS; do
431 OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
432 get_next_config $section
434 # Do we need to run only some sections ?
435 if [ ! -z "$RUN_SECTION" ]; then
437 for s in $RUN_SECTION; do
438 if [ $section == $s ]; then
448 # Did this section get excluded?
449 if [ ! -z "$EXCLUDE_SECTION" ]; then
451 for s in $EXCLUDE_SECTION; do
452 if [ $section == $s ]; then
462 mkdir -p $RESULT_BASE
463 if [ ! -d $RESULT_BASE ]; then
464 echo "failed to create results directory $RESULT_BASE"
469 if $OPTIONS_HAVE_SECTIONS; then
470 echo "SECTION -- $section"
473 if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
474 echo "RECREATING -- $FSTYP on $TEST_DEV"
475 _test_unmount 2> /dev/null
476 if ! _test_mkfs >$tmp.err 2>&1
478 echo "our local _test_mkfs routine ..."
480 echo "check: failed to mkfs \$TEST_DEV using specified options"
484 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
485 if [ $? -ne 1 ]; then
491 elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
492 _test_unmount 2> /dev/null
493 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
494 if [ $? -ne 1 ]; then
504 check="$RESULT_BASE/check"
506 # don't leave old full output behind on a clean run
509 [ -f $check.time ] || touch $check.time
511 # print out our test configuration
512 echo "FSTYP -- `_full_fstyp_details`"
513 echo "PLATFORM -- `_full_platform_details`"
514 if [ ! -z "$SCRATCH_DEV" ]; then
515 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
516 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
521 if [ ! -z "$SCRATCH_DEV" ]; then
522 _scratch_unmount 2> /dev/null
523 # call the overridden mkfs - make sure the FS is built
524 # the same as we'll create it later.
526 if ! _scratch_mkfs >$tmp.err 2>&1
528 echo "our local _scratch_mkfs routine ..."
530 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
535 # call the overridden mount - make sure the FS mounts with
536 # the same options that we'll mount with later.
537 if ! _scratch_mount >$tmp.err 2>&1
539 echo "our local mount routine ..."
541 echo "check: failed to mount \$SCRATCH_DEV using specified options"
553 if [ ! -f $seq ]; then
554 # Try to get full name in case the user supplied only seq id
555 # and the test has a name. A bit of hassle to find really
556 # the test and not its sample output or helping files.
557 bname=$(basename $seq)
558 full_seq=$(find $(dirname $seq) -name $bname* -executable |
559 awk '(NR == 1 || length < length(shortest)) { shortest = $0 }\
560 END { print shortest }')
561 if [ -f $full_seq ] \
562 && [ x$(echo $bname | grep -o "^$VALID_TEST_ID") != x ]; then
567 # the filename for the test and the name output are different.
568 # we don't include the tests/ directory in the name output.
569 export seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
571 # Similarly, the result directory needs to replace the tests/
572 # part of the test location.
574 if $OPTIONS_HAVE_SECTIONS; then
575 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;${RESULT_BASE}/$section;"`
576 seqres="$RESULT_BASE/$section/$seqnum"
578 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
579 seqres="$RESULT_BASE/$seqnum"
591 if [ ! -f $seq ]; then
592 echo " - no such test?"
594 # really going to try and run this one
596 rm -f $seqres.out.bad
598 # check if we really should run it
599 if [ -s $tmp.xlist ]; then
600 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
606 # slashes now in names, sed barfs on them so use grep
607 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
608 if [ "X$lasttime" != X ]; then
609 echo -n " ${lasttime}s ..."
611 echo -n " " # prettier output with timestamps.
613 rm -f core $seqres.notrun
616 $timestamp && echo -n " ["`date "+%T"`"]"
617 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
618 $LOGGER_PROG "run xfstest $seqnum"
619 if [ -w /dev/kmsg ]; then
620 export date_time=`date +"%F %T"`
621 echo "run fstests $seqnum at $date_time" > /dev/kmsg
622 # _check_dmesg depends on this log in dmesg
623 touch ${RESULT_DIR}/check_dmesg
625 if [ "$DUMP_OUTPUT" = true ]; then
626 ./$seq 2>&1 | tee $tmp.rawout
627 # Because $? would get tee's return code
630 ./$seq >$tmp.rawout 2>&1
633 $timestamp && _timestamp
636 _fix_malloc <$tmp.rawout >$tmp.out
641 echo -n " [dumped core]"
642 mv core $RESULT_BASE/$seqnum.core
646 if [ -f $seqres.notrun ]
648 $timestamp || echo -n " [not run] "
649 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
651 notrun="$notrun $seqnum"
655 echo -n " [failed, exit status $sts]"
660 echo " - no qualified output"
664 # coreutils 8.16+ changed quote formats in error messages from
665 # `foo' to 'foo'. Filter old versions to match the new version.
666 sed -i "s/\`/\'/g" $tmp.out
667 if diff $seq.out $tmp.out >/dev/null 2>&1
673 echo "$seqnum `expr $stop - $start`" >>$tmp.time
674 echo -n " `expr $stop - $start`s"
678 echo " - output mismatch (see $seqres.out.bad)"
679 mv $tmp.out $seqres.out.bad
680 $diff $seq.out $seqres.out.bad | {
681 if test "$DIFF_LENGTH" -le 0; then
684 head -n "$DIFF_LENGTH"
686 echo "(Run '$diff $seq.out $seqres.out.bad'" \
687 " to see the entire diff)"
689 sed -e 's/^\(.\)/ \1/'
694 n_try=`expr $n_try + 1`
696 _check_dmesg || err=true
701 # come here for each test, except when $showme is true
706 n_bad=`expr $n_bad + 1`
715 _test_unmount 2> /dev/null
716 _scratch_unmount 2> /dev/null
720 status=`expr $sum_bad`