summaryrefslogtreecommitdiffstats
path: root/src/lib/mysql/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/mysql/tests')
-rw-r--r--src/lib/mysql/tests/Makefile.am40
-rw-r--r--src/lib/mysql/tests/Makefile.in1006
-rw-r--r--src/lib/mysql/tests/mysql_binding_unittest.cc249
-rw-r--r--src/lib/mysql/tests/mysql_connection_unittest.cc789
-rw-r--r--src/lib/mysql/tests/run_unittests.cc20
5 files changed, 2104 insertions, 0 deletions
diff --git a/src/lib/mysql/tests/Makefile.am b/src/lib/mysql/tests/Makefile.am
new file mode 100644
index 0000000..f11254e
--- /dev/null
+++ b/src/lib/mysql/tests/Makefile.am
@@ -0,0 +1,40 @@
+SUBDIRS = .
+
+AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES) $(MYSQL_CPPFLAGS)
+
+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 += libmysql_unittests
+
+libmysql_unittests_SOURCES = mysql_binding_unittest.cc
+libmysql_unittests_SOURCES += mysql_connection_unittest.cc
+libmysql_unittests_SOURCES += run_unittests.cc
+
+libmysql_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+libmysql_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) $(MYSQL_LIBS)
+
+libmysql_unittests_LDADD = $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la
+libmysql_unittests_LDADD += $(top_builddir)/src/lib/mysql/libkea-mysql.la
+libmysql_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
+libmysql_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+libmysql_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+libmysql_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+libmysql_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+libmysql_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+libmysql_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)
+
+endif
+
+noinst_PROGRAMS = $(TESTS)
diff --git a/src/lib/mysql/tests/Makefile.in b/src/lib/mysql/tests/Makefile.in
new file mode 100644
index 0000000..d9ae160
--- /dev/null
+++ b/src/lib/mysql/tests/Makefile.in
@@ -0,0 +1,1006 @@
+# 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 = libmysql_unittests
+noinst_PROGRAMS = $(am__EXEEXT_2)
+subdir = src/lib/mysql/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 = libmysql_unittests$(EXEEXT)
+am__EXEEXT_2 = $(am__EXEEXT_1)
+PROGRAMS = $(noinst_PROGRAMS)
+am__libmysql_unittests_SOURCES_DIST = mysql_binding_unittest.cc \
+ mysql_connection_unittest.cc run_unittests.cc
+@HAVE_GTEST_TRUE@am_libmysql_unittests_OBJECTS = libmysql_unittests-mysql_binding_unittest.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ libmysql_unittests-mysql_connection_unittest.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ libmysql_unittests-run_unittests.$(OBJEXT)
+libmysql_unittests_OBJECTS = $(am_libmysql_unittests_OBJECTS)
+am__DEPENDENCIES_1 =
+@HAVE_GTEST_TRUE@libmysql_unittests_DEPENDENCIES = $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la \
+@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/mysql/libkea-mysql.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/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_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 =
+libmysql_unittests_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(AM_CXXFLAGS) $(CXXFLAGS) $(libmysql_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)/libmysql_unittests-mysql_binding_unittest.Po \
+ ./$(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Po \
+ ./$(DEPDIR)/libmysql_unittests-run_unittests.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 = $(libmysql_unittests_SOURCES)
+DIST_SOURCES = $(am__libmysql_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=''; \
+ grn=''; \
+ lgn=''; \
+ blu=''; \
+ mgn=''; \
+ brg=''; \
+ std=''; \
+ 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 \
+ $(BOOST_INCLUDES) $(MYSQL_CPPFLAGS)
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+@USE_STATIC_LINK_TRUE@AM_LDFLAGS = -static
+CLEANFILES = *.gcno *.gcda
+TESTS_ENVIRONMENT = \
+ $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+
+@HAVE_GTEST_TRUE@libmysql_unittests_SOURCES = \
+@HAVE_GTEST_TRUE@ mysql_binding_unittest.cc \
+@HAVE_GTEST_TRUE@ mysql_connection_unittest.cc run_unittests.cc
+@HAVE_GTEST_TRUE@libmysql_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+@HAVE_GTEST_TRUE@libmysql_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS) $(MYSQL_LIBS)
+@HAVE_GTEST_TRUE@libmysql_unittests_LDADD = $(top_builddir)/src/lib/mysql/testutils/libmysqltest.la \
+@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/mysql/libkea-mysql.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/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) $(BOOST_LIBS) \
+@HAVE_GTEST_TRUE@ $(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/mysql/tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/lib/mysql/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
+
+libmysql_unittests$(EXEEXT): $(libmysql_unittests_OBJECTS) $(libmysql_unittests_DEPENDENCIES) $(EXTRA_libmysql_unittests_DEPENDENCIES)
+ @rm -f libmysql_unittests$(EXEEXT)
+ $(AM_V_CXXLD)$(libmysql_unittests_LINK) $(libmysql_unittests_OBJECTS) $(libmysql_unittests_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmysql_unittests-mysql_binding_unittest.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libmysql_unittests-run_unittests.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 $@ $<
+
+libmysql_unittests-mysql_binding_unittest.o: mysql_binding_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libmysql_unittests-mysql_binding_unittest.o -MD -MP -MF $(DEPDIR)/libmysql_unittests-mysql_binding_unittest.Tpo -c -o libmysql_unittests-mysql_binding_unittest.o `test -f 'mysql_binding_unittest.cc' || echo '$(srcdir)/'`mysql_binding_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmysql_unittests-mysql_binding_unittest.Tpo $(DEPDIR)/libmysql_unittests-mysql_binding_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='mysql_binding_unittest.cc' object='libmysql_unittests-mysql_binding_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) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libmysql_unittests-mysql_binding_unittest.o `test -f 'mysql_binding_unittest.cc' || echo '$(srcdir)/'`mysql_binding_unittest.cc
+
+libmysql_unittests-mysql_binding_unittest.obj: mysql_binding_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libmysql_unittests-mysql_binding_unittest.obj -MD -MP -MF $(DEPDIR)/libmysql_unittests-mysql_binding_unittest.Tpo -c -o libmysql_unittests-mysql_binding_unittest.obj `if test -f 'mysql_binding_unittest.cc'; then $(CYGPATH_W) 'mysql_binding_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/mysql_binding_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmysql_unittests-mysql_binding_unittest.Tpo $(DEPDIR)/libmysql_unittests-mysql_binding_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='mysql_binding_unittest.cc' object='libmysql_unittests-mysql_binding_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) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libmysql_unittests-mysql_binding_unittest.obj `if test -f 'mysql_binding_unittest.cc'; then $(CYGPATH_W) 'mysql_binding_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/mysql_binding_unittest.cc'; fi`
+
+libmysql_unittests-mysql_connection_unittest.o: mysql_connection_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libmysql_unittests-mysql_connection_unittest.o -MD -MP -MF $(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Tpo -c -o libmysql_unittests-mysql_connection_unittest.o `test -f 'mysql_connection_unittest.cc' || echo '$(srcdir)/'`mysql_connection_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Tpo $(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='mysql_connection_unittest.cc' object='libmysql_unittests-mysql_connection_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) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libmysql_unittests-mysql_connection_unittest.o `test -f 'mysql_connection_unittest.cc' || echo '$(srcdir)/'`mysql_connection_unittest.cc
+
+libmysql_unittests-mysql_connection_unittest.obj: mysql_connection_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libmysql_unittests-mysql_connection_unittest.obj -MD -MP -MF $(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Tpo -c -o libmysql_unittests-mysql_connection_unittest.obj `if test -f 'mysql_connection_unittest.cc'; then $(CYGPATH_W) 'mysql_connection_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/mysql_connection_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Tpo $(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='mysql_connection_unittest.cc' object='libmysql_unittests-mysql_connection_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) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libmysql_unittests-mysql_connection_unittest.obj `if test -f 'mysql_connection_unittest.cc'; then $(CYGPATH_W) 'mysql_connection_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/mysql_connection_unittest.cc'; fi`
+
+libmysql_unittests-run_unittests.o: run_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libmysql_unittests-run_unittests.o -MD -MP -MF $(DEPDIR)/libmysql_unittests-run_unittests.Tpo -c -o libmysql_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libmysql_unittests-run_unittests.Tpo $(DEPDIR)/libmysql_unittests-run_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='run_unittests.cc' object='libmysql_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) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libmysql_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc
+
+libmysql_unittests-run_unittests.obj: run_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT libmysql_unittests-run_unittests.obj -MD -MP -MF $(DEPDIR)/libmysql_unittests-run_unittests.Tpo -c -o libmysql_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)/libmysql_unittests-run_unittests.Tpo $(DEPDIR)/libmysql_unittests-run_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='run_unittests.cc' object='libmysql_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) $(libmysql_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o libmysql_unittests-run_unittests.obj `if test -f 'run_unittests.cc'; then $(CYGPATH_W) 'run_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/run_unittests.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)/libmysql_unittests-mysql_binding_unittest.Po
+ -rm -f ./$(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Po
+ -rm -f ./$(DEPDIR)/libmysql_unittests-run_unittests.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)/libmysql_unittests-mysql_binding_unittest.Po
+ -rm -f ./$(DEPDIR)/libmysql_unittests-mysql_connection_unittest.Po
+ -rm -f ./$(DEPDIR)/libmysql_unittests-run_unittests.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/mysql/tests/mysql_binding_unittest.cc b/src/lib/mysql/tests/mysql_binding_unittest.cc
new file mode 100644
index 0000000..331dfa8
--- /dev/null
+++ b/src/lib/mysql/tests/mysql_binding_unittest.cc
@@ -0,0 +1,249 @@
+// Copyright (C) 2018-2019 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 <asiolink/io_address.h>
+#include <exceptions/exceptions.h>
+#include <mysql/mysql_binding.h>
+#include <util/optional.h>
+#include <boost/date_time/gregorian/gregorian.hpp>
+#include <boost/date_time/posix_time/posix_time.hpp>
+#include <gtest/gtest.h>
+
+using namespace isc;
+using namespace isc::asiolink;
+using namespace isc::data;
+using namespace isc::db;
+using namespace isc::util;
+
+namespace {
+
+// This test verifies that default string is returned if binding is null.
+TEST(MySqlBindingTest, defaultString) {
+ auto binding = MySqlBinding::createNull();
+ EXPECT_EQ("foo", binding->getStringOrDefault("foo"));
+
+ binding = MySqlBinding::createString("bar");
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_EQ("bar", binding->getStringOrDefault("foo"));
+}
+
+// This test verifies that null binding is created for unspecified string
+// and the string binding is created for a specified string.
+TEST(MySqlBindingTest, conditionalString) {
+ auto binding = MySqlBinding::condCreateString(Optional<std::string>());
+ EXPECT_TRUE(binding->amNull());
+
+ binding = MySqlBinding::condCreateString("foo");
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_EQ("foo", binding->getString());
+}
+
+// This test verifies that empty string is stored in the database.
+TEST(MySqlBindingTest, emptyString) {
+ auto binding = MySqlBinding::condCreateString(Optional<std::string>(""));
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_TRUE(binding->getString().empty());
+}
+
+// This test verifies that an error is thrown upon an attempt to use
+// invalid accessor for a string binding.
+TEST(MySqlBindingTest, stringTypeMismatch) {
+ auto binding = MySqlBinding::createString("foo");
+ EXPECT_NO_THROW(static_cast<void>(binding->getString()));
+
+ EXPECT_THROW(static_cast<void>(binding->getBlob()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint16_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getFloat()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getBool()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getTimestamp()), InvalidOperation);
+}
+
+// This test verifies that null JSON is returned if the string binding
+// is null, JSON value is returned when string value is valid JSON and
+// that exception is thrown if the string is not a valid JSON.
+TEST(MySqlBindingTest, getJSON) {
+ auto binding = MySqlBinding::createNull();
+ EXPECT_FALSE(binding->getJSON());
+
+ binding = MySqlBinding::createString("{ \"foo\": \"bar\" }");
+ auto json = binding->getJSON();
+ ASSERT_TRUE(json);
+ ASSERT_EQ(Element::map, json->getType());
+ auto foo = json->get("foo");
+ ASSERT_TRUE(foo);
+ ASSERT_EQ(Element::string, foo->getType());
+ EXPECT_EQ("bar", foo->stringValue());
+}
+
+// This test verifies that default blob is returned if binding is null.
+TEST(MySqlBindingTest, defaultBlob) {
+ std::vector<uint8_t> blob(10, 1);
+ std::vector<uint8_t> default_blob(10, 5);
+ auto binding = MySqlBinding::createNull();
+ EXPECT_EQ(default_blob, binding->getBlobOrDefault(default_blob));
+
+ binding = MySqlBinding::createBlob(blob.begin(), blob.end());
+ EXPECT_EQ(blob, binding->getBlobOrDefault(default_blob));
+}
+
+// This test verifies that an error is thrown upon an attempt to use
+// invalid accessor for a blob binding.
+TEST(MySqlBindingTest, blobTypeMismatch) {
+ std::vector<uint8_t> blob(10, 1);
+ auto binding = MySqlBinding::createBlob(blob.begin(), blob.end());
+ EXPECT_NO_THROW(static_cast<void>(binding->getBlob()));
+
+ EXPECT_THROW(static_cast<void>(binding->getString()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint16_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getFloat()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getBool()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getTimestamp()), InvalidOperation);
+}
+
+// This test verifies that default number is returned if binding is null.
+TEST(MySqlBindingTest, defaultInteger) {
+ auto binding = MySqlBinding::createNull();
+ ASSERT_TRUE(binding->amNull());
+ EXPECT_EQ(123, binding->getIntegerOrDefault<uint32_t>(123));
+
+ binding = MySqlBinding::createInteger<uint32_t>(1024);
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_EQ(1024, binding->getIntegerOrDefault<uint32_t>(123));
+}
+
+// This test verifies that null binding is created for unspecified number
+// and the integer binding is created for a specified number.
+TEST(MySqlBindingTest, conditionalInteger) {
+ auto binding = MySqlBinding::condCreateInteger<uint16_t>(Optional<uint16_t>());
+ EXPECT_TRUE(binding->amNull());
+
+ binding = MySqlBinding::condCreateInteger<uint16_t>(1);
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_EQ(1, binding->getInteger<uint16_t>());
+}
+
+// This test verifies that an error is thrown upon an attempt to use
+// invalid accessor for an integer binding.
+TEST(MySqlBindingTest, integerTypeMismatch) {
+ auto binding = MySqlBinding::createInteger<uint32_t>(123);
+ EXPECT_NO_THROW(static_cast<void>(binding->getInteger<uint32_t>()));
+
+ EXPECT_THROW(static_cast<void>(binding->getString()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getBlob()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint8_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint16_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getFloat()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getBool()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getTimestamp()), InvalidOperation);
+}
+
+// This test verifies that null binding is created for unspecified floating
+// point value and the float binding is created for the specified value.
+TEST(MySqlBindingTest, conditionalFloat) {
+ auto binding = MySqlBinding::condCreateFloat(Optional<float>());
+ EXPECT_TRUE(binding->amNull());
+
+ binding = MySqlBinding::condCreateFloat<float>(1.567f);
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_EQ(1.567f, binding->getFloat());
+}
+
+// This test verifies that an error is thrown upon an attempt to use
+// invalid accessor for a float binding.
+TEST(MySqlBindingTest, floatTypeMismatch) {
+ auto binding = MySqlBinding::createFloat(123.123f);
+ EXPECT_NO_THROW(static_cast<void>(binding->getFloat()));
+
+ EXPECT_THROW(static_cast<void>(binding->getString()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getBlob()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint8_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint16_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint32_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getBool()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getTimestamp()), InvalidOperation);
+}
+
+// This test verifies that null binding is created for unspecified boolean
+// value and the uint8_t binding is created for a specified boolean
+// value.
+TEST(MySqlBindingTest, conditionalBoolean) {
+ auto binding = MySqlBinding::condCreateBool(Optional<bool>());
+ EXPECT_TRUE(binding->amNull());
+
+ binding = MySqlBinding::condCreateBool(false);
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_FALSE(binding->getBool());
+
+ binding = MySqlBinding::condCreateBool(true);
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_TRUE(binding->getBool());
+}
+
+// This test verifies that an error is thrown upon an attempt to use
+// invalid accessor for a float binding.
+TEST(MySqlBindingTest, booleanTypeMismatch) {
+ auto binding = MySqlBinding::createBool(false);
+ EXPECT_NO_THROW(static_cast<void>(binding->getBool()));
+ EXPECT_NO_THROW(static_cast<void>(binding->getInteger<uint8_t>()));
+
+ EXPECT_THROW(static_cast<void>(binding->getString()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getBlob()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint16_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getInteger<uint32_t>()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getFloat()), InvalidOperation);
+ EXPECT_THROW(static_cast<void>(binding->getTimestamp()), InvalidOperation);
+}
+
+// This test verifies that null binding is created for unspecified address
+// and the uint32_t binding is created for the specified address.
+TEST(MySqlBindingTest, conditionalIPv4Address) {
+ auto binding = MySqlBinding::condCreateIPv4Address(Optional<IOAddress>());
+ EXPECT_TRUE(binding->amNull());
+
+ binding = MySqlBinding::condCreateIPv4Address(IOAddress("192.0.2.1"));
+ ASSERT_FALSE(binding->amNull());
+ EXPECT_EQ(0xC0000201, binding->getInteger<uint32_t>());
+
+ EXPECT_THROW(MySqlBinding::condCreateIPv4Address(IOAddress("2001:db8:1::1")),
+ isc::BadValue);
+}
+
+// This test verifies that default timestamp is returned if binding is null.
+TEST(MySqlBindingTest, defaultTimestamp) {
+ boost::posix_time::ptime current_time = boost::posix_time::second_clock::local_time();
+ boost::posix_time::ptime past_time = current_time - boost::posix_time::hours(1);
+
+ auto binding = MySqlBinding::createNull();
+ EXPECT_TRUE(past_time == binding->getTimestampOrDefault(past_time));
+
+ binding = MySqlBinding::createTimestamp(current_time);
+ EXPECT_TRUE(current_time == binding->getTimestampOrDefault(past_time));
+}
+
+// This test verifies that the binding preserves fractional seconds in
+// millisecond precision.
+/// @todo This test is disabled until we decide that the minimum
+/// supported MySQL version has a fractional seconds precision.
+TEST(MySqlBindingTest, DISABLED_millisecondTimestampPrecision) {
+ // Set timestamp of 2019-01-28 01:12:10.123
+
+ // Fractional part depends on the clock resolution.
+ long fractional = 123*(boost::posix_time::time_duration::ticks_per_second()/1000);
+ boost::posix_time::ptime
+ test_time(boost::gregorian::date(2019, boost::gregorian::Jan, 28),
+ boost::posix_time::time_duration(1, 12, 10, fractional));
+
+ auto binding = MySqlBinding::createTimestamp(test_time);
+
+ boost::posix_time::ptime returned_test_time = binding->getTimestamp();
+
+ EXPECT_EQ(returned_test_time, test_time);
+}
+
+}
+
diff --git a/src/lib/mysql/tests/mysql_connection_unittest.cc b/src/lib/mysql/tests/mysql_connection_unittest.cc
new file mode 100644
index 0000000..19d1a6a
--- /dev/null
+++ b/src/lib/mysql/tests/mysql_connection_unittest.cc
@@ -0,0 +1,789 @@
+// Copyright (C) 2018-2022 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 <mysql/mysql_connection.h>
+#include <mysql/testutils/mysql_schema.h>
+#include <testutils/gtest_utils.h>
+
+#include <array>
+
+#include <gtest/gtest.h>
+
+#include <boost/date_time/posix_time/posix_time.hpp>
+
+using namespace isc::db;
+using namespace isc::db::test;
+
+namespace {
+
+/// @brief RAII wrapper over MYSQL_RES obtained from MySQL library functions like
+/// mysql_use_result().
+struct MySqlResult {
+ MySqlResult(MYSQL_RES* result) : result_(result) {
+ }
+
+ ~MySqlResult() {
+ mysql_free_result(result_);
+ }
+
+ MYSQL_RES* const result_;
+};
+
+/// @brief Test fixture class for @c MySqlConnection class.
+class MySqlConnectionTest : public ::testing::Test {
+public:
+
+ /// @brief Indexes of prepared statements used within the tests.
+ enum StatementIndex {
+ GET_BY_INT_VALUE,
+ DELETE_BY_INT_VALUE,
+ INSERT_VALUE,
+ NUM_STATEMENTS
+ };
+
+ /// @brief Array of tagged MySQL statements.
+ typedef std::array<TaggedStatement, NUM_STATEMENTS> TaggedStatementArray;
+
+ /// @brief Prepared MySQL statements used in the tests.
+ TaggedStatementArray tagged_statements = {{
+ { GET_BY_INT_VALUE,
+ "SELECT tinyint_value, int_value, bigint_value, string_value,"
+ " blob_value, timestamp_value"
+ " FROM mysql_connection_test WHERE int_value = ?" },
+
+ { DELETE_BY_INT_VALUE,
+ "DELETE FROM mysql_connection_test WHERE int_value = ?" },
+
+ { INSERT_VALUE,
+ "INSERT INTO mysql_connection_test (tinyint_value, int_value,"
+ "bigint_value, string_value, blob_value, timestamp_value)"
+ " VALUES (?, ?, ?, ?, ?, ?)" }
+ }};
+
+ /// @brief Constructor.
+ ///
+ /// Re-creates database schema, opens new database connection and creates
+ /// prepared statements used in tests. Created schema contains a test
+ /// table @c mysql_connection_test which includes 6 columns of various
+ /// types.
+ MySqlConnectionTest(bool const primary_key = false)
+ : conn_(DatabaseConnection::parse(validMySQLConnectionString())) {
+
+ try {
+ // Open new connection.
+ conn_.openDatabase();
+
+ // Create mysql_connection_test table.
+ createTestTable(primary_key);
+
+ // In Percona XtraDB cluster, you can't do much on tables with
+ // primary keys. So far the connection and the table creation have
+ // been tested. Continue only if:
+ // * we are in primary key mode
+ // * a MySQL database other than Percona is running
+ // * Percona's pxc_strict_mode is set to "DISABLED" or "PERMISSIVE"
+ // The last two checks are done with inverse logic against the two
+ // modes that restrict this: "ENFORCING" and "MASTER". This check is
+ // to be paired inside the tests without a primary key to disable
+ // those tests.
+ if (!primary_key &&
+ (showPxcStrictMode() == "ENFORCING" || showPxcStrictMode() == "MASTER")) {
+ return;
+ }
+
+ // Created prepared statements for basic queries to test table.
+ conn_.prepareStatements(tagged_statements.begin(),
+ tagged_statements.end());
+ } catch (...) {
+ std::cerr << "*** ERROR: unable to open database. The test\n"
+ "*** environment is broken and must be fixed before\n"
+ "*** the MySQL tests will run correctly.\n"
+ "*** The reason for the problem is described in the\n"
+ "*** accompanying exception output.\n";
+ throw;
+ }
+ }
+
+ /// @brief Destructor
+ ///
+ /// Removes test table from the database.
+ virtual ~MySqlConnectionTest() {
+ if (conn_.isTransactionStarted()) {
+ conn_.rollback();
+ }
+ dropTestTable();
+ }
+
+ /// @brief Creates test table @c mysql_connection_test.
+ ///
+ /// The new table contains 6 columns of various data types. All of
+ /// the columns accept null values.
+ void createTestTable(bool const primary_key = false) {
+ /// @todo TIMESTAMP value lacks sub second precision because
+ /// it is supported since MySQL 5.6.4, which is still not a
+ /// default version on some OSes. When the subsecond precision
+ /// is available on all OSes that Kea supports, the timestamp
+ /// column should be turned to TIMESTAMP(6). Until then, it
+ /// must remain TIMESTAMP.
+ runQuery("CREATE TABLE IF NOT EXISTS mysql_connection_test ("
+ "tinyint_value TINYINT " +
+ std::string(primary_key ? "PRIMARY KEY NOT NULL," : "NULL,") +
+ "int_value INT NULL,"
+ "bigint_value BIGINT NULL,"
+ "string_value TEXT NULL,"
+ "blob_value BLOB NULL,"
+ "timestamp_value TIMESTAMP NULL"
+ ")");
+ }
+
+ /// @brief Drops test table.
+ void dropTestTable() {
+ runQuery("DROP TABLE IF EXISTS mysql_connection_test");
+ }
+
+ /// @brief Runs MySQL query on the opened connection.
+ ///
+ /// @param sql Query in the textual form.
+ void runQuery(const std::string& sql) {
+ MYSQL_STMT *stmt = mysql_stmt_init(conn_.mysql_);
+ if (stmt == NULL) {
+ isc_throw(DbOperationError, "unable to allocate MySQL prepared "
+ "statement structure, reason: " << mysql_error(conn_.mysql_));
+ }
+
+ int status = mysql_stmt_prepare(stmt, sql.c_str(), sql.length());
+ if (status != 0) {
+ isc_throw(DbOperationError, "unable to prepare MySQL statement <"
+ << sql << ">, reason: " << mysql_errno(conn_.mysql_));
+ }
+
+ // Execute the prepared statement.
+ if (MysqlExecuteStatement(stmt) != 0) {
+ isc_throw(DbOperationError, "cannot execute MySQL query <"
+ << sql << ">, reason: " << mysql_errno(conn_.mysql_));
+ }
+
+ // Discard the statement and its resources
+ mysql_stmt_close(stmt);
+ }
+
+
+ /// @brief Tests inserting and retrieving data from the database.
+ ///
+ /// In this test data carried in the bindings is inserted into the database.
+ /// Then this data is retrieved from the database and compared with the
+ /// orginal.
+ ///
+ /// @param in_bindings Collection of bindings encapsulating the data to
+ /// be inserted into the database and then retrieved.
+ void testInsertSelect(const MySqlBindingCollection& in_bindings) {
+ // Expecting 6 bindings because we have 6 columns in our table.
+ ASSERT_EQ(6, in_bindings.size());
+ // We are going to select by int_value so this value must not be null.
+ ASSERT_FALSE(in_bindings[1]->amNull());
+
+ // Store data in the database.
+ ASSERT_NO_THROW_LOG(conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE,
+ in_bindings));
+
+ // Create input binding for select query.
+ MySqlBindingCollection bindings =
+ { MySqlBinding::createInteger<uint32_t>(in_bindings[1]->getInteger<uint32_t>()) };
+
+ // Also, create output (placeholder) bindings for receiving data.
+ MySqlBindingCollection out_bindings = {
+ MySqlBinding::createInteger<uint8_t>(),
+ MySqlBinding::createInteger<uint32_t>(),
+ MySqlBinding::createInteger<int64_t>(),
+ MySqlBinding::createString(512),
+ MySqlBinding::createBlob(512),
+ MySqlBinding::createTimestamp()
+ };
+
+ // Execute select statement. We expect one row to be returned. For this
+ // returned row the lambda provided as 4th argument should be executed.
+ ASSERT_NO_THROW_LOG(conn_.selectQuery(MySqlConnectionTest::GET_BY_INT_VALUE,
+ bindings, out_bindings,
+ [&](MySqlBindingCollection& out_bindings) {
+
+ // Compare received data with input data assuming they are both non-null.
+
+ if (!out_bindings[0]->amNull() && !in_bindings[0]->amNull()) {
+ EXPECT_EQ(static_cast<int>(in_bindings[0]->getInteger<uint8_t>()),
+ static_cast<int>(out_bindings[0]->getInteger<uint8_t>()));
+ }
+
+ if (!out_bindings[1]->amNull() && !in_bindings[1]->amNull()) {
+ EXPECT_EQ(in_bindings[1]->getInteger<uint32_t>(),
+ out_bindings[1]->getInteger<uint32_t>());
+ }
+
+ if (!out_bindings[2]->amNull() && !in_bindings[2]->amNull()) {
+ EXPECT_EQ(in_bindings[2]->getInteger<int64_t>(),
+ out_bindings[2]->getInteger<int64_t>());
+ }
+
+ if (!out_bindings[3]->amNull() && !in_bindings[3]->amNull()) {
+ EXPECT_EQ(in_bindings[3]->getString(),
+ out_bindings[3]->getString());
+ }
+
+ if (!out_bindings[4]->amNull() && !in_bindings[4]->amNull()) {
+ EXPECT_EQ(in_bindings[4]->getBlob(),
+ out_bindings[4]->getBlob());
+ }
+
+ if (!out_bindings[5]->amNull() && !in_bindings[5]->amNull()) {
+ EXPECT_TRUE(in_bindings[5]->getTimestamp() ==
+ out_bindings[5]->getTimestamp());
+ }
+ }));
+
+ // Make sure that null values were returned for columns for which null
+ // was set.
+ ASSERT_EQ(in_bindings.size(), out_bindings.size());
+ for (auto i = 0; i < in_bindings.size(); ++i) {
+ EXPECT_EQ(in_bindings[i]->amNull(), out_bindings[i]->amNull())
+ << "null value test failed for binding #" << i;
+ }
+ }
+
+ /// @brief Run a raw, unprepared statement and return the result.
+ ///
+ /// This is useful when running statements that can't be parameterized with a
+ /// question mark in place of a bound variable e.g. "SHOW GLOBAL VARIABLES"
+ /// and thus cannot be prepared beforehand. All the results are string, the
+ /// output should be the same as that which one would see in a mysql command
+ /// line client.
+ ///
+ /// @param statement the statement in string form
+ /// @throw DbOperationError if the statement could not be run
+ /// @return the list of rows, each row consisting of a list of values for
+ /// each column
+ std::vector<std::vector<std::string>>
+ rawStatement(std::string const& statement) const {
+ // Execute a SQL statement.
+ if (mysql_query(conn_.mysql_, statement.c_str())) {
+ isc_throw(DbOperationError,
+ statement << ": " << mysql_error(conn_.mysql_));
+ }
+
+ // Get a result set.
+ MySqlResult result(mysql_use_result(conn_.mysql_));
+
+ // Fetch a result set.
+ std::vector<std::vector<std::string>> output;
+ size_t r(0);
+ MYSQL_ROW row;
+ size_t const column_count(mysql_num_fields(result.result_));
+ while ((row = mysql_fetch_row(result.result_)) != NULL) {
+ output.push_back(std::vector<std::string>());
+ for (size_t i = 0; i < column_count; ++i) {
+ output[r].push_back(row[i]);
+ }
+ ++r;
+ }
+
+ return output;
+ }
+
+ /// @brief Get pxc_strict_mode global variable from the database.
+ /// For Percona, they can be: DISABLED, PERMISSIVE, ENFORCING, MASTER.
+ std::string showPxcStrictMode() {
+ // Store in a static variable so this only runs once per gtest binary
+ // invocation.
+ static std::string const pxc_strict_mode([&]() -> std::string {
+ // Execute select statement. We expect one row to be returned. For
+ // this returned row the lambda provided as 4th argument should be
+ // executed.
+ std::vector<std::vector<std::string>> const result(
+ rawStatement("SHOW GLOBAL VARIABLES LIKE 'pxc_strict_mode'"));
+ if (result.size() < 1 || result[0].size() < 2) {
+ // Not Percona
+ return "";
+ }
+
+ return result[0][1];
+ }());
+ return pxc_strict_mode;
+ }
+
+ /// *** Test definitions start here. Tests are invoked ***
+ /// *** multiple times further below in different test fixtures. ***
+
+ /// @brief Test that non-null values of various types can be inserted and
+ /// retrieved from the dataabse.
+ void select() {
+ std::string blob = "myblob";
+ MySqlBindingCollection in_bindings = {
+ MySqlBinding::createInteger<uint8_t>(123),
+ MySqlBinding::createInteger<uint32_t>(1024),
+ MySqlBinding::createInteger<int64_t>(-4096),
+ MySqlBinding::createString("shellfish"),
+ MySqlBinding::createBlob(blob.begin(), blob.end()),
+ /// @todo Change it to microsec_clock once we transition to
+ /// subsecond precision.
+ MySqlBinding::createTimestamp(
+ boost::posix_time::second_clock::local_time()),
+ };
+
+ testInsertSelect(in_bindings);
+ }
+
+ /// @brief Test that null value can be inserted to a column having numeric
+ /// type and retrieved.
+ void selectNullInteger() {
+ std::string blob = "myblob";
+ MySqlBindingCollection in_bindings = {
+ MySqlBinding::createInteger<uint8_t>(123),
+ MySqlBinding::createInteger<uint32_t>(1024),
+ MySqlBinding::createNull(),
+ MySqlBinding::createString("shellfish"),
+ MySqlBinding::createBlob(blob.begin(), blob.end()),
+ /// @todo Change it to microsec_clock once we transition to
+ /// subsecond precision.
+ MySqlBinding::createTimestamp(
+ boost::posix_time::second_clock::local_time()),
+ };
+
+ testInsertSelect(in_bindings);
+ }
+
+ /// @brief Test that null value can be inserted to a column having string
+ /// type and retrieved.
+ void selectNullString() {
+ std::string blob = "myblob";
+
+ MySqlBindingCollection in_bindings = {
+ MySqlBinding::createInteger<uint8_t>(123),
+ MySqlBinding::createInteger<uint32_t>(1024),
+ MySqlBinding::createInteger<int64_t>(-4096),
+ MySqlBinding::createNull(),
+ MySqlBinding::createBlob(blob.begin(), blob.end()),
+ /// @todo Change it to microsec_clock once we transition to
+ /// subsecond precision.
+ MySqlBinding::createTimestamp(
+ boost::posix_time::second_clock::local_time()),
+ };
+
+ testInsertSelect(in_bindings);
+ }
+
+ /// @brief Test that null value can be inserted to a column having blob type
+ /// and retrieved.
+ void selectNullBlob() {
+ MySqlBindingCollection in_bindings = {
+ MySqlBinding::createInteger<uint8_t>(123),
+ MySqlBinding::createInteger<uint32_t>(1024),
+ MySqlBinding::createInteger<int64_t>(-4096),
+ MySqlBinding::createString("shellfish"),
+ MySqlBinding::createNull(),
+ /// @todo Change it to microsec_clock once we transition to
+ /// subsecond precision.
+ MySqlBinding::createTimestamp(
+ boost::posix_time::second_clock::local_time()),
+ };
+
+ testInsertSelect(in_bindings);
+ }
+
+ /// @brief Test that null value can be inserted to a column having timestamp
+ /// type and retrieved.
+ void selectNullTimestamp() {
+ std::string blob = "myblob";
+ MySqlBindingCollection in_bindings = {
+ MySqlBinding::createInteger<uint8_t>(123),
+ MySqlBinding::createInteger<uint32_t>(1024),
+ MySqlBinding::createInteger<int64_t>(-4096),
+ MySqlBinding::createString("shellfish"),
+ MySqlBinding::createBlob(blob.begin(), blob.end()),
+ MySqlBinding::createNull(),
+ };
+
+ testInsertSelect(in_bindings);
+ }
+
+ /// @brief Test that empty string and empty blob can be inserted to a
+ /// database.
+ void selectEmptyStringBlob() {
+ std::string blob = "";
+ MySqlBindingCollection in_bindings = {
+ MySqlBinding::createInteger<uint8_t>(123),
+ MySqlBinding::createInteger<uint32_t>(1024),
+ MySqlBinding::createInteger<int64_t>(-4096),
+ MySqlBinding::createString(""),
+ MySqlBinding::createBlob(blob.begin(), blob.end()),
+ /// @todo Change it to microsec_clock once we transition to
+ /// subsecond precision.
+ MySqlBinding::createTimestamp(
+ boost::posix_time::second_clock::local_time()),
+ };
+
+ testInsertSelect(in_bindings);
+ }
+
+ /// @brief Test that a row can be deleted from the database.
+ void deleteByValue() {
+ // Insert a row with numeric values.
+ MySqlBindingCollection in_bindings = {
+ MySqlBinding::createInteger<uint8_t>(123),
+ MySqlBinding::createInteger<uint32_t>(1024),
+ MySqlBinding::createInteger<int64_t>(-4096),
+ MySqlBinding::createNull(),
+ MySqlBinding::createNull(),
+ MySqlBinding::createNull(),
+ };
+
+ ASSERT_NO_THROW_LOG(
+ conn_.insertQuery(MySqlConnectionTest::INSERT_VALUE, in_bindings));
+
+ // This variable will be checked to see if the row has been deleted
+ // from the database.
+ bool deleted = false;
+
+ // Execute delete query but use int_value of non existing row.
+ // The row should not be deleted.
+ in_bindings = {MySqlBinding::createInteger<uint32_t>(1)};
+ ASSERT_NO_THROW_LOG(
+ deleted = conn_.updateDeleteQuery(
+ MySqlConnectionTest::DELETE_BY_INT_VALUE, in_bindings));
+ ASSERT_FALSE(deleted);
+
+ // This time use the correct value.
+ in_bindings = {MySqlBinding::createInteger<uint32_t>(1024)};
+ ASSERT_NO_THROW_LOG(
+ deleted = conn_.updateDeleteQuery(
+ MySqlConnectionTest::DELETE_BY_INT_VALUE, in_bindings));
+ // The row should have been deleted.
+ ASSERT_TRUE(deleted);
+
+ // Let's confirm that it has been deleted by issuing a select query.
+ MySqlBindingCollection out_bindings = {
+ MySqlBinding::createInteger<uint8_t>(),
+ MySqlBinding::createInteger<uint32_t>(),
+ MySqlBinding::createInteger<int64_t>(),
+ MySqlBinding::createString(512),
+ MySqlBinding::createBlob(512),
+ MySqlBinding::createTimestamp(),
+ };
+
+ ASSERT_NO_THROW_LOG(conn_.selectQuery(MySqlConnectionTest::GET_BY_INT_VALUE,
+ in_bindings, out_bindings,
+ [&deleted](MySqlBindingCollection&) {
+ // This will be executed if the
+ // row is returned as a result of
+ // select query. We expect that
+ // this is not executed.
+ deleted = false;
+ }));
+ // Make sure that select query returned nothing.
+ EXPECT_TRUE(deleted);
+ }
+
+ /// @brief Test MySQL connection.
+ MySqlConnection conn_;
+};
+
+struct MySqlConnectionWithPrimaryKeyTest : MySqlConnectionTest {
+ MySqlConnectionWithPrimaryKeyTest()
+ : MySqlConnectionTest(/* primary_key = */ true) {
+ }
+};
+
+TEST_F(MySqlConnectionTest, select) {
+ if (showPxcStrictMode() == "ENFORCING" || showPxcStrictMode() == "MASTER") {
+ return;
+ }
+ select();
+}
+
+TEST_F(MySqlConnectionTest, selectNullInteger) {
+ if (showPxcStrictMode() == "ENFORCING" || showPxcStrictMode() == "MASTER") {
+ return;
+ }
+ selectNullInteger();
+}
+
+TEST_F(MySqlConnectionTest, selectNullString) {
+ if (showPxcStrictMode() == "ENFORCING" || showPxcStrictMode() == "MASTER") {
+ return;
+ }
+ selectNullString();
+}
+
+TEST_F(MySqlConnectionTest, selectNullBlob) {
+ if (showPxcStrictMode() == "ENFORCING" || showPxcStrictMode() == "MASTER") {
+ return;
+ }
+ selectNullBlob();
+}
+
+TEST_F(MySqlConnectionTest, selectNullTimestamp) {
+ if (showPxcStrictMode() == "ENFORCING" || showPxcStrictMode() == "MASTER") {
+ return;
+ }
+ selectNullTimestamp();
+}
+
+TEST_F(MySqlConnectionTest, selectEmptyStringBlob) {
+ if (showPxcStrictMode() == "ENFORCING" || showPxcStrictMode() == "MASTER") {
+ return;
+ }
+ selectEmptyStringBlob();
+}
+
+TEST_F(MySqlConnectionTest, deleteByValue) {
+ if (showPxcStrictMode() == "ENFORCING" || showPxcStrictMode() == "MASTER") {
+ return;
+ }
+ deleteByValue();
+}
+
+TEST_F(MySqlConnectionTest, transactions) {
+ // Two inserts within a transaction and successful commit.
+ conn_.startTransaction();
+ EXPECT_TRUE(conn_.isTransactionStarted());
+ runQuery("INSERT INTO mysql_connection_test (tinyint_value) VALUES (1)");
+ runQuery("INSERT INTO mysql_connection_test (tinyint_value) VALUES (2)");
+ conn_.commit();
+ EXPECT_FALSE(conn_.isTransactionStarted());
+ auto result = rawStatement("SELECT COUNT(*) FROM mysql_connection_test");
+ ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1, result[0].size());
+ EXPECT_EQ("2", result[0][0]);
+
+ // Add third row but roll back the transaction. We should still have
+ // two rows in the table.
+ conn_.startTransaction();
+ EXPECT_TRUE(conn_.isTransactionStarted());
+ runQuery("INSERT INTO mysql_connection_test (tinyint_value) VALUES (5)");
+ conn_.rollback();
+ EXPECT_FALSE(conn_.isTransactionStarted());
+ ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1, result[0].size());
+ EXPECT_EQ("2", result[0][0]);
+
+ // Nested transaction. The inner transaction should be ignored and the outer
+ // transaction rolled back. We should still have two rows in the database.
+ conn_.startTransaction();
+ EXPECT_TRUE(conn_.isTransactionStarted());
+ runQuery("INSERT INTO mysql_connection_test (tinyint_value) VALUES (3)");
+ conn_.startTransaction();
+ EXPECT_TRUE(conn_.isTransactionStarted());
+ runQuery("INSERT INTO mysql_connection_test (tinyint_value) VALUES (4)");
+ conn_.commit();
+ EXPECT_TRUE(conn_.isTransactionStarted());
+ conn_.rollback();
+ EXPECT_FALSE(conn_.isTransactionStarted());
+ result = rawStatement("SELECT COUNT(*) FROM mysql_connection_test");
+ ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1, result[0].size());
+ EXPECT_EQ("2", result[0][0]);
+
+ // Nested transaction. The inner transaction is rolled back but this should
+ // be ignored because nested transactions are not supported. We should
+ // have two new rows.
+ conn_.startTransaction();
+ EXPECT_TRUE(conn_.isTransactionStarted());
+ runQuery("INSERT INTO mysql_connection_test (tinyint_value) VALUES (5)");
+ conn_.startTransaction();
+ EXPECT_TRUE(conn_.isTransactionStarted());
+ runQuery("INSERT INTO mysql_connection_test (tinyint_value) VALUES (6)");
+ conn_.rollback();
+ EXPECT_TRUE(conn_.isTransactionStarted());
+ conn_.commit();
+ EXPECT_FALSE(conn_.isTransactionStarted());
+ result = rawStatement("SELECT COUNT(*) FROM mysql_connection_test");
+ ASSERT_EQ(1, result.size());
+ ASSERT_EQ(1, result[0].size());
+ EXPECT_EQ("4", result[0][0]);
+
+ // Committing or rolling back a not started transaction is a coding error.
+ EXPECT_THROW(conn_.commit(), isc::Unexpected);
+ EXPECT_THROW(conn_.rollback(), isc::Unexpected);
+}
+
+TEST_F(MySqlConnectionWithPrimaryKeyTest, select) {
+ select();
+}
+
+TEST_F(MySqlConnectionWithPrimaryKeyTest, selectNullInteger) {
+ selectNullInteger();
+}
+
+TEST_F(MySqlConnectionWithPrimaryKeyTest, selectNullString) {
+ selectNullString();
+}
+
+TEST_F(MySqlConnectionWithPrimaryKeyTest, selectNullBlob) {
+ selectNullBlob();
+}
+
+TEST_F(MySqlConnectionWithPrimaryKeyTest, selectNullTimestamp) {
+ selectNullTimestamp();
+}
+
+TEST_F(MySqlConnectionWithPrimaryKeyTest, selectEmptyStringBlob) {
+ selectEmptyStringBlob();
+}
+
+TEST_F(MySqlConnectionWithPrimaryKeyTest, deleteByValue) {
+ deleteByValue();
+}
+
+/// @brief Test fixture class for @c MySqlConnection class methods.
+class MySqlSchemaTest : public ::testing::Test {
+public:
+ /// @brief Constructor.
+ MySqlSchemaTest() {
+ // Ensure we have the proper schema.
+ createMySQLSchema();
+ }
+
+ /// @brief Destructor.
+ virtual ~MySqlSchemaTest() {
+ destroyMySQLSchema();
+ }
+};
+
+/// @brief Check that getVersion() returns the expected version.
+TEST_F(MySqlSchemaTest, checkVersion) {
+ // Check version
+ auto parameters = DatabaseConnection::parse(validMySQLConnectionString());
+ std::pair<uint32_t, uint32_t> version;
+ ASSERT_NO_THROW_LOG(version = MySqlConnection::getVersion(parameters));
+ EXPECT_EQ(MYSQL_SCHEMA_VERSION_MAJOR, version.first);
+ EXPECT_EQ(MYSQL_SCHEMA_VERSION_MINOR, version.second);
+}
+
+/// @brief Test fixture class for secure connection.
+class MySqlSecureConnectionTest : public ::testing::Test {
+public:
+
+ /// @brief Check if SSL/TLS support is available and configured.
+ bool hasMySQLTls() {
+ std::string tls = getMySQLTlsEnv();
+ if (tls.empty()) {
+ tls = getMySQLTlsServer();
+ }
+ return (tls == "YES");
+ }
+};
+
+/// @brief Check that we can get the MySQL support status.
+TEST_F(MySqlSecureConnectionTest, getMySQLTls) {
+ std::string env;
+ try {
+ env = getMySQLTlsEnv();
+ std::cout << "getMySQLTlsEnv returns '" << env << "'\n";
+ } catch (const isc::Exception& ex) {
+ std::cerr << "getMySQLTlsEnv fails with " << ex.what() << "\n";
+ }
+ if (!env.empty()) {
+ return;
+ }
+ try {
+ std::cout << "getMySQLTlsServer returns '" << getMySQLTlsServer() << "'\n";
+ } catch (const isc::Exception& ex) {
+ std::cerr << "getMySQLTlsServer fails with " << ex.what() << "\n";
+ }
+}
+
+/// @brief Check the enforced TCP connection.
+TEST_F(MySqlSecureConnectionTest, Tcp) {
+ std::string conn_str = connectionString(MYSQL_VALID_TYPE, VALID_NAME,
+ VALID_HOST_TCP, VALID_USER,
+ VALID_PASSWORD);
+ MySqlConnection conn(DatabaseConnection::parse(conn_str));
+ ASSERT_NO_THROW_LOG(conn.openDatabase());
+}
+
+/// @brief Check the SSL/TLS protected connection.
+TEST_F(MySqlSecureConnectionTest, Tls) {
+ if (!hasMySQLTls()) {
+ std::cout << "SSL/TLS support is not available or configured: "
+ << "skipping this test\n";
+ return;
+ }
+ std::string conn_str = connectionString(MYSQL_VALID_TYPE, VALID_NAME,
+ VALID_HOST_TCP, VALID_SECURE_USER,
+ VALID_PASSWORD, 0, 0,
+ VALID_CERT, VALID_KEY, VALID_CA,
+ VALID_CIPHER);
+ MySqlConnection conn(DatabaseConnection::parse(conn_str));
+ ASSERT_NO_THROW_LOG(conn.openDatabase());
+ EXPECT_TRUE(conn.getTls());
+ std::string cipher = conn.getTlsCipher();
+ EXPECT_FALSE(cipher.empty());
+ std::cout << "TLS cipher is '" << cipher << "'\n";
+}
+
+/// @brief Check the SSL/TLS protected connection still requires the password.
+TEST_F(MySqlSecureConnectionTest, TlsInvalidPassword) {
+ if (!hasMySQLTls()) {
+ std::cout << "SSL/TLS support is not available or configured: "
+ << "skipping this test\n";
+ return;
+ }
+ std::string conn_str = connectionString(MYSQL_VALID_TYPE, VALID_NAME,
+ VALID_HOST_TCP, VALID_SECURE_USER,
+ INVALID_PASSWORD, 0, 0,
+ VALID_CERT, VALID_KEY, VALID_CA,
+ VALID_CIPHER);
+ MySqlConnection conn(DatabaseConnection::parse(conn_str));
+ EXPECT_THROW(conn.openDatabase(), DbOpenError);
+}
+
+/// @brief Check the SSL/TLS protected connection requires crypto parameters.
+TEST_F(MySqlSecureConnectionTest, TlsNoCrypto) {
+ if (!hasMySQLTls()) {
+ std::cout << "SSL/TLS support is not available or configured: "
+ << "skipping this test\n";
+ return;
+ }
+ std::string conn_str = connectionString(MYSQL_VALID_TYPE, VALID_NAME,
+ VALID_HOST_TCP, VALID_SECURE_USER,
+ VALID_PASSWORD);
+ MySqlConnection conn(DatabaseConnection::parse(conn_str));
+ EXPECT_THROW(conn.openDatabase(), DbOpenError);
+}
+
+/// @brief Check the SSL/TLS protected connection requires valid key.
+TEST_F(MySqlSecureConnectionTest, TlsInvalidKey) {
+ if (!hasMySQLTls()) {
+ std::cout << "SSL/TLS support is not available or configured: "
+ << "skipping this test\n";
+ return;
+ }
+ std::string conn_str = connectionString(MYSQL_VALID_TYPE, VALID_NAME,
+ VALID_HOST_TCP, VALID_SECURE_USER,
+ VALID_PASSWORD, 0, 0,
+ VALID_CERT, INVALID_KEY, VALID_CA,
+ VALID_CIPHER);
+ MySqlConnection conn(DatabaseConnection::parse(conn_str));
+ EXPECT_THROW(conn.openDatabase(), DbOpenError);
+}
+
+/// @brief Check the SSL/TLS protected connection requires a key.
+TEST_F(MySqlSecureConnectionTest, TlsNoKey) {
+ if (!hasMySQLTls()) {
+ std::cout << "SSL/TLS support is not available or configured: "
+ << "skipping this test\n";
+ return;
+ }
+ std::string conn_str = connectionString(MYSQL_VALID_TYPE, VALID_NAME,
+ VALID_HOST_TCP, VALID_SECURE_USER,
+ VALID_PASSWORD, 0, 0,
+ VALID_CERT, 0, VALID_CA,
+ VALID_CIPHER);
+ MySqlConnection conn(DatabaseConnection::parse(conn_str));
+ EXPECT_THROW(conn.openDatabase(), DbOpenError);
+}
+
+} // namespace
diff --git a/src/lib/mysql/tests/run_unittests.cc b/src/lib/mysql/tests/run_unittests.cc
new file mode 100644
index 0000000..4e83d4b
--- /dev/null
+++ b/src/lib/mysql/tests/run_unittests.cc
@@ -0,0 +1,20 @@
+// 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);
+}