diff options
Diffstat (limited to 'src/hooks/dhcp/stat_cmds/tests')
-rw-r--r-- | src/hooks/dhcp/stat_cmds/tests/Makefile.am | 74 | ||||
-rw-r--r-- | src/hooks/dhcp/stat_cmds/tests/Makefile.in | 1020 | ||||
-rw-r--r-- | src/hooks/dhcp/stat_cmds/tests/run_unittests.cc | 19 | ||||
-rw-r--r-- | src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc | 1582 |
4 files changed, 2695 insertions, 0 deletions
diff --git a/src/hooks/dhcp/stat_cmds/tests/Makefile.am b/src/hooks/dhcp/stat_cmds/tests/Makefile.am new file mode 100644 index 0000000..a0116ae --- /dev/null +++ b/src/hooks/dhcp/stat_cmds/tests/Makefile.am @@ -0,0 +1,74 @@ +SUBDIRS = . + +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/stat_cmds -I$(top_srcdir)/src/hooks/dhcp/stat_cmds +AM_CPPFLAGS += $(BOOST_INCLUDES) +AM_CPPFLAGS += -DSTAT_CMDS_LIB_SO=\"$(abs_top_builddir)/src/hooks/dhcp/stat_cmds/.libs/libdhcp_stat_cmds.so\" +AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\" + +if HAVE_MYSQL +AM_CPPFLAGS += $(MYSQL_CPPFLAGS) +endif +if HAVE_PGSQL +AM_CPPFLAGS += $(PGSQL_CPPFLAGS) +endif + +AM_CXXFLAGS = $(KEA_CXXFLAGS) + +if USE_STATIC_LINK +AM_LDFLAGS = -static +endif + +# Unit test data files need to get installed. +EXTRA_DIST = + +CLEANFILES = *.gcno *.gcda + +# TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) +LOG_COMPILER = $(LIBTOOL) +AM_LOG_FLAGS = --mode=execute + +TESTS = +if HAVE_GTEST +TESTS += stat_cmds_unittests + +stat_cmds_unittests_SOURCES = run_unittests.cc +stat_cmds_unittests_SOURCES += stat_cmds_unittest.cc + +stat_cmds_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES) + +stat_cmds_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) + +stat_cmds_unittests_CXXFLAGS = $(AM_CXXFLAGS) + +stat_cmds_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/process/libkea-process.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libkea-dhcp_ddns.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/stats/libkea-stats.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/config/libkea-cfgclient.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/http/libkea-http.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la +stat_cmds_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la +stat_cmds_unittests_LDADD += $(LOG4CPLUS_LIBS) +stat_cmds_unittests_LDADD += $(CRYPTO_LIBS) +stat_cmds_unittests_LDADD += $(BOOST_LIBS) +stat_cmds_unittests_LDADD += $(GTEST_LDADD) + +if HAVE_MYSQL +stat_cmds_unittests_LDFLAGS += $(MYSQL_LIBS) +endif +if HAVE_PGSQL +stat_cmds_unittests_LDFLAGS += $(PGSQL_LIBS) +endif + +endif +noinst_PROGRAMS = $(TESTS) diff --git a/src/hooks/dhcp/stat_cmds/tests/Makefile.in b/src/hooks/dhcp/stat_cmds/tests/Makefile.in new file mode 100644 index 0000000..99de1e1 --- /dev/null +++ b/src/hooks/dhcp/stat_cmds/tests/Makefile.in @@ -0,0 +1,1020 @@ +# 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@ +@HAVE_MYSQL_TRUE@am__append_1 = $(MYSQL_CPPFLAGS) +@HAVE_PGSQL_TRUE@am__append_2 = $(PGSQL_CPPFLAGS) +TESTS = $(am__EXEEXT_1) +@HAVE_GTEST_TRUE@am__append_3 = stat_cmds_unittests +@HAVE_GTEST_TRUE@@HAVE_MYSQL_TRUE@am__append_4 = $(MYSQL_LIBS) +@HAVE_GTEST_TRUE@@HAVE_PGSQL_TRUE@am__append_5 = $(PGSQL_LIBS) +noinst_PROGRAMS = $(am__EXEEXT_2) +subdir = src/hooks/dhcp/stat_cmds/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_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_sysrepo.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 = stat_cmds_unittests$(EXEEXT) +am__EXEEXT_2 = $(am__EXEEXT_1) +PROGRAMS = $(noinst_PROGRAMS) +am__stat_cmds_unittests_SOURCES_DIST = run_unittests.cc \ + stat_cmds_unittest.cc +@HAVE_GTEST_TRUE@am_stat_cmds_unittests_OBJECTS = \ +@HAVE_GTEST_TRUE@ stat_cmds_unittests-run_unittests.$(OBJEXT) \ +@HAVE_GTEST_TRUE@ stat_cmds_unittests-stat_cmds_unittest.$(OBJEXT) +stat_cmds_unittests_OBJECTS = $(am_stat_cmds_unittests_OBJECTS) +am__DEPENDENCIES_1 = +@HAVE_GTEST_TRUE@stat_cmds_unittests_DEPENDENCIES = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/process/libkea-process.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/eval/libkea-eval.la \ +@HAVE_GTEST_TRUE@ $(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/config/libkea-cfgclient.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/http/libkea-http.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/database/libkea-database.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 = +stat_cmds_unittests_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ + $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) \ + $(stat_cmds_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)/stat_cmds_unittests-run_unittests.Po \ + ./$(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.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 = +SOURCES = $(stat_cmds_unittests_SOURCES) +DIST_SOURCES = $(am__stat_cmds_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_GTEST_CONFIGURE_FLAG = @DISTCHECK_GTEST_CONFIGURE_FLAG@ +DISTCHECK_KEA_SHELL_CONFIGURE_FLAG = @DISTCHECK_KEA_SHELL_CONFIGURE_FLAG@ +DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG = @DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG@ +DISTCHECK_PERFDHCP_CONFIGURE_FLAG = @DISTCHECK_PERFDHCP_CONFIGURE_FLAG@ +DISTCHECK_PREMIUM_CONFIGURE_FLAG = @DISTCHECK_PREMIUM_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_SYSREPO = @HAVE_SYSREPO@ +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@ +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_REPO_PATH = @SR_REPO_PATH@ +STRIP = @STRIP@ +SYSREPOCPP_VERSION = @SYSREPOCPP_VERSION@ +SYSREPO_CPPFLAGS = @SYSREPO_CPPFLAGS@ +SYSREPO_INCLUDEDIR = @SYSREPO_INCLUDEDIR@ +SYSREPO_LIBS = @SYSREPO_LIBS@ +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 \ + -I$(top_builddir)/src/hooks/dhcp/stat_cmds \ + -I$(top_srcdir)/src/hooks/dhcp/stat_cmds $(BOOST_INCLUDES) \ + -DSTAT_CMDS_LIB_SO=\"$(abs_top_builddir)/src/hooks/dhcp/stat_cmds/.libs/libdhcp_stat_cmds.so\" \ + -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\" \ + $(am__append_1) $(am__append_2) +AM_CXXFLAGS = $(KEA_CXXFLAGS) +@USE_STATIC_LINK_TRUE@AM_LDFLAGS = -static + +# Unit test data files need to get installed. +EXTRA_DIST = +CLEANFILES = *.gcno *.gcda + +# TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND) +LOG_COMPILER = $(LIBTOOL) +AM_LOG_FLAGS = --mode=execute +@HAVE_GTEST_TRUE@stat_cmds_unittests_SOURCES = run_unittests.cc \ +@HAVE_GTEST_TRUE@ stat_cmds_unittest.cc +@HAVE_GTEST_TRUE@stat_cmds_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES) +@HAVE_GTEST_TRUE@stat_cmds_unittests_LDFLAGS = $(AM_LDFLAGS) \ +@HAVE_GTEST_TRUE@ $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS) \ +@HAVE_GTEST_TRUE@ $(am__append_4) $(am__append_5) +@HAVE_GTEST_TRUE@stat_cmds_unittests_CXXFLAGS = $(AM_CXXFLAGS) +@HAVE_GTEST_TRUE@stat_cmds_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/process/libkea-process.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/eval/libkea-eval.la \ +@HAVE_GTEST_TRUE@ $(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/config/libkea-cfgclient.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/http/libkea-http.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/database/libkea-database.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/hooks/dhcp/stat_cmds/tests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/hooks/dhcp/stat_cmds/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 + +stat_cmds_unittests$(EXEEXT): $(stat_cmds_unittests_OBJECTS) $(stat_cmds_unittests_DEPENDENCIES) $(EXTRA_stat_cmds_unittests_DEPENDENCIES) + @rm -f stat_cmds_unittests$(EXEEXT) + $(AM_V_CXXLD)$(stat_cmds_unittests_LINK) $(stat_cmds_unittests_OBJECTS) $(stat_cmds_unittests_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat_cmds_unittests-run_unittests.Po@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.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 $@ $< + +stat_cmds_unittests-run_unittests.o: run_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(stat_cmds_unittests_CPPFLAGS) $(CPPFLAGS) $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) -MT stat_cmds_unittests-run_unittests.o -MD -MP -MF $(DEPDIR)/stat_cmds_unittests-run_unittests.Tpo -c -o stat_cmds_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stat_cmds_unittests-run_unittests.Tpo $(DEPDIR)/stat_cmds_unittests-run_unittests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='run_unittests.cc' object='stat_cmds_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) $(stat_cmds_unittests_CPPFLAGS) $(CPPFLAGS) $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) -c -o stat_cmds_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc + +stat_cmds_unittests-run_unittests.obj: run_unittests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(stat_cmds_unittests_CPPFLAGS) $(CPPFLAGS) $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) -MT stat_cmds_unittests-run_unittests.obj -MD -MP -MF $(DEPDIR)/stat_cmds_unittests-run_unittests.Tpo -c -o stat_cmds_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)/stat_cmds_unittests-run_unittests.Tpo $(DEPDIR)/stat_cmds_unittests-run_unittests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='run_unittests.cc' object='stat_cmds_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) $(stat_cmds_unittests_CPPFLAGS) $(CPPFLAGS) $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) -c -o stat_cmds_unittests-run_unittests.obj `if test -f 'run_unittests.cc'; then $(CYGPATH_W) 'run_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/run_unittests.cc'; fi` + +stat_cmds_unittests-stat_cmds_unittest.o: stat_cmds_unittest.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(stat_cmds_unittests_CPPFLAGS) $(CPPFLAGS) $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) -MT stat_cmds_unittests-stat_cmds_unittest.o -MD -MP -MF $(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.Tpo -c -o stat_cmds_unittests-stat_cmds_unittest.o `test -f 'stat_cmds_unittest.cc' || echo '$(srcdir)/'`stat_cmds_unittest.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.Tpo $(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='stat_cmds_unittest.cc' object='stat_cmds_unittests-stat_cmds_unittest.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) $(stat_cmds_unittests_CPPFLAGS) $(CPPFLAGS) $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) -c -o stat_cmds_unittests-stat_cmds_unittest.o `test -f 'stat_cmds_unittest.cc' || echo '$(srcdir)/'`stat_cmds_unittest.cc + +stat_cmds_unittests-stat_cmds_unittest.obj: stat_cmds_unittest.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(stat_cmds_unittests_CPPFLAGS) $(CPPFLAGS) $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) -MT stat_cmds_unittests-stat_cmds_unittest.obj -MD -MP -MF $(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.Tpo -c -o stat_cmds_unittests-stat_cmds_unittest.obj `if test -f 'stat_cmds_unittest.cc'; then $(CYGPATH_W) 'stat_cmds_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/stat_cmds_unittest.cc'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.Tpo $(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='stat_cmds_unittest.cc' object='stat_cmds_unittests-stat_cmds_unittest.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) $(stat_cmds_unittests_CPPFLAGS) $(CPPFLAGS) $(stat_cmds_unittests_CXXFLAGS) $(CXXFLAGS) -c -o stat_cmds_unittests-stat_cmds_unittest.obj `if test -f 'stat_cmds_unittest.cc'; then $(CYGPATH_W) 'stat_cmds_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/stat_cmds_unittest.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)/stat_cmds_unittests-run_unittests.Po + -rm -f ./$(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.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)/stat_cmds_unittests-run_unittests.Po + -rm -f ./$(DEPDIR)/stat_cmds_unittests-stat_cmds_unittest.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/hooks/dhcp/stat_cmds/tests/run_unittests.cc b/src/hooks/dhcp/stat_cmds/tests/run_unittests.cc new file mode 100644 index 0000000..f5014ce --- /dev/null +++ b/src/hooks/dhcp/stat_cmds/tests/run_unittests.cc @@ -0,0 +1,19 @@ +// Copyright (C) 2018 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/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc b/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc new file mode 100644 index 0000000..bd211dd --- /dev/null +++ b/src/hooks/dhcp/stat_cmds/tests/stat_cmds_unittest.cc @@ -0,0 +1,1582 @@ +// Copyright (C) 2018-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 <exceptions/exceptions.h> +#include <hooks/hooks_manager.h> +#include <config/command_mgr.h> +#include <dhcpsrv/lease_mgr.h> +#include <dhcpsrv/lease_mgr_factory.h> +#include <dhcpsrv/cfgmgr.h> +#include <cc/command_interpreter.h> +#include <cc/data.h> +#include <stats/stats_mgr.h> +#include <testutils/gtest_utils.h> + +#include <boost/date_time/posix_time/posix_time.hpp> +#include <gtest/gtest.h> +#include <time.h> + +using namespace std; +using namespace isc; +using namespace isc::hooks; +using namespace isc::config; +using namespace isc::data; +using namespace isc::dhcp; +using namespace isc::asiolink; +using namespace isc::stats; +using namespace boost::posix_time; + +namespace { + +/// @brief Test fixture for testing loading and unloading the library +class LibLoadTest : public ::testing::Test { +public: + /// @brief Constructor + LibLoadTest(std::string lib_filename) + : lib_name_(lib_filename), start_time_(second_clock::universal_time()) { + CommandMgr::instance(); + unloadLibs(); + } + + /// @brief Destructor + /// Removes files that may be left over from previous tests + virtual ~LibLoadTest() { + unloadLibs(); + } + + /// @brief Adds library/parameters to list of libraries to be loaded + void addLib(const std::string& lib, ConstElementPtr params) { + libraries_.push_back(make_pair(lib, params)); + } + + /// @brief Load all specified libraries. + /// + /// The libraries are stored in libraries + void loadLibs() { + ASSERT_TRUE(HooksManager::loadLibraries(libraries_)) + << "library loading failed"; + } + + /// @brief Unloads all libraries. + void unloadLibs() { + ASSERT_NO_THROW(HooksManager::unloadLibraries()); + } + + /// @brief Checks whether specified command is registered + /// + /// @param name name of the command to be checked + /// @param expect_true true - must be registered, false - must not be + void checkCommandRegistered(const std::string& name, bool expect_true) { + + // First get the list of registered commands + ConstElementPtr lst = Element::fromJSON("{ \"command\": \"list-commands\" }"); + ConstElementPtr rsp = CommandMgr::instance().processCommand(lst); + + ASSERT_TRUE(rsp); + + ConstElementPtr args = rsp->get("arguments"); + ASSERT_TRUE(args); + + string args_txt = args->str(); + + if (expect_true) { + EXPECT_TRUE(args_txt.find(name) != string::npos); + } else { + EXPECT_TRUE(args_txt.find(name) == string::npos); + } } + + /// @brief tests specified command and verifies response + /// + /// This method loads the library, sends specific command, + /// then checks if the result is as expected, checks if text response + /// is ok (optional, check skipped if exp_txt is empty) and then returns + /// the response (for possible additional checks). + /// + /// @param cmd JSON command to be sent (must be valid JSON) + /// @param exp_result 0 - success, 1 - error, 2 - ... + /// @param exp_txt expected text response (optional) + void testCommand(string cmd_txt, int exp_result, string exp_txt, + string exp_result_json = "") { + // Let's load the library first. + loadLib(); + + ConstElementPtr cmd; + ASSERT_NO_THROW(cmd = Element::fromJSON(cmd_txt)) + << "command JSON invalid, test is broken"; + + // Process the command and verify response. + ConstElementPtr rsp = CommandMgr::instance().processCommand(cmd); + checkAnswer(rsp, exp_result, exp_txt); + + // Don't care about argument contents, we're done. + if (exp_result_json.empty()) { + return; + } + + // Turn expected result JSON into Element tree + ConstElementPtr exp_args; + ASSERT_NO_THROW(exp_args = Element::fromJSON(exp_result_json)) + << "Expected result JSON is invalid, test is broken" << exp_result_json; + + ASSERT_TRUE(exp_args->getType() == Element::map) + << "Expected args is not a map, test is broken: " << exp_result_json; + + // Fetch "arguments" from the actual response + ConstElementPtr actual_args = rsp->get("arguments"); + ASSERT_TRUE(actual_args && actual_args->getType() == Element::map) + << "'arguments' missing or not a map " << toJSON(rsp); + + // If we expect nothing and nothing is what we got, we're done. + if (exp_args->size() == 0) { + ASSERT_TRUE(actual_args->size() == 0) + << "Actual args should be empty:" << toJSON(actual_args); + return; + } + + // Fetch "result-set" from the expected arguments + ConstElementPtr exp_result_set = exp_args->get("result-set"); + ASSERT_TRUE(exp_result_set && (exp_result_set->getType() == Element::map)) + << "Expected 'result-set' missing or not map\n" << toJSON(exp_args); + + // Fetch "result-set" from the actual arguments + ConstElementPtr actual_result_set = actual_args->get("result-set"); + ASSERT_TRUE(actual_result_set && (actual_result_set->getType() == Element::map)) + << "Actual 'result-set' missing or not map\n" << toJSON(actual_args); + + // Compare the actual and expected "columns" + ConstElementPtr exp = exp_result_set->get("columns"); + ASSERT_TRUE(exp && exp->getType() == Element::list) + << "Expected 'columns' is missing or not list, test is broken" + << toJSON(exp_result_set); + + ConstElementPtr actual = actual_result_set->get("columns"); + ASSERT_TRUE(actual && (actual->getType() == Element::list)) + << "Actual 'columns' is missing or not list" + << toJSON(actual_result_set); + + ASSERT_TRUE(*exp == *actual) << "Result set columns are wrong\n" + << "Expected:\n" << toJSON(exp) + << "\nActual:\n" << toJSON(actual); + + // Compare the actual and expected "rows" + exp = exp_result_set->get("rows"); + ASSERT_TRUE(exp && (exp->getType() == Element::list)) + << "Expected 'rows' is missing or not a list, test is broken"; + + actual = actual_result_set->get("rows"); + ASSERT_TRUE(actual && (actual->getType() == Element::list)) + << "Actual 'rows' is missing or not a list" + << toJSON(actual_result_set); + + ASSERT_TRUE(*exp == *actual) << "Result set rows are wrong\n" + << "Expected:\n" << toJSON(exp) + << "\nActual:\n" << toJSON(actual); + + // Make sure timestamp is present and appears valid + actual = actual_result_set->get("timestamp"); + ASSERT_TRUE (actual && (actual->getType() == Element::string)) + << "Actual result-set timestamp is missing?" + << toJSON(rsp); + + // We expect it to be the same or later than the test start time + ptime timestamp = strToPtime(actual->stringValue()); + EXPECT_TRUE(timestamp >= start_time_) + << "Actual timestamp is wrong?" << actual->stringValue(); + } + + /// @brief Compares the status in the given parse result to a given value. + /// + /// @param answer Element set containing an integer response and string + /// comment. + /// @param exp_status is an integer against which to compare the status. + /// @param exp_txt is expected text (not checked if "") + void checkAnswer(isc::data::ConstElementPtr answer, + int exp_status, + string exp_txt = "") { + int rcode = 0; + isc::data::ConstElementPtr comment; + comment = isc::config::parseAnswer(rcode, answer); + + if (rcode != exp_status) { + ADD_FAILURE() << "Expected status code " << exp_status + << " but received " << rcode << ", comment: " + << (comment ? comment->str() : "(none)"); + } + + // Ok, parseAnswer interface is weird. If there are no arguments, + // it returns content of text. But if there is an argument, + // it returns the argument and it's not possible to retrieve + // "text" (i.e. comment). + if (comment->getType() != Element::string) { + comment = answer->get("text"); + } + + if (!exp_txt.empty()) { + EXPECT_EQ(exp_txt, comment->stringValue()); + } + } + + /// @brief Loads the library specified by lib_name_ + void loadLib() { + if (libraries_.empty()) { + data::ElementPtr params = data::Element::createMap(); + addLib(lib_name_, params); + } + EXPECT_NO_THROW(loadLibs()); + } + + /// @brief Test checks if specified commands are provided by the library. + /// + /// @param cms a vector of string with command names + void testCommands(const std::vector<string> cmds) { + + // The commands should not be registered yet. + for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) { + checkCommandRegistered(*cmd, false); + } + + loadLib(); + + // The commands should be available after library was loaded. + for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) { + checkCommandRegistered(*cmd, true); + } + + unloadLibs(); + + // and the commands should be gone now. + for (auto cmd = cmds.begin(); cmd != cmds.end(); ++cmd) { + checkCommandRegistered(*cmd, false); + } + + } + + // Check that the library can be loaded and unloaded multiple times. + void testMultipleLoads() { + EXPECT_NO_THROW(loadLib()); + EXPECT_NO_THROW(unloadLibs()); + + EXPECT_NO_THROW(loadLib()); + EXPECT_NO_THROW(unloadLibs()); + + EXPECT_NO_THROW(loadLib()); + EXPECT_NO_THROW(unloadLibs()); + + EXPECT_NO_THROW(loadLib()); + EXPECT_NO_THROW(unloadLibs()); + } + + std::string toJSON(ConstElementPtr element) { + std::stringstream os; + element->toJSON(os); + return (os.str()); + } + + /// @brief Converts a string into a boost::posix_time::ptime + /// + /// The expected format of the input string is: + /// + /// "%Y-%m-%d %H:%M:%S" + /// + /// Example: "2018-04-21 15:03:37" + /// + /// Any content beyond this length is ignored. + /// + /// We're doing it this way because boost's function, time_from_string(), + /// is part of their date/time library which is not header only. + /// + /// @param timestamp string to convert into a ptime + /// @throw BadValue if the string cannot be converted into a ptime + boost::posix_time::ptime strToPtime(const std::string& timestamp) { + struct tm tm_result; + + if (!strptime(timestamp.c_str(), "%Y-%m-%d %H:%M:%S", &tm_result)) { + isc_throw(BadValue, "cannot convert timestamp string: " << timestamp); + } + + return (ptime_from_tm(tm_result)); + } + + /// List of libraries to be/being loaded (usually just one) + HookLibsCollection libraries_; + + /// Path to the library filename + std::string lib_name_; + + /// @brief Holds the time the test started + boost::posix_time::ptime start_time_; +}; + +/// @brief Class dedicated to testing lease_cmds library. +/// +/// Provides convenience methods for loading, testing all commands and +/// unloading the lease_cmds library. +/// @todo This class should really be separated from loading and unloading +/// the library so implementation classes are tested more directly. +class StatCmdsTest : public LibLoadTest { +public: + + /// @brief Constructor + /// + /// Sets the library filename and clears the lease manager pointer. + /// Also ensured there is no lease manager leftovers from previous + /// test. + StatCmdsTest() + :LibLoadTest(STAT_CMDS_LIB_SO), hwaddr_({10,20,30,40,50,00}), + duid_({10,20,30,40,50,60,70,00}) { + LeaseMgrFactory::destroy(); + lmptr_ = 0; + } + + /// @brief Destructor + /// + /// Removes library (if any), destroys lease manager (if any). + virtual ~StatCmdsTest() { + // destroys lease manager first because the other order triggers + // a clang/boost bug + LeaseMgrFactory::destroy(); + unloadLibs(); + lmptr_ = 0; + } + + /// @brief Initializes lease manager for v4 operation + /// + /// Creates a lease manager (memfile, trimmed down to keep everything in memory + /// only) and adds five subnets to the configuration. + void initLeaseMgr4() { + LeaseMgrFactory::destroy(); + LeaseMgrFactory::create("type=memfile persist=false universe=4"); + + lmptr_ = &(LeaseMgrFactory::instance()); + ASSERT_TRUE(lmptr_); + + CfgMgr& cfg_mgr = CfgMgr::instance(); + CfgSubnets4Ptr subnets = cfg_mgr.getStagingCfg()->getCfgSubnets4(); + + Subnet4Ptr subnet; + Pool4Ptr pool; + + subnet.reset(new Subnet4(IOAddress("192.0.1.0"), 24, 1, 2, 3, 10)); + pool.reset(new Pool4(IOAddress("192.0.1.0"), 24)); + subnet->addPool(pool); + subnets->add(subnet); + + subnet.reset(new Subnet4(IOAddress("192.0.2.0"), 28, 1, 2, 3, 20)); + pool.reset(new Pool4(IOAddress("192.0.2.0"), 28)); + subnet->addPool(pool); + subnets->add(subnet); + + subnet.reset(new Subnet4(IOAddress("192.0.3.0"), 24, 1, 2, 3, 30)); + pool.reset(new Pool4(IOAddress("192.0.3.0"), 24)); + subnet->addPool(pool); + subnets->add(subnet); + + subnet.reset(new Subnet4(IOAddress("192.0.4.0"), 28, 1, 2, 3, 40)); + pool.reset(new Pool4(IOAddress("192.0.4.0"), 28)); + subnet->addPool(pool); + subnets->add(subnet); + + subnet.reset(new Subnet4(IOAddress("192.0.5.0"), 24, 1, 2, 3, 50)); + pool.reset(new Pool4(IOAddress("192.0.5.0"), 24)); + subnet->addPool(pool); + subnets->add(subnet); + + cfg_mgr.commit(); + + // Subnet 10 + // 300 cumulative, 2 assigned, 3 declined, 1 expired + setSubnetStat(10, "cumulative-assigned-addresses", 300); + addLease4("192.0.1.1", 10); + addLease4("192.0.1.2", 10, Lease::STATE_DECLINED); + addLease4("192.0.1.3", 10, Lease::STATE_DECLINED); + addLease4("192.0.1.4", 10, Lease::STATE_DECLINED); + addLease4("192.0.1.5", 10); + addLease4("192.0.1.6", 10, Lease::STATE_EXPIRED_RECLAIMED); + + // Subnet 20 + // 10 cumulative, 3 assigned, 0 declined, 2 expired + setSubnetStat(20, "cumulative-assigned-addresses", 10); + addLease4("192.0.2.1", 20); + addLease4("192.0.2.2", 20); + addLease4("192.0.2.3", 20); + addLease4("192.0.2.4", 20, Lease::STATE_EXPIRED_RECLAIMED); + addLease4("192.0.2.5", 20, Lease::STATE_EXPIRED_RECLAIMED); + + // Subnet 30 no leases + + // Subnet 40, 4 cumulative, 4 assigned + setSubnetStat(40, "cumulative-assigned-addresses", 4); + addLease4("192.0.4.1", 40); + addLease4("192.0.4.2", 40); + addLease4("192.0.4.3", 40); + addLease4("192.0.4.4", 40); + + // Subnet 50, 2 cumulative, 1 assigned, 1 declined + setSubnetStat(50, "cumulative-assigned-addresses", 2); + addLease4("192.0.5.1", 50); + addLease4("192.0.5.2", 50, Lease::STATE_DECLINED); + } + + /// @brief Initializes lease manager for v6 operation + /// + /// Creates a lease manager (memfile, trimmed down to keep everything in + /// memory only) and adds five subnets to the configuration. + void initLeaseMgr6() { + LeaseMgrFactory::destroy(); + LeaseMgrFactory::create("type=memfile persist=false universe=6"); + + lmptr_ = &(LeaseMgrFactory::instance()); + ASSERT_TRUE(lmptr_); + + CfgMgr& cfg_mgr = CfgMgr::instance(); + CfgSubnets6Ptr subnets = cfg_mgr.getStagingCfg()->getCfgSubnets6(); + + Subnet6Ptr subnet; + Pool6Ptr pool; + + subnet.reset(new Subnet6(IOAddress("2001:db8:1::"), 64, 1, 2, 3, 4, 10)); + pool.reset(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:1::"), 112)); + subnet->addPool(pool); + subnets->add(subnet); + + subnet.reset(new Subnet6(IOAddress("2001:db8:2::"), 64, 1, 2, 3, 4, 20)); + pool.reset(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:2::"), 104)); + subnet->addPool(pool); + subnets->add(subnet); + + subnet.reset(new Subnet6(IOAddress("2001:db8:3::"), 64, 1, 2, 3, 4, 30)); + pool.reset(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:3::"), 124)); + subnet->addPool(pool); + pool.reset(new Pool6(Lease::TYPE_PD, IOAddress("3001::"), 96, 112)); + subnet->addPool(pool); + subnets->add(subnet); + + subnet.reset(new Subnet6(IOAddress("2001:db8:4::"), 64, 1, 2, 3, 4, 40)); + pool.reset(new Pool6(Lease::TYPE_NA, IOAddress("2001:db8:4::"), 104)); + subnet->addPool(pool); + subnets->add(subnet); + + // Subnet 50 is prefix only + subnet.reset(new Subnet6(IOAddress("2001:db8:5::"), 64, 1, 2, 3, 4, 50)); + pool.reset(new Pool6(Lease::TYPE_PD, IOAddress("5001::"), 96, 112)); + subnet->addPool(pool); + subnets->add(subnet); + + cfg_mgr.commit(); + + // Subnet 10: 10000 cumulative NAs, 2 assigned, 3 declined, 1 expired + setSubnetStat(10, "cumulative-assigned-nas", 10000); + addLease6("2001:db8:1::1", 10); + addLease6("2001:db8:1::2", 10); + addLease6("2001:db8:1::3", 10, Lease::STATE_DECLINED); + addLease6("2001:db8:1::4", 10, Lease::STATE_DECLINED); + addLease6("2001:db8:1::5", 10, Lease::STATE_DECLINED); + addLease6("2001:db8:1::6", 10, Lease::STATE_EXPIRED_RECLAIMED); + + // Subnet 20: 10 cumulative NAs, 3 assigned + setSubnetStat(20, "cumulative-assigned-nas", 10); + addLease6("2001:db8:2::1", 20); + addLease6("2001:db8:2::2", 20); + addLease6("2001:db8:2::3", 20); + + // Subnet 30: 2 cumulative NAs, 1 assigned, 1 declined, + // 4 cumulative PDs, 3 assigned + setSubnetStat(30, "cumulative-assigned-nas", 2); + addLease6("2001:db8:3::1", 30); + addLease6("2001:db8:3::2", 30, Lease::STATE_DECLINED); + setSubnetStat(30, "cumulative-assigned-pds", 4); + addPrefix("3001::1:0", 112, 30); + addPrefix("3001::2:0", 112, 30); + addPrefix("3001::3:0", 112, 30); + + // Subnet 40: no leases + + // Subnet 50: 1000 cumulative PDs, 2 assigned + setSubnetStat(50, "cumulative-assigned-pds", 1000); + addPrefix("5001::1:0", 112, 50); + addPrefix("5001::2:0", 112, 50); + } + + /// @brief Creates an IPv4 lease + /// + /// Lease parameters: valid lifetime = 3600, cltt = 12345678, + /// fqdn-fwd = false,fqdn-rev = true, hostname = myhost.example.com + /// + /// @param ip_address IP address for the lease. + /// @param subnet_id subnet identifier + /// @param state lease state + void addLease4(const std::string& ip_address, const SubnetID& subnet_id, + const int state = Lease::STATE_DEFAULT) { + Lease4Ptr lease(new Lease4()); + + lease->addr_ = IOAddress(ip_address); + + ++hwaddr_[5]; + + // Set other parameters. For historical reasons, address 0 is not used. + lease->hwaddr_.reset(new HWAddr(hwaddr_, HTYPE_ETHER)); + lease->valid_lft_ = 3600; + lease->cltt_ = 12345678; + lease->subnet_id_ = subnet_id; + lease->fqdn_fwd_ = false; + lease->fqdn_rev_ = true; + lease->hostname_ = "myhost.example.com."; + lease->state_ = state; + + ASSERT_NO_THROW(lmptr_->addLease(lease)) + << "cannot add lease4: " << ip_address + << " subnet: " << subnet_id; + } + + /// @brief Creates an IPv6 lease + /// + /// @param ip_address IP address for the lease. + /// @param subnet_id subnet identifier + /// @param state lease state of the lease, defaults to STATE_DEFAULT + /// @param lease_type type of the lease, defaults to TYPE_NA + /// @param prefix_len prefix length of the lease, defaults to 128 + void addLease6(const std::string& ip_address, const SubnetID& subnet_id, + const int state = Lease::STATE_DEFAULT, + const Lease::Type& lease_type = Lease::TYPE_NA, + const int prefix_len = 128) { + Lease6Ptr lease(new Lease6()); + + ++duid_[7]; + + lease->addr_ = IOAddress(ip_address); + lease->type_ = lease_type; + lease->prefixlen_ = prefix_len; + lease->iaid_ = 42; + lease->duid_ = DuidPtr(new DUID(duid_)); + lease->preferred_lft_ = 1800; + lease->valid_lft_ = 3600; + lease->cltt_ = 12345678; + lease->subnet_id_ = subnet_id; + lease->state_ = state; + + ASSERT_NO_THROW(lmptr_->addLease(lease)) + << "cannot add lease6: " << lease->toText(); + } + + /// @brief Creates an IPv6 PD lease + /// + /// @param prefix IP address prefix for the lease. + /// @param prefix_len prefix length of the lease + /// @param subnet_id subnet identifier + /// @param state lease state of the lease, defaults to STATE_DEFAULT + void addPrefix(const std::string& prefix, const int prefix_len, + const SubnetID& subnet_id, + const int state = Lease::STATE_DEFAULT) { + addLease6(prefix, subnet_id, state, Lease::TYPE_PD, prefix_len); + } + + /// @brief Creates a statistic + /// + /// @param subnet_id subnet identifier + /// @param name statistic name + /// @param value statistic value + void setSubnetStat(const SubnetID& subnet_id, const std::string& name, + int64_t value) { + StatsMgr& stats_mgr = StatsMgr::instance(); + const std::string& stats_name = + stats_mgr.generateName("subnet", subnet_id, name); + stats_mgr.setValue(stats_name, value); + } + + /// @brief Pointer to the lease manager + LeaseMgr* lmptr_; + + /// @brief Holds the hardware address for creating v4 leases + vector<uint8_t> hwaddr_; + + /// @brief Holds the DUID for creating v6 leases + vector<uint8_t> duid_; +}; + +// Simple test that checks the library really registers the commands. +TEST_F(StatCmdsTest, commands) { + + vector<string> cmds = { "stat-lease4-get", + "stat-lease6-get" }; + testCommands(cmds); +} + +// Check that the library can be loaded and unloaded multiple times. +TEST_F(StatCmdsTest, multipleLoads) { + testMultipleLoads(); +} + +struct TestScenario { + std::string description_; + std::string command_txt_; + std::string exp_response_; + std::string exp_result_json; +}; + +// Verifies detection of invalid v4 input parameters. +TEST_F(StatCmdsTest, StatLease4GetBadParams) { + // Initialize lease manager + initLeaseMgr4(); + + std::vector<TestScenario> tests = { + { + "arguments is not a map", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": \"not a map\"\n" + "}", + "'arguments' parameter is not a map" + }, + { + "subnet-id 0", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-id\": 0\n" + " }\n" + "}", + "'subnet-id' parameter must be > 0" + }, + + { + "subnet-id -1", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-id\": -1\n" + " }\n" + "}", + "'subnet-id' parameter must be > 0" + }, + { + "subnet-id string", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-id\": \"boo\"\n" + " }\n" + "}", + "'subnet-id' parameter is not integer" + }, + { + "subnet-range not a map", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": -1\n" + " }\n" + "}", + "subnet-range parameter is not a map" + }, + { + "subnet-range empty", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " }\n" + " }\n" + "}", + "'first-subnet-id' parameter missing or not an integer" + }, + { + "first-subnet-id string", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": \"boo\"\n" + " }\n" + " }\n" + "}", + "'first-subnet-id' parameter missing or not an integer" + }, + { + "first-subnet-id < 0", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": -77\n" + " }\n" + " }\n" + "}", + "'first-subnet-id' parameter must be > 0" + }, + { + "last-subnet-id missing", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 10\n" + " }\n" + " }\n" + "}", + "'last-subnet-id' parameter missing or not an integer" + }, + { + "last-subnet-id string", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 10,\n" + " \"last-subnet-id\": \"boo\"\n" + " }\n" + " }\n" + "}", + "'last-subnet-id' parameter missing or not an integer" + }, + { + "last-subnet-id < 0", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 10,\n" + " \"last-subnet-id\": -1\n" + " }\n" + " }\n" + "}", + "'last-subnet-id' parameter must be > 0" + }, + { + "invalid range", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 50,\n" + " \"last-subnet-id\": 2\n" + " }\n" + " }\n" + "}", + "'last-subnet-id' must be greater than 'first-subnet-id'" + }, + { + "Subnet-Range: all in the middle", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-id\": 10,\n" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 20," + " \"last-subnet-id\": 40" + " }\n" + " }\n" + "}", + "cannot specify both subnet-id and subnet-range" + } + }; + + for (auto test = tests.begin(); test != tests.end(); ++test) { + { + SCOPED_TRACE((*test).description_); + testCommand((*test).command_txt_, CONTROL_RESULT_ERROR,(*test).exp_response_); + } + } +} + +// Verifies result content for valid v4 statistic commands. +// These test scenarios are all valid, and not expected to throw. +TEST_F(StatCmdsTest, statLease4GetValid) { + + // Initialize lease manager. + initLeaseMgr4(); + + // Note timestamp actual values are not important but are included + // for clarity. + std::vector<TestScenario> tests = { + { + "ALL-Subnets", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " }\n" + "}", + "stat-lease4-get[all subnets]: 5 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-addresses\",\n" + " \"cumulative-assigned-addresses\",\n" + " \"assigned-addresses\", \"declined-addresses\"\n" + " ],\n" + " \"rows\": [\n" + " [ 10, 256, 300, 2, 3 ],\n" + " [ 20, 16, 10, 3, 0 ],\n" + " [ 30, 256, 0, 0, 0 ],\n" + " [ 40, 16, 4, 4, 0 ],\n" + " [ 50, 256, 2, 1, 1 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "ALL-Subnets - arguments omitted", + "{\n" + " \"command\": \"stat-lease4-get\"\n" + "}", + "stat-lease4-get[all subnets]: 5 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-addresses\",\n" + " \"cumulative-assigned-addresses\",\n" + " \"assigned-addresses\", \"declined-addresses\"\n" + " ],\n" + " \"rows\": [\n" + " [ 10, 256, 300, 2, 3 ],\n" + " [ 20, 16, 10, 3, 0 ],\n" + " [ 30, 256, 0, 0, 0 ],\n" + " [ 40, 16, 4, 4, 0 ],\n" + " [ 50, 256, 2, 1, 1 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Single-Subnet", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-id\": 20" + " }\n" + "}", + "stat-lease4-get[subnet-id=20]: 1 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-addresses\",\n" + " \"cumulative-assigned-addresses\",\n" + " \"assigned-addresses\", \"declined-addresses\"\n" + " ],\n" + " \"rows\": [\n" + " [ 20, 16, 10, 3, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Subnet-Range: beginning to middle", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 10," + " \"last-subnet-id\": 30" + " }\n" + " }\n" + "}", + "stat-lease4-get[subnets 10 through 30]: 3 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-addresses\",\n" + " \"cumulative-assigned-addresses\",\n" + " \"assigned-addresses\", \"declined-addresses\"\n" + " ],\n" + " \"rows\": [\n" + " [ 10, 256, 300, 2, 3 ],\n" + " [ 20, 16, 10, 3, 0 ],\n" + " [ 30, 256, 0, 0, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Subnet-Range: all in the middle", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 20," + " \"last-subnet-id\": 40" + " }\n" + " }\n" + "}", + "stat-lease4-get[subnets 20 through 40]: 3 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-addresses\",\n" + " \"cumulative-assigned-addresses\",\n" + " \"assigned-addresses\", \"declined-addresses\"\n" + " ],\n" + " \"rows\": [\n" + " [ 20, 16, 10, 3, 0 ],\n" + " [ 30, 256, 0, 0, 0 ],\n" + " [ 40, 16, 4, 4, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Subnet-Range: middle to end", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 30," + " \"last-subnet-id\": 50" + " }\n" + " }\n" + "}", + "stat-lease4-get[subnets 30 through 50]: 3 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-addresses\",\n" + " \"cumulative-assigned-addresses\",\n" + " \"assigned-addresses\", \"declined-addresses\"\n" + " ],\n" + " \"rows\": [\n" + " [ 30, 256, 0, 0, 0 ],\n" + " [ 40, 16, 4, 4, 0 ],\n" + " [ 50, 256, 2, 1, 1 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Subnet-Range: fuzzy range", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 25," + " \"last-subnet-id\": 45" + " }\n" + " }\n" + "}", + "stat-lease4-get[subnets 25 through 45]: 2 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-addresses\",\n" + " \"cumulative-assigned-addresses\",\n" + " \"assigned-addresses\", \"declined-addresses\"\n" + " ],\n" + " \"rows\": [\n" + " [ 30, 256, 0, 0, 0 ],\n" + " [ 40, 16, 4, 4, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + } + }; + + for (auto test = tests.begin(); test != tests.end(); ++test) { + { + SCOPED_TRACE((*test).description_); + testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS, + (*test).exp_response_, (*test).exp_result_json); + } + } + +} + +// Verifies result content for valid v4 statistic commands that +// result in no matching subnets. +TEST_F(StatCmdsTest, statLease4GetSubnetsNotFound) { + + // Initialize lease manager. + initLeaseMgr4(); + + // Note timestamp actual values are not important but are included + // for clarity. + std::vector<TestScenario> tests = { + { + "Single-Subnet, undefined subnet", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-id\": 88" + " }\n" + "}", + "stat-lease4-get[subnet-id=88]: no matching data, subnet-id: 88 does not exist", + "{}" + }, + { + "Subnet-Range: empty range below", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 2," + " \"last-subnet-id\": 6" + " }\n" + " }\n" + "}", + "stat-lease4-get[subnets 2 through 6]: no matching data, selected ID range: 2 through 6 includes no known subnets", + "{}" + }, + { + "Subnet-Range: empty range above", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 200," + " \"last-subnet-id\": 600" + " }\n" + " }\n" + "}", + "stat-lease4-get[subnets 200 through 600]: no matching data, selected ID range: 200 through 600 includes no known subnets", + "{}" + } + }; + + for (auto test = tests.begin(); test != tests.end(); ++test) { + { + SCOPED_TRACE((*test).description_); + testCommand((*test).command_txt_, CONTROL_RESULT_EMPTY, + (*test).exp_response_, (*test).exp_result_json); + } + } + +} + +// Verifies detection of invalid v6 input parameters. +TEST_F(StatCmdsTest, StatLease6GetBadParams) { + // Initialize lease manager + initLeaseMgr6(); + + std::vector<TestScenario> tests = { + { + "arguments not a map", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": \"not a map\"\n" + "}", + "'arguments' parameter is not a map" + }, + { + "subnet-id 0", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-id\": 0\n" + " }\n" + "}", + "'subnet-id' parameter must be > 0" + }, + + { + "subnet-id -1", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-id\": -1\n" + " }\n" + "}", + "'subnet-id' parameter must be > 0" + }, + { + "subnet-id string", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-id\": \"boo\"\n" + " }\n" + "}", + "'subnet-id' parameter is not integer" + }, + { + "subnet-range not a map", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": -1\n" + " }\n" + "}", + "subnet-range parameter is not a map" + }, + { + "subnet-range empty", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " }\n" + " }\n" + "}", + "'first-subnet-id' parameter missing or not an integer" + }, + { + "first-subnet-id string", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": \"boo\"\n" + " }\n" + " }\n" + "}", + "'first-subnet-id' parameter missing or not an integer" + }, + { + "first-subnet-id < 0", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": -77\n" + " }\n" + " }\n" + "}", + "'first-subnet-id' parameter must be > 0" + }, + { + "last-subnet-id missing", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 10\n" + " }\n" + " }\n" + "}", + "'last-subnet-id' parameter missing or not an integer" + }, + { + "last-subnet-id string", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 10,\n" + " \"last-subnet-id\": \"boo\"\n" + " }\n" + " }\n" + "}", + "'last-subnet-id' parameter missing or not an integer" + }, + { + "last-subnet-id < 0", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 10,\n" + " \"last-subnet-id\": -1\n" + " }\n" + " }\n" + "}", + "'last-subnet-id' parameter must be > 0" + }, + { + "invalid range", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 50,\n" + " \"last-subnet-id\": 2\n" + " }\n" + " }\n" + "}", + "'last-subnet-id' must be greater than 'first-subnet-id'" + }, + { + "both subnet and range", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-id\": 10,\n" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 20," + " \"last-subnet-id\": 40" + " }\n" + " }\n" + "}", + "cannot specify both subnet-id and subnet-range" + } + }; + + for (auto test = tests.begin(); test != tests.end(); ++test) { + { + SCOPED_TRACE((*test).description_); + testCommand((*test).command_txt_, CONTROL_RESULT_ERROR,(*test).exp_response_); + } + } +} + +// Verifies result content for valid v6 statistic commands. +// These test scenarios are all valid, and not expected to throw. +TEST_F(StatCmdsTest, statLease6GetValid) { + + // Initialize lease manager + initLeaseMgr6(); + + // Note timestamp actual values are not important but are included + // for clarity. + std::vector<TestScenario> tests = { + { + "ALL-Subnets6", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " }\n" + "}", + "stat-lease6-get[all subnets]: 5 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-nas\",\n" + " \"cumulative-assigned-nas\", \"assigned-nas\",\n" + " \"declined-nas\", \"total-pds\",\n" + " \"cumulative-assigned-pds\", \"assigned-pds\"\n" + " ],\n" + " \"rows\": [\n" + " [ 10, 65536, 10000, 2, 3, 0, 0, 0 ],\n" + " [ 20, 16777216, 10, 3, 0, 0, 0, 0 ],\n" + " [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n" + " [ 40, 16777216, 0, 0, 0, 0, 0, 0 ],\n" + " [ 50, 0, 0, 0, 0, 65536, 1000, 2 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "ALL-Subnets6 arguments omitted", + "{\n" + " \"command\": \"stat-lease6-get\"\n" + "}", + "stat-lease6-get[all subnets]: 5 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-nas\",\n" + " \"cumulative-assigned-nas\", \"assigned-nas\",\n" + " \"declined-nas\", \"total-pds\",\n" + " \"cumulative-assigned-pds\", \"assigned-pds\"\n" + " ],\n" + " \"rows\": [\n" + " [ 10, 65536, 10000, 2, 3, 0, 0, 0 ],\n" + " [ 20, 16777216, 10, 3, 0, 0, 0, 0 ],\n" + " [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n" + " [ 40, 16777216, 0, 0, 0, 0, 0, 0 ],\n" + " [ 50, 0, 0, 0, 0, 65536, 1000, 2 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Single-Subnet6", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-id\": 20" + " }\n" + "}", + "stat-lease6-get[subnet-id=20]: 1 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-nas\",\n" + " \"cumulative-assigned-nas\", \"assigned-nas\",\n" + " \"declined-nas\", \"total-pds\",\n" + " \"cumulative-assigned-pds\", \"assigned-pds\"\n" + " ],\n" + " \"rows\": [\n" + " [ 20, 16777216, 10, 3, 0, 0, 0, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Subnet-Range6: beginning to middle", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 10," + " \"last-subnet-id\": 30" + " }\n" + " }\n" + "}", + "stat-lease6-get[subnets 10 through 30]: 3 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-nas\",\n" + " \"cumulative-assigned-nas\", \"assigned-nas\",\n" + " \"declined-nas\", \"total-pds\",\n" + " \"cumulative-assigned-pds\", \"assigned-pds\"\n" + " ],\n" + " \"rows\": [\n" + " [ 10, 65536, 10000, 2, 3, 0, 0, 0 ],\n" + " [ 20, 16777216, 10, 3, 0, 0, 0, 0 ],\n" + " [ 30, 16, 2, 1, 1, 65536, 4, 3 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Subnet-Range6: all in the middle", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 20," + " \"last-subnet-id\": 40" + " }\n" + " }\n" + "}", + "stat-lease6-get[subnets 20 through 40]: 3 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-nas\",\n" + " \"cumulative-assigned-nas\", \"assigned-nas\",\n" + " \"declined-nas\", \"total-pds\",\n" + " \"cumulative-assigned-pds\", \"assigned-pds\"\n" + " ],\n" + " \"rows\": [\n" + " [ 20, 16777216, 10, 3, 0, 0, 0, 0 ],\n" + " [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n" + " [ 40, 16777216, 0, 0, 0, 0, 0, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Subnet-Range6: middle to end", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 30," + " \"last-subnet-id\": 50" + " }\n" + " }\n" + "}", + "stat-lease6-get[subnets 30 through 50]: 3 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-nas\",\n" + " \"cumulative-assigned-nas\", \"assigned-nas\",\n" + " \"declined-nas\", \"total-pds\",\n" + " \"cumulative-assigned-pds\", \"assigned-pds\"\n" + " ],\n" + " \"rows\": [\n" + " [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n" + " [ 40, 16777216, 0, 0, 0, 0, 0, 0 ],\n" + " [ 50, 0, 0, 0, 0, 65536, 1000, 2 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + }, + { + "Subnet-Range6: fuzzy range", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 25," + " \"last-subnet-id\": 45" + " }\n" + " }\n" + "}", + "stat-lease6-get[subnets 25 through 45]: 2 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-nas\",\n" + " \"cumulative-assigned-nas\", \"assigned-nas\",\n" + " \"declined-nas\", \"total-pds\",\n" + " \"cumulative-assigned-pds\", \"assigned-pds\"\n" + " ],\n" + " \"rows\": [\n" + " [ 30, 16, 2, 1, 1, 65536, 4, 3 ],\n" + " [ 40, 16777216, 0, 0, 0, 0, 0, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + } + }; + + for (auto test = tests.begin(); test != tests.end(); ++test) { + { + SCOPED_TRACE((*test).description_); + testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS, + (*test).exp_response_, (*test).exp_result_json); + } + } + +} + +// Verifies result content for valid v6 statistic commands that +// result in no matching subnets. +TEST_F(StatCmdsTest, statLease6GetSubnetsNotFound) { + + // Initialize lease manager + initLeaseMgr6(); + + // Note timestamp actual values are not important but are included + // for clarity. + std::vector<TestScenario> tests = { + { + "Single-Subnet6, undefined subnet", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-id\": 88" + " }\n" + "}", + "stat-lease6-get[subnet-id=88]: no matching data, subnet-id: 88 does not exist", + "{}" + }, + { + "Subnet-Range6: empty range below", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 2," + " \"last-subnet-id\": 6" + " }\n" + " }\n" + "}", + "stat-lease6-get[subnets 2 through 6]: no matching data, selected ID range: 2 through 6 includes no known subnets", + "{}" + }, + { + "Subnet-Range6: empty range above", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " \"subnet-range\": {\n" + " \"first-subnet-id\": 200," + " \"last-subnet-id\": 600" + " }\n" + " }\n" + "}", + "stat-lease6-get[subnets 200 through 600]: no matching data, selected ID range: 200 through 600 includes no known subnets", + "{}" + } + }; + + for (auto test = tests.begin(); test != tests.end(); ++test) { + { + SCOPED_TRACE((*test).description_); + testCommand((*test).command_txt_, CONTROL_RESULT_EMPTY, + (*test).exp_response_, (*test).exp_result_json); + } + } +} + +// Verifies that statistics for v4 subnets which no longer +// exist are dropped from the result sets. +TEST_F(StatCmdsTest, statLease4OrphanedStats) { + + // Initialize lease manager. + initLeaseMgr4(); + + // Now remove subnets 10, 30, and 50 thereby orphaning their leases. + CfgMgr& cfg_mgr = CfgMgr::instance(); + CfgSubnets4Ptr subnets = cfg_mgr.getCurrentCfg()->getCfgSubnets4(); + ASSERT_NO_THROW_LOG(subnets->del(10)); + ASSERT_NO_THROW_LOG(subnets->del(30)); + ASSERT_NO_THROW_LOG(subnets->del(50)); + cfg_mgr.commit(); + + // Note timestamp actual values are not important but are included + // for clarity. + std::vector<TestScenario> tests = { + { + "ALL-Subnets", + "{\n" + " \"command\": \"stat-lease4-get\",\n" + " \"arguments\": {" + " }\n" + "}", + "stat-lease4-get[all subnets]: 2 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-addresses\",\n" + " \"cumulative-assigned-addresses\",\n" + " \"assigned-addresses\", \"declined-addresses\"\n" + " ],\n" + " \"rows\": [\n" + " [ 20, 16, 0, 3, 0 ],\n" + " [ 40, 16, 0, 4, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + } + }; + + for (auto test = tests.begin(); test != tests.end(); ++test) { + { + SCOPED_TRACE((*test).description_); + testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS, + (*test).exp_response_, (*test).exp_result_json); + } + } +} + +// Verifies that statistics for v6 subnets which no longer +// exist are dropped from the result sets. +TEST_F(StatCmdsTest, statLease6OrphanedStats) { + + // Initialize lease manager. + initLeaseMgr6(); + + // Now remove subnets 10, 30, and 50 thereby orphaning their leases. + CfgMgr& cfg_mgr = CfgMgr::instance(); + CfgSubnets6Ptr subnets = cfg_mgr.getCurrentCfg()->getCfgSubnets6(); + ASSERT_NO_THROW_LOG(subnets->del(10)); + ASSERT_NO_THROW_LOG(subnets->del(30)); + ASSERT_NO_THROW_LOG(subnets->del(50)); + cfg_mgr.commit(); + + // Note timestamp actual values are not important but are included + // for clarity. + std::vector<TestScenario> tests = { + { + "ALL-Subnets", + "{\n" + " \"command\": \"stat-lease6-get\",\n" + " \"arguments\": {" + " }\n" + "}", + "stat-lease6-get[all subnets]: 2 rows found", + "{\n" + "\"result-set\": {\n" + " \"columns\": [\n" + " \"subnet-id\", \"total-nas\",\n" + " \"cumulative-assigned-nas\", \"assigned-nas\",\n" + " \"declined-nas\", \"total-pds\",\n" + " \"cumulative-assigned-pds\", \"assigned-pds\"\n" + " ],\n" + " \"rows\": [\n" + " [ 20, 16777216, 0, 3, 0, 0, 0, 0 ],\n" + " [ 40, 16777216, 0, 0, 0, 0, 0, 0 ]\n" + " ],\n" + " \"timestamp\": \"2018-05-04 15:03:37.000000\" }\n" + "}\n" + } + }; + + for (auto test = tests.begin(); test != tests.end(); ++test) { + { + SCOPED_TRACE((*test).description_); + testCommand((*test).command_txt_, CONTROL_RESULT_SUCCESS, + (*test).exp_response_, (*test).exp_result_json); + } + } +} + +} // end of anonymous namespace + |