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}
34 # by default don't output timestamps
35 timestamp=${TIMESTAMP:=false}
37 # generic initialization
40 # we need common.config
41 if ! . ./common.config
43 echo "$iam: failed to source common.config"
54 echo "check: failed to source common.rc"
60 echo "check: QA must be run as root"
66 date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
78 # remove files that were used by hangcheck
80 [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
81 [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
88 if [ -f check.time -a -f $tmp.time ]
90 cat check.time $tmp.time \
94 for (i in t) print i " " t[i]
98 mv $tmp.out check.time
101 if [ -f $tmp.expunged ]
103 notrun=`wc -l <$tmp.expunged | sed -e 's/ *//g'`
104 n_try=`expr $n_try - $notrun`
105 list=`echo "$list" | sed -f $tmp.expunged`
110 echo $list | fmt | sed -e 's/^/ /' >>check.log
111 $interrupt && echo "Interrupted!" >>check.log
113 if [ ! -z "$n_try" -a $n_try != 0 ]
118 if [ ! -z "$notrun" ]
120 echo "Not run:$notrun"
121 echo "Not run:$notrun" >>check.log
124 if [ ! -z "$n_bad" -a $n_bad != 0 ]
127 echo "Failed $n_bad of $n_try tests"
128 echo "Failures:$bad" | fmt >>check.log
129 echo "Failed $n_bad of $n_try tests" >>check.log
131 echo "Passed all $n_try tests"
132 echo "Passed all $n_try tests" >>check.log
137 rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
138 rm -f /tmp/check.pid /tmp/check.sts
142 trap "_wrapup; exit \$status" 0 1 2 3 15
145 # Save pid of check in a well known place, so that hangcheck can be sure it
146 # has the right pid (getting the pid from ps output is not reliable enough).
148 rm -rf /tmp/check.pid
149 echo $$ >/tmp/check.pid
152 # Save the status of check in a well known place, so that hangcheck can be
153 # sure to know where check is up to (getting test number from ps output is
154 # not reliable enough since the trace stuff has been introduced).
156 rm -rf /tmp/check.sts
157 echo "preamble" >/tmp/check.sts
159 # don't leave old full output behind on a clean run
162 [ -f check.time ] || touch check.time
164 # print out our test configuration
165 echo "FSTYP -- `_full_fstyp_details`"
166 echo "PLATFORM -- `_full_platform_details`"
167 if [ ! -z "$SCRATCH_DEV" ]; then
168 echo "MKFS_OPTIONS -- `_scratch_mkfs_options`"
169 echo "MOUNT_OPTIONS -- `_scratch_mount_options`"
174 if [ ! -z "$SCRATCH_DEV" ]; then
175 umount $SCRATCH_DEV 2>/dev/null
176 # call the overridden mkfs - make sure the FS is built
177 # the same as we'll create it later.
179 if ! _scratch_mkfs $flag >$tmp.err 2>&1
181 echo "our local _scratch_mkfs routine ..."
183 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
187 # call the overridden mount - make sure the FS mounts with
188 # the same options that we'll mount with later.
189 if ! _scratch_mount >$tmp.err 2>&1
191 echo "our local mount routine ..."
193 echo "check: failed to mount \$SCRATCH_DEV using specified options"
201 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
207 if [ -n "$TESTS_REMAINING_LOG" ] ; then
208 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
209 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
217 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
221 echo "/^$seq\$/d" >>$tmp.expunged
224 echo " - no such test?"
225 echo "/^$seq\$/d" >>$tmp.expunged
227 # really going to try and run this one
230 lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
231 if [ "X$lasttime" != X ]; then
232 echo -n " ${lasttime}s ..."
234 echo -n " " # prettier output with timestamps.
236 rm -f core $seq.notrun
239 echo "$seq" >/tmp/check.sts
242 $timestamp && echo -n " ["`date "+%T"`"]"
243 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
244 ./$seq >$tmp.rawout 2>&1
246 $timestamp && _timestamp
249 _fix_malloc <$tmp.rawout >$tmp.out
254 echo -n " [dumped core]"
259 if [ -f $seq.notrun ]
261 $timestamp || echo -n " [not run] "
262 $timestamp && echo " [not run]" && echo -n " $seq -- "
264 notrun="$notrun $seq"
268 echo -n " [failed, exit status $sts]"
273 echo " - no qualified output"
276 if diff $seq.out $tmp.out >/dev/null 2>&1
282 echo "$seq `expr $stop - $start`" >>$tmp.time
283 echo -n " `expr $stop - $start`s"
287 echo " - output mismatch (see $seq.out.bad)"
288 mv $tmp.out $seq.out.bad
289 $diff $seq.out $seq.out.bad
297 # come here for each test, except when $showme is true
302 n_bad=`expr $n_bad + 1`
305 if [ ! -f $seq.notrun ]
308 n_try=`expr $n_try + 1`