Index: head/share/mk/bsd.test.mk =================================================================== --- head/share/mk/bsd.test.mk (revision 366469) +++ head/share/mk/bsd.test.mk (revision 366470) @@ -1,103 +1,104 @@ # $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 ____: # Third-party software (kyua, etc) prefix. LOCALBASE?= /usr/local # Tests install directory TESTSDIR?= ${TESTSBASE}/${RELDIR:H} PACKAGE?= tests FILESGROUPS+= ${PACKAGE}FILES ${PACKAGE}FILESPACKAGE= ${PACKAGE} ${PACKAGE}FILESDIR= ${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?= # 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 # overridden. 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 .include .include .include +# Include atf last to let other test framework use it +.include # Sort the tests alphabetically, so the results are deterministically formed # across runs. _TESTS:= ${_TESTS:O} # 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 SUBDIR_PARALLEL= t .endif # it is rare for test cases to have man pages .if !defined(MAN) MAN= .endif .if !defined(NOT_FOR_TEST_SUITE) .include .endif .if !target(realcheck) realcheck: .PHONY @echo "$@ not defined; skipping" .endif beforecheck realcheck aftercheck check: .PHONY .ORDER: beforecheck realcheck aftercheck check: beforecheck realcheck aftercheck .include Index: head/share/mk/googletest.test.mk =================================================================== --- head/share/mk/googletest.test.mk (revision 366469) +++ head/share/mk/googletest.test.mk (revision 366470) @@ -1,41 +1,47 @@ # $FreeBSD$ # # You must include bsd.test.mk instead of this file from your Makefile. # # Logic to build and install GoogleTest based test programs. # # GoogleTest is a C++ test framework, thus, it does not describe/articulate how # to write tests in other languages, e.g., C or shell, unlike the ATF, plain, # and TAP raw test interfaces. # # For now this is a thin wrapper around the `plain` test interface, but in the # future this will rely on a newer version of kyua which will integrate in # GoogleTest support. .if !target(____) .error googletest.test.mk cannot be included directly. .endif # List of GoogleTest test programs to build. # # Programs listed here are built according to the semantics of bsd.progs.mk for # PROGS_CXX. # # Test programs registered in this manner are set to be installed into TESTSDIR # (which should be overridden by the Makefile) and are not required to provide a # manpage. GTESTS?= .if !empty(GTESTS) .include PROGS_CXX+= ${GTESTS} -_TESTS+= ${GTESTS} .for _T in ${GTESTS} BINDIR.${_T}= ${TESTSDIR} CXXFLAGS.${_T}+= ${GTESTS_CXXFLAGS} MAN.${_T}?= # empty SRCS.${_T}?= ${_T}.cc +.if !empty(GTESTS_WRAPPER_SH.${_T}) +# A stopgap/workaround to let kyua execute test case one by one +ATF_TESTS_SH+= ${GTESTS_WRAPPER_SH.${_T}} +.else +_TESTS+= ${_T} TEST_INTERFACE.${_T}= plain +.endif + .endfor .endif Index: head/tests/sys/capsicum/Makefile =================================================================== --- head/tests/sys/capsicum/Makefile (revision 366469) +++ head/tests/sys/capsicum/Makefile (revision 366470) @@ -1,55 +1,56 @@ # $FreeBSD$ .include TESTSDIR= ${TESTSBASE}/sys/capsicum ATF_TESTS_C+= bindat_connectat ATF_TESTS_C+= ioctls_test CFLAGS+= -I${SRCTOP}/tests .if ${MK_GOOGLETEST} != no .PATH: ${SRCTOP}/contrib/capsicum-test GTESTS+= capsicum-test +GTESTS_WRAPPER_SH.capsicum-test= functional SRCS.capsicum-test+= \ capsicum-test-main.cc \ capsicum-test.cc \ capability-fd.cc \ fexecve.cc \ procdesc.cc \ capmode.cc \ fcntl.cc \ ioctl.cc \ openat.cc \ sysctl.cc \ select.cc \ mqueue.cc \ socket.cc \ sctp.cc \ capability-fd-pair.cc \ overhead.cc \ rename.cc LIBADD.capsicum-test+= gtest pthread TEST_METADATA.capsicum-test= required_user="unprivileged" .for p in mini-me mini-me.noexec mini-me.setuid PROGS+= $p NO_SHARED.$p= SRCS.$p= mini-me.c .endfor BINDIR= ${TESTSDIR} BINMODE.mini-me.noexec= ${NOBINMODE} BINMODE.mini-me.setuid= 4555 WARNS.capsicum-test= 3 -.endif +.endif # MK_GOOGLETEST .include Index: head/tests/sys/capsicum/functional.sh =================================================================== --- head/tests/sys/capsicum/functional.sh (nonexistent) +++ head/tests/sys/capsicum/functional.sh (revision 366470) @@ -0,0 +1,68 @@ +#- +# SPDX-License-Identifier: BSD-2-Clause-FreeBSD +# +# Copyright (c) 2020 The FreeBSD Foundation +# +# This software was developed by Li-Wen Hsu +# under sponsorship from the FreeBSD Foundation. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +SRCDIR=$(atf_get_srcdir) +CAPSICUM_TEST_BIN=capsicum-test + +check() +{ + local tc=${1} + + atf_check -s exit:0 -o match:PASSED -e ignore \ + ${SRCDIR}/${CAPSICUM_TEST_BIN} --gtest_filter=${tc} +} + +add_testcase() +{ + local tc=${1} + local tc_escaped word + + tc_escaped=$(echo ${tc} | sed -e 's/\./__/') + + atf_test_case ${tc_escaped} + eval "${tc_escaped}_body() { check ${tc}; }" + atf_add_test_case ${tc_escaped} +} + +list_tests() +{ + ${SRCDIR}/${CAPSICUM_TEST_BIN} --gtest_list_tests | awk ' + /^[^ ]/ { CAT=$0 } + /^[ ]/ { print CAT $1}' +} + +atf_init_test_cases() +{ + local t + for t in `list_tests`; do + add_testcase $t + done +} Property changes on: head/tests/sys/capsicum/functional.sh ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property