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