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
38 SUPPORTED_TESTS="[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]"
40 SRC_GROUPS="generic shared"
42 # generic initialization
45 export QA_CHECK_FS=${QA_CHECK_FS:=true}
47 # by default don't output timestamps
48 timestamp=${TIMESTAMP:=false}
50 # number of diff lines from a failed test, 0 for whole output
51 export DIFF_LENGTH=${DIFF_LENGTH:=10}
53 # by default don't output timestamps
54 timestamp=${TIMESTAMP:=false}
58 echo "Usage: $0 [options] [testlist]"'
61 -xfs test XFS (default)
65 -udiff show unified diff (default)
66 -n show me, do not run tests
68 -r randomize test order
69 --large-fs optimise scratch device for large filesystems
72 -g group[,group...] include tests from these groups
73 -x group[,group...] exclude tests from these groups
74 [testlist] include tests matching names in testlist
89 for d in $SRC_GROUPS $FSTYP; do
90 l=$(sed -n < $SRC_DIR/$d/group \
93 -e "s;\(^[0-9][0-9][0-9]\).* $grp .*;$SRC_DIR/$d/\1;p")
99 # find all tests, excluding files that are test metadata such as group files.
100 # This assumes that tests are defined purely by alphanumeric filenames with no
101 # ".xyz" extensions in the name.
105 for d in $SRC_GROUPS $FSTYP; do
108 grep -v group >> $tmp.list 2>/dev/null
114 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
123 # start the initialisation work now
126 rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out
128 # Autodetect fs type based on what's on $TEST_DEV
129 if [ "$HOSTOS" == "Linux" ]; then
130 FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
134 # we need common.config
135 if ! . ./common.config
137 echo "$iam: failed to source common.config"
141 # Process command arguments first.
142 while [ $# -gt 0 ]; do
144 -\? | -h | --help) usage ;;
150 -g) group=$2 ; shift ;
151 group_list=$(get_group_list $group)
152 if [ -z "$group_list" ]; then
153 echo "Group \"$group\" is empty or not defined?"
157 [ ! -s $tmp.list ] && touch $tmp.list
158 for t in $group_list; do
159 grep -s "^$t\$" $tmp.list >/dev/null || \
160 echo "$t" >>$tmp.list
165 -x) xgroup=$2 ; shift ;
167 # Note: behaviour is dependent on command line ordering of
168 # -g and -x parameters. If there are no preceding -g commands,
169 # this works on all tests, otherwise just the tests specified by
170 # the early -g inclusions.
171 [ ! -s $tmp.list ] && get_all_tests
173 group_list=$(get_group_list $xgroup)
174 if [ -z "$group_list" ]; then
175 echo "Group \"$xgroup\" is empty or not defined?"
183 if [ $numsed -gt 100 ]; then
184 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
185 mv $tmp.tmp $tmp.list
189 echo "^$t\$" >>$tmp.grep
190 numsed=`expr $numsed + 1`
192 grep -v -f $tmp.grep <$tmp.list >$tmp.tmp
193 mv $tmp.tmp $tmp.list
197 -udiff) diff="$diff -u" ;;
200 -r) randomize=true ;;
202 -T) timestamp=true ;;
204 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
205 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
208 *) # not an argument, we've got tests now.
209 have_test_arg=true ;;
212 # if we've found a test specification, the break out of the processing
213 # loop before we shift the arguments so that this is the first argument
214 # that we process in the test arg loop below.
215 if $have_test_arg; then
222 # Process tests from command line now.
223 if $have_test_arg; then
224 while [ $# -gt 0 ]; do
226 -*) echo "Argments before tests, please!"
230 *) test_dir=`dirname $1`
231 test_name=`basename $1`
232 group_file=$SRC_DIR/$test_dir/group
234 if grep "^$testname" $group_file >/dev/null ; then
235 # in group file ... OK
236 echo $SRC_DIR/$1 >>$tmp.list
239 echo "$1 - unknown test, ignored"
248 if [ -s $tmp.list ]; then
249 # found some valid test numbers ... this is good
251 elif $have_test_arg; then
252 # had test numbers, but none in group file ... do nothing
255 # no test numbers, do everything from group file
256 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
259 # sort the list of tests into numeric order
260 list=`sort -n $tmp.list`
261 rm -f $tmp.list $tmp.tmp $tmp.grep
265 list=`echo $list | awk -f randomize.awk`
271 echo "check: failed to source common.rc"
277 echo "check: QA must be run as root"
281 # Ok, time to start running...
290 if [ -f check.time -a -f $tmp.time ]
292 cat check.time $tmp.time \
296 for (i in t) print i " " t[i]
300 mv $tmp.out check.time
305 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>check.log
306 $interrupt && echo "Interrupted!" >>check.log
308 if [ ! -z "$n_try" -a $n_try != 0 ]
313 if [ ! -z "$notrun" ]
315 echo "Not run:$notrun"
316 echo "Not run:$notrun" >>check.log
319 if [ ! -z "$n_bad" -a $n_bad != 0 ]
322 echo "Failed $n_bad of $n_try tests"
323 echo "Failures:$bad" | fmt >>check.log
324 echo "Failed $n_bad of $n_try tests" >>check.log
326 echo "Passed all $n_try tests"
327 echo "Passed all $n_try tests" >>check.log
332 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
336 trap "_wrapup; exit \$status" 0 1 2 3 15
338 # don't leave old full output behind on a clean run
341 [ -f check.time ] || touch check.time
343 # print out our test configuration
344 echo "FSTYP -- `_full_fstyp_details`"
345 echo "PLATFORM -- `_full_platform_details`"
346 if [ ! -z "$SCRATCH_DEV" ]; then
347 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
348 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
353 if [ ! -z "$SCRATCH_DEV" ]; then
354 umount $SCRATCH_DEV 2>/dev/null
355 # call the overridden mkfs - make sure the FS is built
356 # the same as we'll create it later.
358 if ! _scratch_mkfs $flag >$tmp.err 2>&1
360 echo "our local _scratch_mkfs routine ..."
362 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
366 # call the overridden mount - make sure the FS mounts with
367 # the same options that we'll mount with later.
368 if ! _scratch_mount >$tmp.err 2>&1
370 echo "our local mount routine ..."
372 echo "check: failed to mount \$SCRATCH_DEV using specified options"
384 # the filename for the test and the name output are different.
385 # we don't include the tests/ directory in the name output.
386 seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
396 echo " - no such test?"
398 # really going to try and run this one
402 # slashes now in names, sed barfs on them so use grep
403 lasttime=`grep -w ^$seq check.time | awk '// {print $2}'`
404 if [ "X$lasttime" != X ]; then
405 echo -n " ${lasttime}s ..."
407 echo -n " " # prettier output with timestamps.
409 rm -f core $seq.notrun
412 $timestamp && echo -n " ["`date "+%T"`"]"
413 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
414 $LOGGER_PROG "run xfstest $seqnum"
415 ./$seq >$tmp.rawout 2>&1
417 $timestamp && _timestamp
420 _fix_malloc <$tmp.rawout >$tmp.out
425 echo -n " [dumped core]"
430 if [ -f $seq.notrun ]
432 $timestamp || echo -n " [not run] "
433 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
435 notrun="$notrun $seqnum"
439 echo -n " [failed, exit status $sts]"
444 echo " - no qualified output"
447 if diff $seq.out $tmp.out >/dev/null 2>&1
453 echo "$seqnum `expr $stop - $start`" >>$tmp.time
454 echo -n " `expr $stop - $start`s"
458 echo " - output mismatch (see $seq.out.bad)"
459 mv $tmp.out $seq.out.bad
460 $diff $seq.out $seq.out.bad | {
461 if test "$DIFF_LENGTH" -le 0; then
464 head -n "$DIFF_LENGTH"
466 sed -e 's/^\(.\)/ \1/'
468 echo " (Run '$diff $seq.out $seq.out.bad' to see the" \
477 # come here for each test, except when $showme is true
482 n_bad=`expr $n_bad + 1`
485 if [ ! -f $seq.notrun ]
488 n_try=`expr $n_try + 1`