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
40 # start the initialisation work now
43 export MSGVERB="text:action"
44 export QA_CHECK_FS=${QA_CHECK_FS:=true}
46 # number of diff lines from a failed test, 0 for whole output
47 export DIFF_LENGTH=${DIFF_LENGTH:=10}
49 # by default don't output timestamps
50 timestamp=${TIMESTAMP:=false}
52 rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist
54 # we need common/config
55 if ! . ./common/config
57 echo "$iam: failed to source common/config"
61 SUPPORTED_TESTS="[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]"
62 SRC_GROUPS="generic shared"
63 export SRC_DIR="tests"
67 echo "Usage: $0 [options] [testlist]"'
74 -udiff show unified diff (default)
75 -n show me, do not run tests
77 -r randomize test order
78 --large-fs optimise scratch device for large filesystems
79 -s section run only specified section from config file
82 -g group[,group...] include tests from these groups
83 -x group[,group...] exclude tests from these groups
84 -X file exclude individual tests
85 -E external_file exclude individual tests
86 [testlist] include tests matching names in testlist
95 for d in $SRC_GROUPS $FSTYP; do
96 l=$(sed -n < $SRC_DIR/$d/group \
99 -e "s;\(^[0-9][0-9][0-9]\).* $grp .*;$SRC_DIR/$d/\1;p")
105 # find all tests, excluding files that are test metadata such as group files.
106 # This assumes that tests are defined purely by alphanumeric filenames with no
107 # ".xyz" extensions in the name.
111 for d in $SRC_GROUPS $FSTYP; do
114 grep -v "group\|Makefile" >> $tmp.list 2>/dev/null
118 # takes the list of tests to run in $tmp.list, and removes the tests passed to
119 # the function from that list.
128 if [ $numsed -gt 100 ]; then
129 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
130 mv $tmp.tmp $tmp.list
134 echo "^$t\$" >>$tmp.grep
135 numsed=`expr $numsed + 1`
137 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
138 mv $tmp.tmp $tmp.list
156 # Tests specified on the command line
157 if [ -s $tmp.arglist ]; then
158 cat $tmp.arglist > $tmp.list
163 # Specified groups to include
164 for group in $GROUP_LIST; do
165 list=$(get_group_list $group)
166 if [ -z "$list" ]; then
167 echo "Group \"$group\" is empty or not defined?"
172 grep -s "^$t\$" $tmp.list >/dev/null || \
173 echo "$t" >>$tmp.list
177 if ! $have_test_arg && [ -z "$GROUP_LIST" ]; then
178 # no test numbers, do everything
182 # Specified groups to exclude
183 for xgroup in $XGROUP_LIST; do
184 list=$(get_group_list $xgroup)
185 if [ -z "$list" ]; then
186 echo "Group \"$xgroup\" is empty or not defined?"
193 # sort the list of tests into numeric order
194 list=`sort -n $tmp.list | uniq`
195 rm -f $tmp.list $tmp.tmp $tmp.grep
199 list=`echo $list | awk -f randomize.awk`
203 # Process command arguments first.
204 while [ $# -gt 0 ]; do
206 -\? | -h | --help) usage ;;
210 -tmpfs) FSTYP=tmpfs ;;
212 -g) group=$2 ; shift ;
213 GROUP_LIST="$GROUP_LIST $group"
216 -x) xgroup=$2 ; shift ;
217 XGROUP_LIST="$XGROUP_LIST $xgroup"
220 -X) xfile=$2; shift ;
221 for d in $SRC_GROUPS $FSTYP; do
222 [ -f $SRC_DIR/$d/$xfile ] || continue
223 for f in `cat $SRC_DIR/$d/$xfile`; do
224 echo $d/$f >> $tmp.xlist
228 -E) xfile=$2; shift ;
229 if [ -f $xfile ]; then
230 cat "$xfile" >> $tmp.xlist
233 -s) RUN_SECTION="$RUN_SECTION $2"; shift ;;
235 -udiff) diff="$diff -u" ;;
238 -r) randomize=true ;;
240 -T) timestamp=true ;;
242 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
243 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
246 *) # not an argument, we've got tests now.
247 have_test_arg=true ;;
250 # if we've found a test specification, the break out of the processing
251 # loop before we shift the arguments so that this is the first argument
252 # that we process in the test arg loop below.
253 if $have_test_arg; then
260 # Process tests from command line now.
261 if $have_test_arg; then
262 while [ $# -gt 0 ]; do
264 -*) echo "Argments before tests, please!"
268 *) test_dir=`dirname $1`
269 test_dir=${test_dir#$SRC_DIR/*}
270 test_name=`basename $1`
271 group_file=$SRC_DIR/$test_dir/group
273 if egrep "^$test_name" $group_file >/dev/null ; then
274 # in group file ... OK
275 echo $SRC_DIR/$test_dir/$test_name >>$tmp.arglist
278 echo "$1 - unknown test, ignored"
290 echo "check: failed to source common/rc"
296 echo "check: QA must be run as root"
310 check="$RESULT_BASE/check"
317 if [ -f $check.time -a -f $tmp.time ]
319 cat $check.time $tmp.time \
323 for (i in t) print i " " t[i]
327 mv $tmp.out $check.time
332 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>$check.log
333 $interrupt && echo "Interrupted!" >>$check.log
335 echo "SECTION -- $section" >>$tmp.summary
336 echo "=========================" >>$tmp.summary
337 if [ ! -z "$n_try" -a $n_try != 0 ]
340 echo "Ran:$try" >>$tmp.summary
343 if [ ! -z "$notrun" ]
345 echo "Not run:$notrun"
346 echo "Not run:$notrun" >>$check.log
347 echo "Not run:$notrun" >>$tmp.summary
350 if [ ! -z "$n_bad" -a $n_bad != 0 ]
353 echo "Failed $n_bad of $n_try tests"
354 echo "Failures:$bad" | fmt >>$check.log
355 echo "Failed $n_bad of $n_try tests" >>$check.log
356 echo "Failures:$bad" >>$tmp.summary
357 echo "Failed $n_bad of $n_try tests" >>$tmp.summary
359 echo "Passed all $n_try tests"
360 echo "Passed all $n_try tests" >>$check.log
361 echo "Passed all $n_try tests" >>$tmp.summary
363 echo "" >>$tmp.summary
367 sum_bad=`expr $sum_bad + $n_bad`
369 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
370 if ! $OPTIONS_HAVE_SECTIONS; then
381 count=`wc -L $tmp.summary | cut -f1 -d" "`
390 if $OPTIONS_HAVE_SECTIONS; then
391 trap "_summary; exit \$status" 0 1 2 3 15
393 trap "_wrapup; exit \$status" 0 1 2 3 15
396 for section in $HOST_OPTIONS_SECTIONS; do
398 OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
399 get_next_config $section
401 # Do we need to run only some sections ?
402 if [ ! -z "$RUN_SECTION" ]; then
404 for s in $RUN_SECTION; do
405 if [ $section == $s ]; then
414 mkdir -p $RESULT_BASE
415 if [ ! -d $RESULT_BASE ]; then
416 echo "failed to create results directory $RESULT_BASE"
420 if $OPTIONS_HAVE_SECTIONS; then
421 echo "SECTION -- $section"
424 if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
425 echo "RECREATING -- $FSTYP on $TEST_DEV"
426 umount $TEST_DEV 2> /dev/null
427 if ! _test_mkfs >$tmp.err 2>&1
429 echo "our local _test_mkfs routine ..."
431 echo "check: failed to mkfs \$TEST_DEV using specified options"
434 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
435 if [ $? -ne 1 ]; then
440 elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
441 umount $TEST_DEV 2> /dev/null
442 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
443 if [ $? -ne 1 ]; then
452 check="$RESULT_BASE/check"
454 # don't leave old full output behind on a clean run
457 [ -f $check.time ] || touch $check.time
459 # print out our test configuration
460 echo "FSTYP -- `_full_fstyp_details`"
461 echo "PLATFORM -- `_full_platform_details`"
462 if [ ! -z "$SCRATCH_DEV" ]; then
463 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
464 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
469 if [ ! -z "$SCRATCH_DEV" ]; then
470 umount $SCRATCH_DEV 2>/dev/null
471 # call the overridden mkfs - make sure the FS is built
472 # the same as we'll create it later.
474 if ! _scratch_mkfs $flag >$tmp.err 2>&1
476 echo "our local _scratch_mkfs routine ..."
478 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
482 # call the overridden mount - make sure the FS mounts with
483 # the same options that we'll mount with later.
484 if ! _scratch_mount >$tmp.err 2>&1
486 echo "our local mount routine ..."
488 echo "check: failed to mount \$SCRATCH_DEV using specified options"
500 # the filename for the test and the name output are different.
501 # we don't include the tests/ directory in the name output.
502 seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
504 # Similarly, the result directory needs to replace the tests/
505 # part of the test location.
507 if $OPTIONS_HAVE_SECTIONS; then
508 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;${RESULT_BASE}/$section;"`
509 seqres="$RESULT_BASE/$section/$seqnum"
511 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
512 seqres="$RESULT_BASE/$seqnum"
525 echo " - no such test?"
527 # really going to try and run this one
529 rm -f $seqres.out.bad
531 # check if we really should run it
532 if [ -s $tmp.xlist ]; then
533 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
539 # slashes now in names, sed barfs on them so use grep
540 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
541 if [ "X$lasttime" != X ]; then
542 echo -n " ${lasttime}s ..."
544 echo -n " " # prettier output with timestamps.
546 rm -f core $seqres.notrun
549 $timestamp && echo -n " ["`date "+%T"`"]"
550 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
551 $LOGGER_PROG "run xfstest $seqnum"
552 ./$seq >$tmp.rawout 2>&1
554 $timestamp && _timestamp
557 _fix_malloc <$tmp.rawout >$tmp.out
562 echo -n " [dumped core]"
563 mv core $RESULT_BASE/$seqnum.core
567 if [ -f $seqres.notrun ]
569 $timestamp || echo -n " [not run] "
570 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
572 notrun="$notrun $seqnum"
576 echo -n " [failed, exit status $sts]"
581 echo " - no qualified output"
585 # coreutils 8.16+ changed quote formats in error messages from
586 # `foo' to 'foo'. Filter old versions to match the new version.
587 sed -i "s/\`/\'/g" $tmp.out
588 if diff $seq.out $tmp.out >/dev/null 2>&1
594 echo "$seqnum `expr $stop - $start`" >>$tmp.time
595 echo -n " `expr $stop - $start`s"
599 echo " - output mismatch (see $seqres.out.bad)"
600 mv $tmp.out $seqres.out.bad
601 $diff $seq.out $seqres.out.bad | {
602 if test "$DIFF_LENGTH" -le 0; then
605 head -n "$DIFF_LENGTH"
607 echo "(Run '$diff $seq.out $seqres.out.bad'" \
608 " to see the entire diff)"
610 sed -e 's/^\(.\)/ \1/'
618 # come here for each test, except when $showme is true
623 n_bad=`expr $n_bad + 1`
626 if [ ! -f $seqres.notrun ]
629 n_try=`expr $n_try + 1`
630 test -f ${RESULT_DIR}/require_test && _check_test_fs
631 rm -f ${RESULT_DIR}/require_test
632 test -f ${RESULT_DIR}/require_scratch && _check_scratch_fs
633 rm -f ${RESULT_DIR}/require_scratch
641 umount $TEST_DEV 2> /dev/null
642 umount $SCRATCH_DEV 2> /dev/null
646 status=`expr $sum_bad`