0
|
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;${PWDCMD-pwd}`
|
|
11
|
|
12 [ -d ${TESTDIR} ] || mkdir ${TESTDIR}
|
|
13 cd ${TESTDIR}
|
|
14 TESTDIR=`${PWDCMD-pwd}`
|
|
15
|
|
16 TARGET_MACHINE='*'
|
|
17 DESTDIR=`${PWDCMD-pwd}`/res
|
|
18 SRCDIR=`${PWDCMD-pwd}`/inc
|
|
19 FIND_BASE='.'
|
|
20 VERBOSE=[=` echo ${VERBOSE-1} `=]
|
|
21 INPUT=`${PWDCMD-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 [=
|
|
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 =]
|
|
40 cd inc
|
|
41 [=
|
|
42 (define sfile "")
|
|
43 (define HACK "")
|
|
44 (define dfile "") =][=
|
|
45
|
|
46 FOR fix =][=
|
|
47
|
|
48 IF (> (count "test_text") 1) =][=
|
|
49 (set! HACK (string-upcase! (get "hackname")))
|
|
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) =]
|
|
59 cat >> [=(. sfile)=] <<_HACK_EOF_
|
|
60
|
|
61
|
|
62 #if defined( [=(. HACK)=]_CHECK_[=(for-index)=] )
|
|
63 [=test_text=]
|
|
64 #endif /* [=(. HACK)=]_CHECK_[=(for-index)=] */
|
|
65 _HACK_EOF_
|
|
66 echo [=(. sfile)=] | ../../fixincl
|
|
67 mv -f [=(. sfile)=] [=(. dfile)=]-[=(for-index)=].h
|
|
68 [ -f ${DESTDIR}/[=(. sfile)=] ] && [=#
|
|
69 =]mv ${DESTDIR}/[=(. sfile)=] ${DESTDIR}/[=(. dfile)=]-[=(for-index)=].h[=
|
|
70
|
|
71 ENDFOR test_text =][=
|
|
72
|
|
73 ENDIF multi-test =][=
|
|
74
|
|
75 ENDFOR fix
|
|
76
|
|
77 =][=
|
|
78
|
|
79 FOR fix =][=
|
|
80 (set! HACK (string-upcase! (get "hackname"))) =][=
|
|
81
|
|
82 IF (not (exist? "test_text")) =][=
|
|
83 (if (not (exist? "replace"))
|
|
84 (error (sprintf "include fix '%s' has no test text"
|
|
85 (get "hackname") )) )
|
|
86 =][=
|
|
87 ELSE =]
|
|
88 cat >> [=
|
|
89 IF (exist? "files") =][=
|
|
90 files[0] =][=
|
|
91 ELSE =]testing.h[=
|
|
92 ENDIF =] <<_HACK_EOF_
|
|
93
|
|
94
|
|
95 #if defined( [=(. HACK)=]_CHECK )
|
|
96 [=test_text=]
|
|
97 #endif /* [=(. HACK)=]_CHECK */
|
|
98 _HACK_EOF_
|
|
99 [=ENDIF =][=
|
|
100
|
|
101 ENDFOR fix
|
|
102
|
|
103 =]
|
|
104
|
|
105 find . -type f | sed 's;^\./;;' | sort | ../../fixincl
|
|
106 cd ${DESTDIR}
|
|
107
|
|
108 exitok=true
|
|
109
|
|
110 find * -type f -print > ${TESTDIR}/LIST
|
|
111
|
|
112 # Special hack for sys/types.h: the #define-d types for size_t,
|
|
113 # ptrdiff_t and wchar_t are different for each port. Therefore,
|
|
114 # strip off the defined-to type so that the test results are the
|
|
115 # same for all platforms.
|
|
116 #
|
|
117 sed 's/\(#define __[A-Z_]*_TYPE__\).*/\1/' sys/types.h > XX
|
|
118 mv -f XX sys/types.h
|
|
119
|
|
120 # The following subshell weirdness is for saving an exit
|
|
121 # status from within a while loop that reads input. If you can
|
|
122 # think of a cleaner way, suggest away, please...
|
|
123 #
|
|
124 exitok=`
|
|
125 exec < ${TESTDIR}/LIST
|
|
126 while read f
|
|
127 do
|
|
128 if [ ! -f ${TESTBASE}/$f ]
|
|
129 then
|
|
130 echo "Newly fixed header: $f" >&2
|
|
131 exitok=false
|
|
132
|
|
133 elif cmp $f ${TESTBASE}/$f >&2
|
|
134 then
|
|
135 :
|
|
136
|
|
137 else
|
|
138 ${DIFF:-diff} -c $f ${TESTBASE}/$f >&2 || :
|
|
139 exitok=false
|
|
140 fi
|
|
141 done
|
|
142 echo $exitok`
|
|
143
|
|
144 cd $TESTBASE
|
|
145
|
|
146 find * -type f -print | \
|
|
147 fgrep -v 'CVS/' | \
|
|
148 fgrep -v '.svn/' > ${TESTDIR}/LIST
|
|
149
|
|
150 exitok=`
|
|
151 exec < ${TESTDIR}/LIST
|
|
152 while read f
|
|
153 do
|
|
154 if [ -s $f ] && [ ! -f ${DESTDIR}/$f ]
|
|
155 then
|
|
156 echo "Missing header fix: $f" >&2
|
|
157 exitok=false
|
|
158 fi
|
|
159 done
|
|
160 echo $exitok`
|
|
161
|
|
162 echo
|
|
163 if $exitok
|
|
164 then
|
|
165 cd ${TESTDIR}
|
|
166 rm -rf inc res LIST
|
|
167 cd ..
|
|
168 rmdir ${TESTDIR} > /dev/null 2>&1 || :
|
|
169 echo All fixinclude tests pass >&2
|
|
170 else
|
|
171 echo There were fixinclude test FAILURES >&2
|
|
172 fi
|
|
173 $exitok[=
|
|
174
|
|
175 (if (defined? 'set-writable) (set-writable))
|
|
176
|
|
177 =]
|