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 # generic initialization
43 export QA_CHECK_FS=${QA_CHECK_FS:=true}
45 # by default don't output timestamps
46 timestamp=${TIMESTAMP:=false}
48 # number of diff lines from a failed test, 0 for whole output
49 export DIFF_LENGTH=${DIFF_LENGTH:=10}
51 # by default don't output timestamps
52 timestamp=${TIMESTAMP:=false}
56 echo "Usage: $0 [options] [testlist]"'
59 -xfs test XFS (default)
63 -udiff show unified diff (default)
64 -n show me, do not run tests
66 -r randomize test order
67 --large-fs optimise scratch device for large filesystems
70 -g group[,group...] include tests from these groups
71 -x group[,group...] exclude tests from these groups
73 NNN-NNN include test range (eg. 012-021)
88 grpl=$(sed -n < group \
91 -e "/^[0-9][0-9][0-9].* $grp /"'{ s/ .*//p }')
97 # strip leading zeros, could be considered octal.
98 start=`echo $1 | sed 's/^0*//'`
99 end=`echo $2 | sed 's/^0*//'`
101 $AWK_PROG </dev/null '
102 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
105 if grep -s "^$id " group >/dev/null ; then
106 # in group file ... OK
110 echo "$id - unknown test, ignored"
117 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
126 # start the initialisation work now
129 rm -f $tmp.list $tmp.tmp $tmp.sed $here/$iam.out
131 # Autodetect fs type based on what's on $TEST_DEV
132 if [ "$HOSTOS" == "Linux" ]; then
133 FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
137 # we need common.config
138 if ! . ./common.config
140 echo "$iam: failed to source common.config"
144 while [ $# -gt 0 ]; do
146 -\? | -h | --help) usage ;;
152 -g) group=$2 ; shift ;
153 group_list=$(get_group_list $group)
154 if [ -z "$group_list" ]; then
155 echo "Group \"$group\" is empty or not defined?"
159 [ ! -s $tmp.list ] && touch $tmp.list
160 for t in $group_list; do
161 grep -s "^$t\$" $tmp.list >/dev/null || \
162 echo "$t" >>$tmp.list
167 -x) xgroup=$2 ; shift ;
168 [ ! -s $tmp.list ] && ls $SUPPORTED_TESTS >$tmp.list 2>/dev/null
169 group_list=$(get_group_list $xgroup)
170 if [ -z "$group_list" ]; then
171 echo "Group \"$xgroup\" is empty or not defined?"
179 if [ $numsed -gt 100 ]; then
180 sed -f $tmp.sed <$tmp.list >$tmp.tmp
181 mv $tmp.tmp $tmp.list
185 echo "/^$t\$/d" >>$tmp.sed
186 numsed=`expr $numsed + 1`
188 sed -f $tmp.sed <$tmp.list >$tmp.tmp
189 mv $tmp.tmp $tmp.list
193 -udiff) diff="$diff -u" ;;
196 -r) randomize=true ;;
198 -T) timestamp=true ;;
207 eval `echo $1 | sed -e 's/^/start=/' -e 's/-/ end=/'`
208 expand_test_numbers $start $end
213 eval `echo $1 | sed -e 's/^/start=/' -e 's/-//'`
214 end=`echo $SUPPORTED_TESTS | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'`
215 if [ -z "$end" ]; then
216 echo "No tests in range \"$1\"?"
220 expand_test_numbers $start $end
224 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
225 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
228 *) expand_test_numbers $1 $1 ;
236 if [ -s $tmp.list ]; then
237 # found some valid test numbers ... this is good
239 elif $have_test_arg; then
240 # had test numbers, but none in group file ... do nothing
243 # no test numbers, do everything from group file
244 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
247 # sort the list of tests into numeric order
248 list=`sort -n $tmp.list`
249 rm -f $tmp.list $tmp.tmp $tmp.sed
253 list=`echo $list | awk -f randomize.awk`
259 echo "check: failed to source common.rc"
265 echo "check: QA must be run as root"
269 # Ok, time to start running...
278 if [ -f check.time -a -f $tmp.time ]
280 cat check.time $tmp.time \
284 for (i in t) print i " " t[i]
288 mv $tmp.out check.time
293 echo $list | fmt | sed -e 's/^/ /' >>check.log
294 $interrupt && echo "Interrupted!" >>check.log
296 if [ ! -z "$n_try" -a $n_try != 0 ]
301 if [ ! -z "$notrun" ]
303 echo "Not run:$notrun"
304 echo "Not run:$notrun" >>check.log
307 if [ ! -z "$n_bad" -a $n_bad != 0 ]
310 echo "Failed $n_bad of $n_try tests"
311 echo "Failures:$bad" | fmt >>check.log
312 echo "Failed $n_bad of $n_try tests" >>check.log
314 echo "Passed all $n_try tests"
315 echo "Passed all $n_try tests" >>check.log
320 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
324 trap "_wrapup; exit \$status" 0 1 2 3 15
326 # don't leave old full output behind on a clean run
329 [ -f check.time ] || touch check.time
331 # print out our test configuration
332 echo "FSTYP -- `_full_fstyp_details`"
333 echo "PLATFORM -- `_full_platform_details`"
334 if [ ! -z "$SCRATCH_DEV" ]; then
335 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
336 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
341 if [ ! -z "$SCRATCH_DEV" ]; then
342 umount $SCRATCH_DEV 2>/dev/null
343 # call the overridden mkfs - make sure the FS is built
344 # the same as we'll create it later.
346 if ! _scratch_mkfs $flag >$tmp.err 2>&1
348 echo "our local _scratch_mkfs routine ..."
350 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
354 # call the overridden mount - make sure the FS mounts with
355 # the same options that we'll mount with later.
356 if ! _scratch_mount >$tmp.err 2>&1
358 echo "our local mount routine ..."
360 echo "check: failed to mount \$SCRATCH_DEV using specified options"
368 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
374 if [ -n "$TESTS_REMAINING_LOG" ] ; then
375 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
376 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
386 echo " - no such test?"
388 # really going to try and run this one
391 lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
392 if [ "X$lasttime" != X ]; then
393 echo -n " ${lasttime}s ..."
395 echo -n " " # prettier output with timestamps.
397 rm -f core $seq.notrun
400 $timestamp && echo -n " ["`date "+%T"`"]"
401 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
402 $LOGGER_PROG "run xfstest $seq"
403 ./$seq >$tmp.rawout 2>&1
405 $timestamp && _timestamp
408 _fix_malloc <$tmp.rawout >$tmp.out
413 echo -n " [dumped core]"
418 if [ -f $seq.notrun ]
420 $timestamp || echo -n " [not run] "
421 $timestamp && echo " [not run]" && echo -n " $seq -- "
423 notrun="$notrun $seq"
427 echo -n " [failed, exit status $sts]"
432 echo " - no qualified output"
435 if diff $seq.out $tmp.out >/dev/null 2>&1
441 echo "$seq `expr $stop - $start`" >>$tmp.time
442 echo -n " `expr $stop - $start`s"
446 echo " - output mismatch (see $seq.out.bad)"
447 mv $tmp.out $seq.out.bad
448 $diff $seq.out $seq.out.bad | {
449 if test "$DIFF_LENGTH" -le 0; then
452 head -n "$DIFF_LENGTH"
454 sed -e 's/^\(.\)/ \1/'
456 echo " (Run '$diff $seq.out $seq.out.bad' to see the" \
465 # come here for each test, except when $showme is true
470 n_bad=`expr $n_bad + 1`
473 if [ ! -f $seq.notrun ]
476 n_try=`expr $n_try + 1`