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 SUPPORTED_TESTS="[0-9][0-9][0-9] [0-9][0-9][0-9][0-9]"
41 # generic initialization
44 export QA_CHECK_FS=${QA_CHECK_FS:=true}
46 # by default don't output timestamps
47 timestamp=${TIMESTAMP:=false}
49 # number of diff lines from a failed test, 0 for whole output
50 export DIFF_LENGTH=${DIFF_LENGTH:=10}
52 # by default don't output timestamps
53 timestamp=${TIMESTAMP:=false}
57 echo "Usage: $0 [options] [testlist]"'
60 -xfs test XFS (default)
64 -udiff show unified diff (default)
65 -n show me, do not run tests
67 -r randomize test order
68 --large-fs optimise scratch device for large filesystems
71 -g group[,group...] include tests from these groups
72 -x group[,group...] exclude tests from these groups
74 NNN-NNN include test range (eg. 012-021)
89 grpl=$(sed -n < group \
92 -e "/^[0-9][0-9][0-9].* $grp /"'{ s/ .*//p }')
98 # strip leading zeros, could be considered octal.
99 start=`echo $1 | sed 's/^0*//'`
100 end=`echo $2 | sed 's/^0*//'`
102 $AWK_PROG </dev/null '
103 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
106 if grep -s "^$id " group >/dev/null ; then
107 # in group file ... OK
109 elif [ -f expunged ] && $expunge && \
110 egrep "^$id([ ]|\$)" expunged >/dev/null ; then
111 # expunged ... will be reported, but not run, later
115 echo "$id - unknown test, ignored"
122 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
131 # start the initialisation work now
134 rm -f $tmp.list $tmp.tmp $tmp.sed $here/$iam.out
136 # Autodetect fs type based on what's on $TEST_DEV
137 if [ "$HOSTOS" == "Linux" ]; then
138 FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
142 # we need common.config
143 if ! . ./common.config
145 echo "$iam: failed to source common.config"
149 while [ $# -gt 0 ]; do
151 -\? | -h | --help) usage ;;
157 -g) group=$2 ; shift ;
158 group_list=$(get_group_list $group)
159 if [ -z "$group_list" ]; then
160 echo "Group \"$group\" is empty or not defined?"
164 [ ! -s $tmp.list ] && touch $tmp.list
165 for t in $group_list; do
166 grep -s "^$t\$" $tmp.list >/dev/null || \
167 echo "$t" >>$tmp.list
172 -x) xgroup=$2 ; shift ;
173 [ ! -s $tmp.list ] && ls $SUPPORTED_TESTS >$tmp.list 2>/dev/null
174 group_list=$(get_group_list $xgroup)
175 if [ -z "$group_list" ]; then
176 echo "Group \"$xgroup\" is empty or not defined?"
184 if [ $numsed -gt 100 ]; then
185 sed -f $tmp.sed <$tmp.list >$tmp.tmp
186 mv $tmp.tmp $tmp.list
190 echo "/^$t\$/d" >>$tmp.sed
191 numsed=`expr $numsed + 1`
193 sed -f $tmp.sed <$tmp.list >$tmp.tmp
194 mv $tmp.tmp $tmp.list
198 -udiff) diff="$diff -u" ;;
201 -r) randomize=true ;;
203 -T) timestamp=true ;;
212 eval `echo $1 | sed -e 's/^/start=/' -e 's/-/ end=/'`
213 expand_test_numbers $start $end
218 eval `echo $1 | sed -e 's/^/start=/' -e 's/-//'`
219 end=`echo $SUPPORTED_TESTS | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'`
220 if [ -z "$end" ]; then
221 echo "No tests in range \"$1\"?"
225 expand_test_numbers $start $end
229 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
230 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
233 *) expand_test_numbers $1 $1 ;
241 if [ -s $tmp.list ]; then
242 # found some valid test numbers ... this is good
244 elif $have_test_arg; then
245 # had test numbers, but none in group file ... do nothing
248 # no test numbers, do everything from group file
249 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
252 # sort the list of tests into numeric order
253 list=`sort -n $tmp.list`
254 rm -f $tmp.list $tmp.tmp $tmp.sed
258 list=`echo $list | awk -f randomize.awk`
264 echo "check: failed to source common.rc"
270 echo "check: QA must be run as root"
274 # Ok, time to start running...
279 # remove files that were used by hangcheck
281 [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
282 [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
289 if [ -f check.time -a -f $tmp.time ]
291 cat check.time $tmp.time \
295 for (i in t) print i " " t[i]
299 mv $tmp.out check.time
302 if [ -f $tmp.expunged ]
304 notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'`
305 n_try=`expr $n_try - $notrun`
306 list=`echo "$list" | sed -f $tmp.expunged`
311 echo $list | fmt | sed -e 's/^/ /' >>check.log
312 $interrupt && echo "Interrupted!" >>check.log
314 if [ ! -z "$n_try" -a $n_try != 0 ]
319 if [ ! -z "$notrun" ]
321 echo "Not run:$notrun"
322 echo "Not run:$notrun" >>check.log
325 if [ ! -z "$n_bad" -a $n_bad != 0 ]
328 echo "Failed $n_bad of $n_try tests"
329 echo "Failures:$bad" | fmt >>check.log
330 echo "Failed $n_bad of $n_try tests" >>check.log
332 echo "Passed all $n_try tests"
333 echo "Passed all $n_try tests" >>check.log
338 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
339 rm -f /tmp/check.pid /tmp/check.sts
343 trap "_wrapup; exit \$status" 0 1 2 3 15
346 # Save pid of check in a well known place, so that hangcheck can be sure it
347 # has the right pid (getting the pid from ps output is not reliable enough).
349 rm -rf /tmp/check.pid
350 echo $$ >/tmp/check.pid
353 # Save the status of check in a well known place, so that hangcheck can be
354 # sure to know where check is up to (getting test number from ps output is
355 # not reliable enough since the trace stuff has been introduced).
357 rm -rf /tmp/check.sts
358 echo "preamble" >/tmp/check.sts
360 # don't leave old full output behind on a clean run
363 [ -f check.time ] || touch check.time
365 # print out our test configuration
366 echo "FSTYP -- `_full_fstyp_details`"
367 echo "PLATFORM -- `_full_platform_details`"
368 if [ ! -z "$SCRATCH_DEV" ]; then
369 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
370 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
375 if [ ! -z "$SCRATCH_DEV" ]; then
376 umount $SCRATCH_DEV 2>/dev/null
377 # call the overridden mkfs - make sure the FS is built
378 # the same as we'll create it later.
380 if ! _scratch_mkfs $flag >$tmp.err 2>&1
382 echo "our local _scratch_mkfs routine ..."
384 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
388 # call the overridden mount - make sure the FS mounts with
389 # the same options that we'll mount with later.
390 if ! _scratch_mount >$tmp.err 2>&1
392 echo "our local mount routine ..."
394 echo "check: failed to mount \$SCRATCH_DEV using specified options"
402 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
408 if [ -n "$TESTS_REMAINING_LOG" ] ; then
409 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
410 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
418 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
422 echo "/^$seq\$/d" >>$tmp.expunged
425 echo " - no such test?"
426 echo "/^$seq\$/d" >>$tmp.expunged
428 # really going to try and run this one
431 lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
432 if [ "X$lasttime" != X ]; then
433 echo -n " ${lasttime}s ..."
435 echo -n " " # prettier output with timestamps.
437 rm -f core $seq.notrun
440 echo "$seq" >/tmp/check.sts
443 $timestamp && echo -n " ["`date "+%T"`"]"
444 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
445 $LOGGER_PROG "run xfstest $seq"
446 ./$seq >$tmp.rawout 2>&1
448 $timestamp && _timestamp
451 _fix_malloc <$tmp.rawout >$tmp.out
456 echo -n " [dumped core]"
461 if [ -f $seq.notrun ]
463 $timestamp || echo -n " [not run] "
464 $timestamp && echo " [not run]" && echo -n " $seq -- "
466 notrun="$notrun $seq"
470 echo -n " [failed, exit status $sts]"
475 echo " - no qualified output"
478 if diff $seq.out $tmp.out >/dev/null 2>&1
484 echo "$seq `expr $stop - $start`" >>$tmp.time
485 echo -n " `expr $stop - $start`s"
489 echo " - output mismatch (see $seq.out.bad)"
490 mv $tmp.out $seq.out.bad
491 $diff $seq.out $seq.out.bad | {
492 if test "$DIFF_LENGTH" -le 0; then
495 head -n "$DIFF_LENGTH"
497 sed -e 's/^\(.\)/ \1/'
499 echo " (Run '$diff $seq.out $seq.out.bad' to see the" \
508 # come here for each test, except when $showme is true
513 n_bad=`expr $n_bad + 1`
516 if [ ! -f $seq.notrun ]
519 n_try=`expr $n_try + 1`