diff --git a/.gitignore b/.gitignore
index b7853f094203ba2d4aa00d6d1e9b9b4273ee0171..73497b8934bd19682b1a4cee1a2a1329d53b84ee 100644
--- a/.gitignore
+++ b/.gitignore
@@ -27,35 +27,6 @@ gen.dSYM/
.deps/
.dirstamp
.libs/
-unit/atf-src/atf-c++/atf-c++.pc
-unit/atf-src/atf-c/atf-c.pc
-unit/atf-src/atf-c/defs.h
-unit/atf-src/atf-c/detail/process_helpers
-unit/atf-src/atf-config/atf-config
-unit/atf-src/atf-report/atf-report
-unit/atf-src/atf-report/fail_helper
-unit/atf-src/atf-report/misc_helpers
-unit/atf-src/atf-report/pass_helper
-unit/atf-src/atf-run/atf-run
-unit/atf-src/atf-run/bad_metadata_helper
-unit/atf-src/atf-run/expect_helpers
-unit/atf-src/atf-run/misc_helpers
-unit/atf-src/atf-run/pass_helper
-unit/atf-src/atf-run/several_tcs_helper
-unit/atf-src/atf-run/zero_tcs_helper
-unit/atf-src/atf-sh/atf-check
-unit/atf-src/atf-sh/atf-sh
-unit/atf-src/atf-sh/misc_helpers
-unit/atf-src/atf-version/atf-version
-unit/atf-src/atf-version/revision.h
-unit/atf-src/atf-version/revision.h.stamp
-unit/atf-src/bconfig.h
-unit/atf-src/bootstrap/atconfig
-unit/atf-src/doc/atf.7
-unit/atf-src/stamp-h1
-unit/atf-src/test-programs/c_helpers
-unit/atf-src/test-programs/cpp_helpers
-unit/atf-src/test-programs/sh_helpers
# ccc-analyzer store its results in .plist directories
*.plist/
*~
diff --git a/CHANGES b/CHANGES
index e75888e33b8131bb2e15613692dfdb29b70b02e1..d2bd08a90dbd27d583e0c75bc22f630bf990d208 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,6 @@
+5097. [cleanup] Remove embedded ATF unit testing framework
+ from BIND source distribution. [GL !875]
+
5096. [func] Use multiple event loops in socket code, and
make network threads CPU-affinitive. This
significantly improves performance on large
diff --git a/README b/README
index 31b58aa1a81f8097563f544e4ebe53d4745206b9..8ea021026a3fe1b988f58a9860da4c0e4c768a12 100644
--- a/README
+++ b/README
@@ -289,8 +289,9 @@ and will be skipped if these are not available. Some tests require Python
and the 'dnspython' module and will be skipped if these are not available.
See bin/tests/system/README for further details.
-Unit tests are implemented using Automated Testing Framework (ATF). To run
-them, use configure --with-atf, then run make test or make unit.
+Unit tests are implemented using cmocka unit testing framework.
+To run them, use configure --with-cmocka, then run make test or
+make unit.
Documentation
diff --git a/README.md b/README.md
index 272e5a7e0bda32c9365b587df8550aaee1fc9464..ea95a9d6c60215e68428d8366a5ccf8dfb38da31 100644
--- a/README.md
+++ b/README.md
@@ -307,8 +307,8 @@ and will be skipped if these are not available. Some tests require Python
and the 'dnspython' module and will be skipped if these are not available.
See bin/tests/system/README for further details.
-Unit tests are implemented using Automated Testing Framework (ATF).
-To run them, use `configure --with-atf`, then run `make test` or
+Unit tests are implemented using cmocka unit testing framework.
+To run them, use `configure --with-cmocka`, then run `make test` or
`make unit`.
### Documentation
diff --git a/config.h.in b/config.h.in
index 2900c299cd6589f19193fedda8478ee367669882..81c5ce8653b460929d5543af2b4cc6547e3f4ae4 100644
--- a/config.h.in
+++ b/config.h.in
@@ -6,9 +6,6 @@
/* Use AES for Client Cookie generation */
#undef AES_CC
-/* define if ATF unit tests are to be built. */
-#undef ATF_TEST
-
/* Define if you cannot bind() before connect() for TCP sockets. */
#undef BROKEN_TCP_BIND_BEFORE_CONNECT
diff --git a/configure b/configure
index 73e40c14b490dd28f6fe18b19363d8035b6e925c..5476a005ee493fd0d435ac6ac9a2f027afcea9d1 100755
--- a/configure
+++ b/configure
@@ -670,6 +670,7 @@ BIND9_ISCCC_BUILDINCLUDE
BIND9_ISC_BUILDINCLUDE
BIND9_TOP_BUILDDIR
LD_WRAP_TESTS
+KYUA
UNITTESTS
CMOCKA_LIBS
CMOCKA_CFLAGS
@@ -841,7 +842,6 @@ infodir
docdir
oldincludedir
includedir
-runstatedir
localstatedir
sharedstatedir
sysconfdir
@@ -961,7 +961,8 @@ OPENSSL_LIBS
LIBIDN2_CFLAGS
LIBIDN2_LIBS
CMOCKA_CFLAGS
-CMOCKA_LIBS'
+CMOCKA_LIBS
+KYUA'
# Initialize some variables set by options.
@@ -1000,7 +1001,6 @@ datadir='${datarootdir}'
sysconfdir='${prefix}/etc'
sharedstatedir='${prefix}/com'
localstatedir='${prefix}/var'
-runstatedir='${localstatedir}/run'
includedir='${prefix}/include'
oldincludedir='/usr/include'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
@@ -1253,15 +1253,6 @@ do
| -silent | --silent | --silen | --sile | --sil)
silent=yes ;;
- -runstatedir | --runstatedir | --runstatedi | --runstated \
- | --runstate | --runstat | --runsta | --runst | --runs \
- | --run | --ru | --r)
- ac_prev=runstatedir ;;
- -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
- | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
- | --run=* | --ru=* | --r=*)
- runstatedir=$ac_optarg ;;
-
-sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
ac_prev=sbindir ;;
-sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1399,7 +1390,7 @@ fi
for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
datadir sysconfdir sharedstatedir localstatedir includedir \
oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
- libdir localedir mandir runstatedir
+ libdir localedir mandir
do
eval ac_val=\$$ac_var
# Remove trailing slashes.
@@ -1552,7 +1543,6 @@ Fine tuning of the installation directories:
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
- --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
@@ -1715,6 +1705,7 @@ Some influential environment variables:
CMOCKA_CFLAGS
C compiler flags for CMOCKA, overriding pkg-config
CMOCKA_LIBS linker flags for CMOCKA, overriding pkg-config
+ KYUA path to kyua execution engine
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -11916,7 +11907,6 @@ yes)
STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DNS_HOOKS_ENABLE=1"
test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
test "${enable_querytrace+set}" = set || enable_querytrace=yes
- test "${with_atf+set}" = set || with_atf=yes
test "${with_cmocka+set}" = set || with_cmocka=yes
test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
test "${enable_symtable+set}" = set || enable_symtable=all
@@ -19884,6 +19874,64 @@ esac
+#
+# Check for kyua execution engine if ATF was requested
+# and bail out if execution engine was not found
+#
+
+if test "$with_cmocka" != "no"; then :
+ for ac_prog in kyua
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_KYUA+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $KYUA in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_KYUA="$KYUA" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_KYUA="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+KYUA=$ac_cv_path_KYUA
+if test -n "$KYUA"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $KYUA" >&5
+$as_echo "$KYUA" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$KYUA" && break
+done
+
+ if test -z "$KYUA"; then :
+ as_fn_error $? "kyua test execution engine not found" "$LINENO" 5
+fi
+fi
+
+
+
#
# Check for -Wl,--wrap= support
#
@@ -19925,6 +19973,9 @@ rm -f core conftest.err conftest.$ac_objext \
LDFLAGS=$save_LDFLAGS
+#
+# Check for i18n
+#
for ac_header in locale.h
do :
ac_fn_c_check_header_mongrel "$LINENO" "locale.h" "ac_cv_header_locale_h" "$ac_includes_default"
diff --git a/configure.ac b/configure.ac
index 96a829c716e6734e0c930e44bf1ec02eb7f6f09f..a01bca0a30963e92152e62e9b119ecb26d93c133 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,6 @@ yes)
STD_CDEFINES="$STD_CDEFINES -DISC_MEM_DEFAULTFILL=1 -DISC_LIST_CHECKINIT=1 -DNS_HOOKS_ENABLE=1"
test "${enable_fixed_rrset+set}" = set || enable_fixed_rrset=yes
test "${enable_querytrace+set}" = set || enable_querytrace=yes
- test "${with_atf+set}" = set || with_atf=yes
test "${with_cmocka+set}" = set || with_cmocka=yes
test "${with_dlz_filesystem+set}" = set || with_dlz_filesystem=yes
test "${enable_symtable+set}" = set || enable_symtable=all
@@ -2436,6 +2435,18 @@ AC_SUBST([CMOCKA_CFLAGS])
AC_SUBST([CMOCKA_LIBS])
AC_SUBST(UNITTESTS)
+#
+# Check for kyua execution engine if ATF was requested
+# and bail out if execution engine was not found
+#
+AC_ARG_VAR([KYUA], [path to kyua execution engine])
+AS_IF([test "$with_cmocka" != "no"],
+ [AC_PATH_PROGS([KYUA], [kyua], [])
+ AS_IF([test -z "$KYUA"],
+ [AC_MSG_ERROR([kyua test execution engine not found])])])
+
+AC_SUBST([KYUA])
+
#
# Check for -Wl,--wrap= support
#
@@ -2458,6 +2469,9 @@ AC_SUBST([LD_WRAP_TESTS])
LDFLAGS=$save_LDFLAGS
+#
+# Check for i18n
+#
AC_CHECK_HEADERS(locale.h)
AC_CHECK_FUNCS(setlocale)
diff --git a/doc/dev/dev.md b/doc/dev/dev.md
index e7e4b897af448e84606db3af96b127c7a0f687ee..b9c37aa7a3f816e0bbc293ab763beb5d9e5afa59 100644
--- a/doc/dev/dev.md
+++ b/doc/dev/dev.md
@@ -197,27 +197,10 @@ points to `rndc`, `SIGNZONE` to `dnssec-signzone`, etc.
#### Building unit tests
-BIND uses the Automated Testing Framework (ATF), originally from the NetBSD
-project, as its unit testing framework. (Note: ATF has been supplanted by
-a newer version called Kyua, but BIND is still using the older system.)
+BIND uses the cmocka, unit testing framework.
-To build BIND with unit tests, run `configure` with the `--with-atf`
-option. This causes the ATF source code in the `unit/atf-src`
-subdirectory to be built.
-
-To save time on repeated builds, you can build and install ATF
-in another directory, and configure BIND to use the pre-built
-version. (Be sure to disable shared libraries in the ATF build,
-and to build the ATF tools; libraries alone are not sufficient).
-
- $ cd atf-src
- $ configure --prefix= --enable-tools --disable-shared
- $ make
- $ make install
-
-After this has been done, specify the ATF prefix when building BIND:
-
- $ configure --with-atf=
+To build BIND with unit tests, run `configure` with the `--with-cmocka`
+option. This requires cmocka >= 1.0.0 to be installed in the system.
#### Running unit tests
@@ -249,53 +232,11 @@ redirected:
#### Writing unit tests
-Information on writing ATF tests can be found at the
-[NetBSD site](http://wiki.netbsd.org/tutorials/atf/).
-
-New unit tests should be added whenever significant new API
-functionality is added to libdns or libisc.
-
-Each unit test file contains at least one unit test case, and
-a list of test cases to execute when the test is run. These
-will look like the following:
-
- ATF_TC(test_case);
- ATF_TC_HEAD(test_case, tc) {
- atf_tc_set_md_var(tc, "descr",
- "Describe the test case here.");
- }
- ATF_TC_BODY(serialize_align, tc) {
- UNUSED(tc);
-
- result = isc_test_begin(NULL, true);
- ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);
-
- ATF_CHECK_EQ(value1, value2);
- ATF_CHECK(value1 + value2 < 100);
-
- isc_test_end();
- }
-
- /*
- * Main
- */
- ATF_TP_ADD_TCS(tp) {
- ATF_TP_ADD_TC(tp, test_case);
-
- return (atf_no_error());
- }
-
-If the conditions specified in `ATF_CHECK` and `ATF_CHECK_EQ`
-directives are found to be false, then the test case will fail, but it
-will continue running to see if there are any more failures.
-
-If the conditions specified in `ATF_REQUIRE` and `ATF_REQUIRE_EQ` are
-found to be false, the test case cannot continue running and will stop
+Information on writing cmocka tests can be found at the
+[cmocka website](https://cmocka.org).
-`isc_test_begin()` and `isc_test_end()` set up necessary preconditions
-for checking libisc functions, such as starting a task manger and
-creating a memory context. Similar functions `dns_test_begin()` and
-`dns_test_end()` are available for testing libdns functions.
+New unit tests should be added whenever new API functionality is added to the
+libraries.
### BIND system architecture
diff --git a/lib/ns/tests/listenlist_test.c b/lib/ns/tests/listenlist_test.c
index 4367b297b03f71fc719d176419f89a3b9b160eb7..40415c1d7c6dad344d7e4fe7ad4c8f368a05a4a0 100644
--- a/lib/ns/tests/listenlist_test.c
+++ b/lib/ns/tests/listenlist_test.c
@@ -15,9 +15,13 @@
#include
#include
+#include
#include
-#include
+#include
+
+#ifdef NS_HOOKS_ENABLE
+
#include
#include
#include
@@ -122,6 +126,17 @@ main(void) {
return (cmocka_run_group_tests(tests, NULL, NULL));
}
+#else
+
+#include
+
+int
+main(void) {
+ printf("1..0 # Skipped: libns hooks not enabled\n");
+ return (0);
+}
+
+#endif /* NS_HOOKS_ENABLE */
#else /* HAVE_CMOCKA */
@@ -133,4 +148,4 @@ main(void) {
return (0);
}
-#endif
+#endif /* HAVE_CMOCKA */
diff --git a/lib/ns/tests/notify_test.c b/lib/ns/tests/notify_test.c
index 990c3b99efcb4c37afebb5ecb6ab4197a17f7832..e1e2654ca3882d7140a8c797b72fe3070c8dcb39 100644
--- a/lib/ns/tests/notify_test.c
+++ b/lib/ns/tests/notify_test.c
@@ -15,9 +15,13 @@
#include
#include
+#include
#include
-#include
+#include
+
+#ifdef NS_HOOKS_ENABLE
+
#include
#include
#include
@@ -150,6 +154,17 @@ main(void) {
return (cmocka_run_group_tests(tests, NULL, NULL));
}
+#else
+
+#include
+
+int
+main(void) {
+ printf("1..0 # Skipped: libns hooks not enabled\n");
+ return (0);
+}
+
+#endif /* NS_HOOKS_ENABLE */
#else /* HAVE_CMOCKA */
diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c
index 2e6a97d437671e8dbb99d42a18a0870dab69cb17..85c641bcd4828f8b7517799129d79db1544501d5 100644
--- a/lib/ns/tests/nstest.c
+++ b/lib/ns/tests/nstest.c
@@ -13,6 +13,8 @@
#include
+#ifdef NS_HOOKS_ENABLE
+
#include
#include
#include
@@ -925,3 +927,4 @@ ns_test_getdata(const char *file, unsigned char *buf,
isc_stdio_close(f);
return (result);
}
+#endif
diff --git a/lib/ns/tests/query_test.c b/lib/ns/tests/query_test.c
index 0261c81d898c29cbd702d569ed5b7c898caecd86..21c68e4c7638331ee3a657dbc765d7b5be00ae90 100644
--- a/lib/ns/tests/query_test.c
+++ b/lib/ns/tests/query_test.c
@@ -17,6 +17,10 @@
#include
#include
+#include
+
+#ifdef NS_HOOKS_ENABLE
+
#include
#include
#include
@@ -27,7 +31,6 @@
#include
#include
-#include
#include
#include
#include
@@ -601,6 +604,17 @@ main(void) {
return (cmocka_run_group_tests(tests, NULL, NULL));
}
+#else
+
+#include
+
+int
+main(void) {
+ printf("1..0 # Skipped: libns hooks not enabled\n");
+ return (0);
+}
+
+#endif /* NS_HOOKS_ENABLE */
#else /* HAVE_CMOCKA */
@@ -612,4 +626,4 @@ main(void) {
return (0);
}
-#endif
+#endif /* HAVE_CMOCKA */
diff --git a/unit/README b/unit/README
index 35edf4cfed0c5861634a3163cfa8c98591354d2e..5775ef87eff0b5b83b512a0fec94dc0ac82b13aa 100644
--- a/unit/README
+++ b/unit/README
@@ -1,21 +1,7 @@
-These unit tests for BIND 9 are based on the NetBSD Automated Test Framework
-release 0.17.
+Unit tests for BIND 9 are based on cmocka and test execution engine Kyua.
-To build an external copy of ATF for use by BIND 9:
+If your distribution of choice doesn't include packages for kyua or cmocka, the
+sources can be found here:
- $ cd atf-src
- $ configure --prefix= --enable-tools --disable-shared
- $ make
- $ make install
-
-Subsequently, specify the ATF prefix when building BIND 9:
-
- $ configure --with-atf=
-
-ATF can also be built automatically during the BIND 9 build,
-by specifying --with-atf without an argument:
-
- $ configure --with-atf
-
-This causes BIND 9 to build ATF in the atf-src directory and
-link to it directly.
+ * Kyua 0.13 - https://github.com/jmmv/kyua/releases
+ * CMocka 1.0 - https://cmocka.org/files/
diff --git a/unit/unittest.sh.in b/unit/unittest.sh.in
index eb6c29735c3599c4a5ec5a1ef84b2e4ce7ebdd71..c46e2fc40cc79f879314d5de6d740b08b2491196 100755
--- a/unit/unittest.sh.in
+++ b/unit/unittest.sh.in
@@ -1,29 +1,27 @@
#!/bin/sh
-
-PATH="@ATFBIN@:${PATH}"
-export PATH
-KYUA=`command -v kyua 2>/dev/null`
+KYUA=@KYUA@
+UNITTESTS=@UNITTESTS@
CMOCKA_MESSAGE_OUTPUT=TAP
export CMOCKA_MESSAGE_OUTPUT
status=0
-if [ -n "@UNITTESTS@" -a -x "$KYUA" -a -f Kyuafile ]
+if [ -n "${UNITTESTS}" ] && [ -f Kyuafile ]
then
- echo "S:unit:`date`"
+ echo "S:unit:$(date)"
echo "T:unit:1:A"
echo "I: unit tests (using kyua)"
- $KYUA -v parallelism=${TEST_PARALLEL_JOBS:-1} --logfile kyua.log --loglevel debug test --results-file ${KYUA_RESULT:-NEW}
+ ${KYUA} -v parallelism="${TEST_PARALLEL_JOBS:-1}" --logfile kyua.log --loglevel debug test --results-file "${KYUA_RESULT:-NEW}"
status=$?
- $KYUA report --results-file ${KYUA_RESULT:-LATEST}
+ ${KYUA} report --results-file "${KYUA_RESULT:-LATEST}"
- if [ $status -eq 0 ]
+ if [ "${status}" -eq "0" ]
then
rm -f kyua.log
- echo R:PASS
+ echo "R:PASS"
else
- echo R:FAIL
+ echo "R:FAIL"
fi
- echo "E:unit:`date`"
+ echo "E:unit:$(date)"
fi
-exit $status
+exit ${status}
diff --git a/util/merge_copyrights b/util/merge_copyrights
index 28ee0c20ef731f9ccb78ef3b3790ccb5b4a5c8a0..8f90eeb0b264f9d21aea42d64b16b63fd08a943b 100644
--- a/util/merge_copyrights
+++ b/util/merge_copyrights
@@ -68,8 +68,6 @@ while () {
# Contributed code should maintain its own copyright.
if ($base =~ /\.\/contrib\//) {
$file_types{$_} = "X";
- } elsif ($base =~ /\.\/unit\/atf-src\//) {
- $file_types{$_} = "X";
} elsif ($base =~ /\/openssl-[a-z0-9.]*-patch$/) {
$file_types{$_} = "X";
} elsif ($base =~ /\.(c|h|css)$/) {
@@ -109,7 +107,7 @@ while () {
$file_types{$_} = "CONF-SH";
} elsif ($base =~ /\.md$/) {
$file_types{$_} = "MKD";
- } elsif ($base =~ /(\/\.(gitignore|gitattributes)|Atffile|Kyuafile|\.(gif|jpg))$/i) {
+ } elsif ($base =~ /(\/\.(gitignore|gitattributes)|Kyuafile|\.(gif|jpg))$/i) {
$file_types{$_} = "X";
} elsif ($base =~ /\.(def|dep|dsp|dsw|mak|sln)$/i) {
$file_types{$_} = "X";
diff --git a/util/models.c b/util/models.c
index 2e2db2b1d8ac01d79df3a6aac44c943c39e910ad..48e58f4f1c30f45de9e05067b4108824a4fa698e 100644
--- a/util/models.c
+++ b/util/models.c
@@ -94,7 +94,3 @@ void isc__mempool_put(void *mem, void *ptr FLARG) {
if (!mem) __coverity_panic__();
__coverity_free__(ptr);
}
-
-void atf_tc_fail_requirement(const char *, const size_t, const char *, ...) {
- __coverity_panic__();
-}