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")
101 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
110 # start the initialisation work now
113 rm -f $tmp.list $tmp.tmp $tmp.sed $here/$iam.out
115 # Autodetect fs type based on what's on $TEST_DEV
116 if [ "$HOSTOS" == "Linux" ]; then
117 FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
121 # we need common.config
122 if ! . ./common.config
124 echo "$iam: failed to source common.config"
128 # Process command arguments first.
129 while [ $# -gt 0 ]; do
131 -\? | -h | --help) usage ;;
137 -g) group=$2 ; shift ;
138 group_list=$(get_group_list $group)
139 if [ -z "$group_list" ]; then
140 echo "Group \"$group\" is empty or not defined?"
144 [ ! -s $tmp.list ] && touch $tmp.list
145 for t in $group_list; do
146 grep -s "^$t\$" $tmp.list >/dev/null || \
147 echo "$t" >>$tmp.list
152 -x) xgroup=$2 ; shift ;
153 [ ! -s $tmp.list ] && ls $SUPPORTED_TESTS >$tmp.list 2>/dev/null
154 group_list=$(get_group_list $xgroup)
155 if [ -z "$group_list" ]; then
156 echo "Group \"$xgroup\" is empty or not defined?"
164 if [ $numsed -gt 100 ]; then
165 sed -f $tmp.sed <$tmp.list >$tmp.tmp
166 mv $tmp.tmp $tmp.list
170 echo "/^$t\$/d" >>$tmp.sed
171 numsed=`expr $numsed + 1`
173 sed -f $tmp.sed <$tmp.list >$tmp.tmp
174 mv $tmp.tmp $tmp.list
178 -udiff) diff="$diff -u" ;;
181 -r) randomize=true ;;
183 -T) timestamp=true ;;
185 --large-fs) export LARGE_SCRATCH_DEV=yes ;;
186 --extra-space=*) export SCRATCH_DEV_EMPTY_SPACE=${r#*=} ;;
189 *) # not an argument, we've got tests now.
190 have_test_arg=true ;;
193 # if we've found a test specification, the break out of the processing
194 # loop before we shift the arguments so that this is the first argument
195 # that we process in the test arg loop below.
196 if $have_test_arg; then
203 # Process tests from command line now.
204 if $have_test_arg; then
205 while [ $# -gt 0 ]; do
207 -*) echo "Argments before tests, please!"
211 *) test_dir=`dirname $1`
212 test_name=`basename $1`
213 group_file=$SRC_DIR/$test_dir/group
215 if grep "^$testname" $group_file >/dev/null ; then
216 # in group file ... OK
217 echo $SRC_DIR/$1 >>$tmp.list
220 echo "$1 - unknown test, ignored"
229 if [ -s $tmp.list ]; then
230 # found some valid test numbers ... this is good
232 elif $have_test_arg; then
233 # had test numbers, but none in group file ... do nothing
236 # no test numbers, do everything from group file
237 sed -n -e '/^[0-9][0-9][0-9]*/s/[ ].*//p' <group >$tmp.list
240 # sort the list of tests into numeric order
241 list=`sort -n $tmp.list`
242 rm -f $tmp.list $tmp.tmp $tmp.sed
246 list=`echo $list | awk -f randomize.awk`
252 echo "check: failed to source common.rc"
258 echo "check: QA must be run as root"
262 # Ok, time to start running...
271 if [ -f check.time -a -f $tmp.time ]
273 cat check.time $tmp.time \
277 for (i in t) print i " " t[i]
281 mv $tmp.out check.time
286 echo $list | fmt | sed -e 's/^/ /' -e "s;$SRC_DIR/;;g" >>check.log
287 $interrupt && echo "Interrupted!" >>check.log
289 if [ ! -z "$n_try" -a $n_try != 0 ]
294 if [ ! -z "$notrun" ]
296 echo "Not run:$notrun"
297 echo "Not run:$notrun" >>check.log
300 if [ ! -z "$n_bad" -a $n_bad != 0 ]
303 echo "Failed $n_bad of $n_try tests"
304 echo "Failures:$bad" | fmt >>check.log
305 echo "Failed $n_bad of $n_try tests" >>check.log
307 echo "Passed all $n_try tests"
308 echo "Passed all $n_try tests" >>check.log
313 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
317 trap "_wrapup; exit \$status" 0 1 2 3 15
319 # don't leave old full output behind on a clean run
322 [ -f check.time ] || touch check.time
324 # print out our test configuration
325 echo "FSTYP -- `_full_fstyp_details`"
326 echo "PLATFORM -- `_full_platform_details`"
327 if [ ! -z "$SCRATCH_DEV" ]; then
328 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
329 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
334 if [ ! -z "$SCRATCH_DEV" ]; then
335 umount $SCRATCH_DEV 2>/dev/null
336 # call the overridden mkfs - make sure the FS is built
337 # the same as we'll create it later.
339 if ! _scratch_mkfs $flag >$tmp.err 2>&1
341 echo "our local _scratch_mkfs routine ..."
343 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
347 # call the overridden mount - make sure the FS mounts with
348 # the same options that we'll mount with later.
349 if ! _scratch_mount >$tmp.err 2>&1
351 echo "our local mount routine ..."
353 echo "check: failed to mount \$SCRATCH_DEV using specified options"
365 # the filename for the test and the name output are different.
366 # we don't include the tests/ directory in the name output.
367 seqnum=`echo $seq | sed -e "s;$SRC_DIR/;;"`
377 echo " - no such test?"
379 # really going to try and run this one
383 # slashes now in names, sed barfs on them so use grep
384 lasttime=`grep -w ^$seq check.time | awk '// {print $2}'`
385 if [ "X$lasttime" != X ]; then
386 echo -n " ${lasttime}s ..."
388 echo -n " " # prettier output with timestamps.
390 rm -f core $seq.notrun
393 $timestamp && echo -n " ["`date "+%T"`"]"
394 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
395 $LOGGER_PROG "run xfstest $seqnum"
396 ./$seq >$tmp.rawout 2>&1
398 $timestamp && _timestamp
401 _fix_malloc <$tmp.rawout >$tmp.out
406 echo -n " [dumped core]"
411 if [ -f $seq.notrun ]
413 $timestamp || echo -n " [not run] "
414 $timestamp && echo " [not run]" && echo -n " $seqnum -- "
416 notrun="$notrun $seqnum"
420 echo -n " [failed, exit status $sts]"
425 echo " - no qualified output"
428 if diff $seq.out $tmp.out >/dev/null 2>&1
434 echo "$seqnum `expr $stop - $start`" >>$tmp.time
435 echo -n " `expr $stop - $start`s"
439 echo " - output mismatch (see $seq.out.bad)"
440 mv $tmp.out $seq.out.bad
441 $diff $seq.out $seq.out.bad | {
442 if test "$DIFF_LENGTH" -le 0; then
445 head -n "$DIFF_LENGTH"
447 sed -e 's/^\(.\)/ \1/'
449 echo " (Run '$diff $seq.out $seq.out.bad' to see the" \
458 # come here for each test, except when $showme is true
463 n_bad=`expr $n_bad + 1`
466 if [ ! -f $seq.notrun ]
469 n_try=`expr $n_try + 1`