opnsense-src/usr.bin/bmake/unit-tests/Makefile

176 lines
4.2 KiB
Makefile
Raw Normal View History

# $FreeBSD$
# $Id: Makefile,v 1.60 2020/07/10 00:48:32 sjg Exp $
#
# $NetBSD: Makefile,v 1.63 2020/07/09 22:40:14 sjg Exp $
#
# Unit tests for make(1)
#
# The main targets are:
#
# all:
# run all the tests
# test:
# run 'all', and compare to expected results
# accept:
# move generated output to expected results
#
# Settable variables
#
# TEST_MAKE
# The make program to be tested.
#
#
# Adding a test case
#
# Each feature should get its own set of tests in its own suitably
2015-04-19 23:45:54 -04:00
# named makefile (*.mk), with its own set of expected results (*.exp),
# and it should be added to the TESTS list.
#
# Any added files must also be added to src/distrib/sets/lists/tests/mi.
# Makefiles that are not added to TESTS must be ignored in
# src/tests/usr.bin/make/t_make.sh (example: include-sub).
#
# Each test is in a sub-makefile.
# Keep the list sorted.
TESTS+= comment
TESTS+= cond-late
TESTS+= cond-short
TESTS+= cond1
TESTS+= cond2
TESTS+= dollar
TESTS+= doterror
TESTS+= dotwait
TESTS+= error
TESTS+= # escape # broken by reverting POSIX changes
TESTS+= export
TESTS+= export-all
TESTS+= export-env
TESTS+= forloop
TESTS+= forsubst
TESTS+= hash
TESTS+= # impsrc # broken by reverting POSIX changes
TESTS+= include-main
TESTS+= misc
TESTS+= moderrs
TESTS+= modmatch
TESTS+= modmisc
TESTS+= modorder
TESTS+= modts
TESTS+= modword
TESTS+= order
TESTS+= # phony-end # broken by reverting POSIX changes
TESTS+= posix
TESTS+= # posix1 # broken by reverting POSIX changes
TESTS+= qequals
TESTS+= # suffixes # broken by reverting POSIX changes
TESTS+= sunshcmd
TESTS+= sysv
TESTS+= ternary
TESTS+= unexport
TESTS+= unexport-env
TESTS+= varcmd
TESTS+= varmisc
TESTS+= varmod-edge
TESTS+= varquote
TESTS+= varshell
# Override make flags for certain tests; default is -k.
FLAGS.doterror= # none
FLAGS.order= -j1
# Some tests need extra post-processing.
SED_CMDS.modmisc+= -e 's,\(substitution error:\).*,\1 (details omitted),'
SED_CMDS.varshell+= -e 's,^[a-z]*sh: ,,'
SED_CMDS.varshell+= -e '/command/s,No such.*,not found,'
# End of the configuration section.
.MAIN: all
Import bmake-20200517 Changes since 20181221 are mostly portability related hence the large gap in versions imported. There are however some bug fixes, and a rework of filemon handling. In NetBSD make/filemon/filemon_ktrace.c allows use of fktrace and elimination of filemon(4) which has not had the TLC it needs. FreeBSD filemon(4) is in much better shape, so bmake/filemon/filemon_dev.c allows use of that, with a bit less overhead than the ktrace model. Summary of changes from ChangeLog o str.c: empty string does not match % pattern plus unit-test changes o var.c: import handling of old sysV style modifier using '%' o str.c: refactor brk_string o meta.c: meta_oodate, CHECK_VALID_META is too aggressive for CMD a blank command is perfectly valid. o meta.c: meta_oodate, check for corrupted meta file earlier and more often. * meta.c: meta_compat_parent check for USE_FILEMON patch from Soeren Tempel o meta.c: fix compat mode, need to call meta_job_output() o job.c: extra fds for meta mode not needed if using filemon_dev o meta.c: avoid passing NULL to filemon_*() when meta_needed() returns FALSE. o filemon/filemon_{dev,ktrace}.c: allow selection of filemon implementation. filemon_dev.c uses the kernel module while filemon_ktrace.c leverages the fktrace api available in NetBSD. filemon_ktrace.c can hopefully form the basis for adding support for other tracing mechanisms such as strace on Linux. o meta.c: when target is out-of-date per normal make rules record value of .OODATE in meta file. o parse.c: don't pass NULL to realpath(3) some versions cannot handle it. o parse.c: ParseDoDependency: free paths rather than assert plus more unit-tests
2020-05-20 15:34:48 -04:00
.-include "Makefile.config"
UNIT_TESTS:= ${srcdir}
2015-04-19 23:45:54 -04:00
.PATH: ${UNIT_TESTS}
OUTFILES= ${TESTS:=.out}
2015-04-19 23:45:54 -04:00
all: ${OUTFILES}
CLEANFILES+= *.rawout *.out *.status *.tmp *.core *.tmp
CLEANFILES+= obj*.[och] lib*.a # posix1.mk
CLEANFILES+= issue* .[ab]* # suffixes.mk
CLEANRECURSIVE+= dir dummy # posix1.mk
2015-04-19 23:45:54 -04:00
clean:
rm -f ${CLEANFILES}
.if !empty(CLEANRECURSIVE)
rm -rf ${CLEANRECURSIVE}
.endif
TEST_MAKE?= ${.MAKE}
TOOL_SED?= sed
TOOL_TR?= tr
TOOL_DIFF?= diff
DIFF_FLAGS?= -u
.if defined(.PARSEDIR)
# ensure consistent results from sort(1)
LC_ALL= C
LANG= C
.export LANG LC_ALL
.endif
2015-04-19 23:45:54 -04:00
# the tests are actually done with sub-makes.
.SUFFIXES: .mk .rawout .out
.mk.rawout:
@echo ${TEST_MAKE} ${FLAGS.${.TARGET:R}:U-k} -f ${.IMPSRC}
2015-04-19 23:45:54 -04:00
-@cd ${.OBJDIR} && \
{ ${TEST_MAKE} ${FLAGS.${.TARGET:R}:U-k} -f ${.IMPSRC} \
2015-04-19 23:45:54 -04:00
2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp
@mv ${.TARGET}.tmp ${.TARGET}
# Post-process the test output so that the results can be compared.
#
# always pretend .MAKE was called 'make'
_SED_CMDS+= -e 's,^${TEST_MAKE:T:S,.,\\.,g}[][0-9]*:,make:,'
_SED_CMDS+= -e 's,${TEST_MAKE:S,.,\\.,g},make,'
# replace anything after 'stopped in' with unit-tests
_SED_CMDS+= -e '/stopped/s, /.*, unit-tests,'
# strip ${.CURDIR}/ from the output
_SED_CMDS+= -e 's,${.CURDIR:S,.,\\.,g}/,,g'
_SED_CMDS+= -e 's,${UNIT_TESTS:S,.,\\.,g}/,,g'
2015-04-19 23:45:54 -04:00
.rawout.out:
@echo postprocess ${.TARGET}
@${TOOL_SED} ${_SED_CMDS} ${SED_CMDS.${.TARGET:R}} \
2015-04-19 23:45:54 -04:00
< ${.IMPSRC} > ${.TARGET}.tmp
@echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp
@mv ${.TARGET}.tmp ${.TARGET}
# Compare all output files
test: ${OUTFILES} .PHONY
@failed= ; \
for test in ${TESTS}; do \
2015-12-07 17:51:25 -05:00
${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \
2015-04-19 23:45:54 -04:00
|| failed="$${failed}$${failed:+ }$${test}" ; \
done ; \
if [ -n "$${failed}" ]; then \
echo "Failed tests: $${failed}" ; false ; \
else \
echo "All tests passed" ; \
fi
accept:
@for test in ${TESTS}; do \
2015-04-19 23:45:54 -04:00
cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \
|| { echo "Replacing $${test}.exp" ; \
cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \
done
2015-04-19 23:45:54 -04:00
.if exists(${TEST_MAKE})
${TESTS:=.rawout}: ${TEST_MAKE}
2015-04-19 23:45:54 -04:00
.endif
.-include <bsd.obj.mk>