OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [start/] [insight/] [dejagnu/] [contrib/] [test-tool] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
#!/bin/sh
2
# This script automatically test the given tool with the tool's test cases,
3
# reporting anything of interest.
4
 
5
# exits with 1 if there is nothing of interest
6
# exits with 0 if there is something interesting
7
# exits with 2 if an error occurred
8
 
9
# Syntax: test-tool [-expectedpass] [-keepoutput] [-noupdate] g++|gcc|gdb|...
10
#
11
# -expectedpass: Turn XFAIL into "pass", XPASS into "fail".
12
#                The default is XFAIL->fail, XPASS->pass.
13
# -keepoutput: Save "make check" output in test-$tool.log.
14
# -noupdate: Don't update log files.
15
 
16
# Limitations, don't run this multiple times in one day, unless the -noupdate
17
# flag is given.
18
 
19
# Written by Mike Stump 
20
 
21
expectedpass=no
22
keepoutput=no
23
update=yes
24
tool=""
25
 
26
# See if cp -p works.
27
pwd=`pwd`
28
cd /tmp
29
rm -f test-tool-$$-1 test-tool-$$-2
30
touch test-tool-$$-1
31
cp -p test-tool-$$-1 test-tool-$$-2 2>/dev/null
32
if [ $? = 0 -a -f test-tool-$$-2 ] ; then
33
    CP="cp -p"
34
else
35
    CP=cp
36
fi
37
rm -f test-tool-$$-1 test-tool-$$-2
38
cd $pwd
39
 
40
for arg in $*
41
do
42
        case $arg in
43
        -expectedpass) expectedpass=yes ;;
44
        -keepoutput) keepoutput=yes ;;
45
        -noupdate) update=no ;;
46
        -*)
47
                echo "Usage: [-expectedpass] [-keepoutput] [-noupdate] tool_name" >&2
48
                exit 2
49
                ;;
50
        *)
51
                if [ "$tool" != "" ]; then
52
                        echo "Usage: [-expectedpass] [-keepoutput] [-noupdate] tool_name" >&2
53
                        exit 2
54
                fi
55
                tool=$arg
56
                ;;
57
        esac
58
done
59
 
60
# FIXME: It sure would be nice if `testdir' wasn't necessary. :-(
61
 
62
case $tool in
63
    g++)
64
        devoname=gcc
65
        checktarget=check-g++
66
        testdir=testsuite
67
        ;;
68
    gcc)
69
        devoname=gcc
70
        checktarget=check-gcc
71
        testdir=testsuite
72
        ;;
73
    ld|gld)
74
        devoname=ld
75
        checktarget=check
76
        testdir=.
77
        ;;
78
    binutils)
79
        devoname=binutils
80
        checktarget=check
81
        testdir=.
82
        ;;
83
    *)
84
        devoname=$tool
85
        checktarget=check
86
        testdir=testsuite
87
        ;;
88
esac
89
 
90
# Default DEVOSRCDIR
91
if [ "$DEVOSRCDIR" = "" ]; then
92
        DEVOSRCDIR=$HOME/devo ; export DEVOSRCDIR
93
fi
94
 
95
# Check DEVOSRCDIR
96
if [ ! -d "$DEVOSRCDIR" ]; then
97
        echo "$0: no directory $DEVOSRCDIR" >&2
98
        exit 2
99
fi
100
 
101
# Default DEVOBINDIR
102
if [ "$DEVOBINDIR" = "" ]; then
103
        CPU=`$DEVOSRCDIR/config.guess`
104
        if [ $? != 0 ]; then
105
                echo "$0: cannot run config.guess" >&2
106
                exit 2
107
        fi
108
        DEVOBINDIR=$HOME/$CPU ; export DEVOBINDIR
109
fi
110
 
111
# Check DEVOBINDIR
112
if [ ! -d "$DEVOBINDIR" ]; then
113
        echo "$0: no directory $DEVOBINDIR" >&2
114
        exit 2
115
fi
116
 
