]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.bin/bmake/unit-tests/Makefile
Update to bmake-20200902
[FreeBSD/FreeBSD.git] / usr.bin / bmake / unit-tests / Makefile
1 # This is a generated file, do NOT edit!
2 # See contrib/bmake/bsd.after-import.mk
3 #
4 # $FreeBSD$
5 # $Id: Makefile,v 1.92 2020/09/02 18:39:29 sjg Exp $
6 #
7 # $NetBSD: Makefile,v 1.130 2020/09/02 05:33:57 rillig Exp $
8 #
9 # Unit tests for make(1)
10 #
11 # The main targets are:
12 #
13 # all:
14 #       run all the tests
15 # test:
16 #       run 'all', and compare to expected results
17 # accept:
18 #       move generated output to expected results
19 #
20 # Settable variables
21 #
22 # TEST_MAKE
23 #       The make program to be tested.
24 #
25 #
26 # Adding a test case
27 #
28 # Each feature should get its own set of tests in its own suitably
29 # named makefile (*.mk), with its own set of expected results (*.exp),
30 # and it should be added to the TESTS list.
31 #
32 # A few *.mk files are helper files for other tests (such as include-sub.mk)
33 # and are thus not added to TESTS.  Such files must be ignored in
34 # src/tests/usr.bin/make/t_make.sh.
35 #
36
37 # Each test is in a sub-makefile.
38 # Keep the list sorted.
39 # Any test that is commented out must be ignored in
40 # src/tests/usr.bin/make/t_make.sh as well.
41 TESTS+=         # archive       # broken on FreeBSD, enabled in t_make.sh
42 TESTS+=         archive-suffix
43 TESTS+=         cmd-interrupt
44 TESTS+=         cmdline
45 TESTS+=         comment
46 TESTS+=         cond-cmp-numeric
47 TESTS+=         cond-cmp-numeric-eq
48 TESTS+=         cond-cmp-numeric-ge
49 TESTS+=         cond-cmp-numeric-gt
50 TESTS+=         cond-cmp-numeric-le
51 TESTS+=         cond-cmp-numeric-lt
52 TESTS+=         cond-cmp-numeric-ne
53 TESTS+=         cond-cmp-string
54 TESTS+=         cond-func
55 TESTS+=         cond-func-commands
56 TESTS+=         cond-func-defined
57 TESTS+=         cond-func-empty
58 TESTS+=         cond-func-exists
59 TESTS+=         cond-func-make
60 TESTS+=         cond-func-target
61 TESTS+=         cond-late
62 TESTS+=         cond-op
63 TESTS+=         cond-op-and
64 TESTS+=         cond-op-not
65 TESTS+=         cond-op-or
66 TESTS+=         cond-op-parentheses
67 TESTS+=         cond-short
68 TESTS+=         cond-token-number
69 TESTS+=         cond-token-plain
70 TESTS+=         cond-token-string
71 TESTS+=         cond-token-var
72 TESTS+=         cond1
73 TESTS+=         cond2
74 TESTS+=         counter
75 TESTS+=         dep
76 TESTS+=         dep-colon
77 TESTS+=         dep-double-colon
78 TESTS+=         dep-exclam
79 TESTS+=         dep-none
80 TESTS+=         dep-var
81 TESTS+=         dep-wildcards
82 TESTS+=         depsrc
83 TESTS+=         depsrc-exec
84 TESTS+=         depsrc-ignore
85 TESTS+=         depsrc-made
86 TESTS+=         depsrc-make
87 TESTS+=         depsrc-meta
88 TESTS+=         depsrc-nometa
89 TESTS+=         depsrc-nometa_cmp
90 TESTS+=         depsrc-nopath
91 TESTS+=         depsrc-notmain
92 TESTS+=         depsrc-optional
93 TESTS+=         depsrc-phony
94 TESTS+=         depsrc-precious
95 TESTS+=         depsrc-recursive
96 TESTS+=         depsrc-silent
97 TESTS+=         depsrc-use
98 TESTS+=         depsrc-usebefore
99 TESTS+=         depsrc-usebefore-double-colon
100 TESTS+=         depsrc-wait
101 TESTS+=         deptgt
102 TESTS+=         deptgt-begin
103 TESTS+=         deptgt-default
104 TESTS+=         deptgt-delete_on_error
105 TESTS+=         deptgt-end
106 TESTS+=         deptgt-error
107 TESTS+=         deptgt-ignore
108 TESTS+=         deptgt-interrupt
109 TESTS+=         deptgt-main
110 TESTS+=         deptgt-makeflags
111 TESTS+=         deptgt-no_parallel
112 TESTS+=         deptgt-nopath
113 TESTS+=         deptgt-notparallel
114 TESTS+=         deptgt-objdir
115 TESTS+=         deptgt-order
116 TESTS+=         deptgt-path
117 TESTS+=         deptgt-path-suffix
118 TESTS+=         deptgt-phony
119 TESTS+=         deptgt-precious
120 TESTS+=         deptgt-shell
121 TESTS+=         deptgt-silent
122 TESTS+=         deptgt-stale
123 TESTS+=         deptgt-suffixes
124 TESTS+=         dir
125 TESTS+=         dir-expand-path
126 TESTS+=         directive
127 TESTS+=         directive-elif
128 TESTS+=         directive-elifdef
129 TESTS+=         directive-elifmake
130 TESTS+=         directive-elifndef
131 TESTS+=         directive-elifnmake
132 TESTS+=         directive-else
133 TESTS+=         directive-endif
134 TESTS+=         directive-error
135 TESTS+=         directive-export
136 TESTS+=         directive-export-env
137 TESTS+=         directive-export-literal
138 TESTS+=         directive-for
139 TESTS+=         directive-for-generating-endif
140 TESTS+=         directive-if
141 TESTS+=         directive-ifdef
142 TESTS+=         directive-ifmake
143 TESTS+=         directive-ifndef
144 TESTS+=         directive-ifnmake
145 TESTS+=         directive-info
146 TESTS+=         directive-undef
147 TESTS+=         directive-unexport
148 TESTS+=         directive-unexport-env
149 TESTS+=         directive-warning
150 TESTS+=         directives
151 TESTS+=         dollar
152 TESTS+=         doterror
153 TESTS+=         dotwait
154 TESTS+=         envfirst
155 TESTS+=         error
156 TESTS+=         # escape        # broken by reverting POSIX changes
157 TESTS+=         export
158 TESTS+=         export-all
159 TESTS+=         export-env
160 TESTS+=         export-variants
161 TESTS+=         forloop
162 TESTS+=         forsubst
163 TESTS+=         hash
164 TESTS+=         impsrc
165 TESTS+=         include-main
166 TESTS+=         lint
167 TESTS+=         make-exported
168 TESTS+=         misc
169 TESTS+=         moderrs
170 TESTS+=         modmatch
171 TESTS+=         modmisc
172 TESTS+=         modts
173 TESTS+=         modword
174 TESTS+=         opt
175 TESTS+=         opt-backwards
176 TESTS+=         opt-chdir
177 TESTS+=         opt-debug
178 TESTS+=         opt-debug-g1
179 TESTS+=         opt-define
180 TESTS+=         opt-env
181 TESTS+=         opt-file
182 TESTS+=         opt-ignore
183 TESTS+=         opt-include-dir
184 TESTS+=         opt-jobs
185 TESTS+=         opt-jobs-internal
186 TESTS+=         opt-keep-going
187 TESTS+=         opt-m-include-dir
188 TESTS+=         opt-no-action
189 TESTS+=         opt-no-action-at-all
190 TESTS+=         opt-query
191 TESTS+=         opt-raw
192 TESTS+=         opt-silent
193 TESTS+=         opt-touch
194 TESTS+=         opt-tracefile
195 TESTS+=         opt-var-expanded
196 TESTS+=         opt-var-literal
197 TESTS+=         opt-warnings-as-errors
198 TESTS+=         opt-where-am-i
199 TESTS+=         opt-x-reduce-exported
200 TESTS+=         order
201 TESTS+=         phony-end
202 TESTS+=         posix
203 TESTS+=         # posix1        # broken by reverting POSIX changes
204 TESTS+=         qequals
205 TESTS+=         recursive
206 TESTS+=         sh
207 TESTS+=         sh-dots
208 TESTS+=         sh-jobs
209 TESTS+=         sh-jobs-error
210 TESTS+=         sh-leading-at
211 TESTS+=         sh-leading-hyphen
212 TESTS+=         sh-leading-plus
213 TESTS+=         sh-meta-chars
214 TESTS+=         sh-multi-line
215 TESTS+=         sh-single-line
216 TESTS+=         # suffixes      # runs into an endless loop (try -dA)
217 TESTS+=         sunshcmd
218 TESTS+=         sysv
219 TESTS+=         ternary
220 TESTS+=         unexport
221 TESTS+=         unexport-env
222 TESTS+=         use-inference
223 TESTS+=         var-class
224 TESTS+=         var-class-cmdline
225 TESTS+=         var-class-env
226 TESTS+=         var-class-global
227 TESTS+=         var-class-local
228 TESTS+=         var-class-local-legacy
229 TESTS+=         var-op
230 TESTS+=         var-op-append
231 TESTS+=         var-op-assign
232 TESTS+=         var-op-default
233 TESTS+=         var-op-expand
234 TESTS+=         var-op-shell
235 TESTS+=         varcmd
236 TESTS+=         vardebug
237 TESTS+=         varfind
238 TESTS+=         varmisc
239 TESTS+=         varmod
240 TESTS+=         varmod-assign
241 TESTS+=         varmod-defined
242 TESTS+=         varmod-edge
243 TESTS+=         varmod-exclam-shell
244 TESTS+=         varmod-extension
245 TESTS+=         varmod-gmtime
246 TESTS+=         varmod-hash
247 TESTS+=         varmod-head
248 TESTS+=         varmod-ifelse
249 TESTS+=         varmod-l-name-to-value
250 TESTS+=         varmod-localtime
251 TESTS+=         varmod-loop
252 TESTS+=         varmod-match
253 TESTS+=         varmod-match-escape
254 TESTS+=         varmod-no-match
255 TESTS+=         varmod-order
256 TESTS+=         varmod-order-reverse
257 TESTS+=         varmod-order-shuffle
258 TESTS+=         varmod-path
259 TESTS+=         varmod-quote
260 TESTS+=         varmod-quote-dollar
261 TESTS+=         varmod-range
262 TESTS+=         varmod-remember
263 TESTS+=         varmod-root
264 TESTS+=         varmod-select-words
265 TESTS+=         varmod-shell
266 TESTS+=         varmod-subst
267 TESTS+=         varmod-subst-regex
268 TESTS+=         varmod-sysv
269 TESTS+=         varmod-tail
270 TESTS+=         varmod-to-abs
271 TESTS+=         varmod-to-lower
272 TESTS+=         varmod-to-many-words
273 TESTS+=         varmod-to-one-word
274 TESTS+=         varmod-to-separator
275 TESTS+=         varmod-to-upper
276 TESTS+=         varmod-undefined
277 TESTS+=         varmod-unique
278 TESTS+=         varname
279 TESTS+=         varname-dollar
280 TESTS+=         varname-dot-alltargets
281 TESTS+=         varname-dot-curdir
282 TESTS+=         varname-dot-includes
283 TESTS+=         varname-dot-includedfromdir
284 TESTS+=         varname-dot-includedfromfile
285 TESTS+=         varname-dot-libs
286 TESTS+=         varname-dot-make-dependfile
287 TESTS+=         varname-dot-make-expand_variables
288 TESTS+=         varname-dot-make-exported
289 TESTS+=         varname-dot-make-jobs
290 TESTS+=         varname-dot-make-jobs-prefix
291 TESTS+=         varname-dot-make-level
292 TESTS+=         varname-dot-make-makefile_preference
293 TESTS+=         varname-dot-make-makefiles
294 TESTS+=         varname-dot-make-meta-bailiwick
295 TESTS+=         varname-dot-make-meta-created
296 TESTS+=         varname-dot-make-meta-files
297 TESTS+=         varname-dot-make-meta-ignore_filter
298 TESTS+=         varname-dot-make-meta-ignore_paths
299 TESTS+=         varname-dot-make-meta-ignore_patterns
300 TESTS+=         varname-dot-make-meta-prefix
301 TESTS+=         varname-dot-make-mode
302 TESTS+=         varname-dot-make-path_filemon
303 TESTS+=         varname-dot-make-pid
304 TESTS+=         varname-dot-make-ppid
305 TESTS+=         varname-dot-make-save_dollars
306 TESTS+=         varname-dot-makeoverrides
307 TESTS+=         varname-dot-newline
308 TESTS+=         varname-dot-objdir
309 TESTS+=         varname-dot-parsedir
310 TESTS+=         varname-dot-parsefile
311 TESTS+=         varname-dot-path
312 TESTS+=         varname-dot-shell
313 TESTS+=         varname-dot-targets
314 TESTS+=         varname-empty
315 TESTS+=         varname-make
316 TESTS+=         varname-make_print_var_on_error
317 TESTS+=         varname-makeflags
318 TESTS+=         varname-pwd
319 TESTS+=         varname-vpath
320 TESTS+=         varparse-dynamic
321 TESTS+=         varquote
322 TESTS+=         varshell
323
324 # Additional environment variables for some of the tests.
325 # The base environment is -i PATH="$PATH".
326 ENV.envfirst=           FROM_ENV=value-from-env
327 ENV.varmisc=            FROM_ENV=env
328 ENV.varmisc+=           FROM_ENV_BEFORE=env
329 ENV.varmisc+=           FROM_ENV_AFTER=env
330
331 # Override make flags for some of the tests; default is -k.
332 # If possible, write ".MAKEFLAGS: -dv" in the test .mk file instead of
333 # settings FLAGS.test=-dv here, since that is closer to the test code.
334 FLAGS.archive=          -dA
335 FLAGS.counter=          -dv
336 FLAGS.directive-ifmake= first second
337 FLAGS.doterror=         # none
338 FLAGS.envfirst=         -e
339 FLAGS.export=           # none
340 FLAGS.lint=             -dL -k
341 FLAGS.opt-debug-g1=     -dg1
342 FLAGS.opt-ignore=       -i
343 FLAGS.opt-keep-going=   -k
344 FLAGS.opt-no-action=    -n
345 FLAGS.opt-query=        -q
346 FLAGS.opt-var-expanded= -v VAR -v VALUE
347 FLAGS.opt-var-literal=  -V VAR -V VALUE
348 FLAGS.opt-warnings-as-errors= -W
349 FLAGS.order=            -j1
350 FLAGS.recursive=        -dL
351 FLAGS.sh-leading-plus=  -n
352 FLAGS.vardebug=         -k -dv FROM_CMDLINE=
353 FLAGS.varmod-match-escape= -dv
354 FLAGS.varname-dot-shell= -dpv
355 FLAGS.varname-empty=    -dv '$${:U}=cmdline-u' '=cmline-plain'
356
357 # Some tests need extra post-processing.
358 SED_CMDS.opt-debug-g1=  -e 's,${.CURDIR},CURDIR,'
359 SED_CMDS.opt-debug-g1+= -e '/Global Variables:/,/Suffixes:/d'
360 SED_CMDS.sh-dots=       -e 's,^.*\.\.\.:.*,<normalized: ...: not found>,'
361 SED_CMDS.varmod-subst-regex+= \
362                         -e 's,\(Regex compilation error:\).*,\1 (details omitted),'
363 SED_CMDS.varmod-edge+=  -e 's, line [0-9]*:, line omitted:,'
364 SED_CMDS.varshell+=     -e 's,^${.SHELL:T}: ,,'
365 SED_CMDS.varshell+=     -e '/command/s,No such.*,not found,'
366 SED_CMDS.varname-dot-shell=     -e 's, = /.*, = (details omitted),'
367 SED_CMDS.varname-dot-shell+=    -e 's,"/[^"]*","(details omitted)",'
368 SED_CMDS.varname-dot-shell+=    -e 's,\[/[^]]*\],[(details omitted)],'
369
370 # Some tests need an additional round of postprocessing.
371 POSTPROC.counter=       ${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
372 POSTPROC.deptgt-suffixes= \
373                         ${TOOL_SED} -n -e '/^\#\*\*\* Suffixes/,/^\#\*/p'
374 POSTPROC.vardebug=      ${TOOL_SED} -n -e '/:RELEVANT = yes/,/:RELEVANT = no/p'
375 POSTPROC.varmod-match-escape= ${TOOL_SED} -n -e '/^Pattern/p'
376 POSTPROC.varname-dot-shell= \
377                         awk '/\.SHELL/ || /^ParseReadLine/'
378 POSTPROC.varname-empty= ${TOOL_SED} -n -e '/^Var_Set/p' -e '/^out:/p'
379
380 # Some tests reuse other tests, which makes them unnecessarily fragile.
381 export-all.rawout: export.mk
382 unexport.rawout: export.mk
383 unexport-env.rawout: export.mk
384
385 # End of the configuration section.
386
387 .MAIN: all
388
389 .sinclude "Makefile.inc"
390 .sinclude "Makefile.config"
391
392 UNIT_TESTS:= ${srcdir}
393 .PATH: ${UNIT_TESTS}
394
395 OUTFILES=       ${TESTS:=.out}
396
397 all: ${OUTFILES}
398
399 CLEANFILES=             *.rawout *.out *.status *.tmp *.core *.tmp
400 CLEANFILES+=            obj*.[och] lib*.a       # posix1.mk
401 CLEANFILES+=            issue* .[ab]*           # suffixes.mk
402 CLEANDIRS=              dir dummy               # posix1.mk
403
404 clean:
405         rm -f ${CLEANFILES}
406         rm -rf ${CLEANDIRS}
407
408 TEST_MAKE?=     ${.MAKE}
409 TOOL_SED?=      sed
410 TOOL_TR?=       tr
411 TOOL_DIFF?=     diff
412 DIFF_FLAGS?=    -u
413
414 .if defined(.PARSEDIR)
415 # ensure consistent results from sort(1)
416 LC_ALL=         C
417 LANG=           C
418 .export LANG LC_ALL
419 .endif
420
421 .if ${.MAKE.MODE:Unormal:Mmeta} != ""
422 # we don't need the noise
423 _MKMSG_TEST= :
424 .endif
425
426 # the tests are actually done with sub-makes.
427 .SUFFIXES: .mk .rawout .out
428 .mk.rawout:
429         @${_MKMSG_TEST:Uecho '#      test '} ${.PREFIX}
430         @set -eu; \
431         cd ${.OBJDIR}; \
432         env -i PATH="$$PATH" ${ENV.${.TARGET:R}} \
433           ${TEST_MAKE} \
434             -r -C ${.CURDIR} -f ${.IMPSRC} \
435             ${FLAGS.${.TARGET:R}:U-k} \
436             > ${.TARGET}.tmp 2>&1 \
437         && status=$$? || status=$$?; \
438         echo $$status > ${.TARGET:R}.status
439         @mv ${.TARGET}.tmp ${.TARGET}
440
441 # Post-process the test output so that the results can be compared.
442 #
443 # always pretend .MAKE was called 'make'
444 _SED_CMDS+=     -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
445 _SED_CMDS+=     -e 's,${TEST_MAKE:S,.,\\.,g},make,'
446 # replace anything after 'stopped in' with unit-tests
447 _SED_CMDS+=     -e '/stopped/s, /.*, unit-tests,'
448 # strip ${.CURDIR}/ from the output
449 _SED_CMDS+=     -e 's,${.CURDIR:S,.,\\.,g}/,,g'
450 _SED_CMDS+=     -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
451
452 .rawout.out:
453         @${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.TARGET:R}} \
454           < ${.IMPSRC} > ${.TARGET}.tmp1
455         @${POSTPROC.${.TARGET:R}:Ucat} < ${.TARGET}.tmp1 > ${.TARGET}.tmp2
456         @rm ${.TARGET}.tmp1
457         @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp2
458         @mv ${.TARGET}.tmp2 ${.TARGET}
459
460 # Compare all output files
461 test:   ${OUTFILES} .PHONY
462         @failed= ; \
463         for test in ${TESTS}; do \
464           ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
465           || failed="$${failed}$${failed:+ }$${test}" ; \
466         done ; \
467         if [ -n "$${failed}" ]; then \
468           echo "Failed tests: $${failed}" ; false ; \
469         else \
470           echo "All tests passed" ; \
471         fi
472
473 accept:
474         @for test in ${TESTS}; do \
475           cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
476           || { echo "Replacing $${test}.exp" ; \
477                cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
478         done
479
480 .if exists(${TEST_MAKE})
481 ${TESTS:=.rawout}: ${TEST_MAKE} ${.PARSEDIR}/Makefile
482 .endif
483
484 .sinclude <bsd.obj.mk>