Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 19 Oct 2013 06:48:49 +0000 (UTC)
From:      Rui Paulo <rpaulo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r256761 - in head: lib/libcrypt/tests share/mk
Message-ID:  <201310190648.r9J6mnYn035724@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: rpaulo
Date: Sat Oct 19 06:48:49 2013
New Revision: 256761
URL: http://svnweb.freebsd.org/changeset/base/256761

Log:
  Clearly split the logic to build ATF and plain tests apart.
  
  This change introduces a new plain.test.mk file that provides the build
  infrastructure to build test programs that don't use any framework.
  Most of the code previously in bsd.test.mk moves to plain.test.mk and
  atf.test.mk is extended with the missing pieces.
  
  In doing so, this change pushes all test program building logic to the
  various *.test.mk files instead of trying to reuse some tiny bits.
  In fact, this attempt to reuse some definitions makes the code harder
  to read and harder to extend.
  
  The clear benefit of this is that the interface of bsd.test.mk is now
  clearly delimited.
  
  Submitted by:	Julio Merino jmmv google.com
  MFC after:	2 weeks

Modified:
  head/lib/libcrypt/tests/Makefile
  head/share/mk/atf.test.mk
  head/share/mk/bsd.test.mk

Modified: head/lib/libcrypt/tests/Makefile
==============================================================================
--- head/lib/libcrypt/tests/Makefile	Sat Oct 19 06:47:02 2013	(r256760)
+++ head/lib/libcrypt/tests/Makefile	Sat Oct 19 06:48:49 2013	(r256761)
@@ -2,7 +2,7 @@
 
 # exercise libcrypt
 
-TESTS_C= crypt_tests
+ATF_TESTS_C= crypt_tests
 
 CFLAGS+= -I${.CURDIR:H}
 LDADD+= -L${.OBJDIR:H} -lcrypt

Modified: head/share/mk/atf.test.mk
==============================================================================
--- head/share/mk/atf.test.mk	Sat Oct 19 06:47:02 2013	(r256760)
+++ head/share/mk/atf.test.mk	Sat Oct 19 06:48:49 2013	(r256761)
@@ -1,49 +1,53 @@
-# $NetBSD$
 # $FreeBSD$
 #
+# Logic to build and install ATF test programs; i.e. test programs linked
+# against the ATF libraries.
 
 .include <bsd.init.mk>
 
-ATF_TESTS:=
-
-.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 <bsd.subdir.mk>
-.endif
-
-.if defined(TESTS_C)
-ATF_TESTS+= ${TESTS_C}
-.for _T in ${TESTS_C}
+# 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 !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

Modified: head/share/mk/bsd.test.mk
==============================================================================
--- head/share/mk/bsd.test.mk	Sat Oct 19 06:47:02 2013	(r256760)
+++ head/share/mk/bsd.test.mk	Sat Oct 19 06:48:49 2013	(r256761)
@@ -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 <bsd.init.mk>
 
-.if defined(TESTS_C)
-PROGS+=	${TESTS_C}
-.for _T in ${TESTS_C}
-BINDIR.${_T}= ${TESTSDIR}
-MAN.${_T}?= # empty
-.endfor
-.endif
-
-.if defined(TESTS_CXX)
-PROGS_CXX+= ${TESTS_CXX}
-PROGS+= ${TESTS_CXX}
-.for _T in ${TESTS_CXX}
-BINDIR.${_T}= ${TESTSDIR}
-MAN.${_T}?= # empty
-.endfor
-.endif
-
-.if defined(TESTS_SH)
-SCRIPTS+= ${TESTS_SH}
-.for _T in ${TESTS_SH}
-SCRIPTSDIR_${_T}= ${TESTSDIR}
-.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
+
+# Directory in which to install tests defined by the current Makefile.
+# Makefiles have to override this to point to a subdirectory of TESTSBASE.
+TESTSDIR?= .
+
+# 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 <bsd.progs.mk>
-.endif
-
 beforetest: .PHONY
 .if defined(TESTSDIR)
 .if ${TESTSDIR} == ${TESTSBASE}
@@ -76,4 +76,12 @@ test: beforetest realtest
 test: aftertest
 .endif
 
+.if !empty(SUBDIR)
+.include <bsd.subdir.mk>
+.endif
+
+.if !empty(PROGS) || !empty(PROGS_CXX) || !empty(SCRIPTS)
+.include <bsd.progs.mk>
+.endif
+
 .include <bsd.obj.mk>



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201310190648.r9J6mnYn035724>