diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:15:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 12:15:43 +0000 |
commit | f5f56e1a1c4d9e9496fcb9d81131066a964ccd23 (patch) | |
tree | 49e44c6f87febed37efb953ab5485aa49f6481a7 /src/lib/dhcp_ddns/tests | |
parent | Initial commit. (diff) | |
download | isc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.tar.xz isc-kea-f5f56e1a1c4d9e9496fcb9d81131066a964ccd23.zip |
Adding upstream version 2.4.1.upstream/2.4.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib/dhcp_ddns/tests')
-rw-r--r-- | src/lib/dhcp_ddns/tests/Makefile.am | 48 | ||||
-rw-r--r-- | src/lib/dhcp_ddns/tests/Makefile.in | 1075 | ||||
-rw-r--r-- | src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc | 1428 | ||||
-rw-r--r-- | src/lib/dhcp_ddns/tests/ncr_unittests.cc | 743 | ||||
-rw-r--r-- | src/lib/dhcp_ddns/tests/run_unittests.cc | 21 | ||||
-rw-r--r-- | src/lib/dhcp_ddns/tests/test_utils.cc | 37 | ||||
-rw-r--r-- | src/lib/dhcp_ddns/tests/test_utils.h | 29 |
7 files changed, 3381 insertions, 0 deletions
diff --git a/src/lib/dhcp_ddns/tests/Makefile.am b/src/lib/dhcp_ddns/tests/Makefile.am new file mode 100644 index 0000000..68ae6ba --- /dev/null +++ b/src/lib/dhcp_ddns/tests/Makefile.am @@ -0,0 +1,48 @@ +SUBDIRS = . + +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) +AM_CPPFLAGS += -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/dhcp_ddns/tests\" +AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\" + +AM_CXXFLAGS = $(KEA_CXXFLAGS) + +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + +CLEANFILES = *.gcno *.gcda + +TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) + +TESTS = +if HAVE_GTEST +TESTS += libdhcp_ddns_unittests + +libdhcp_ddns_unittests_SOURCES = run_unittests.cc +libdhcp_ddns_unittests_SOURCES += ncr_unittests.cc +libdhcp_ddns_unittests_SOURCES += ncr_udp_unittests.cc +libdhcp_ddns_unittests_SOURCES += test_utils.cc test_utils.h + +libdhcp_ddns_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) + +libdhcp_ddns_unittests_CXXFLAGS = $(AM_CXXFLAGS) + +libdhcp_ddns_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) + +libdhcp_ddns_unittests_LDADD = $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la +libdhcp_ddns_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la +libdhcp_ddns_unittests_LDADD += $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) +libdhcp_ddns_unittests_LDADD += $(BOOST_LIBS) $(GTEST_LDADD) +endif + +noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/dhcp_ddns/tests/Makefile.in b/src/lib/dhcp_ddns/tests/Makefile.in new file mode 100644 index 0000000..441af44 --- /dev/null +++ b/src/lib/dhcp_ddns/tests/Makefile.in @@ -0,0 +1,1075 @@ +# Makefile.in generated by automake 1.16.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994-2018 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@ + +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@ +TESTS = $(am__EXEEXT_1) +@HAVE_GTEST_TRUE@am__append_1 = libdhcp_ddns_unittests +noinst_PROGRAMS = $(am__EXEEXT_2) +subdir = src/lib/dhcp_ddns/tests +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4macros/ax_boost_for_kea.m4 \ + $(top_srcdir)/m4macros/ax_cpp11.m4 \ + $(top_srcdir)/m4macros/ax_cpp20.m4 \ + $(top_srcdir)/m4macros/ax_crypto.m4 \ + $(top_srcdir)/m4macros/ax_find_library.m4 \ + $(top_srcdir)/m4macros/ax_gssapi.m4 \ + $(top_srcdir)/m4macros/ax_gtest.m4 \ + $(top_srcdir)/m4macros/ax_isc_rpath.m4 \ + $(top_srcdir)/m4macros/ax_netconf.m4 \ + $(top_srcdir)/m4macros/libtool.m4 \ + $(top_srcdir)/m4macros/ltoptions.m4 \ + $(top_srcdir)/m4macros/ltsugar.m4 \ + $(top_srcdir)/m4macros/ltversion.m4 \ + $(top_srcdir)/m4macros/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 = +@HAVE_GTEST_TRUE@am__EXEEXT_1 = libdhcp_ddns_unittests$(EXEEXT) +am__EXEEXT_2 = $(am__EXEEXT_1) +PROGRAMS = $(noinst_PROGRAMS) +am__libdhcp_ddns_unittests_SOURCES_DIST = run_unittests.cc \ + ncr_unittests.cc ncr_udp_unittests.cc test_utils.cc \ + test_utils.h +@HAVE_GTEST_TRUE@am_libdhcp_ddns_unittests_OBJECTS = libdhcp_ddns_unittests-run_unittests.$(OBJEXT) \ +@HAVE_GTEST_TRUE@ libdhcp_ddns_unittests-ncr_unittests.$(OBJEXT) \ +@HAVE_GTEST_TRUE@ libdhcp_ddns_unittests-ncr_udp_unittests.$(OBJEXT) \ +@HAVE_GTEST_TRUE@ libdhcp_ddns_unittests-test_utils.$(OBJEXT) +libdhcp_ddns_unittests_OBJECTS = $(am_libdhcp_ddns_unittests_OBJECTS) +am__DEPENDENCIES_1 = +@HAVE_GTEST_TRUE@libdhcp_ddns_unittests_DEPENDENCIES = $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/stats/libkea-stats.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/hooks/libkea-hooks.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/cc/libkea-cc.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/asiolink/libkea-asiolink.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/dns/libkea-dns++.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/log/libkea-log.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/util/libkea-util.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/exceptions/libkea-exceptions.la \ +@HAVE_GTEST_TRUE@ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ +@HAVE_GTEST_TRUE@ $(am__DEPENDENCIES_1) $(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 = +libdhcp_ddns_unittests_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ + $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) \ + $(libdhcp_ddns_unittests_LDFLAGS) $(LDFLAGS) -o $@ +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)/libdhcp_ddns_unittests-ncr_udp_unittests.Po \ + ./$(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Po \ + ./$(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Po \ + ./$(DEPDIR)/libdhcp_ddns_unittests-test_utils.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +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 = $(libdhcp_ddns_unittests_SOURCES) +DIST_SOURCES = $(am__libdhcp_ddns_unittests_SOURCES_DIST) +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + distdir distdir-am +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)` +ETAGS = etags +CTAGS = ctags +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='[0;31m'; \ + grn='[0;32m'; \ + lgn='[1;32m'; \ + blu='[1;34m'; \ + mgn='[0;35m'; \ + brg='[1m'; \ + std='[m'; \ + fi; \ +} +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ASCIIDOC = @ASCIIDOC@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_INCLUDES = @BOOST_INCLUDES@ +BOOST_LIBS = @BOOST_LIBS@ +BOTAN_TOOL = @BOTAN_TOOL@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONTRIB_DIR = @CONTRIB_DIR@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRYPTO_CFLAGS = @CRYPTO_CFLAGS@ +CRYPTO_INCLUDES = @CRYPTO_INCLUDES@ +CRYPTO_LDFLAGS = @CRYPTO_LDFLAGS@ +CRYPTO_LIBS = @CRYPTO_LIBS@ +CRYPTO_PACKAGE = @CRYPTO_PACKAGE@ +CRYPTO_RPATH = @CRYPTO_RPATH@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISTCHECK_BOOST_CONFIGURE_FLAG = @DISTCHECK_BOOST_CONFIGURE_FLAG@ +DISTCHECK_CONTRIB_CONFIGURE_FLAG = @DISTCHECK_CONTRIB_CONFIGURE_FLAG@ +DISTCHECK_CRYPTO_CONFIGURE_FLAG = @DISTCHECK_CRYPTO_CONFIGURE_FLAG@ +DISTCHECK_GSSAPI_CONFIGURE_FLAG = @DISTCHECK_GSSAPI_CONFIGURE_FLAG@ +DISTCHECK_GTEST_CONFIGURE_FLAG = @DISTCHECK_GTEST_CONFIGURE_FLAG@ +DISTCHECK_KEA_SHELL_CONFIGURE_FLAG = @DISTCHECK_KEA_SHELL_CONFIGURE_FLAG@ +DISTCHECK_LIBYANGCPP_CONFIGURE_FLAG = @DISTCHECK_LIBYANGCPP_CONFIGURE_FLAG@ +DISTCHECK_LIBYANG_CONFIGURE_FLAG = @DISTCHECK_LIBYANG_CONFIGURE_FLAG@ +DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG = @DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG@ +DISTCHECK_MYSQL_CONFIGURE_FLAG = @DISTCHECK_MYSQL_CONFIGURE_FLAG@ +DISTCHECK_PERFDHCP_CONFIGURE_FLAG = @DISTCHECK_PERFDHCP_CONFIGURE_FLAG@ +DISTCHECK_PGSQL_CONFIGURE_FLAG = @DISTCHECK_PGSQL_CONFIGURE_FLAG@ +DISTCHECK_PREMIUM_CONFIGURE_FLAG = @DISTCHECK_PREMIUM_CONFIGURE_FLAG@ +DISTCHECK_SYSREPOCPP_CONFIGURE_FLAG = @DISTCHECK_SYSREPOCPP_CONFIGURE_FLAG@ +DISTCHECK_SYSREPO_CONFIGURE_FLAG = @DISTCHECK_SYSREPO_CONFIGURE_FLAG@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GENHTML = @GENHTML@ +GREP = @GREP@ +GSSAPI_CFLAGS = @GSSAPI_CFLAGS@ +GSSAPI_LIBS = @GSSAPI_LIBS@ +GTEST_CONFIG = @GTEST_CONFIG@ +GTEST_INCLUDES = @GTEST_INCLUDES@ +GTEST_LDADD = @GTEST_LDADD@ +GTEST_LDFLAGS = @GTEST_LDFLAGS@ +GTEST_SOURCE = @GTEST_SOURCE@ +HAVE_NETCONF = @HAVE_NETCONF@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KEA_CXXFLAGS = @KEA_CXXFLAGS@ +KEA_SRCID = @KEA_SRCID@ +KRB5_CONFIG = @KRB5_CONFIG@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIBYANGCPP_CPPFLAGS = @LIBYANGCPP_CPPFLAGS@ +LIBYANGCPP_INCLUDEDIR = @LIBYANGCPP_INCLUDEDIR@ +LIBYANGCPP_LIBS = @LIBYANGCPP_LIBS@ +LIBYANGCPP_PREFIX = @LIBYANGCPP_PREFIX@ +LIBYANGCPP_VERSION = @LIBYANGCPP_VERSION@ +LIBYANG_CPPFLAGS = @LIBYANG_CPPFLAGS@ +LIBYANG_INCLUDEDIR = @LIBYANG_INCLUDEDIR@ +LIBYANG_LIBS = @LIBYANG_LIBS@ +LIBYANG_PREFIX = @LIBYANG_PREFIX@ +LIBYANG_VERSION = @LIBYANG_VERSION@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOG4CPLUS_INCLUDES = @LOG4CPLUS_INCLUDES@ +LOG4CPLUS_LIBS = @LOG4CPLUS_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ +MYSQL_LIBS = @MYSQL_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +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@ +PACKAGE_VERSION_TYPE = @PACKAGE_VERSION_TYPE@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PDFLATEX = @PDFLATEX@ +PERL = @PERL@ +PGSQL_CPPFLAGS = @PGSQL_CPPFLAGS@ +PGSQL_LIBS = @PGSQL_LIBS@ +PKGPYTHONDIR = @PKGPYTHONDIR@ +PKG_CONFIG = @PKG_CONFIG@ +PLANTUML = @PLANTUML@ +PREMIUM_DIR = @PREMIUM_DIR@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +SED = @SED@ +SEP = @SEP@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPHINXBUILD = @SPHINXBUILD@ +SRPD_PLUGINS_PATH = @SRPD_PLUGINS_PATH@ +SR_PLUGINS_PATH = @SR_PLUGINS_PATH@ +SR_REPO_PATH = @SR_REPO_PATH@ +STRIP = @STRIP@ +SYSREPOCPP_CPPFLAGS = @SYSREPOCPP_CPPFLAGS@ +SYSREPOCPP_INCLUDEDIR = @SYSREPOCPP_INCLUDEDIR@ +SYSREPOCPP_LIBS = @SYSREPOCPP_LIBS@ +SYSREPOCPP_PREFIX = @SYSREPOCPP_PREFIX@ +SYSREPOCPP_VERSION = @SYSREPOCPP_VERSION@ +SYSREPO_CPPFLAGS = @SYSREPO_CPPFLAGS@ +SYSREPO_INCLUDEDIR = @SYSREPO_INCLUDEDIR@ +SYSREPO_LIBS = @SYSREPO_LIBS@ +SYSREPO_PREFIX = @SYSREPO_PREFIX@ +SYSREPO_VERSION = @SYSREPO_VERSION@ +USE_LCOV = @USE_LCOV@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WARNING_GCC_44_STRICT_ALIASING_CFLAG = @WARNING_GCC_44_STRICT_ALIASING_CFLAG@ +YACC = @YACC@ +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_CXX = @ac_ct_CXX@ +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@ +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_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = . +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib \ + $(BOOST_INCLUDES) \ + -DTEST_DATA_BUILDDIR=\"$(abs_top_builddir)/src/lib/dhcp_ddns/tests\" \ + -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\" +AM_CXXFLAGS = $(KEA_CXXFLAGS) +@USE_STATIC_LINK_TRUE@AM_LDFLAGS = -static +CLEANFILES = *.gcno *.gcda +TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) +@HAVE_GTEST_TRUE@libdhcp_ddns_unittests_SOURCES = run_unittests.cc \ +@HAVE_GTEST_TRUE@ ncr_unittests.cc ncr_udp_unittests.cc \ +@HAVE_GTEST_TRUE@ test_utils.cc test_utils.h +@HAVE_GTEST_TRUE@libdhcp_ddns_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) +@HAVE_GTEST_TRUE@libdhcp_ddns_unittests_CXXFLAGS = $(AM_CXXFLAGS) +@HAVE_GTEST_TRUE@libdhcp_ddns_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) +@HAVE_GTEST_TRUE@libdhcp_ddns_unittests_LDADD = $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/stats/libkea-stats.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/hooks/libkea-hooks.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/cc/libkea-cc.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/asiolink/libkea-asiolink.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/dns/libkea-dns++.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/log/libkea-log.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/util/libkea-util.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/exceptions/libkea-exceptions.la \ +@HAVE_GTEST_TRUE@ $(LOG4CPLUS_LIBS) $(CRYPTO_LIBS) \ +@HAVE_GTEST_TRUE@ $(BOOST_LIBS) $(GTEST_LDADD) +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .cc .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(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 src/lib/dhcp_ddns/tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/lib/dhcp_ddns/tests/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_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): + +clean-noinstPROGRAMS: + @list='$(noinst_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 + +libdhcp_ddns_unittests$(EXEEXT): $(libdhcp_ddns_unittests_OBJECTS) $(libdhcp_ddns_unittests_DEPENDENCIES) $(EXTRA_libdhcp_ddns_unittests_DEPENDENCIES) + @rm -f libdhcp_ddns_unittests$(EXEEXT) + $(AM_V_CXXLD)$(libdhcp_ddns_unittests_LINK) $(libdhcp_ddns_unittests_OBJECTS) $(libdhcp_ddns_unittests_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libdhcp_ddns_unittests-test_utils.Po@am__quote@ # am--include-marker + +$(am__depfiles_remade): + @$(MKDIR_P) $(@D) + @echo '# dummy' >$@-t && $(am__mv) $@-t $@ + +am--depfiles: $(am__depfiles_remade) + +.cc.o: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $< + +.cc.obj: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'` + +.cc.lo: +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $< + +libdhcp_ddns_unittests-run_unittests.o: run_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -MT libdhcp_ddns_unittests-run_unittests.o -MD -MP -MF $(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Tpo -c -o libdhcp_ddns_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Tpo $(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='run_unittests.cc' object='libdhcp_ddns_unittests-run_unittests.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -c -o libdhcp_ddns_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc + +libdhcp_ddns_unittests-run_unittests.obj: run_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -MT libdhcp_ddns_unittests-run_unittests.obj -MD -MP -MF $(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Tpo -c -o libdhcp_ddns_unittests-run_unittests.obj `if test -f 'run_unittests.cc'; then $(CYGPATH_W) 'run_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/run_unittests.cc'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Tpo $(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='run_unittests.cc' object='libdhcp_ddns_unittests-run_unittests.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -c -o libdhcp_ddns_unittests-run_unittests.obj `if test -f 'run_unittests.cc'; then $(CYGPATH_W) 'run_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/run_unittests.cc'; fi` + +libdhcp_ddns_unittests-ncr_unittests.o: ncr_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -MT libdhcp_ddns_unittests-ncr_unittests.o -MD -MP -MF $(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Tpo -c -o libdhcp_ddns_unittests-ncr_unittests.o `test -f 'ncr_unittests.cc' || echo '$(srcdir)/'`ncr_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Tpo $(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ncr_unittests.cc' object='libdhcp_ddns_unittests-ncr_unittests.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -c -o libdhcp_ddns_unittests-ncr_unittests.o `test -f 'ncr_unittests.cc' || echo '$(srcdir)/'`ncr_unittests.cc + +libdhcp_ddns_unittests-ncr_unittests.obj: ncr_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -MT libdhcp_ddns_unittests-ncr_unittests.obj -MD -MP -MF $(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Tpo -c -o libdhcp_ddns_unittests-ncr_unittests.obj `if test -f 'ncr_unittests.cc'; then $(CYGPATH_W) 'ncr_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/ncr_unittests.cc'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Tpo $(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ncr_unittests.cc' object='libdhcp_ddns_unittests-ncr_unittests.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -c -o libdhcp_ddns_unittests-ncr_unittests.obj `if test -f 'ncr_unittests.cc'; then $(CYGPATH_W) 'ncr_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/ncr_unittests.cc'; fi` + +libdhcp_ddns_unittests-ncr_udp_unittests.o: ncr_udp_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -MT libdhcp_ddns_unittests-ncr_udp_unittests.o -MD -MP -MF $(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Tpo -c -o libdhcp_ddns_unittests-ncr_udp_unittests.o `test -f 'ncr_udp_unittests.cc' || echo '$(srcdir)/'`ncr_udp_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Tpo $(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ncr_udp_unittests.cc' object='libdhcp_ddns_unittests-ncr_udp_unittests.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -c -o libdhcp_ddns_unittests-ncr_udp_unittests.o `test -f 'ncr_udp_unittests.cc' || echo '$(srcdir)/'`ncr_udp_unittests.cc + +libdhcp_ddns_unittests-ncr_udp_unittests.obj: ncr_udp_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -MT libdhcp_ddns_unittests-ncr_udp_unittests.obj -MD -MP -MF $(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Tpo -c -o libdhcp_ddns_unittests-ncr_udp_unittests.obj `if test -f 'ncr_udp_unittests.cc'; then $(CYGPATH_W) 'ncr_udp_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/ncr_udp_unittests.cc'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Tpo $(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='ncr_udp_unittests.cc' object='libdhcp_ddns_unittests-ncr_udp_unittests.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -c -o libdhcp_ddns_unittests-ncr_udp_unittests.obj `if test -f 'ncr_udp_unittests.cc'; then $(CYGPATH_W) 'ncr_udp_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/ncr_udp_unittests.cc'; fi` + +libdhcp_ddns_unittests-test_utils.o: test_utils.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -MT libdhcp_ddns_unittests-test_utils.o -MD -MP -MF $(DEPDIR)/libdhcp_ddns_unittests-test_utils.Tpo -c -o libdhcp_ddns_unittests-test_utils.o `test -f 'test_utils.cc' || echo '$(srcdir)/'`test_utils.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdhcp_ddns_unittests-test_utils.Tpo $(DEPDIR)/libdhcp_ddns_unittests-test_utils.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='test_utils.cc' object='libdhcp_ddns_unittests-test_utils.o' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -c -o libdhcp_ddns_unittests-test_utils.o `test -f 'test_utils.cc' || echo '$(srcdir)/'`test_utils.cc + +libdhcp_ddns_unittests-test_utils.obj: test_utils.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -MT libdhcp_ddns_unittests-test_utils.obj -MD -MP -MF $(DEPDIR)/libdhcp_ddns_unittests-test_utils.Tpo -c -o libdhcp_ddns_unittests-test_utils.obj `if test -f 'test_utils.cc'; then $(CYGPATH_W) 'test_utils.cc'; else $(CYGPATH_W) '$(srcdir)/test_utils.cc'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libdhcp_ddns_unittests-test_utils.Tpo $(DEPDIR)/libdhcp_ddns_unittests-test_utils.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='test_utils.cc' object='libdhcp_ddns_unittests-test_utils.obj' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libdhcp_ddns_unittests_CPPFLAGS) $(CPPFLAGS) $(libdhcp_ddns_unittests_CXXFLAGS) $(CXXFLAGS) -c -o libdhcp_ddns_unittests-test_utils.obj `if test -f 'test_utils.cc'; then $(CYGPATH_W) 'test_utils.cc'; else $(CYGPATH_W) '$(srcdir)/test_utils.cc'; fi` + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(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-recursive + +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-recursive + +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 + +check-TESTS: $(TESTS) + @failed=0; all=0; xfail=0; xpass=0; skip=0; \ + srcdir=$(srcdir); export srcdir; \ + list=' $(TESTS) '; \ + $(am__tty_colors); \ + if test -n "$$list"; then \ + for tst in $$list; do \ + if test -f ./$$tst; then dir=./; \ + elif test -f $$tst; then dir=; \ + else dir="$(srcdir)/"; fi; \ + if $(TESTS_ENVIRONMENT) $${dir}$$tst $(AM_TESTS_FD_REDIRECT); then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xpass=`expr $$xpass + 1`; \ + failed=`expr $$failed + 1`; \ + col=$$red; res=XPASS; \ + ;; \ + *) \ + col=$$grn; res=PASS; \ + ;; \ + esac; \ + elif test $$? -ne 77; then \ + all=`expr $$all + 1`; \ + case " $(XFAIL_TESTS) " in \ + *[\ \ ]$$tst[\ \ ]*) \ + xfail=`expr $$xfail + 1`; \ + col=$$lgn; res=XFAIL; \ + ;; \ + *) \ + failed=`expr $$failed + 1`; \ + col=$$red; res=FAIL; \ + ;; \ + esac; \ + else \ + skip=`expr $$skip + 1`; \ + col=$$blu; res=SKIP; \ + fi; \ + echo "$${col}$$res$${std}: $$tst"; \ + done; \ + if test "$$all" -eq 1; then \ + tests="test"; \ + All=""; \ + else \ + tests="tests"; \ + All="All "; \ + fi; \ + if test "$$failed" -eq 0; then \ + if test "$$xfail" -eq 0; then \ + banner="$$All$$all $$tests passed"; \ + else \ + if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ + banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ + fi; \ + else \ + if test "$$xpass" -eq 0; then \ + banner="$$failed of $$all $$tests failed"; \ + else \ + if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ + banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ + fi; \ + fi; \ + dashes="$$banner"; \ + skipped=""; \ + if test "$$skip" -ne 0; then \ + if test "$$skip" -eq 1; then \ + skipped="($$skip test was not run)"; \ + else \ + skipped="($$skip tests were not run)"; \ + fi; \ + test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$skipped"; \ + fi; \ + report=""; \ + if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ + report="Please report to $(PACKAGE_BUGREPORT)"; \ + test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ + dashes="$$report"; \ + fi; \ + dashes=`echo "$$dashes" | sed s/./=/g`; \ + if test "$$failed" -eq 0; then \ + col="$$grn"; \ + else \ + col="$$red"; \ + fi; \ + echo "$${col}$$dashes$${std}"; \ + echo "$${col}$$banner$${std}"; \ + test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ + test -z "$$report" || echo "$${col}$$report$${std}"; \ + echo "$${col}$$dashes$${std}"; \ + test "$$failed" -eq 0; \ + else :; fi + +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 + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am + $(MAKE) $(AM_MAKEFLAGS) check-TESTS +check: check-recursive +all-am: Makefile $(PROGRAMS) +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +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: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +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-recursive + +clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \ + mostlyclean-am + +distclean: distclean-recursive + -rm -f ./$(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Po + -rm -f ./$(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Po + -rm -f ./$(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Po + -rm -f ./$(DEPDIR)/libdhcp_ddns_unittests-test_utils.Po + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/libdhcp_ddns_unittests-ncr_udp_unittests.Po + -rm -f ./$(DEPDIR)/libdhcp_ddns_unittests-ncr_unittests.Po + -rm -f ./$(DEPDIR)/libdhcp_ddns_unittests-run_unittests.Po + -rm -f ./$(DEPDIR)/libdhcp_ddns_unittests-test_utils.Po + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(am__recursive_targets) check-am install-am install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ + am--depfiles check check-TESTS check-am clean clean-generic \ + clean-libtool clean-noinstPROGRAMS cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir 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 installdirs-am maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ + tags tags-am uninstall uninstall-am + +.PRECIOUS: Makefile + + +# 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/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc new file mode 100644 index 0000000..b63ed8c --- /dev/null +++ b/src/lib/dhcp_ddns/tests/ncr_udp_unittests.cc @@ -0,0 +1,1428 @@ +// Copyright (C) 2013-2021 Internet Systems Consortium, Inc. ("ISC") +// +// 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 http://mozilla.org/MPL/2.0/. + +#include <config.h> + +#include <gtest/gtest.h> + +#include <asiolink/interval_timer.h> +#include <dhcp_ddns/ncr_io.h> +#include <dhcp_ddns/ncr_udp.h> +#include <util/multi_threading_mgr.h> +#include <util/time_utilities.h> +#include <test_utils.h> + +#include <boost/asio/ip/udp.hpp> + +#include <functional> +#include <algorithm> + +#include <sys/select.h> + +using namespace std; +using namespace isc; +using namespace isc::util; +using namespace isc::dhcp_ddns; + +namespace { + +/// @brief Defines a list of valid JSON NameChangeRequest test messages. +const char *valid_msgs[] = +{ + // Valid Add. + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Valid Remove. + "{" + " \"change-type\" : 1 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": false" + "}", + // Valid Add with IPv6 address + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"fe80::2acf:e9ff:fe12:e56f\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\" : true" + "}" +}; + +const char* TEST_ADDRESS = "127.0.0.1"; +const uint32_t LISTENER_PORT = 5301; +const uint32_t SENDER_PORT = LISTENER_PORT+1; +const long TEST_TIMEOUT = 5 * 1000; + +/// @brief A NOP derivation for constructor test purposes. +class SimpleListenHandler : public NameChangeListener::RequestReceiveHandler { +public: + virtual void operator ()(const NameChangeListener::Result, + NameChangeRequestPtr&) { + } +}; + +/// @brief Tests the NameChangeUDPListener constructors. +/// This test verifies that: +/// 1. Given valid parameters, the listener constructor works +TEST(NameChangeUDPListenerBasicTest, constructionTests) { + // Verify the default constructor works. + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + uint32_t port = LISTENER_PORT; + isc::asiolink::IOService io_service; + SimpleListenHandler ncr_handler; + // Verify that valid constructor works. + EXPECT_NO_THROW(NameChangeUDPListener(ip_address, port, FMT_JSON, + ncr_handler)); +} + +/// @brief Tests NameChangeUDPListener starting and stopping listening . +/// This test verifies that the listener will: +/// 1. Enter listening state +/// 2. If in the listening state, does not allow calls to start listening +/// 3. Exist the listening state +/// 4. Return to the listening state after stopping +TEST(NameChangeUDPListenerBasicTest, basicListenTests) { + // Verify the default constructor works. + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + uint32_t port = LISTENER_PORT; + isc::asiolink::IOService io_service; + SimpleListenHandler ncr_handler; + + NameChangeListenerPtr listener; + ASSERT_NO_THROW(listener.reset( + new NameChangeUDPListener(ip_address, port, FMT_JSON, ncr_handler))); + + // Verify that we can start listening. + EXPECT_NO_THROW(listener->startListening(io_service)); + + // Verify that we are in listening mode. + EXPECT_TRUE(listener->amListening()); + // Verify that a read is in progress. + EXPECT_TRUE(listener->isIoPending()); + + // Verify that attempting to listen when we already are is an error. + EXPECT_THROW(listener->startListening(io_service), NcrListenerError); + + // Verify that we can stop listening. + EXPECT_NO_THROW(listener->stopListening()); + EXPECT_FALSE(listener->amListening()); + + // Verify that IO pending is still true, as IO cancel event has not yet + // occurred. + EXPECT_TRUE(listener->isIoPending()); + + // Verify that IO pending is false, after cancel event occurs. + EXPECT_NO_THROW(io_service.run_one()); + EXPECT_FALSE(listener->isIoPending()); + + // Verify that attempting to stop listening when we are not is ok. + EXPECT_NO_THROW(listener->stopListening()); + + // Verify that we can re-enter listening. + EXPECT_NO_THROW(listener->startListening(io_service)); + EXPECT_TRUE(listener->amListening()); +} + +/// @brief Compares two NameChangeRequests for equality. +bool checkSendVsReceived(NameChangeRequestPtr sent_ncr, + NameChangeRequestPtr received_ncr) { + return ((sent_ncr && received_ncr) && + (*sent_ncr == *received_ncr)); +} + +/// @brief Text fixture for testing NameChangeUDPListener +class NameChangeUDPListenerTest : public virtual ::testing::Test, + NameChangeListener::RequestReceiveHandler { +public: + isc::asiolink::IOService io_service_; + NameChangeListener::Result result_; + NameChangeRequestPtr sent_ncr_; + NameChangeRequestPtr received_ncr_; + NameChangeListenerPtr listener_; + isc::asiolink::IntervalTimer test_timer_; + + /// @brief Constructor + // + // Instantiates the listener member and the test timer. The timer is used + // to ensure a test doesn't go awry and hang forever. + NameChangeUDPListenerTest() + : io_service_(), result_(NameChangeListener::SUCCESS), + test_timer_(io_service_) { + isc::asiolink::IOAddress addr(TEST_ADDRESS); + listener_.reset(new NameChangeUDPListener(addr, LISTENER_PORT, + FMT_JSON, *this, true)); + + // Set the test timeout to break any running tasks if they hang. + test_timer_.setup(std::bind(&NameChangeUDPListenerTest:: + testTimeoutHandler, this), + TEST_TIMEOUT); + } + + virtual ~NameChangeUDPListenerTest(){ + } + + + /// @brief Converts JSON string into an NCR and sends it to the listener. + /// + void sendNcr(const std::string& msg) { + // Build an NCR from json string. This verifies that the + // test string is valid. + ASSERT_NO_THROW(sent_ncr_ = NameChangeRequest::fromJSON(msg)); + + // Now use the NCR to write JSON to an output buffer. + isc::util::OutputBuffer ncr_buffer(1024); + ASSERT_NO_THROW(sent_ncr_->toFormat(FMT_JSON, ncr_buffer)); + + // Create a UDP socket through which our "sender" will send the NCR. + boost::asio::ip::udp::socket + udp_socket(io_service_.get_io_service(), boost::asio::ip::udp::v4()); + + // Create an endpoint pointed at the listener. + boost::asio::ip::udp::endpoint + listener_endpoint(boost::asio::ip::address::from_string(TEST_ADDRESS), + LISTENER_PORT); + + // A response message is now ready to send. Send it! + // Note this uses a synchronous send so it ships immediately. + // If listener isn't in listening mode, it will get missed. + udp_socket.send_to(boost::asio::buffer(ncr_buffer.getData(), + ncr_buffer.getLength()), + listener_endpoint); + } + + /// @brief RequestReceiveHandler operator implementation for receiving NCRs. + /// + /// The fixture acts as the "application" layer. It derives from + /// RequestReceiveHandler and as such implements operator() in order to + /// receive NCRs. + virtual void operator ()(const NameChangeListener::Result result, + NameChangeRequestPtr& ncr) { + // save the result and the NCR we received + result_ = result; + received_ncr_ = ncr; + } + + /// @brief Handler invoked when test timeout is hit + /// + /// This callback stops all running (hanging) tasks on IO service. + void testTimeoutHandler() { + io_service_.stop(); + FAIL() << "Test timeout hit."; + } +}; + +/// @brief Tests NameChangeUDPListener ability to receive NCRs. +/// This test verifies that a listener can enter listening mode and +/// receive NCRs in wire format on its UDP socket; reconstruct the +/// NCRs and delivery them to the "application" layer. +TEST_F(NameChangeUDPListenerTest, basicReceiveTests) { + // Verify we can enter listening mode. + ASSERT_FALSE(listener_->amListening()); + ASSERT_NO_THROW(listener_->startListening(io_service_)); + ASSERT_TRUE(listener_->amListening()); + ASSERT_TRUE(listener_->isIoPending()); + + // Iterate over a series of requests, sending and receiving one + /// at time. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + for (int i = 0; i < num_msgs; i++) { + // We are not verifying ability to send, so if we can't test is over. + ASSERT_NO_THROW(sendNcr(valid_msgs[i])); + + // Execute no more then one event, which should be receive complete. + EXPECT_NO_THROW(io_service_.run_one()); + + // Verify the "application" status value for a successful complete. + EXPECT_EQ(NameChangeListener::SUCCESS, result_); + + // Verify the received request matches the sent request. + EXPECT_TRUE(checkSendVsReceived(sent_ncr_, received_ncr_)); + } + + // Verify we can gracefully stop listening. + EXPECT_NO_THROW(listener_->stopListening()); + EXPECT_FALSE(listener_->amListening()); + + // Verify that IO pending is false, after cancel event occurs. + EXPECT_NO_THROW(io_service_.run_one()); + EXPECT_FALSE(listener_->isIoPending()); +} + +/// @brief A NOP derivation for constructor test purposes. +class SimpleSendHandler : public NameChangeSender::RequestSendHandler { +public: + SimpleSendHandler() : pass_count_(0), error_count_(0) { + } + + virtual void operator ()(const NameChangeSender::Result result, + NameChangeRequestPtr&) { + if (result == NameChangeSender::SUCCESS) { + ++pass_count_; + } else { + ++error_count_; + } + } + + int pass_count_; + int error_count_; +}; + +/// @brief Text fixture for testing NameChangeUDPListener +class NameChangeUDPSenderBasicTest : public virtual ::testing::Test { +public: + NameChangeUDPSenderBasicTest() { + // Disable multi-threading + MultiThreadingMgr::instance().setMode(false); + } + + ~NameChangeUDPSenderBasicTest() { + // Disable multi-threading + MultiThreadingMgr::instance().setMode(false); + } +}; + +/// @brief Tests the NameChangeUDPSender constructors. +/// This test verifies that: +/// 1. Constructing with a max queue size of 0 is not allowed +/// 2. Given valid parameters, the sender constructor works +/// 3. Default construction provides default max queue size +/// 4. Construction with a custom max queue size works +TEST_F(NameChangeUDPSenderBasicTest, constructionTests) { + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + uint32_t port = SENDER_PORT; + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Verify that constructing with an queue size of zero is not allowed. + EXPECT_THROW(NameChangeUDPSender(ip_address, port, + ip_address, port, FMT_JSON, ncr_handler, 0), NcrSenderError); + + NameChangeSenderPtr sender; + // Verify that valid constructor works. + EXPECT_NO_THROW(sender.reset( + new NameChangeUDPSender(ip_address, port, ip_address, port, + FMT_JSON, ncr_handler))); + + // Verify that send queue default max is correct. + size_t expected = NameChangeSender::MAX_QUEUE_DEFAULT; + EXPECT_EQ(expected, sender->getQueueMaxSize()); + + // Verify that constructor with a valid custom queue size works. + EXPECT_NO_THROW(sender.reset( + new NameChangeUDPSender(ip_address, port, ip_address, port, + FMT_JSON, ncr_handler, 100))); + + EXPECT_EQ(100, sender->getQueueMaxSize()); +} + +/// @brief Tests the NameChangeUDPSender constructors. +/// This test verifies that: +/// 1. Constructing with a max queue size of 0 is not allowed +/// 2. Given valid parameters, the sender constructor works +/// 3. Default construction provides default max queue size +/// 4. Construction with a custom max queue size works +TEST_F(NameChangeUDPSenderBasicTest, constructionTestsMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + uint32_t port = SENDER_PORT; + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Verify that constructing with an queue size of zero is not allowed. + EXPECT_THROW(NameChangeUDPSender(ip_address, port, + ip_address, port, FMT_JSON, ncr_handler, 0), NcrSenderError); + + NameChangeSenderPtr sender; + // Verify that valid constructor works. + EXPECT_NO_THROW(sender.reset( + new NameChangeUDPSender(ip_address, port, ip_address, port, + FMT_JSON, ncr_handler))); + + // Verify that send queue default max is correct. + size_t expected = NameChangeSender::MAX_QUEUE_DEFAULT; + EXPECT_EQ(expected, sender->getQueueMaxSize()); + + // Verify that constructor with a valid custom queue size works. + EXPECT_NO_THROW(sender.reset( + new NameChangeUDPSender(ip_address, port, ip_address, port, + FMT_JSON, ncr_handler, 100))); + + EXPECT_EQ(100, sender->getQueueMaxSize()); +} + +/// @brief Tests NameChangeUDPSender basic send functionality +TEST_F(NameChangeUDPSenderBasicTest, basicSendTests) { + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Tests are based on a list of messages, get the count now. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Create the sender, setting the queue max equal to the number of + // messages we will have in the list. + NameChangeUDPSender sender(ip_address, SENDER_PORT, ip_address, + LISTENER_PORT, FMT_JSON, ncr_handler, + num_msgs, true); + + // Verify that we can start sending. + EXPECT_NO_THROW(sender.startSending(io_service)); + EXPECT_TRUE(sender.amSending()); + + // Verify that attempting to send when we already are is an error. + EXPECT_THROW(sender.startSending(io_service), NcrSenderError); + + // Verify that we can stop sending. + EXPECT_NO_THROW(sender.stopSending()); + EXPECT_FALSE(sender.amSending()); + + // Verify that attempting to stop sending when we are not is ok. + EXPECT_NO_THROW(sender.stopSending()); + + // Verify that we can re-enter sending after stopping. + EXPECT_NO_THROW(sender.startSending(io_service)); + EXPECT_TRUE(sender.amSending()); + + // Fetch the sender's select-fd. + int select_fd = sender.getSelectFd(); + + // Verify select_fd is valid and currently shows no ready to read. + ASSERT_NE(util::WatchSocket::SOCKET_NOT_VALID, select_fd); + + // Make sure select_fd does evaluates to not ready via select and + // that ioReady() method agrees. + ASSERT_EQ(0, selectCheck(select_fd)); + ASSERT_FALSE(sender.ioReady()); + + // Iterate over a series of messages, sending each one. Since we + // do not invoke IOService::run, then the messages should accumulate + // in the queue. + NameChangeRequestPtr ncr; + NameChangeRequestPtr ncr2; + for (int i = 0; i < num_msgs; i++) { + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + EXPECT_NO_THROW(sender.sendRequest(ncr)); + // Verify that the queue count increments in step with each send. + EXPECT_EQ(i+1, sender.getQueueSize()); + + // Verify that peekAt(i) returns the NCR we just added. + ASSERT_NO_THROW(ncr2 = sender.peekAt(i)); + ASSERT_TRUE(ncr2); + EXPECT_TRUE(*ncr == *ncr2); + } + + // Verify that attempting to peek beyond the end of the queue, throws. + ASSERT_THROW(sender.peekAt(sender.getQueueSize()+1), NcrSenderError); + + // Verify that attempting to send an additional message results in a + // queue full exception. + EXPECT_THROW(sender.sendRequest(ncr), NcrSenderQueueFull); + + // Loop for the number of valid messages. So long as there is at least + // on NCR in the queue, select-fd indicate ready to read. Invoke + // IOService::run_one. This should complete the send of exactly one + // message and the queue count should decrement accordingly. + for (int i = num_msgs; i > 0; i--) { + // Make sure select_fd does evaluates to ready via select and + // that ioReady() method agrees. + ASSERT_TRUE(selectCheck(select_fd) > 0); + ASSERT_TRUE(sender.ioReady()); + + // Execute at one ready handler. + ASSERT_NO_THROW(sender.runReadyIO()); + + // Verify that the queue count decrements in step with each run. + EXPECT_EQ(i-1, sender.getQueueSize()); + } + + // Make sure select_fd does evaluates to not ready via select and + // that ioReady() method agrees. + ASSERT_EQ(0, selectCheck(select_fd)); + ASSERT_FALSE(sender.ioReady()); + + // Verify that the queue is empty. + EXPECT_EQ(0, sender.getQueueSize()); + + // Verify that we can add back to the queue + EXPECT_NO_THROW(sender.sendRequest(ncr)); + EXPECT_EQ(1, sender.getQueueSize()); + + // Verify that we can remove the current entry at the front of the queue. + EXPECT_NO_THROW(sender.skipNext()); + EXPECT_EQ(0, sender.getQueueSize()); + + // Verify that flushing the queue is not allowed in sending state. + EXPECT_THROW(sender.clearSendQueue(), NcrSenderError); + + // Put num_msgs messages on the queue. + for (int i = 0; i < num_msgs; i++) { + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + EXPECT_NO_THROW(sender.sendRequest(ncr)); + } + + // Make sure we have number of messages expected. + EXPECT_EQ(num_msgs, sender.getQueueSize()); + + // Verify that we can gracefully stop sending. + EXPECT_NO_THROW(sender.stopSending()); + EXPECT_FALSE(sender.amSending()); + + // Verify that the queue is preserved after leaving sending state. + EXPECT_EQ(num_msgs - 1, sender.getQueueSize()); + + // Verify that flushing the queue works when not sending. + EXPECT_NO_THROW(sender.clearSendQueue()); + EXPECT_EQ(0, sender.getQueueSize()); +} + +/// @brief Tests NameChangeUDPSender basic send functionality +TEST_F(NameChangeUDPSenderBasicTest, basicSendTestsMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Tests are based on a list of messages, get the count now. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Create the sender, setting the queue max equal to the number of + // messages we will have in the list. + NameChangeUDPSender sender(ip_address, SENDER_PORT, ip_address, + LISTENER_PORT, FMT_JSON, ncr_handler, + num_msgs, true); + + // Verify that we can start sending. + EXPECT_NO_THROW(sender.startSending(io_service)); + EXPECT_TRUE(sender.amSending()); + + // Verify that attempting to send when we already are is an error. + EXPECT_THROW(sender.startSending(io_service), NcrSenderError); + + // Verify that we can stop sending. + EXPECT_NO_THROW(sender.stopSending()); + EXPECT_FALSE(sender.amSending()); + + // Verify that attempting to stop sending when we are not is ok. + EXPECT_NO_THROW(sender.stopSending()); + + // Verify that we can re-enter sending after stopping. + EXPECT_NO_THROW(sender.startSending(io_service)); + EXPECT_TRUE(sender.amSending()); + + // Fetch the sender's select-fd. + int select_fd = sender.getSelectFd(); + + // Verify select_fd is valid and currently shows no ready to read. + ASSERT_NE(util::WatchSocket::SOCKET_NOT_VALID, select_fd); + + // Make sure select_fd does evaluates to not ready via select and + // that ioReady() method agrees. + ASSERT_EQ(0, selectCheck(select_fd)); + ASSERT_FALSE(sender.ioReady()); + + // Iterate over a series of messages, sending each one. Since we + // do not invoke IOService::run, then the messages should accumulate + // in the queue. + NameChangeRequestPtr ncr; + NameChangeRequestPtr ncr2; + for (int i = 0; i < num_msgs; i++) { + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + EXPECT_NO_THROW(sender.sendRequest(ncr)); + // Verify that the queue count increments in step with each send. + EXPECT_EQ(i+1, sender.getQueueSize()); + + // Verify that peekAt(i) returns the NCR we just added. + ASSERT_NO_THROW(ncr2 = sender.peekAt(i)); + ASSERT_TRUE(ncr2); + EXPECT_TRUE(*ncr == *ncr2); + } + + // Verify that attempting to peek beyond the end of the queue, throws. + ASSERT_THROW(sender.peekAt(sender.getQueueSize()+1), NcrSenderError); + + // Verify that attempting to send an additional message results in a + // queue full exception. + EXPECT_THROW(sender.sendRequest(ncr), NcrSenderQueueFull); + + // Loop for the number of valid messages. So long as there is at least + // on NCR in the queue, select-fd indicate ready to read. Invoke + // IOService::run_one. This should complete the send of exactly one + // message and the queue count should decrement accordingly. + for (int i = num_msgs; i > 0; i--) { + // Make sure select_fd does evaluates to ready via select and + // that ioReady() method agrees. + ASSERT_TRUE(selectCheck(select_fd) > 0); + ASSERT_TRUE(sender.ioReady()); + + // Execute at one ready handler. + ASSERT_NO_THROW(sender.runReadyIO()); + + // Verify that the queue count decrements in step with each run. + EXPECT_EQ(i-1, sender.getQueueSize()); + } + + // Make sure select_fd does evaluates to not ready via select and + // that ioReady() method agrees. + ASSERT_EQ(0, selectCheck(select_fd)); + ASSERT_FALSE(sender.ioReady()); + + // Verify that the queue is empty. + EXPECT_EQ(0, sender.getQueueSize()); + + // Verify that we can add back to the queue + EXPECT_NO_THROW(sender.sendRequest(ncr)); + EXPECT_EQ(1, sender.getQueueSize()); + + // Verify that we can remove the current entry at the front of the queue. + EXPECT_NO_THROW(sender.skipNext()); + EXPECT_EQ(0, sender.getQueueSize()); + + // Verify that flushing the queue is not allowed in sending state. + EXPECT_THROW(sender.clearSendQueue(), NcrSenderError); + + // Put num_msgs messages on the queue. + for (int i = 0; i < num_msgs; i++) { + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + EXPECT_NO_THROW(sender.sendRequest(ncr)); + } + + // Make sure we have number of messages expected. + EXPECT_EQ(num_msgs, sender.getQueueSize()); + + // Verify that we can gracefully stop sending. + EXPECT_NO_THROW(sender.stopSending()); + EXPECT_FALSE(sender.amSending()); + + // Verify that the queue is preserved after leaving sending state. + EXPECT_EQ(num_msgs - 1, sender.getQueueSize()); + + // Verify that flushing the queue works when not sending. + EXPECT_NO_THROW(sender.clearSendQueue()); + EXPECT_EQ(0, sender.getQueueSize()); +} + +/// @brief Tests that sending gets kick-started if the queue isn't empty +/// when startSending is called. +TEST_F(NameChangeUDPSenderBasicTest, autoStart) { + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Tests are based on a list of messages, get the count now. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Create the sender, setting the queue max equal to the number of + // messages we will have in the list. + NameChangeUDPSender sender(ip_address, SENDER_PORT, ip_address, + LISTENER_PORT, FMT_JSON, ncr_handler, + num_msgs, true); + + // Verify that we can start sending. + EXPECT_NO_THROW(sender.startSending(io_service)); + EXPECT_TRUE(sender.amSending()); + + // Queue up messages. + NameChangeRequestPtr ncr; + for (int i = 0; i < num_msgs; i++) { + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + EXPECT_NO_THROW(sender.sendRequest(ncr)); + } + // Make sure queue count is what we expect. + EXPECT_EQ(num_msgs, sender.getQueueSize()); + + // Stop sending. + ASSERT_NO_THROW(sender.stopSending()); + ASSERT_FALSE(sender.amSending()); + + // We should have completed the first message only. + EXPECT_EQ(--num_msgs, sender.getQueueSize()); + + // Restart sending. + EXPECT_NO_THROW(sender.startSending(io_service)); + + // We should be able to loop through remaining messages and send them. + for (int i = num_msgs; i > 0; i--) { + // ioReady() should evaluate to true. + ASSERT_TRUE(sender.ioReady()); + + // Execute at one ready handler. + ASSERT_NO_THROW(sender.runReadyIO()); + } + + // Verify that the queue is empty. + EXPECT_EQ(0, sender.getQueueSize()); +} + +/// @brief Tests that sending gets kick-started if the queue isn't empty +/// when startSending is called. +TEST_F(NameChangeUDPSenderBasicTest, autoStartMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Tests are based on a list of messages, get the count now. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Create the sender, setting the queue max equal to the number of + // messages we will have in the list. + NameChangeUDPSender sender(ip_address, SENDER_PORT, ip_address, + LISTENER_PORT, FMT_JSON, ncr_handler, + num_msgs, true); + + // Verify that we can start sending. + EXPECT_NO_THROW(sender.startSending(io_service)); + EXPECT_TRUE(sender.amSending()); + + // Queue up messages. + NameChangeRequestPtr ncr; + for (int i = 0; i < num_msgs; i++) { + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + EXPECT_NO_THROW(sender.sendRequest(ncr)); + } + // Make sure queue count is what we expect. + EXPECT_EQ(num_msgs, sender.getQueueSize()); + + // Stop sending. + ASSERT_NO_THROW(sender.stopSending()); + ASSERT_FALSE(sender.amSending()); + + // We should have completed the first message only. + EXPECT_EQ(--num_msgs, sender.getQueueSize()); + + // Restart sending. + EXPECT_NO_THROW(sender.startSending(io_service)); + + // We should be able to loop through remaining messages and send them. + for (int i = num_msgs; i > 0; i--) { + // ioReady() should evaluate to true. + ASSERT_TRUE(sender.ioReady()); + + // Execute at one ready handler. + ASSERT_NO_THROW(sender.runReadyIO()); + } + + // Verify that the queue is empty. + EXPECT_EQ(0, sender.getQueueSize()); +} + +/// @brief Tests NameChangeUDPSender basic send with INADDR_ANY and port 0. +TEST_F(NameChangeUDPSenderBasicTest, anyAddressSend) { + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOAddress any_address("0.0.0.0"); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Tests are based on a list of messages, get the count now. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Create the sender, setting the queue max equal to the number of + // messages we will have in the list. + NameChangeUDPSender sender(any_address, 0, ip_address, LISTENER_PORT, + FMT_JSON, ncr_handler, num_msgs); + + // Enter send mode. + ASSERT_NO_THROW(sender.startSending(io_service)); + EXPECT_TRUE(sender.amSending()); + + // Create and queue up a message. + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[0])); + EXPECT_NO_THROW(sender.sendRequest(ncr)); + EXPECT_EQ(1, sender.getQueueSize()); + + // Verify we have a ready IO, then execute at one ready handler. + ASSERT_TRUE(sender.ioReady()); + ASSERT_NO_THROW(sender.runReadyIO()); + + // Verify that sender shows no IO ready. + // and that the queue is empty. + ASSERT_FALSE(sender.ioReady()); + EXPECT_EQ(0, sender.getQueueSize()); +} + +/// @brief Tests NameChangeUDPSender basic send with INADDR_ANY and port 0. +TEST_F(NameChangeUDPSenderBasicTest, anyAddressSendMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOAddress any_address("0.0.0.0"); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Tests are based on a list of messages, get the count now. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Create the sender, setting the queue max equal to the number of + // messages we will have in the list. + NameChangeUDPSender sender(any_address, 0, ip_address, LISTENER_PORT, + FMT_JSON, ncr_handler, num_msgs); + + // Enter send mode. + ASSERT_NO_THROW(sender.startSending(io_service)); + EXPECT_TRUE(sender.amSending()); + + // Create and queue up a message. + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[0])); + EXPECT_NO_THROW(sender.sendRequest(ncr)); + EXPECT_EQ(1, sender.getQueueSize()); + + // Verify we have a ready IO, then execute at one ready handler. + ASSERT_TRUE(sender.ioReady()); + ASSERT_NO_THROW(sender.runReadyIO()); + + // Verify that sender shows no IO ready. + // and that the queue is empty. + ASSERT_FALSE(sender.ioReady()); + EXPECT_EQ(0, sender.getQueueSize()); +} + +/// @brief Test the NameChangeSender::assumeQueue method. +TEST_F(NameChangeUDPSenderBasicTest, assumeQueue) { + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + uint32_t port = SENDER_PORT; + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + NameChangeRequestPtr ncr; + + // Tests are based on a list of messages, get the count now. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Create two senders with queue max equal to the number of + // messages we will have in the list. + NameChangeUDPSender sender1(ip_address, port, ip_address, port, + FMT_JSON, ncr_handler, num_msgs); + + NameChangeUDPSender sender2(ip_address, port+1, ip_address, port, + FMT_JSON, ncr_handler, num_msgs); + + // Place sender1 into send mode and queue up messages. + ASSERT_NO_THROW(sender1.startSending(io_service)); + for (int i = 0; i < num_msgs; i++) { + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + ASSERT_NO_THROW(sender1.sendRequest(ncr)); + } + + // Make sure sender1's queue count is as expected. + ASSERT_EQ(num_msgs, sender1.getQueueSize()); + + // Verify sender1 is sending, sender2 is not. + ASSERT_TRUE(sender1.amSending()); + ASSERT_FALSE(sender2.amSending()); + + // Transfer from sender1 to sender2 should fail because + // sender1 is in send mode. + ASSERT_THROW(sender2.assumeQueue(sender1), NcrSenderError); + + // Take sender1 out of send mode. + ASSERT_NO_THROW(sender1.stopSending()); + ASSERT_FALSE(sender1.amSending()); + // Stopping should have completed the first message. + --num_msgs; + EXPECT_EQ(num_msgs, sender1.getQueueSize()); + + // Transfer should succeed. Verify sender1 has none, + // and sender2 has num_msgs queued. + EXPECT_NO_THROW(sender2.assumeQueue(sender1)); + EXPECT_EQ(0, sender1.getQueueSize()); + EXPECT_EQ(num_msgs, sender2.getQueueSize()); + + // Reduce sender1's max queue size. + ASSERT_NO_THROW(sender1.setQueueMaxSize(num_msgs - 1)); + + // Transfer should fail as sender1's queue is not large enough. + ASSERT_THROW(sender1.assumeQueue(sender2), NcrSenderError); + + // Place sender1 into send mode and queue up a message. + ASSERT_NO_THROW(sender1.startSending(io_service)); + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[0])); + ASSERT_NO_THROW(sender1.sendRequest(ncr)); + + // Take sender1 out of send mode. + ASSERT_NO_THROW(sender1.stopSending()); + + // Try to transfer from sender1 to sender2. This should fail + // as sender2's queue is not empty. + ASSERT_THROW(sender2.assumeQueue(sender1), NcrSenderError); +} + +/// @brief Test the NameChangeSender::assumeQueue method. +TEST_F(NameChangeUDPSenderBasicTest, assumeQueueMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + uint32_t port = SENDER_PORT; + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + NameChangeRequestPtr ncr; + + // Tests are based on a list of messages, get the count now. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Create two senders with queue max equal to the number of + // messages we will have in the list. + NameChangeUDPSender sender1(ip_address, port, ip_address, port, + FMT_JSON, ncr_handler, num_msgs); + + NameChangeUDPSender sender2(ip_address, port+1, ip_address, port, + FMT_JSON, ncr_handler, num_msgs); + + // Place sender1 into send mode and queue up messages. + ASSERT_NO_THROW(sender1.startSending(io_service)); + for (int i = 0; i < num_msgs; i++) { + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + ASSERT_NO_THROW(sender1.sendRequest(ncr)); + } + + // Make sure sender1's queue count is as expected. + ASSERT_EQ(num_msgs, sender1.getQueueSize()); + + // Verify sender1 is sending, sender2 is not. + ASSERT_TRUE(sender1.amSending()); + ASSERT_FALSE(sender2.amSending()); + + // Transfer from sender1 to sender2 should fail because + // sender1 is in send mode. + ASSERT_THROW(sender2.assumeQueue(sender1), NcrSenderError); + + // Take sender1 out of send mode. + ASSERT_NO_THROW(sender1.stopSending()); + ASSERT_FALSE(sender1.amSending()); + // Stopping should have completed the first message. + --num_msgs; + EXPECT_EQ(num_msgs, sender1.getQueueSize()); + + // Transfer should succeed. Verify sender1 has none, + // and sender2 has num_msgs queued. + EXPECT_NO_THROW(sender2.assumeQueue(sender1)); + EXPECT_EQ(0, sender1.getQueueSize()); + EXPECT_EQ(num_msgs, sender2.getQueueSize()); + + // Reduce sender1's max queue size. + ASSERT_NO_THROW(sender1.setQueueMaxSize(num_msgs - 1)); + + // Transfer should fail as sender1's queue is not large enough. + ASSERT_THROW(sender1.assumeQueue(sender2), NcrSenderError); + + // Place sender1 into send mode and queue up a message. + ASSERT_NO_THROW(sender1.startSending(io_service)); + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[0])); + ASSERT_NO_THROW(sender1.sendRequest(ncr)); + + // Take sender1 out of send mode. + ASSERT_NO_THROW(sender1.stopSending()); + + // Try to transfer from sender1 to sender2. This should fail + // as sender2's queue is not empty. + ASSERT_THROW(sender2.assumeQueue(sender1), NcrSenderError); +} + +/// @brief Text fixture that allows testing a listener and sender together +/// It derives from both the receive and send handler classes and contains +/// and instance of UDP listener and UDP sender. +class NameChangeUDPTest : public virtual ::testing::Test, + NameChangeListener::RequestReceiveHandler, + NameChangeSender::RequestSendHandler { +public: + isc::asiolink::IOService io_service_; + NameChangeListener::Result recv_result_; + NameChangeSender::Result send_result_; + NameChangeListenerPtr listener_; + NameChangeSenderPtr sender_; + isc::asiolink::IntervalTimer test_timer_; + + std::vector<NameChangeRequestPtr> sent_ncrs_; + std::vector<NameChangeRequestPtr> received_ncrs_; + + NameChangeUDPTest() + : io_service_(), recv_result_(NameChangeListener::SUCCESS), + send_result_(NameChangeSender::SUCCESS), test_timer_(io_service_) { + isc::asiolink::IOAddress addr(TEST_ADDRESS); + // Create our listener instance. Note that reuse_address is true. + listener_.reset( + new NameChangeUDPListener(addr, LISTENER_PORT, FMT_JSON, + *this, true)); + + // Create our sender instance. Note that reuse_address is true. + sender_.reset( + new NameChangeUDPSender(addr, SENDER_PORT, addr, LISTENER_PORT, + FMT_JSON, *this, 100, true)); + + // Set the test timeout to break any running tasks if they hang. + test_timer_.setup(std::bind(&NameChangeUDPTest::testTimeoutHandler, + this), + TEST_TIMEOUT); + // Disable multi-threading + MultiThreadingMgr::instance().setMode(false); + } + + ~NameChangeUDPTest() { + // Disable multi-threading + MultiThreadingMgr::instance().setMode(false); + } + + void reset_results() { + sent_ncrs_.clear(); + received_ncrs_.clear(); + } + + /// @brief Implements the receive completion handler. + virtual void operator ()(const NameChangeListener::Result result, + NameChangeRequestPtr& ncr) { + // save the result and the NCR received. + recv_result_ = result; + received_ncrs_.push_back(ncr); + } + + /// @brief Implements the send completion handler. + virtual void operator ()(const NameChangeSender::Result result, + NameChangeRequestPtr& ncr) { + // save the result and the NCR sent. + send_result_ = result; + sent_ncrs_.push_back(ncr); + } + + /// @brief Handler invoked when test timeout is hit + /// + /// This callback stops all running (hanging) tasks on IO service. + void testTimeoutHandler() { + io_service_.stop(); + FAIL() << "Test timeout hit."; + } + + /// @brief checks the received NCR content, ignoring the order if necessary. + /// + /// The UDP does not provide any guarantees regarding order. While in most cases + /// the NCRs are received in the order they're sent, that's not guaranteed. As such, + /// the test does the normal ordered check, which will pass in most cases. However, + /// we have documented Jenkins history that it sometimes fail. In those cases, we + /// need to go through a full check assuming the packets were received not in order. + /// If that fails, the test will print detailed information about the failure. + /// + /// This function returns a status, but it's not really necessary to check it as + /// it calls gtest macros to indicate failures. + /// + /// @param num_msgs number of received and sent messages + /// @param sent vector of sent NCRs + /// @param rcvd vector of received NCRs + /// @return true if all packets were received, false otherwise + bool checkUnordered(size_t num_msgs, const std::vector<NameChangeRequestPtr>& sent, + const std::vector<NameChangeRequestPtr>& rcvd) { + // Verify that what we sent matches what we received. + // WRONG ASSUMPTION HERE: UDP does not guarantee ordered delivery. + bool ok = true; + for (int i = 0; i < num_msgs; i++) { + if (!checkSendVsReceived(sent[i], rcvd[i])) { + // Ok, the data was not received in order. + ok = false; + break; + } + } + if (!ok) { + std::cout << "UDP data received not in order! Checking un ordered delivery" + << std::endl; + // We need to double iterate through the messages to check every one + // against one another. + for (int i = 0; i < num_msgs; i++) { + ok = false; + for (int j = 0; j < num_msgs; j++) { + if (checkSendVsReceived(sent[i], rcvd[j])) { + std::cout << "Found UDP packet " << i << ", received as " << j << "th" + << std::endl; + ok = true; + } + } + EXPECT_TRUE(ok) << "failed to find UDP packet " << i << " among total of " + << num_msgs << " messages received"; + } + } + return (ok); + } +}; + +/// @brief Uses a sender and listener to test UDP-based NCR delivery +/// Conducts a "round-trip" test using a sender to transmit a set of valid +/// NCRs to a listener. The test verifies that what was sent matches what +/// was received both in quantity and in content. +TEST_F(NameChangeUDPTest, roundTripTest) { + // Place the listener into listening state. + ASSERT_NO_THROW(listener_->startListening(io_service_)); + EXPECT_TRUE(listener_->amListening()); + + // Get the number of messages in the list of test messages. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Place the sender into sending state. + ASSERT_NO_THROW(sender_->startSending(io_service_)); + EXPECT_TRUE(sender_->amSending()); + + for (int i = 0; i < num_msgs; i++) { + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + sender_->sendRequest(ncr); + EXPECT_EQ(i+1, sender_->getQueueSize()); + } + + // Execute callbacks until we have sent and received all of messages. + while (sender_->getQueueSize() > 0 || (received_ncrs_.size() < num_msgs)) { + EXPECT_NO_THROW(io_service_.run_one()); + } + + // Send queue should be empty. + EXPECT_EQ(0, sender_->getQueueSize()); + + // We should have the same number of sends and receives as we do messages. + ASSERT_EQ(num_msgs, sent_ncrs_.size()); + ASSERT_EQ(num_msgs, received_ncrs_.size()); + + // Check if the payload was received, ignoring the order if necessary. + checkUnordered(num_msgs, sent_ncrs_, received_ncrs_); + + // Verify that we can gracefully stop listening. + EXPECT_NO_THROW(listener_->stopListening()); + EXPECT_FALSE(listener_->amListening()); + + // Verify that IO pending is false, after cancel event occurs. + EXPECT_NO_THROW(io_service_.run_one()); + EXPECT_FALSE(listener_->isIoPending()); + + // Verify that we can gracefully stop sending. + EXPECT_NO_THROW(sender_->stopSending()); + EXPECT_FALSE(sender_->amSending()); +} + +/// @brief Uses a sender and listener to test UDP-based NCR delivery +/// Conducts a "round-trip" test using a sender to transmit a set of valid +/// NCRs to a listener. The test verifies that what was sent matches what +/// was received both in quantity and in content. +TEST_F(NameChangeUDPTest, roundTripTestMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + // Place the listener into listening state. + ASSERT_NO_THROW(listener_->startListening(io_service_)); + EXPECT_TRUE(listener_->amListening()); + + // Get the number of messages in the list of test messages. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + + // Place the sender into sending state. + ASSERT_NO_THROW(sender_->startSending(io_service_)); + EXPECT_TRUE(sender_->amSending()); + + for (int i = 0; i < num_msgs; i++) { + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + sender_->sendRequest(ncr); + EXPECT_EQ(i+1, sender_->getQueueSize()); + } + + // Execute callbacks until we have sent and received all of messages. + while (sender_->getQueueSize() > 0 || (received_ncrs_.size() < num_msgs)) { + EXPECT_NO_THROW(io_service_.run_one()); + } + + // Send queue should be empty. + EXPECT_EQ(0, sender_->getQueueSize()); + + // We should have the same number of sends and receives as we do messages. + ASSERT_EQ(num_msgs, sent_ncrs_.size()); + ASSERT_EQ(num_msgs, received_ncrs_.size()); + + // Verify that what we sent matches what we received. Ignore the order + // if necessary. + checkUnordered(num_msgs, sent_ncrs_, received_ncrs_); + + // Verify that we can gracefully stop listening. + EXPECT_NO_THROW(listener_->stopListening()); + EXPECT_FALSE(listener_->amListening()); + + // Verify that IO pending is false, after cancel event occurs. + EXPECT_NO_THROW(io_service_.run_one()); + EXPECT_FALSE(listener_->isIoPending()); + + // Verify that we can gracefully stop sending. + EXPECT_NO_THROW(sender_->stopSending()); + EXPECT_FALSE(sender_->amSending()); +} + +// Tests error handling of a failure to mark the watch socket ready, when +// sendRequest() is called. +TEST_F(NameChangeUDPSenderBasicTest, watchClosedBeforeSendRequest) { + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Create the sender and put into send mode. + NameChangeUDPSender sender(ip_address, 0, ip_address, LISTENER_PORT, + FMT_JSON, ncr_handler, 100, true); + ASSERT_NO_THROW(sender.startSending(io_service)); + ASSERT_TRUE(sender.amSending()); + + // Create an NCR. + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[0])); + + // Tamper with the watch socket by closing the select-fd. + close(sender.getSelectFd()); + + // Send should fail as we interfered by closing the select-fd. + ASSERT_THROW(sender.sendRequest(ncr), util::WatchSocketError); + + // Verify we didn't invoke the handler. + EXPECT_EQ(0, ncr_handler.pass_count_); + EXPECT_EQ(0, ncr_handler.error_count_); + + // Request remains in the queue. Technically it was sent but its + // completion handler won't get called. + EXPECT_EQ(1, sender.getQueueSize()); +} + +// Tests error handling of a failure to mark the watch socket ready, when +// sendRequest() is called. +TEST_F(NameChangeUDPSenderBasicTest, watchClosedBeforeSendRequestMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Create the sender and put into send mode. + NameChangeUDPSender sender(ip_address, 0, ip_address, LISTENER_PORT, + FMT_JSON, ncr_handler, 100, true); + ASSERT_NO_THROW(sender.startSending(io_service)); + ASSERT_TRUE(sender.amSending()); + + // Create an NCR. + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[0])); + + // Tamper with the watch socket by closing the select-fd. + close(sender.getSelectFd()); + + // Send should fail as we interfered by closing the select-fd. + ASSERT_THROW(sender.sendRequest(ncr), util::WatchSocketError); + + // Verify we didn't invoke the handler. + EXPECT_EQ(0, ncr_handler.pass_count_); + EXPECT_EQ(0, ncr_handler.error_count_); + + // Request remains in the queue. Technically it was sent but its + // completion handler won't get called. + EXPECT_EQ(1, sender.getQueueSize()); +} + +// Tests error handling of a failure to mark the watch socket ready, when +// sendNext() is called during completion handling. +TEST_F(NameChangeUDPSenderBasicTest, watchClosedAfterSendRequest) { + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Create the sender and put into send mode. + NameChangeUDPSender sender(ip_address, 0, ip_address, LISTENER_PORT, + FMT_JSON, ncr_handler, 100, true); + ASSERT_NO_THROW(sender.startSending(io_service)); + ASSERT_TRUE(sender.amSending()); + + // Build and queue up 2 messages. No handlers will get called yet. + for (int i = 0; i < 2; i++) { + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + sender.sendRequest(ncr); + EXPECT_EQ(i+1, sender.getQueueSize()); + } + + // Tamper with the watch socket by closing the select-fd. + close (sender.getSelectFd()); + + // Run one handler. This should execute the send completion handler + // after sending the first message. Doing completion handling, we will + // attempt to queue the second message which should fail. + ASSERT_NO_THROW(sender.runReadyIO()); + + // Verify handler got called twice. First request should have be sent + // without error, second call should have failed to send due to watch + // socket markReady failure. + EXPECT_EQ(1, ncr_handler.pass_count_); + EXPECT_EQ(1, ncr_handler.error_count_); + + // The second request should still be in the queue. + EXPECT_EQ(1, sender.getQueueSize()); +} + +// Tests error handling of a failure to mark the watch socket ready, when +// sendNext() is called during completion handling. +TEST_F(NameChangeUDPSenderBasicTest, watchClosedAfterSendRequestMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Create the sender and put into send mode. + NameChangeUDPSender sender(ip_address, 0, ip_address, LISTENER_PORT, + FMT_JSON, ncr_handler, 100, true); + ASSERT_NO_THROW(sender.startSending(io_service)); + ASSERT_TRUE(sender.amSending()); + + // Build and queue up 2 messages. No handlers will get called yet. + for (int i = 0; i < 2; i++) { + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + sender.sendRequest(ncr); + EXPECT_EQ(i+1, sender.getQueueSize()); + } + + // Tamper with the watch socket by closing the select-fd. + close (sender.getSelectFd()); + + // Run one handler. This should execute the send completion handler + // after sending the first message. Doing completion handling, we will + // attempt to queue the second message which should fail. + ASSERT_NO_THROW(sender.runReadyIO()); + + // Verify handler got called twice. First request should have be sent + // without error, second call should have failed to send due to watch + // socket markReady failure. + EXPECT_EQ(1, ncr_handler.pass_count_); + EXPECT_EQ(1, ncr_handler.error_count_); + + // The second request should still be in the queue. + EXPECT_EQ(1, sender.getQueueSize()); +} + + +// Tests error handling of a failure to clear the watch socket during +// completion handling. +TEST_F(NameChangeUDPSenderBasicTest, watchSocketBadRead) { + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Create the sender and put into send mode. + NameChangeUDPSender sender(ip_address, 0, ip_address, LISTENER_PORT, + FMT_JSON, ncr_handler, 100, true); + ASSERT_NO_THROW(sender.startSending(io_service)); + ASSERT_TRUE(sender.amSending()); + + // Build and queue up 2 messages. No handlers will get called yet. + for (int i = 0; i < 2; i++) { + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + sender.sendRequest(ncr); + EXPECT_EQ(i+1, sender.getQueueSize()); + } + + // Fetch the sender's select-fd. + int select_fd = sender.getSelectFd(); + + // Verify that select_fd appears ready. + ASSERT_TRUE(selectCheck(select_fd) > 0); + + // Interfere by reading part of the marker from the select-fd. + uint32_t buf = 0; + ASSERT_EQ((read (select_fd, &buf, 1)), 1); + ASSERT_NE(util::WatchSocket::MARKER, buf); + + // Run one handler. This should execute the send completion handler + // after sending the message. Doing completion handling clearing the + // watch socket should fail, which will close the socket, but not + // result in a throw. + ASSERT_NO_THROW(sender.runReadyIO()); + + // Verify handler got called twice. First request should have be sent + // without error, second call should have failed to send due to watch + // socket markReady failure. + EXPECT_EQ(1, ncr_handler.pass_count_); + EXPECT_EQ(1, ncr_handler.error_count_); + + // The second request should still be in the queue. + EXPECT_EQ(1, sender.getQueueSize()); +} + +// Tests error handling of a failure to clear the watch socket during +// completion handling. +TEST_F(NameChangeUDPSenderBasicTest, watchSocketBadReadMultiThreading) { + // Enable multi-threading + MultiThreadingMgr::instance().setMode(true); + + isc::asiolink::IOAddress ip_address(TEST_ADDRESS); + isc::asiolink::IOService io_service; + SimpleSendHandler ncr_handler; + + // Create the sender and put into send mode. + NameChangeUDPSender sender(ip_address, 0, ip_address, LISTENER_PORT, + FMT_JSON, ncr_handler, 100, true); + ASSERT_NO_THROW(sender.startSending(io_service)); + ASSERT_TRUE(sender.amSending()); + + // Build and queue up 2 messages. No handlers will get called yet. + for (int i = 0; i < 2; i++) { + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(valid_msgs[i])); + sender.sendRequest(ncr); + EXPECT_EQ(i+1, sender.getQueueSize()); + } + + // Fetch the sender's select-fd. + int select_fd = sender.getSelectFd(); + + // Verify that select_fd appears ready. + ASSERT_TRUE(selectCheck(select_fd) > 0); + + // Interfere by reading part of the marker from the select-fd. + uint32_t buf = 0; + ASSERT_EQ((read (select_fd, &buf, 1)), 1); + ASSERT_NE(util::WatchSocket::MARKER, buf); + + // Run one handler. This should execute the send completion handler + // after sending the message. Doing completion handling clearing the + // watch socket should fail, which will close the socket, but not + // result in a throw. + ASSERT_NO_THROW(sender.runReadyIO()); + + // Verify handler got called twice. First request should have be sent + // without error, second call should have failed to send due to watch + // socket markReady failure. + EXPECT_EQ(1, ncr_handler.pass_count_); + EXPECT_EQ(1, ncr_handler.error_count_); + + // The second request should still be in the queue. + EXPECT_EQ(1, sender.getQueueSize()); +} + +} // end of anonymous namespace diff --git a/src/lib/dhcp_ddns/tests/ncr_unittests.cc b/src/lib/dhcp_ddns/tests/ncr_unittests.cc new file mode 100644 index 0000000..b17d72b --- /dev/null +++ b/src/lib/dhcp_ddns/tests/ncr_unittests.cc @@ -0,0 +1,743 @@ +// Copyright (C) 2013-2023 Internet Systems Consortium, Inc. ("ISC") +// +// 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 http://mozilla.org/MPL/2.0/. + +#include <config.h> + +#include <dhcp_ddns/ncr_io.h> +#include <dhcp/duid.h> +#include <dhcp/hwaddr.h> +#include <util/time_utilities.h> + +#include <testutils/gtest_utils.h> +#include <gtest/gtest.h> +#include <algorithm> + +using namespace std; +using namespace isc; +using namespace isc::dhcp_ddns; +using namespace isc::dhcp; + +namespace { + +/// @brief Defines a list of valid JSON NameChangeRequest renditions. +/// They are used as input to test conversion from JSON. +const char *valid_msgs[] = +{ + // Valid Add. + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Valid Remove. + "{" + " \"change-type\" : 1 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Valid Add with IPv6 address + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"fe80::2acf:e9ff:fe12:e56f\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Missing use-conflict-resolution + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300 " + "}" +}; + +/// @brief Defines a list of invalid JSON NameChangeRequest renditions. +/// They are used as input to test conversion from JSON. +const char *invalid_msgs[] = +{ + // Invalid change type. + "{" + " \"change-type\" : 7 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Invalid forward change. + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : \"bogus\" , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Invalid reverse change. + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : 500 , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Forward and reverse change both false. + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : false , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Blank FQDN + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Malformed FQDN + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \".bad_name\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Bad IP address + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"xxxxxx\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300 " + " \"use-conflict-resolution\": true" + "}", + // Blank DHCID + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Odd number of digits in DHCID + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Text in DHCID + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"THIS IS BOGUS!!!\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Invalid lease expiration string + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"Wed Jun 26 13:46:46 EDT 2013\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": true" + "}", + // Non-integer for lease length. + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : \"BOGUS\", " + " \"use-conflict-resolution\": true" + "}", + // Invalid use-conflict-resolution + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300, " + " \"use-conflict-resolution\": 777" + "}" +}; + +/// @brief Tests the NameChangeRequest constructors. +/// This test verifies that: +/// 1. Default constructor works. +/// 2. "Full" constructor, when given valid parameter values, works. +/// 3. "Full" constructor, given a blank FQDN fails +/// 4. "Full" constructor, given an invalid IP Address FQDN fails +/// 5. "Full" constructor, given a blank DHCID fails +/// 6. "Full" constructor, given false for both forward and reverse fails +TEST(NameChangeRequestTest, constructionTests) { + // Verify the default constructor works. + NameChangeRequestPtr ncr; + EXPECT_NO_THROW(ncr.reset(new NameChangeRequest())); + EXPECT_TRUE(ncr); + + // Verify that full constructor works. + uint64_t expiry = isc::util::detail::gettimeWrapper(); + D2Dhcid dhcid("010203040A7F8E3D"); + + EXPECT_NO_THROW(ncr.reset(new NameChangeRequest( + CHG_ADD, true, true, "walah.walah.com", + "192.168.1.101", dhcid, expiry, 1300))); + EXPECT_TRUE(ncr); + ncr.reset(); + + // Verify blank FQDN is detected. + EXPECT_THROW(NameChangeRequest(CHG_ADD, true, true, "", + "192.168.1.101", dhcid, expiry, 1300), NcrMessageError); + + // Verify that an invalid IP address is detected. + EXPECT_THROW(NameChangeRequest(CHG_ADD, true, true, "valid.fqdn", + "xxx.168.1.101", dhcid, expiry, 1300), NcrMessageError); + + // Verify that a blank DHCID is detected. + D2Dhcid blank_dhcid; + EXPECT_THROW(NameChangeRequest(CHG_ADD, true, true, "walah.walah.com", + "192.168.1.101", blank_dhcid, expiry, 1300), NcrMessageError); + + // Verify that one or both of direction flags must be true. + EXPECT_THROW(NameChangeRequest(CHG_ADD, false, false, "valid.fqdn", + "192.168.1.101", dhcid, expiry, 1300), NcrMessageError); + +} + +/// @brief Tests the basic workings of D2Dhcid to and from string conversions. +/// It verifies that: +/// 1. DHCID input strings must contain an even number of characters +/// 2. DHCID input strings must contain only hexadecimal character digits +/// 3. A valid DHCID string converts correctly. +/// 4. Converting a D2Dhcid to a string works correctly. +/// 5. Equality, inequality, and less-than-equal operators work. +TEST(NameChangeRequestTest, dhcidTest) { + D2Dhcid dhcid; + + // Odd number of digits should be rejected. + std::string test_str = "010203040A7F8E3"; + EXPECT_THROW(dhcid.fromStr(test_str), NcrMessageError); + + // Non digit content should be rejected. + test_str = "0102BOGUSA7F8E3D"; + EXPECT_THROW(dhcid.fromStr(test_str), NcrMessageError); + + // Verify that valid input converts into a proper byte array. + test_str = "010203040A7F8E3D"; + ASSERT_NO_THROW(dhcid.fromStr(test_str)); + + // Create a test vector of expected byte contents. + const uint8_t bytes[] = { 0x1, 0x2, 0x3, 0x4, 0xA, 0x7F, 0x8E, 0x3D }; + std::vector<uint8_t> expected_bytes(bytes, bytes + sizeof(bytes)); + + // Fetch the byte vector from the dhcid and verify if equals the expected + // content. + const std::vector<uint8_t>& converted_bytes = dhcid.getBytes(); + EXPECT_EQ(expected_bytes.size(), converted_bytes.size()); + EXPECT_TRUE (std::equal(expected_bytes.begin(), + expected_bytes.begin()+expected_bytes.size(), + converted_bytes.begin())); + + // Convert the new dhcid back to string and verify it matches the original + // DHCID input string. + std::string next_str = dhcid.toStr(); + EXPECT_EQ(test_str, next_str); + + // Test equality, inequality, and less-than-equal operators + test_str="AABBCCDD"; + EXPECT_NO_THROW(dhcid.fromStr(test_str)); + + D2Dhcid other_dhcid; + EXPECT_NO_THROW(other_dhcid.fromStr(test_str)); + + EXPECT_TRUE(dhcid == other_dhcid); + EXPECT_FALSE(dhcid != other_dhcid); + + EXPECT_NO_THROW(other_dhcid.fromStr("BBCCDDEE")); + EXPECT_TRUE(dhcid < other_dhcid); + +} + +/// @brief Test fixture class for testing DHCID creation. +class DhcidTest : public ::testing::Test { +public: + /// @brief Constructor + DhcidTest() { + // 0x000000066d79686f7374076578616d706c6503636f6d00 + const uint8_t fqdn_data[] = { + 6, 109, 121, 104, 111, 115, 116, // myhost. + 7, 101, 120, 97, 109, 112, 108, 101, // example. + 3, 99, 111, 109, 0 // com. + }; + wire_fqdn_.assign(fqdn_data, fqdn_data + sizeof(fqdn_data)); + } + + /// @brief Destructor + virtual ~DhcidTest() { + } + + std::vector<uint8_t> wire_fqdn_; +}; + +/// Tests that DHCID is correctly created from a DUID and FQDN. The final format +/// of the DHCID is as follows: +/// <identifier-type> <digest-type-code> <digest> +/// where: +/// - identifier-type (2 octets) is 0x0002. +/// - digest-type-code (1 octet) indicates SHA-256 hashing and is equal 0x1. +/// - digest = SHA-256(<DUID> <FQDN>) +/// Note: FQDN is given in the on-wire canonical format. +TEST_F(DhcidTest, fromDUID) { + D2Dhcid dhcid; + + // Create DUID. + uint8_t duid_data[] = { 0, 1, 2, 3, 4, 5, 6 }; + DUID duid(duid_data, sizeof(duid_data)); + + // Create DHCID. + ASSERT_NO_THROW(dhcid.fromDUID(duid, wire_fqdn_)); + + // The reference DHCID (represented as string of hexadecimal digits) + // has been calculated using one of the online calculators. + std::string dhcid_ref = "0002012191B7B21AF97E0E656DF887C5E2D" + "EF30E7758A207EDF4CCB2DE8CA37066021C"; + + // Make sure that the DHCID is valid. + EXPECT_EQ(dhcid_ref, dhcid.toStr()); +} + +// Test that DHCID is correctly created when the DUID has minimal length (1). +TEST_F(DhcidTest, fromMinDUID) { + D2Dhcid dhcid; + + // Create DUID. + std::vector<uint8_t> duid_data(DUID::MIN_DUID_LEN, 1); + DUID duid(duid_data.data(), duid_data.size()); + + // Create DHCID. + ASSERT_NO_THROW(dhcid.fromDUID(duid, wire_fqdn_)); + + // The reference DHCID (represented as string of hexadecimal digits) + // has been calculated using one of the online calculators. + std::string dhcid_ref = "000201202F813E7D9C88BADA41250F2A662" + "97742BB9B3EB37C0981D4A905745A30BDD3"; + + // Make sure that the DHCID is valid. + EXPECT_EQ(dhcid_ref, dhcid.toStr()); +} + +// Test that DHCID is correctly created when the DUID has maximal length (128). +TEST_F(DhcidTest, fromMaxDUID) { + D2Dhcid dhcid; + + // Create DUID. + std::vector<uint8_t> duid_data(DUID::MAX_DUID_LEN, 1); + DUID duid(&duid_data[0], duid_data.size()); + + // Create DHCID. + ASSERT_NO_THROW(dhcid.fromDUID(duid, wire_fqdn_)); + + // The reference DHCID (represented as string of hexadecimal digits) + // has been calculated using one of the online calculators. + std::string dhcid_ref = "0002015B9022851B4015AD78187BB9BDB98" + "7708C5EEA74140B28095ED36FE1EAFEE3F6"; + + // Make sure that the DHCID is valid. + EXPECT_EQ(dhcid_ref, dhcid.toStr()); +} + +// This test verifies that DHCID is properly computed from a buffer holding +// client identifier data. +TEST_F(DhcidTest, fromClientId) { + D2Dhcid dhcid; + + // Create a buffer holding client id.. + uint8_t clientid_data[] = { 0, 1, 2, 3, 4, 5, 6 }; + std::vector<uint8_t> clientid(clientid_data, + clientid_data + sizeof(clientid_data)); + + // Create DHCID. + ASSERT_NO_THROW(dhcid.fromClientId(clientid, wire_fqdn_)); + + // The reference DHCID (represented as string of hexadecimal digits) + // has been calculated using one of the online calculators. + std::string dhcid_ref = "0001012191B7B21AF97E0E656DF887C5E2D" + "EF30E7758A207EDF4CCB2DE8CA37066021C"; + + // Make sure that the DHCID is valid. + EXPECT_EQ(dhcid_ref, dhcid.toStr()); + + // Make sure that the empty FQDN is not accepted. + std::vector<uint8_t> empty_wire_fqdn; + EXPECT_THROW(dhcid.fromClientId(clientid, empty_wire_fqdn), + isc::dhcp_ddns::DhcidRdataComputeError); + + // Make sure that the empty client identifier is not accepted. + clientid.clear(); + EXPECT_THROW(dhcid.fromClientId(clientid, wire_fqdn_), + isc::dhcp_ddns::DhcidRdataComputeError); + + +} + +// This test verifies that DHCID is properly computed from a buffer holding +// client identifier data that contains a DUID. +TEST_F(DhcidTest, fromClientIdDUID) { + D2Dhcid dhcid; + + // Create a buffer holding client id.. + uint8_t clientid_data[] = { 0xff, 0x5d, 0xe2, 0x6c, 0x15, 0x00, 0x02, + 0x00, 0x00, 0xab, 0x11, 0x9a, 0x57, 0x20, 0x95, 0x71, 0x61, 0xbd, 0xd0 }; + std::vector<uint8_t> clientid(clientid_data, + clientid_data + sizeof(clientid_data)); + + // Create DHCID. + ASSERT_NO_THROW(dhcid.fromClientId(clientid, wire_fqdn_)); + + // The reference DHCID (represented as string of hexadecimal digits) + std::string dhcid_ref = "000201A250D060B9352AE68E5014B78D25" + "1C30EFB0D5F64E48303B2BC56E6938F129E7"; + + // Make sure that the DHCID is valid. + EXPECT_EQ(dhcid_ref, dhcid.toStr()); + + // Make sure that a too long client identifier is not accepted. + clientid.resize(136); + EXPECT_THROW_MSG(dhcid.fromClientId(clientid, wire_fqdn_), + isc::dhcp_ddns::DhcidRdataComputeError, + "unable to compute DHCID from client identifier," + " embedded DUID length of: 136, is too long"); + + // Make sure that a too short client identifier is not accepted. + clientid.resize(5); + EXPECT_THROW_MSG(dhcid.fromClientId(clientid, wire_fqdn_), + isc::dhcp_ddns::DhcidRdataComputeError, + "unable to compute DHCID from client identifier," + " embedded DUID length of: 5, is too short"); + + // Make sure an empty client identifier is not accepted. + clientid.clear(); + EXPECT_THROW_MSG(dhcid.fromClientId(clientid, wire_fqdn_), + isc::dhcp_ddns::DhcidRdataComputeError, + "empty DUID used to create DHCID"); +} + +// This test verifies that DHCID is properly computed from a HW address. +TEST_F(DhcidTest, fromHWAddr) { + D2Dhcid dhcid; + + // Create a buffer holding client id.. + uint8_t hwaddr_data[] = { 0, 1, 2, 3, 4, 5, 6 }; + HWAddrPtr hwaddr(new HWAddr(hwaddr_data, sizeof(hwaddr_data), + HTYPE_ETHER)); + + // Create DHCID. + ASSERT_NO_THROW(dhcid.fromHWAddr(hwaddr, wire_fqdn_)); + + // The reference DHCID (represented as string of hexadecimal digits) + // has been calculated using one of the online calculators. + std::string dhcid_ref = "0000012247F6DC4423C3E8627434A9D686860" + "9D88948F78018B215EDCAA30C0C135035"; + + // Make sure that the DHCID is valid. + EXPECT_EQ(dhcid_ref, dhcid.toStr()); + + // Make sure that the empty FQDN is not accepted. + std::vector<uint8_t> empty_wire_fqdn; + EXPECT_THROW(dhcid.fromHWAddr(hwaddr, empty_wire_fqdn), + isc::dhcp_ddns::DhcidRdataComputeError); + + // Make sure that the NULL HW address is not accepted. + hwaddr.reset(); + EXPECT_THROW(dhcid.fromHWAddr(hwaddr, wire_fqdn_), + isc::dhcp_ddns::DhcidRdataComputeError); +} + +// test operator<< on D2Dhcid +TEST(NameChangeRequestTest, leftShiftOperation) { + const D2Dhcid dhcid("010203040A7F8E3D"); + + ostringstream oss; + oss << dhcid; + EXPECT_EQ(dhcid.toStr(), oss.str()); +} + +/// @brief Verifies the fundamentals of converting from and to JSON. +/// It verifies that: +/// 1. A NameChangeRequest can be created from a valid JSON string. +/// 2. A valid JSON string can be created from a NameChangeRequest +TEST(NameChangeRequestTest, basicJsonTest) { + // Define valid JSON rendition of a request. + std::string msg_str = "{" + "\"change-type\":1," + "\"forward-change\":true," + "\"reverse-change\":false," + "\"fqdn\":\"walah.walah.com.\"," + "\"ip-address\":\"192.168.2.1\"," + "\"dhcid\":\"010203040A7F8E3D\"," + "\"lease-expires-on\":\"20130121132405\"," + "\"lease-length\":1300," + "\"use-conflict-resolution\":true" + "}"; + + // Verify that a NameChangeRequests can be instantiated from the + // a valid JSON rendition. + NameChangeRequestPtr ncr; + ASSERT_NO_THROW_LOG(ncr = NameChangeRequest::fromJSON(msg_str)); + ASSERT_TRUE(ncr); + + // Verify that the JSON string created by the new request equals the + // original input string. + std::string json_str = ncr->toJSON(); + EXPECT_EQ(msg_str, json_str); + + // Verify that the request ID matches the string from the DHCID. + std::string dhcid_str = "010203040A7F8E3D"; + EXPECT_EQ(dhcid_str, ncr->getRequestId()); +} + +/// @brief Tests a variety of invalid JSON message strings. +/// This test iterates over a list of JSON messages, each containing a single +/// content error. The list of messages is defined by the global array, +/// invalid_messages. Currently that list contains the following invalid +/// conditions: +/// 1. Invalid change type +/// 2. Invalid forward change +/// 3. Invalid reverse change +/// 4. Forward and reverse change both false +/// 5. Invalid forward change +/// 6. Blank FQDN +/// 7. Bad IP address +/// 8. Blank DHCID +/// 9. Odd number of digits in DHCID +/// 10. Text in DHCID +/// 11. Invalid lease expiration string +/// 12. Non-integer for lease length. +/// If more permutations arise they can easily be added to the list. +TEST(NameChangeRequestTest, invalidMsgChecks) { + // Iterate over the list of JSON strings, attempting to create a + // NameChangeRequest. The attempt should throw a NcrMessageError. + int num_msgs = sizeof(invalid_msgs)/sizeof(char*); + for (int i = 0; i < num_msgs; i++) { + EXPECT_THROW(NameChangeRequest::fromJSON(invalid_msgs[i]), + NcrMessageError) << "Invalid message not caught idx: " + << i << std::endl << " text:[" << invalid_msgs[i] << "]" + << std::endl; + } +} + +/// @brief Tests a variety of valid JSON message strings. +/// This test iterates over a list of JSON messages, each containing a single +/// valid request rendition. The list of messages is defined by the global +/// array, valid_messages. Currently that list contains the following valid +/// messages: +/// 1. Valid, IPv4 Add +/// 2. Valid, IPv4 Remove +/// 3. Valid, IPv6 Add +/// If more permutations arise they can easily be added to the list. +TEST(NameChangeRequestTest, validMsgChecks) { + // Iterate over the list of JSON strings, attempting to create a + // NameChangeRequest. The attempt should succeed. + int num_msgs = sizeof(valid_msgs)/sizeof(char*); + for (int i = 0; i < num_msgs; i++) { + EXPECT_NO_THROW(NameChangeRequest::fromJSON(valid_msgs[i])) + << "Valid message failed, message idx: " << i + << std::endl << " text:[" << valid_msgs[i] << "]" + << std::endl; + } +} + +/// @brief Tests converting to and from JSON via isc::util buffer classes. +/// This test verifies that: +/// 1. A NameChangeRequest can be rendered in JSON written to an OutputBuffer +/// 2. A InputBuffer containing a valid JSON request rendition can be used +/// to create a NameChangeRequest. +TEST(NameChangeRequestTest, toFromBufferTest) { + // Define a string containing a valid JSON NameChangeRequest rendition. + std::string msg_str = "{" + "\"change-type\":1," + "\"forward-change\":true," + "\"reverse-change\":false," + "\"fqdn\":\"walah.walah.com.\"," + "\"ip-address\":\"192.168.2.1\"," + "\"dhcid\":\"010203040A7F8E3D\"," + "\"lease-expires-on\":\"20130121132405\"," + "\"lease-length\":1300," + "\"use-conflict-resolution\":true" + "}"; + + // Create a request from JSON directly. + NameChangeRequestPtr ncr; + ASSERT_NO_THROW(ncr = NameChangeRequest::fromJSON(msg_str)); + + // Verify that we output the request as JSON text to a buffer + // without error. + isc::util::OutputBuffer output_buffer(1024); + ASSERT_NO_THROW(ncr->toFormat(FMT_JSON, output_buffer)); + + // Make an InputBuffer from the OutputBuffer. + isc::util::InputBuffer input_buffer(output_buffer.getData(), + output_buffer.getLength()); + + // Verify that we can create a new request from the InputBuffer. + NameChangeRequestPtr ncr2; + ASSERT_NO_THROW(ncr2 = + NameChangeRequest::fromFormat(FMT_JSON, input_buffer)); + + // Convert the new request to JSON directly. + std::string final_str = ncr2->toJSON(); + + // Verify that the final string matches the original. + ASSERT_EQ(final_str, msg_str); +} + +/// @brief Tests ip address modification and validation +TEST(NameChangeRequestTest, ipAddresses) { + NameChangeRequest ncr; + + // Verify that a valid IPv4 address works. + ASSERT_NO_THROW(ncr.setIpAddress("192.168.1.1")); + const asiolink::IOAddress& io_addr4 = ncr.getIpIoAddress(); + EXPECT_EQ(ncr.getIpAddress(), io_addr4.toText()); + EXPECT_TRUE(ncr.isV4()); + EXPECT_FALSE(ncr.isV6()); + + // Verify that a valid IPv6 address works. + ASSERT_NO_THROW(ncr.setIpAddress("2001:1::f3")); + const asiolink::IOAddress& io_addr6 = ncr.getIpIoAddress(); + EXPECT_EQ(ncr.getIpAddress(), io_addr6.toText()); + EXPECT_FALSE(ncr.isV4()); + EXPECT_TRUE(ncr.isV6()); + + // Verify that an invalid address fails. + ASSERT_THROW(ncr.setIpAddress("x001:1::f3"),NcrMessageError); +} + +/// @brief Tests conversion of NameChangeFormat between enum and strings. +TEST(NameChangeFormatTest, formatEnumConversion){ + ASSERT_EQ(stringToNcrFormat("JSON"), dhcp_ddns::FMT_JSON); + ASSERT_EQ(stringToNcrFormat("jSoN"), dhcp_ddns::FMT_JSON); + ASSERT_THROW(stringToNcrFormat("bogus"), isc::BadValue); + + ASSERT_EQ(ncrFormatToString(dhcp_ddns::FMT_JSON), "JSON"); +} + +/// @brief Tests conversion of NameChangeProtocol between enum and strings. +TEST(NameChangeProtocolTest, protocolEnumConversion){ + ASSERT_EQ(stringToNcrProtocol("UDP"), dhcp_ddns::NCR_UDP); + ASSERT_EQ(stringToNcrProtocol("udP"), dhcp_ddns::NCR_UDP); + ASSERT_EQ(stringToNcrProtocol("TCP"), dhcp_ddns::NCR_TCP); + ASSERT_EQ(stringToNcrProtocol("Tcp"), dhcp_ddns::NCR_TCP); + ASSERT_THROW(stringToNcrProtocol("bogus"), isc::BadValue); + + ASSERT_EQ(ncrProtocolToString(dhcp_ddns::NCR_UDP), "UDP"); + ASSERT_EQ(ncrProtocolToString(dhcp_ddns::NCR_TCP), "TCP"); +} + +TEST(NameChangeRequestTest, useConflictResolutionParsing) { + std::string base_json = + "{" + " \"change-type\" : 0 , " + " \"forward-change\" : true , " + " \"reverse-change\" : false , " + " \"fqdn\" : \"walah.walah.com\" , " + " \"ip-address\" : \"192.168.2.1\" , " + " \"dhcid\" : \"010203040A7F8E3D\" , " + " \"lease-expires-on\" : \"20130121132405\" , " + " \"lease-length\" : 1300 "; + + std::string its_true(base_json + ",\"use-conflict-resolution\": true}"); + NameChangeRequestPtr ncr; + ASSERT_NO_THROW_LOG(ncr = NameChangeRequest::fromJSON(its_true)); + ASSERT_TRUE(ncr); + EXPECT_TRUE(ncr->useConflictResolution()); + + std::string its_false(base_json + ",\"use-conflict-resolution\": false}"); + ASSERT_NO_THROW_LOG(ncr = NameChangeRequest::fromJSON(its_false)); + ASSERT_TRUE(ncr); + EXPECT_FALSE(ncr->useConflictResolution()); + + std::string its_missing(base_json + "}"); + ASSERT_NO_THROW_LOG(ncr = NameChangeRequest::fromJSON(its_true)); + ASSERT_TRUE(ncr); + EXPECT_TRUE(ncr->useConflictResolution()); +} + +} // end of anonymous namespace + diff --git a/src/lib/dhcp_ddns/tests/run_unittests.cc b/src/lib/dhcp_ddns/tests/run_unittests.cc new file mode 100644 index 0000000..e1c0801 --- /dev/null +++ b/src/lib/dhcp_ddns/tests/run_unittests.cc @@ -0,0 +1,21 @@ +// Copyright (C) 2011-2015 Internet Systems Consortium, Inc. ("ISC") +// +// 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 http://mozilla.org/MPL/2.0/. + +#include <config.h> + +#include <log/logger_support.h> + +#include <gtest/gtest.h> + +int +main(int argc, char* argv[]) { + ::testing::InitGoogleTest(&argc, argv); + isc::log::initLogger(); + + int result = RUN_ALL_TESTS(); + + return (result); +} diff --git a/src/lib/dhcp_ddns/tests/test_utils.cc b/src/lib/dhcp_ddns/tests/test_utils.cc new file mode 100644 index 0000000..0671307 --- /dev/null +++ b/src/lib/dhcp_ddns/tests/test_utils.cc @@ -0,0 +1,37 @@ +// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC") +// +// 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 http://mozilla.org/MPL/2.0/. + +#include <config.h> + +#include <gtest/gtest.h> + +#include <sys/select.h> +#include <sys/ioctl.h> + +using namespace std; + +namespace isc { +namespace dhcp_ddns { + +int selectCheck(int fd_to_check) { + fd_set read_fds; + int maxfd = 0; + + FD_ZERO(&read_fds); + + // Add this socket to listening set + FD_SET(fd_to_check, &read_fds); + maxfd = fd_to_check; + + struct timeval select_timeout; + select_timeout.tv_sec = 0; + select_timeout.tv_usec = 0; + + return (select(maxfd + 1, &read_fds, NULL, NULL, &select_timeout)); +} + +}; // namespace isc::d2 +}; // namespace isc diff --git a/src/lib/dhcp_ddns/tests/test_utils.h b/src/lib/dhcp_ddns/tests/test_utils.h new file mode 100644 index 0000000..256350e --- /dev/null +++ b/src/lib/dhcp_ddns/tests/test_utils.h @@ -0,0 +1,29 @@ +// Copyright (C) 2014-2015 Internet Systems Consortium, Inc. ("ISC") +// +// 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 http://mozilla.org/MPL/2.0/. + +#ifndef TEST_UTILS_H +#define TEST_UTILS_H + +/// @file test_utils.h Common dhcp_ddns testing elements + +#include <gtest/gtest.h> + + +namespace isc { +namespace dhcp_ddns { + +/// @brief Returns the result of select() given an fd to check for read status. +/// +/// @param fd_to_check The file descriptor to test +/// +/// @return Returns less than one on an error, 0 if the fd is not ready to +/// read, > 0 if it is ready to read. +int selectCheck(int fd_to_check); + +}; // namespace isc::dhcp_ddns; +}; // namespace isc; + +#endif |