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]"
39 TEST_GROUP_DIR="tests"
40 GENERIC_GROUP_DIR="$TEST_GROUP_DIR/generic"
41 XFS_GROUP_DIR="$TEST_GROUP_DIR/xfs"
43 # generic initialization
46 export QA_CHECK_FS=${QA_CHECK_FS:=true}
48 # by default don't output timestamps
49 timestamp=${TIMESTAMP:=false}
51 # number of diff lines from a failed test, 0 for whole output
52 export DIFF_LENGTH=${DIFF_LENGTH:=10}
54 # by default don't output timestamps
55 timestamp=${TIMESTAMP:=false}
59 echo "Usage: $0 [options] [testlist]"'
62 -xfs test XFS (default)
66 -udiff show unified diff (default)
67 -n show me, do not run tests
69 -r randomize test order
70 --large-fs optimise scratch device for large filesystems
73 -g group[,group...] include tests from these groups
74 -x group[,group...] exclude tests from these groups
76 NNN-NNN include test range (eg. 012-021)
90 dirs=". $GENERIC_GROUP_DIR $XFS_GROUP_DIR"
93 l=$(sed -n < $d/group \
96 -e "s;\(^[0-9][0-9][0-9]\).* $grp .*;$d/\1;p")
102 expand_test_numbers()
104 # strip leading zeros, could be considered octal.
105 start=`echo $1 | sed 's/^0*//'`
106 end=`echo $2 | sed 's/^0*//'`
108 $AWK_PROG </dev/null '
109 BEGIN { for (t='$start'; t<='$end'; t++) printf "%03d\n",t }' \
112 if grep -s "^$id " group >/dev/null ; then
113 # in group file ... OK
117 echo "$id - unknown test, ignored"
124 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
133 # start the initialisation work now
136 rm -f $tmp.list $tmp.tmp $tmp.sed $here/$iam.out
138 # Autodetect fs type based on what's on $TEST_DEV
139 if [ "$HOSTOS" == "Linux" ]; then
140 FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
144 # we need common.config
145 if ! . ./common.config
147 echo "$iam: failed to source common.config"
151 while [ $# -gt 0 ]; do
153 -\? | -h | --help) usage ;;
159 -g) group=$2 ; shift ;
160 group_list=$(get_group_list $group)
161 if [ -z "$group_list" ]; then
162 echo "Group \"$group\" is empty or not defined?"
166 [ ! -s $tmp.list ] && touch $tmp.list
167 for t in $group_list; do
168 grep -s "^$t\$" $tmp.list >/dev/null || \
169 echo "$t" >>$tmp.list
174 -x) xgroup=$2 ; shift ;
175 [ ! -s $tmp.list ] && ls $SUPPORTED_TESTS >$tmp.list 2>/dev/null
176 group_list=$(get_group_list $xgroup)
177 if [ -z "$group_list" ]; then
178 echo "Group \"$xgroup\" is empty or not defined?"
186 if [ $numsed -gt 100 ]; then
187 sed -f $tmp.sed <$tmp.list >$tmp.tmp
188 mv $tmp.tmp $tmp.list
192 echo "/^$t\$/d" >>$tmp.sed
193 numsed=`expr $numsed + 1`
195 sed -f $tmp.sed <$tmp.list >$tmp.tmp
196 mv $tmp.tmp $tmp.list
200 -udiff) diff="$diff -u" ;;
203 -r) randomize=true ;;
205 -T) timestamp=true ;;
214 eval `echo $1 | sed -e 's/^/start=/' -e 's/-/ end=/'`
215 expand_test_numbers $start $end
220 eval `echo $1 | sed -e 's/^/start=/' -e 's/-//'`
221 end=`echo $SUPPORTED_TESTS | sed -e 's/\[0-9]//g' -e 's/ *$//' -e 's/.* //'`
222 if [ -z "$end" ]; then
223 echo "No tests in range \"$1\"?"
227 expand_test_numbers $start $end
231 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
232 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
235 *) expand_test_numbers $1 $1 ;
243 if [ -s $tmp.list ]; then
244 # found some valid test numbers ... this is good
246 elif $have_test_arg; then
247 # had test numbers, but none in group file ... do nothing
250 # no test numbers, do everything from group file
251 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
254 # sort the list of tests into numeric order
255 list=`sort -n $tmp.list`
256 rm -f $tmp.list $tmp.tmp $tmp.sed
260 list=`echo $list | awk -f randomize.awk`
266 echo "check: failed to source common.rc"
272 echo "check: QA must be run as root"
276 # Ok, time to start running...
285 if [ -f check.time -a -f $tmp.time ]
287 cat check.time $tmp.time \
291 for (i in t) print i " " t[i]
295 mv $tmp.out check.time
300 echo $list | fmt | sed -e 's/^/ /' -e 's;tests/;;g' >>check.log
301 $interrupt && echo "Interrupted!" >>check.log
303 if [ ! -z "$n_try" -a $n_try != 0 ]
308 if [ ! -z "$notrun" ]
310 echo "Not run:$notrun"
311 echo "Not run:$notrun" >>check.log
314 if [ ! -z "$n_bad" -a $n_bad != 0 ]
317 echo "Failed $n_bad of $n_try tests"
318 echo "Failures:$bad" | fmt >>check.log
319 echo "Failed $n_bad of $n_try tests" >>check.log
321 echo "Passed all $n_try tests"
322 echo "Passed all $n_try tests" >>check.log
327 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
331 trap "_wrapup; exit \$status" 0 1 2 3 15
333 # don't leave old full output behind on a clean run
336 [ -f check.time ] || touch check.time
338 # print out our test configuration
339 echo "FSTYP -- `_full_fstyp_details`"
340 echo "PLATFORM -- `_full_platform_details`"
341 if [ ! -z "$SCRATCH_DEV" ]; then
342 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
343 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
348 if [ ! -z "$SCRATCH_DEV" ]; then
349 umount $SCRATCH_DEV 2>/dev/null
350 # call the overridden mkfs - make sure the FS is built
351 # the same as we'll create it later.
353 if ! _scratch_mkfs $flag >$tmp.err 2>&1
355 echo "our local _scratch_mkfs routine ..."
357 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
361 # call the overridden mount - make sure the FS mounts with
362 # the same options that we'll mount with later.
363 if ! _scratch_mount >$tmp.err 2>&1
365 echo "our local mount routine ..."
367 echo "check: failed to mount \$SCRATCH_DEV using specified options"
379 # the filename for the test and the name output are different.
380 # we don't include the tests/ directory in the name output.
381 seqnum=`echo $seq | sed -e 's;tests/;;'`
391 echo " - no such test?"
393 # really going to try and run this one
397 # slashes now in names, sed barfs on them so use grep
398 lasttime=`grep -w ^$seq check.time | awk '// {print $2}'`
399 if [ "X$lasttime" != X ]; then
400 echo -n " ${lasttime}s ..."
402 echo -n " " # prettier output with timestamps.
404 rm -f core $seq.notrun
407 $timestamp && echo -n " ["`date "+%T"`"]"
408 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
409 $LOGGER_PROG "run xfstest $seqnum"
410 ./$seq >$tmp.rawout 2>&1
412 $timestamp && _timestamp
415 _fix_malloc <$tmp.rawout >$tmp.out
420 echo -n " [dumped core]"
425 if [ -f $seq.notrun ]
427 $timestamp || echo -n " [not run] "
428 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
430 notrun="$notrun $seqnum"
434 echo -n " [failed, exit status $sts]"
439 echo " - no qualified output"
442 if diff $seq.out $tmp.out >/dev/null 2>&1
448 echo "$seqnum `expr $stop - $start`" >>$tmp.time
449 echo -n " `expr $stop - $start`s"
453 echo " - output mismatch (see $seq.out.bad)"
454 mv $tmp.out $seq.out.bad
455 $diff $seq.out $seq.out.bad | {
456 if test "$DIFF_LENGTH" -le 0; then
459 head -n "$DIFF_LENGTH"
461 sed -e 's/^\(.\)/ \1/'
463 echo " (Run '$diff $seq.out $seq.out.bad' to see the" \
472 # come here for each test, except when $showme is true
477 n_bad=`expr $n_bad + 1`
480 if [ ! -f $seq.notrun ]
483 n_try=`expr $n_try + 1`