summaryrefslogtreecommitdiffstats
path: root/tests/ns
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:59:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 15:59:48 +0000
commit3b9b6d0b8e7f798023c9d109c490449d528fde80 (patch)
tree2e1c188dd7b8d7475cd163de9ae02c428343669b /tests/ns
parentInitial commit. (diff)
downloadbind9-3b9b6d0b8e7f798023c9d109c490449d528fde80.tar.xz
bind9-3b9b6d0b8e7f798023c9d109c490449d528fde80.zip
Adding upstream version 1:9.18.19.upstream/1%9.18.19upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ns')
-rw-r--r--tests/ns/Makefile.am25
-rw-r--r--tests/ns/Makefile.in1219
-rw-r--r--tests/ns/listenlist_test.c119
-rw-r--r--tests/ns/notify_test.c141
-rw-r--r--tests/ns/plugin_test.c166
-rw-r--r--tests/ns/query_test.c1500
-rw-r--r--tests/ns/testdata/notify/notify1.msg3
-rw-r--r--tests/ns/testdata/notify/zone1.db26
-rw-r--r--tests/ns/testdata/query/foo.db20
9 files changed, 3219 insertions, 0 deletions
diff --git a/tests/ns/Makefile.am b/tests/ns/Makefile.am
new file mode 100644
index 0000000..33f91d8
--- /dev/null
+++ b/tests/ns/Makefile.am
@@ -0,0 +1,25 @@
+include $(top_srcdir)/Makefile.top
+
+AM_CPPFLAGS += \
+ $(LIBISC_CFLAGS) \
+ $(LIBDNS_CFLAGS) \
+ $(LIBNS_CFLAGS) \
+ $(LIBUV_CFLAGS) \
+ -I$(top_srcdir)/lib/isc \
+ -I$(top_srcdir)/lib/dns
+
+LDADD += \
+ $(LIBISC_LIBS) \
+ $(LIBDNS_LIBS) \
+ $(LIBNS_LIBS) \
+ $(LIBUV_LIBS)
+
+check_PROGRAMS = \
+ listenlist_test \
+ notify_test \
+ plugin_test \
+ query_test
+
+EXTRA_DIST = testdata
+
+include $(top_srcdir)/Makefile.tests
diff --git a/tests/ns/Makefile.in b/tests/ns/Makefile.in
new file mode 100644
index 0000000..efa0cc9
--- /dev/null
+++ b/tests/ns/Makefile.in
@@ -0,0 +1,1219 @@
+# Makefile.in generated by automake 1.16.5 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2021 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Hey Emacs, this is -*- makefile-automake -*- file!
+# vim: filetype=automake
+
+# Hey Emacs, this is -*- makefile-automake -*- file!
+# vim: filetype=automake
+VPATH = @srcdir@
+am__is_gnu_make = { \
+ if test -z '$(MAKELEVEL)'; then \
+ false; \
+ elif test -n '$(MAKE_HOST)'; then \
+ true; \
+ elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+ true; \
+ else \
+ false; \
+ fi; \
+}
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+@HOST_MACOS_TRUE@am__append_1 = \
+@HOST_MACOS_TRUE@ -Wl,-flat_namespace
+
+check_PROGRAMS = listenlist_test$(EXEEXT) notify_test$(EXEEXT) \
+ plugin_test$(EXEEXT) query_test$(EXEEXT)
+subdir = tests/ns
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ax_check_compile_flag.m4 \
+ $(top_srcdir)/m4/ax_check_link_flag.m4 \
+ $(top_srcdir)/m4/ax_check_openssl.m4 \
+ $(top_srcdir)/m4/ax_gcc_func_attribute.m4 \
+ $(top_srcdir)/m4/ax_jemalloc.m4 \
+ $(top_srcdir)/m4/ax_lib_lmdb.m4 \
+ $(top_srcdir)/m4/ax_perl_module.m4 \
+ $(top_srcdir)/m4/ax_posix_shell.m4 \
+ $(top_srcdir)/m4/ax_prog_cc_for_build.m4 \
+ $(top_srcdir)/m4/ax_pthread.m4 \
+ $(top_srcdir)/m4/ax_python_module.m4 \
+ $(top_srcdir)/m4/ax_restore_flags.m4 \
+ $(top_srcdir)/m4/ax_save_flags.m4 $(top_srcdir)/m4/ax_tls.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+listenlist_test_SOURCES = listenlist_test.c
+listenlist_test_OBJECTS = listenlist_test.$(OBJEXT)
+listenlist_test_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+listenlist_test_DEPENDENCIES = $(LIBISC_LIBS) $(LIBDNS_LIBS) \
+ $(LIBNS_LIBS) $(am__DEPENDENCIES_1) \
+ $(top_builddir)/tests/libtest/libtest.la $(am__DEPENDENCIES_1)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+notify_test_SOURCES = notify_test.c
+notify_test_OBJECTS = notify_test.$(OBJEXT)
+notify_test_LDADD = $(LDADD)
+notify_test_DEPENDENCIES = $(LIBISC_LIBS) $(LIBDNS_LIBS) $(LIBNS_LIBS) \
+ $(am__DEPENDENCIES_1) $(top_builddir)/tests/libtest/libtest.la \
+ $(am__DEPENDENCIES_1)
+plugin_test_SOURCES = plugin_test.c
+plugin_test_OBJECTS = plugin_test.$(OBJEXT)
+plugin_test_LDADD = $(LDADD)
+plugin_test_DEPENDENCIES = $(LIBISC_LIBS) $(LIBDNS_LIBS) $(LIBNS_LIBS) \
+ $(am__DEPENDENCIES_1) $(top_builddir)/tests/libtest/libtest.la \
+ $(am__DEPENDENCIES_1)
+query_test_SOURCES = query_test.c
+query_test_OBJECTS = query_test.$(OBJEXT)
+query_test_LDADD = $(LDADD)
+query_test_DEPENDENCIES = $(LIBISC_LIBS) $(LIBDNS_LIBS) $(LIBNS_LIBS) \
+ $(am__DEPENDENCIES_1) $(top_builddir)/tests/libtest/libtest.la \
+ $(am__DEPENDENCIES_1)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/listenlist_test.Po \
+ ./$(DEPDIR)/notify_test.Po ./$(DEPDIR)/plugin_test.Po \
+ ./$(DEPDIR)/query_test.Po
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = listenlist_test.c notify_test.c plugin_test.c query_test.c
+DIST_SOURCES = listenlist_test.c notify_test.c plugin_test.c \
+ query_test.c
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+am__extra_recursive_targets = test-recursive unit-recursive \
+ doc-recursive
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+am__tty_colors_dummy = \
+ mgn= red= grn= lgn= blu= brg= std=; \
+ am__color_tests=no
+am__tty_colors = { \
+ $(am__tty_colors_dummy); \
+ if test "X$(AM_COLOR_TESTS)" = Xno; then \
+ am__color_tests=no; \
+ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
+ am__color_tests=yes; \
+ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
+ am__color_tests=yes; \
+ fi; \
+ if test $$am__color_tests = yes; then \
+ red=''; \
+ grn=''; \
+ lgn=''; \
+ blu=''; \
+ mgn=''; \
+ brg=''; \
+ std=''; \
+ fi; \
+}
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__recheck_rx = ^[ ]*:recheck:[ ]*
+am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
+am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
+# A command that, given a newline-separated list of test names on the
+# standard input, print the name of the tests that are to be re-run
+# upon "make recheck".
+am__list_recheck_tests = $(AWK) '{ \
+ recheck = 1; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ { \
+ if ((getline line2 < ($$0 ".log")) < 0) \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+ { \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+ { \
+ break; \
+ } \
+ }; \
+ if (recheck) \
+ print $$0; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# A command that, given a newline-separated list of test names on the
+# standard input, create the global log from their .trs and .log files.
+am__create_global_log = $(AWK) ' \
+function fatal(msg) \
+{ \
+ print "fatal: making $@: " msg | "cat >&2"; \
+ exit 1; \
+} \
+function rst_section(header) \
+{ \
+ print header; \
+ len = length(header); \
+ for (i = 1; i <= len; i = i + 1) \
+ printf "="; \
+ printf "\n\n"; \
+} \
+{ \
+ copy_in_global_log = 1; \
+ global_test_result = "RUN"; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".trs"); \
+ if (line ~ /$(am__global_test_result_rx)/) \
+ { \
+ sub("$(am__global_test_result_rx)", "", line); \
+ sub("[ ]*$$", "", line); \
+ global_test_result = line; \
+ } \
+ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+ copy_in_global_log = 0; \
+ }; \
+ if (copy_in_global_log) \
+ { \
+ rst_section(global_test_result ": " $$0); \
+ while ((rc = (getline line < ($$0 ".log"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".log"); \
+ print line; \
+ }; \
+ printf "\n"; \
+ }; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# Restructured Text title.
+am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+ --color-tests "$$am__color_tests" \
+ --enable-hard-errors "$$am__enable_hard_errors" \
+ --expect-failure "$$am__expect_failure"
+# To be inserted before the command running the test. Creates the
+# directory for the log if needed. Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log. Executes the
+# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
+# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
+am__check_pre = \
+$(am__sh_e_setup); \
+$(am__vpath_adj_setup) $(am__vpath_adj) \
+$(am__tty_colors); \
+srcdir=$(srcdir); export srcdir; \
+case "$@" in \
+ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
+ *) am__odir=.;; \
+esac; \
+test "x$$am__odir" = x"." || test -d "$$am__odir" \
+ || $(MKDIR_P) "$$am__odir" || exit $$?; \
+if test -f "./$$f"; then dir=./; \
+elif test -f "$$f"; then dir=; \
+else dir="$(srcdir)/"; fi; \
+tst=$$dir$$f; log='$@'; \
+if test -n '$(DISABLE_HARD_ERRORS)'; then \
+ am__enable_hard_errors=no; \
+else \
+ am__enable_hard_errors=yes; \
+fi; \
+case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
+ am__expect_failure=yes;; \
+ *) \
+ am__expect_failure=no;; \
+esac; \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the '.log' extension removed). The result is saved in the shell variable
+# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
+am__set_TESTS_bases = \
+ bases='$(TEST_LOGS)'; \
+ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+ bases=`echo $$bases`
+AM_TESTSUITE_SUMMARY_HEADER = ' for $(PACKAGE_STRING)'
+RECHECK_LOGS = $(TEST_LOGS)
+AM_RECURSIVE_TARGETS = check recheck
+TEST_SUITE_LOG = test-suite.log
+TEST_EXTENSIONS = @EXEEXT@ .test
+LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
+am__set_b = \
+ case '$@' in \
+ */*) \
+ case '$*' in \
+ */*) b='$*';; \
+ *) b=`echo '$@' | sed 's/\.log$$//'`; \
+ esac;; \
+ *) \
+ b='$*';; \
+ esac
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+ $(TEST_LOG_FLAGS)
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/Makefile.tests \
+ $(top_srcdir)/Makefile.top $(top_srcdir)/depcomp \
+ $(top_srcdir)/test-driver
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BUILD_EXEEXT = @BUILD_EXEEXT@
+BUILD_OBJEXT = @BUILD_OBJEXT@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CC_FOR_BUILD = @CC_FOR_BUILD@
+CFLAGS = @CFLAGS@
+CFLAGS_FOR_BUILD = @CFLAGS_FOR_BUILD@
+CMOCKA_CFLAGS = @CMOCKA_CFLAGS@
+CMOCKA_LIBS = @CMOCKA_LIBS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CPPFLAGS_FOR_BUILD = @CPPFLAGS_FOR_BUILD@
+CPP_FOR_BUILD = @CPP_FOR_BUILD@
+CSCOPE = @CSCOPE@
+CTAGS = @CTAGS@
+CURL = @CURL@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DEVELOPER_MODE = @DEVELOPER_MODE@
+DLLTOOL = @DLLTOOL@
+DNSTAP_CFLAGS = @DNSTAP_CFLAGS@
+DNSTAP_LIBS = @DNSTAP_LIBS@
+DOXYGEN = @DOXYGEN@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ETAGS = @ETAGS@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+FILECMD = @FILECMD@
+FSTRM_CAPTURE = @FSTRM_CAPTURE@
+FUZZ_LDFLAGS = @FUZZ_LDFLAGS@
+FUZZ_LOG_COMPILER = @FUZZ_LOG_COMPILER@
+GREP = @GREP@
+GSSAPI_CFLAGS = @GSSAPI_CFLAGS@
+GSSAPI_LIBS = @GSSAPI_LIBS@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JEMALLOC_CFLAGS = @JEMALLOC_CFLAGS@
+JEMALLOC_LIBS = @JEMALLOC_LIBS@
+JSON_C_CFLAGS = @JSON_C_CFLAGS@
+JSON_C_LIBS = @JSON_C_LIBS@
+KRB5_CFLAGS = @KRB5_CFLAGS@
+KRB5_CONFIG = @KRB5_CONFIG@
+KRB5_LIBS = @KRB5_LIBS@
+LATEXMK = @LATEXMK@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LDFLAGS_FOR_BUILD = @LDFLAGS_FOR_BUILD@
+LIBCAP_LIBS = @LIBCAP_LIBS@
+LIBIDN2_CFLAGS = @LIBIDN2_CFLAGS@
+LIBIDN2_LIBS = @LIBIDN2_LIBS@
+LIBNGHTTP2_CFLAGS = @LIBNGHTTP2_CFLAGS@
+LIBNGHTTP2_LIBS = @LIBNGHTTP2_LIBS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBUV_CFLAGS = @LIBUV_CFLAGS@
+LIBUV_LIBS = @LIBUV_LIBS@
+LIBXML2_CFLAGS = @LIBXML2_CFLAGS@
+LIBXML2_LIBS = @LIBXML2_LIBS@
+LIPO = @LIPO@
+LMDB_CFLAGS = @LMDB_CFLAGS@
+LMDB_LIBS = @LMDB_LIBS@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAINT = @MAINT@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MAXMINDDB_CFLAGS = @MAXMINDDB_CFLAGS@
+MAXMINDDB_LIBS = @MAXMINDDB_LIBS@
+MAXMINDDB_PREFIX = @MAXMINDDB_PREFIX@
+MKDIR_P = @MKDIR_P@
+NC = @NC@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OPENSSL_CFLAGS = @OPENSSL_CFLAGS@
+OPENSSL_LDFLAGS = @OPENSSL_LDFLAGS@
+OPENSSL_LIBS = @OPENSSL_LIBS@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PERL = @PERL@
+PKG_CONFIG = @PKG_CONFIG@
+PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@
+PKG_CONFIG_PATH = @PKG_CONFIG_PATH@
+PROTOC_C = @PROTOC_C@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_CXX = @PTHREAD_CXX@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTEST = @PYTEST@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+READLINE_CFLAGS = @READLINE_CFLAGS@
+READLINE_LIBS = @READLINE_LIBS@
+RELEASE_DATE = @RELEASE_DATE@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SPHINX_BUILD = @SPHINX_BUILD@
+STD_CFLAGS = @STD_CFLAGS@
+STD_CPPFLAGS = @STD_CPPFLAGS@
+STD_LDFLAGS = @STD_LDFLAGS@
+STRIP = @STRIP@
+TEST_CFLAGS = @TEST_CFLAGS@
+VERSION = @VERSION@
+XELATEX = @XELATEX@
+XSLTPROC = @XSLTPROC@
+ZLIB_CFLAGS = @ZLIB_CFLAGS@
+ZLIB_LIBS = @ZLIB_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CC_FOR_BUILD = @ac_ct_CC_FOR_BUILD@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+ax_pthread_config = @ax_pthread_config@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ACLOCAL_AMFLAGS = -I $(top_srcdir)/m4
+AM_CFLAGS = $(STD_CFLAGS) -I$(top_srcdir)/tests/include $(TEST_CFLAGS)
+AM_CPPFLAGS = $(STD_CPPFLAGS) -include $(top_builddir)/config.h \
+ -I$(srcdir)/include $(LIBISC_CFLAGS) $(LIBDNS_CFLAGS) \
+ $(LIBNS_CFLAGS) $(LIBUV_CFLAGS) -I$(top_srcdir)/lib/isc \
+ -I$(top_srcdir)/lib/dns $(CMOCKA_CFLAGS) \
+ -DNAMED_PLUGINDIR=\"$(pkglibdir)\" \
+ -DTESTS_DIR=\"$(abs_srcdir)\"
+AM_LDFLAGS = $(STD_LDFLAGS) $(am__append_1)
+LDADD = $(LIBISC_LIBS) $(LIBDNS_LIBS) $(LIBNS_LIBS) $(LIBUV_LIBS) \
+ $(top_builddir)/tests/libtest/libtest.la $(CMOCKA_LIBS)
+LIBISC_CFLAGS = \
+ -I$(top_srcdir)/include \
+ -I$(top_srcdir)/lib/isc/include \
+ -I$(top_builddir)/lib/isc/include
+
+LIBISC_LIBS = $(top_builddir)/lib/isc/libisc.la
+LIBDNS_CFLAGS = \
+ -I$(top_srcdir)/lib/dns/include \
+ -I$(top_builddir)/lib/dns/include
+
+LIBDNS_LIBS = \
+ $(top_builddir)/lib/dns/libdns.la
+
+LIBNS_CFLAGS = \
+ -I$(top_srcdir)/lib/ns/include
+
+LIBNS_LIBS = \
+ $(top_builddir)/lib/ns/libns.la
+
+LIBIRS_CFLAGS = \
+ -I$(top_srcdir)/lib/irs/include
+
+LIBIRS_LIBS = \
+ $(top_builddir)/lib/irs/libirs.la
+
+LIBISCCFG_CFLAGS = \
+ -I$(top_srcdir)/lib/isccfg/include
+
+LIBISCCFG_LIBS = \
+ $(top_builddir)/lib/isccfg/libisccfg.la
+
+LIBISCCC_CFLAGS = \
+ -I$(top_srcdir)/lib/isccc/include/
+
+LIBISCCC_LIBS = \
+ $(top_builddir)/lib/isccc/libisccc.la
+
+LIBBIND9_CFLAGS = \
+ -I$(top_srcdir)/lib/bind9/include
+
+LIBBIND9_LIBS = \
+ $(top_builddir)/lib/bind9/libbind9.la
+
+EXTRA_DIST = testdata
+@HAVE_CMOCKA_TRUE@TESTS = $(check_PROGRAMS)
+LOG_COMPILER = $(top_builddir)/tests/unit-test-driver.sh
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .log .o .obj .test .test$(EXEEXT) .trs
+$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(top_srcdir)/Makefile.top $(top_srcdir)/Makefile.tests $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign tests/ns/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign tests/ns/Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
+ esac;
+$(top_srcdir)/Makefile.top $(top_srcdir)/Makefile.tests $(am__empty):
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-checkPROGRAMS:
+ @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+listenlist_test$(EXEEXT): $(listenlist_test_OBJECTS) $(listenlist_test_DEPENDENCIES) $(EXTRA_listenlist_test_DEPENDENCIES)
+ @rm -f listenlist_test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(listenlist_test_OBJECTS) $(listenlist_test_LDADD) $(LIBS)
+
+notify_test$(EXEEXT): $(notify_test_OBJECTS) $(notify_test_DEPENDENCIES) $(EXTRA_notify_test_DEPENDENCIES)
+ @rm -f notify_test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(notify_test_OBJECTS) $(notify_test_LDADD) $(LIBS)
+
+plugin_test$(EXEEXT): $(plugin_test_OBJECTS) $(plugin_test_DEPENDENCIES) $(EXTRA_plugin_test_DEPENDENCIES)
+ @rm -f plugin_test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(plugin_test_OBJECTS) $(plugin_test_LDADD) $(LIBS)
+
+query_test$(EXEEXT): $(query_test_OBJECTS) $(query_test_DEPENDENCIES) $(EXTRA_query_test_DEPENDENCIES)
+ @rm -f query_test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(query_test_OBJECTS) $(query_test_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/listenlist_test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/notify_test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plugin_test.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/query_test.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+test-local:
+unit-local:
+doc-local:
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+# Recover from deleted '.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
+# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+ rm -f $< $@
+ $(MAKE) $(AM_MAKEFLAGS) $<
+
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# expand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+ @:
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+ @$(am__set_TESTS_bases); \
+ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+ redo_bases=`for i in $$bases; do \
+ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+ done`; \
+ if test -n "$$redo_bases"; then \
+ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+ if $(am__make_dryrun); then :; else \
+ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
+ fi; \
+ fi; \
+ if test -n "$$am__remaking_logs"; then \
+ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+ "recursion detected" >&2; \
+ elif test -n "$$redo_logs"; then \
+ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+ fi; \
+ if $(am__make_dryrun); then :; else \
+ st=0; \
+ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+ for i in $$redo_bases; do \
+ test -f $$i.trs && test -r $$i.trs \
+ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
+ test -f $$i.log && test -r $$i.log \
+ || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+ done; \
+ test $$st -eq 0 || exit 1; \
+ fi
+ @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+ ws='[ ]'; \
+ results=`for b in $$bases; do echo $$b.trs; done`; \
+ test -n "$$results" || results=/dev/null; \
+ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
+ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
+ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
+ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
+ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+ if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+ success=true; \
+ else \
+ success=false; \
+ fi; \
+ br='==================='; br=$$br$$br$$br$$br; \
+ result_count () \
+ { \
+ if test x"$$1" = x"--maybe-color"; then \
+ maybe_colorize=yes; \
+ elif test x"$$1" = x"--no-color"; then \
+ maybe_colorize=no; \
+ else \
+ echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+ fi; \
+ shift; \
+ desc=$$1 count=$$2; \
+ if test $$maybe_colorize = yes && test $$count -gt 0; then \
+ color_start=$$3 color_end=$$std; \
+ else \
+ color_start= color_end=; \
+ fi; \
+ echo "$${color_start}# $$desc $$count$${color_end}"; \
+ }; \
+ create_testsuite_report () \
+ { \
+ result_count $$1 "TOTAL:" $$all "$$brg"; \
+ result_count $$1 "PASS: " $$pass "$$grn"; \
+ result_count $$1 "SKIP: " $$skip "$$blu"; \
+ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+ result_count $$1 "FAIL: " $$fail "$$red"; \
+ result_count $$1 "XPASS:" $$xpass "$$red"; \
+ result_count $$1 "ERROR:" $$error "$$mgn"; \
+ }; \
+ { \
+ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
+ $(am__rst_title); \
+ create_testsuite_report --no-color; \
+ echo; \
+ echo ".. contents:: :depth: 2"; \
+ echo; \
+ for b in $$bases; do echo $$b; done \
+ | $(am__create_global_log); \
+ } >$(TEST_SUITE_LOG).tmp || exit 1; \
+ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
+ if $$success; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
+ fi; \
+ echo "$${col}$$br$${std}"; \
+ echo "$${col}Testsuite summary"$(AM_TESTSUITE_SUMMARY_HEADER)"$${std}"; \
+ echo "$${col}$$br$${std}"; \
+ create_testsuite_report --maybe-color; \
+ echo "$$col$$br$$std"; \
+ if $$success; then :; else \
+ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
+ if test -n "$(PACKAGE_BUGREPORT)"; then \
+ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+ fi; \
+ echo "$$col$$br$$std"; \
+ fi; \
+ $$success || exit 1
+
+check-TESTS: $(check_PROGRAMS)
+ @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+ @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ trs_list=`for i in $$bases; do echo $$i.trs; done`; \
+ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+ exit $$?;
+recheck: all $(check_PROGRAMS)
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ bases=`for i in $$bases; do echo $$i; done \
+ | $(am__list_recheck_tests)` || exit 1; \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ log_list=`echo $$log_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+ am__force_recheck=am--force-recheck \
+ TEST_LOGS="$$log_list"; \
+ exit $$?
+listenlist_test.log: listenlist_test$(EXEEXT)
+ @p='listenlist_test$(EXEEXT)'; \
+ b='listenlist_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+notify_test.log: notify_test$(EXEEXT)
+ @p='notify_test$(EXEEXT)'; \
+ b='notify_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+plugin_test.log: plugin_test$(EXEEXT)
+ @p='plugin_test$(EXEEXT)'; \
+ b='plugin_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+query_test.log: query_test$(EXEEXT)
+ @p='query_test$(EXEEXT)'; \
+ b='query_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+.test.log:
+ @p='$<'; \
+ $(am__set_b); \
+ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@ @p='$<'; \
+@am__EXEEXT_TRUE@ $(am__set_b); \
+@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
+@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+ -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+ -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
+ -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -f ./$(DEPDIR)/listenlist_test.Po
+ -rm -f ./$(DEPDIR)/notify_test.Po
+ -rm -f ./$(DEPDIR)/plugin_test.Po
+ -rm -f ./$(DEPDIR)/query_test.Po
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+doc: doc-am
+
+doc-am: doc-local
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f ./$(DEPDIR)/listenlist_test.Po
+ -rm -f ./$(DEPDIR)/notify_test.Po
+ -rm -f ./$(DEPDIR)/plugin_test.Po
+ -rm -f ./$(DEPDIR)/query_test.Po
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+test: test-am
+
+test-am: test-local
+
+uninstall-am:
+
+unit: unit-am
+
+unit-am: unit-local
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-TESTS \
+ check-am clean clean-checkPROGRAMS clean-generic clean-libtool \
+ cscopelist-am ctags ctags-am distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir \
+ doc-am doc-local dvi dvi-am html html-am info info-am install \
+ install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am recheck tags tags-am test-am test-local \
+ uninstall uninstall-am unit-am unit-local
+
+.PRECIOUS: Makefile
+
+
+unit-local: check
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/tests/ns/listenlist_test.c b/tests/ns/listenlist_test.c
new file mode 100644
index 0000000..53d5783
--- /dev/null
+++ b/tests/ns/listenlist_test.c
@@ -0,0 +1,119 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+#include <inttypes.h>
+#include <sched.h> /* IWYU pragma: keep */
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define UNIT_TESTING
+#include <cmocka.h>
+
+#include <isc/list.h>
+#include <isc/print.h>
+#include <isc/random.h>
+#include <isc/util.h>
+
+#include <dns/acl.h>
+
+#include <ns/listenlist.h>
+
+#include <tests/ns.h>
+
+static int
+_setup(void **state) {
+ isc__nm_force_tid(0);
+
+ setup_managers(state);
+
+ return (0);
+}
+
+static int
+_teardown(void **state) {
+ isc__nm_force_tid(-1);
+
+ teardown_managers(state);
+
+ return (0);
+}
+
+/* test that ns_listenlist_default() works */
+ISC_RUN_TEST_IMPL(ns_listenlist_default) {
+ isc_result_t result;
+ in_port_t port = 5300 + isc_random8();
+ ns_listenlist_t *list = NULL;
+ ns_listenelt_t *elt;
+ int count;
+
+ UNUSED(state);
+
+ result = ns_listenlist_default(mctx, port, false, AF_INET, &list);
+ assert_int_equal(result, ISC_R_SUCCESS);
+ assert_non_null(list);
+
+ assert_false(ISC_LIST_EMPTY(list->elts));
+
+ count = 0;
+ elt = ISC_LIST_HEAD(list->elts);
+ while (elt != NULL) {
+ ns_listenelt_t *next = ISC_LIST_NEXT(elt, link);
+ dns_acl_t *acl = NULL;
+
+ dns_acl_attach(elt->acl, &acl);
+ ISC_LIST_UNLINK(list->elts, elt, link);
+ ns_listenelt_destroy(elt);
+ elt = next;
+
+ assert_true(dns_acl_isnone(acl));
+ dns_acl_detach(&acl);
+ count++;
+ }
+
+ assert_true(ISC_LIST_EMPTY(list->elts));
+ assert_int_equal(count, 1);
+
+ ns_listenlist_detach(&list);
+
+ result = ns_listenlist_default(mctx, port, true, AF_INET, &list);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
+ assert_false(ISC_LIST_EMPTY(list->elts));
+
+ /* This time just use ns_listenlist_detach() to destroy elements */
+ count = 0;
+ elt = ISC_LIST_HEAD(list->elts);
+ while (elt != NULL) {
+ ns_listenelt_t *next = ISC_LIST_NEXT(elt, link);
+ assert_true(dns_acl_isany(elt->acl));
+ elt = next;
+ count++;
+ }
+
+ assert_int_equal(count, 1);
+
+ ns_listenlist_detach(&list);
+}
+
+ISC_TEST_LIST_START
+
+ISC_TEST_ENTRY_CUSTOM(ns_listenlist_default, _setup, _teardown)
+
+ISC_TEST_LIST_END
+
+ISC_TEST_MAIN
diff --git a/tests/ns/notify_test.c b/tests/ns/notify_test.c
new file mode 100644
index 0000000..1b962e3
--- /dev/null
+++ b/tests/ns/notify_test.c
@@ -0,0 +1,141 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+#include <inttypes.h>
+#include <sched.h> /* IWYU pragma: keep */
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#define UNIT_TESTING
+#include <cmocka.h>
+
+#include <isc/event.h>
+#include <isc/print.h>
+#include <isc/task.h>
+#include <isc/thread.h>
+#include <isc/util.h>
+
+#include <dns/acl.h>
+#include <dns/rcode.h>
+#include <dns/view.h>
+
+#include <ns/client.h>
+#include <ns/notify.h>
+
+#include <tests/dns.h>
+#include <tests/ns.h>
+
+static int
+setup_test(void **state) {
+ isc__nm_force_tid(0);
+ return (setup_server(state));
+}
+
+static int
+teardown_test(void **state) {
+ isc__nm_force_tid(-1);
+ return (teardown_server(state));
+}
+
+static void
+check_response(isc_buffer_t *buf) {
+ isc_result_t result;
+ dns_message_t *message = NULL;
+ char rcodebuf[20];
+ isc_buffer_t b;
+
+ dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
+
+ result = dns_message_parse(message, buf, 0);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
+ isc_buffer_init(&b, rcodebuf, sizeof(rcodebuf));
+ result = dns_rcode_totext(message->rcode, &b);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
+ assert_int_equal(message->rcode, dns_rcode_noerror);
+
+ dns_message_detach(&message);
+}
+
+/* test ns_notify_start() */
+ISC_RUN_TEST_IMPL(ns_notify_start) {
+ isc_result_t result;
+ ns_client_t *client = NULL;
+ isc_nmhandle_t *handle = NULL;
+ dns_message_t *nmsg = NULL;
+ unsigned char ndata[4096];
+ isc_buffer_t nbuf;
+ size_t nsize;
+
+ UNUSED(state);
+
+ result = ns_test_getclient(NULL, false, &client);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
+ result = dns_test_makeview("view", false, &client->view);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
+ result = ns_test_serve_zone("example.com",
+ TESTS_DIR "/testdata/notify/zone1.db",
+ client->view);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
+ /*
+ * Create a NOTIFY message by parsing a file in testdata.
+ * (XXX: use better message mocking method when available.)
+ */
+
+ result = ns_test_getdata(TESTS_DIR "/testdata/notify/notify1.msg",
+ ndata, sizeof(ndata), &nsize);
+ assert_int_equal(result, ISC_R_SUCCESS);
+ isc_buffer_init(&nbuf, ndata, nsize);
+ isc_buffer_add(&nbuf, nsize);
+
+ dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &nmsg);
+
+ result = dns_message_parse(nmsg, &nbuf, 0);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
+ /*
+ * Set up client object with this message and test the NOTIFY
+ * handler.
+ */
+ if (client->message != NULL) {
+ dns_message_detach(&client->message);
+ }
+ client->message = nmsg;
+ nmsg = NULL;
+ client->sendcb = check_response;
+ ns_notify_start(client, client->handle);
+
+ /*
+ * Clean up
+ */
+ ns_test_cleanup_zone();
+
+ handle = client->handle;
+ isc_nmhandle_detach(&client->handle);
+ isc_nmhandle_detach(&handle);
+}
+
+ISC_TEST_LIST_START
+ISC_TEST_ENTRY_CUSTOM(ns_notify_start, setup_test, teardown_test)
+ISC_TEST_LIST_END
+
+ISC_TEST_MAIN
diff --git a/tests/ns/plugin_test.c b/tests/ns/plugin_test.c
new file mode 100644
index 0000000..24d021e
--- /dev/null
+++ b/tests/ns/plugin_test.c
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+#include <inttypes.h>
+#include <limits.h>
+#include <sched.h> /* IWYU pragma: keep */
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define UNIT_TESTING
+#include <cmocka.h>
+
+#include <isc/attributes.h>
+#include <isc/dir.h>
+#include <isc/mem.h>
+#include <isc/result.h>
+#include <isc/types.h>
+#include <isc/util.h>
+
+noreturn void
+_fail(const char *const file, const int line);
+
+#include <ns/hooks.h>
+
+#include <tests/ns.h>
+
+/*%
+ * Structure containing parameters for run_full_path_test().
+ */
+typedef struct {
+ const ns_test_id_t id; /* libns test identifier */
+ const char *input; /* source string - plugin name or path
+ * */
+ size_t output_size; /* size of target char array to
+ * allocate */
+ isc_result_t result; /* expected return value */
+ const char *output; /* expected output string */
+} ns_plugin_expandpath_test_params_t;
+
+/*%
+ * Perform a single ns_plugin_expandpath() check using given parameters.
+ */
+static void
+run_full_path_test(const ns_plugin_expandpath_test_params_t *test,
+ void **state) {
+ char **target = (char **)state;
+ isc_result_t result;
+
+ REQUIRE(test != NULL);
+ REQUIRE(test->id.description != NULL);
+ REQUIRE(test->input != NULL);
+ REQUIRE(test->result != ISC_R_SUCCESS || test->output != NULL);
+
+ /*
+ * Prepare a target buffer of given size. Store it in 'state' so that
+ * it can get cleaned up by _teardown() if the test fails.
+ */
+ *target = isc_mem_allocate(mctx, test->output_size);
+
+ /*
+ * Call ns_plugin_expandpath().
+ */
+ result = ns_plugin_expandpath(test->input, *target, test->output_size);
+
+ /*
+ * Check return value.
+ */
+ if (result != test->result) {
+ fail_msg("# test \"%s\" on line %d: "
+ "expected result %d (%s), got %d (%s)",
+ test->id.description, test->id.lineno, test->result,
+ isc_result_totext(test->result), result,
+ isc_result_totext(result));
+ }
+
+ /*
+ * Check output string if return value indicates success.
+ */
+ if (result == ISC_R_SUCCESS && strcmp(*target, test->output) != 0) {
+ fail_msg("# test \"%s\" on line %d: "
+ "expected output \"%s\", got \"%s\"",
+ test->id.description, test->id.lineno, test->output,
+ *target);
+ }
+
+ isc_mem_free(mctx, *target);
+}
+
+/* test ns_plugin_expandpath() */
+ISC_RUN_TEST_IMPL(ns_plugin_expandpath) {
+ size_t i;
+
+ const ns_plugin_expandpath_test_params_t tests[] = {
+ {
+ NS_TEST_ID("correct use with an absolute path"),
+ .input = "/usr/lib/named/foo.so",
+ .output_size = PATH_MAX,
+ .result = ISC_R_SUCCESS,
+ .output = "/usr/lib/named/foo.so",
+ },
+ {
+ NS_TEST_ID("correct use with a relative path"),
+ .input = "../../foo.so",
+ .output_size = PATH_MAX,
+ .result = ISC_R_SUCCESS,
+ .output = "../../foo.so",
+ },
+ {
+ NS_TEST_ID("correct use with a filename"),
+ .input = "foo.so",
+ .output_size = PATH_MAX,
+ .result = ISC_R_SUCCESS,
+ .output = NAMED_PLUGINDIR "/foo.so",
+ },
+ {
+ NS_TEST_ID("no space at all in target buffer"),
+ .input = "/usr/lib/named/foo.so",
+ .output_size = 0,
+ .result = ISC_R_NOSPACE,
+ },
+ {
+ NS_TEST_ID("target buffer too small to fit input"),
+ .input = "/usr/lib/named/foo.so",
+ .output_size = 1,
+ .result = ISC_R_NOSPACE,
+ },
+ {
+ NS_TEST_ID("target buffer too small to fit NULL byte"),
+ .input = "/foo.so",
+ .output_size = 7,
+ .result = ISC_R_NOSPACE,
+ },
+ {
+ NS_TEST_ID("target buffer too small to fit full path"),
+ .input = "foo.so",
+ .output_size = 7,
+ .result = ISC_R_NOSPACE,
+ },
+ };
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ run_full_path_test(&tests[i], state);
+ }
+}
+
+ISC_TEST_LIST_START
+
+ISC_TEST_ENTRY_CUSTOM(ns_plugin_expandpath, setup_managers, teardown_managers)
+
+ISC_TEST_LIST_END
+
+ISC_TEST_MAIN
diff --git a/tests/ns/query_test.c b/tests/ns/query_test.c
new file mode 100644
index 0000000..5bea01a
--- /dev/null
+++ b/tests/ns/query_test.c
@@ -0,0 +1,1500 @@
+/*
+ * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+ *
+ * SPDX-License-Identifier: MPL-2.0
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, you can obtain one at https://mozilla.org/MPL/2.0/.
+ *
+ * See the COPYRIGHT file distributed with this work for additional
+ * information regarding copyright ownership.
+ */
+
+#include <inttypes.h>
+#include <sched.h> /* IWYU pragma: keep */
+#include <setjmp.h>
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <string.h>
+
+#define UNIT_TESTING
+#include <cmocka.h>
+
+#include <isc/quota.h>
+#include <isc/util.h>
+
+#include <dns/badcache.h>
+#include <dns/view.h>
+#include <dns/zone.h>
+
+#include <ns/client.h>
+#include <ns/events.h>
+#include <ns/hooks.h>
+#include <ns/query.h>
+#include <ns/server.h>
+#include <ns/stats.h>
+
+#include <tests/ns.h>
+
+static int
+setup_test(void **state) {
+ isc__nm_force_tid(0);
+ setup_server(state);
+ return (0);
+}
+
+static int
+teardown_test(void **state) {
+ isc__nm_force_tid(-1);
+ teardown_server(state);
+ return (0);
+}
+
+/* can be used for client->sendcb to avoid disruption on sending a response */
+static void
+send_noop(isc_buffer_t *buffer) {
+ UNUSED(buffer);
+}
+
+/*****
+***** ns__query_sfcache() tests
+*****/
+
+/*%
+ * Structure containing parameters for ns__query_sfcache_test().
+ */
+typedef struct {
+ const ns_test_id_t id; /* libns test identifier */
+ unsigned int qflags; /* query flags */
+ bool cache_entry_present; /* whether a SERVFAIL
+ * cache entry
+ * matching the query
+ * should be
+ * present */
+ uint32_t cache_entry_flags; /* NS_FAILCACHE_* flags to
+ * set for
+ * the SERVFAIL cache entry
+ * */
+ bool servfail_expected; /* whether a cached
+ * SERVFAIL is
+ * expected to be returned
+ * */
+} ns__query_sfcache_test_params_t;
+
+/*%
+ * Perform a single ns__query_sfcache() check using given parameters.
+ */
+static void
+run_sfcache_test(const ns__query_sfcache_test_params_t *test) {
+ ns_hooktable_t *query_hooks = NULL;
+ query_ctx_t *qctx = NULL;
+ isc_result_t result;
+ const ns_hook_t hook = {
+ .action = ns_test_hook_catch_call,
+ };
+
+ REQUIRE(test != NULL);
+ REQUIRE(test->id.description != NULL);
+ REQUIRE(test->cache_entry_present || test->cache_entry_flags == 0);
+
+ /*
+ * Interrupt execution if ns_query_done() is called.
+ */
+
+ ns_hooktable_create(mctx, &query_hooks);
+ ns_hook_add(query_hooks, mctx, NS_QUERY_DONE_BEGIN, &hook);
+ ns__hook_table = query_hooks;
+
+ /*
+ * Construct a query context for a ./NS query with given flags.
+ */
+ {
+ const ns_test_qctx_create_params_t qctx_params = {
+ .qname = ".",
+ .qtype = dns_rdatatype_ns,
+ .qflags = test->qflags,
+ .with_cache = true,
+ };
+
+ result = ns_test_qctx_create(&qctx_params, &qctx);
+ assert_int_equal(result, ISC_R_SUCCESS);
+ }
+
+ /*
+ * If this test wants a SERVFAIL cache entry matching the query to
+ * exist, create it.
+ */
+ if (test->cache_entry_present) {
+ isc_interval_t hour;
+ isc_time_t expire;
+
+ isc_interval_set(&hour, 3600, 0);
+ result = isc_time_nowplusinterval(&expire, &hour);
+ assert_int_equal(result, ISC_R_SUCCESS);
+
+ dns_badcache_add(qctx->client->view->failcache, dns_rootname,
+ dns_rdatatype_ns, true,
+ test->cache_entry_flags, &expire);
+ }
+
+ /*
+ * Check whether ns__query_sfcache() behaves as expected.
+ */
+ ns__query_sfcache(qctx);
+
+ if (test->servfail_expected) {
+ if (qctx->result != DNS_R_SERVFAIL) {
+ fail_msg("# test \"%s\" on line %d: "
+ "expected SERVFAIL, got %s",
+ test->id.description, test->id.lineno,
+ isc_result_totext(qctx->result));
+ }
+ } else {
+ if (qctx->result != ISC_R_SUCCESS) {
+ fail_msg("# test \"%s\" on line %d: "
+ "expected success, got %s",
+ test->id.description, test->id.lineno,
+ isc_result_totext(qctx->result));
+ }
+ }
+
+ /*
+ * Clean up.
+ */
+ ns_test_qctx_destroy(&qctx);
+ ns_hooktable_free(mctx, (void **)&query_hooks);
+}
+
+/* test ns__query_sfcache() */
+ISC_RUN_TEST_IMPL(ns_query_sfcache) {
+ size_t i;
+
+ const ns__query_sfcache_test_params_t tests[] = {
+ /*
+ * Sanity check for an empty SERVFAIL cache.
+ */
+ {
+ NS_TEST_ID("query: RD=1, CD=0; cache: empty"),
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .cache_entry_present = false,
+ .servfail_expected = false,
+ },
+ /*
+ * Query: RD=1, CD=0. Cache entry: CD=0. Should SERVFAIL.
+ */
+ {
+ NS_TEST_ID("query: RD=1, CD=0; cache: CD=0"),
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .cache_entry_present = true,
+ .cache_entry_flags = 0,
+ .servfail_expected = true,
+ },
+ /*
+ * Query: RD=1, CD=1. Cache entry: CD=0. Should not SERVFAIL:
+ * failed validation should not influence CD=1 queries.
+ */
+ {
+ NS_TEST_ID("query: RD=1, CD=1; cache: CD=0"),
+ .qflags = DNS_MESSAGEFLAG_RD | DNS_MESSAGEFLAG_CD,
+ .cache_entry_present = true,
+ .cache_entry_flags = 0,
+ .servfail_expected = false,
+ },
+ /*
+ * Query: RD=1, CD=1. Cache entry: CD=1. Should SERVFAIL:
+ * SERVFAIL responses elicited by CD=1 queries can be
+ * "replayed" for other CD=1 queries during the lifetime of the
+ * SERVFAIL cache entry.
+ */
+ {
+ NS_TEST_ID("query: RD=1, CD=1; cache: CD=1"),
+ .qflags = DNS_MESSAGEFLAG_RD | DNS_MESSAGEFLAG_CD,
+ .cache_entry_present = true,
+ .cache_entry_flags = NS_FAILCACHE_CD,
+ .servfail_expected = true,
+ },
+ /*
+ * Query: RD=1, CD=0. Cache entry: CD=1. Should SERVFAIL: if
+ * a CD=1 query elicited a SERVFAIL, a CD=0 query for the same
+ * QNAME and QTYPE will SERVFAIL as well.
+ */
+ {
+ NS_TEST_ID("query: RD=1, CD=0; cache: CD=1"),
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .cache_entry_present = true,
+ .cache_entry_flags = NS_FAILCACHE_CD,
+ .servfail_expected = true,
+ },
+ /*
+ * Query: RD=0, CD=0. Cache entry: CD=0. Should not SERVFAIL
+ * despite a matching entry being present as the SERVFAIL cache
+ * should not be consulted for non-recursive queries.
+ */
+ {
+ NS_TEST_ID("query: RD=0, CD=0; cache: CD=0"),
+ .qflags = 0,
+ .cache_entry_present = true,
+ .cache_entry_flags = 0,
+ .servfail_expected = false,
+ },
+ };
+
+ UNUSED(state);
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ run_sfcache_test(&tests[i]);
+ }
+}
+
+/*****
+***** ns__query_start() tests
+*****/
+
+/*%
+ * Structure containing parameters for ns__query_start_test().
+ */
+typedef struct {
+ const ns_test_id_t id; /* libns test identifier */
+ const char *qname; /* QNAME */
+ dns_rdatatype_t qtype; /* QTYPE */
+ unsigned int qflags; /* query flags */
+ bool disable_name_checks; /* if set to true, owner
+ * name
+ * checks will
+ * be disabled for the
+ * view created
+ * */
+ bool recursive_service; /* if set to true, the view
+ * created will
+ * have a cache
+ * database
+ * attached */
+ const char *auth_zone_origin; /* origin name of the zone
+ * the
+ * created view will be
+ * authoritative for */
+ const char *auth_zone_path; /* path to load the
+ * authoritative
+ * zone from */
+ enum { /* expected result: */
+ NS__QUERY_START_R_INVALID,
+ NS__QUERY_START_R_REFUSE, /* query should be REFUSED */
+ NS__QUERY_START_R_CACHE, /* query should be answered from
+ * cache */
+ NS__QUERY_START_R_AUTH, /* query should be answered using
+ * authoritative data */
+ } expected_result;
+} ns__query_start_test_params_t;
+
+/*%
+ * Perform a single ns__query_start() check using given parameters.
+ */
+static void
+run_start_test(const ns__query_start_test_params_t *test) {
+ ns_hooktable_t *query_hooks = NULL;
+ query_ctx_t *qctx = NULL;
+ isc_result_t result;
+ const ns_hook_t hook = {
+ .action = ns_test_hook_catch_call,
+ };
+
+ REQUIRE(test != NULL);
+ REQUIRE(test->id.description != NULL);
+ REQUIRE((test->auth_zone_origin == NULL &&
+ test->auth_zone_path == NULL) ||
+ (test->auth_zone_origin != NULL &&
+ test->auth_zone_path != NULL));
+
+ /*
+ * Interrupt execution if query_lookup() or ns_query_done() is called.
+ */
+
+ ns_hooktable_create(mctx, &query_hooks);
+ ns_hook_add(query_hooks, mctx, NS_QUERY_LOOKUP_BEGIN, &hook);
+ ns_hook_add(query_hooks, mctx, NS_QUERY_DONE_BEGIN, &hook);
+ ns__hook_table = query_hooks;
+
+ /*
+ * Construct a query context using the supplied parameters.
+ */
+ {
+ const ns_test_qctx_create_params_t qctx_params = {
+ .qname = test->qname,
+ .qtype = test->qtype,
+ .qflags = test->qflags,
+ .with_cache = test->recursive_service,
+ };
+ result = ns_test_qctx_create(&qctx_params, &qctx);
+ assert_int_equal(result, ISC_R_SUCCESS);
+ }
+
+ /*
+ * Enable view->checknames by default, disable if requested.
+ */
+ qctx->client->view->checknames = !test->disable_name_checks;
+
+ /*
+ * Load zone from file and attach it to the client's view, if
+ * requested.
+ */
+ if (test->auth_zone_path != NULL) {
+ result = ns_test_serve_zone(test->auth_zone_origin,
+ test->auth_zone_path,
+ qctx->client->view);
+ assert_int_equal(result, ISC_R_SUCCESS);
+ }
+
+ /*
+ * Check whether ns__query_start() behaves as expected.
+ */
+ ns__query_start(qctx);
+
+ switch (test->expected_result) {
+ case NS__QUERY_START_R_REFUSE:
+ if (qctx->result != DNS_R_REFUSED) {
+ fail_msg("# test \"%s\" on line %d: "
+ "expected REFUSED, got %s",
+ test->id.description, test->id.lineno,
+ isc_result_totext(qctx->result));
+ }
+ if (qctx->zone != NULL) {
+ fail_msg("# test \"%s\" on line %d: "
+ "no zone was expected to be attached to "
+ "query context, but some was",
+ test->id.description, test->id.lineno);
+ }
+ if (qctx->db != NULL) {
+ fail_msg("# test \"%s\" on line %d: "
+ "no database was expected to be attached to "
+ "query context, but some was",
+ test->id.description, test->id.lineno);
+ }
+ break;
+ case NS__QUERY_START_R_CACHE:
+ if (qctx->result != ISC_R_SUCCESS) {
+ fail_msg("# test \"%s\" on line %d: "
+ "expected success, got %s",
+ test->id.description, test->id.lineno,
+ isc_result_totext(qctx->result));
+ }
+ if (qctx->zone != NULL) {
+ fail_msg("# test \"%s\" on line %d: "
+ "no zone was expected to be attached to "
+ "query context, but some was",
+ test->id.description, test->id.lineno);
+ }
+ if (qctx->db == NULL || qctx->db != qctx->client->view->cachedb)
+ {
+ fail_msg("# test \"%s\" on line %d: "
+ "cache database was expected to be "
+ "attached to query context, but it was not",
+ test->id.description, test->id.lineno);
+ }
+ break;
+ case NS__QUERY_START_R_AUTH:
+ if (qctx->result != ISC_R_SUCCESS) {
+ fail_msg("# test \"%s\" on line %d: "
+ "expected success, got %s",
+ test->id.description, test->id.lineno,
+ isc_result_totext(qctx->result));
+ }
+ if (qctx->zone == NULL) {
+ fail_msg("# test \"%s\" on line %d: "
+ "a zone was expected to be attached to query "
+ "context, but it was not",
+ test->id.description, test->id.lineno);
+ }
+ if (qctx->db == qctx->client->view->cachedb) {
+ fail_msg("# test \"%s\" on line %d: "
+ "cache database was not expected to be "
+ "attached to query context, but it is",
+ test->id.description, test->id.lineno);
+ }
+ break;
+ case NS__QUERY_START_R_INVALID:
+ fail_msg("# test \"%s\" on line %d has no expected result set",
+ test->id.description, test->id.lineno);
+ break;
+ default:
+ UNREACHABLE();
+ }
+
+ /*
+ * Clean up.
+ */
+ if (test->auth_zone_path != NULL) {
+ ns_test_cleanup_zone();
+ }
+ ns_test_qctx_destroy(&qctx);
+ ns_hooktable_free(mctx, (void **)&query_hooks);
+}
+
+/* test ns__query_start() */
+ISC_RUN_TEST_IMPL(ns_query_start) {
+ size_t i;
+
+ const ns__query_start_test_params_t tests[] = {
+ /*
+ * Recursive foo/A query to a server without recursive service
+ * and no zones configured. Query should be REFUSED.
+ */
+ {
+ NS_TEST_ID("foo/A, no cache, no auth"),
+ .qname = "foo",
+ .qtype = dns_rdatatype_a,
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .recursive_service = false,
+ .expected_result = NS__QUERY_START_R_REFUSE,
+ },
+ /*
+ * Recursive foo/A query to a server with recursive service and
+ * no zones configured. Query should be answered from cache.
+ */
+ {
+ NS_TEST_ID("foo/A, cache, no auth"),
+ .qname = "foo",
+ .qtype = dns_rdatatype_a,
+ .recursive_service = true,
+ .expected_result = NS__QUERY_START_R_CACHE,
+ },
+ /*
+ * Recursive foo/A query to a server with recursive service and
+ * zone "foo" configured. Query should be answered from
+ * authoritative data.
+ */
+ {
+ NS_TEST_ID("foo/A, RD=1, cache, auth for foo"),
+ .qname = "foo",
+ .qtype = dns_rdatatype_a,
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .recursive_service = true,
+ .auth_zone_origin = "foo",
+ .auth_zone_path = TESTS_DIR "/testdata/query/foo.db",
+ .expected_result = NS__QUERY_START_R_AUTH,
+ },
+ /*
+ * Recursive bar/A query to a server without recursive service
+ * and zone "foo" configured. Query should be REFUSED.
+ */
+ {
+ NS_TEST_ID("bar/A, RD=1, no cache, auth for foo"),
+ .qname = "bar",
+ .qtype = dns_rdatatype_a,
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .recursive_service = false,
+ .auth_zone_origin = "foo",
+ .auth_zone_path = TESTS_DIR "/testdata/query/foo.db",
+ .expected_result = NS__QUERY_START_R_REFUSE,
+ },
+ /*
+ * Recursive bar/A query to a server with recursive service and
+ * zone "foo" configured. Query should be answered from
+ * cache.
+ */
+ {
+ NS_TEST_ID("bar/A, RD=1, cache, auth for foo"),
+ .qname = "bar",
+ .qtype = dns_rdatatype_a,
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .recursive_service = true,
+ .auth_zone_origin = "foo",
+ .auth_zone_path = TESTS_DIR "/testdata/query/foo.db",
+ .expected_result = NS__QUERY_START_R_CACHE,
+ },
+ /*
+ * Recursive bar.foo/DS query to a server with recursive
+ * service and zone "foo" configured. Query should be answered
+ * from authoritative data.
+ */
+ {
+ NS_TEST_ID("bar.foo/DS, RD=1, cache, auth for foo"),
+ .qname = "bar.foo",
+ .qtype = dns_rdatatype_ds,
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .recursive_service = true,
+ .auth_zone_origin = "foo",
+ .auth_zone_path = TESTS_DIR "/testdata/query/foo.db",
+ .expected_result = NS__QUERY_START_R_AUTH,
+ },
+ /*
+ * Non-recursive bar.foo/DS query to a server with recursive
+ * service and zone "foo" configured. Query should be answered
+ * from authoritative data.
+ */
+ {
+ NS_TEST_ID("bar.foo/DS, RD=0, cache, auth for foo"),
+ .qname = "bar.foo",
+ .qtype = dns_rdatatype_ds,
+ .qflags = 0,
+ .recursive_service = true,
+ .auth_zone_origin = "foo",
+ .auth_zone_path = TESTS_DIR "/testdata/query/foo.db",
+ .expected_result = NS__QUERY_START_R_AUTH,
+ },
+ /*
+ * Recursive foo/DS query to a server with recursive service
+ * and zone "foo" configured. Query should be answered from
+ * cache.
+ */
+ {
+ NS_TEST_ID("foo/DS, RD=1, cache, auth for foo"),
+ .qname = "foo",
+ .qtype = dns_rdatatype_ds,
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .recursive_service = true,
+ .auth_zone_origin = "foo",
+ .auth_zone_path = TESTS_DIR "/testdata/query/foo.db",
+ .expected_result = NS__QUERY_START_R_CACHE,
+ },
+ /*
+ * Non-recursive foo/DS query to a server with recursive
+ * service and zone "foo" configured. Query should be answered
+ * from authoritative data.
+ */
+ {
+ NS_TEST_ID("foo/DS, RD=0, cache, auth for foo"),
+ .qname = "foo",
+ .qtype = dns_rdatatype_ds,
+ .qflags = 0,
+ .recursive_service = true,
+ .auth_zone_origin = "foo",
+ .auth_zone_path = TESTS_DIR "/testdata/query/foo.db",
+ .expected_result = NS__QUERY_START_R_AUTH,
+ },
+ /*
+ * Recursive _foo/A query to a server with recursive service,
+ * no zones configured and owner name checks disabled. Query
+ * should be answered from cache.
+ */
+ {
+ NS_TEST_ID("_foo/A, cache, no auth, name checks off"),
+ .qname = "_foo",
+ .qtype = dns_rdatatype_a,
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .disable_name_checks = true,
+ .recursive_service = true,
+ .expected_result = NS__QUERY_START_R_CACHE,
+ },
+ /*
+ * Recursive _foo/A query to a server with recursive service,
+ * no zones configured and owner name checks enabled. Query
+ * should be REFUSED.
+ */
+ {
+ NS_TEST_ID("_foo/A, cache, no auth, name checks on"),
+ .qname = "_foo",
+ .qtype = dns_rdatatype_a,
+ .qflags = DNS_MESSAGEFLAG_RD,
+ .disable_name_checks = false,
+ .recursive_service = true,
+ .expected_result = NS__QUERY_START_R_REFUSE,
+ },
+ };
+
+ UNUSED(state);
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ run_start_test(&tests[i]);
+ }
+}
+
+/*****
+***** tests for ns_query_hookasync().
+*****/
+
+/*%
+ * Structure containing parameters for ns__query_hookasync_test().
+ */
+typedef struct {
+ const ns_test_id_t id; /* libns test identifier */
+ ns_hookpoint_t hookpoint; /* hook point specified for resume */
+ ns_hookpoint_t hookpoint2; /* expected hook point used after resume */
+ ns_hook_action_t action; /* action for the hook point */
+ isc_result_t start_result; /* result of 'runasync' */
+ bool quota_ok; /* true if recursion quota should be okay */
+ bool do_cancel; /* true if query should be canceled
+ * in test */
+} ns__query_hookasync_test_params_t;
+
+/* Data structure passed from tests to hooks */
+typedef struct hookasync_data {
+ bool async; /* true if in a hook-triggered
+ * asynchronous process */
+ bool canceled; /* true if the query has been canceled */
+ isc_result_t start_result; /* result of 'runasync' */
+ ns_hook_resevent_t *rev; /* resume event sent on completion */
+ query_ctx_t qctx; /* shallow copy of qctx passed to hook */
+ ns_hookpoint_t hookpoint; /* specifies where to resume */
+ ns_hookpoint_t lasthookpoint; /* remember the last hook point called */
+} hookasync_data_t;
+
+/*
+ * 'destroy' callback of hook recursion ctx.
+ * The dynamically allocated context will be freed here, thereby proving
+ * this is actually called; otherwise tests would fail due to memory leak.
+ */
+static void
+destroy_hookactx(ns_hookasync_t **ctxp) {
+ ns_hookasync_t *ctx = *ctxp;
+
+ *ctxp = NULL;
+ isc_mem_putanddetach(&ctx->mctx, ctx, sizeof(*ctx));
+}
+
+/* 'cancel' callback of hook recursion ctx. */
+static void
+cancel_hookactx(ns_hookasync_t *ctx) {
+ /* Mark the hook data so the test can confirm this is called. */
+ ((hookasync_data_t *)ctx->private)->canceled = true;
+}
+
+/* 'runasync' callback passed to ns_query_hookasync */
+static isc_result_t
+test_hookasync(query_ctx_t *qctx, isc_mem_t *memctx, void *arg,
+ isc_task_t *task, isc_taskaction_t action, void *evarg,
+ ns_hookasync_t **ctxp) {
+ hookasync_data_t *asdata = arg;
+ ns_hookasync_t *ctx = NULL;
+ ns_hook_resevent_t *rev = NULL;
+
+ if (asdata->start_result != ISC_R_SUCCESS) {
+ return (asdata->start_result);
+ }
+
+ ctx = isc_mem_get(memctx, sizeof(*ctx));
+ rev = (ns_hook_resevent_t *)isc_event_allocate(
+ memctx, task, NS_EVENT_HOOKASYNCDONE, action, evarg,
+ sizeof(*rev));
+
+ rev->hookpoint = asdata->hookpoint;
+ rev->origresult = DNS_R_NXDOMAIN;
+ rev->saved_qctx = qctx;
+ rev->ctx = ctx;
+ asdata->rev = rev;
+
+ *ctx = (ns_hookasync_t){ .private = asdata };
+ isc_mem_attach(memctx, &ctx->mctx);
+ ctx->destroy = destroy_hookactx;
+ ctx->cancel = cancel_hookactx;
+
+ *ctxp = ctx;
+ return (ISC_R_SUCCESS);
+}
+
+/*
+ * Main logic for hook actions.
+ * 'hookpoint' should identify the point that calls the hook. It will be
+ * remembered in the hook data, so that the test can confirm which hook point
+ * was last used.
+ */
+static ns_hookresult_t
+hook_async_common(void *arg, void *data, isc_result_t *resultp,
+ ns_hookpoint_t hookpoint) {
+ query_ctx_t *qctx = arg;
+ hookasync_data_t *asdata = data;
+ isc_result_t result;
+
+ asdata->qctx = *qctx; /* remember passed ctx for inspection */
+ asdata->lasthookpoint = hookpoint; /* ditto */
+
+ if (!asdata->async) {
+ /* Initial call to the hook; start recursion */
+ result = ns_query_hookasync(qctx, test_hookasync, asdata);
+ if (result == ISC_R_SUCCESS) {
+ asdata->async = true;
+ }
+ } else {
+ /*
+ * Resume from the completion of async event.
+ * fetchhandle should have been detached so that we can start
+ * another async event or DNS recursive resolution.
+ */
+ INSIST(qctx->client->fetchhandle == NULL);
+ asdata->async = false;
+ switch (hookpoint) {
+ case NS_QUERY_GOT_ANSWER_BEGIN:
+ case NS_QUERY_NODATA_BEGIN:
+ case NS_QUERY_NXDOMAIN_BEGIN:
+ case NS_QUERY_NCACHE_BEGIN:
+ INSIST(*resultp == DNS_R_NXDOMAIN);
+ break;
+ default:;
+ }
+ }
+
+ *resultp = ISC_R_UNSET;
+ return (NS_HOOK_RETURN);
+}
+
+static ns_hookresult_t
+hook_async_query_setup(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_SETUP));
+}
+
+static ns_hookresult_t
+hook_async_query_start_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_START_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_lookup_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_LOOKUP_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_resume_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_RESUME_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_got_answer_begin(void *arg, void *data,
+ isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp,
+ NS_QUERY_GOT_ANSWER_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_respond_any_begin(void *arg, void *data,
+ isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp,
+ NS_QUERY_RESPOND_ANY_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_addanswer_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp,
+ NS_QUERY_ADDANSWER_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_notfound_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_NOTFOUND_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_prep_delegation_begin(void *arg, void *data,
+ isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp,
+ NS_QUERY_PREP_DELEGATION_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_zone_delegation_begin(void *arg, void *data,
+ isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp,
+ NS_QUERY_ZONE_DELEGATION_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_delegation_begin(void *arg, void *data,
+ isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp,
+ NS_QUERY_DELEGATION_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_delegation_recurse_begin(void *arg, void *data,
+ isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp,
+ NS_QUERY_DELEGATION_RECURSE_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_nodata_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_NODATA_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_nxdomain_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_NXDOMAIN_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_ncache_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_NCACHE_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_cname_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_CNAME_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_dname_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_DNAME_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_respond_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_RESPOND_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_response_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp,
+ NS_QUERY_PREP_RESPONSE_BEGIN));
+}
+
+static ns_hookresult_t
+hook_async_query_done_begin(void *arg, void *data, isc_result_t *resultp) {
+ return (hook_async_common(arg, data, resultp, NS_QUERY_DONE_BEGIN));
+}
+
+/*
+ * hook on destroying actx. Can't be used for async event, but we use this
+ * to remember the qctx at that point.
+ */
+static ns_hookresult_t
+ns_test_qctx_destroy_hook(void *arg, void *data, isc_result_t *resultp) {
+ query_ctx_t *qctx = arg;
+ hookasync_data_t *asdata = data;
+
+ asdata->qctx = *qctx; /* remember passed ctx for inspection */
+ *resultp = ISC_R_UNSET;
+ return (NS_HOOK_CONTINUE);
+}
+
+static void
+run_hookasync_test(const ns__query_hookasync_test_params_t *test) {
+ query_ctx_t *qctx = NULL;
+ isc_result_t result;
+ hookasync_data_t asdata = {
+ .async = false,
+ .canceled = false,
+ .start_result = test->start_result,
+ .hookpoint = test->hookpoint,
+ };
+ const ns_hook_t testhook = {
+ .action = test->action,
+ .action_data = &asdata,
+ };
+ const ns_hook_t destroyhook = {
+ .action = ns_test_qctx_destroy_hook,
+ .action_data = &asdata,
+ };
+ isc_quota_t *quota = NULL;
+ isc_statscounter_t srvfail_cnt;
+ bool expect_servfail = false;
+
+ /*
+ * Prepare hooks. We always begin with ns__query_start for simplicity.
+ * Its action will specify various different resume points (unusual
+ * in practice, but that's fine for the testing purpose).
+ */
+ ns__hook_table = NULL;
+ ns_hooktable_create(mctx, &ns__hook_table);
+ ns_hook_add(ns__hook_table, mctx, NS_QUERY_START_BEGIN, &testhook);
+ if (test->hookpoint2 != NS_QUERY_START_BEGIN) {
+ /*
+ * unless testing START_BEGIN itself, specify the hook for the
+ * expected resume point, too.
+ */
+ ns_hook_add(ns__hook_table, mctx, test->hookpoint2, &testhook);
+ }
+ ns_hook_add(ns__hook_table, mctx, NS_QUERY_QCTX_DESTROYED,
+ &destroyhook);
+
+ {
+ const ns_test_qctx_create_params_t qctx_params = {
+ .qname = "test.example.com",
+ .qtype = dns_rdatatype_aaaa,
+ };
+ result = ns_test_qctx_create(&qctx_params, &qctx);
+ INSIST(result == ISC_R_SUCCESS);
+ qctx->client->sendcb = send_noop;
+ }
+
+ /*
+ * Set recursion quota to the lowest possible value, then make it full
+ * if we want to exercise a quota failure case.
+ */
+ isc_quota_max(&sctx->recursionquota, 1);
+ if (!test->quota_ok) {
+ result = isc_quota_attach(&sctx->recursionquota, &quota);
+ INSIST(result == ISC_R_SUCCESS);
+ }
+
+ /* Remember SERVFAIL counter */
+ srvfail_cnt = ns_stats_get_counter(qctx->client->sctx->nsstats,
+ ns_statscounter_servfail);
+
+ /*
+ * If the query has been canceled, or async event didn't succeed,
+ * SERVFAIL will have to be sent. In this case we need to have
+ * 'reqhandle' attach to the client's handle as it's detached in
+ * query_error.
+ */
+ if (test->start_result != ISC_R_SUCCESS || !test->quota_ok ||
+ test->do_cancel)
+ {
+ expect_servfail = true;
+ isc_nmhandle_attach(qctx->client->handle,
+ &qctx->client->reqhandle);
+ }
+
+ /*
+ * Emulate query handling from query_start.
+ * Specified hook should be called.
+ */
+ qctx->client->state = NS_CLIENTSTATE_WORKING;
+ result = ns__query_start(qctx);
+ INSIST(result == ISC_R_UNSET);
+
+ /*
+ * hook-triggered async event should be happening unless it hits
+ * recursion quota limit or 'runasync' callback fails.
+ */
+ INSIST(asdata.async ==
+ (test->quota_ok && test->start_result == ISC_R_SUCCESS));
+
+ /*
+ * Emulate cancel if so specified.
+ * The cancel callback should be called.
+ */
+ if (test->do_cancel) {
+ ns_query_cancel(qctx->client);
+ }
+ INSIST(asdata.canceled == test->do_cancel);
+
+ /* If async event has started, manually invoke the 'done' event. */
+ if (asdata.async) {
+ qctx->client->now = 0; /* set to sentinel before resume */
+ asdata.rev->ev_action(asdata.rev->ev_sender,
+ (isc_event_t *)asdata.rev);
+
+ /* Confirm necessary cleanup has been performed. */
+ INSIST(qctx->client->query.hookactx == NULL);
+ INSIST(qctx->client->state == NS_CLIENTSTATE_WORKING);
+ INSIST(qctx->client->recursionquota == NULL);
+ INSIST(ns_stats_get_counter(qctx->client->sctx->nsstats,
+ ns_statscounter_recursclients) ==
+ 0);
+ INSIST(!ISC_LINK_LINKED(qctx->client, rlink));
+ if (!test->do_cancel) {
+ /*
+ * In the normal case the client's timestamp is updated
+ * and the query handling has been resumed from the
+ * expected point.
+ */
+ INSIST(qctx->client->now != 0);
+ INSIST(asdata.lasthookpoint == test->hookpoint2);
+ }
+ } else {
+ INSIST(qctx->client->query.hookactx == NULL);
+ }
+
+ /*
+ * Confirm SERVFAIL has been sent if it was expected.
+ * Also, the last-generated qctx should have detach_client being true.
+ */
+ if (expect_servfail) {
+ INSIST(ns_stats_get_counter(qctx->client->sctx->nsstats,
+ ns_statscounter_servfail) ==
+ srvfail_cnt + 1);
+ if (test->do_cancel) {
+ /* qctx was created on resume and copied in hook */
+ INSIST(asdata.qctx.detach_client);
+ } else {
+ INSIST(qctx->detach_client);
+ }
+ }
+
+ /*
+ * Cleanup. Note that we've kept 'qctx' until now; otherwise
+ * qctx->client may have been invalidated while we still need it.
+ */
+ ns_test_qctx_destroy(&qctx);
+ ns_hooktable_free(mctx, (void **)&ns__hook_table);
+ if (quota != NULL) {
+ isc_quota_detach(&quota);
+ }
+}
+
+ISC_RUN_TEST_IMPL(ns_query_hookasync) {
+ size_t i;
+
+ UNUSED(state);
+
+ const ns__query_hookasync_test_params_t tests[] = {
+ {
+ NS_TEST_ID("normal case"),
+ NS_QUERY_START_BEGIN,
+ NS_QUERY_START_BEGIN,
+ hook_async_query_start_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("quota fail"),
+ NS_QUERY_START_BEGIN,
+ NS_QUERY_START_BEGIN,
+ hook_async_query_start_begin,
+ ISC_R_SUCCESS,
+ false,
+ false,
+ },
+ {
+ NS_TEST_ID("start fail"),
+ NS_QUERY_START_BEGIN,
+ NS_QUERY_START_BEGIN,
+ hook_async_query_start_begin,
+ ISC_R_FAILURE,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("query cancel"),
+ NS_QUERY_START_BEGIN,
+ NS_QUERY_START_BEGIN,
+ hook_async_query_start_begin,
+ ISC_R_SUCCESS,
+ true,
+ true,
+ },
+ /*
+ * The rest of the test case just confirms supported hookpoints
+ * with the same test logic.
+ */
+ {
+ NS_TEST_ID("async from setup"),
+ NS_QUERY_SETUP,
+ NS_QUERY_SETUP,
+ hook_async_query_setup,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from lookup"),
+ NS_QUERY_LOOKUP_BEGIN,
+ NS_QUERY_LOOKUP_BEGIN,
+ hook_async_query_lookup_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from resume"),
+ NS_QUERY_RESUME_BEGIN,
+ NS_QUERY_RESUME_BEGIN,
+ hook_async_query_resume_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from resume restored"),
+ NS_QUERY_RESUME_RESTORED,
+ NS_QUERY_RESUME_BEGIN,
+ hook_async_query_resume_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from gotanswer"),
+ NS_QUERY_GOT_ANSWER_BEGIN,
+ NS_QUERY_GOT_ANSWER_BEGIN,
+ hook_async_query_got_answer_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from respond any"),
+ NS_QUERY_RESPOND_ANY_BEGIN,
+ NS_QUERY_RESPOND_ANY_BEGIN,
+ hook_async_query_respond_any_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from add answer"),
+ NS_QUERY_ADDANSWER_BEGIN,
+ NS_QUERY_ADDANSWER_BEGIN,
+ hook_async_query_addanswer_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from notfound"),
+ NS_QUERY_NOTFOUND_BEGIN,
+ NS_QUERY_NOTFOUND_BEGIN,
+ hook_async_query_notfound_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from prep delegation"),
+ NS_QUERY_PREP_DELEGATION_BEGIN,
+ NS_QUERY_PREP_DELEGATION_BEGIN,
+ hook_async_query_prep_delegation_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from zone delegation"),
+ NS_QUERY_ZONE_DELEGATION_BEGIN,
+ NS_QUERY_ZONE_DELEGATION_BEGIN,
+ hook_async_query_zone_delegation_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from delegation"),
+ NS_QUERY_DELEGATION_BEGIN,
+ NS_QUERY_DELEGATION_BEGIN,
+ hook_async_query_delegation_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from async delegation"),
+ NS_QUERY_DELEGATION_RECURSE_BEGIN,
+ NS_QUERY_DELEGATION_RECURSE_BEGIN,
+ hook_async_query_delegation_recurse_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from nodata"),
+ NS_QUERY_NODATA_BEGIN,
+ NS_QUERY_NODATA_BEGIN,
+ hook_async_query_nodata_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from nxdomain"),
+ NS_QUERY_NXDOMAIN_BEGIN,
+ NS_QUERY_NXDOMAIN_BEGIN,
+ hook_async_query_nxdomain_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from ncache"),
+ NS_QUERY_NCACHE_BEGIN,
+ NS_QUERY_NCACHE_BEGIN,
+ hook_async_query_ncache_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from CNAME"),
+ NS_QUERY_CNAME_BEGIN,
+ NS_QUERY_CNAME_BEGIN,
+ hook_async_query_cname_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from DNAME"),
+ NS_QUERY_DNAME_BEGIN,
+ NS_QUERY_DNAME_BEGIN,
+ hook_async_query_dname_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from prep response"),
+ NS_QUERY_PREP_RESPONSE_BEGIN,
+ NS_QUERY_PREP_RESPONSE_BEGIN,
+ hook_async_query_response_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from respond"),
+ NS_QUERY_RESPOND_BEGIN,
+ NS_QUERY_RESPOND_BEGIN,
+ hook_async_query_respond_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from done begin"),
+ NS_QUERY_DONE_BEGIN,
+ NS_QUERY_DONE_BEGIN,
+ hook_async_query_done_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ {
+ NS_TEST_ID("async from done send"),
+ NS_QUERY_DONE_SEND,
+ NS_QUERY_DONE_BEGIN,
+ hook_async_query_done_begin,
+ ISC_R_SUCCESS,
+ true,
+ false,
+ },
+ };
+
+ for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ run_hookasync_test(&tests[i]);
+ }
+}
+
+/*****
+***** tests for higher level ("e2e") behavior of ns_query_hookasync().
+***** It exercises overall behavior for some selected cases, while
+***** ns__query_hookasync_test exercises implementation details for a
+***** simple scenario and for all supported hook points.
+*****/
+
+/*%
+ * Structure containing parameters for ns__query_hookasync_e2e_test().
+ */
+typedef struct {
+ const ns_test_id_t id; /* libns test identifier */
+ const char *qname; /* QNAME */
+ ns_hookpoint_t hookpoint; /* hook point specified for resume */
+ isc_result_t start_result; /* result of 'runasync' */
+ bool do_cancel; /* true if query should be canceled
+ * in test */
+ dns_rcode_t expected_rcode;
+} ns__query_hookasync_e2e_test_params_t;
+
+/* data structure passed from tests to hooks */
+typedef struct hookasync_e2e_data {
+ bool async; /* true if in a hook-triggered
+ * asynchronous process */
+ ns_hook_resevent_t *rev; /* resume event sent on completion */
+ ns_hookpoint_t hookpoint; /* specifies where to resume */
+ isc_result_t start_result; /* result of 'runasync' */
+ dns_rcode_t expected_rcode;
+ bool done; /* if SEND_DONE hook is called */
+} hookasync_e2e_data_t;
+
+/* Cancel callback. Just need to be defined, it doesn't have to do anything. */
+static void
+cancel_e2ehookactx(ns_hookasync_t *ctx) {
+ UNUSED(ctx);
+}
+
+/* 'runasync' callback passed to ns_query_hookasync */
+static isc_result_t
+test_hookasync_e2e(query_ctx_t *qctx, isc_mem_t *memctx, void *arg,
+ isc_task_t *task, isc_taskaction_t action, void *evarg,
+ ns_hookasync_t **ctxp) {
+ ns_hookasync_t *ctx = NULL;
+ ns_hook_resevent_t *rev = NULL;
+ hookasync_e2e_data_t *asdata = arg;
+
+ if (asdata->start_result != ISC_R_SUCCESS) {
+ return (asdata->start_result);
+ }
+
+ ctx = isc_mem_get(memctx, sizeof(*ctx));
+ rev = (ns_hook_resevent_t *)isc_event_allocate(
+ memctx, task, NS_EVENT_HOOKASYNCDONE, action, evarg,
+ sizeof(*rev));
+
+ rev->hookpoint = asdata->hookpoint;
+ rev->saved_qctx = qctx;
+ rev->ctx = ctx;
+ asdata->rev = rev;
+
+ *ctx = (ns_hookasync_t){ .private = asdata };
+ isc_mem_attach(memctx, &ctx->mctx);
+ ctx->destroy = destroy_hookactx;
+ ctx->cancel = cancel_e2ehookactx;
+
+ *ctxp = ctx;
+ return (ISC_R_SUCCESS);
+}
+
+static ns_hookresult_t
+hook_async_e2e(void *arg, void *data, isc_result_t *resultp) {
+ query_ctx_t *qctx = arg;
+ hookasync_e2e_data_t *asdata = data;
+ isc_result_t result;
+
+ if (!asdata->async) {
+ /* Initial call to the hook; start async event */
+ result = ns_query_hookasync(qctx, test_hookasync_e2e, asdata);
+ if (result != ISC_R_SUCCESS) {
+ *resultp = result;
+ return (NS_HOOK_RETURN);
+ }
+
+ asdata->async = true;
+ asdata->rev->origresult = *resultp; /* save it for resume */
+ *resultp = ISC_R_UNSET;
+ return (NS_HOOK_RETURN);
+ } else {
+ /* Resume from the completion of async event */
+ asdata->async = false;
+ /* Don't touch 'resultp' */
+ return (NS_HOOK_CONTINUE);
+ }
+}
+
+/*
+ * Check whether the final response has expected the RCODE according to
+ * the test scenario.
+ */
+static ns_hookresult_t
+hook_donesend(void *arg, void *data, isc_result_t *resultp) {
+ query_ctx_t *qctx = arg;
+ hookasync_e2e_data_t *asdata = data;
+
+ INSIST(qctx->client->message->rcode == asdata->expected_rcode);
+ asdata->done = true; /* Let the test know this hook is called */
+ *resultp = ISC_R_UNSET;
+ return (NS_HOOK_CONTINUE);
+}
+
+static void
+run_hookasync_e2e_test(const ns__query_hookasync_e2e_test_params_t *test) {
+ query_ctx_t *qctx = NULL;
+ isc_result_t result;
+ hookasync_e2e_data_t asdata = {
+ .async = false,
+ .hookpoint = test->hookpoint,
+ .start_result = test->start_result,
+ .expected_rcode = test->expected_rcode,
+ .done = false,
+ };
+ const ns_hook_t donesend_hook = {
+ .action = hook_donesend,
+ .action_data = &asdata,
+ };
+ const ns_hook_t hook = {
+ .action = hook_async_e2e,
+ .action_data = &asdata,
+ };
+ const ns_test_qctx_create_params_t qctx_params = {
+ .qname = test->qname,
+ .qtype = dns_rdatatype_a,
+ .with_cache = true,
+ };
+
+ ns__hook_table = NULL;
+ ns_hooktable_create(mctx, &ns__hook_table);
+ ns_hook_add(ns__hook_table, mctx, test->hookpoint, &hook);
+ ns_hook_add(ns__hook_table, mctx, NS_QUERY_DONE_SEND, &donesend_hook);
+
+ result = ns_test_qctx_create(&qctx_params, &qctx);
+ INSIST(result == ISC_R_SUCCESS);
+
+ isc_sockaddr_any(&qctx->client->peeraddr); /* for sortlist */
+ qctx->client->sendcb = send_noop;
+
+ /* Load a zone. it should have ns.foo/A */
+ result = ns_test_serve_zone("foo", TESTS_DIR "/testdata/query/foo.db",
+ qctx->client->view);
+ INSIST(result == ISC_R_SUCCESS);
+
+ /*
+ * We expect to have a response sent all cases, so we need to
+ * setup reqhandle (which will be detached on the send).
+ */
+ isc_nmhandle_attach(qctx->client->handle, &qctx->client->reqhandle);
+
+ /* Handle the query. hook-based async event will be triggered. */
+ qctx->client->state = NS_CLIENTSTATE_WORKING;
+ ns__query_start(qctx);
+
+ /* If specified cancel the query at this point. */
+ if (test->do_cancel) {
+ ns_query_cancel(qctx->client);
+ }
+
+ if (test->start_result == ISC_R_SUCCESS) {
+ /*
+ * If async event has started, manually invoke the done event.
+ */
+ INSIST(asdata.async);
+ asdata.rev->ev_action(asdata.rev->ev_sender,
+ (isc_event_t *)asdata.rev);
+
+ /*
+ * Usually 'async' is reset to false on the 2nd call to
+ * the hook. But the hook isn't called if the query is
+ * canceled.
+ */
+ INSIST(asdata.done == !test->do_cancel);
+ INSIST(asdata.async == test->do_cancel);
+ } else {
+ INSIST(!asdata.async);
+ }
+
+ /* Cleanup */
+ ns_test_qctx_destroy(&qctx);
+ ns_test_cleanup_zone();
+ ns_hooktable_free(mctx, (void **)&ns__hook_table);
+}
+
+ISC_RUN_TEST_IMPL(ns_query_hookasync_e2e) {
+ UNUSED(state);
+
+ const ns__query_hookasync_e2e_test_params_t tests[] = {
+ {
+ NS_TEST_ID("positive answer"),
+ "ns.foo",
+ NS_QUERY_GOT_ANSWER_BEGIN,
+ ISC_R_SUCCESS,
+ false,
+ dns_rcode_noerror,
+ },
+ {
+ NS_TEST_ID("NXDOMAIN"),
+ "notexist.foo",
+ NS_QUERY_NXDOMAIN_BEGIN,
+ ISC_R_SUCCESS,
+ false,
+ dns_rcode_nxdomain,
+ },
+ {
+ NS_TEST_ID("async fail"),
+ "ns.foo",
+ NS_QUERY_DONE_BEGIN,
+ ISC_R_FAILURE,
+ false,
+ -1,
+ },
+ {
+ NS_TEST_ID("cancel query"),
+ "ns.foo",
+ NS_QUERY_DONE_BEGIN,
+ ISC_R_SUCCESS,
+ true,
+ -1,
+ },
+ };
+
+ for (size_t i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ run_hookasync_e2e_test(&tests[i]);
+ }
+}
+
+ISC_TEST_LIST_START
+
+ISC_TEST_ENTRY_CUSTOM(ns_query_sfcache, setup_test, teardown_test)
+ISC_TEST_ENTRY_CUSTOM(ns_query_start, setup_test, teardown_test)
+ISC_TEST_ENTRY_CUSTOM(ns_query_hookasync, setup_test, teardown_test)
+ISC_TEST_ENTRY_CUSTOM(ns_query_hookasync_e2e, setup_test, teardown_test)
+
+ISC_TEST_LIST_END
+ISC_TEST_MAIN
diff --git a/tests/ns/testdata/notify/notify1.msg b/tests/ns/testdata/notify/notify1.msg
new file mode 100644
index 0000000..a84193b
--- /dev/null
+++ b/tests/ns/testdata/notify/notify1.msg
@@ -0,0 +1,3 @@
+# notify for example.com
+10 a6 10 10 00 01 00 00 00 00 00 00 07 65 78 61
+6d 70 6c 65 03 63 6f 6d 00 00 06 00 01
diff --git a/tests/ns/testdata/notify/zone1.db b/tests/ns/testdata/notify/zone1.db
new file mode 100644
index 0000000..b218d6d
--- /dev/null
+++ b/tests/ns/testdata/notify/zone1.db
@@ -0,0 +1,26 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; SPDX-License-Identifier: MPL-2.0
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+$TTL 1000
+@ in soa localhost. postmaster.localhost. (
+ 1993050801 ;serial
+ 3600 ;refresh
+ 1800 ;retry
+ 604800 ;expiration
+ 3600 ) ;minimum
+ in ns ns.example.com.
+ in ns ns2.example.com.
+ in ns ns3.example.com.
+ns in a 10.0.0.1
+ns2 in a 10.0.0.2
+ns3 in a 10.0.0.3
+
+a in a 1.2.3.4
diff --git a/tests/ns/testdata/query/foo.db b/tests/ns/testdata/query/foo.db
new file mode 100644
index 0000000..5fb2c42
--- /dev/null
+++ b/tests/ns/testdata/query/foo.db
@@ -0,0 +1,20 @@
+; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+;
+; SPDX-License-Identifier: MPL-2.0
+;
+; This Source Code Form is subject to the terms of the Mozilla Public
+; License, v. 2.0. If a copy of the MPL was not distributed with this
+; file, you can obtain one at https://mozilla.org/MPL/2.0/.
+;
+; See the COPYRIGHT file distributed with this work for additional
+; information regarding copyright ownership.
+
+$TTL 3600
+@ IN SOA localhost. postmaster.localhost. (
+ 1 ;serial
+ 3600 ;refresh
+ 1800 ;retry
+ 604800 ;expiration
+ 3600 ) ;minimum
+ IN NS ns
+ns IN A 127.0.0.1