OSDN Git Service

592a69b1f08451522409a8cbf5797e4da03d3638
[pf3gnuchains/gcc-fork.git] / gcc / fixinc / check.tpl
1 [= autogen5 template sh=check.sh =]
2 [=
3 #
4 #  This file contanes the shell template to run tests on the fixes
5 #
6 =]#!/bin/sh
7
8 set -e
9 TESTDIR=tests
10 TESTBASE=`cd $1;pwd`
11
12 [ -d ${TESTDIR} ] || mkdir ${TESTDIR}
13 cd ${TESTDIR}
14 TESTDIR=`pwd`
15
16 TARGET_MACHINE='*'
17 DESTDIR=`pwd`/res
18 SRCDIR=`pwd`/inc
19 FIND_BASE='.'
20 VERBOSE=1
21 INPUT=`pwd`
22 ORIGDIR=${INPUT}
23
24 export TARGET_MACHINE DESTDIR SRCDIR FIND_BASE VERBOSE INPUT ORIGDIR
25
26 rm -rf ${DESTDIR} ${SRCDIR}
27 mkdir ${DESTDIR} ${SRCDIR}
28
29 ( cd ${SRCDIR}
30   set +e
31   for f in [=
32
33   (shellf "echo `
34
35   for f in %s
36   do case $f in
37      */* ) echo $f | sed 's;/[^/]*$;;' ;;
38      esac
39   done | sort -u
40
41   ` " (join " " (stack "fix.files"))  ) =]
42   do
43     mkdir $f || mkdir -p $f
44   done ) > /dev/null 2>&1
45
46 cd inc
47 [=
48
49 FOR fix =][=
50
51   IF (> (count "test_text") 1) =]
52 #
53 #  [=hackname=] has [=(count "test_text")=] tests
54 #
55 sfile=[=
56     IF (exist? "files") =][=
57       files[] =][=
58     ELSE  =]testing.h[=
59     ENDIF =][=
60     FOR test_text FROM 1 =]
61 dfile=`dirname $sfile`/[=(string-tr! (get "hackname") "_A-Z" "-a-z")
62                         =]-[=(for-index)=].h
63 cat >> $sfile <<_HACK_EOF_
64
65
66 #if defined( [=(string-upcase! (get "hackname"))=]_CHECK_[=(for-index)=] )
67 [=test_text=]
68 #endif  /* [=(string-upcase! (get "hackname"))=]_CHECK_[=(for-index)=] */
69 _HACK_EOF_
70 echo $sfile | ../../fixincl
71 mv -f $sfile $dfile
72 [ -f ${DESTDIR}/$sfile ] && mv ${DESTDIR}/$sfile ${DESTDIR}/$dfile[=
73     ENDFOR  test_text =][=
74   ENDIF               =][=
75
76 ENDFOR  fix
77
78 =][=
79
80 FOR fix =][=
81
82   IF (not (exist? "test_text")) =][=
83     IF (not (exist? "replace")) =]
84 echo No test for [=hackname=] in inc/[=
85       IF (exist? "files")       =][=
86         files[0] =][=
87       ELSE  =]testing.h[=
88       ENDIF =][=
89     ENDIF   =][=
90   ELSE      =]
91 cat >> [=
92     IF (exist? "files") =][=
93       files[0] =][=
94     ELSE =]testing.h[=
95     ENDIF =] <<_HACK_EOF_
96
97
98 #if defined( [=(string-upcase! (get "hackname"))=]_CHECK )
99 [=test_text=]
100 #endif  /* [=(string-upcase! (get "hackname"))=]_CHECK */
101 _HACK_EOF_
102 [=ENDIF =][=
103
104 ENDFOR  fix
105
106 =]
107
108 find . -type f | sed 's;\./;;' | sort | ../../fixincl
109 cd ${DESTDIR}
110
111 exitok=true
112
113 find * -type f -print > ${TESTDIR}/LIST
114
115 #  Special hack for sys/types.h:  the #define-d types for size_t,
116 #  ptrdiff_t and wchar_t are different for each port.  Therefore,
117 #  strip off the defined-to type so that the test results are the
118 #  same for all platforms.
119 #
120 sed 's/\(#define __[A-Z_]*_TYPE__\).*/\1/' sys/types.h > XX
121 mv -f XX sys/types.h
122
123 #  The following subshell weirdness is for saving an exit
124 #  status from within a while loop that reads input.  If you can
125 #  think of a cleaner way, suggest away, please...
126 #
127 exitok=`
128 exec < ${TESTDIR}/LIST
129 while read f
130 do
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
137   then
138     :
139
140   else
141     diff -c $f ${TESTBASE}/$f >&2 || :
142     exitok=false
143   fi
144 done
145 echo $exitok`
146
147 cd $TESTBASE
148
149 find * -type f -print | \
150 fgrep -v 'CVS/' > ${TESTDIR}/LIST
151
152 exitok=`
153 exec < ${TESTDIR}/LIST
154 while read f
155 do
156   if [ -s $f ] && [ ! -f ${DESTDIR}/$f ]
157   then
158     echo "Missing header fix:  $f" >&2
159     exitok=false
160   fi
161 done
162 echo $exitok`
163
164 echo
165 if $exitok
166 then
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
172 else
173   echo There were fixinclude test FAILURES  >&2
174 fi
175 $exitok[=
176
177 (set-writable)
178
179 =]