117
# Specialize DEVOSRCDIR
118
if [ -d "$DEVOSRCDIR/$devoname" ]; then
119
        DEVOSRCDIR=$DEVOSRCDIR/$devoname
120
else
121
        echo "$0: Cannot find source directory." >&2
122
        exit 2
123
fi
124
 
125
# Default LOGDIR
126
if [ "$LOGDIR" = "" ]; then
127
        LOGDIR=$HOME/logs ; export LOGDIR
128
fi
129
 
130
# Check LOGDIR
131
if [ ! -d "$LOGDIR" ]; then
132
        echo "$0: no directory $LOGDIR" >&2
133
        exit 2
134
fi
135
 
136
# Specialize DEVOBINDIR
137
if [ -d "$DEVOBINDIR/$devoname" ]; then
138
        DEVOBINDIR=$DEVOBINDIR/$devoname
139
else
140
        echo "$0: Cannot find binary directory." >&2
141
        exit 2
142
fi
143
 
144
# Binary directory
145
cd $DEVOBINDIR || exit 2
146
 
147
TMPDIR=${TMPDIR-/tmp}
148
 
149
tmp=$TMPDIR/$tool-testing.$$a
150
tmp1=$TMPDIR/$tool-testing.$$b
151
tmp2=$TMPDIR/$tool-testing.$$c
152
now_s=$TMPDIR/$tool-testing.$$d
153
before_s=$TMPDIR/$tool-testing.$$e
154
 
155
if [ "$keepoutput" = yes ]; then
156
        rm -f test-$tool.log
157
        make RUNTESTFLAGS="-v -v" $checktarget >test-$tool.log 2>&1
158
else
159
        make RUNTESTFLAGS="-v -v" $checktarget >/dev/null 2>&1
160
fi
161
 
162
# Check for DEJAGNU errors that prevented any output at all.
163
if [ ! -f $testdir/$tool.sum ]; then
164
        echo "Tests didn't run, probably because of a framework error."
165
        if [ "$keepoutput" = yes ]; then
166
                echo
167
                tail -20 test-$tool.log
168
        else
169
                echo "Unable to determine why.  Rerun with -keepoutput."
170
        fi
171
        exit 2
172
fi
173
 
174
# Canonicalize XFAIL and XPASS so the rest of the script can ignore them.
175
if [ "$expectedpass" = yes ]; then
176
        sed 's/^XFAIL/PASS(XFAIL)/; s/^XPASS/FAIL(XPASS)/' <$testdir/$tool.sum >$testdir/$tool.1.sum || exit 2
177
else
178
        sed 's/^XFAIL/FAIL(XFAIL)/; s/^XPASS/PASS(XPASS)/' <$testdir/$tool.sum >$testdir/$tool.1.sum || exit 2
179
fi
180
mv $testdir/$tool.1.sum $testdir/$tool.sum
181
 
182
patterns="$LOGDIR/$tool-??????.sum $LOGDIR/$tool-??????.sum.gz $LOGDIR/$tool-??????????.sum $LOGDIR/$tool-??????????.sum.gz"
183
before=`ls -1t $patterns 2>/dev/null | sed 1q`
184
 
185
todayname=`date '+%y%m%d'`
186
if [ "$update" = no ]; then
187
        now=$testdir/$tool.sum
188
else
189
        mv -f $testdir/$tool.sum $LOGDIR/$tool-$todayname.sum || exit 2
190
        mv -f $testdir/$tool.log $LOGDIR/$tool-$todayname.log || exit 2
191
 
192
        # Say where the logs are stored so they appear in email messages.
193
        echo
194
        echo "Log files: $LOGDIR/$tool-$todayname.*"
195
        echo
196
 
197
        now="$LOGDIR/$tool-$todayname.sum";
198
fi
199
 
200
trap "rm -f $tmp $tmp1 $tmp2 $now_s $before_s" 0 1 2 3 5 9 13 15
201
 
202
case $before in
203
    "") before="cat /dev/null" ;;
204
    *.gz) before="gunzip -c $before" ;;
205
    *) before="cat $before" ;;
