Fix up a configure diagnostic when detecting attr/acl headers.
[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
8 tmp=/tmp/$$
9 status=0
10 needwrap=true
11 try=0
12 n_bad=0
13 bad=""
14 notrun=""
15 interrupt=true
16
17 export QA_CHECK_FS=${QA_CHECK_FS:=true}
18
19 # generic initialization
20 iam=check
21 if ! . ./common.rc
22 then
23     echo "check: failed to source common.rc"
24     exit 1
25 fi
26
27 if [ `id -u` -ne 0 ]
28 then
29     echo "check: QA must be run as root"
30     exit 1
31 fi
32
33 _wallclock()
34 {
35     date "+%H %M %S" | $AWK_PROG '{ print $1*3600 + $2*60 + $3 }'
36 }
37
38 _timestamp()
39 {
40     now=`date "+%T"`
41     echo -n " [$now]"
42 }
43
44 _wrapup()
45 {
46     # for hangcheck ...
47     # remove files that were used by hangcheck
48     #
49     [ -f /tmp/check.pid ] && rm -rf /tmp/check.pid
50     [ -f /tmp/check.sts ] && rm -rf /tmp/check.sts
51
52     if $showme
53     then
54         :
55     elif $needwrap
56     then
57         if [ -f check.time -a -f $tmp.time ]
58         then
59             cat check.time $tmp.time \
60             | $AWK_PROG '
61         { t[$1] = $2 }
62 END     { if (NR > 0) {
63             for (i in t) print i " " t[i]
64           }
65         }' \
66             | sort -n >$tmp.out
67             mv $tmp.out check.time
68         fi
69
70         if [ -f $tmp.expunged ]
71         then
72             notrun=`wc -l <$tmp.expunged | sed -e 's/  *//g'`
73             try=`expr $try - $notrun`
74             list=`echo "$list" | sed -f $tmp.expunged`
75         fi
76
77         echo "" >>check.log
78         date >>check.log
79         echo $list | fmt | sed -e 's/^/    /' >>check.log
80         $interrupt && echo "Interrupted!" >>check.log
81         
82         if [ ! -z "$notrun" ]
83         then
84             echo "Not run:$notrun"
85             echo "Not run:$notrun" >>check.log
86         fi
87         if [ ! -z "$n_bad" -a $n_bad != 0 ]
88         then
89             echo "Failures:$bad"
90             echo "Failed $n_bad of $try tests"
91             echo "Failures:$bad" | fmt >>check.log
92             echo "Failed $n_bad of $try tests" >>check.log
93         else
94             echo "Passed all $try tests"
95             echo "Passed all $try tests" >>check.log
96         fi
97         needwrap=false
98     fi
99
100     rm -f /tmp/*.rawout /tmp/*.out /tmp/*.err /tmp/*.time
101     rm -f /tmp/check.pid /tmp/check.sts
102     rm -f $tmp.*
103 }
104
105 trap "_wrapup; exit \$status" 0 1 2 3 15
106
107 # for hangcheck ...
108 # Save pid of check in a well known place, so that hangcheck can be sure it
109 # has the right pid (getting the pid from ps output is not reliable enough).
110 #
111 rm -rf /tmp/check.pid
112 echo $$ >/tmp/check.pid
113
114 # for hangcheck ...
115 # Save the status of check in a well known place, so that hangcheck can be
116 # sure to know where check is up to (getting test number from ps output is
117 # not reliable enough since the trace stuff has been introduced).
118 #
119 rm -rf /tmp/check.sts
120 echo "preamble" >/tmp/check.sts
121
122 # don't leave old full output behind on a clean run
123 rm -f check.full
124
125 # by default don't output timestamps
126 timestamp=${TIMESTAMP:=false}
127
128 . ./common
129
130 [ -f check.time ] || touch check.time
131
132 FULL_FSTYP_DETAILS=`_full_fstyp_details`
133 FULL_HOST_DETAILS=`_full_platform_details`
134 FULL_MKFS_OPTIONS=`_scratch_mkfs_options`
135 FULL_MOUNT_OPTIONS=`_scratch_mount_options`
136
137 cat <<EOF
138 FSTYP         -- $FULL_FSTYP_DETAILS
139 PLATFORM      -- $FULL_HOST_DETAILS
140 MKFS_OPTIONS  -- $FULL_MKFS_OPTIONS
141 MOUNT_OPTIONS -- $FULL_MOUNT_OPTIONS
142
143 EOF
144
145 umount $SCRATCH_DEV 2>/dev/null
146 # call the overridden mkfs - make sure the FS is built
147 # the same as we'll create it later.
148
149 if ! _scratch_mkfs $flag >$tmp.err 2>&1
150 then
151     echo "our local _scratch_mkfs routine ..."
152     cat $tmp.err
153     echo "check: failed to mkfs \$SCRATCH_DEV using specified options"
154     exit 1
155 fi
156
157 # call the overridden mount - make sure the FS mounts with
158 # the same options that we'll mount with later.
159 if ! _scratch_mount >$tmp.err 2>&1
160 then
161     echo "our local mount routine ..."
162     cat $tmp.err
163     echo "check: failed to mount \$SCRATCH_DEV using specified options"
164     exit 1
165 fi
166
167 seq="check"
168 _check_test_fs
169
170 for seq in $list
171 do
172     err=false
173     echo -n "$seq"
174     if $showme
175     then
176         echo
177         continue
178     elif [ -f expunged ] && $expunge && egrep "^$seq([  ]|\$)" expunged >/dev/null
179     then
180         echo " - expunged"
181         rm -f $seq.out.bad
182         echo "/^$seq\$/d" >>$tmp.expunged
183     elif [ ! -f $seq ]
184     then
185         echo " - no such test?"
186         echo "/^$seq\$/d" >>$tmp.expunged
187     else
188         # really going to try and run this one
189         #
190         rm -f $seq.out.bad
191         lasttime=`sed -n -e "/^$seq /s/.* //p" <check.time`
192         if [ "X$lasttime" != X ]; then
193                 echo -n " ${lasttime}s ..."
194         else
195                 echo -n "       "       # prettier output with timestamps.
196         fi
197         rm -f core $seq.notrun
198
199         # for hangcheck ...
200         echo "$seq" >/tmp/check.sts
201
202         start=`_wallclock`
203         $timestamp && echo -n " ["`date "+%T"`"]"
204         [ ! -x $seq ] && chmod u+x $seq # ensure we can run it
205         ./$seq >$tmp.rawout 2>&1
206         sts=$?
207         $timestamp && _timestamp
208         stop=`_wallclock`
209
210         _fix_malloc <$tmp.rawout >$tmp.out
211         rm -f $tmp.rawout
212
213         if [ -f core ]
214         then
215             echo -n " [dumped core]"
216             mv core $seq.core
217             err=true
218         fi
219
220         if [ -f $seq.notrun ]
221         then
222             $timestamp || echo -n " [not run] "
223             $timestamp && echo " [not run]" && echo -n "        $seq -- "
224             cat $seq.notrun
225             notrun="$notrun $seq"
226         else
227             if [ $sts -ne 0 ]
228             then
229                 echo -n " [failed, exit status $sts]"
230                 err=true
231             fi
232             if [ ! -f $seq.out ]
233             then
234                 echo " - no qualified output"
235                 err=true
236             else
237                 if diff $seq.out $tmp.out >/dev/null 2>&1
238                 then
239                     echo ""
240                     if $err
241                     then
242                         :
243                     else
244                         echo "$seq `expr $stop - $start`" >>$tmp.time
245                     fi
246                 else
247                     echo " - output mismatch (see $seq.out.bad)"
248                     mv $tmp.out $seq.out.bad
249                     $diff $seq.out $seq.out.bad
250                     err=true
251                 fi
252             fi
253         fi
254
255     fi
256
257     # come here for each test, except when $showme is true
258     #
259     if $err
260     then
261         bad="$bad $seq"
262         n_bad=`expr $n_bad + 1`
263         quick=false
264     fi
265     [ -f $seq.notrun ] || try=`expr $try + 1`
266     
267     seq="after_$seq"
268     _check_test_fs
269 done
270
271 interrupt=false
272 status=`expr $n_bad`
273 exit