xref: /netbsd-src/external/gpl3/gcc.old/dist/contrib/reghunt/bin/gcc-test-compiler-hangs (revision 36ac495d2b3ea2b9d96377b2143ebfedac224b92)
1*36ac495dSmrg#! /bin/sh
2*36ac495dSmrg
3*36ac495dSmrg# Test a bug for which the compiler hangs, using environment variables
4*36ac495dSmrg# set in several reghunt scripts and configuration files.
5*36ac495dSmrg#
6*36ac495dSmrg# Copyright (C) 2007 Free Software Foundation.
7*36ac495dSmrg#
8*36ac495dSmrg# This file is free software; you can redistribute it and/or modify
9*36ac495dSmrg# it under the terms of the GNU General Public License as published by
10*36ac495dSmrg# the Free Software Foundation; either version 3 of the License, or
11*36ac495dSmrg# (at your option) any later version.
12*36ac495dSmrg#
13*36ac495dSmrg# This program is distributed in the hope that it will be useful,
14*36ac495dSmrg# but WITHOUT ANY WARRANTY; without even the implied warranty of
15*36ac495dSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16*36ac495dSmrg# GNU General Public License for more details.
17*36ac495dSmrg#
18*36ac495dSmrg# For a copy of the GNU General Public License, write the the
19*36ac495dSmrg# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20*36ac495dSmrg# Boston, MA 02111-1301, USA.
21*36ac495dSmrg
22*36ac495dSmrgID=$1
23*36ac495dSmrgLOGID=`printf "%04d" ${ID}`
24*36ac495dSmrgLOG=${BUGID}.${LOGID}.out
25*36ac495dSmrgMSGID="bug ${BUGID}, id ${ID}"
26*36ac495dSmrg
27*36ac495dSmrgtrap "echo \"`date`  compiler hang for ${MSGID}\"; pkill -9 cc1; exit $REG_FAIL" SIGUSR1
28*36ac495dSmrgSLEEPCNT=10
29*36ac495dSmrg
30*36ac495dSmrg# Set up to trap the hang.
31*36ac495dSmrgsleep $SLEEPCNT && /bin/kill -s SIGUSR1 0 &
32*36ac495dSmrgSLEEPID=$!
33*36ac495dSmrg
34*36ac495dSmrg# This might hang.
35*36ac495dSmrg$REG_TEST_COMPILER $REG_OPTS $REG_TESTCASE > ${LOG} 2>&1
36*36ac495dSmrg
37*36ac495dSmrg# The command didn't hang.  Capture its return value so we can check
38*36ac495dSmrg# whether it had other unexpected problems.
39*36ac495dSmrgRET=$?
40*36ac495dSmrg
41*36ac495dSmrg# Kill the sleep command so it won't finish normally and cause this
42*36ac495dSmrg# process to get a signal telling it to report a failure.
43*36ac495dSmrg/bin/kill $SLEEPID
44*36ac495dSmrg
45*36ac495dSmrgif [ $RET -eq 0 ]; then
46*36ac495dSmrg    echo "`date`  test compiled successfully for ${MSGID}"
47*36ac495dSmrg    exit $REG_PASS
48*36ac495dSmrgfi
49*36ac495dSmrg
50*36ac495dSmrggrep -q 'No such file or directory' ${LOG}
51*36ac495dSmrgif [ $? -eq 0 ]; then
52*36ac495dSmrg    echo "`date`    unexpected failure: missing file for ${MSGID}"
53*36ac495dSmrg    exit $REG_ERROR
54*36ac495dSmrgfi
55*36ac495dSmrg
56*36ac495dSmrggrep -q "egmentation fault"
57*36ac495dSmrgif [ $? -eq 0 ]; then
58*36ac495dSmrg    echo "`date`   unexpected failure: segfault for ${MSGID}"
59*36ac495dSmrg    exit $REG_ERROR
60*36ac495dSmrgfi
61*36ac495dSmrg
62*36ac495dSmrgecho "`date`    unexpected failure for ${MSGID}"
63*36ac495dSmrgexit $REG_ERROR
64