206
esac
207
 
208
# First, the test summary.
209
egrep '^# of |===.*Summary.*===' "$now" || echo "(No test summary?)"
210
echo
211
 
212
# Pick out the PASS/FAIL/Ufoo messages.
213
# We grep for them again later but that's for robustness' sake.
214
grep '^[PFU][A-Z()]*:' "$now" | sort -t ':' +1 > "$now_s"
215
$before | grep '^[PFU][A-Z()]*:' | sort -t ':' +1 > "$before_s"
216
 
217
grep '^FAIL:' "$now_s" | sed 's/^[^:]*:[        ]*//' >$tmp1
218
grep '^PASS' "$before_s" | sed 's/^[^:]*:[      ]*//' | comm -12 $tmp1 - >$tmp2
219
 
220
grep -s . $tmp2 >/dev/null
221
if [ $? = 0 ]; then
222
        echo "Tests that now unexpectedly fail, but worked before:"
223
        echo
224
        cat $tmp2
225
        showchangelog=1
226
        echo
227
fi
228
 
229
grep '^FAIL:' "$now_s" | sed 's/^[^:]*:[        ]*//' >$tmp1
230
grep '^[PFU][A-Z()]*:' "$before_s" | sed 's/^[^:]*:[    ]*//' | comm -23 $tmp1 - >$tmp2
231
 
232
grep -s . $tmp2 >/dev/null
233
if [ $? = 0 ]; then
234
        echo "New tests that unexpectedly FAIL:"
235
        echo
236
        cat $tmp2
237
        echo
238
fi
239
 
240
grep '^FAIL:' "$now_s" | sed 's/^[^:]*:[        ]*//' >$tmp1
241
grep '^FAIL' "$before_s" | sed 's/^[^:]*:[      ]*//' | comm -12 $tmp1 - >$tmp2
242
 
243
grep -s . $tmp2 >/dev/null
244
if [ $? = 0 ]; then
245
        echo "Tests that still don't work:"
246
        echo
247
        cat $tmp2
248
        echo
249
fi
250
 
251
grep '^PASS' "$now_s" | sed 's/^[^:]*:[         ]*//' >$tmp1
252
grep '^FAIL' "$before_s" | sed 's/^[^:]*:[      ]*//' | comm -12 $tmp1 - >$tmp2
253
 
254
grep -s . $tmp2 >/dev/null
255
if [ $? = 0 ]; then
256
        echo "Tests that now work, but didn't before:"
257
        echo
258
        cat $tmp2
259
        echo
260
fi
261
 
262
grep '^PASS' "$now_s" | sed 's/^[^:]*:[         ]*//' >$tmp1
263
grep '^[PFU][A-Z()]*:' "$before_s" | sed 's/^[^:]*:[    ]*//' | comm -23 $tmp1 - >$tmp2
264
 
265
grep -s . $tmp2 >/dev/null
266
if [ $? = 0 ]; then
267
        echo "New tests that PASS:"
268
        echo
269
        cat $tmp2
270
        echo
271
fi
272
 
273
grep '^[PFU][A-Z()]*:' "$now_s" | sed 's/^[^:]*:[       ]*//' >$tmp1
274
grep '^PASS' "$before_s" | sed 's/^[^:]*:[      ]*//' | comm -13 $tmp1 - >$tmp2
275
 
276
grep -s . $tmp2 >/dev/null
277
if [ $? = 0 ]; then
278
        echo "Old tests that passed, that have disappeared: (Eeek!)"
279
        echo
280
        cat $tmp2
281
        echo
282
fi
283
 
284
grep '^[PFU][A-Z()]*:' "$now_s" | sed 's/^[^:]*:[       ]*//' >$tmp1
285
grep '^FAIL' "$before_s" | sed 's/^[^:]*:[      ]*//' | comm -13 $tmp1 - >$tmp2
286
 
287
grep -s . $tmp2 >/dev/null
288
if [ $? = 0 ]; then
289
        echo "Old tests that failed, that have disappeared: (Eeek!)"
