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 # start the initialisation work now
42 export MSGVERB="text:action"
43 export QA_CHECK_FS=${QA_CHECK_FS:=true}
45 # number of diff lines from a failed test, 0 for whole output
46 export DIFF_LENGTH=${DIFF_LENGTH:=10}
48 # by default don't output timestamps
49 timestamp=${TIMESTAMP:=false}
51 rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.xlist
53 # we need common/config
54 if ! . ./common/config
56 echo "$iam: failed to source common/config"
60 # Autodetect fs type based on what's on $TEST_DEV
61 if [ "$HOSTOS" == "Linux" ]; then
62 FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
66 SUPPORTED_TESTS="[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]"
67 SRC_GROUPS="generic shared"
68 export SRC_DIR="tests"
72 echo "Usage: $0 [options] [testlist]"'
78 -udiff show unified diff (default)
79 -n show me, do not run tests
81 -r randomize test order
82 --large-fs optimise scratch device for large filesystems
85 -g group[,group...] include tests from these groups
86 -x group[,group...] exclude tests from these groups
87 -X file exclude individual tests
88 [testlist] include tests matching names in testlist
97 for d in $SRC_GROUPS $FSTYP; do
98 l=$(sed -n < $SRC_DIR/$d/group \
101 -e "s;\(^[0-9][0-9][0-9]\).* $grp .*;$SRC_DIR/$d/\1;p")
107 # find all tests, excluding files that are test metadata such as group files.
108 # This assumes that tests are defined purely by alphanumeric filenames with no
109 # ".xyz" extensions in the name.
113 for d in $SRC_GROUPS $FSTYP; do
116 grep -v "group\|Makefile" >> $tmp.list 2>/dev/null
120 # takes the list of tests to run in $tmp.list, and removes the tests passed to
121 # the function from that list.
130 if [ $numsed -gt 100 ]; then
131 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
132 mv $tmp.tmp $tmp.list
136 echo "^$t\$" >>$tmp.grep
137 numsed=`expr $numsed + 1`
139 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
140 mv $tmp.tmp $tmp.list
146 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
158 # Tests specified on the command line
159 if [ -s $tmp.arglist ]; then
160 cat $tmp.arglist > $tmp.list
165 # Specified groups to include
166 for group in $GROUP_LIST; do
167 list=$(get_group_list $group)
168 if [ -z "$list" ]; then
169 echo "Group \"$group\" is empty or not defined?"
174 grep -s "^$t\$" $tmp.list >/dev/null || \
175 echo "$t" >>$tmp.list
179 if ! $have_test_arg && [ -z "$GROUP_LIST" ]; then
180 # no test numbers, do everything
184 # Specified groups to exclude
185 for xgroup in $XGROUP_LIST; do
186 list=$(get_group_list $xgroup)
187 if [ -z "$list" ]; then
188 echo "Group \"$xgroup\" is empty or not defined?"
195 # sort the list of tests into numeric order
196 list=`sort -n $tmp.list | uniq`
197 rm -f $tmp.list $tmp.tmp $tmp.grep
201 list=`echo $list | awk -f randomize.awk`
205 # Process command arguments first.
206 while [ $# -gt 0 ]; do
208 -\? | -h | --help) usage ;;
211 -tmpfs) FSTYP=tmpfs ;;
213 -g) group=$2 ; shift ;
214 GROUP_LIST="$GROUP_LIST $group"
217 -x) xgroup=$2 ; shift ;
218 XGROUP_LIST="$XGROUP_LIST $xgroup"
221 -X) xfile=$2; shift ;
222 for d in $SRC_GROUPS $FSTYP; do
223 [ -f $SRC_DIR/$d/$xfile ] || continue
224 for f in `cat $SRC_DIR/$d/$xfile`; do
225 echo $d/$f >> $tmp.xlist
231 -udiff) diff="$diff -u" ;;
234 -r) randomize=true ;;
236 -T) timestamp=true ;;
238 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
239 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
242 *) # not an argument, we've got tests now.
243 have_test_arg=true ;;
246 # if we've found a test specification, the break out of the processing
247 # loop before we shift the arguments so that this is the first argument
248 # that we process in the test arg loop below.
249 if $have_test_arg; then
256 # Process tests from command line now.
257 if $have_test_arg; then
258 while [ $# -gt 0 ]; do
260 -*) echo "Argments before tests, please!"
264 *) test_dir=`dirname $1`
265 test_dir=${test_dir#$SRC_DIR/*}
266 test_name=`basename $1`
267 group_file=$SRC_DIR/$test_dir/group
269 if egrep "^$test_name" $group_file >/dev/null ; then
270 # in group file ... OK
271 echo $SRC_DIR/$test_dir/$test_name >>$tmp.arglist
274 echo "$1 - unknown test, ignored"
288 echo "check: failed to source common/rc"
294 echo "check: QA must be run as root"
298 # Ok, time to start running...
303 check="$RESULT_BASE/check"
310 if [ -f $check.time -a -f $tmp.time ]
312 cat $check.time $tmp.time \
316 for (i in t) print i " " t[i]
320 mv $tmp.out $check.time
325 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>$check.log
326 $interrupt && echo "Interrupted!" >>$check.log
328 if [ ! -z "$n_try" -a $n_try != 0 ]
333 if [ ! -z "$notrun" ]
335 echo "Not run:$notrun"
336 echo "Not run:$notrun" >>$check.log
339 if [ ! -z "$n_bad" -a $n_bad != 0 ]
342 echo "Failed $n_bad of $n_try tests"
343 echo "Failures:$bad" | fmt >>$check.log
344 echo "Failed $n_bad of $n_try tests" >>$check.log
346 echo "Passed all $n_try tests"
347 echo "Passed all $n_try tests" >>$check.log
352 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
356 trap "_wrapup; exit \$status" 0 1 2 3 15
358 mkdir -p $RESULT_BASE
359 if [ ! -d $RESULT_BASE ]; then
360 echo "failed to create results directory $RESULTS_BASE"
365 check="$RESULT_BASE/check"
367 # don't leave old full output behind on a clean run
370 [ -f $check.time ] || touch $check.time
372 # print out our test configuration
373 echo "FSTYP -- `_full_fstyp_details`"
374 echo "PLATFORM -- `_full_platform_details`"
375 if [ ! -z "$SCRATCH_DEV" ]; then
376 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
377 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
382 if [ ! -z "$SCRATCH_DEV" ]; then
383 umount $SCRATCH_DEV 2>/dev/null
384 # call the overridden mkfs - make sure the FS is built
385 # the same as we'll create it later.
387 if ! _scratch_mkfs $flag >$tmp.err 2>&1
389 echo "our local _scratch_mkfs routine ..."
391 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
395 # call the overridden mount - make sure the FS mounts with
396 # the same options that we'll mount with later.
397 if ! _scratch_mount >$tmp.err 2>&1
399 echo "our local mount routine ..."
401 echo "check: failed to mount \$SCRATCH_DEV using specified options"
413 # the filename for the test and the name output are different.
414 # we don't include the tests/ directory in the name output.
415 seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
417 # Similarly, the result directory needs to replace the tests/
418 # part of the test location.
420 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
422 seqres="$RESULT_BASE/$seqnum"
432 echo " - no such test?"
434 # really going to try and run this one
436 rm -f $seqres.out.bad
438 # check if we really should run it
439 if [ -s $tmp.xlist ]; then
440 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
446 # slashes now in names, sed barfs on them so use grep
447 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
448 if [ "X$lasttime" != X ]; then
449 echo -n " ${lasttime}s ..."
451 echo -n " " # prettier output with timestamps.
453 rm -f core $seqres.notrun
456 $timestamp && echo -n " ["`date "+%T"`"]"
457 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
458 $LOGGER_PROG "run xfstest $seqnum"
459 ./$seq >$tmp.rawout 2>&1
461 $timestamp && _timestamp
464 _fix_malloc <$tmp.rawout >$tmp.out
469 echo -n " [dumped core]"
470 mv core $RESULT_BASE/$seqnum.core
474 if [ -f $seqres.notrun ]
476 $timestamp || echo -n " [not run] "
477 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
479 notrun="$notrun $seqnum"
483 echo -n " [failed, exit status $sts]"
488 echo " - no qualified output"
492 # coreutils 8.16+ changed quote formats in error messages from
493 # `foo' to 'foo'. Filter old versions to match the new version.
494 sed -i "s/\`/\'/g" $tmp.out
495 if diff $seq.out $tmp.out >/dev/null 2>&1
501 echo "$seqnum `expr $stop - $start`" >>$tmp.time
502 echo -n " `expr $stop - $start`s"
506 echo " - output mismatch (see $seqres.out.bad)"
507 mv $tmp.out $seqres.out.bad
508 $diff $seq.out $seqres.out.bad | {
509 if test "$DIFF_LENGTH" -le 0; then
512 head -n "$DIFF_LENGTH"
514 sed -e 's/^\(.\)/ \1/'
516 echo " (Run '$diff $seq.out $seqres.out.bad' to see the" \
525 # come here for each test, except when $showme is true
530 n_bad=`expr $n_bad + 1`
533 if [ ! -f $seqres.notrun ]
536 n_try=`expr $n_try + 1`