]> git.ipfire.org Git - thirdparty/gcc.git/blame - fixincludes/check.tpl
Handle failure to determine pointer provenance conservatively [PR104069].
[thirdparty/gcc.git] / fixincludes / check.tpl
CommitLineData
865e0a83 1[= autogen5 template sh=check.sh =]
7a544ce1
BK
2[=
3#
a3d37119 4# This file contains the shell template to run tests on the fixes
7a544ce1
BK
5#
6=]#!/bin/sh
7
8set -e
5d7d28c2 9TESTDIR=tests
1e6347d8 10TESTBASE=`cd $1;${PWDCMD-pwd}`
5d7d28c2
BK
11
12[ -d ${TESTDIR} ] || mkdir ${TESTDIR}
13cd ${TESTDIR}
1e6347d8 14TESTDIR=`${PWDCMD-pwd}`
7a544ce1
BK
15
16TARGET_MACHINE='*'
1e6347d8
RO
17DESTDIR=`${PWDCMD-pwd}`/res
18SRCDIR=`${PWDCMD-pwd}`/inc
7a544ce1 19FIND_BASE='.'
7a9cdb10 20VERBOSE=[=` echo ${VERBOSE-1} `=]
1e6347d8 21INPUT=`${PWDCMD-pwd}`
62a99405 22ORIGDIR=${INPUT}
7a544ce1 23
62a99405 24export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE INPUT ORIGDIR
7a544ce1 25
5d7d28c2 26rm -rf ${DESTDIR} ${SRCDIR}
7a544ce1 27mkdir ${DESTDIR} ${SRCDIR}
8d75cd1f
BK
28(
29[=
30 (shellf
31 "for f in %s
32 do case $f in
33 */* ) echo $f | sed 's;/[^/]*$;;' ;;
34 esac
35 done | sort -u | \
36 while read g
37 do echo \" mkdir \\${SRCDIR}/$g || mkdir -p \\${SRCDIR}/$g || exit 1\"
38 done" (join " " (stack "fix.files")) ) =]
39) 2> /dev/null[= # suppress 'No such file or directory' messages =]
5d7d28c2 40cd inc
7a544ce1 41[=
8d75cd1f 42(define sfile "")
7b78a14a 43(define HACK "")
8d75cd1f 44(define dfile "") =][=
7a544ce1 45
8d75cd1f 46FOR fix =][=
5d7d28c2 47
8d75cd1f 48 IF (> (count "test_text") 1) =][=
7b78a14a 49 (set! HACK (string-upcase! (get "hackname")))
8d75cd1f
BK
50 (set! sfile (if (exist? "files") (get "files[]") "testing.h"))
51 (set! dfile (string-append
52 (if (*==* sfile "/")
53 (shellf "echo \"%s\"|sed 's,/[^/]*,/,'" sfile )
54 "" )
55 (string-tr! (get "hackname") "_A-Z" "-a-z")
56 ) ) =][=
57
58 FOR test_text (for-from 1) =]
59cat >> [=(. sfile)=] <<_HACK_EOF_
5d7d28c2
BK
60
61
7b78a14a 62#if defined( [=(. HACK)=]_CHECK_[=(for-index)=] )
5d7d28c2 63[=test_text=]
7b78a14a 64#endif /* [=(. HACK)=]_CHECK_[=(for-index)=] */
5d7d28c2 65_HACK_EOF_
8d75cd1f
BK
66echo [=(. sfile)=] | ../../fixincl
67mv -f [=(. sfile)=] [=(. dfile)=]-[=(for-index)=].h
68[ -f ${DESTDIR}/[=(. sfile)=] ] && [=#
69 =]mv ${DESTDIR}/[=(. sfile)=] ${DESTDIR}/[=(. dfile)=]-[=(for-index)=].h[=
70
865e0a83 71 ENDFOR test_text =][=
8d75cd1f
BK
72
73 ENDIF multi-test =][=
5d7d28c2 74
865e0a83 75ENDFOR fix
5d7d28c2
BK
76
77=][=
78
7b78a14a
BK
79FOR fix =][=
80 (set! HACK (string-upcase! (get "hackname"))) =][=
7a544ce1 81
865e0a83 82 IF (not (exist? "test_text")) =][=
7b78a14a
BK
83 (if (not (exist? "replace"))
84 (error (sprintf "include fix '%s' has no test text"
85 (get "hackname") )) )
86 =][=
87 ELSE =]
067e2f06
TG
88cat >> [= (raw-shell-str (if (exist? "files") (get "files[0]") "testing.h"))
89 =] <<_HACK_EOF_
7a544ce1
BK
90
91
7b78a14a 92#if defined( [=(. HACK)=]_CHECK )
5d7d28c2 93[=test_text=]
7b78a14a 94#endif /* [=(. HACK)=]_CHECK */
7a544ce1 95_HACK_EOF_
865e0a83 96[=ENDIF =][=
7a544ce1 97
865e0a83 98ENDFOR fix
7a544ce1
BK
99
100=]
101
7e416541 102export TEST_MODE=true
7b78a14a 103find . -type f | sed 's;^\./;;' | sort | ../../fixincl
5d7d28c2
BK
104cd ${DESTDIR}
105
106exitok=true
35dfe415 107
5d7d28c2
BK
108find * -type f -print > ${TESTDIR}/LIST
109
a83b3e4f
BK
110# Special hack for sys/types.h: the #define-d types for size_t,
111# ptrdiff_t and wchar_t are different for each port. Therefore,
112# strip off the defined-to type so that the test results are the
113# same for all platforms.
114#
115sed 's/\(#define __[A-Z_]*_TYPE__\).*/\1/' sys/types.h > XX
116mv -f XX sys/types.h
117
118# The following subshell weirdness is for saving an exit
119# status from within a while loop that reads input. If you can
120# think of a cleaner way, suggest away, please...
121#
5d7d28c2
BK
122exitok=`
123exec < ${TESTDIR}/LIST
35dfe415
BK
124while read f
125do
716028e4
TK
126 if [ -n "$MSYSTEM" -o -n "$DJGPP" ]
127 then
128 # On MinGW and DJGPP convert line endings to avoid false positives
129 mv $f $f.dos; tr -d '\r' < $f.dos > $f; rm $f.dos
130 fi
5d7d28c2
BK
131 if [ ! -f ${TESTBASE}/$f ]
132 then
133 echo "Newly fixed header: $f" >&2
134 exitok=false
135
136 elif cmp $f ${TESTBASE}/$f >&2
35dfe415 137 then
5d7d28c2
BK
138 :
139
35dfe415 140 else
6bf1ffe1 141 ${DIFF:-diff} -c $f ${TESTBASE}/$f >&2 || :
5d7d28c2 142 exitok=false
35dfe415 143 fi
5d7d28c2
BK
144done
145echo $exitok`
35dfe415 146
5d7d28c2 147cd $TESTBASE
7a544ce1 148
cfce0488
EG
149find * -type f ! -name .DS_Store ! -name CVS ! -name .svn -print \
150> ${TESTDIR}/LIST
7a544ce1 151
5d7d28c2
BK
152exitok=`
153exec < ${TESTDIR}/LIST
154while read f
155do
156 if [ -s $f ] && [ ! -f ${DESTDIR}/$f ]
157 then
158 echo "Missing header fix: $f" >&2
159 exitok=false
160 fi
161done
162echo $exitok`
7a544ce1 163
5d7d28c2
BK
164echo
165if $exitok
166then
167 cd ${TESTDIR}
168 rm -rf inc res LIST
169 cd ..
170 rmdir ${TESTDIR} > /dev/null 2>&1 || :
171 echo All fixinclude tests pass >&2
172else
173 echo There were fixinclude test FAILURES >&2
174fi
175$exitok[=
7a544ce1 176
abaa8559 177(if (defined? 'set-writable) (set-writable))
5d7d28c2 178
7a544ce1 179=]