290
        echo
291
        cat $tmp2
292
        echo
293
fi
294
 
295
egrep '^(ERROR|WARNING):' "$now" >$tmp1
296
 
297
if grep -s . $tmp1 > /dev/null; then
298
        echo "Errors and warnings:"
299
        echo
300
        cat $tmp1
301
        echo
302
fi
303
 
304
if [ "$tool" = g++ ]; then
305
   if [ -f $DEVOBINDIR/libio/run-make-check ]; then
306
    cd $DEVOBINDIR/libio
307
    make check >$TMPDIR/clgpp$$ 2>&1
308
    if [ $? != 0 ]; then
309
        echo
310
        echo "libio fails to make check:"
311
        tail -20 $TMPDIR/clgpp$$
312
    fi
313
   fi
314
   if [ -f $DEVOBINDIR/libstdc++/run-make-check ]; then
315
    cd $DEVOBINDIR/libstdc++
316
    make check >$TMPDIR/clgpp$$ 2>&1
317
    if [ $? != 0 ]; then
318
        echo
319
        echo "libstdc++ fails to make check:"
320
        tail -20 $TMPDIR/clgpp$$
321
    fi
322
   fi
323
   if [ -f $DEVOBINDIR/libg++/run-make-check ]; then
324
    cd $DEVOBINDIR/libg++
325
    make check >$TMPDIR/clgpp$$ 2>&1
326
    if [ $? != 0 ]; then
327
        echo
328
        echo "libg++ fails to make check:"
329
        tail -20 $TMPDIR/clgpp$$
330
    fi
331
   fi
332
   rm -f $TMPDIR/clgpp$$
333
   cd $DEVOBINDIR
334
fi
335
 
336
if [ "$devoname" != "" ]; then
337
        if [ "$showchangelog" = 1 ]; then
338
                echo "Here is what's new in the ChangeLog:"
339
                echo
340
                diff -c $LOGDIR/$devoname.ChangeLog $DEVOSRCDIR/ChangeLog
341
                echo
342
                if [ "$tool" = g++ ]; then
343
                        echo
344
                        echo "Here is what's new in the ChangeLog.egcs:"
345
                        echo
346
                        diff -c $LOGDIR/gcc.ChangeLog.egcs $DEVOSRCDIR/ChangeLog.egcs
347
 
348
                        echo
349
                        echo "Here is what's new in the cp/ChangeLog:"
350
                        echo
351
                        diff -c $LOGDIR/g++.ChangeLog $DEVOSRCDIR/cp/ChangeLog
352
                fi
353
                echo
354
        fi
355
        if [ "$update" != no ]; then
356
                # save the old ChangeLog as a reference for next time
357
                rm -f $LOGDIR/$devoname.ChangeLog.BAK
358
                mv $LOGDIR/$devoname.ChangeLog $LOGDIR/$devoname.ChangeLog.BAK 2>/dev/null
359
                $CP $DEVOSRCDIR/ChangeLog $LOGDIR/$devoname.ChangeLog
360
                if [ "$tool" = g++ ]; then
361
                        rm -f $LOGDIR/gcc.ChangeLog.egcs.BAK
362
                        mv $LOGDIR/gcc.ChangeLog.egcs $LOGDIR/gcc.ChangeLog.egcs.BAK 2>/dev/null
363
                        $CP $DEVOSRCDIR/ChangeLog.egcs $LOGDIR/gcc.ChangeLog.egcs
364
 
365
                        rm -f $LOGDIR/g++.ChangeLog.BAK
366
                        mv $LOGDIR/g++.ChangeLog $LOGDIR/g++.ChangeLog.BAK 2>/dev/null
367
                        $CP $DEVOSRCDIR/cp/ChangeLog $LOGDIR/g++.ChangeLog
368
                fi
369
        fi
370
fi
371
 
372
$before | diff - $now | grep -s . >/dev/null
373
if [ $? = 0 ]; then
374
        echo "Details:"
375
        echo
376
        $before | diff - $now
377
        echo
378
fi

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.