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
32 export QA_CHECK_FS=${QA_CHECK_FS:=true}
33 # number of diff lines from a failed test, 0 for whole output
34 export DIFF_LENGTH=${DIFF_LENGTH:=10}
36 # by default don't output timestamps
37 timestamp=${TIMESTAMP:=false}
39 # generic initialization
42 # we need common.config
43 if ! . ./common.config
45 echo "$iam: failed to source common.config"
56 echo "check: failed to source common.rc"
62 echo "check: QA must be run as root"
68 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
80 # remove files that were used by hangcheck
82 [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
83 [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
90 if [ -f check.time -a -f $tmp.time ]
92 cat check.time $tmp.time \
96 for (i in t) print i " " t[i]
100 mv $tmp.out check.time
103 if [ -f $tmp.expunged ]
105 notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'`
106 n_try=`expr $n_try - $notrun`
107 list=`echo "$list" | sed -f $tmp.expunged`
112 echo $list | fmt | sed -e 's/^/ /' >>check.log
113 $interrupt && echo "Interrupted!" >>check.log
115 if [ ! -z "$n_try" -a $n_try != 0 ]
120 if [ ! -z "$notrun" ]
122 echo "Not run:$notrun"
123 echo "Not run:$notrun" >>check.log
126 if [ ! -z "$n_bad" -a $n_bad != 0 ]
129 echo "Failed $n_bad of $n_try tests"
130 echo "Failures:$bad" | fmt >>check.log
131 echo "Failed $n_bad of $n_try tests" >>check.log
133 echo "Passed all $n_try tests"
134 echo "Passed all $n_try tests" >>check.log
139 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
140 rm -f /tmp/check.pid /tmp/check.sts
144 trap "_wrapup; exit \$status" 0 1 2 3 15
147 # Save pid of check in a well known place, so that hangcheck can be sure it
148 # has the right pid (getting the pid from ps output is not reliable enough).
150 rm -rf /tmp/check.pid
151 echo $$ >/tmp/check.pid
154 # Save the status of check in a well known place, so that hangcheck can be
155 # sure to know where check is up to (getting test number from ps output is
156 # not reliable enough since the trace stuff has been introduced).
158 rm -rf /tmp/check.sts
159 echo "preamble" >/tmp/check.sts
161 # don't leave old full output behind on a clean run
164 [ -f check.time ] || touch check.time
166 # print out our test configuration
167 echo "FSTYP -- `_full_fstyp_details`"
168 echo "PLATFORM -- `_full_platform_details`"
169 if [ ! -z "$SCRATCH_DEV" ]; then
170 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
171 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
176 if [ ! -z "$SCRATCH_DEV" ]; then
177 umount $SCRATCH_DEV 2>/dev/null
178 # call the overridden mkfs - make sure the FS is built
179 # the same as we'll create it later.
181 if ! _scratch_mkfs $flag >$tmp.err 2>&1
183 echo "our local _scratch_mkfs routine ..."
185 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
189 # call the overridden mount - make sure the FS mounts with
190 # the same options that we'll mount with later.
191 if ! _scratch_mount >$tmp.err 2>&1
193 echo "our local mount routine ..."
195 echo "check: failed to mount \$SCRATCH_DEV using specified options"
203 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
209 if [ -n "$TESTS_REMAINING_LOG" ] ; then
210 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
211 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
219 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
223 echo "/^$seq\$/d" >>$tmp.expunged
226 echo " - no such test?"
227 echo "/^$seq\$/d" >>$tmp.expunged
229 # really going to try and run this one
232 lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
233 if [ "X$lasttime" != X ]; then
234 echo -n " ${lasttime}s ..."
236 echo -n " " # prettier output with timestamps.
238 rm -f core $seq.notrun
241 echo "$seq" >/tmp/check.sts
244 $timestamp && echo -n " ["`date "+%T"`"]"
245 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
246 [ -x /usr/bin/logger ] && /usr/bin/logger "run xfstest $seq"
247 ./$seq >$tmp.rawout 2>&1
249 $timestamp && _timestamp
252 _fix_malloc <$tmp.rawout >$tmp.out
257 echo -n " [dumped core]"
262 if [ -f $seq.notrun ]
264 $timestamp || echo -n " [not run] "
265 $timestamp && echo " [not run]" && echo -n " $seq -- "
267 notrun="$notrun $seq"
271 echo -n " [failed, exit status $sts]"
276 echo " - no qualified output"
279 if diff $seq.out $tmp.out >/dev/null 2>&1
285 echo "$seq `expr $stop - $start`" >>$tmp.time
286 echo -n " `expr $stop - $start`s"
290 echo " - output mismatch (see $seq.out.bad)"
291 mv $tmp.out $seq.out.bad
292 $diff $seq.out $seq.out.bad | {
293 if test "$DIFF_LENGTH" -le 0; then
296 head -n "$DIFF_LENGTH"
298 sed -e 's/^\(.\)/ \1/'
300 echo " (Run '$diff $seq.out $seq.out.bad' to see the" \
309 # come here for each test, except when $showme is true
314 n_bad=`expr $n_bad + 1`
317 if [ ! -f $seq.notrun ]
320 n_try=`expr $n_try + 1`