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"
69 export RESULT_BASE=${RESULT_BASE:="$here/results"}
73 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 >> $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 }'
155 # Process command arguments first.
156 while [ $# -gt 0 ]; do
158 -\? | -h | --help) usage ;;
162 -g) group=$2 ; shift ;
163 group_list=$(get_group_list $group)
164 if [ -z "$group_list" ]; then
165 echo "Group \"$group\" is empty or not defined?"
169 [ ! -s $tmp.list ] && touch $tmp.list
170 for t in $group_list; do
171 grep -s "^$t\$" $tmp.list >/dev/null || \
172 echo "$t" >>$tmp.list
177 -x) xgroup=$2 ; shift ;
179 # Note: behaviour is dependent on command line ordering of
180 # -g and -x parameters. If there are no preceding -g commands,
181 # this works on all tests, otherwise just the tests specified by
182 # the early -g inclusions.
183 [ ! -s $tmp.list ] && get_all_tests
185 group_list=$(get_group_list $xgroup)
186 if [ -z "$group_list" ]; then
187 echo "Group \"$xgroup\" is empty or not defined?"
191 trim_test_list $group_list
194 -X) xfile=$2; shift ;
195 for d in $SRC_GROUPS $FSTYP; do
196 [ -f $SRC_DIR/$d/$xfile ] || continue
197 for f in `cat $SRC_DIR/$d/$xfile`; do
198 echo $d/$f >> $tmp.xlist
204 -udiff) diff="$diff -u" ;;
207 -r) randomize=true ;;
209 -T) timestamp=true ;;
211 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
212 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
215 *) # not an argument, we've got tests now.
216 have_test_arg=true ;;
219 # if we've found a test specification, the break out of the processing
220 # loop before we shift the arguments so that this is the first argument
221 # that we process in the test arg loop below.
222 if $have_test_arg; then
229 # Process tests from command line now.
230 if $have_test_arg; then
231 while [ $# -gt 0 ]; do
233 -*) echo "Argments before tests, please!"
237 *) test_dir=`dirname $1`
238 test_name=`basename $1`
239 group_file=$SRC_DIR/$test_dir/group
241 if egrep "^$test_name" $group_file >/dev/null ; then
242 # in group file ... OK
243 echo $SRC_DIR/$1 >>$tmp.list
246 echo "$1 - unknown test, ignored"
255 if [ -s $tmp.list ]; then
256 # found some valid test numbers ... this is good
258 elif $have_test_arg; then
259 # had test numbers, but none in group file ... do nothing
262 # no test numbers, do everything from group file
263 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
266 # sort the list of tests into numeric order
267 list=`sort -n $tmp.list`
268 rm -f $tmp.list $tmp.tmp $tmp.grep
272 list=`echo $list | awk -f randomize.awk`
278 echo "check: failed to source common/rc"
284 echo "check: QA must be run as root"
288 # Ok, time to start running...
293 check="$RESULT_BASE/check"
300 if [ -f $check.time -a -f $tmp.time ]
302 cat $check.time $tmp.time \
306 for (i in t) print i " " t[i]
310 mv $tmp.out $check.time
315 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>$check.log
316 $interrupt && echo "Interrupted!" >>$check.log
318 if [ ! -z "$n_try" -a $n_try != 0 ]
323 if [ ! -z "$notrun" ]
325 echo "Not run:$notrun"
326 echo "Not run:$notrun" >>$check.log
329 if [ ! -z "$n_bad" -a $n_bad != 0 ]
332 echo "Failed $n_bad of $n_try tests"
333 echo "Failures:$bad" | fmt >>$check.log
334 echo "Failed $n_bad of $n_try tests" >>$check.log
336 echo "Passed all $n_try tests"
337 echo "Passed all $n_try tests" >>$check.log
342 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
346 trap "_wrapup; exit \$status" 0 1 2 3 15
348 mkdir -p $RESULT_BASE
349 if [ ! -d $RESULT_BASE ]; then
350 echo "failed to create results directory $RESULTS_BASE"
355 check="$RESULT_BASE/check"
357 # don't leave old full output behind on a clean run
360 [ -f $check.time ] || touch $check.time
362 # print out our test configuration
363 echo "FSTYP -- `_full_fstyp_details`"
364 echo "PLATFORM -- `_full_platform_details`"
365 if [ ! -z "$SCRATCH_DEV" ]; then
366 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
367 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
372 if [ ! -z "$SCRATCH_DEV" ]; then
373 umount $SCRATCH_DEV 2>/dev/null
374 # call the overridden mkfs - make sure the FS is built
375 # the same as we'll create it later.
377 if ! _scratch_mkfs $flag >$tmp.err 2>&1
379 echo "our local _scratch_mkfs routine ..."
381 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
385 # call the overridden mount - make sure the FS mounts with
386 # the same options that we'll mount with later.
387 if ! _scratch_mount >$tmp.err 2>&1
389 echo "our local mount routine ..."
391 echo "check: failed to mount \$SCRATCH_DEV using specified options"
403 # the filename for the test and the name output are different.
404 # we don't include the tests/ directory in the name output.
405 seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
407 # Similarly, the result directory needs to replace the tests/
408 # part of the test location.
410 export RESULT_DIR=`echo $group | sed -e "s;$SRC_DIR;$RESULT_BASE;"`
412 seqres="$RESULT_BASE/$seqnum"
422 echo " - no such test?"
424 # really going to try and run this one
426 rm -f $seqres.out.bad
428 # check if we really should run it
429 if [ -s $tmp.xlist ]; then
430 if grep $seqnum $tmp.xlist > /dev/null 2>&1 ; then
436 # slashes now in names, sed barfs on them so use grep
437 lasttime=`grep -w ^$seqnum $check.time | awk '// {print $2}'`
438 if [ "X$lasttime" != X ]; then
439 echo -n " ${lasttime}s ..."
441 echo -n " " # prettier output with timestamps.
443 rm -f core $seqres.notrun
446 $timestamp && echo -n " ["`date "+%T"`"]"
447 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
448 $LOGGER_PROG "run xfstest $seqnum"
449 ./$seq >$tmp.rawout 2>&1
451 $timestamp && _timestamp
454 _fix_malloc <$tmp.rawout >$tmp.out
459 echo -n " [dumped core]"
460 mv core $RESULT_BASE/$seqnum.core
464 if [ -f $seqres.notrun ]
466 $timestamp || echo -n " [not run] "
467 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
469 notrun="$notrun $seqnum"
473 echo -n " [failed, exit status $sts]"
478 echo " - no qualified output"
481 if diff $seq.out $tmp.out >/dev/null 2>&1
487 echo "$seqnum `expr $stop - $start`" >>$tmp.time
488 echo -n " `expr $stop - $start`s"
492 echo " - output mismatch (see $seqres.out.bad)"
493 mv $tmp.out $seqres.out.bad
494 $diff $seq.out $seqres.out.bad | {
495 if test "$DIFF_LENGTH" -le 0; then
498 head -n "$DIFF_LENGTH"
500 sed -e 's/^\(.\)/ \1/'
502 echo " (Run '$diff $seq.out $seqres.out.bad' to see the" \
511 # come here for each test, except when $showme is true
516 n_bad=`expr $n_bad + 1`
519 if [ ! -f $seqres.notrun ]
522 n_try=`expr $n_try + 1`