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 SRC_GROUPS="generic shared"
62 export SRC_DIR="tests"
66 echo "Usage: $0 [options] [testlist]"'
73 -udiff show unified diff (default)
74 -n show me, do not run tests
76 -r randomize test order
77 --large-fs optimise scratch device for large filesystems
78 -s section run only specified section from 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 l=$(sed -n < $SRC_DIR/$d/group \
98 -e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
104 # Find all tests, excluding files that are test metadata such as group files.
105 # It matches test names against $VALID_TEST_NAME defined in common/rc
109 for d in $SRC_GROUPS $FSTYP; do
112 grep "^$SRC_DIR/$d/$VALID_TEST_NAME"| \
113 grep -v "group\|Makefile" >> $tmp.list 2>/dev/null
117 # takes the list of tests to run in $tmp.list, and removes the tests passed to
118 # the function from that list.
127 if [ $numsed -gt 100 ]; then
128 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
129 mv $tmp.tmp $tmp.list
133 echo "^$t\$" >>$tmp.grep
134 numsed=`expr $numsed + 1`
136 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
137 mv $tmp.tmp $tmp.list
155 # Tests specified on the command line
156 if [ -s $tmp.arglist ]; then
157 cat $tmp.arglist > $tmp.list
162 # Specified groups to include
163 for group in $GROUP_LIST; do
164 list=$(get_group_list $group)
165 if [ -z "$list" ]; then
166 echo "Group \"$group\" is empty or not defined?"
171 grep -s "^$t\$" $tmp.list >/dev/null || \
172 echo "$t" >>$tmp.list
176 if ! $have_test_arg && [ -z "$GROUP_LIST" ]; then
177 # no test numbers, do everything
181 # Specified groups to exclude
182 for xgroup in $XGROUP_LIST; do
183 list=$(get_group_list $xgroup)
184 if [ -z "$list" ]; then
185 echo "Group \"$xgroup\" is empty or not defined?"
192 # sort the list of tests into numeric order
193 list=`sort -n $tmp.list | uniq`
194 rm -f $tmp.list $tmp.tmp $tmp.grep
198 list=`echo $list | awk -f randomize.awk`
202 # Process command arguments first.
203 while [ $# -gt 0 ]; do
205 -\? | -h | --help) usage ;;
209 -tmpfs) FSTYP=tmpfs ;;
211 -g) group=$2 ; shift ;
212 GROUP_LIST="$GROUP_LIST $group"
215 -x) xgroup=$2 ; shift ;
216 XGROUP_LIST="$XGROUP_LIST $xgroup"
219 -X) xfile=$2; shift ;
220 for d in $SRC_GROUPS $FSTYP; do
221 [ -f $SRC_DIR/$d/$xfile ] || continue
222 for f in `cat $SRC_DIR/$d/$xfile`; do
223 echo $d/$f >> $tmp.xlist
227 -E) xfile=$2; shift ;
228 if [ -f $xfile ]; then
229 cat "$xfile" >> $tmp.xlist
232 -s) RUN_SECTION="$RUN_SECTION $2"; shift ;;
234 -udiff) diff="$diff -u" ;;
237 -r) randomize=true ;;
239 -T) timestamp=true ;;
241 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
242 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
245 *) # not an argument, we've got tests now.
246 have_test_arg=true ;;
249 # if we've found a test specification, the break out of the processing
250 # loop before we shift the arguments so that this is the first argument
251 # that we process in the test arg loop below.
252 if $have_test_arg; then
259 # Process tests from command line now.
260 if $have_test_arg; then
261 while [ $# -gt 0 ]; do
263 -*) echo "Argments before tests, please!"
267 *) test_dir=`dirname $1`
268 test_dir=${test_dir#$SRC_DIR/*}
269 test_name=`basename $1`
270 group_file=$SRC_DIR/$test_dir/group
272 if egrep "^$test_name" $group_file >/dev/null ; then
273 # in group file ... OK
274 echo $SRC_DIR/$test_dir/$test_name >>$tmp.arglist
277 echo "$1 - unknown test, ignored"
289 echo "check: failed to source common/rc"
295 echo "check: QA must be run as root"
309 check="$RESULT_BASE/check"
316 if [ -f $check.time -a -f $tmp.time ]
318 cat $check.time $tmp.time \
322 for (i in t) print i " " t[i]
326 mv $tmp.out $check.time
331 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>$check.log
332 $interrupt && echo "Interrupted!" >>$check.log
334 echo "SECTION -- $section" >>$tmp.summary
335 echo "=========================" >>$tmp.summary
336 if [ ! -z "$n_try" -a $n_try != 0 ]
339 echo "Ran:$try" >>$tmp.summary
342 if [ ! -z "$notrun" ]
344 echo "Not run:$notrun"
345 echo "Not run:$notrun" >>$check.log
346 echo "Not run:$notrun" >>$tmp.summary
349 if [ ! -z "$n_bad" -a $n_bad != 0 ]
352 echo "Failed $n_bad of $n_try tests"
353 echo "Failures:$bad" | fmt >>$check.log
354 echo "Failed $n_bad of $n_try tests" >>$check.log
355 echo "Failures:$bad" >>$tmp.summary
356 echo "Failed $n_bad of $n_try tests" >>$tmp.summary
358 echo "Passed all $n_try tests"
359 echo "Passed all $n_try tests" >>$check.log
360 echo "Passed all $n_try tests" >>$tmp.summary
362 echo "" >>$tmp.summary
366 sum_bad=`expr $sum_bad + $n_bad`
368 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
369 if ! $OPTIONS_HAVE_SECTIONS; then
380 count=`wc -L $tmp.summary | cut -f1 -d" "`
389 if [ -f ${RESULT_DIR}/require_test ]; then
390 _check_test_fs || err=true
391 rm -f ${RESULT_DIR}/require_test
393 if [ -f ${RESULT_DIR}/require_scratch ]; then
394 _check_scratch_fs || err=true
395 rm -f ${RESULT_DIR}/require_scratch
401 if [ ! -f ${RESULT_DIR}/check_dmesg ]; then
404 rm -f ${RESULT_DIR}/check_dmesg
406 # search the dmesg log of last run of $seqnum for possible failures
407 # use sed \cregexpc address type, since $seqnum contains "/"
408 dmesg | tac | sed -ne "0,\#run fstests $seqnum at $date_time#p" | \
410 grep -q -e "kernel BUG at" \
414 -e "possible recursive locking detected" \
416 if [ $? -eq 0 ]; then
417 echo "_check_dmesg: something found in dmesg (see $seqres.dmesg)"
427 if $OPTIONS_HAVE_SECTIONS; then
428 trap "_summary; exit \$status" 0 1 2 3 15
430 trap "_wrapup; exit \$status" 0 1 2 3 15
433 for section in $HOST_OPTIONS_SECTIONS; do
435 OLD_MOUNT_OPTIONS=$MOUNT_OPTIONS
436 get_next_config $section
438 # Do we need to run only some sections ?
439 if [ ! -z "$RUN_SECTION" ]; then
441 for s in $RUN_SECTION; do
442 if [ $section == $s ]; then
451 mkdir -p $RESULT_BASE
452 if [ ! -d $RESULT_BASE ]; then
453 echo "failed to create results directory $RESULT_BASE"
457 if $OPTIONS_HAVE_SECTIONS; then
458 echo "SECTION -- $section"
461 if $RECREATE_TEST_DEV || [ "$OLD_FSTYP" != "$FSTYP" ]; then
462 echo "RECREATING -- $FSTYP on $TEST_DEV"
463 umount $TEST_DEV 2> /dev/null
464 if ! _test_mkfs >$tmp.err 2>&1
466 echo "our local _test_mkfs routine ..."
468 echo "check: failed to mkfs \$TEST_DEV using specified options"
471 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
472 if [ $? -ne 1 ]; then
477 elif [ "$OLD_MOUNT_OPTIONS" != "$MOUNT_OPTIONS" ]; then
478 umount $TEST_DEV 2> /dev/null
479 out=`_mount_or_remount_rw "$MOUNT_OPTIONS" $TEST_DEV $TEST_DIR`
480 if [ $? -ne 1 ]; then
489 check="$RESULT_BASE/check"
491 # don't leave old full output behind on a clean run
494 [ -f $check.time ] || touch $check.time
496 # print out our test configuration
497 echo "FSTYP -- `_full_fstyp_details`"
498 echo "PLATFORM -- `_full_platform_details`"
499 if [ ! -z "$SCRATCH_DEV" ]; then
500 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
501 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
506 if [ ! -z "$SCRATCH_DEV" ]; then
507 umount $SCRATCH_DEV 2>/dev/null
508 # call the overridden mkfs - make sure the FS is built
509 # the same as we'll create it later.
511 if ! _scratch_mkfs $flag >$tmp.err 2>&1
513 echo "our local _scratch_mkfs routine ..."
515 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
519 # call the overridden mount - make sure the FS mounts with
520 # the same options that we'll mount with later.
521 if ! _scratch_mount >$tmp.err 2>&1
523 echo "our local mount routine ..."
525 echo "check: failed to mount \$SCRATCH_DEV using specified options"
537 # the filename for the test and the name output are different.
538 # we don't include the tests/ directory in the name output.
539 seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
541 # Similarly, the result directory needs to replace the tests/
542 # part of the test location.
544 if $OPTIONS_HAVE_SECTIONS; then
545 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;${RESULT_BASE}/$section;"`
546 seqres="$RESULT_BASE/$section/$seqnum"
548 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
549 seqres="$RESULT_BASE/$seqnum"
562 echo " - no such test?"
564 # really going to try and run this one
566 rm -f $seqres.out.bad
568 # check if we really should run it
569 if [ -s $tmp.xlist ]; then
570 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
576 # slashes now in names, sed barfs on them so use grep
577 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
578 if [ "X$lasttime" != X ]; then
579 echo -n " ${lasttime}s ..."
581 echo -n " " # prettier output with timestamps.
583 rm -f core $seqres.notrun
586 $timestamp && echo -n " ["`date "+%T"`"]"
587 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
588 $LOGGER_PROG "run xfstest $seqnum"
589 if [ -w /dev/kmsg ]; then
590 date_time=`date +"%F %T"`
591 echo "run fstests $seqnum at $date_time" > /dev/kmsg
592 # _check_dmesg depends on this log in dmesg
593 touch ${RESULT_DIR}/check_dmesg
595 ./$seq >$tmp.rawout 2>&1
597 $timestamp && _timestamp
600 _fix_malloc <$tmp.rawout >$tmp.out
605 echo -n " [dumped core]"
606 mv core $RESULT_BASE/$seqnum.core
610 if [ -f $seqres.notrun ]
612 $timestamp || echo -n " [not run] "
613 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
615 notrun="$notrun $seqnum"
619 echo -n " [failed, exit status $sts]"
624 echo " - no qualified output"
628 # coreutils 8.16+ changed quote formats in error messages from
629 # `foo' to 'foo'. Filter old versions to match the new version.
630 sed -i "s/\`/\'/g" $tmp.out
631 if diff $seq.out $tmp.out >/dev/null 2>&1
637 echo "$seqnum `expr $stop - $start`" >>$tmp.time
638 echo -n " `expr $stop - $start`s"
642 echo " - output mismatch (see $seqres.out.bad)"
643 mv $tmp.out $seqres.out.bad
644 $diff $seq.out $seqres.out.bad | {
645 if test "$DIFF_LENGTH" -le 0; then
648 head -n "$DIFF_LENGTH"
650 echo "(Run '$diff $seq.out $seqres.out.bad'" \
651 " to see the entire diff)"
653 sed -e 's/^\(.\)/ \1/'
658 n_try=`expr $n_try + 1`
665 # come here for each test, except when $showme is true
670 n_bad=`expr $n_bad + 1`
679 umount $TEST_DEV 2> /dev/null
680 umount $SCRATCH_DEV 2> /dev/null
684 status=`expr $sum_bad`