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 FULL_FSTYP_DETAILS=`_full_fstyp_details`
165 FULL_HOST_DETAILS=`_full_platform_details`
166 FULL_MKFS_OPTIONS=`_scratch_mkfs_options`
167 FULL_MOUNT_OPTIONS=`_scratch_mount_options`
170 FSTYP -- $FULL_FSTYP_DETAILS
171 PLATFORM -- $FULL_HOST_DETAILS
172 MKFS_OPTIONS -- $FULL_MKFS_OPTIONS
173 MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS
177 if [ ! -z "$SCRATCH_DEV" ]; then
178 umount $SCRATCH_DEV 2>/dev/null
179 # call the overridden mkfs - make sure the FS is built
180 # the same as we'll create it later.
182 if ! _scratch_mkfs $flag >$tmp.err 2>&1
184 echo "our local _scratch_mkfs routine ..."
186 echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
190 # call the overridden mount - make sure the FS mounts with
191 # the same options that we'll mount with later.
192 if ! _scratch_mount >$tmp.err 2>&1
194 echo "our local mount routine ..."
196 echo "check: failed to mount \$SCRATCH_DEV using specified options"
204 [ -n "$TESTS_REMAINING_LOG" ] && echo $list > $TESTS_REMAINING_LOG
210 if [ -n "$TESTS_REMAINING_LOG" ] ; then
211 sed -e "s/$seq//" -e 's/ / /' -e 's/^ *//' $TESTS_REMAINING_LOG > $TESTS_REMAINING_LOG.tmp
212 mv $TESTS_REMAINING_LOG.tmp $TESTS_REMAINING_LOG
220 elif [ -f expunged ] && $expunge && egrep "^$seq([ ]|\$)" expunged >/dev/null
224 echo "/^$seq\$/d" >>$tmp.expunged
227 echo " - no such test?"
228 echo "/^$seq\$/d" >>$tmp.expunged
230 # really going to try and run this one
233 lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
234 if [ "X$lasttime" != X ]; then
235 echo -n " ${lasttime}s ..."
237 echo -n " " # prettier output with timestamps.
239 rm -f core $seq.notrun
242 echo "$seq" >/tmp/check.sts
245 $timestamp && echo -n " ["`date "+%T"`"]"
246 [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
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
286 echo "$seq `expr $stop - $start`" >>$tmp.time
289 echo " - output mismatch (see $seq.out.bad)"
290 mv $tmp.out $seq.out.bad
291 $diff $seq.out $seq.out.bad
299 # come here for each test, except when $showme is true
304 n_bad=`expr $n_bad + 1`
307 if [ ! -f $seq.notrun ]
310 n_try=`expr $n_try + 1`