Debian Codegraph @

test/Gentests

raw
1 #!/usr/bin/gawk -f
2
3 # This program should generate Maketests
4
5 BEGIN {
6 # read the list of files
7 for (i = 2; i < ARGC; i++)
8 files[ARGV[i]]
9
10 # throw it away
11 ARGC = 2
12
13 ntests = 0
14
15 Locale["C"] = "C"
16 Locale["EN"] = "en_US.UTF-8"
17 Locale["FR"] = "fr_FR.UTF-8"
18 Locale["GR"] = "el_GR.iso88597"
19 Locale["JP"] = "ja_JP.UTF-8"
20 Locale["RU"] = "ru_RU.UTF-8"
21 }
22
23 # process the file Makefile.am:
24
25 /^EXTRA_DIST *=/,/[^\\]$/ {
26 gsub(/(^EXTRA_DIST *=|\\$)/,"")
27 for (i = 1; i <= NF; i++)
28 extra_dist[$i]
29 next
30 }
31
32 /^[[:upper:]_]*_TESTS *=/,/[^\\]$/ {
33 gsub(/(^[[:upper:]_]*_TESTS *=|\\$)/,"")
34 for (i = 1; i <= NF; i++)
35 tests[++ntests] = $i
36 next
37 }
38
39 /^NEED_DEBUG *=/,/[^\\]$/ {
40 gsub(/(^NEED_DEBUG *=|\\$)/,"")
41 for (i = 1; i <= NF; i++)
42 debug[$i]
43 next
44 }
45
46 /^NEED_LINT *=/,/[^\\]$/ {
47 gsub(/(^NEED_LINT *=|\\$)/,"")
48 for (i = 1; i <= NF; i++)
49 lint[$i]
50 next
51 }
52
53 /^NEED_LINT_OLD *=/,/[^\\]$/ {
54 gsub(/(^NEED_LINT_OLD *=|\\$)/,"")
55 for (i = 1; i <= NF; i++)
56 lint_old[$i]
57 next
58 }
59
60 /^NEED_MPFR *=/,/[^\\]$/ {
61 gsub(/(^NEED_MPFR *=|\\$)/,"")
62 for (i = 1; i <= NF; i++) {
63 simple_mpfr[$i]
64 tests[++ntests] = $i
65 }
66 next
67 }
68
69 /^NEED_NONDEC *=/,/[^\\]$/ {
70 gsub(/(^NEED_NONDEC *=|\\$)/,"")
71 for (i = 1; i <= NF; i++)
72 nondec[$i]
73 next
74 }
75
76 /^NEED_PRETTY *=/,/[^\\]$/ {
77 gsub(/(^NEED_PRETTY *=|\\$)/,"")
78 for (i = 1; i <= NF; i++)
79 pretty[$i]
80 next
81 }
82
83 /^NEED_POSIX *=/,/[^\\]$/ {
84 gsub(/(^NEED_POSIX *=|\\$)/,"")
85 for (i = 1; i <= NF; i++)
86 posix[$i]
87 next
88 }
89
90 /^NEED_RE_INTERVAL *=/,/[^\\]$/ {
91 gsub(/(^NEED_RE_INTERVAL *=|\\$)/,"")
92 for (i = 1; i <= NF; i++)
93 re_interval[$i]
94 next
95 }
96
97 /^NEED_TRADITIONAL *=/,/[^\\]$/ {
98 gsub(/(^NEED_TRADITIONAL *=|\\$)/,"")
99 for (i = 1; i <= NF; i++)
100 traditional[$i]
101 next
102 }
103
104 /^NEED_SANDBOX *=/,/[^\\]$/ {
105 gsub(/(^NEED_SANDBOX *=|\\$)/,"")
106 for (i = 1; i <= NF; i++)
107 sandbox[$i]
108 next
109 }
110
111 /^NEED_CSV *=/,/[^\\]$/ {
112 gsub(/(^NEED_CSV *=|\\$)/,"")
113 for (i = 1; i <= NF; i++)
114 csv[$i]
115 next
116 }
117
118 /^GENTESTS_UNUSED *=/,/[^\\]$/ {
119 gsub(/(^GENTESTS_UNUSED *=|\\$)/,"")
120 for (i = 1; i <= NF; i++)
121 unused[$i]
122 next
123 }
124
125 # Tests needing a particular locale
126 /^NEED_LOCALE_.* *=/,/[^\\]$/ {
127 if (/^NEED/)
128 cur_locale = gensub(/^NEED_LOCALE_([[:alnum:]]+).*/, "\\1", 1, $1)
129
130 gsub(/^NEED_LOCALE_.* *=|\\$/, "")
131 for (i = 1; i <= NF; i++) {
132 locale_tests[cur_locale][$i]
133 all_locale_tests[$i]
134 }
135 }
136
137 # Tests that fail on z/OS
138 /EXPECTED_FAIL_ZOS *=/,/[^\\]$/ {
139 gsub(/(^EXPECTED_FAIL_ZOS *=|\\$)/,"")
140 for (i = 1; i <= NF; i++)
141 {
142 zos_fail[$i]
143 }
144 next
145 }
146
147 /^[[:alpha:]_][-[:alnum:]_]*:/ {
148 # remember all targets from Makefile.am
149 sub(/:.*/,"")
150 targets[$0]
151 }
152
153 # Now write the output file:
154 END {
155 # this line tells automake to keep the comment with the rules:
156 print "Gt-dummy:"
157 print "# file Maketests, generated from Makefile.am by the Gentests program"
158
159 for (i = 1; i <= ntests; i++) {
160 x = tests[i]
161 if (!(x in targets))
162 generate(x)
163 }
164
165 print "# end of file Maketests"
166 }
167
168 function generate_shell(x, s)
169 {
170 delete files[x".sh"]
171
172 s = ""
173 if (x".in" in files) {
174 s = "\"$(srcdir)\"/[email protected]"
175 delete files[x".in"]
176 }
177
178 print x ":"
179 printf "\t@echo $@\n"
180
181 printf "\t@-$(LOCALES) AWK=\"$(AWKPROG) $(GAWK_TEST_ARGS)\" \"$(srcdir)\"/[email protected] %s > _$@ 2>&1 || echo EXIT CODE: $$? >>_$@\n", s
182 printf "\t@-$(CMP) \"$(srcdir)\"/[email protected] _$@ && rm -f _$@\n\n"
183
184 }
185
186 function generate(x, s, i, locale_string)
187 {
188 if (x".sh" in files)
189 return generate_shell(x)
190
191 if (!(x".awk" in files))
192 printf "WARNING: file `%s.awk' not found.\n", x > "/dev/stderr"
193 else
194 delete files[x".awk"]
195
196 print x ":"
197
198 s = ""
199 if (x in lint) {
200 s = s " --lint"
201 delete lint[x]
202 }
203 if (x in lint_old) {
204 s = s " --lint-old"
205 delete lint_old[x]
206 }
207 if (x in simple_mpfr) {
208 s = s " -M"
209 delete simple_mpfr[x]
210 }
211 if (x in posix) {
212 s = s " --posix"
213 delete posix[x]
214 }
215 if (x in traditional) {
216 s = s " --traditional"
217 delete traditional[x]
218 }
219 if (x in sandbox) {
220 s = s " --sandbox"
221 delete sandbox[x]
222 }
223 if (x in pretty) {
224 s = s " --pretty-print=_$@"
225 delete pretty[x]
226 }
227 if (x in debug) {
228 s = s " --debug"
229 delete debug[x]
230 }
231 if (x in nondec) {
232 s = s " --non-decimal-data"
233 delete nondec[x]
234 }
235 if (x in re_interval) {
236 s = s " --re-interval"
237 delete re_interval[x]
238 }
239 if (x in csv) {
240 s = s " --csv"
241 delete csv[x]
242 }
243 if (x".in" in files) {
244 s = s " < \"$(srcdir)\"/[email protected]"
245 delete files[x".in"]
246 }
247
248 if (x in zos_fail) {
249 printf "\t@echo $@ $(ZOS_FAIL)\n"
250 delete zos_fail[x]
251 } else
252 printf "\t@echo $@\n"
253
254 # default is the leading tab and @
255 locale_string = "\t@-"
256 if (x in all_locale_tests) {
257 delete all_locale_tests[x]
258 for (i in locale_tests) {
259 if (x in locale_tests[i]) {
260 locale_string = sprintf("\t@-[ -z \"$$GAWKLOCALE\" ] && GAWKLOCALE=%s; export GAWKLOCALE; \\\n\t", Locale[i])
261 delete locale_tests[i][x]
262 break
263 }
264 }
265 }
266
267 printf "%s", locale_string
268 printf "AWKPATH=\"$(srcdir)\" $(AWK) -f [email protected] %s >_$@ 2>&1 || echo EXIT CODE: $$? >>_$@\n", s
269
270 if ((x "-mpfr.ok") in extra_dist) {
271 printf "\t@-if echo \"$$GAWK_TEST_ARGS\" | egrep -s -e '-M|--bignum' > /dev/null ; \\\n"
272 printf "\tthen $(CMP) \"$(srcdir)\"/[email protected] _$@ && rm -f _$@ ; \\\n"
273 printf "\telse $(CMP) \"$(srcdir)\"/[email protected] _$@ && rm -f _$@ ; fi\n\n"
274 } else {
275 printf "\t@-$(CMP) \"$(srcdir)\"/[email protected] _$@ && rm -f _$@\n\n"
276 }
277 }
278
279 END {
280 for (x in lint)
281 if (!(x in targets))
282 printf "WARNING: --lint target `%s' is missing.\n", x > "/dev/stderr"
283 for (x in lint_old)
284 if (!(x in targets))
285 printf "WARNING: --lint-old target `%s' is missing.\n", x > "/dev/stderr"
286 for (x in simple_mpfr)
287 if (!(x in targets))
288 printf "WARNING: -M target `%s' is missing.\n", x > "/dev/stderr"
289 for (x in posix)
290 if (!(x in targets))
291 printf "WARNING: --posix target `%s' is missing.\n", x > "/dev/stderr"
292 for (x in traditional)
293 if (!(x in targets))
294 printf "WARNING: --traditional target `%s' is missing.\n", x > "/dev/stderr"
295 for (x in sandbox)
296 if (!(x in targets))
297 printf "WARNING: --sandbox target `%s' is missing.\n", x > "/dev/stderr"
298 for (x in pretty)
299 if (!(x in targets))
300 printf "WARNING: --pretty-print target `%s' is missing.\n", x > "/dev/stderr"
301 for (x in debug)
302 if (!(x in targets))
303 printf "WARNING: --debug target `%s' is missing.\n", x > "/dev/stderr"
304 for (x in nondec)
305 if (!(x in targets))
306 printf "WARNING: --non-decimal-data target `%s' is missing.\n", x > "/dev/stderr"
307 for (x in re_interval)
308 if (!(x in targets))
309 printf "WARNING: --re-interval target `%s' is missing.\n", x > "/dev/stderr"
310 for (x in locale_tests)
311 for (y in locale_tests[x])
312 if (!(y in targets))
313 printf("WARNING: Locale `%s' target `%s' is missing.\n", x, y) > "/dev/stderr"
314 if ("check_zos" in ENVIRON)
315 for (x in zos_fail)
316 printf "WARNING: check target `%s' for $(ZOS_FAIL).\n", x > "/dev/stderr"
317
318 for (x in files)
319 if (!(x in unused) && \
320 !(gensub(/\.(awk|in|sh)$/,"",1,x) in targets))
321 printf "WARNING: unused file `%s'.\n", x > "/dev/stderr"
322 }