Add some code to limit the repquota output to just the local entries and not
[xfstests-dev.git] / check
1 #!/bin/sh
2 #
3 # Control script for QA
4 #
5 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
6
7 # This program is free software; you can redistribute it and/or modify it
8 # under the terms of version 2 of the GNU General Public License as
9 # published by the Free Software Foundation.
10
11 # This program is distributed in the hope that it would be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15 # Further, this software is distributed without any warranty that it is
16 # free of the rightful claim of any third person regarding infringement
17 # or the like.  Any license provided herein, whether implied or
18 # otherwise, applies only to this software file.  Patent licenses, if
19 # any, provided herein do not apply to combinations of this program with
20 # other software, or any other product whatsoever.
21
22 # You should have received a copy of the GNU General Public License along
23 # with this program; if not, write the Free Software Foundation, Inc., 59
24 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
25
26 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
27 # Mountain View, CA  94043, or:
28
29 # http://www.sgi.com 
30
31 # For further information regarding this notice, see: 
32
33 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 #
35
36 export MKFS_OPTIONS=${MKFS_OPTIONS:=-bsize=4096}
37 export MOUNT_OPTIONS=${MOUNT_OPTIONS:=-ologbufs=2}
38
39 tmp=/tmp/$$
40 status=0
41 needwrap=true
42 try=0
43 n_bad=0
44 bad=""
45 notrun=""
46 interrupt=true
47
48 # generic initialization
49 iam=check
50 if ! . ./common.rc
51 then
52     echo "check: failed to source common.rc"
53     exit 1
54 fi
55
56 if [ $UID -ne 0 ]
57 then
58     echo "check: QA must be run as root"
59     exit 1
60 fi
61
62 _wallclock()
63 {
64     date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
65 }
66
67 _wrapup()
68 {
69     # for hangcheck ...
70     # remove files that were used by hangcheck
71     #
72     [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
73     [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
74
75     if $showme
76     then
77         :
78     elif $needwrap
79     then
80         if [ -f check.time -a -f $tmp.time ]
81         then
82             cat check.time $tmp.time \
83             | $AWK_PROG '
84         { t[$1] = $2 }
85 END     { if (NR > 0) {
86             for (i in t) print i " " t[i]
87           }
88         }' \
89             | sort -n >$tmp.out
90             mv $tmp.out check.time
91         fi
92
93         if [ -f $tmp.expunged ]
94         then
95             notrun=`wc -l <$tmp.expunged | sed -e 's/  *//g'`
96             try=`expr $try - $notrun`
97             list=`echo "$list" | sed -f $tmp.expunged`
98         fi
99
100         echo "" >>check.log
101         date >>check.log
102         echo $list | fmt | sed -e 's/^/    /' >>check.log
103         $interrupt && echo "Interrupted!" >>check.log
104         
105         if [ ! -z "$notrun" ]
106         then
107             echo "Not run:$notrun"
108             echo "Not run:$notrun" >>check.log
109         fi
110         if [ ! -z "$n_bad" -a $n_bad != 0 ]
111         then
112             echo "Failures:$bad"
113             echo "Failed $n_bad of $try tests"
114             echo "Failures:$bad" | fmt >>check.log
115             echo "Failed $n_bad of $try tests" >>check.log
116         else
117             echo "Passed all $try tests"
118             echo "Passed all $try tests" >>check.log
119         fi
120         needwrap=false
121     fi
122
123     rm -f $tmp.*
124 }
125
126 trap "_wrapup; exit \$status" 0 1 2 3 15
127
128 # for hangcheck ...
129 # Save pid of check in a well known place, so that hangcheck can be sure it
130 # has the right pid (getting the pid from ps output is not reliable enough).
131 #
132 rm -rf /tmp/check.pid
133 echo $$ >/tmp/check.pid
134
135 # for hangcheck ...
136 # Save the status of check in a well known place, so that hangcheck can be
137 # sure to know where check is up to (getting test number from ps output is
138 # not reliable enough since the trace stuff has been introduced).
139 #
140 rm -rf /tmp/check.sts
141 echo "preamble" >/tmp/check.sts
142
143 # don't leave old full output behind on a clean run
144 rm -f check.full
145
146 # by default don't output timestamps
147 timestamp=${TIMESTAMP:=false}
148
149 . ./common
150
151 [ -f check.time ] || touch check.time
152
153 if [ ! -z "$MKFS_OPTIONS" ]
154 then
155     echo "check: \$MKFS_OPTIONS specified -- \"$MKFS_OPTIONS\""
156     umount $SCRATCH_DEV 2>/dev/null
157     # call the overridden mkfs.xfs - make sure the FS is built
158     # the same as we'll create it later.
159     if ! mkfs_xfs -f $SCRATCH_DEV >$tmp.err 2>&1
160     then
161         echo "our local mkfs_xfs routine ..."
162         cat $tmp.err
163         echo "check: failed to mkfs.xfs \$SCRATCH_DEV using specified options"
164         exit 1
165     fi
166 fi
167
168 if [ ! -z "$MOUNT_OPTIONS" ]
169 then
170     echo "check: \$MOUNT_OPTIONS specified -- \"$MOUNT_OPTIONS\""
171     umount $TEST_DEV
172     # call the overridden mount - make sure the FS starts as
173     # the same as we'll set it later.
174     if ! mount -t xfs $TEST_DEV $TEST_DIR >$tmp.err 2>&1
175     then
176         echo "our local mount routine ..."
177         cat $tmp.err
178         # call the normal mount
179         echo "normal mount ..."
180         /bin/mount -t xfs $TEST_DEV $TEST_DIR
181         echo "check: failed to mount \$TEST_DEV using specified mount options"
182         exit 1
183     fi
184 fi
185
186 seq="check"
187 _check_fs $TEST_DEV
188
189 for seq in $list
190 do
191     err=false
192     echo -n "$seq"
193     if $showme
194     then
195         echo
196         continue
197     elif [ -f expunged ] && $expunge && egrep "^$seq([  ]|\$)" expunged >/dev/null
198     then
199         echo " - expunged"
200         rm -f $seq.out.bad
201         echo "/^$seq\$/d" >>$tmp.expunged
202     elif [ ! -f $seq ]
203     then
204         echo " - no such test?"
205         echo "/^$seq\$/d" >>$tmp.expunged
206     else
207         # really going to try and run this one
208         #
209         rm -f $seq.out.bad
210         lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
211         if [ "X$lasttime" != X ]; then
212                 echo -n " ${lasttime}s ..."
213         else
214                 echo -n "       "       # prettier output with timestamps.
215         fi
216         rm -f core $seq.notrun
217
218         # for hangcheck ...
219         echo "$seq" >/tmp/check.sts
220
221         start=`_wallclock`
222         $timestamp && echo -n " ["`date "+%T"`"]"
223         sh $seq >$tmp.rawout 2>&1
224         sts=$?
225         $timestamp && echo -n " ["`date "+%T"`"]"
226         stop=`_wallclock`
227
228         _fix_malloc <$tmp.rawout >$tmp.out
229         rm -f $tmp.rawout
230
231         if [ -f core ]
232         then
233             echo -n " [dumped core]"
234             mv core $seq.core
235             err=true
236         fi
237
238         if [ -f $seq.notrun ]
239         then
240             $timestamp || echo -n " [not run] "
241             $timestamp && echo " [not run]" && echo -n "        $seq -- "
242             cat $seq.notrun
243             notrun="$notrun $seq"
244         else
245             if [ $sts -ne 0 ]
246             then
247                 echo -n " [failed, exit status $sts]"
248                 err=true
249             fi
250             if [ ! -f $seq.out ]
251             then
252                 echo " - no qualified output"
253                 err=true
254             else
255                 if diff $seq.out $tmp.out >/dev/null 2>&1
256                 then
257                     echo ""
258                     if $err
259                     then
260                         :
261                     else
262                         echo "$seq `expr $stop - $start`" >>$tmp.time
263                     fi
264                 else
265                     echo " - output mismatch (see $seq.out.bad)"
266                     mv $tmp.out $seq.out.bad
267                     $diff $seq.out $seq.out.bad
268                     err=true
269                 fi
270             fi
271         fi
272
273     fi
274
275     # come here for each test, except when $showme is true
276     #
277     if $err
278     then
279         bad="$bad $seq"
280         n_bad=`expr $n_bad + 1`
281         quick=false
282     fi
283     [ -f $seq.notrun ] || try=`expr $try + 1`
284     
285     seq="after_$seq"
286     _check_fs $TEST_DEV
287     
288 done
289
290 interrupt=false
291 status=`expr $n_bad`
292 exit