aboutsummaryrefslogtreecommitdiff
path: root/libexec/atf
diff options
context:
space:
mode:
Diffstat (limited to 'libexec/atf')
-rw-r--r--libexec/atf/Makefile29
-rw-r--r--libexec/atf/Makefile.inc33
-rw-r--r--libexec/atf/atf-check/Makefile45
-rw-r--r--libexec/atf/atf-check/Makefile.depend20
-rw-r--r--libexec/atf/atf-check/Makefile.inc1
-rw-r--r--libexec/atf/atf-check/tests/Makefile8
-rw-r--r--libexec/atf/atf-check/tests/Makefile.depend10
-rw-r--r--libexec/atf/atf-pytest-wrapper/Makefile8
-rw-r--r--libexec/atf/atf-pytest-wrapper/Makefile.depend18
-rw-r--r--libexec/atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp229
-rw-r--r--libexec/atf/atf-sh/Makefile80
-rw-r--r--libexec/atf/atf-sh/Makefile.depend20
-rw-r--r--libexec/atf/atf-sh/tests/Makefile26
-rw-r--r--libexec/atf/atf-sh/tests/Makefile.depend10
-rw-r--r--libexec/atf/tests/Makefile7
-rw-r--r--libexec/atf/tests/Makefile.depend10
16 files changed, 554 insertions, 0 deletions
diff --git a/libexec/atf/Makefile b/libexec/atf/Makefile
new file mode 100644
index 000000000000..e3002d6c7626
--- /dev/null
+++ b/libexec/atf/Makefile
@@ -0,0 +1,29 @@
+#-
+# Copyright (c) 2011 Google, Inc.
+# All rights reserved.
+#
+# 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.
+#
+
+SUBDIR= atf-check atf-pytest-wrapper atf-sh tests
+
+.include <bsd.subdir.mk>
diff --git a/libexec/atf/Makefile.inc b/libexec/atf/Makefile.inc
new file mode 100644
index 000000000000..5fd06c35cd09
--- /dev/null
+++ b/libexec/atf/Makefile.inc
@@ -0,0 +1,33 @@
+#-
+# Copyright (c) 2011 Google, Inc.
+# All rights reserved.
+#
+# 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.
+#
+
+PACKAGE?= atf
+LIB_PACKAGE=
+CFLAGS+= -DHAVE_CONFIG_H
+
+WARNS?= 3
+
+.include "../Makefile.inc"
diff --git a/libexec/atf/atf-check/Makefile b/libexec/atf/atf-check/Makefile
new file mode 100644
index 000000000000..cf598e384c86
--- /dev/null
+++ b/libexec/atf/atf-check/Makefile
@@ -0,0 +1,45 @@
+#-
+# Copyright (c) 2011 Google, Inc.
+# All rights reserved.
+#
+# 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.
+#
+
+.include <src.opts.mk>
+.include <bsd.init.mk>
+
+ATF= ${SRCTOP}/contrib/atf
+.PATH: ${ATF}/atf-sh
+
+PROG_CXX= atf-check
+SRCS= atf-check.cpp
+MAN= atf-check.1
+
+CFLAGS+= -I${ATF}
+CFLAGS+= -DATF_SHELL='"/bin/sh"'
+
+LIBADD= atf_cxx
+
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+.include <bsd.prog.mk>
diff --git a/libexec/atf/atf-check/Makefile.depend b/libexec/atf/atf-check/Makefile.depend
new file mode 100644
index 000000000000..7886e7624456
--- /dev/null
+++ b/libexec/atf/atf-check/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/atf/libatf-c \
+ lib/atf/libatf-c++ \
+ lib/libc \
+ lib/libc++ \
+ lib/libcompiler_rt \
+ lib/libcxxrt \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/atf/atf-check/Makefile.inc b/libexec/atf/atf-check/Makefile.inc
new file mode 100644
index 000000000000..01b5f23410c8
--- /dev/null
+++ b/libexec/atf/atf-check/Makefile.inc
@@ -0,0 +1 @@
+.include "../Makefile.inc"
diff --git a/libexec/atf/atf-check/tests/Makefile b/libexec/atf/atf-check/tests/Makefile
new file mode 100644
index 000000000000..6e21e4ede211
--- /dev/null
+++ b/libexec/atf/atf-check/tests/Makefile
@@ -0,0 +1,8 @@
+ATF= ${SRCTOP}/contrib/atf
+.PATH: ${ATF}/atf-sh
+
+PACKAGE= tests
+
+ATF_TESTS_SH= atf-check_test
+
+.include <bsd.test.mk>
diff --git a/libexec/atf/atf-check/tests/Makefile.depend b/libexec/atf/atf-check/tests/Makefile.depend
new file mode 100644
index 000000000000..11aba52f82cf
--- /dev/null
+++ b/libexec/atf/atf-check/tests/Makefile.depend
@@ -0,0 +1,10 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/atf/atf-pytest-wrapper/Makefile b/libexec/atf/atf-pytest-wrapper/Makefile
new file mode 100644
index 000000000000..75b1bc3e1004
--- /dev/null
+++ b/libexec/atf/atf-pytest-wrapper/Makefile
@@ -0,0 +1,8 @@
+.include <src.opts.mk>
+.include <bsd.init.mk>
+
+PROG_CXX= atf_pytest_wrapper
+SRCS= atf_pytest_wrapper.cpp
+MAN=
+
+.include <bsd.prog.mk>
diff --git a/libexec/atf/atf-pytest-wrapper/Makefile.depend b/libexec/atf/atf-pytest-wrapper/Makefile.depend
new file mode 100644
index 000000000000..76a8d2cdc8ca
--- /dev/null
+++ b/libexec/atf/atf-pytest-wrapper/Makefile.depend
@@ -0,0 +1,18 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/libc \
+ lib/libc++ \
+ lib/libcompiler_rt \
+ lib/libcxxrt \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp b/libexec/atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp
new file mode 100644
index 000000000000..b0cc600bde21
--- /dev/null
+++ b/libexec/atf/atf-pytest-wrapper/atf_pytest_wrapper.cpp
@@ -0,0 +1,229 @@
+// vim: ts=2 sw=2 et
+
+#include <format>
+#include <iostream>
+#include <map>
+#include <string>
+#include <vector>
+#include <stdlib.h>
+#include <unistd.h>
+
+class Handler {
+ private:
+ const std::string kPytestName = "pytest";
+ const std::string kCleanupSuffix = ":cleanup";
+ const std::string kPythonPathEnv = "PYTHONPATH";
+ const std::string kAtfVar = "_ATF_VAR_";
+ public:
+ // Test listing requested
+ bool flag_list = false;
+ // Output debug data (will break listing)
+ bool flag_debug = false;
+ // Cleanup for the test requested
+ bool flag_cleanup = false;
+ // Test source directory (provided by ATF)
+ std::string src_dir;
+ // Path to write test status to (provided by ATF)
+ std::string dst_file;
+ // Path to add to PYTHONPATH (provided by the schebang args)
+ std::string python_path;
+ // Path to the script (provided by the schebang wrapper)
+ std::string script_path;
+ // Name of the test to run (provided by ATF)
+ std::string test_name;
+ // kv pairs (provided by ATF)
+ std::map<std::string,std::string> kv_map;
+ // our binary name
+ std::string binary_name;
+
+ static std::vector<std::string> ToVector(int argc, char **argv) {
+ std::vector<std::string> ret;
+
+ for (int i = 0; i < argc; i++) {
+ ret.emplace_back(std::string(argv[i]));
+ }
+ return ret;
+ }
+
+ static void PrintVector(std::string prefix, const std::vector<std::string> &vec) {
+ std::cerr << prefix << ": ";
+ for (auto &val: vec) {
+ std::cerr << "'" << val << "' ";
+ }
+ std::cerr << std::endl;
+ }
+
+ void Usage(std::string msg, bool exit_with_error) {
+ std::cerr << binary_name << ": ERROR: " << msg << "." << std::endl;
+ std::cerr << binary_name << ": See atf-test-program(1) for usage details." << std::endl;
+ exit(exit_with_error != 0);
+ }
+
+ // Parse args received from the OS. There can be multiple valid options:
+ // * with schebang args (#!/binary -P/path):
+ // atf_wrap '-P /path' /path/to/script -l
+ // * without schebang args
+ // atf_wrap /path/to/script -l
+ // Running test:
+ // atf_wrap '-P /path' /path/to/script -r /path1 -s /path2 -vk1=v1 testname
+ void Parse(int argc, char **argv) {
+ if (flag_debug) {
+ PrintVector("IN", ToVector(argc, argv));
+ }
+ // getopt() skips the first argument (as it is typically binary name)
+ // it is possible to have either '-P\s*/path' followed by the script name
+ // or just the script name. Parse kernel-provided arg manually and adjust
+ // array to make getopt work
+
+ binary_name = std::string(argv[0]);
+ argc--; argv++;
+ // parse -P\s*path from the kernel.
+ if (argc > 0 && !strncmp(argv[0], "-P", 2)) {
+ char *path = &argv[0][2];
+ while (*path == ' ')
+ path++;
+ python_path = std::string(path);
+ argc--; argv++;
+ }
+
+ // The next argument is a script name. Copy and keep argc/argv the same
+ // Show usage for empty args
+ if (argc == 0) {
+ Usage("Must provide a test case name", true);
+ }
+ script_path = std::string(argv[0]);
+
+ int c;
+ while ((c = getopt(argc, argv, "lr:s:v:")) != -1) {
+ switch (c) {
+ case 'l':
+ flag_list = true;
+ break;
+ case 's':
+ src_dir = std::string(optarg);
+ break;
+ case 'r':
+ dst_file = std::string(optarg);
+ break;
+ case 'v':
+ {
+ std::string kv = std::string(optarg);
+ size_t splitter = kv.find("=");
+ if (splitter == std::string::npos) {
+ Usage("Unknown variable: " + kv, true);
+ }
+ kv_map[kv.substr(0, splitter)] = kv.substr(splitter + 1);
+ }
+ break;
+ default:
+ Usage("Unknown option -" + std::string(1, static_cast<char>(c)), true);
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (flag_list) {
+ return;
+ }
+ // There should be just one argument with the test name
+ if (argc != 1) {
+ Usage("Must provide a test case name", true);
+ }
+ test_name = std::string(argv[0]);
+ if (test_name.size() > kCleanupSuffix.size() &&
+ std::equal(kCleanupSuffix.rbegin(), kCleanupSuffix.rend(), test_name.rbegin())) {
+ test_name = test_name.substr(0, test_name.size() - kCleanupSuffix.size());
+ flag_cleanup = true;
+ }
+ }
+
+ std::vector<std::string> BuildArgs() {
+ std::vector<std::string> args = {"pytest", "-vv", "-p",
+ "no:cacheprovider", "-s", "--atf"};
+
+ args.push_back("--confcutdir=" + python_path);
+
+ if (flag_list) {
+ args.push_back("--co");
+ args.push_back(script_path);
+ return args;
+ }
+ if (flag_cleanup) {
+ args.push_back("--atf-cleanup");
+ }
+ // workaround pytest parser bug:
+ // https://github.com/pytest-dev/pytest/issues/3097
+ // use '--arg=value' format instead of '--arg value' for all
+ // path-like options
+ if (!src_dir.empty()) {
+ args.push_back("--atf-source-dir=" + src_dir);
+ }
+ if (!dst_file.empty()) {
+ args.push_back("--atf-file=" + dst_file);
+ }
+ // Create nodeid from the test path &name
+ args.push_back(script_path + "::" + test_name);
+ return args;
+ }
+
+ void SetPythonPath() {
+ if (!python_path.empty()) {
+ char *env_path = getenv(kPythonPathEnv.c_str());
+ if (env_path != nullptr) {
+ python_path = python_path + ":" + std::string(env_path);
+ }
+ setenv(kPythonPathEnv.c_str(), python_path.c_str(), 1);
+ }
+ }
+
+ void SetEnv() {
+ SetPythonPath();
+
+ // Pass ATF kv pairs as env variables to avoid dealing with
+ // pytest parser
+ for (auto [k, v]: kv_map) {
+ setenv((kAtfVar + k).c_str(), v.c_str(), 1);
+ }
+ }
+
+ bool Run(std::string binary, std::vector<std::string> args) {
+ if (flag_debug) {
+ PrintVector("OUT", args);
+ }
+ // allocate array with final NULL
+ char **arr = new char*[args.size() + 1]();
+ for (unsigned long i = 0; i < args.size(); i++) {
+ // work around 'char *const *'
+ arr[i] = strdup(args[i].c_str());
+ }
+ return execvp(binary.c_str(), arr) == 0;
+ }
+
+ void ReportError() {
+ if (flag_list) {
+ std::cout << "Content-Type: application/X-atf-tp; version=\"1\"";
+ std::cout << std::endl << std::endl;
+ std::cout << "ident: __test_cases_list_"<< kPytestName << "_binary_" <<
+ "not_found__" << std::endl;
+ } else {
+ std::cout << "execvp(" << kPytestName << ") failed: " <<
+ std::strerror(errno) << std::endl;
+ }
+ }
+
+ int Process() {
+ SetEnv();
+ if (!Run(kPytestName, BuildArgs())) {
+ ReportError();
+ }
+ return 0;
+ }
+};
+
+
+int main(int argc, char **argv) {
+ Handler handler;
+
+ handler.Parse(argc, argv);
+ return handler.Process();
+}
diff --git a/libexec/atf/atf-sh/Makefile b/libexec/atf/atf-sh/Makefile
new file mode 100644
index 000000000000..afd848581f36
--- /dev/null
+++ b/libexec/atf/atf-sh/Makefile
@@ -0,0 +1,80 @@
+#-
+# Copyright (c) 2011 Google, Inc.
+# All rights reserved.
+#
+# 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.
+#
+
+.include <src.opts.mk>
+.include <bsd.init.mk>
+
+ATF= ${SRCTOP}/contrib/atf
+.PATH: ${ATF}/atf-sh
+
+PROG_CXX= atf-sh
+SRCS= atf-sh.cpp
+MAN= atf-sh.1 atf-sh.3
+# Backwards compatibility.
+MLINKS+= atf-sh.3 atf-sh-api.3
+
+MLINKS+= \
+ atf-sh.3 atf_add_test_case.3 \
+ atf-sh.3 atf_check.3 \
+ atf-sh.3 atf_check_equal.3 \
+ atf-sh.3 atf_config_get.3 \
+ atf-sh.3 atf_config_has.3 \
+ atf-sh.3 atf_expect_death.3 \
+ atf-sh.3 atf_expect_exit.3 \
+ atf-sh.3 atf_expect_fail.3 \
+ atf-sh.3 atf_expect_pass.3 \
+ atf-sh.3 atf_expect_signal.3 \
+ atf-sh.3 atf_expect_timeout.3 \
+ atf-sh.3 atf_fail.3 \
+ atf-sh.3 atf_get.3 \
+ atf-sh.3 atf_get_srcdir.3 \
+ atf-sh.3 atf_init_test_cases.3 \
+ atf-sh.3 atf_pass.3 \
+ atf-sh.3 atf_require_kmod.3 \
+ atf-sh.3 atf_require_prog.3 \
+ atf-sh.3 atf_set.3 \
+ atf-sh.3 atf_skip.3 \
+ atf-sh.3 atf_test_case.3
+
+CFLAGS+= -DHAVE_CONFIG_H
+CFLAGS+= -DATF_LIBEXECDIR='"${LIBEXECDIR}"'
+CFLAGS+= -DATF_PKGDATADIR='"${SHAREDIR}/atf"'
+CFLAGS+= -DATF_SHELL='"/bin/sh"'
+CFLAGS+= -I${ATF}
+
+LIBADD= atf_cxx
+
+FILESGROUPS= SUBR
+
+SUBRDIR= ${SHAREDIR}/atf
+SUBR= libatf-sh.subr
+SUBRTAGS= package=tests
+
+HAS_TESTS=
+SUBDIR.${MK_TESTS}+= tests
+
+.include "../../../lib/atf/common.mk"
+.include <bsd.prog.mk>
diff --git a/libexec/atf/atf-sh/Makefile.depend b/libexec/atf/atf-sh/Makefile.depend
new file mode 100644
index 000000000000..7886e7624456
--- /dev/null
+++ b/libexec/atf/atf-sh/Makefile.depend
@@ -0,0 +1,20 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ include \
+ include/xlocale \
+ lib/${CSU_DIR} \
+ lib/atf/libatf-c \
+ lib/atf/libatf-c++ \
+ lib/libc \
+ lib/libc++ \
+ lib/libcompiler_rt \
+ lib/libcxxrt \
+ lib/msun \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/atf/atf-sh/tests/Makefile b/libexec/atf/atf-sh/tests/Makefile
new file mode 100644
index 000000000000..d358ed403a47
--- /dev/null
+++ b/libexec/atf/atf-sh/tests/Makefile
@@ -0,0 +1,26 @@
+.include <bsd.init.mk>
+
+ATF= ${SRCTOP}/contrib/atf
+.PATH: ${ATF}/atf-sh
+
+ATF_TESTS_SH+= atf_check_test
+ATF_TESTS_SH+= config_test
+ATF_TESTS_SH+= integration_test
+ATF_TESTS_SH+= normalize_test
+ATF_TESTS_SH+= tc_test
+ATF_TESTS_SH+= tp_test
+
+integration_test: Makefile
+ATF_TESTS_SH_SED_integration_test= \
+ -e 's,__ATF_SH__,/usr/libexec/atf-sh,g'
+
+SCRIPTS+= misc_helpers
+SCRIPTSDIR_misc_helpers=${TESTSDIR}
+CLEANFILES+= misc_helpers misc_helpers.tmp
+misc_helpers: misc_helpers.sh
+ echo '#! /usr/libexec/atf-sh' >${.TARGET}.tmp
+ cat ${.ALLSRC} >>${.TARGET}.tmp
+ chmod +x ${.TARGET}.tmp
+ mv ${.TARGET}.tmp ${.TARGET}
+
+.include <bsd.test.mk>
diff --git a/libexec/atf/atf-sh/tests/Makefile.depend b/libexec/atf/atf-sh/tests/Makefile.depend
new file mode 100644
index 000000000000..11aba52f82cf
--- /dev/null
+++ b/libexec/atf/atf-sh/tests/Makefile.depend
@@ -0,0 +1,10 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/libexec/atf/tests/Makefile b/libexec/atf/tests/Makefile
new file mode 100644
index 000000000000..ad9431e75a63
--- /dev/null
+++ b/libexec/atf/tests/Makefile
@@ -0,0 +1,7 @@
+.PATH: ${SRCTOP}/tests
+
+PACKAGE= tests
+
+KYUAFILE= yes
+
+.include <bsd.test.mk>
diff --git a/libexec/atf/tests/Makefile.depend b/libexec/atf/tests/Makefile.depend
new file mode 100644
index 000000000000..11aba52f82cf
--- /dev/null
+++ b/libexec/atf/tests/Makefile.depend
@@ -0,0 +1,10 @@
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif