From owner-svn-src-all@FreeBSD.ORG Sat Oct 19 06:48:50 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 4DA419B7; Sat, 19 Oct 2013 06:48:50 +0000 (UTC) (envelope-from rpaulo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 38F9C29AF; Sat, 19 Oct 2013 06:48:50 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9J6mox7035727; Sat, 19 Oct 2013 06:48:50 GMT (envelope-from rpaulo@svn.freebsd.org) Received: (from rpaulo@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r9J6mnYn035724; Sat, 19 Oct 2013 06:48:49 GMT (envelope-from rpaulo@svn.freebsd.org) Message-Id: <201310190648.r9J6mnYn035724@svn.freebsd.org> From: Rui Paulo Date: Sat, 19 Oct 2013 06:48:49 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 19 Oct 2013 06:48:50 -0000 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 -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 -.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 -.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 -.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