diff --git a/lib/libcrypt/tests/Makefile b/lib/libcrypt/tests/Makefile index 3190dbe9492e..8c818bdda230 100644 --- a/lib/libcrypt/tests/Makefile +++ b/lib/libcrypt/tests/Makefile @@ -2,7 +2,7 @@ # exercise libcrypt -TESTS_C= crypt_tests +ATF_TESTS_C= crypt_tests CFLAGS+= -I${.CURDIR:H} LDADD+= -L${.OBJDIR:H} -lcrypt diff --git a/share/mk/atf.test.mk b/share/mk/atf.test.mk index da4d12f1263f..85ddfa5a2c9a 100644 --- a/share/mk/atf.test.mk +++ b/share/mk/atf.test.mk @@ -1,49 +1,53 @@ -# $NetBSD$ # $FreeBSD$ # +# Logic to build and install ATF test programs; i.e. test programs linked +# against the ATF libraries. .include -ATF_TESTS:= +# List of C, C++ and shell test programs to build. +# +# Programs listed here are built using PROGS, PROGS_CXX and SCRIPTS, +# respectively, from bsd.prog.mk. However, the build rules are tweaked to +# require the ATF libraries. +# +# Test programs registered in this manner are set to be installed into TESTSDIR +# (which should be overriden by the Makefile) and are not required to provide a +# manpage. +ATF_TESTS_C?= +ATF_TESTS_CXX?= +ATF_TESTS_SH?= -.if make(*test) -TESTSDIR?= . -.endif - -.if defined(ATF_TESTS_SUBDIRS) -# Only visit subdirs when building, etc because ATF does this it on its own. -.if !make(atf-test) -SUBDIR+= ${ATF_TESTS_SUBDIRS} -.endif -ATF_TESTS+= ${ATF_TESTS_SUBDIRS} - -.include -.endif - -.if defined(TESTS_C) -ATF_TESTS+= ${TESTS_C} -.for _T in ${TESTS_C} +.if !empty(ATF_TESTS_C) +PROGS+= ${ATF_TESTS_C} +.for _T in ${ATF_TESTS_C} +BINDIR.${_T}= ${TESTSDIR} +MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.c DPADD.${_T}+= ${LIBATF_C} LDADD.${_T}+= -latf-c .endfor .endif -.if defined(TESTS_CXX) -ATF_TESTS+= ${TESTS_CXX} -.for _T in ${TESTS_CXX} +.if !empty(ATF_TESTS_CXX) +PROGS_CXX+= ${ATF_TESTS_CXX} +PROGS+= ${ATF_TESTS_CXX} +.for _T in ${ATF_TESTS_CXX} +BINDIR.${_T}= ${TESTSDIR} +MAN.${_T}?= # empty SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc} DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C} LDADD.${_T}+= -latf-c++ -latf-c .endfor .endif -.if defined(TESTS_SH) -ATF_TESTS+= ${TESTS_SH} -.for _T in ${TESTS_SH} +.if !empty(ATF_TESTS_SH) +SCRIPTS+= ${ATF_TESTS_SH} +.for _T in ${ATF_TESTS_SH} +SCRIPTSDIR_${_T}= ${TESTSDIR} CLEANFILES+= ${_T} ${_T}.tmp -TESTS_SH_SRC_${_T}?= ${_T}.sh -${_T}: ${TESTS_SH_SRC_${_T}} +ATF_TESTS_SH_SRC_${_T}?= ${_T}.sh +${_T}: ${ATF_TESTS_SH_SRC_${_T}} echo '#! /usr/bin/atf-sh' > ${.TARGET}.tmp cat ${.ALLSRC} >> ${.TARGET}.tmp chmod +x ${.TARGET}.tmp diff --git a/share/mk/bsd.test.mk b/share/mk/bsd.test.mk index a75298f42d65..60993b98f030 100644 --- a/share/mk/bsd.test.mk +++ b/share/mk/bsd.test.mk @@ -1,33 +1,37 @@ -# $NetBSD: bsd.test.mk,v 1.21 2012/08/25 22:21:16 jmmv Exp $ # $FreeBSD$ +# +# Generic build infrastructure for test programs. +# +# The code in this file is independent of the implementation of the test +# programs being built; this file just provides generic infrastructure for the +# build and the definition of various helper variables and targets. +# +# Makefiles should never include this file directly. Instead, they should +# include one of the various *.test.mk depending on the specific test programs +# being built. .include -.if defined(TESTS_C) -PROGS+= ${TESTS_C} -.for _T in ${TESTS_C} -BINDIR.${_T}= ${TESTSDIR} -MAN.${_T}?= # empty -.endfor -.endif +# Pointer to the top directory into which tests are installed. Should not be +# overriden by Makefiles, but the user may choose to set this in src.conf(5). +TESTSBASE?= /usr/tests -.if defined(TESTS_CXX) -PROGS_CXX+= ${TESTS_CXX} -PROGS+= ${TESTS_CXX} -.for _T in ${TESTS_CXX} -BINDIR.${_T}= ${TESTSDIR} -MAN.${_T}?= # empty -.endfor -.endif +# Directory in which to install tests defined by the current Makefile. +# Makefiles have to override this to point to a subdirectory of TESTSBASE. +TESTSDIR?= . -.if defined(TESTS_SH) -SCRIPTS+= ${TESTS_SH} -.for _T in ${TESTS_SH} -SCRIPTSDIR_${_T}= ${TESTSDIR} -.endfor -.endif +# 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?= -TESTSBASE?= ${DESTDIR}/usr/tests +.if !empty(TESTS_SUBDIRS) +SUBDIR+= ${TESTS_SUBDIRS} +.endif # it is rare for test cases to have man pages .if !defined(MAN) @@ -39,10 +43,6 @@ WITHOUT_MAN=yes PROG_VARS+= BINDIR PROGS_TARGETS+= install -.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) -.include -.endif - beforetest: .PHONY .if defined(TESTSDIR) .if ${TESTSDIR} == ${TESTSBASE} @@ -76,4 +76,12 @@ test: beforetest realtest test: aftertest .endif +.if !empty(SUBDIR) +.include +.endif + +.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS) +.include +.endif + .include