freebsd-dev/share/mk/bsd.test.mk
Enji Cooper 71b7fa1252 Simplify running the FreeBSD test suite
Replace `make regress` (legacy test make target) and `make test` (incomplete
test make target added with the FreeBSD test suite) with make check as it's
consistent with other open source projects.

`make check` defaults to running tests from `.OBJDIR`, but can be overridden
with the `CHECKDIR` variable.

Add `make checkworld` target to simplify running the FreeBSD test suite from
`TESTSBASE` (i.e. the top-level tests directory), similar to buildworld.

Document `make check` and `make checkworld` in build(7).

Other minor changes:

- Rename intermediate file (`Kyuafile.auto`) to `Kyuafile` to simplify
  `make check`.
- Remove terse warnings attached to `beforetest`/`aftertest`.
- Add kyua binary check to check target in suite.test.mk; error out if it's
  not found

The MFC is [partly] contingent on other build related changes being MFCed.

Differential Revision: https://reviews.freebsd.org/D4406
MFC after: 2 months
X-MFC to: stable/10
Relnotes: yes
Reviewed by: bdrewery, Evan Cramer <eccramer@gmail.com>
Sponsored by: EMC / Isilon Storage Division
2016-02-07 18:40:04 +00:00

122 lines
3.4 KiB
Makefile

# $FreeBSD$
#
# Generic build infrastructure for test programs.
#
# This is the only public file that should be included by Makefiles when
# tests are to be built. All other *.test.mk files are internal and not
# to be included directly.
.include <bsd.init.mk>
__<bsd.test.mk>__:
# Third-party software (kyua, etc) prefix.
LOCALBASE?= /usr/local
# Tests install directory
TESTSDIR?= ${TESTSBASE}/${RELDIR:H}
# List of subdirectories containing tests into which to recurse. This has the
# same semantics as SUBDIR at build-time. However, the directories listed here
# get registered into the run-time test suite definitions so that the test
# engines know to recurse into these directories.
#
# In other words: list here any directories that contain test programs but use
# SUBDIR for directories that may contain helper binaries and/or data files.
TESTS_SUBDIRS?=
# If defined, indicates that the tests built by the Makefile are not part of
# the FreeBSD Test Suite. The implication of this is that the tests won't be
# installed under /usr/tests/ and that Kyua won't be able to run them.
#NOT_FOR_TEST_SUITE=
# List of variables to pass to the tests at run-time via the environment.
TESTS_ENV?=
# Force all tests in a separate distribution file.
#
# We want this to be the case even when the distribution name is already
# overriden. For example: we want the tests for programs in the 'games'
# distribution to end up in the 'tests' distribution; the test programs
# themselves have all the necessary logic to detect that the games are not
# installed and thus won't cause false negatives.
DISTRIBUTION:= tests
# Ordered list of directories to construct the PATH for the tests.
TESTS_PATH+= ${DESTDIR}/bin ${DESTDIR}/sbin \
${DESTDIR}/usr/bin ${DESTDIR}/usr/sbin
TESTS_ENV+= PATH=${TESTS_PATH:tW:C/ +/:/g}
# Ordered list of directories to construct the LD_LIBRARY_PATH for the tests.
TESTS_LD_LIBRARY_PATH+= ${DESTDIR}/lib ${DESTDIR}/usr/lib
TESTS_ENV+= LD_LIBRARY_PATH=${TESTS_LD_LIBRARY_PATH:tW:C/ +/:/g}
# List of all tests being built. The various *.test.mk modules extend this
# variable as needed.
_TESTS=
# Pull in the definitions of all supported test interfaces.
.include <atf.test.mk>
.include <plain.test.mk>
.include <tap.test.mk>
# kyua automatically descends directories; only run make check on the
# top-level directory
.if !make(check)
.for ts in ${TESTS_SUBDIRS}
.if empty(SUBDIR:M${ts})
SUBDIR+= ${ts}
.endif
.endfor
.endif
# it is rare for test cases to have man pages
.if !defined(MAN)
MAN=
.endif
# tell progs.mk we might want to install things
PROG_VARS+= BINDIR
PROGS_TARGETS+= install
.if !defined(NOT_FOR_TEST_SUITE)
.include <suite.test.mk>
.endif
.if !target(realcheck)
realcheck: .PHONY
@echo "$@ not defined; skipping"
.endif
beforecheck realcheck aftercheck check: .PHONY
.ORDER: beforecheck realcheck aftercheck
check: beforecheck realcheck aftercheck
.ifdef PROG
# we came here via bsd.progs.mk below
# parent will do staging.
MK_STAGING= no
.endif
.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
.include <bsd.progs.mk>
.endif
.include <bsd.files.mk>
.if !defined(PROG) && ${MK_STAGING} != "no"
.if !defined(_SKIP_BUILD)
# this will handle staging if needed
_SKIP_STAGING= no
# but we don't want it to build anything
_SKIP_BUILD=
.endif
.if !empty(PROGS)
stage_files.prog: ${PROGS}
.endif
.include <bsd.prog.mk>
.endif
.if !target(objwarn)
.include <bsd.obj.mk>
.endif