From c91bd1b225993ba7ed8ee5a9a667813e2e9f3644 Mon Sep 17 00:00:00 2001 From: jmmv Date: Thu, 6 Mar 2014 13:20:38 +0000 Subject: [PATCH] MFC various fixes for the ATF tests. - r260505 Allow tests to provide a Kyuafile when they relied on auto-generation. - r260525 Respect the original layout of the atf-{c,c++} tests. - r260526 Fix path to the process_helpers for the libatf-c++ tests. - r260576 Generate and install pkg-config files for atf. - r260577 Add atf pkg-config files from the vendor branch. - r260584 Prevent misc_helpers from running as a test. git-svn-id: svn://svn.freebsd.org/base/stable/10@262849 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- UPDATING | 8 ++++++ contrib/atf/FREEBSD-Xlist | 1 - contrib/atf/atf-c++/atf-c++.pc.in | 11 ++++++++ contrib/atf/atf-c++/detail/test_helpers.cpp | 29 +++++++++++++++----- contrib/atf/atf-c/atf-c.pc.in | 11 ++++++++ contrib/atf/atf-sh/atf-sh.pc.in | 8 ++++++ etc/mtree/BSD.tests.dist | 4 +++ lib/atf/Makefile.inc | 1 + lib/atf/common.mk | 19 +++++++++++++ lib/atf/libatf-c++/Makefile | 13 +++++++++ lib/atf/libatf-c++/tests/Makefile | 18 +------------ lib/atf/libatf-c++/tests/Makefile.inc | 3 +++ lib/atf/libatf-c++/tests/detail/Makefile | 26 ++++++++++++++++++ lib/atf/libatf-c/Makefile | 13 +++++++++ lib/atf/libatf-c/tests/Makefile | 23 +--------------- lib/atf/libatf-c/tests/Makefile.inc | 3 +++ lib/atf/libatf-c/tests/detail/Makefile | 30 +++++++++++++++++++++ share/mk/bsd.test.mk | 23 +++++++++------- tools/build/mk/OptionalObsoleteFiles.inc | 20 ++++++++++++++ usr.bin/atf/atf-sh/Makefile | 11 ++++++++ usr.bin/atf/atf-sh/tests/Makefile | 10 ++++++- 21 files changed, 229 insertions(+), 56 deletions(-) create mode 100644 contrib/atf/atf-c++/atf-c++.pc.in create mode 100644 contrib/atf/atf-c/atf-c.pc.in create mode 100644 contrib/atf/atf-sh/atf-sh.pc.in create mode 100644 lib/atf/common.mk create mode 100644 lib/atf/libatf-c++/tests/Makefile.inc create mode 100644 lib/atf/libatf-c++/tests/detail/Makefile create mode 100644 lib/atf/libatf-c/tests/Makefile.inc create mode 100644 lib/atf/libatf-c/tests/detail/Makefile diff --git a/UPDATING b/UPDATING index 081ec6fdf..174a37567 100644 --- a/UPDATING +++ b/UPDATING @@ -17,6 +17,14 @@ stable/10, and then rebuild without this option. The bootstrap process from older version of current is a bit fragile. +20140306: + If a Makefile in a tests/ directory was auto-generating a Kyuafile + instead of providing an explicit one, this would prevent such + Makefile from providing its own Kyuafile in the future during + NO_CLEAN builds. This has been fixed in the Makefiles but manual + intervention is needed to clean an objdir if you use NO_CLEAN: + # find /usr/obj -name Kyuafile | xargs rm -f + 20140303: OpenSSH will now ignore errors caused by kernel lacking of Capsicum capability mode support. Please note that enabling the feature in diff --git a/contrib/atf/FREEBSD-Xlist b/contrib/atf/FREEBSD-Xlist index be75e54ff..bffac425e 100644 --- a/contrib/atf/FREEBSD-Xlist +++ b/contrib/atf/FREEBSD-Xlist @@ -8,7 +8,6 @@ Makefile* aclocal.m4 admin/ atf-*/atf-*.m4 -atf-*/atf-*.pc.in atf-config/ atf-report/ atf-run/ diff --git a/contrib/atf/atf-c++/atf-c++.pc.in b/contrib/atf/atf-c++/atf-c++.pc.in new file mode 100644 index 000000000..f366bb016 --- /dev/null +++ b/contrib/atf/atf-c++/atf-c++.pc.in @@ -0,0 +1,11 @@ +# ATF pkg-config file + +cxx=__CXX__ +includedir=__INCLUDEDIR__ +libdir=__LIBDIR__ + +Name: atf-c++ +Description: Automated Testing Framework (C++ binding) +Version: __ATF_VERSION__ +Cflags: -I${includedir} +Libs: -L${libdir} -latf-c++ -latf-c diff --git a/contrib/atf/atf-c++/detail/test_helpers.cpp b/contrib/atf/atf-c++/detail/test_helpers.cpp index dc35da96b..92f588d72 100644 --- a/contrib/atf/atf-c++/detail/test_helpers.cpp +++ b/contrib/atf/atf-c++/detail/test_helpers.cpp @@ -40,6 +40,18 @@ #include "process.hpp" #include "test_helpers.hpp" +// Path to the directory containing the libatf-c tests, used to locate the +// process_helpers program. If NULL (the default), the code will use a +// relative path. Otherwise, the provided path will be used; this is so +// that we can locate the helpers binary if the installation uses a +// different layout than the one we provide (as is the case in FreeBSD). +#if defined(ATF_C_TESTS_BASE) +static const char* atf_c_tests_base = ATF_C_TESTS_BASE; +#else +static const char* atf_c_tests_base = NULL; +#endif +#undef ATF_C_TESTS_BASE + void build_check_cxx_o_aux(const atf::fs::path& sfile, const char* failmsg, const bool expect_pass) @@ -80,12 +92,17 @@ header_check(const char *hdrname) atf::fs::path get_process_helpers_path(const atf::tests::tc& tc, bool is_detail) { - if (is_detail) - return atf::fs::path(tc.get_config_var("srcdir")) / - ".." / ".." / "atf-c" / "detail" / "process_helpers"; - else - return atf::fs::path(tc.get_config_var("srcdir")) / - ".." / "atf-c" / "detail" / "process_helpers"; + const char* helper = "detail/process_helpers"; + if (atf_c_tests_base == NULL) { + if (is_detail) + return atf::fs::path(tc.get_config_var("srcdir")) / + ".." / ".." / "atf-c" / helper; + else + return atf::fs::path(tc.get_config_var("srcdir")) / + ".." / "atf-c" / helper; + } else { + return atf::fs::path(atf_c_tests_base) / helper; + } } void diff --git a/contrib/atf/atf-c/atf-c.pc.in b/contrib/atf/atf-c/atf-c.pc.in new file mode 100644 index 000000000..6fd52740b --- /dev/null +++ b/contrib/atf/atf-c/atf-c.pc.in @@ -0,0 +1,11 @@ +# ATF pkg-config file + +cc=__CC__ +includedir=__INCLUDEDIR__ +libdir=__LIBDIR__ + +Name: atf-c +Description: Automated Testing Framework (C binding) +Version: __ATF_VERSION__ +Cflags: -I${includedir} +Libs: -L${libdir} -latf-c diff --git a/contrib/atf/atf-sh/atf-sh.pc.in b/contrib/atf/atf-sh/atf-sh.pc.in new file mode 100644 index 000000000..930dc4c3d --- /dev/null +++ b/contrib/atf/atf-sh/atf-sh.pc.in @@ -0,0 +1,8 @@ +# ATF pkg-config file + +exec_prefix=__EXEC_PREFIX__ +interpreter=${exec_prefix}/bin/atf-sh + +Name: atf-sh +Description: Automated Testing Framework (POSIX shell binding) +Version: __ATF_VERSION__ diff --git a/etc/mtree/BSD.tests.dist b/etc/mtree/BSD.tests.dist index b4afeeeeb..acb0dcb20 100644 --- a/etc/mtree/BSD.tests.dist +++ b/etc/mtree/BSD.tests.dist @@ -23,8 +23,12 @@ lib atf libatf-c + detail + .. .. libatf-c++ + detail + .. .. test-programs .. diff --git a/lib/atf/Makefile.inc b/lib/atf/Makefile.inc index 15e7517f0..40da94673 100644 --- a/lib/atf/Makefile.inc +++ b/lib/atf/Makefile.inc @@ -38,6 +38,7 @@ CFLAGS+= -DATF_BUILD_CPPFLAGS='"${_CPPFLAGS}"' CFLAGS+= -DATF_BUILD_CXX='"${CXX}"' CFLAGS+= -DATF_BUILD_CXXFLAGS='"${_CXXFLAGS}"' CFLAGS+= -DATF_CONFDIR='"${CONFDIR}/atf"' +CFLAGS+= -DATF_C_TESTS_BASE='"${TESTSBASE}/lib/atf/libatf-c"' CFLAGS+= -DATF_INCLUDEDIR='"${INCLUDEDIR}"' CFLAGS+= -DATF_LIBDIR='"${LIBDIR}"' CFLAGS+= -DATF_LIBEXECDIR='"${LIBEXECDIR}"' diff --git a/lib/atf/common.mk b/lib/atf/common.mk new file mode 100644 index 000000000..633820794 --- /dev/null +++ b/lib/atf/common.mk @@ -0,0 +1,19 @@ +# $FreeBSD$ +# +# Common Makefile code for all components of ATF. +# + +.if !defined(ATF) +.error "ATF must be defined and point to the contrib/atf directory" +.endif + +# Depend on the atf-version target to generate a file that contains the +# version number of the currently imported ATF release and that only +# changes on new imports. +atf-version: atf-version-real + @cmp -s atf-version atf-version-real \ + || cp atf-version-real atf-version +atf-version-real: .PHONY + @grep 'define VERSION' ${ATF}/bconfig.h \ + | cut -d '"' -f 2 >atf-version-real +CLEANFILES+= atf-version atf-version-real diff --git a/lib/atf/libatf-c++/Makefile b/lib/atf/libatf-c++/Makefile index f1d9dcfb1..ff05da7b4 100644 --- a/lib/atf/libatf-c++/Makefile +++ b/lib/atf/libatf-c++/Makefile @@ -76,8 +76,21 @@ INCSDIR_atf-c++.hpp= ${INCLUDEDIR} MAN= atf-c++-api.3 +all: atf-c++.pc +atf-c++.pc: atf-c++.pc.in atf-version + sed -e 's,__CXX__,${CXX},g' \ + -e 's,__INCLUDEDIR__,${INCLUDEDIR},g' \ + -e 's,__LIBDIR__,${LIBDIR},g' \ + -e "s,__ATF_VERSION__,$$(cat atf-version),g" \ + <${ATF}/atf-c++/atf-c++.pc.in >atf-c++.pc + +beforeinstall: + ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + atf-c++.pc ${DESTDIR}${LIBDATADIR}/pkgconfig + .if ${MK_TESTS} != "no" SUBDIR= tests .endif +.include "../common.mk" .include diff --git a/lib/atf/libatf-c++/tests/Makefile b/lib/atf/libatf-c++/tests/Makefile index db10fce8d..1ab5fdaa6 100644 --- a/lib/atf/libatf-c++/tests/Makefile +++ b/lib/atf/libatf-c++/tests/Makefile @@ -3,6 +3,7 @@ .include TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c++ +TESTS_SUBDIRS= detail ATF= ${.CURDIR:H:H:H:H}/contrib/atf .PATH: ${ATF}/atf-c++ @@ -14,7 +15,6 @@ FILESDIR= ${TESTSDIR} FILES= macros_hpp_test.cpp FILES+= unused_test.cpp -# Tests in atf-c++. .for _T in atf_c++_test \ build_test \ check_test \ @@ -28,20 +28,4 @@ SRCS.${_T}= ${_T}.cpp test_helpers.cpp ATF_TESTS_SH= pkg_config_test -# Tests in atf-c++/detail. - -.for _T in application_test \ - env_test \ - exceptions_test \ - expand_test \ - fs_test \ - parser_test \ - process_test \ - sanity_test \ - text_test \ - ui_test -ATF_TESTS_CXX+= ${_T} -SRCS.${_T}= ${_T}.cpp test_helpers.cpp -.endfor - .include diff --git a/lib/atf/libatf-c++/tests/Makefile.inc b/lib/atf/libatf-c++/tests/Makefile.inc new file mode 100644 index 000000000..265f86d1e --- /dev/null +++ b/lib/atf/libatf-c++/tests/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +.include "../Makefile.inc" diff --git a/lib/atf/libatf-c++/tests/detail/Makefile b/lib/atf/libatf-c++/tests/detail/Makefile new file mode 100644 index 000000000..e4ed1a5f2 --- /dev/null +++ b/lib/atf/libatf-c++/tests/detail/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +.include + +TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c++/detail + +ATF= ${.CURDIR:H:H:H:H:H}/contrib/atf +.PATH: ${ATF}/atf-c++/detail + +CFLAGS+= -I${ATF} + +.for _T in application_test \ + env_test \ + exceptions_test \ + expand_test \ + fs_test \ + parser_test \ + process_test \ + sanity_test \ + text_test \ + ui_test +ATF_TESTS_CXX+= ${_T} +SRCS.${_T}= ${_T}.cpp test_helpers.cpp +.endfor + +.include diff --git a/lib/atf/libatf-c/Makefile b/lib/atf/libatf-c/Makefile index b197958c3..829f8ffd0 100644 --- a/lib/atf/libatf-c/Makefile +++ b/lib/atf/libatf-c/Makefile @@ -74,8 +74,21 @@ INCSDIR_atf-c.h= ${INCLUDEDIR} MAN= atf-c-api.3 +all: atf-c.pc +atf-c.pc: atf-c.pc.in atf-version + sed -e 's,__CC__,${CC},g' \ + -e 's,__INCLUDEDIR__,${INCLUDEDIR},g' \ + -e 's,__LIBDIR__,${LIBDIR},g' \ + -e "s,__ATF_VERSION__,$$(cat atf-version),g" \ + <${ATF}/atf-c/atf-c.pc.in >atf-c.pc + +beforeinstall: + ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + atf-c.pc ${DESTDIR}${LIBDATADIR}/pkgconfig + .if ${MK_TESTS} != "no" SUBDIR= tests .endif +.include "../common.mk" .include diff --git a/lib/atf/libatf-c/tests/Makefile b/lib/atf/libatf-c/tests/Makefile index a5c2836f6..14b199f59 100644 --- a/lib/atf/libatf-c/tests/Makefile +++ b/lib/atf/libatf-c/tests/Makefile @@ -3,6 +3,7 @@ .include TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c +TESTS_SUBDIRS= detail ATF= ${.CURDIR:H:H:H:H}/contrib/atf .PATH: ${ATF}/atf-c @@ -19,8 +20,6 @@ FILESDIR= ${TESTSDIR} FILES= macros_h_test.c FILES+= unused_test.c -# Tests in atf-c. - .for _T in atf_c_test \ build_test \ check_test \ @@ -36,24 +35,4 @@ SRCS.${_T}= ${_T}.c test_helpers.c ATF_TESTS_SH= pkg_config_test -# Tests in atf-c/detail. - -.for _T in dynstr_test \ - env_test \ - fs_test \ - list_test \ - map_test \ - process_test \ - sanity_test \ - text_test \ - user_test -ATF_TESTS_C+= ${_T} -SRCS.${_T}= ${_T}.c test_helpers.c -.endfor - -PROGS+= process_helpers -SRCS.process_helpers= process_helpers.c -MAN.process_helpers= # defined -BINDIR.process_helpers= ${TESTSDIR} - .include diff --git a/lib/atf/libatf-c/tests/Makefile.inc b/lib/atf/libatf-c/tests/Makefile.inc new file mode 100644 index 000000000..265f86d1e --- /dev/null +++ b/lib/atf/libatf-c/tests/Makefile.inc @@ -0,0 +1,3 @@ +# $FreeBSD$ + +.include "../Makefile.inc" diff --git a/lib/atf/libatf-c/tests/detail/Makefile b/lib/atf/libatf-c/tests/detail/Makefile new file mode 100644 index 000000000..82bbf6f0d --- /dev/null +++ b/lib/atf/libatf-c/tests/detail/Makefile @@ -0,0 +1,30 @@ +# $FreeBSD$ + +.include + +TESTSDIR= ${TESTSBASE}/lib/atf/libatf-c/detail + +ATF= ${.CURDIR:H:H:H:H:H}/contrib/atf +.PATH: ${ATF}/atf-c/detail + +CFLAGS+= -I${ATF} + +.for _T in dynstr_test \ + env_test \ + fs_test \ + list_test \ + map_test \ + process_test \ + sanity_test \ + text_test \ + user_test +ATF_TESTS_C+= ${_T} +SRCS.${_T}= ${_T}.c test_helpers.c +.endfor + +PROGS+= process_helpers +SRCS.process_helpers= process_helpers.c +MAN.process_helpers= # defined +BINDIR.process_helpers= ${TESTSDIR} + +.include diff --git a/share/mk/bsd.test.mk b/share/mk/bsd.test.mk index 8cdf91448..01d74b538 100644 --- a/share/mk/bsd.test.mk +++ b/share/mk/bsd.test.mk @@ -79,14 +79,20 @@ WITHOUT_MAN=yes PROG_VARS+= BINDIR PROGS_TARGETS+= install -.if ${KYUAFILE:tl} != "no" +.if ${KYUAFILE:tl} == "yes" FILES+= Kyuafile FILESDIR_Kyuafile= ${TESTSDIR} -.if ${KYUAFILE:tl} == "auto" -CLEANFILES+= Kyuafile Kyuafile.tmp +CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp +.elif ${KYUAFILE:tl} == "auto" +FILES+= Kyuafile.auto +FILESDIR_Kyuafile.auto= ${TESTSDIR} +FILESNAME_Kyuafile.auto= Kyuafile -Kyuafile: Makefile +CLEANFILES+= Kyuafile.auto Kyuafile.auto.tmp + +.NOPATH: Kyuafile.auto +Kyuafile.auto: Makefile @{ \ echo '-- Automatically generated by bsd.test.mk.'; \ echo; \ @@ -94,16 +100,15 @@ Kyuafile: Makefile echo; \ echo 'test_suite("${TESTSUITE}")'; \ echo; \ - } >Kyuafile.tmp + } >Kyuafile.auto.tmp .for _T in ${_TESTS} @echo "${TEST_INTERFACE.${_T}}_test_program{name=\"${_T}\"}" \ - >>Kyuafile.tmp + >>Kyuafile.auto.tmp .endfor .for _T in ${TESTS_SUBDIRS:N.WAIT} - @echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.tmp + @echo "include(\"${_T}/Kyuafile\")" >>Kyuafile.auto.tmp .endfor - @mv Kyuafile.tmp Kyuafile -.endif + @mv Kyuafile.auto.tmp Kyuafile.auto .endif KYUA?= ${KYUA_PREFIX}/bin/kyua diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 5a6f2d244..f733d6c78 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -4102,6 +4102,26 @@ OLD_FILES+=usr/share/man/man8/telnetd.8.gz .if ${MK_TESTS} == yes OLD_FILES+=usr/tests/lib/atf/libatf-c/test_helpers_test OLD_FILES+=usr/tests/lib/atf/test-programs/fork_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/application_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/env_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/exceptions_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/expand_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/fs_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/parser_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/process_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/sanity_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/text_test +OLD_FILES+=usr/tests/lib/atf/libatf-c++/ui_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/dynstr_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/env_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/fs_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/list_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/map_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/process_helpers +OLD_FILES+=usr/tests/lib/atf/libatf-c/process_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/sanity_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/text_test +OLD_FILES+=usr/tests/lib/atf/libatf-c/user_test .else # ATF libraries. OLD_FILES+=usr/bin/atf-sh diff --git a/usr.bin/atf/atf-sh/Makefile b/usr.bin/atf/atf-sh/Makefile index 1688b191f..1d72b56a5 100644 --- a/usr.bin/atf/atf-sh/Makefile +++ b/usr.bin/atf/atf-sh/Makefile @@ -45,8 +45,19 @@ FILESGROUPS= SUBR SUBRDIR= ${SHAREDIR}/atf SUBR= libatf-sh.subr +all: atf-sh.pc +atf-sh.pc: atf-sh.pc.in atf-version + sed -e 's,__EXEC_PREFIX__,/usr,g' \ + -e "s,__ATF_VERSION__,$$(cat atf-version),g" \ + <${ATF}/atf-sh/atf-sh.pc.in >atf-sh.pc + +beforeinstall: + ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ + atf-sh.pc ${DESTDIR}${LIBDATADIR}/pkgconfig + .if ${MK_TESTS} != "no" SUBDIR+= tests .endif +.include "../../../lib/atf/common.mk" .include diff --git a/usr.bin/atf/atf-sh/tests/Makefile b/usr.bin/atf/atf-sh/tests/Makefile index 664f25ab6..b43b649fb 100644 --- a/usr.bin/atf/atf-sh/tests/Makefile +++ b/usr.bin/atf/atf-sh/tests/Makefile @@ -10,9 +10,17 @@ ATF= ${.CURDIR:H:H:H:H}/contrib/atf ATF_TESTS_SH+= atf_check_test ATF_TESTS_SH+= config_test ATF_TESTS_SH+= integration_test -ATF_TESTS_SH+= misc_helpers ATF_TESTS_SH+= normalize_test ATF_TESTS_SH+= tc_test ATF_TESTS_SH+= tp_test +SCRIPTS+= misc_helpers +SCRIPTSDIR_misc_helpers=${TESTSDIR} +CLEANFILES+= misc_helpers misc_helpers.tmp +misc_helpers: misc_helpers.sh + echo '#! /usr/bin/atf-sh' >${.TARGET}.tmp + cat ${.ALLSRC} >>${.TARGET}.tmp + chmod +x ${.TARGET}.tmp + mv ${.TARGET}.tmp ${.TARGET} + .include -- 2.45.0