summaryrefslogtreecommitdiffstats
path: root/src/lib/yang/tests
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/lib/yang/tests/Makefile.am70
-rw-r--r--src/lib/yang/tests/Makefile.in1315
-rw-r--r--src/lib/yang/tests/adaptor_config_unittests.cc154
-rw-r--r--src/lib/yang/tests/adaptor_host_unittests.cc119
-rw-r--r--src/lib/yang/tests/adaptor_option_unittests.cc245
-rw-r--r--src/lib/yang/tests/adaptor_pool_unittests.cc276
-rw-r--r--src/lib/yang/tests/adaptor_subnet_unittests.cc214
-rw-r--r--src/lib/yang/tests/adaptor_unittests.cc398
-rw-r--r--src/lib/yang/tests/config_unittests.cc392
-rw-r--r--src/lib/yang/tests/json_configs.h176
-rw-r--r--src/lib/yang/tests/run_unittests.cc21
-rw-r--r--src/lib/yang/tests/sysrepo_setup.h96
-rw-r--r--src/lib/yang/tests/translator_class_unittests.cc123
-rw-r--r--src/lib/yang/tests/translator_control_socket_unittests.cc174
-rw-r--r--src/lib/yang/tests/translator_database_unittests.cc324
-rw-r--r--src/lib/yang/tests/translator_host_unittests.cc192
-rw-r--r--src/lib/yang/tests/translator_logger_unittests.cc156
-rw-r--r--src/lib/yang/tests/translator_option_data_unittests.cc135
-rw-r--r--src/lib/yang/tests/translator_option_def_unittests.cc138
-rw-r--r--src/lib/yang/tests/translator_pd_pool_unittests.cc296
-rw-r--r--src/lib/yang/tests/translator_pool_unittests.cc252
-rw-r--r--src/lib/yang/tests/translator_shared_network_unittests.cc210
-rw-r--r--src/lib/yang/tests/translator_subnet_unittests.cc379
-rw-r--r--src/lib/yang/tests/translator_unittests.cc892
-rw-r--r--src/lib/yang/tests/translator_utils_unittests.cc288
-rw-r--r--src/lib/yang/tests/yang_configs.h655
26 files changed, 7690 insertions, 0 deletions
diff --git a/src/lib/yang/tests/Makefile.am b/src/lib/yang/tests/Makefile.am
new file mode 100644
index 0000000..028f3d9
--- /dev/null
+++ b/src/lib/yang/tests/Makefile.am
@@ -0,0 +1,70 @@
+AM_CPPFLAGS =
+AM_CPPFLAGS += -DKEATEST_MODULE
+AM_CPPFLAGS += -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
+AM_CPPFLAGS += $(BOOST_INCLUDES)
+AM_CPPFLAGS += $(LIBYANG_CPPFLAGS)
+AM_CPPFLAGS += $(LIBYANG_INCLUDEDIR)
+AM_CPPFLAGS += $(LIBYANGCPP_CPPFLAGS)
+AM_CPPFLAGS += $(LIBYANGCPP_INCLUDEDIR)
+AM_CPPFLAGS += $(SYSREPO_CPPFLAGS)
+AM_CPPFLAGS += $(SYSREPO_INCLUDEDIR)
+AM_CPPFLAGS += $(SYSREPOCPP_CPPFLAGS)
+AM_CPPFLAGS += $(SYSREPOCPP_INCLUDEDIR)
+AM_CPPFLAGS += -DCFG_EXAMPLES=\"$(abs_top_srcdir)/doc/examples\"
+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 += run_unittests
+run_unittests_SOURCES = json_configs.h yang_configs.h
+run_unittests_SOURCES += adaptor_unittests.cc
+run_unittests_SOURCES += adaptor_option_unittests.cc
+run_unittests_SOURCES += adaptor_pool_unittests.cc
+run_unittests_SOURCES += adaptor_host_unittests.cc
+run_unittests_SOURCES += adaptor_subnet_unittests.cc
+run_unittests_SOURCES += adaptor_config_unittests.cc
+run_unittests_SOURCES += sysrepo_setup.h
+run_unittests_SOURCES += translator_unittests.cc
+run_unittests_SOURCES += translator_control_socket_unittests.cc
+run_unittests_SOURCES += translator_database_unittests.cc
+run_unittests_SOURCES += translator_logger_unittests.cc
+run_unittests_SOURCES += translator_option_data_unittests.cc
+run_unittests_SOURCES += translator_option_def_unittests.cc
+run_unittests_SOURCES += translator_class_unittests.cc
+run_unittests_SOURCES += translator_pool_unittests.cc
+run_unittests_SOURCES += translator_pd_pool_unittests.cc
+run_unittests_SOURCES += translator_host_unittests.cc
+run_unittests_SOURCES += translator_subnet_unittests.cc
+run_unittests_SOURCES += translator_shared_network_unittests.cc
+run_unittests_SOURCES += translator_utils_unittests.cc
+run_unittests_SOURCES += config_unittests.cc
+run_unittests_SOURCES += run_unittests.cc
+run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+
+run_unittests_LDADD = $(top_builddir)/src/lib/yang/testutils/libyangtest.la
+run_unittests_LDADD += $(top_builddir)/src/lib/yang/libkea-yang.la
+run_unittests_LDADD += $(top_builddir)/src/lib/testutils/libkea-testutils.la
+run_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
+run_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
+run_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
+run_unittests_LDADD += $(top_builddir)/src/lib/util/unittests/libutil_unittests.la
+run_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
+run_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
+run_unittests_LDADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(GTEST_LDADD)
+run_unittests_LDADD += $(LIBYANG_LIBS)
+run_unittests_LDADD += $(LIBYANGCPP_LIBS)
+run_unittests_LDADD += $(SYSREPO_LIBS)
+run_unittests_LDADD += $(SYSREPOCPP_LIBS)
+
+endif
+
+noinst_PROGRAMS = $(TESTS)
diff --git a/src/lib/yang/tests/Makefile.in b/src/lib/yang/tests/Makefile.in
new file mode 100644
index 0000000..6c5989a
--- /dev/null
+++ b/src/lib/yang/tests/Makefile.in
@@ -0,0 +1,1315 @@
+# 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 = run_unittests
+noinst_PROGRAMS = $(am__EXEEXT_2)
+subdir = src/lib/yang/tests
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4macros/ax_boost_for_kea.m4 \
+ $(top_srcdir)/m4macros/ax_cpp11.m4 \
+ $(top_srcdir)/m4macros/ax_cpp20.m4 \
+ $(top_srcdir)/m4macros/ax_crypto.m4 \
+ $(top_srcdir)/m4macros/ax_find_library.m4 \
+ $(top_srcdir)/m4macros/ax_gssapi.m4 \
+ $(top_srcdir)/m4macros/ax_gtest.m4 \
+ $(top_srcdir)/m4macros/ax_isc_rpath.m4 \
+ $(top_srcdir)/m4macros/ax_netconf.m4 \
+ $(top_srcdir)/m4macros/libtool.m4 \
+ $(top_srcdir)/m4macros/ltoptions.m4 \
+ $(top_srcdir)/m4macros/ltsugar.m4 \
+ $(top_srcdir)/m4macros/ltversion.m4 \
+ $(top_srcdir)/m4macros/lt~obsolete.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+@HAVE_GTEST_TRUE@am__EXEEXT_1 = run_unittests$(EXEEXT)
+am__EXEEXT_2 = $(am__EXEEXT_1)
+PROGRAMS = $(noinst_PROGRAMS)
+am__run_unittests_SOURCES_DIST = json_configs.h yang_configs.h \
+ adaptor_unittests.cc adaptor_option_unittests.cc \
+ adaptor_pool_unittests.cc adaptor_host_unittests.cc \
+ adaptor_subnet_unittests.cc adaptor_config_unittests.cc \
+ sysrepo_setup.h translator_unittests.cc \
+ translator_control_socket_unittests.cc \
+ translator_database_unittests.cc \
+ translator_logger_unittests.cc \
+ translator_option_data_unittests.cc \
+ translator_option_def_unittests.cc \
+ translator_class_unittests.cc translator_pool_unittests.cc \
+ translator_pd_pool_unittests.cc translator_host_unittests.cc \
+ translator_subnet_unittests.cc \
+ translator_shared_network_unittests.cc \
+ translator_utils_unittests.cc config_unittests.cc \
+ run_unittests.cc
+@HAVE_GTEST_TRUE@am_run_unittests_OBJECTS = \
+@HAVE_GTEST_TRUE@ run_unittests-adaptor_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-adaptor_option_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-adaptor_pool_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-adaptor_host_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-adaptor_subnet_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-adaptor_config_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_control_socket_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_database_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_logger_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_option_data_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_option_def_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_class_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_pool_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_pd_pool_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_host_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_subnet_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_shared_network_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-translator_utils_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-config_unittests.$(OBJEXT) \
+@HAVE_GTEST_TRUE@ run_unittests-run_unittests.$(OBJEXT)
+run_unittests_OBJECTS = $(am_run_unittests_OBJECTS)
+am__DEPENDENCIES_1 =
+@HAVE_GTEST_TRUE@run_unittests_DEPENDENCIES = $(top_builddir)/src/lib/yang/testutils/libyangtest.la \
+@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/yang/libkea-yang.la \
+@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/testutils/libkea-testutils.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/unittests/libutil_unittests.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) \
+@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 =
+run_unittests_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(AM_CXXFLAGS) $(CXXFLAGS) $(run_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)/run_unittests-adaptor_config_unittests.Po \
+ ./$(DEPDIR)/run_unittests-adaptor_host_unittests.Po \
+ ./$(DEPDIR)/run_unittests-adaptor_option_unittests.Po \
+ ./$(DEPDIR)/run_unittests-adaptor_pool_unittests.Po \
+ ./$(DEPDIR)/run_unittests-adaptor_subnet_unittests.Po \
+ ./$(DEPDIR)/run_unittests-adaptor_unittests.Po \
+ ./$(DEPDIR)/run_unittests-config_unittests.Po \
+ ./$(DEPDIR)/run_unittests-run_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_class_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_control_socket_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_database_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_host_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_logger_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_option_data_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_option_def_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_pd_pool_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_pool_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_shared_network_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_subnet_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_unittests.Po \
+ ./$(DEPDIR)/run_unittests-translator_utils_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 =
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+SOURCES = $(run_unittests_SOURCES)
+DIST_SOURCES = $(am__run_unittests_SOURCES_DIST)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+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; \
+}
+am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+ASCIIDOC = @ASCIIDOC@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_INCLUDES = @BOOST_INCLUDES@
+BOOST_LIBS = @BOOST_LIBS@
+BOTAN_TOOL = @BOTAN_TOOL@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CONTRIB_DIR = @CONTRIB_DIR@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CRYPTO_CFLAGS = @CRYPTO_CFLAGS@
+CRYPTO_INCLUDES = @CRYPTO_INCLUDES@
+CRYPTO_LDFLAGS = @CRYPTO_LDFLAGS@
+CRYPTO_LIBS = @CRYPTO_LIBS@
+CRYPTO_PACKAGE = @CRYPTO_PACKAGE@
+CRYPTO_RPATH = @CRYPTO_RPATH@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DISTCHECK_BOOST_CONFIGURE_FLAG = @DISTCHECK_BOOST_CONFIGURE_FLAG@
+DISTCHECK_CONTRIB_CONFIGURE_FLAG = @DISTCHECK_CONTRIB_CONFIGURE_FLAG@
+DISTCHECK_CRYPTO_CONFIGURE_FLAG = @DISTCHECK_CRYPTO_CONFIGURE_FLAG@
+DISTCHECK_GSSAPI_CONFIGURE_FLAG = @DISTCHECK_GSSAPI_CONFIGURE_FLAG@
+DISTCHECK_GTEST_CONFIGURE_FLAG = @DISTCHECK_GTEST_CONFIGURE_FLAG@
+DISTCHECK_KEA_SHELL_CONFIGURE_FLAG = @DISTCHECK_KEA_SHELL_CONFIGURE_FLAG@
+DISTCHECK_LIBYANGCPP_CONFIGURE_FLAG = @DISTCHECK_LIBYANGCPP_CONFIGURE_FLAG@
+DISTCHECK_LIBYANG_CONFIGURE_FLAG = @DISTCHECK_LIBYANG_CONFIGURE_FLAG@
+DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG = @DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG@
+DISTCHECK_MYSQL_CONFIGURE_FLAG = @DISTCHECK_MYSQL_CONFIGURE_FLAG@
+DISTCHECK_PERFDHCP_CONFIGURE_FLAG = @DISTCHECK_PERFDHCP_CONFIGURE_FLAG@
+DISTCHECK_PGSQL_CONFIGURE_FLAG = @DISTCHECK_PGSQL_CONFIGURE_FLAG@
+DISTCHECK_PREMIUM_CONFIGURE_FLAG = @DISTCHECK_PREMIUM_CONFIGURE_FLAG@
+DISTCHECK_SYSREPOCPP_CONFIGURE_FLAG = @DISTCHECK_SYSREPOCPP_CONFIGURE_FLAG@
+DISTCHECK_SYSREPO_CONFIGURE_FLAG = @DISTCHECK_SYSREPO_CONFIGURE_FLAG@
+DLLTOOL = @DLLTOOL@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GENHTML = @GENHTML@
+GREP = @GREP@
+GSSAPI_CFLAGS = @GSSAPI_CFLAGS@
+GSSAPI_LIBS = @GSSAPI_LIBS@
+GTEST_CONFIG = @GTEST_CONFIG@
+GTEST_INCLUDES = @GTEST_INCLUDES@
+GTEST_LDADD = @GTEST_LDADD@
+GTEST_LDFLAGS = @GTEST_LDFLAGS@
+GTEST_SOURCE = @GTEST_SOURCE@
+HAVE_NETCONF = @HAVE_NETCONF@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+KEA_CXXFLAGS = @KEA_CXXFLAGS@
+KEA_SRCID = @KEA_SRCID@
+KRB5_CONFIG = @KRB5_CONFIG@
+LCOV = @LCOV@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LEX = @LEX@
+LEXLIB = @LEXLIB@
+LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBYANGCPP_CPPFLAGS = @LIBYANGCPP_CPPFLAGS@
+LIBYANGCPP_INCLUDEDIR = @LIBYANGCPP_INCLUDEDIR@
+LIBYANGCPP_LIBS = @LIBYANGCPP_LIBS@
+LIBYANGCPP_PREFIX = @LIBYANGCPP_PREFIX@
+LIBYANGCPP_VERSION = @LIBYANGCPP_VERSION@
+LIBYANG_CPPFLAGS = @LIBYANG_CPPFLAGS@
+LIBYANG_INCLUDEDIR = @LIBYANG_INCLUDEDIR@
+LIBYANG_LIBS = @LIBYANG_LIBS@
+LIBYANG_PREFIX = @LIBYANG_PREFIX@
+LIBYANG_VERSION = @LIBYANG_VERSION@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LOG4CPLUS_INCLUDES = @LOG4CPLUS_INCLUDES@
+LOG4CPLUS_LIBS = @LOG4CPLUS_LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@
+MAKEINFO = @MAKEINFO@
+MANIFEST_TOOL = @MANIFEST_TOOL@
+MKDIR_P = @MKDIR_P@
+MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@
+MYSQL_LIBS = @MYSQL_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PACKAGE_VERSION_TYPE = @PACKAGE_VERSION_TYPE@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PDFLATEX = @PDFLATEX@
+PERL = @PERL@
+PGSQL_CPPFLAGS = @PGSQL_CPPFLAGS@
+PGSQL_LIBS = @PGSQL_LIBS@
+PKGPYTHONDIR = @PKGPYTHONDIR@
+PKG_CONFIG = @PKG_CONFIG@
+PLANTUML = @PLANTUML@
+PREMIUM_DIR = @PREMIUM_DIR@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SED = @SED@
+SEP = @SEP@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SPHINXBUILD = @SPHINXBUILD@
+SRPD_PLUGINS_PATH = @SRPD_PLUGINS_PATH@
+SR_PLUGINS_PATH = @SR_PLUGINS_PATH@
+SR_REPO_PATH = @SR_REPO_PATH@
+STRIP = @STRIP@
+SYSREPOCPP_CPPFLAGS = @SYSREPOCPP_CPPFLAGS@
+SYSREPOCPP_INCLUDEDIR = @SYSREPOCPP_INCLUDEDIR@
+SYSREPOCPP_LIBS = @SYSREPOCPP_LIBS@
+SYSREPOCPP_PREFIX = @SYSREPOCPP_PREFIX@
+SYSREPOCPP_VERSION = @SYSREPOCPP_VERSION@
+SYSREPO_CPPFLAGS = @SYSREPO_CPPFLAGS@
+SYSREPO_INCLUDEDIR = @SYSREPO_INCLUDEDIR@
+SYSREPO_LIBS = @SYSREPO_LIBS@
+SYSREPO_PREFIX = @SYSREPO_PREFIX@
+SYSREPO_VERSION = @SYSREPO_VERSION@
+USE_LCOV = @USE_LCOV@
+VALGRIND = @VALGRIND@
+VERSION = @VERSION@
+WARNING_GCC_44_STRICT_ALIASING_CFLAG = @WARNING_GCC_44_STRICT_ALIASING_CFLAG@
+YACC = @YACC@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+runstatedir = @runstatedir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AM_CPPFLAGS = -DKEATEST_MODULE -I$(top_builddir)/src/lib \
+ -I$(top_srcdir)/src/lib $(BOOST_INCLUDES) $(LIBYANG_CPPFLAGS) \
+ $(LIBYANG_INCLUDEDIR) $(LIBYANGCPP_CPPFLAGS) \
+ $(LIBYANGCPP_INCLUDEDIR) $(SYSREPO_CPPFLAGS) \
+ $(SYSREPO_INCLUDEDIR) $(SYSREPOCPP_CPPFLAGS) \
+ $(SYSREPOCPP_INCLUDEDIR) \
+ -DCFG_EXAMPLES=\"$(abs_top_srcdir)/doc/examples\"
+AM_CXXFLAGS = $(KEA_CXXFLAGS)
+@USE_STATIC_LINK_TRUE@AM_LDFLAGS = -static
+CLEANFILES = *.gcno *.gcda
+TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
+@HAVE_GTEST_TRUE@run_unittests_SOURCES = json_configs.h yang_configs.h \
+@HAVE_GTEST_TRUE@ adaptor_unittests.cc \
+@HAVE_GTEST_TRUE@ adaptor_option_unittests.cc \
+@HAVE_GTEST_TRUE@ adaptor_pool_unittests.cc \
+@HAVE_GTEST_TRUE@ adaptor_host_unittests.cc \
+@HAVE_GTEST_TRUE@ adaptor_subnet_unittests.cc \
+@HAVE_GTEST_TRUE@ adaptor_config_unittests.cc sysrepo_setup.h \
+@HAVE_GTEST_TRUE@ translator_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_control_socket_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_database_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_logger_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_option_data_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_option_def_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_class_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_pool_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_pd_pool_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_host_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_subnet_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_shared_network_unittests.cc \
+@HAVE_GTEST_TRUE@ translator_utils_unittests.cc \
+@HAVE_GTEST_TRUE@ config_unittests.cc run_unittests.cc
+@HAVE_GTEST_TRUE@run_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES)
+@HAVE_GTEST_TRUE@run_unittests_LDFLAGS = $(AM_LDFLAGS) $(GTEST_LDFLAGS)
+@HAVE_GTEST_TRUE@run_unittests_LDADD = $(top_builddir)/src/lib/yang/testutils/libyangtest.la \
+@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/yang/libkea-yang.la \
+@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/testutils/libkea-testutils.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/unittests/libutil_unittests.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) $(LIBYANG_LIBS) \
+@HAVE_GTEST_TRUE@ $(LIBYANGCPP_LIBS) $(SYSREPO_LIBS) \
+@HAVE_GTEST_TRUE@ $(SYSREPOCPP_LIBS)
+all: all-am
+
+.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/yang/tests/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/lib/yang/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
+
+run_unittests$(EXEEXT): $(run_unittests_OBJECTS) $(run_unittests_DEPENDENCIES) $(EXTRA_run_unittests_DEPENDENCIES)
+ @rm -f run_unittests$(EXEEXT)
+ $(AM_V_CXXLD)$(run_unittests_LINK) $(run_unittests_OBJECTS) $(run_unittests_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-adaptor_config_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-adaptor_host_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-adaptor_option_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-adaptor_pool_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-adaptor_subnet_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-adaptor_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-config_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-run_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_class_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_control_socket_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_database_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_host_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_logger_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_option_data_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_option_def_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_pd_pool_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_pool_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_shared_network_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_subnet_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_unittests.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/run_unittests-translator_utils_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 $@ $<
+
+run_unittests-adaptor_unittests.o: adaptor_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_unittests.Tpo -c -o run_unittests-adaptor_unittests.o `test -f 'adaptor_unittests.cc' || echo '$(srcdir)/'`adaptor_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_unittests.cc' object='run_unittests-adaptor_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_unittests.o `test -f 'adaptor_unittests.cc' || echo '$(srcdir)/'`adaptor_unittests.cc
+
+run_unittests-adaptor_unittests.obj: adaptor_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_unittests.Tpo -c -o run_unittests-adaptor_unittests.obj `if test -f 'adaptor_unittests.cc'; then $(CYGPATH_W) 'adaptor_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_unittests.cc' object='run_unittests-adaptor_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_unittests.obj `if test -f 'adaptor_unittests.cc'; then $(CYGPATH_W) 'adaptor_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_unittests.cc'; fi`
+
+run_unittests-adaptor_option_unittests.o: adaptor_option_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_option_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_option_unittests.Tpo -c -o run_unittests-adaptor_option_unittests.o `test -f 'adaptor_option_unittests.cc' || echo '$(srcdir)/'`adaptor_option_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_option_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_option_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_option_unittests.cc' object='run_unittests-adaptor_option_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_option_unittests.o `test -f 'adaptor_option_unittests.cc' || echo '$(srcdir)/'`adaptor_option_unittests.cc
+
+run_unittests-adaptor_option_unittests.obj: adaptor_option_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_option_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_option_unittests.Tpo -c -o run_unittests-adaptor_option_unittests.obj `if test -f 'adaptor_option_unittests.cc'; then $(CYGPATH_W) 'adaptor_option_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_option_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_option_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_option_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_option_unittests.cc' object='run_unittests-adaptor_option_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_option_unittests.obj `if test -f 'adaptor_option_unittests.cc'; then $(CYGPATH_W) 'adaptor_option_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_option_unittests.cc'; fi`
+
+run_unittests-adaptor_pool_unittests.o: adaptor_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_pool_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_pool_unittests.Tpo -c -o run_unittests-adaptor_pool_unittests.o `test -f 'adaptor_pool_unittests.cc' || echo '$(srcdir)/'`adaptor_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_pool_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_pool_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_pool_unittests.cc' object='run_unittests-adaptor_pool_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_pool_unittests.o `test -f 'adaptor_pool_unittests.cc' || echo '$(srcdir)/'`adaptor_pool_unittests.cc
+
+run_unittests-adaptor_pool_unittests.obj: adaptor_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_pool_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_pool_unittests.Tpo -c -o run_unittests-adaptor_pool_unittests.obj `if test -f 'adaptor_pool_unittests.cc'; then $(CYGPATH_W) 'adaptor_pool_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_pool_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_pool_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_pool_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_pool_unittests.cc' object='run_unittests-adaptor_pool_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_pool_unittests.obj `if test -f 'adaptor_pool_unittests.cc'; then $(CYGPATH_W) 'adaptor_pool_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_pool_unittests.cc'; fi`
+
+run_unittests-adaptor_host_unittests.o: adaptor_host_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_host_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_host_unittests.Tpo -c -o run_unittests-adaptor_host_unittests.o `test -f 'adaptor_host_unittests.cc' || echo '$(srcdir)/'`adaptor_host_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_host_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_host_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_host_unittests.cc' object='run_unittests-adaptor_host_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_host_unittests.o `test -f 'adaptor_host_unittests.cc' || echo '$(srcdir)/'`adaptor_host_unittests.cc
+
+run_unittests-adaptor_host_unittests.obj: adaptor_host_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_host_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_host_unittests.Tpo -c -o run_unittests-adaptor_host_unittests.obj `if test -f 'adaptor_host_unittests.cc'; then $(CYGPATH_W) 'adaptor_host_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_host_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_host_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_host_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_host_unittests.cc' object='run_unittests-adaptor_host_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_host_unittests.obj `if test -f 'adaptor_host_unittests.cc'; then $(CYGPATH_W) 'adaptor_host_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_host_unittests.cc'; fi`
+
+run_unittests-adaptor_subnet_unittests.o: adaptor_subnet_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_subnet_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_subnet_unittests.Tpo -c -o run_unittests-adaptor_subnet_unittests.o `test -f 'adaptor_subnet_unittests.cc' || echo '$(srcdir)/'`adaptor_subnet_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_subnet_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_subnet_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_subnet_unittests.cc' object='run_unittests-adaptor_subnet_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_subnet_unittests.o `test -f 'adaptor_subnet_unittests.cc' || echo '$(srcdir)/'`adaptor_subnet_unittests.cc
+
+run_unittests-adaptor_subnet_unittests.obj: adaptor_subnet_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_subnet_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_subnet_unittests.Tpo -c -o run_unittests-adaptor_subnet_unittests.obj `if test -f 'adaptor_subnet_unittests.cc'; then $(CYGPATH_W) 'adaptor_subnet_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_subnet_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_subnet_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_subnet_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_subnet_unittests.cc' object='run_unittests-adaptor_subnet_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_subnet_unittests.obj `if test -f 'adaptor_subnet_unittests.cc'; then $(CYGPATH_W) 'adaptor_subnet_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_subnet_unittests.cc'; fi`
+
+run_unittests-adaptor_config_unittests.o: adaptor_config_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_config_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_config_unittests.Tpo -c -o run_unittests-adaptor_config_unittests.o `test -f 'adaptor_config_unittests.cc' || echo '$(srcdir)/'`adaptor_config_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_config_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_config_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_config_unittests.cc' object='run_unittests-adaptor_config_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_config_unittests.o `test -f 'adaptor_config_unittests.cc' || echo '$(srcdir)/'`adaptor_config_unittests.cc
+
+run_unittests-adaptor_config_unittests.obj: adaptor_config_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-adaptor_config_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-adaptor_config_unittests.Tpo -c -o run_unittests-adaptor_config_unittests.obj `if test -f 'adaptor_config_unittests.cc'; then $(CYGPATH_W) 'adaptor_config_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_config_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-adaptor_config_unittests.Tpo $(DEPDIR)/run_unittests-adaptor_config_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='adaptor_config_unittests.cc' object='run_unittests-adaptor_config_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-adaptor_config_unittests.obj `if test -f 'adaptor_config_unittests.cc'; then $(CYGPATH_W) 'adaptor_config_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/adaptor_config_unittests.cc'; fi`
+
+run_unittests-translator_unittests.o: translator_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_unittests.Tpo -c -o run_unittests-translator_unittests.o `test -f 'translator_unittests.cc' || echo '$(srcdir)/'`translator_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_unittests.Tpo $(DEPDIR)/run_unittests-translator_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_unittests.cc' object='run_unittests-translator_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_unittests.o `test -f 'translator_unittests.cc' || echo '$(srcdir)/'`translator_unittests.cc
+
+run_unittests-translator_unittests.obj: translator_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_unittests.Tpo -c -o run_unittests-translator_unittests.obj `if test -f 'translator_unittests.cc'; then $(CYGPATH_W) 'translator_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_unittests.Tpo $(DEPDIR)/run_unittests-translator_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_unittests.cc' object='run_unittests-translator_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_unittests.obj `if test -f 'translator_unittests.cc'; then $(CYGPATH_W) 'translator_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_unittests.cc'; fi`
+
+run_unittests-translator_control_socket_unittests.o: translator_control_socket_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_control_socket_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_control_socket_unittests.Tpo -c -o run_unittests-translator_control_socket_unittests.o `test -f 'translator_control_socket_unittests.cc' || echo '$(srcdir)/'`translator_control_socket_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_control_socket_unittests.Tpo $(DEPDIR)/run_unittests-translator_control_socket_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_control_socket_unittests.cc' object='run_unittests-translator_control_socket_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_control_socket_unittests.o `test -f 'translator_control_socket_unittests.cc' || echo '$(srcdir)/'`translator_control_socket_unittests.cc
+
+run_unittests-translator_control_socket_unittests.obj: translator_control_socket_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_control_socket_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_control_socket_unittests.Tpo -c -o run_unittests-translator_control_socket_unittests.obj `if test -f 'translator_control_socket_unittests.cc'; then $(CYGPATH_W) 'translator_control_socket_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_control_socket_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_control_socket_unittests.Tpo $(DEPDIR)/run_unittests-translator_control_socket_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_control_socket_unittests.cc' object='run_unittests-translator_control_socket_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_control_socket_unittests.obj `if test -f 'translator_control_socket_unittests.cc'; then $(CYGPATH_W) 'translator_control_socket_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_control_socket_unittests.cc'; fi`
+
+run_unittests-translator_database_unittests.o: translator_database_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_database_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_database_unittests.Tpo -c -o run_unittests-translator_database_unittests.o `test -f 'translator_database_unittests.cc' || echo '$(srcdir)/'`translator_database_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_database_unittests.Tpo $(DEPDIR)/run_unittests-translator_database_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_database_unittests.cc' object='run_unittests-translator_database_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_database_unittests.o `test -f 'translator_database_unittests.cc' || echo '$(srcdir)/'`translator_database_unittests.cc
+
+run_unittests-translator_database_unittests.obj: translator_database_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_database_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_database_unittests.Tpo -c -o run_unittests-translator_database_unittests.obj `if test -f 'translator_database_unittests.cc'; then $(CYGPATH_W) 'translator_database_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_database_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_database_unittests.Tpo $(DEPDIR)/run_unittests-translator_database_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_database_unittests.cc' object='run_unittests-translator_database_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_database_unittests.obj `if test -f 'translator_database_unittests.cc'; then $(CYGPATH_W) 'translator_database_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_database_unittests.cc'; fi`
+
+run_unittests-translator_logger_unittests.o: translator_logger_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_logger_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_logger_unittests.Tpo -c -o run_unittests-translator_logger_unittests.o `test -f 'translator_logger_unittests.cc' || echo '$(srcdir)/'`translator_logger_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_logger_unittests.Tpo $(DEPDIR)/run_unittests-translator_logger_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_logger_unittests.cc' object='run_unittests-translator_logger_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_logger_unittests.o `test -f 'translator_logger_unittests.cc' || echo '$(srcdir)/'`translator_logger_unittests.cc
+
+run_unittests-translator_logger_unittests.obj: translator_logger_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_logger_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_logger_unittests.Tpo -c -o run_unittests-translator_logger_unittests.obj `if test -f 'translator_logger_unittests.cc'; then $(CYGPATH_W) 'translator_logger_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_logger_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_logger_unittests.Tpo $(DEPDIR)/run_unittests-translator_logger_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_logger_unittests.cc' object='run_unittests-translator_logger_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_logger_unittests.obj `if test -f 'translator_logger_unittests.cc'; then $(CYGPATH_W) 'translator_logger_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_logger_unittests.cc'; fi`
+
+run_unittests-translator_option_data_unittests.o: translator_option_data_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_option_data_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_option_data_unittests.Tpo -c -o run_unittests-translator_option_data_unittests.o `test -f 'translator_option_data_unittests.cc' || echo '$(srcdir)/'`translator_option_data_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_option_data_unittests.Tpo $(DEPDIR)/run_unittests-translator_option_data_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_option_data_unittests.cc' object='run_unittests-translator_option_data_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_option_data_unittests.o `test -f 'translator_option_data_unittests.cc' || echo '$(srcdir)/'`translator_option_data_unittests.cc
+
+run_unittests-translator_option_data_unittests.obj: translator_option_data_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_option_data_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_option_data_unittests.Tpo -c -o run_unittests-translator_option_data_unittests.obj `if test -f 'translator_option_data_unittests.cc'; then $(CYGPATH_W) 'translator_option_data_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_option_data_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_option_data_unittests.Tpo $(DEPDIR)/run_unittests-translator_option_data_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_option_data_unittests.cc' object='run_unittests-translator_option_data_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_option_data_unittests.obj `if test -f 'translator_option_data_unittests.cc'; then $(CYGPATH_W) 'translator_option_data_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_option_data_unittests.cc'; fi`
+
+run_unittests-translator_option_def_unittests.o: translator_option_def_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_option_def_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_option_def_unittests.Tpo -c -o run_unittests-translator_option_def_unittests.o `test -f 'translator_option_def_unittests.cc' || echo '$(srcdir)/'`translator_option_def_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_option_def_unittests.Tpo $(DEPDIR)/run_unittests-translator_option_def_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_option_def_unittests.cc' object='run_unittests-translator_option_def_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_option_def_unittests.o `test -f 'translator_option_def_unittests.cc' || echo '$(srcdir)/'`translator_option_def_unittests.cc
+
+run_unittests-translator_option_def_unittests.obj: translator_option_def_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_option_def_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_option_def_unittests.Tpo -c -o run_unittests-translator_option_def_unittests.obj `if test -f 'translator_option_def_unittests.cc'; then $(CYGPATH_W) 'translator_option_def_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_option_def_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_option_def_unittests.Tpo $(DEPDIR)/run_unittests-translator_option_def_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_option_def_unittests.cc' object='run_unittests-translator_option_def_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_option_def_unittests.obj `if test -f 'translator_option_def_unittests.cc'; then $(CYGPATH_W) 'translator_option_def_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_option_def_unittests.cc'; fi`
+
+run_unittests-translator_class_unittests.o: translator_class_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_class_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_class_unittests.Tpo -c -o run_unittests-translator_class_unittests.o `test -f 'translator_class_unittests.cc' || echo '$(srcdir)/'`translator_class_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_class_unittests.Tpo $(DEPDIR)/run_unittests-translator_class_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_class_unittests.cc' object='run_unittests-translator_class_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_class_unittests.o `test -f 'translator_class_unittests.cc' || echo '$(srcdir)/'`translator_class_unittests.cc
+
+run_unittests-translator_class_unittests.obj: translator_class_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_class_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_class_unittests.Tpo -c -o run_unittests-translator_class_unittests.obj `if test -f 'translator_class_unittests.cc'; then $(CYGPATH_W) 'translator_class_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_class_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_class_unittests.Tpo $(DEPDIR)/run_unittests-translator_class_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_class_unittests.cc' object='run_unittests-translator_class_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_class_unittests.obj `if test -f 'translator_class_unittests.cc'; then $(CYGPATH_W) 'translator_class_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_class_unittests.cc'; fi`
+
+run_unittests-translator_pool_unittests.o: translator_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_pool_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_pool_unittests.Tpo -c -o run_unittests-translator_pool_unittests.o `test -f 'translator_pool_unittests.cc' || echo '$(srcdir)/'`translator_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_pool_unittests.Tpo $(DEPDIR)/run_unittests-translator_pool_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_pool_unittests.cc' object='run_unittests-translator_pool_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_pool_unittests.o `test -f 'translator_pool_unittests.cc' || echo '$(srcdir)/'`translator_pool_unittests.cc
+
+run_unittests-translator_pool_unittests.obj: translator_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_pool_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_pool_unittests.Tpo -c -o run_unittests-translator_pool_unittests.obj `if test -f 'translator_pool_unittests.cc'; then $(CYGPATH_W) 'translator_pool_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_pool_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_pool_unittests.Tpo $(DEPDIR)/run_unittests-translator_pool_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_pool_unittests.cc' object='run_unittests-translator_pool_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_pool_unittests.obj `if test -f 'translator_pool_unittests.cc'; then $(CYGPATH_W) 'translator_pool_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_pool_unittests.cc'; fi`
+
+run_unittests-translator_pd_pool_unittests.o: translator_pd_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_pd_pool_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_pd_pool_unittests.Tpo -c -o run_unittests-translator_pd_pool_unittests.o `test -f 'translator_pd_pool_unittests.cc' || echo '$(srcdir)/'`translator_pd_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_pd_pool_unittests.Tpo $(DEPDIR)/run_unittests-translator_pd_pool_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_pd_pool_unittests.cc' object='run_unittests-translator_pd_pool_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_pd_pool_unittests.o `test -f 'translator_pd_pool_unittests.cc' || echo '$(srcdir)/'`translator_pd_pool_unittests.cc
+
+run_unittests-translator_pd_pool_unittests.obj: translator_pd_pool_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_pd_pool_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_pd_pool_unittests.Tpo -c -o run_unittests-translator_pd_pool_unittests.obj `if test -f 'translator_pd_pool_unittests.cc'; then $(CYGPATH_W) 'translator_pd_pool_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_pd_pool_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_pd_pool_unittests.Tpo $(DEPDIR)/run_unittests-translator_pd_pool_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_pd_pool_unittests.cc' object='run_unittests-translator_pd_pool_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_pd_pool_unittests.obj `if test -f 'translator_pd_pool_unittests.cc'; then $(CYGPATH_W) 'translator_pd_pool_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_pd_pool_unittests.cc'; fi`
+
+run_unittests-translator_host_unittests.o: translator_host_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_host_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_host_unittests.Tpo -c -o run_unittests-translator_host_unittests.o `test -f 'translator_host_unittests.cc' || echo '$(srcdir)/'`translator_host_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_host_unittests.Tpo $(DEPDIR)/run_unittests-translator_host_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_host_unittests.cc' object='run_unittests-translator_host_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_host_unittests.o `test -f 'translator_host_unittests.cc' || echo '$(srcdir)/'`translator_host_unittests.cc
+
+run_unittests-translator_host_unittests.obj: translator_host_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_host_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_host_unittests.Tpo -c -o run_unittests-translator_host_unittests.obj `if test -f 'translator_host_unittests.cc'; then $(CYGPATH_W) 'translator_host_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_host_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_host_unittests.Tpo $(DEPDIR)/run_unittests-translator_host_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_host_unittests.cc' object='run_unittests-translator_host_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_host_unittests.obj `if test -f 'translator_host_unittests.cc'; then $(CYGPATH_W) 'translator_host_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_host_unittests.cc'; fi`
+
+run_unittests-translator_subnet_unittests.o: translator_subnet_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_subnet_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_subnet_unittests.Tpo -c -o run_unittests-translator_subnet_unittests.o `test -f 'translator_subnet_unittests.cc' || echo '$(srcdir)/'`translator_subnet_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_subnet_unittests.Tpo $(DEPDIR)/run_unittests-translator_subnet_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_subnet_unittests.cc' object='run_unittests-translator_subnet_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_subnet_unittests.o `test -f 'translator_subnet_unittests.cc' || echo '$(srcdir)/'`translator_subnet_unittests.cc
+
+run_unittests-translator_subnet_unittests.obj: translator_subnet_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_subnet_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_subnet_unittests.Tpo -c -o run_unittests-translator_subnet_unittests.obj `if test -f 'translator_subnet_unittests.cc'; then $(CYGPATH_W) 'translator_subnet_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_subnet_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_subnet_unittests.Tpo $(DEPDIR)/run_unittests-translator_subnet_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_subnet_unittests.cc' object='run_unittests-translator_subnet_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_subnet_unittests.obj `if test -f 'translator_subnet_unittests.cc'; then $(CYGPATH_W) 'translator_subnet_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_subnet_unittests.cc'; fi`
+
+run_unittests-translator_shared_network_unittests.o: translator_shared_network_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_shared_network_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_shared_network_unittests.Tpo -c -o run_unittests-translator_shared_network_unittests.o `test -f 'translator_shared_network_unittests.cc' || echo '$(srcdir)/'`translator_shared_network_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_shared_network_unittests.Tpo $(DEPDIR)/run_unittests-translator_shared_network_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_shared_network_unittests.cc' object='run_unittests-translator_shared_network_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_shared_network_unittests.o `test -f 'translator_shared_network_unittests.cc' || echo '$(srcdir)/'`translator_shared_network_unittests.cc
+
+run_unittests-translator_shared_network_unittests.obj: translator_shared_network_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_shared_network_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_shared_network_unittests.Tpo -c -o run_unittests-translator_shared_network_unittests.obj `if test -f 'translator_shared_network_unittests.cc'; then $(CYGPATH_W) 'translator_shared_network_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_shared_network_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_shared_network_unittests.Tpo $(DEPDIR)/run_unittests-translator_shared_network_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_shared_network_unittests.cc' object='run_unittests-translator_shared_network_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_shared_network_unittests.obj `if test -f 'translator_shared_network_unittests.cc'; then $(CYGPATH_W) 'translator_shared_network_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_shared_network_unittests.cc'; fi`
+
+run_unittests-translator_utils_unittests.o: translator_utils_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_utils_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-translator_utils_unittests.Tpo -c -o run_unittests-translator_utils_unittests.o `test -f 'translator_utils_unittests.cc' || echo '$(srcdir)/'`translator_utils_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_utils_unittests.Tpo $(DEPDIR)/run_unittests-translator_utils_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_utils_unittests.cc' object='run_unittests-translator_utils_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_utils_unittests.o `test -f 'translator_utils_unittests.cc' || echo '$(srcdir)/'`translator_utils_unittests.cc
+
+run_unittests-translator_utils_unittests.obj: translator_utils_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-translator_utils_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-translator_utils_unittests.Tpo -c -o run_unittests-translator_utils_unittests.obj `if test -f 'translator_utils_unittests.cc'; then $(CYGPATH_W) 'translator_utils_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_utils_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-translator_utils_unittests.Tpo $(DEPDIR)/run_unittests-translator_utils_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_utils_unittests.cc' object='run_unittests-translator_utils_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-translator_utils_unittests.obj `if test -f 'translator_utils_unittests.cc'; then $(CYGPATH_W) 'translator_utils_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/translator_utils_unittests.cc'; fi`
+
+run_unittests-config_unittests.o: config_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-config_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-config_unittests.Tpo -c -o run_unittests-config_unittests.o `test -f 'config_unittests.cc' || echo '$(srcdir)/'`config_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-config_unittests.Tpo $(DEPDIR)/run_unittests-config_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='config_unittests.cc' object='run_unittests-config_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-config_unittests.o `test -f 'config_unittests.cc' || echo '$(srcdir)/'`config_unittests.cc
+
+run_unittests-config_unittests.obj: config_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-config_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-config_unittests.Tpo -c -o run_unittests-config_unittests.obj `if test -f 'config_unittests.cc'; then $(CYGPATH_W) 'config_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/config_unittests.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-config_unittests.Tpo $(DEPDIR)/run_unittests-config_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='config_unittests.cc' object='run_unittests-config_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-config_unittests.obj `if test -f 'config_unittests.cc'; then $(CYGPATH_W) 'config_unittests.cc'; else $(CYGPATH_W) '$(srcdir)/config_unittests.cc'; fi`
+
+run_unittests-run_unittests.o: run_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-run_unittests.o -MD -MP -MF $(DEPDIR)/run_unittests-run_unittests.Tpo -c -o run_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/run_unittests-run_unittests.Tpo $(DEPDIR)/run_unittests-run_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='run_unittests.cc' object='run_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_unittests-run_unittests.o `test -f 'run_unittests.cc' || echo '$(srcdir)/'`run_unittests.cc
+
+run_unittests-run_unittests.obj: run_unittests.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT run_unittests-run_unittests.obj -MD -MP -MF $(DEPDIR)/run_unittests-run_unittests.Tpo -c -o run_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)/run_unittests-run_unittests.Tpo $(DEPDIR)/run_unittests-run_unittests.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='run_unittests.cc' object='run_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) $(run_unittests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o run_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
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+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
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+
+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-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_config_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_host_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_option_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_pool_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_subnet_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-config_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-run_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_class_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_control_socket_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_database_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_host_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_logger_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_option_data_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_option_def_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_pd_pool_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_pool_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_shared_network_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_subnet_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_utils_unittests.Po
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_config_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_host_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_option_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_pool_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_subnet_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-adaptor_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-config_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-run_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_class_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_control_socket_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_database_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_host_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_logger_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_option_data_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_option_def_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_pd_pool_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_pool_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_shared_network_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_subnet_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_unittests.Po
+ -rm -f ./$(DEPDIR)/run_unittests-translator_utils_unittests.Po
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: 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 \
+ 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/yang/tests/adaptor_config_unittests.cc b/src/lib/yang/tests/adaptor_config_unittests.cc
new file mode 100644
index 0000000..2109890
--- /dev/null
+++ b/src/lib/yang/tests/adaptor_config_unittests.cc
@@ -0,0 +1,154 @@
+// Copyright (C) 2018-2023 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <gtest/gtest.h>
+
+#include <testutils/gtest_utils.h>
+#include <testutils/io_utils.h>
+#include <testutils/user_context_utils.h>
+#include <yang/adaptor_config.h>
+
+#include <vector>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::test;
+using namespace isc::yang;
+
+namespace {
+
+/// @brief Fixture class that helps testing AdaptorConfig
+class AdaptorConfigTest : public ::testing::Test {
+public:
+
+/// @brief Load an example JSON config
+///
+/// @param fname name of the file (expected to be a valid JSON config)
+/// @param v6 - false=v4, true=v6
+/// @param result - JSON converted by a AdaptorConfig::preprocess[4/6]
+void testFile(const string& fname, bool v6, ElementPtr& result) {
+ ElementPtr json;
+ ElementPtr reference_json;
+
+ string decommented = decommentJSONfile(fname);
+
+ EXPECT_NO_THROW_LOG(json = Element::fromJSONFile(decommented, true));
+ reference_json = moveComments(json);
+
+ // remove the temporary file
+ EXPECT_NO_THROW_LOG(::remove(decommented.c_str()));
+
+ string before = json->str();
+ if (v6) {
+ ASSERT_NO_THROW_LOG(AdaptorConfig::preProcess6(json));
+ } else {
+ ASSERT_NO_THROW_LOG(AdaptorConfig::preProcess4(json));
+ }
+ string after = json->str();
+
+ EXPECT_FALSE(before.empty());
+ EXPECT_FALSE(after.empty());
+
+ result = json;
+}
+
+}; // AdaptorConfigTest
+
+TEST_F(AdaptorConfigTest, loadExamples4) {
+ vector<string> configs = {
+ "advanced.json",
+ "all-keys-netconf.json",
+ "all-options.json",
+ "backends.json",
+ "classify.json",
+ "classify2.json",
+ "comments.json",
+ "config-backend.json",
+ "dhcpv4-over-dhcpv6.json",
+ "dnr.json",
+ "global-reservations.json",
+ "ha-load-balancing-server1-mt-with-tls.json",
+ "ha-load-balancing-server2-mt.json",
+ "hooks.json",
+ "hooks-radius.json",
+ "leases-expiration.json",
+ "multiple-options.json",
+ "mysql-reservations.json",
+ "pgsql-reservations.json",
+ "reservations.json",
+ "several-subnets.json",
+ "shared-network.json",
+ "single-subnet.json",
+ "vendor-specific.json",
+ "vivso.json",
+ "with-ddns.json",
+ };
+
+ ElementPtr x;
+
+ for (int i = 0; i<configs.size(); i++) {
+ x.reset();
+ testFile(string(CFG_EXAMPLES) + "/kea4/" + configs[i], false, x);
+ ASSERT_TRUE(x);
+ }
+}
+
+TEST_F(AdaptorConfigTest, loadExamples6) {
+ vector<string> configs = {
+ "advanced.json",
+ "all-keys-netconf.json",
+ "all-options.json",
+ "backends.json",
+ "classify.json",
+ "classify2.json",
+ "comments.json",
+ "config-backend.json",
+ "dhcpv4-over-dhcpv6.json",
+ "dnr.json",
+ "duid.json",
+ "global-reservations.json",
+ "ha-hot-standby-server1-with-tls.json",
+ "ha-hot-standby-server2.json",
+ "hooks.json",
+ "iPXE.json",
+ "leases-expiration.json",
+ "multiple-options.json",
+ "mysql-reservations.json",
+ "pgsql-reservations.json",
+ "reservations.json",
+ "several-subnets.json",
+ "shared-network.json",
+ "simple.json",
+ "softwire46.json",
+ "stateless.json",
+ "tee-times.json",
+ "with-ddns.json",
+ };
+ ElementPtr x;
+
+ for (int i = 0; i<configs.size(); i++) {
+ x.reset();
+ testFile(string(CFG_EXAMPLES) + "/kea6/" + configs[i], true, x);
+ ASSERT_TRUE(x);
+ }
+}
+
+/// In general, the AdatorConfig class doesn't need very thorough
+/// direct tests, as there will be tests that will process whole
+/// configuration that will in turn use AdaptorConfig calls.
+/// Nevertheless, here are some ideas for tests. We hope to have
+/// them implemented one day.
+///
+/// @todo: Check subnet-id assigned in subnets using any config
+/// @todo: Check shared-networks assign id using kea4/shared-network.json
+/// @todo: Check option classes using kea4/classify2.json
+/// @todo: Check option data using kea6/with-ddns.json
+/// @todo: Check option defs using kea6/dhcpv4-over-dhcpv6.json
+
+} // anonymous namespace
diff --git a/src/lib/yang/tests/adaptor_host_unittests.cc b/src/lib/yang/tests/adaptor_host_unittests.cc
new file mode 100644
index 0000000..0d50632
--- /dev/null
+++ b/src/lib/yang/tests/adaptor_host_unittests.cc
@@ -0,0 +1,119 @@
+// 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 <gtest/gtest.h>
+
+#include <testutils/gtest_utils.h>
+#include <yang/adaptor_host.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+
+namespace {
+
+// Verifies that quoteIdentifier does not touch an identifier which
+// has a type different from flex-d.
+TEST(AdaptorHostTest, notFlexId) {
+ string config = "{\n"
+ " \"hw-address\": \"1a:1b:1c:1d:1e:1f\",\n"
+ " \"ip-address\": \"192.0.2.201\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorHost::quoteIdentifier(json));
+ EXPECT_TRUE(copied->equals(*json));
+}
+
+// Verifies that quoteIdentifier does not touch a flex-id identifier
+// without quotes.
+TEST(AdaptorHostTest, noQuote) {
+ string config = "{\n"
+ " \"flex-id\": \"s0mEVaLue\",\n"
+ " \"ip-address\": \"192.0.2.206\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorHost::quoteIdentifier(json));
+ EXPECT_TRUE(copied->equals(*json));
+}
+
+// Verifies that quoteIdentifier removes quotes from a flex-id identifier.
+TEST(AdaptorHostTest, quotes) {
+ string config = "{\n"
+ " \"flex-id\": \"'somevalue'\",\n"
+ " \"ip-addresses\": \"2001:db8:1:cafe::2\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorHost::quoteIdentifier(json));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr id = json->get("flex-id");
+ ASSERT_TRUE(id);
+ ASSERT_EQ(Element::string, id->getType());
+ EXPECT_EQ("73:6f:6d:65:76:61:6c:75:65", id->stringValue());
+}
+
+// Verifies that quoteIdentifier removes quotes from a flex-id identifier
+// but does not interpret a quote in the middle.
+TEST(AdaptorHostTest, extraQuote) {
+ string config = "{\n"
+ " \"flex-id\": \"'some'value'\",\n"
+ " \"ip-addresses\": \"2001:db8:1:cafe::2\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorHost::quoteIdentifier(json));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr id = json->get("flex-id");
+ ASSERT_TRUE(id);
+ ASSERT_EQ(Element::string, id->getType());
+ EXPECT_EQ("73:6f:6d:65:27:76:61:6c:75:65", id->stringValue());
+}
+
+// Verifies that quoteIdentifier works on not standard characters too.
+TEST(AdaptorHostTest, notStandard) {
+ string config = "{\n"
+ " \"flex-id\": \"'some\\\"value'\",\n"
+ " \"ip-addresses\": \"2001:db8:1:cafe::2\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorHost::quoteIdentifier(json));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr id = json->get("flex-id");
+ ASSERT_TRUE(id);
+ ASSERT_EQ(Element::string, id->getType());
+ EXPECT_EQ("73:6f:6d:65:22:76:61:6c:75:65", id->stringValue());
+}
+
+// Verifies that quoteIdentifier works on not standard characters too
+// even without quotes.
+TEST(AdaptorHostTest, notQuoted) {
+ string config = "{\n"
+ " \"flex-id\": \"some\\\"value\",\n"
+ " \"ip-addresses\": \"2001:db8:1:cafe::2\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorHost::quoteIdentifier(json));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr id = json->get("flex-id");
+ ASSERT_TRUE(id);
+ ASSERT_EQ(Element::string, id->getType());
+ EXPECT_EQ("73:6f:6d:65:22:76:61:6c:75:65", id->stringValue());
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/adaptor_option_unittests.cc b/src/lib/yang/tests/adaptor_option_unittests.cc
new file mode 100644
index 0000000..9fdcb9c
--- /dev/null
+++ b/src/lib/yang/tests/adaptor_option_unittests.cc
@@ -0,0 +1,245 @@
+// 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 <gtest/gtest.h>
+
+#include <dhcp/dhcp4.h>
+#include <dhcp/dhcp6.h>
+#include <dhcp/option_data_types.h>
+#include <dhcp/option_space.h>
+#include <testutils/gtest_utils.h>
+#include <yang/adaptor_option.h>
+#include <yang/netconf_error.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::dhcp;
+using namespace isc::yang;
+
+namespace {
+
+// Verifies that setSpace adds a space to an option without this entry.
+TEST(AdaptorOptionTest, setSpaceNoSpace) {
+ string config = "{\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorOption::setSpace(json, "foo"));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr space = json->get("space");
+ ASSERT_TRUE(space);
+ ASSERT_EQ(Element::string, space->getType());
+ EXPECT_EQ("foo", space->stringValue());
+}
+
+// Verifies that setSpace does not change to an option with space.
+TEST(AdaptorOptionTest, setSpace) {
+ string config = "{\n"
+ " \"space\": \"dhcp4\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorOption::setSpace(json, "foo"));
+ EXPECT_TRUE(copied->equals(*json));
+}
+
+// Verifies that checkType accepts an option with type.
+TEST(AdaptorOptionTest, checkType) {
+ string config = "{\n"
+ " \"type\": \"string\"\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ EXPECT_NO_THROW_LOG(AdaptorOption::checkType(json));
+}
+
+// Verifies that checkType does not accept an option without type.
+TEST(AdaptorOptionTest, checkTypeNoType) {
+ string config = "{\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ EXPECT_THROW_MSG(AdaptorOption::checkType(json), MissingKey,
+ "missing type in option definition { }");
+}
+
+// Verifies that checkCode accepts an option with code.
+TEST(AdaptorOptionTest, checkCode) {
+ string config = "{\n"
+ " \"code\": 123\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ EXPECT_NO_THROW_LOG(AdaptorOption::checkCode(json));
+}
+
+// Verifies that checkCode does not accept an option without code.
+TEST(AdaptorOptionTest, checkCodeNoCode) {
+ string config = "{\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ EXPECT_THROW_MSG(AdaptorOption::checkCode(json), MissingKey, "missing code in option { }");
+}
+
+// Verifies that collect works as expected.
+TEST(AdaptorOptionTest, collect) {
+ string config = "{\n"
+ " \"code\": 123,\n"
+ " \"name\": \"foo\",\n"
+ " \"space\": \"bar\"\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ OptionCodes codes;
+ ASSERT_NO_THROW_LOG(AdaptorOption::collect(json, codes));
+ EXPECT_EQ(1, codes.size());
+ EXPECT_EQ(123, codes["bar@foo"]);
+ EXPECT_FALSE(codes.contains("foo@bar"));
+}
+
+// Verifies that collect skips an already known option definition.
+TEST(AdaptorOptionTest, collectKnown) {
+ string config = "{\n"
+ " \"code\": 123,\n"
+ " \"name\": \"foo\",\n"
+ " \"space\": \"bar\"\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ OptionCodes codes = { { "bar@foo", 111 } };
+ ASSERT_NO_THROW_LOG(AdaptorOption::collect(json, codes));
+ EXPECT_EQ(1, codes.size());
+ EXPECT_EQ(111, codes["bar@foo"]);
+}
+
+// Verifies that setCode adds a code to an option without this entry
+// when the code is available in the map.
+TEST(AdaptorOptionTest, setCodeNoCode) {
+ string config = "{\n"
+ " \"name\": \"foo\",\n"
+ " \"space\": \"bar\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ OptionCodes codes = { { "bar@foo", 123 } };
+ EXPECT_NO_THROW_LOG(AdaptorOption::setCode(json, codes));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr code = json->get("code");
+ ASSERT_TRUE(code);
+ ASSERT_EQ(Element::integer, code->getType());
+ EXPECT_EQ(123, code->intValue());
+}
+
+// Verifies that setCode does not change to an option with code.
+TEST(AdaptorOptionTest, setCode) {
+ string config = "{\n"
+ " \"code\": \"dhcp4\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ OptionCodes codes;
+ EXPECT_NO_THROW_LOG(AdaptorOption::setCode(json, codes));
+ EXPECT_TRUE(copied->equals(*json));
+}
+
+// Verifies that setCode raises an error on option without name and code.
+TEST(AdaptorOptionTest, setCodeNoName) {
+ string config = "{\n"
+ " \"space\": \"bar\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ OptionCodes codes;
+ EXPECT_THROW_MSG(AdaptorOption::setCode(json, codes), MissingKey,
+ "missing name and code in option { \"space\": \"bar\" }");
+}
+
+// Note the code assumes there is a space, i.e. setSpace was called.
+
+// Verifies that setCode raises an error on option without code but
+// the code is not available in the map.
+TEST(AdaptorOptionTest, setCodeNotInMap) {
+ string config = "{\n"
+ " \"name\": \"foo\",\n"
+ " \"space\": \"bar\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ OptionCodes codes;
+ EXPECT_THROW_MSG(AdaptorOption::setCode(json, codes), MissingKey,
+ "can't get code from option { \"name\": \"foo\", \"space\": \"bar\" }");
+}
+
+/// @brief Test class to make initCodes public.
+class TestAdaptorOption : public AdaptorOption {
+public:
+ using AdaptorOption::initCodesInternal;
+}; // TestAdaptorOption
+
+// Verifies that initCodesInternal works as expected.
+TEST(AdaptorOptionTest, initCodesInternal) {
+ const OptionDefParams DEFS[] = {
+ { "subnet-mask", DHO_SUBNET_MASK, DHCP4_OPTION_SPACE,
+ OPT_IPV4_ADDRESS_TYPE, false, 0, 0, "" },
+ { "time-offset", DHO_TIME_OFFSET, DHCP4_OPTION_SPACE, OPT_INT32_TYPE,
+ false, 0, 0, "" }
+ };
+ const size_t DEFS_SIZE = sizeof(DEFS) / sizeof(DEFS[0]);
+ OptionCodes codes;
+ ASSERT_NO_THROW_LOG(TestAdaptorOption::initCodesInternal(codes,
+ DHCP4_OPTION_SPACE,
+ DEFS,
+ DEFS_SIZE));
+ ASSERT_EQ(2, codes.size());
+ EXPECT_EQ(DHO_SUBNET_MASK, codes["dhcp4@subnet-mask"]);
+ EXPECT_EQ(DHO_TIME_OFFSET, codes["dhcp4@time-offset"]);
+}
+
+// Verifies that initCodes works as expected with DHCPv4.
+TEST(AdaptorOptionTest, initCodes4) {
+ OptionCodes codes;
+ ASSERT_NO_THROW_LOG(AdaptorOption::initCodes(codes, DHCP4_OPTION_SPACE));
+ EXPECT_EQ(DHO_SUBNET_MASK, codes["dhcp4@subnet-mask"]);
+ EXPECT_EQ(DHO_TIME_OFFSET, codes["dhcp4@time-offset"]);
+ EXPECT_FALSE(codes.contains("dhcp6@clientid"));
+
+ // initCodes loads last resort too.
+ EXPECT_EQ(DHO_VENDOR_ENCAPSULATED_OPTIONS,
+ codes["dhcp4@vendor-encapsulated-options"]);
+
+ // and DOCSIS3.
+ EXPECT_EQ(2, codes["vendor-4491@tftp-servers"]);
+}
+
+// Verifies that initCodes works as expected with DHCPv6.
+TEST(AdaptorOptionTest, initCodes6) {
+ OptionCodes codes;
+ ASSERT_NO_THROW_LOG(AdaptorOption::initCodes(codes, DHCP6_OPTION_SPACE));
+ EXPECT_EQ(D6O_CLIENTID, codes["dhcp6@clientid"]);
+ EXPECT_EQ(D6O_SERVERID, codes["dhcp6@serverid"]);
+ EXPECT_FALSE(codes.contains("dhcp4@subnet-mask"));
+
+ // initCodes loads DOCSIS3 too.
+ EXPECT_EQ(32, codes["vendor-4491@tftp-servers"]);
+
+ // Various MAP suboptions.
+ EXPECT_EQ(D6O_S46_BR, codes["s46-cont-mape-options@s46-br"]);
+ EXPECT_EQ(D6O_S46_V4V6BIND, codes["s46-cont-lw-options@s46-v4v6bind"]);
+ EXPECT_EQ(D6O_S46_PORTPARAMS, codes["s46-v4v6bind-options@s46-portparams"]);
+
+ // And ISC space.
+ EXPECT_EQ(ISC_V6_4O6_INTERFACE, codes["vendor-2495@4o6-interface"]);
+}
+
+} //anonymous namespace
diff --git a/src/lib/yang/tests/adaptor_pool_unittests.cc b/src/lib/yang/tests/adaptor_pool_unittests.cc
new file mode 100644
index 0000000..6152834
--- /dev/null
+++ b/src/lib/yang/tests/adaptor_pool_unittests.cc
@@ -0,0 +1,276 @@
+// 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 <gtest/gtest.h>
+
+#include <testutils/gtest_utils.h>
+#include <yang/adaptor_pool.h>
+#include <yang/yang_models.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+
+namespace {
+
+// Verifies that canonizePool does not touch a prefix without space.
+TEST(AdaptorPoolTest, canonizePoolPrefixNoSpace) {
+ string config = "{\n"
+ " \"pool\": \"192.0.2.128/28\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorPool::canonizePool(json));
+ EXPECT_TRUE(copied->equals(*json));
+}
+
+// Verifies that canonizePool does not touch a canonical range.
+TEST(AdaptorPoolTest, canonizePoolRange) {
+ string config = "{\n"
+ " \"pool\": \"192.0.2.1 - 192.0.2.200\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorPool::canonizePool(json));
+ EXPECT_TRUE(copied->equals(*json));
+}
+
+// Verifies that canonizePool removes spaces from a prefix.
+TEST(AdaptorPoolTest, canonizePoolPrefixSpaces) {
+ string config = "{\n"
+ " \"pool\": \"192.0.2.128 /\t28\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorPool::canonizePool(json));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr pool = json->get("pool");
+ ASSERT_TRUE(pool);
+ ASSERT_EQ(Element::string, pool->getType());
+ EXPECT_EQ("192.0.2.128/28", pool->stringValue());
+}
+
+// Verifies that canonizePool adds two spaces from a range.
+TEST(AdaptorPoolTest, canonizePoolRangeNoSpace) {
+ string config = "{\n"
+ " \"pool\": \"192.0.2.1-192.0.2.200\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorPool::canonizePool(json));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr pool = json->get("pool");
+ ASSERT_TRUE(pool);
+ ASSERT_EQ(Element::string, pool->getType());
+ EXPECT_EQ("192.0.2.1 - 192.0.2.200", pool->stringValue());
+}
+
+// Verifies that canonizePool removes extra spaces from a range.
+TEST(AdaptorPoolTest, canonizePoolRangeExtraSpaces) {
+ string config = "{\n"
+ " \"pool\": \"192.0.2.1 - 192.0.2.200\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ EXPECT_NO_THROW_LOG(AdaptorPool::canonizePool(json));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr pool = json->get("pool");
+ ASSERT_TRUE(pool);
+ ASSERT_EQ(Element::string, pool->getType());
+ EXPECT_EQ("192.0.2.1 - 192.0.2.200", pool->stringValue());
+}
+
+// Verifies that fromSubnet is specific to ietf-dhcpv6-server model.
+TEST(AdaptorPoolTest, fromSubnetKea) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"192.0.2.1 - 192.0.2.100\"\n"
+ " },{\n"
+ " \"pool\": \"192.0.2.101 - 192.0.2.200\"\n"
+ " } ],\n"
+ " \"valid-lifetime\": 4000,\n"
+ " \"renew-timer\": 1000,\n"
+ " \"rebind-timer\": 2000\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ConstElementPtr pools = json->get("pools");
+
+ // This should be no-op for kea-dhcp4-server and kea-dhcp6-server models
+ EXPECT_NO_THROW_LOG(AdaptorPool::fromSubnet(KEA_DHCP4_SERVER, json, pools));
+ EXPECT_TRUE(copied->equals(*json));
+ // The model is checked first.
+ EXPECT_NO_THROW_LOG(AdaptorPool::fromSubnet(KEA_DHCP6_SERVER, json, pools));
+ EXPECT_TRUE(copied->equals(*json));
+
+ // Check that the model name is actually checked.
+ EXPECT_THROW_MSG(AdaptorPool::fromSubnet("non-existent-module", json, pools), NotImplemented,
+ "fromSubnet not implemented for the model: non-existent-module");
+}
+
+// Verifies that fromSubnet works as expected.
+TEST(AdaptorPoolTest, fromSubnet) {
+ string config = "{\n"
+ " \"subnet\": \"2001:db8:1::/64\",\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"2001:db8:1::/80\"\n"
+ " },{\n"
+ " \"pool\": \"2001:db8:1:0:1::/80\"\n"
+ " } ],\n"
+ " \"preferred-lifetime\": 3000,\n"
+ " \"valid-lifetime\": 4000,\n"
+ " \"renew-timer\": 1000,\n"
+ " \"rebind-timer\": 2000\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ConstElementPtr pools = json->get("pools");
+ EXPECT_NO_THROW_LOG(AdaptorPool::fromSubnet(IETF_DHCPV6_SERVER, json, pools));
+ EXPECT_FALSE(copied->equals(*json));
+ pools = json->get("pools");
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(2, pools->size());
+ ConstElementPtr pool = pools->get(0);
+ ASSERT_TRUE(pool);
+ string expected = "{"
+ " \"pool\": \"2001:db8:1::/80\","
+ " \"preferred-lifetime\": 3000,"
+ " \"rebind-timer\": 2000,"
+ " \"renew-timer\": 1000,"
+ " \"valid-lifetime\": 4000 }";
+ EXPECT_EQ(expected, pool->str());
+ pool = pools->get(1);
+ ASSERT_TRUE(pool);
+ expected = "{"
+ " \"pool\": \"2001:db8:1:0:1::/80\","
+ " \"preferred-lifetime\": 3000,"
+ " \"rebind-timer\": 2000,"
+ " \"renew-timer\": 1000,"
+ " \"valid-lifetime\": 4000 }";
+ EXPECT_EQ(expected, pool->str());
+}
+
+// Verifies that toSubnet is specific to ietf-dhcpv6-server model.
+TEST(AdaptorPoolTest, toSubnetKea) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"192.0.2.1 - 192.0.2.100\"\n"
+ " },{\n"
+ " \"pool\": \"192.0.2.101 - 192.0.2.200\"\n"
+ " } ],\n"
+ " \"valid-lifetime\": 4000,\n"
+ " \"renew-timer\": 1000,\n"
+ " \"rebind-timer\": 2000\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ConstElementPtr pools = json->get("pools");
+ EXPECT_NO_THROW_LOG(AdaptorPool::toSubnet(KEA_DHCP4_SERVER, json, pools));
+ EXPECT_TRUE(copied->equals(*json));
+ // The model is checked first.
+ EXPECT_NO_THROW_LOG(AdaptorPool::toSubnet(KEA_DHCP6_SERVER, json, pools));
+ EXPECT_TRUE(copied->equals(*json));
+ // Model name is not free: an error is raised if it is not expected.
+ EXPECT_THROW_MSG(AdaptorPool::toSubnet("keatest-module", json, pools), NotImplemented,
+ "toSubnet not implemented for the model: keatest-module");
+}
+
+// Verifies that toSubnet works as expected.
+TEST(AdaptorPoolTest, toSubnet) {
+ string config = "{\n"
+ " \"subnet\": \"2001:db8:1::/64\",\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"2001:db8:1::/80\",\n"
+ " \"preferred-lifetime\": 3000,\n"
+ " \"valid-lifetime\": 4000,\n"
+ " \"renew-timer\": 1000,\n"
+ " \"rebind-timer\": 2000\n"
+ " },{\n"
+ " \"pool\": \"2001:db8:1:0:1::/80\",\n"
+ " \"preferred-lifetime\": 3000,\n"
+ " \"valid-lifetime\": 4000,\n"
+ " \"renew-timer\": 1000,\n"
+ " \"rebind-timer\": 2000\n"
+ " } ]\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ConstElementPtr pools = json->get("pools");
+ EXPECT_NO_THROW_LOG(AdaptorPool::toSubnet(IETF_DHCPV6_SERVER, json, pools));
+ EXPECT_FALSE(copied->equals(*json));
+ // Check timers.
+ ConstElementPtr timer = json->get("valid-lifetime");
+ ASSERT_TRUE(timer);
+ EXPECT_EQ("4000", timer->str());
+ timer = json->get("preferred-lifetime");
+ ASSERT_TRUE(timer);
+ EXPECT_EQ("3000", timer->str());
+ timer = json->get("renew-timer");
+ ASSERT_TRUE(timer);
+ EXPECT_EQ("1000", timer->str());
+ timer = json->get("rebind-timer");
+ ASSERT_TRUE(timer);
+ EXPECT_EQ("2000", timer->str());
+ // Timers must be removed as they are not allowed here in Kea.
+ pools = json->get("pools");
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(2, pools->size());
+ ConstElementPtr pool = pools->get(0);
+ ASSERT_TRUE(pool);
+ EXPECT_EQ("{ \"pool\": \"2001:db8:1::/80\" }", pool->str());
+ pool = pools->get(1);
+ ASSERT_TRUE(pool);
+ EXPECT_EQ("{ \"pool\": \"2001:db8:1:0:1::/80\" }", pool->str());
+}
+
+// Verifies that toSubnet fails on inconsistent input.
+TEST(AdaptorPoolTest, toSubnetBad) {
+ // Changed last rebind-timer to a different value.
+ string config = "{\n"
+ " \"subnet\": \"2001:db8:1::/64\",\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"2001:db8:1::/80\",\n"
+ " \"preferred-lifetime\": 3000,\n"
+ " \"valid-lifetime\": 4000,\n"
+ " \"renew-timer\": 1000,\n"
+ " \"rebind-timer\": 2000\n"
+ " },{\n"
+ " \"pool\": \"2001:db8:1:0:1::/80\",\n"
+ " \"preferred-lifetime\": 3000,\n"
+ " \"valid-lifetime\": 4000,\n"
+ " \"renew-timer\": 1000,\n"
+ " \"rebind-timer\": 20\n"
+ " } ]\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr pools = json->get("pools");
+ EXPECT_THROW_MSG(AdaptorPool::toSubnet(IETF_DHCPV6_SERVER, json, pools), BadValue,
+ "inconsistent value of rebind-timer in [ { \"pool\": \"2001:db8:1::/80\", "
+ "\"rebind-timer\": 2000 }, { \"pool\": \"2001:db8:1:0:1::/80\", "
+ "\"rebind-timer\": 20 } ]");
+}
+
+} // anonymous namespace
diff --git a/src/lib/yang/tests/adaptor_subnet_unittests.cc b/src/lib/yang/tests/adaptor_subnet_unittests.cc
new file mode 100644
index 0000000..4b744b4
--- /dev/null
+++ b/src/lib/yang/tests/adaptor_subnet_unittests.cc
@@ -0,0 +1,214 @@
+// 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 <gtest/gtest.h>
+
+#include <dhcpsrv/subnet_id.h>
+#include <testutils/gtest_utils.h>
+#include <yang/adaptor_subnet.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::dhcp;
+using namespace isc::yang;
+
+namespace {
+
+// Verifies how collectID handles a subnet entry without ID.
+TEST(AdaptorSubnetTest, collectNoId) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\"\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ SubnetIDSet set;
+ bool ret = true;
+ ASSERT_NO_THROW_LOG(ret = AdaptorSubnet::collectID(json, set));
+ EXPECT_FALSE(ret);
+ EXPECT_EQ(0, set.size());
+}
+
+// Verifies how collectID handles a subnet entry with an ID.
+TEST(AdaptorSubnetTest, collectId) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"id\": 123\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ SubnetIDSet set;
+ bool ret = false;
+ ASSERT_NO_THROW_LOG(ret = AdaptorSubnet::collectID(json, set));
+ EXPECT_TRUE(ret);
+ EXPECT_EQ(1, set.size());
+ EXPECT_EQ(1, set.count(123));
+}
+
+// Verifies how collectID handles a subnet entry with an ID which is
+// already known: the set is not updated.
+TEST(AdaptorSubnetTest, collectKnownId) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"id\": 123\n"
+ "}";
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ SubnetIDSet set = { 123 };
+ bool ret = false;
+ ASSERT_NO_THROW_LOG(ret = AdaptorSubnet::collectID(json, set));
+ EXPECT_TRUE(ret);
+ EXPECT_EQ(1, set.size());
+ EXPECT_EQ(1, set.count(123));
+}
+
+// Verifies how assignID handles a subnet entry without ID: the next ID
+// is assigned, the set is updated and the next ID is incremented.
+TEST(AdaptorSubnetTest, assignNoId) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ SubnetIDSet set;
+ SubnetID next_id = 123;
+ ASSERT_NO_THROW_LOG(AdaptorSubnet::assignID(json, set, next_id));
+ EXPECT_FALSE(copied->equals(*json));
+ EXPECT_EQ(1, set.size());
+ EXPECT_EQ(1, set.count(123));
+ EXPECT_EQ(124, next_id);
+ ConstElementPtr id = json->get("id");
+ ASSERT_TRUE(id);
+ ASSERT_EQ(Element::integer, id->getType());
+ EXPECT_EQ(123, id->intValue());
+}
+
+// Verifies how assignID handles a subnet entry without ID but with the
+// candidate ID already used: the used value is skipped.
+TEST(AdaptorSubnetTest, assignNoIdUsed) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ SubnetIDSet set = { 123 };
+ SubnetID next_id = 123;
+ ASSERT_NO_THROW_LOG(AdaptorSubnet::assignID(json, set, next_id));
+ EXPECT_FALSE(copied->equals(*json));
+ EXPECT_EQ(2, set.size());
+ EXPECT_EQ(1, set.count(123));
+ EXPECT_EQ(1, set.count(124));
+ EXPECT_EQ(125, next_id);
+ ConstElementPtr id = json->get("id");
+ ASSERT_TRUE(id);
+ ASSERT_EQ(Element::integer, id->getType());
+ EXPECT_EQ(124, id->intValue());
+}
+
+// Verifies how assignID handles a subnet entry with ID: no change.
+TEST(AdaptorSubnetTest, assignId) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"id\": 123\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ SubnetIDSet set; // ignored.
+ SubnetID next_id = 123; // ignored.
+ ASSERT_NO_THROW_LOG(AdaptorSubnet::assignID(json, set, next_id));
+ EXPECT_TRUE(copied->equals(*json));
+ EXPECT_EQ(0, set.size());
+ EXPECT_EQ(123, next_id);
+}
+
+// Verifies how updateRelay handles a subnet entry without relay: no change.
+TEST(AdaptorSubnetTest, updateNoRelay) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\"\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ASSERT_NO_THROW_LOG(AdaptorSubnet::updateRelay(json));
+ EXPECT_TRUE(copied->equals(*json));
+}
+
+// Verifies how updateRelay handles a subnet entry with empty relay:
+// the relay entry is useless and removed.
+TEST(AdaptorSubnetTest, updateEmptyRelay) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"relay\": { }\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ASSERT_NO_THROW_LOG(AdaptorSubnet::updateRelay(json));
+ EXPECT_FALSE(copied->equals(*json));
+ EXPECT_FALSE(json->get("relay"));
+}
+
+// Verifies how updateRelay handles a subnet entry with relay which
+// has empty addresses: the relay entry is useless and removed.
+TEST(AdaptorSubnetTest, updateRelayEmptyAddresses) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"relay\": {\n"
+ " \"ip-addresses\": [ ]\n"
+ " }\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ASSERT_NO_THROW_LOG(AdaptorSubnet::updateRelay(json));
+ EXPECT_FALSE(copied->equals(*json));
+ EXPECT_FALSE(json->get("relay"));
+}
+
+// Verifies how updateRelay handles a subnet entry with relay which
+// has addresses: no change.
+TEST(AdaptorSubnetTest, updateRelayAddresses) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"relay\": {\n"
+ " \"ip-addresses\": [ \"192.168.1.1\" ]\n"
+ " }\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ASSERT_NO_THROW_LOG(AdaptorSubnet::updateRelay(json));
+ EXPECT_TRUE(copied->equals(*json));
+}
+
+// Verifies how updateRelay handles a subnet entry with relay which
+// has only address: the address is moved to a new list.
+TEST(AdaptorSubnetTest, updateRelayAddress) {
+ string config = "{\n"
+ " \"subnet\": \"192.0.2.0/24\",\n"
+ " \"relay\": {\n"
+ " \"ip-address\": \"192.168.1.1\"\n"
+ " }\n"
+ "}";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ ConstElementPtr copied = copy(json);
+ ASSERT_NO_THROW_LOG(AdaptorSubnet::updateRelay(json));
+ EXPECT_FALSE(copied->equals(*json));
+ ConstElementPtr relay = json->get("relay");
+ ASSERT_TRUE(relay);
+ string expected = "{ \"ip-addresses\": [ \"192.168.1.1\" ] }";
+ EXPECT_EQ(expected, relay->str());
+}
+
+// It does not make sense to have both ip-address and ip-addresses...
+
+} // anonymous namespace
diff --git a/src/lib/yang/tests/adaptor_unittests.cc b/src/lib/yang/tests/adaptor_unittests.cc
new file mode 100644
index 0000000..f95d5d3
--- /dev/null
+++ b/src/lib/yang/tests/adaptor_unittests.cc
@@ -0,0 +1,398 @@
+// 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 <gtest/gtest.h>
+
+#include <testutils/gtest_utils.h>
+#include <yang/adaptor.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+
+namespace {
+
+// Test that get context works as expected i.e. moves a comment into
+// the user context creating it if not exists.
+TEST(AdaptorTest, getContext) {
+ // Empty.
+ string config = "{\n"
+ "}\n";
+ ElementPtr json = Element::fromJSON(config);
+ ConstElementPtr context;
+ ASSERT_NO_THROW_LOG(context = Adaptor::getContext(json));
+ EXPECT_FALSE(context);
+
+ // No relevant.
+ config = "{\n"
+ " \"foo\": 1\n"
+ "}\n";
+ json = Element::fromJSON(config);
+ ASSERT_NO_THROW_LOG(context = Adaptor::getContext(json));
+ EXPECT_FALSE(context);
+
+ // User context.
+ config = "{\n"
+ " \"foo\": 1,\n"
+ " \"user-context\": { \"bar\": 2 }\n"
+ "}\n";
+ json = Element::fromJSON(config);
+ ASSERT_NO_THROW_LOG(context = Adaptor::getContext(json));
+ ASSERT_TRUE(context);
+ EXPECT_EQ("{ \"bar\": 2 }", context->str());
+
+ // Comment.
+ config = "{\n"
+ " \"foo\": 1,\n"
+ " \"comment\": \"a comment\"\n"
+ "}\n";
+ json = Element::fromJSON(config);
+ ASSERT_NO_THROW_LOG(context = Adaptor::getContext(json));
+ ASSERT_TRUE(context);
+ EXPECT_EQ("{ \"comment\": \"a comment\" }", context->str());
+
+ // User context and comment.
+ config = "{\n"
+ " \"foo\": 1,\n"
+ " \"user-context\": { \"bar\": 2 },\n"
+ " \"comment\": \"a comment\"\n"
+ "}\n";
+ json = Element::fromJSON(config);
+ ASSERT_NO_THROW_LOG(context = Adaptor::getContext(json));
+ ASSERT_TRUE(context);
+ EXPECT_EQ("{ \"bar\": 2, \"comment\": \"a comment\" }", context->str());
+
+ // User context with conflicting comment and comment.
+ config = "{\n"
+ " \"foo\": 1,\n"
+ " \"user-context\": {\n"
+ " \"bar\": 2,\n"
+ " \"comment\": \"conflicting\"\n"
+ " },\n"
+ " \"comment\": \"a comment\"\n"
+ "}\n";
+ json = Element::fromJSON(config);
+ ASSERT_NO_THROW_LOG(context = Adaptor::getContext(json));
+ ASSERT_TRUE(context);
+ EXPECT_EQ("{ \"bar\": 2, \"comment\": \"a comment\" }", context->str());
+}
+
+// Test that fromParent works as expected i.e. moves parameters from the
+// parent to children and not overwrite them.
+TEST(AdaptorTest, fromParent) {
+ string config = "{\n"
+ " \"param1\": 123,\n"
+ " \"param2\": \"foo\",\n"
+ " \"list\": [\n"
+ " {\n"
+ " \"param1\": 234\n"
+ " },{\n"
+ " \"another\": \"entry\"\n"
+ " }\n"
+ " ]\n"
+ "}\n";
+
+ ElementPtr json = Element::fromJSON(config);
+ EXPECT_NO_THROW_LOG(Adaptor::fromParent("param1", json, json->get("list")));
+ EXPECT_NO_THROW_LOG(Adaptor::fromParent("param2", json, json->get("list")));
+ EXPECT_NO_THROW_LOG(Adaptor::fromParent("param3", json, json->get("list")));
+
+ string expected = "{\n"
+ " \"param1\": 123,\n"
+ " \"param2\": \"foo\",\n"
+ " \"list\": [\n"
+ " {\n"
+ " \"param1\": 234,\n"
+ " \"param2\": \"foo\"\n"
+ " },{\n"
+ " \"another\": \"entry\",\n"
+ " \"param1\": 123,\n"
+ " \"param2\": \"foo\"\n"
+ " }\n"
+ " ]\n"
+ "}\n";
+ EXPECT_TRUE(json->equals(*Element::fromJSON(expected)));
+}
+
+// Test that toParent works as expected i.e. moves parameters from children
+// to the parent throwing when a value differs between two children.
+TEST(AdaptorTest, toParent) {
+ string config = "{\n"
+ " \"list\": [\n"
+ " {\n"
+ " \"param2\": \"foo\",\n"
+ " \"param3\": 234,\n"
+ " \"param4\": true\n"
+ " },{\n"
+ " \"another\": \"entry\",\n"
+ " \"param2\": \"foo\",\n"
+ " \"param3\": 123,\n"
+ " \"param5\": false\n"
+ " }\n"
+ " ]\n"
+ "}\n";
+
+ ElementPtr json = Element::fromJSON(config);
+ EXPECT_NO_THROW_LOG(Adaptor::toParent("param1", json, json->get("list")));
+ EXPECT_TRUE(json->equals(*Element::fromJSON(config)));
+
+ string expected = "{\n"
+ " \"param2\": \"foo\",\n"
+ " \"list\": [\n"
+ " {\n"
+ " \"param3\": 234,\n"
+ " \"param4\": true\n"
+ " },{\n"
+ " \"another\": \"entry\",\n"
+ " \"param3\": 123,\n"
+ " \"param5\": false\n"
+ " }\n"
+ " ]\n"
+ "}\n";
+
+ EXPECT_NO_THROW_LOG(Adaptor::toParent("param2",json, json->get("list")));
+ EXPECT_TRUE(json->equals(*Element::fromJSON(expected)));
+
+ // param[345] have different values so it should throw.
+ EXPECT_THROW_MSG(Adaptor::toParent("param3", json, json->get("list")), BadValue,
+ "inconsistent value of param3 in [ { \"param3\": 234, \"param4\": true }, { "
+ "\"another\": \"entry\", \"param3\": 123, \"param5\": false } ]");
+ EXPECT_THROW_MSG(Adaptor::toParent("param4", json, json->get("list")), BadValue,
+ "inconsistent value of param4 in [ { \"param3\": 234, \"param4\": true }, { "
+ "\"another\": \"entry\", \"param3\": 123, \"param5\": false } ]");
+ EXPECT_THROW_MSG(Adaptor::toParent("param5", json, json->get("list")), BadValue,
+ "inconsistent value of param5 in [ { \"param3\": 234, \"param4\": true }, { "
+ "\"another\": \"entry\", \"param3\": 123, \"param5\": false } ]");
+
+ // And not modify the value.
+ EXPECT_TRUE(json->equals(*Element::fromJSON(expected)));
+}
+
+// Test for modify (maps & insert).
+TEST(AdaptorTest, modifyMapInsert) {
+ string config = "{\n"
+ " \"foo\": {\n"
+ " \"bar\": {\n"
+ "}}}\n";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ string spath = "[ \"foo\", \"bar\" ]";
+ ConstElementPtr path;
+ ASSERT_NO_THROW_LOG(path = Element::fromJSON(spath));
+ string sactions = "[\n"
+ "{\n"
+ " \"action\": \"insert\",\n"
+ " \"key\": \"test\",\n"
+ " \"value\": 1234\n"
+ "}]\n";
+ ConstElementPtr actions;
+ ASSERT_NO_THROW_LOG(actions = Element::fromJSON(sactions));
+ string result = "{\n"
+ " \"foo\": {\n"
+ " \"bar\": {\n"
+ " \"test\": 1234\n"
+ "}}}\n";
+ ConstElementPtr expected;
+ ASSERT_NO_THROW_LOG(expected = Element::fromJSON(result));
+ ASSERT_NO_THROW_LOG(Adaptor::modify(path, actions, json));
+ EXPECT_TRUE(expected->equals(*json));
+}
+
+// Test for modify (maps & replace).
+TEST(AdaptorTest, modifyMapReplace) {
+ string config = "{\n"
+ " \"foo\": {\n"
+ " \"bar\": {\n"
+ " \"test1\": 1234,\n"
+ " \"test2\": 1234\n"
+ "}}}\n";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ string spath = "[ \"foo\", \"bar\" ]";
+ ConstElementPtr path;
+ ASSERT_NO_THROW_LOG(path = Element::fromJSON(spath));
+ string sactions = "[\n"
+ "{\n"
+ " \"action\": \"insert\",\n"
+ " \"key\": \"test1\",\n"
+ " \"value\": 5678\n"
+ "},{\n"
+ " \"action\": \"replace\",\n"
+ " \"key\": \"test2\",\n"
+ " \"value\": 5678\n"
+ "}]\n";
+ ConstElementPtr actions;
+ ASSERT_NO_THROW_LOG(actions = Element::fromJSON(sactions));
+ string result = "{\n"
+ " \"foo\": {\n"
+ " \"bar\": {\n"
+ " \"test1\": 1234,\n"
+ " \"test2\": 5678\n"
+ "}}}\n";
+ ConstElementPtr expected;
+ ASSERT_NO_THROW_LOG(expected = Element::fromJSON(result));
+ ASSERT_NO_THROW_LOG(Adaptor::modify(path, actions, json));
+ EXPECT_TRUE(expected->equals(*json));
+}
+
+// Test for modify (maps & delete).
+TEST(AdaptorTest, modifyMapDelete) {
+ string config = "{\n"
+ " \"foo\": {\n"
+ " \"bar\": {\n"
+ " \"test\": 1234\n"
+ "}}}\n";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ string spath = "[ \"foo\", \"bar\" ]";
+ ConstElementPtr path;
+ ASSERT_NO_THROW_LOG(path = Element::fromJSON(spath));
+ string sactions = "[\n"
+ "{\n"
+ " \"action\": \"delete\",\n"
+ " \"key\": \"test\"\n"
+ "}]\n";
+ ConstElementPtr actions;
+ ASSERT_NO_THROW_LOG(actions = Element::fromJSON(sactions));
+ string result = "{\n"
+ " \"foo\": {\n"
+ " \"bar\": {\n"
+ "}}}\n";
+ ConstElementPtr expected;
+ ASSERT_NO_THROW_LOG(expected = Element::fromJSON(result));
+ ASSERT_NO_THROW_LOG(Adaptor::modify(path, actions, json));
+ EXPECT_TRUE(expected->equals(*json));
+}
+
+// Test for modify (lists & insert).
+TEST(AdaptorTest, modifyListInsert) {
+ string config = "[\n"
+ "[{\n"
+ " \"foo\": \"bar\"\n"
+ "}]]\n";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ string spath = "[ 0, { \"key\": \"foo\", \"value\": \"bar\" }]";
+ ConstElementPtr path;
+ ASSERT_NO_THROW_LOG(path = Element::fromJSON(spath));
+ string sactions = "[\n"
+ "{\n"
+ " \"action\": \"insert\",\n"
+ " \"key\": \"test\",\n"
+ " \"value\": 1234\n"
+ "}]\n";
+ ConstElementPtr actions;
+ ASSERT_NO_THROW_LOG(actions = Element::fromJSON(sactions));
+ string result = "[\n"
+ "[{\n"
+ " \"foo\": \"bar\",\n"
+ " \"test\": 1234\n"
+ "}]]\n";
+ ConstElementPtr expected;
+ ASSERT_NO_THROW_LOG(expected = Element::fromJSON(result));
+ ASSERT_NO_THROW_LOG(Adaptor::modify(path, actions, json));
+ EXPECT_TRUE(expected->equals(*json));
+}
+
+// Test for modify (list all & insert).
+TEST(AdaptorTest, modifyListAllInsert) {
+ string config = "[\n"
+ "{},\n"
+ "{},\n"
+ "{ \"test\": 1234 },\n"
+ "]\n";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ string spath = "[ -1 ]";
+ ConstElementPtr path;
+ ASSERT_NO_THROW_LOG(path = Element::fromJSON(spath));
+ string sactions = "[\n"
+ "{\n"
+ " \"action\": \"insert\",\n"
+ " \"key\": \"test\",\n"
+ " \"value\": 5678\n"
+ "}]\n";
+ ConstElementPtr actions;
+ ASSERT_NO_THROW_LOG(actions = Element::fromJSON(sactions));
+ string result = "[\n"
+ "{ \"test\": 5678 },\n"
+ "{ \"test\": 5678 },\n"
+ "{ \"test\": 1234 }\n"
+ "]\n";
+ ConstElementPtr expected;
+ ASSERT_NO_THROW_LOG(expected = Element::fromJSON(result));
+ ASSERT_NO_THROW_LOG(Adaptor::modify(path, actions, json));
+ EXPECT_TRUE(expected->equals(*json));
+}
+
+TEST(AdaptorTest, modifyListDelete) {
+ string config = "[[\n"
+ "{\n"
+ " \"foo\": \"bar\"\n"
+ "},{\n"
+ "},[\n"
+ "0, 1, 2, 3\n"
+ "]]]\n";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ string spath = "[ 0 ]";
+ ConstElementPtr path;
+ ASSERT_NO_THROW_LOG(path = Element::fromJSON(spath));
+ // Put the positional first as it applies after previous actions...
+ string sactions = "[\n"
+ "{\n"
+ " \"action\": \"delete\",\n"
+ " \"key\": 2\n"
+ "},{\n"
+ " \"action\": \"delete\",\n"
+ " \"key\": { \"key\": \"foo\", \"value\": \"bar\" }\n"
+ "}]\n";
+ ConstElementPtr actions;
+ ASSERT_NO_THROW_LOG(actions = Element::fromJSON(sactions));
+ string result = "[[{}]]\n";
+ ConstElementPtr expected;
+ ASSERT_NO_THROW_LOG(expected = Element::fromJSON(result));
+ ASSERT_NO_THROW_LOG(Adaptor::modify(path, actions, json));
+ EXPECT_TRUE(expected->equals(*json));
+}
+
+TEST(AdaptorTest, modifyListAllDelete) {
+ string config = "[[\n"
+ "{\n"
+ " \"foo\": \"bar\"\n"
+ "},{\n"
+ "},[\n"
+ "0, 1, 2, 3\n"
+ "]]]\n";
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ // The main change from the previous unit test is key 0 -> -1 so
+ // modify() applies the delete to all elements vs only the first one.
+ string spath = "[ -1 ]";
+ ConstElementPtr path;
+ ASSERT_NO_THROW_LOG(path = Element::fromJSON(spath));
+ // Put the positional first as it applies after previous actions...
+ string sactions = "[\n"
+ "{\n"
+ " \"action\": \"delete\",\n"
+ " \"key\": 2\n"
+ "},{\n"
+ " \"action\": \"delete\",\n"
+ " \"key\": { \"key\": \"foo\", \"value\": \"bar\" }\n"
+ "}]\n";
+ ConstElementPtr actions;
+ ASSERT_NO_THROW_LOG(actions = Element::fromJSON(sactions));
+ string result = "[[{}]]\n";
+ ConstElementPtr expected;
+ ASSERT_NO_THROW_LOG(expected = Element::fromJSON(result));
+ ASSERT_NO_THROW_LOG(Adaptor::modify(path, actions, json));
+ EXPECT_TRUE(expected->equals(*json));
+}
+
+} // anonymous namespace
diff --git a/src/lib/yang/tests/config_unittests.cc b/src/lib/yang/tests/config_unittests.cc
new file mode 100644
index 0000000..46b591d
--- /dev/null
+++ b/src/lib/yang/tests/config_unittests.cc
@@ -0,0 +1,392 @@
+// Copyright (C) 2018-2023 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <gtest/gtest.h>
+
+#include <testutils/io_utils.h>
+#include <testutils/user_context_utils.h>
+#include <yang/tests/json_configs.h>
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/tests/yang_configs.h>
+#include <yang/translator_config.h>
+#include <yang/yang_models.h>
+
+#include <iostream>
+#include <vector>
+
+#include <boost/algorithm/string.hpp>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Return the difference between two strings
+///
+/// Use the gtest >= 1.8.0 tool which builds the difference between
+/// two vectors of lines.
+///
+/// @param left left string
+/// @param right right string
+/// @return the unified diff between left and right
+#ifdef HAVE_CREATE_UNIFIED_DIFF
+string generateDiff(string left, string right) {
+ vector<string> left_lines;
+ boost::split(left_lines, left, boost::is_any_of("\n"));
+ vector<string> right_lines;
+ boost::split(right_lines, right, boost::is_any_of("\n"));
+ using namespace testing::internal;
+ return (edit_distance::CreateUnifiedDiff(left_lines, right_lines));
+}
+#else
+string generateDiff(string, string) {
+ return ("");
+}
+#endif
+
+/// @brief Test Fixture class for Yang <-> JSON configs.
+class ConfigTest : public ::testing::Test {
+public:
+ ConfigTest() : session_(Connection{}.sessionStart()) {
+ session_.switchDatastore(Datastore::Candidate);
+ }
+ virtual ~ConfigTest() = default;
+
+ void SetUp() override {
+ translator_.reset(new Translator(session_, model_));
+ cleanModelData();
+ }
+
+ void TearDown() override {
+ cleanModelData();
+ translator_.reset();
+ SysrepoSetup::cleanSharedMemory();
+ }
+
+ void cleanModelData() {
+ string toplevel_node("config");
+ if (model_ == IETF_DHCPV6_SERVER) {
+ toplevel_node = "server";
+ }
+ translator_->deleteItem("/" + model_ + ":" + toplevel_node);
+ }
+
+ /// @brief Reset session.
+ void resetSession() {
+ SetUp();
+ }
+
+ /// @brief Loads YANG configuration from specified tree.
+ ///
+ /// @param tree The Yang tree to load.
+ void load(const YRTree& tree) {
+ YangRepr repr(model_);
+ repr.set(tree, session_);
+ }
+
+ /// @brief Loads JSON configuration from specified Element tree.
+ ///
+ /// @param json The JSON tree to load.
+ void load(ElementPtr json) {
+ TranslatorConfig tc(session_, model_);
+ tc.setConfig(json);
+ }
+
+ /// @brief Load a cofiguration from a string containing JSON.
+ ///
+ /// @param config The JSON tree to load in textual format.
+ void load(const string& config) {
+ ElementPtr json;
+ ASSERT_NO_THROW_LOG(json = Element::fromJSON(config));
+ load(json);
+ }
+
+ /// @brief Load a configuration from JSON file.
+ ///
+ /// @param filename The name of the JSON file to load,
+ ConstElementPtr loadFile(const string& filename) {
+ string decommented = isc::test::decommentJSONfile(filename);
+ ElementPtr json = Element::fromJSONFile(decommented, true);
+ ::remove(decommented.c_str());
+ load(json);
+ return (json);
+ }
+
+ /// @brief Returns YANG tree configuration.
+ YRTree getYang() {
+ YangRepr repr(model_);
+ return (repr.get(session_));
+ }
+
+ /// @brief Returns configuration in JSON (translated by TranslatorConfig)
+ ConstElementPtr getJSON() {
+ TranslatorConfig tc(session_, model_);
+ return (tc.getConfig());
+ }
+
+ /// @brief Retrieves configuration as text (in pretty JSON format).
+ string getText() {
+ return (isc::data::prettyPrint(getJSON()));
+ }
+
+ /// @brief Verify Yang.
+ ///
+ /// @param expected The expected Yang tree.
+ bool verify(const YRTree& expected) {
+ YangRepr repr(model_);
+ return (repr.verify(expected, session_, cerr));
+ }
+
+ /// @brief Verify JSON.
+ ///
+ /// @param expected The expected JSON tree.
+ bool verify(ConstElementPtr expected) {
+ TranslatorConfig tc(session_, model_);
+ ConstElementPtr content = tc.getConfig();
+ if (isEquivalent(expected, content)) {
+ return (true);
+ }
+ string wanted = prettyPrint(expected);
+ string got = prettyPrint(content);
+ cerr << "Expected:\n" << wanted << "\n"
+ << "Actual:\n" << got
+#ifdef HAVE_CREATE_UNIFIED_DIFF
+ << "\nDiff:\n" << generateDiff(wanted, got)
+#endif
+ << "\n";
+ return (false);
+ }
+
+ /// @brief Verify JSON.
+ ///
+ /// @param expected The expected JSON tree in textual format.
+ bool verify(const string& config) {
+ ConstElementPtr expected;
+ expected = Element::fromJSON(config);
+ return (verify(expected));
+ }
+
+ /// @brief The model.
+ string model_;
+
+ /// @brief The sysrepo session.
+ Session session_;
+
+ unique_ptr<Translator> translator_;
+}; // ConfigTest
+
+struct ConfigTestKeaV4 : ConfigTest {
+ ConfigTestKeaV4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // ConfigTestKeaV4
+struct ConfigTestKeaV6 : ConfigTest {
+ ConfigTestKeaV6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // ConfigTestKeaV6
+struct ConfigTestIetfV6 : ConfigTest {
+ ConfigTestIetfV6() {
+ model_ = IETF_DHCPV6_SERVER;
+ }
+}; // ConfigTestIetfV6
+
+// Check empty config with ietf-dhcpv6-server model.
+TEST_F(ConfigTestIetfV6, emptyIetf6) {
+ YRTree tree;
+ ASSERT_NO_THROW_LOG(load(tree));
+ EXPECT_TRUE(verify(tree));
+
+ ElementPtr json = Element::fromJSON(emptyJson6);
+ EXPECT_TRUE(verify(json));
+ ASSERT_NO_THROW_LOG(load(json));
+ EXPECT_TRUE(verify(emptyJson6));
+ EXPECT_TRUE(verify(tree));
+}
+
+// Check empty config with kea-dhcp4-server:config model.
+TEST_F(ConfigTestKeaV4, emptyKeaDhcp4) {
+ YRTree tree;
+ ASSERT_NO_THROW_LOG(load(tree));
+ EXPECT_TRUE(verify(emptyTreeKeaDhcp4));
+
+ ElementPtr json = Element::fromJSON(emptyJson4);
+ EXPECT_TRUE(verify(json));
+ ASSERT_NO_THROW_LOG(load(json));
+ EXPECT_TRUE(verify(emptyJson4));
+ EXPECT_TRUE(verify(emptyTreeKeaDhcp4));
+}
+
+// Check empty config with kea-dhcp6-server:config model.
+TEST_F(ConfigTestKeaV6, emptyKeaDhcp6) {
+ YRTree tree;
+ ASSERT_NO_THROW_LOG(load(tree));
+ EXPECT_TRUE(verify(emptyTreeKeaDhcp6));
+
+ ElementPtr json = Element::fromJSON(emptyJson6);
+ EXPECT_TRUE(verify(json));
+ ASSERT_NO_THROW_LOG(load(json));
+ EXPECT_TRUE(verify(emptyJson6));
+ EXPECT_TRUE(verify(emptyTreeKeaDhcp6));
+}
+
+// Check subnet with two pools with ietf-dhcpv6-server model.
+// Validation will fail because the current model has a vendor-info
+// container with a mandatory ent-num leaf and no presence flag,
+// and of course the candidate YANG tree has nothing for this.
+TEST_F(ConfigTestIetfV6, subnetTwoPoolsIetf6) {
+ ASSERT_NO_THROW_LOG(load(subnetTwoPoolsTreeIetf6));
+ EXPECT_TRUE(verify(subnetTwoPoolsJson6));
+
+ resetSession();
+
+ ASSERT_NO_THROW_LOG(load(subnetTwoPoolsJson6));
+ EXPECT_TRUE(verify(subnetTwoPoolsTreeIetf6));
+}
+
+// Check subnet with a pool and option data lists with
+// kea-dhcp4-server:config model.
+TEST_F(ConfigTestKeaV4, subnetOptionsKeaDhcp4) {
+ ASSERT_NO_THROW_LOG(load(subnetOptionsTreeKeaDhcp4));
+ EXPECT_TRUE(verify(subnetOptionsJson4));
+
+ resetSession();
+
+ ASSERT_NO_THROW_LOG(load(subnetOptionsJson4));
+ EXPECT_TRUE(verify(subnetOptionsTreeKeaDhcp4));
+}
+
+// Check subnet with a pool and option data lists with
+// kea-dhcp6-server:config model.
+TEST_F(ConfigTestKeaV6, subnetOptionsKeaDhcp6) {
+ ASSERT_NO_THROW_LOG(load(subnetOptionsTreeKeaDhcp6));
+ EXPECT_TRUE(verify(subnetOptionsJson6));
+
+ resetSession();
+
+ ASSERT_NO_THROW_LOG(load(subnetOptionsJson6));
+ EXPECT_TRUE(verify(subnetOptionsTreeKeaDhcp6));
+}
+
+// Check with timers.
+TEST_F(ConfigTestIetfV6, subnetTimersIetf6) {
+ ASSERT_NO_THROW_LOG(load(subnetTimersIetf6));
+ EXPECT_TRUE(verify(subnetTimersJson6));
+
+ resetSession();
+
+ ASSERT_NO_THROW_LOG(load(subnetTimersJson6));
+ EXPECT_TRUE(verify(subnetTimersIetf6));
+}
+
+// Check a ietf-dhcpv6-server configuration which validates.
+TEST_F(ConfigTestIetfV6, validateIetf6) {
+ ASSERT_NO_THROW_LOG(load(validTreeIetf6));
+ EXPECT_TRUE(verify(validTreeIetf6));
+}
+
+// Check Kea4 example files.
+TEST_F(ConfigTestKeaV4, examples4) {
+ vector<string> examples = {
+ "advanced.json",
+ "all-keys-netconf.json",
+ "all-options.json",
+ "backends.json",
+ "classify.json",
+ "classify2.json",
+ "comments.json",
+ "config-backend.json",
+ "dhcpv4-over-dhcpv6.json",
+ "dnr.json",
+ "global-reservations.json",
+ "ha-load-balancing-server1-mt-with-tls.json",
+ "ha-load-balancing-server2-mt.json",
+ "hooks.json",
+ "hooks-radius.json",
+ "leases-expiration.json",
+ "multiple-options.json",
+ "mysql-reservations.json",
+ "pgsql-reservations.json",
+ "reservations.json",
+ "several-subnets.json",
+ "shared-network.json",
+ "single-subnet.json",
+ "vendor-specific.json",
+ "vivso.json",
+ "with-ddns.json",
+ };
+ for (string file : examples) {
+ resetSession();
+ string path = string(CFG_EXAMPLES) + "/kea4/" + file;
+ SCOPED_TRACE("\n* Tested file: " + path);
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = loadFile(path));
+ json = isc::test::moveComments(json);
+ EXPECT_TRUE(verify(json));
+ }
+}
+
+// Check Kea6 example files.
+TEST_F(ConfigTestKeaV6, examples6) {
+ vector<string> examples = {
+ "advanced.json",
+ "all-keys-netconf.json",
+ "all-options.json",
+ "backends.json",
+ "classify.json",
+ "classify2.json",
+ "comments.json",
+ "config-backend.json",
+ "dhcpv4-over-dhcpv6.json",
+ "dnr.json",
+ "duid.json",
+ "global-reservations.json",
+ "ha-hot-standby-server1-with-tls.json",
+ "ha-hot-standby-server2.json",
+ "hooks.json",
+ "iPXE.json",
+ "leases-expiration.json",
+ "multiple-options.json",
+ "mysql-reservations.json",
+ "pgsql-reservations.json",
+ "reservations.json",
+ "several-subnets.json",
+ "shared-network.json",
+ "simple.json",
+ "softwire46.json",
+ "stateless.json",
+ "tee-times.json",
+ "with-ddns.json",
+ };
+ for (string file : examples) {
+ resetSession();
+ string path = string(CFG_EXAMPLES) + "/kea6/" + file;
+ SCOPED_TRACE("\n* Tested file: " + path);
+ ConstElementPtr json;
+ ASSERT_NO_THROW_LOG(json = loadFile(path));
+ json = isc::test::moveComments(json);
+ EXPECT_TRUE(verify(json));
+ }
+}
+
+// Check the example in the design document.
+TEST_F(ConfigTestIetfV6, designExample) {
+ ASSERT_NO_THROW_LOG(load(designExampleTree));
+ EXPECT_TRUE(verify(designExampleJson));
+
+ resetSession();
+
+ ASSERT_NO_THROW_LOG(load(designExampleJson));
+ EXPECT_TRUE(verify(designExampleTree));
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/json_configs.h b/src/lib/yang/tests/json_configs.h
new file mode 100644
index 0000000..147cbc7
--- /dev/null
+++ b/src/lib/yang/tests/json_configs.h
@@ -0,0 +1,176 @@
+// Copyright (C) 2018-2023 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef ISC_JSON_CONFIGS_H
+#define ISC_JSON_CONFIGS_H
+
+#include <string>
+
+namespace isc {
+namespace yang {
+namespace test {
+
+/// @brief Empty DHCPv4 config.
+const std::string emptyJson4 =
+ "{\n"
+ " \"Dhcp4\": {\n"
+ " }\n"
+ "}";
+
+/// @brief A DHCPv4 config with one subnet with two pools.
+const std::string subnetTwoPoolsJson4 =
+ "{\n"
+ " \"Dhcp4\": {\n"
+ " \"subnet4\": [\n"
+ " {\n"
+ " \"id\": 111,\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"10.0.1.0/24\"\n"
+ " },\n"
+ " {\n"
+ " \"pool\": \"10.0.2.0/24\"\n"
+ " }\n"
+ " ],\n"
+ " \"subnet\": \"10.0.0.0/8\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
+
+/// @brief A DHCPv6 config with one subnet with two pools and timers.
+const std::string subnetTimersJson6 =
+ "{\n"
+ " \"Dhcp6\": {\n"
+ " \"subnet6\": [\n"
+ " {\n"
+ " \"id\": 111,\n"
+ " \"renew-timer\": 1000,\n"
+ " \"rebind-timer\": 2000,\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"2001:db8::1:0/112\"\n"
+ " },\n"
+ " {\n"
+ " \"pool\": \"2001:db8::2:0/112\"\n"
+ " }\n"
+ " ],\n"
+ " \"subnet\": \"2001:db8::/48\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
+
+/// @brief A DHCPv4 subnet with one pool and option data lists.
+const std::string subnetOptionsJson4 =
+ "{\n"
+ " \"Dhcp4\": {\n"
+ " \"subnet4\": [\n"
+ " {\n"
+ " \"id\": 111,\n"
+ " \"option-data\": [\n"
+ " {\n"
+ " \"code\": 100,\n"
+ " \"space\": \"dns\",\n"
+ " \"csv-format\": false,\n"
+ " \"data\": \"12121212\",\n"
+ " \"always-send\": false,\n"
+ " \"never-send\": false\n"
+ " }\n"
+ " ],\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"10.0.1.0/24\"\n"
+ " }\n"
+ " ],\n"
+ " \"subnet\": \"10.0.0.0/8\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
+
+/// @brief Empty DHCPv6 config.
+const std::string emptyJson6 =
+ "{\n"
+ " \"Dhcp6\": {\n"
+ " }\n"
+ "}";
+
+/// @brief A DHCPv6 config with one subnet with one pool and option data lists.
+const std::string subnetOptionsJson6 =
+ "{\n"
+ " \"Dhcp6\": {\n"
+ " \"subnet6\": [\n"
+ " {\n"
+ " \"id\": 111,\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"option-data\": [\n"
+ " {\n"
+ " \"code\": 100,\n"
+ " \"space\": \"dns\",\n"
+ " \"csv-format\": false,\n"
+ " \"data\": \"12121212\",\n"
+ " \"always-send\": false,\n"
+ " \"never-send\": false\n"
+ " }\n"
+ " ],\n"
+ " \"pool\": \"2001:db8::1:0/112\"\n"
+ " }\n"
+ " ],\n"
+ " \"subnet\": \"2001:db8::/48\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
+
+/// @brief A DHCPv6 config with one subnet with two pools.
+const std::string subnetTwoPoolsJson6 =
+ "{\n"
+ " \"Dhcp6\": {\n"
+ " \"subnet6\": [\n"
+ " {\n"
+ " \"id\": 111,\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"2001:db8::1:0/112\"\n"
+ " },\n"
+ " {\n"
+ " \"pool\": \"2001:db8::2:0/112\"\n"
+ " }\n"
+ " ],\n"
+ " \"subnet\": \"2001:db8::/48\"\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
+
+/// @brief Example from the design document.
+const std::string designExampleJson =
+ "{\n"
+ " \"Dhcp6\": {\n"
+ " \"subnet6\": [\n"
+ " {\n"
+ " \"id\": 1,\n"
+ " \"subnet\": \"2001:db8:20:b00::/56\",\n"
+ " \"user-context\": { \"description\": \"example\" },\n"
+ " \"pd-pools\": [\n"
+ " {\n"
+ " \"prefix\": \"2001:db8:20:b00::\",\n"
+ " \"prefix-len\": 57\n"
+// " \"delegated-len\": 57\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ " ]\n"
+ " }\n"
+ "}";
+
+} // namespace test
+} // namespace yang
+} // namespace isc
+
+#endif // ISC_JSON_CONFIGS_H
diff --git a/src/lib/yang/tests/run_unittests.cc b/src/lib/yang/tests/run_unittests.cc
new file mode 100644
index 0000000..24870d1
--- /dev/null
+++ b/src/lib/yang/tests/run_unittests.cc
@@ -0,0 +1,21 @@
+// 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 <gtest/gtest.h>
+
+#include <log/logger_support.h>
+#include <util/unittests/run_all.h>
+
+int
+main(int argc, char* argv[]) {
+ ::testing::InitGoogleTest(&argc, argv);
+
+ isc::log::initLogger();
+
+ return (isc::util::unittests::run_all());
+}
diff --git a/src/lib/yang/tests/sysrepo_setup.h b/src/lib/yang/tests/sysrepo_setup.h
new file mode 100644
index 0000000..4e315dd
--- /dev/null
+++ b/src/lib/yang/tests/sysrepo_setup.h
@@ -0,0 +1,96 @@
+// 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/.
+
+#ifndef SYSREPO_SETUP_H
+#define SYSREPO_SETUP_H
+
+#include <config.h>
+
+#include <gtest/gtest.h>
+
+#include <testutils/gtest_utils.h>
+#include <yang/translator.h>
+#include <yang/yang_models.h>
+
+#include <sysrepo-cpp/Connection.hpp>
+
+namespace isc {
+namespace yang {
+namespace test {
+
+/// @brief Wrapper for sysrepo setup actions
+struct SysrepoSetup {
+ /// @brief Cleans shared memory.
+ ///
+ /// If a unit test crashes (mostly when migrating to a new version), it
+ /// leaves behind corrupted shared memory. Let's make sure we can run all
+ /// the following unit tests free of any side effect from said crash. This
+ /// is the equivalent of running "make shm_clean" in sysrepo:
+ /// https://github.com/sysrepo/sysrepo/blob/v1.4.140/CMakeLists.txt#L329-L334
+ static void cleanSharedMemory() {
+ call_system("rm -rf /dev/shm/sr_*");
+ call_system("rm -rf /dev/shm/srsub_*");
+ }
+
+private:
+ /// @brief Wrapper over a system() call that also checks the return value.
+ ///
+ /// @brief command the command to be run
+ static void call_system(char const* command) {
+ int return_value(system(command));
+ if (return_value != 0) {
+ std::cerr << "\"" << command << "\" exited with " << return_value
+ << ". Unit tests may be influenced by previous abnormally "
+ "terminated unit tests or sysrepo uses."
+ << std::endl;
+ }
+ }
+}; // SysrepoSetup
+
+/// @brief Test Fixture template for translator tests.
+///
+/// @tparam Name The name of the translator to test.
+/// @tparam Type The type of the translator to test.
+template<char const* Name, typename translator_t>
+class GenericTranslatorTest : public ::testing::Test {
+public:
+ virtual ~GenericTranslatorTest() = default;
+
+ void SetUp() override {
+ SysrepoSetup::cleanSharedMemory();
+ sess_ = sysrepo::Connection{}.sessionStart();
+ sess_->switchDatastore(sysrepo::Datastore::Candidate);
+ translator_.reset(new translator_t(*sess_, model_));
+ cleanModelData();
+ }
+
+ void TearDown() override {
+ cleanModelData();
+ translator_.reset();
+ SysrepoSetup::cleanSharedMemory();
+ }
+
+ void cleanModelData() {
+ std::string toplevel_node("config");
+ if (model_ == IETF_DHCPV6_SERVER) {
+ toplevel_node = "server";
+ }
+ translator_->deleteItem("/" + model_ + ":" + toplevel_node);
+ }
+
+ /// @brief Sysrepo session.
+ std::optional<sysrepo::Session> sess_;
+
+ /// @brief Shared pointer to the transaction object.
+ std::shared_ptr<translator_t> translator_;
+ std::string model_;
+}; // GenericTranslatorTest
+
+} // namespace test
+} // namespace yang
+} // namespace isc
+
+#endif // SYSREPO_SETUP_H
diff --git a/src/lib/yang/tests/translator_class_unittests.cc b/src/lib/yang/tests/translator_class_unittests.cc
new file mode 100644
index 0000000..02405c5
--- /dev/null
+++ b/src/lib/yang/tests/translator_class_unittests.cc
@@ -0,0 +1,123 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_class.h>
+#include <yang/yang_models.h>
+
+#include <sstream>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const client_classes[] = "client classes";
+
+/// @brief Test fixture class for @ref TranslatorClasses.
+class TranslatorClassesTestv4 :
+ public GenericTranslatorTest<client_classes, TranslatorClasses> {
+public:
+ /// @brief Constructor
+ TranslatorClassesTestv4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorClassesTestv4
+
+class TranslatorClassesTestv6 :
+ public GenericTranslatorTest<client_classes, TranslatorClasses> {
+public:
+ /// @brief Constructor
+ TranslatorClassesTestv6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorClassesTestv6
+
+// This test verifies that an empty client class list can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorClassesTestv4, getEmpty) {
+ // Get the client class list and check if it is empty.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr classes;
+ EXPECT_NO_THROW_LOG(classes = translator_->getClassesFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(classes);
+}
+
+// This test verifies that one client class can be properly translated
+// from YANG to JSON.
+TEST_F(TranslatorClassesTestv6, get) {
+ // Create the client class.
+ const string& xpath = "/kea-dhcp6-server:config";
+ const string& xclass = xpath + "/client-class[name='foo']";
+ const string& xtest = xclass + "/test";
+ string const v_test("not member('ALL')");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xtest, v_test));
+ sess_->applyChanges();
+
+ // Get the client class.
+ ConstElementPtr cclass;
+ EXPECT_NO_THROW_LOG(cclass = translator_->getClassFromAbsoluteXpath(xclass));
+ ASSERT_TRUE(cclass);
+ ElementPtr expected = Element::createMap();
+ expected->set("name", Element::create("foo"));
+ expected->set("test", Element::create("not member('ALL')"));
+ EXPECT_TRUE(expected->equals(*cclass));
+
+ // Get the client class list and check if the client class is in it.
+ ConstElementPtr classes;
+ EXPECT_NO_THROW_LOG(classes = translator_->getClassesFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(classes);
+ ASSERT_EQ(Element::list, classes->getType());
+ ASSERT_EQ(1, classes->size());
+ EXPECT_TRUE(cclass->equals(*classes->get(0)));
+}
+
+// This test verifies that an empty client class list can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorClassesTestv4, setEmpty) {
+ // Set empty list.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr classes = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setClasses(xpath, classes));
+
+ // Get it back.
+ classes.reset();
+ EXPECT_NO_THROW_LOG(classes = translator_->getClassesFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(classes);
+}
+
+// This test verifies that one client class can be properly translated
+// from JSON to YANG.
+TEST_F(TranslatorClassesTestv6, set) {
+ // Set one client class.
+ const string& xpath = "/kea-dhcp6-server:config";
+ ElementPtr classes = Element::createList();
+ ElementPtr cclass = Element::createMap();
+ cclass->set("name", Element::create("foo"));
+ cclass->set("test", Element::create("''==''"));
+ cclass->set("only-if-required", Element::create(false));
+ classes->add(cclass);
+ EXPECT_NO_THROW_LOG(translator_->setClasses(xpath, classes));
+
+ // Get it back.
+ ConstElementPtr got;
+ EXPECT_NO_THROW_LOG(got = translator_->getClassesFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(got);
+ ASSERT_EQ(Element::list, got->getType());
+ ASSERT_EQ(1, got->size());
+ EXPECT_TRUE(cclass->equals(*got->get(0)));
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_control_socket_unittests.cc b/src/lib/yang/tests/translator_control_socket_unittests.cc
new file mode 100644
index 0000000..f9174db
--- /dev/null
+++ b/src/lib/yang/tests/translator_control_socket_unittests.cc
@@ -0,0 +1,174 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_control_socket.h>
+#include <yang/yang_models.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace libyang;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const control_socket[] = "control socket";
+
+/// @brief Test fixture class for @ref TranslatorControlSocket.
+class TranslatorControlSocketTestv4 :
+ public GenericTranslatorTest<control_socket, TranslatorControlSocket> {
+public:
+ /// @brief Constructor
+ TranslatorControlSocketTestv4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+
+ virtual ~TranslatorControlSocketTestv4() = default;
+}; // TranslatorControlSocketTestv4
+
+class TranslatorControlSocketTestv6 :
+ public GenericTranslatorTest<control_socket, TranslatorControlSocket> {
+public:
+ /// @brief Constructor
+ TranslatorControlSocketTestv6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+
+ virtual ~TranslatorControlSocketTestv6() = default;
+}; // TranslatorControlSocketTestv6
+
+class TranslatorControlSocketTestCtrlAgent :
+ public GenericTranslatorTest<control_socket, TranslatorControlSocket> {
+public:
+ /// @brief Constructor
+ TranslatorControlSocketTestCtrlAgent() {
+ model_ = KEA_CTRL_AGENT;
+ }
+
+ virtual ~TranslatorControlSocketTestCtrlAgent() = default;
+}; // TranslatorControlSocketTestCtrlAgent
+
+// This test verifies that an empty control socket can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorControlSocketTestv4, getEmpty) {
+ // Get empty.
+ const string& xpath = "/kea-dhcp4-server:config/control-socket";
+ ConstElementPtr sock;
+ EXPECT_NO_THROW_LOG(sock = translator_->getControlSocketFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(sock);
+}
+
+// This test verifies that a not empty control socket can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorControlSocketTestv6, get) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp6-server:config/control-socket";
+ const string& xname = xpath + "/socket-name";
+ const string& xtype = xpath + "/socket-type";
+ const string& xcontext = xpath + "/user-context";
+ string const s_name("/tmp/kea.sock");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xname, s_name));
+ string const s_type("unix");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xtype, s_type));
+ string const s_context("{ \"foo\": 1 }");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xcontext, s_context));
+ sess_->applyChanges();
+
+ // Get it.
+ ConstElementPtr sock;
+ EXPECT_NO_THROW_LOG(sock = translator_->getControlSocketFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(sock);
+ ASSERT_EQ(Element::map, sock->getType());
+ EXPECT_EQ(3, sock->size());
+ ConstElementPtr type = sock->get("socket-type");
+ ASSERT_TRUE(type);
+ ASSERT_EQ(Element::string, type->getType());
+ EXPECT_EQ("unix", type->stringValue());
+ ConstElementPtr name = sock->get("socket-name");
+ ASSERT_TRUE(name);
+ ASSERT_EQ(Element::string, name->getType());
+ EXPECT_EQ("/tmp/kea.sock", name->stringValue());
+ ConstElementPtr context = sock->get("user-context");
+ ASSERT_TRUE(context);
+ EXPECT_EQ("{ \"foo\": 1 }", context->str());
+}
+
+// This test verifies that a not empty control socket can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorControlSocketTestCtrlAgent, set) {
+ // Set a value.
+ const string& xpath =
+ "/kea-ctrl-agent:config/control-sockets/socket[server-type='dhcp4']/control-socket";
+ ElementPtr sock = Element::createMap();
+ sock->set("socket-name", Element::create("/tmp/kea.sock"));
+ sock->set("socket-type", Element::create("unix"));
+ sock->set("comment", Element::create("a comment"));
+ try {
+ translator_->setControlSocket(xpath, sock);
+ } catch (exception const& ex) {
+ cerr << "setControlSocket fail with " << ex.what() << endl;
+ }
+ ASSERT_NO_THROW_LOG(translator_->setControlSocket(xpath, sock));
+
+ // Get it back.
+ ConstElementPtr got;
+ EXPECT_NO_THROW_LOG(got = translator_->getControlSocketFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(got);
+ ASSERT_EQ(Element::map, got->getType());
+ EXPECT_EQ(3, got->size());
+ ConstElementPtr name = got->get("socket-name");
+ ASSERT_TRUE(name);
+ ASSERT_EQ(Element::string, name->getType());
+ EXPECT_EQ("/tmp/kea.sock", name->stringValue());
+ ConstElementPtr type = got->get("socket-type");
+ ASSERT_TRUE(type);
+ ASSERT_EQ(Element::string, type->getType());
+ EXPECT_EQ("unix", type->stringValue());
+ ConstElementPtr context = got->get("user-context");
+ ASSERT_TRUE(context);
+ EXPECT_EQ("{ \"comment\": \"a comment\" }", context->str());
+}
+
+// This test verifies that an empty control socket can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorControlSocketTestv4, setEmpty) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp4-server:config/control-socket";
+ const string& xname = xpath + "/socket-name";
+ const string& xtype = xpath + "/socket-type";
+ const string& xcontext = xpath + "/user-context";
+ string const s_name("/tmp/kea.sock");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xname, s_name));
+ string const s_type("unix");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xtype, s_type));
+ string const s_context("{ \"foo\": 1 }");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xcontext, s_context));
+ sess_->applyChanges();
+
+ // Get it back.
+ ConstElementPtr sock;
+ EXPECT_NO_THROW_LOG(sock = translator_->getControlSocketFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(sock);
+ EXPECT_EQ(sock->str(),
+ R"({ "socket-name": "/tmp/kea.sock", "socket-type": "unix", "user-context": { "foo": 1 } })");
+
+ // Reset to empty.
+ EXPECT_NO_THROW_LOG(translator_->setControlSocket(xpath, ConstElementPtr()));
+
+ // Get it back.
+ EXPECT_NO_THROW_LOG(sock = translator_->getControlSocketFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(sock);
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_database_unittests.cc b/src/lib/yang/tests/translator_database_unittests.cc
new file mode 100644
index 0000000..4203bcb
--- /dev/null
+++ b/src/lib/yang/tests/translator_database_unittests.cc
@@ -0,0 +1,324 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_database.h>
+#include <yang/yang_models.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const database_access[] = "database access";
+
+/// @brief Test fixture class for @ref TranslatorDatabase.
+class TranslatorDatabaseTestv4 :
+ public GenericTranslatorTest<database_access, TranslatorDatabase> {
+public:
+ TranslatorDatabaseTestv4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+
+ virtual ~TranslatorDatabaseTestv4() = default;
+}; // TranslatorDatabaseTestv4
+
+class TranslatorDatabaseTestv6 :
+ public GenericTranslatorTest<database_access, TranslatorDatabase> {
+public:
+ TranslatorDatabaseTestv6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+
+ virtual ~TranslatorDatabaseTestv6() = default;
+}; // TranslatorDatabaseTestv6
+
+// This test verifies that an empty database can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorDatabaseTestv4, getEmpty) {
+ // Get empty.
+ const string& xpath = "/kea-dhcp4-server:config/lease-database";
+ ConstElementPtr database;
+ EXPECT_NO_THROW_LOG(database = translator_->getDatabaseFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(database);
+}
+
+// This test verifies that a database can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorDatabaseTestv4, get) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp4-server:config/lease-database";
+ const string& xtype = xpath + "/database-type";
+ const string& xinterval = xpath + "/lfc-interval";
+ string const s_type("memfile");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xtype, s_type));
+ uint32_t li = 3600;
+ string const s_interval(to_string(li));
+ EXPECT_NO_THROW_LOG(sess_->setItem(xinterval, s_interval));
+ sess_->applyChanges();
+
+ // Get empty.
+ ConstElementPtr database;
+ EXPECT_NO_THROW_LOG(database = translator_->getDatabaseFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(database);
+ EXPECT_EQ(2, database->size());
+ ConstElementPtr type = database->get("type");
+ ASSERT_TRUE(type);
+ ASSERT_EQ(Element::string, type->getType());
+ EXPECT_EQ("memfile", type->stringValue());
+ ConstElementPtr interval = database->get("lfc-interval");
+ ASSERT_TRUE(interval);
+ ASSERT_EQ(Element::integer, interval->getType());
+ EXPECT_EQ(li, interval->intValue());
+}
+
+// This test verifies that a database can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorDatabaseTestv4, set) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp4-server:config/lease-database";
+ ElementPtr database = Element::createMap();
+ database->set("type", Element::create("memfile"));
+ database->set("lfc-interval", Element::create(3600));
+ ASSERT_NO_THROW_LOG(translator_->setDatabase(xpath, database));
+
+ // Get it back.
+ ConstElementPtr got;
+ EXPECT_NO_THROW_LOG(got = translator_->getDatabaseFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(got);
+ ASSERT_EQ(Element::map, got->getType());
+ EXPECT_EQ(2, got->size());
+ ConstElementPtr type = got->get("type");
+ ASSERT_TRUE(type);
+ ASSERT_EQ(Element::string, type->getType());
+ EXPECT_EQ("memfile", type->stringValue());
+ ConstElementPtr interval = database->get("lfc-interval");
+ ASSERT_TRUE(interval);
+ ASSERT_EQ(Element::integer, interval->getType());
+ EXPECT_EQ(3600, interval->intValue());
+}
+
+// This test verifies that an empty database can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorDatabaseTestv4, setEmpty) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp4-server:config/lease-database";
+ const string& xtype = xpath + "/database-type";
+ const string& xinterval = xpath + "/lfc-interval";
+ string const s_type("memfile");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xtype, s_type));
+ uint32_t li = 3600;
+ string const s_interval(to_string(li));
+ EXPECT_NO_THROW_LOG(sess_->setItem(xinterval, s_interval));
+ sess_->applyChanges();
+
+ // Reset to empty.
+ ASSERT_NO_THROW_LOG(translator_->setDatabase(xpath, ConstElementPtr()));
+
+ // Get it back.
+ ConstElementPtr database;
+ EXPECT_NO_THROW_LOG(database = translator_->getDatabaseFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(database);
+}
+
+/// @brief Translator name.
+extern char const database_accesses[] = "database accesses";
+
+/// @brief Test fixture class for @ref TranslatorDatabases.
+class TranslatorDatabasesTestv4 :
+ public GenericTranslatorTest<database_accesses, TranslatorDatabases> {
+public:
+ /// @brief Constructor
+ TranslatorDatabasesTestv4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorDatabasesTestv4
+
+class TranslatorDatabasesTestv6 :
+ public GenericTranslatorTest<database_accesses, TranslatorDatabases> {
+public:
+ /// @brief Constructor
+ TranslatorDatabasesTestv6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorDatabasesTestv6
+
+// This test verifies that an empty database list can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorDatabasesTestv6, getEmpty) {
+ // Get empty.
+ const string& xpath = "/kea-dhcp6-server:config/hosts-database";
+ ConstElementPtr databases;
+ EXPECT_NO_THROW_LOG(databases = translator_->getDatabasesFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(databases);
+}
+
+// This test verifies that a database list can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorDatabasesTestv4, get) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp4-server:config/hosts-database";
+ const string& xdatabase = xpath + "[database-type='mysql']";
+ const string& xname = xdatabase + "/name";
+ const string& xuser = xdatabase + "/user";
+ const string& xpassword = xdatabase + "/password";
+ const string& xhost = xdatabase + "/host";
+ const string& xport = xdatabase + "/port";
+ string const s_name("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xname, s_name));
+ string const s_user("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xuser, s_user));
+ string const s_password("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xpassword, s_password));
+ string const s_host("localhost");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xhost, s_host));
+ uint16_t mport = 3306;
+ string const s_port(to_string(mport));
+ EXPECT_NO_THROW_LOG(sess_->setItem(xport, s_port));
+ sess_->applyChanges();
+
+ // Get empty.
+ ConstElementPtr databases;
+ EXPECT_NO_THROW_LOG(databases = translator_->getDatabasesFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(databases);
+ ASSERT_EQ(1, databases->size());
+ ConstElementPtr database = databases->get(0);
+ ASSERT_TRUE(database);
+ EXPECT_EQ(6, database->size());
+ ConstElementPtr type = database->get("type");
+ ASSERT_TRUE(type);
+ ASSERT_EQ(Element::string, type->getType());
+ EXPECT_EQ("mysql", type->stringValue());
+ ConstElementPtr name = database->get("name");
+ ASSERT_TRUE(name);
+ ASSERT_EQ(Element::string, name->getType());
+ EXPECT_EQ("kea", name->stringValue());
+ ConstElementPtr user = database->get("user");
+ ASSERT_TRUE(user);
+ ASSERT_EQ(Element::string, user->getType());
+ EXPECT_EQ("kea", user->stringValue());
+ ConstElementPtr password = database->get("password");
+ ASSERT_TRUE(password);
+ ASSERT_EQ(Element::string, password->getType());
+ EXPECT_EQ("kea", password->stringValue());
+ ConstElementPtr host = database->get("host");
+ ASSERT_TRUE(host);
+ ASSERT_EQ(Element::string, host->getType());
+ EXPECT_EQ("localhost", host->stringValue());
+ ConstElementPtr port = database->get("port");
+ ASSERT_TRUE(port);
+ ASSERT_EQ(Element::integer, port->getType());
+ EXPECT_EQ(mport, port->intValue());
+}
+
+// This test verifies that a database list can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorDatabasesTestv6, set) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp6-server:config/hosts-database";
+ ElementPtr database = Element::createMap();
+ database->set("type", Element::create("memfile"));
+ database->set("lfc-interval", Element::create(3600));
+ ElementPtr databases = Element::createList();
+ databases->add(database);
+ ASSERT_NO_THROW_LOG(translator_->setDatabases(xpath, databases));
+
+ // Get it back.
+ ConstElementPtr gots;
+ EXPECT_NO_THROW_LOG(gots = translator_->getDatabasesFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(gots);
+ ASSERT_EQ(Element::list, gots->getType());
+ ASSERT_EQ(1, gots->size());
+ ConstElementPtr got = gots->get(0);
+ ASSERT_TRUE(got);
+ ASSERT_EQ(Element::map, got->getType());
+ EXPECT_EQ(2, got->size());
+ ConstElementPtr type = got->get("type");
+ ASSERT_TRUE(type);
+ ASSERT_EQ(Element::string, type->getType());
+ EXPECT_EQ("memfile", type->stringValue());
+ ConstElementPtr interval = database->get("lfc-interval");
+ ASSERT_TRUE(interval);
+ ASSERT_EQ(Element::integer, interval->getType());
+ EXPECT_EQ(3600, interval->intValue());
+}
+
+// This test verifies that an emptied database list can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorDatabasesTestv4, setEmpty) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp4-server:config/hosts-database";
+ const string& xdatabase = xpath + "[database-type='mysql']";
+ const string& xname = xdatabase + "/name";
+ const string& xuser = xdatabase + "/user";
+ const string& xpassword = xdatabase + "/password";
+ const string& xhost = xdatabase + "/host";
+ const string& xport = xdatabase + "/port";
+ string const s_name("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xname, s_name));
+ string const s_user("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xuser, s_user));
+ string const s_password("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xpassword, s_password));
+ string const s_host("localhost");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xhost, s_host));
+ uint16_t mport = 3306;
+ string const s_port(to_string(mport));
+ EXPECT_NO_THROW_LOG(sess_->setItem(xport, s_port));
+ sess_->applyChanges();
+
+ // Reset to empty.
+ EXPECT_NO_THROW_LOG(translator_->setDatabase(xdatabase, ConstElementPtr()));
+
+ // Get empty.
+ ConstElementPtr databases;
+ EXPECT_NO_THROW_LOG(databases = translator_->getDatabasesFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(databases);
+}
+
+// This test verifies that an empty database list can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorDatabasesTestv4, setEmpties) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp4-server:config/hosts-database";
+ const string& xdatabase = xpath + "[database-type='mysql']";
+ const string& xname = xdatabase + "/name";
+ const string& xuser = xdatabase + "/user";
+ const string& xpassword = xdatabase + "/password";
+ const string& xhost = xdatabase + "/host";
+ const string& xport = xdatabase + "/port";
+ string const s_name("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xname, s_name));
+ string const s_user("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xuser, s_user));
+ string const s_password("kea");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xpassword, s_password));
+ string const s_host("localhost");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xhost, s_host));
+ uint16_t mport = 3306;
+ string const s_port(to_string(mport));
+ EXPECT_NO_THROW_LOG(sess_->setItem(xport, s_port));
+ sess_->applyChanges();
+
+ // Reset to empty.
+ EXPECT_NO_THROW_LOG(translator_->setDatabases(xdatabase, ConstElementPtr()));
+
+ // Get empty.
+ ConstElementPtr databases;
+ EXPECT_NO_THROW_LOG(databases = translator_->getDatabasesFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(databases);
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_host_unittests.cc b/src/lib/yang/tests/translator_host_unittests.cc
new file mode 100644
index 0000000..d51c235
--- /dev/null
+++ b/src/lib/yang/tests/translator_host_unittests.cc
@@ -0,0 +1,192 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_host.h>
+#include <yang/yang_models.h>
+
+#include <sstream>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace libyang;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const host_reservations[] = "host reservations";
+
+/// @brief Test fixture class for @ref TranslatorHosts.
+class TranslatorHostsTestv4 :
+ public GenericTranslatorTest<host_reservations, TranslatorHosts> {
+public:
+ /// @brief Constructor
+ TranslatorHostsTestv4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorHostsTestv4
+
+class TranslatorHostsTestv6 :
+ public GenericTranslatorTest<host_reservations, TranslatorHosts> {
+public:
+ /// @brief Constructor
+ TranslatorHostsTestv6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorHostsTestv6
+
+// This test verifies that an empty host reservation list can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorHostsTestv6, getEmpty) {
+ // Get the host reservation list and check if it is empty.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ ConstElementPtr hosts;
+ EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(hosts);
+}
+
+// This test verifies that one host reservation can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorHostsTestv6, get) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Create the host reservation for 2001:db8::1.
+ ostringstream shost;
+ shost << xpath + "/host[identifier-type='hw-address']"
+ << "[identifier='00:01:02:03:04:05']";
+ const string& xaddr = shost.str() + "/ip-addresses";
+ string const s_addr("2001:db8::1");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xaddr, s_addr));
+ sess_->applyChanges();
+
+ // Get the host.
+ ConstElementPtr host;
+ EXPECT_NO_THROW_LOG(host = translator_->getHostFromAbsoluteXpath(shost.str()));
+ ASSERT_TRUE(host);
+ ElementPtr expected = Element::createMap();
+ ElementPtr addresses = Element::createList();
+ addresses->add(Element::create("2001:db8::1"));
+ expected->set("hw-address", Element::create("00:01:02:03:04:05"));
+ expected->set("ip-addresses", addresses);
+ EXPECT_TRUE(expected->equals(*host));
+
+ // Get the host reservation list and check if the host reservation
+ // is in it.
+ ConstElementPtr hosts;
+ EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(hosts);
+ ASSERT_EQ(Element::list, hosts->getType());
+ ASSERT_EQ(1, hosts->size());
+ EXPECT_TRUE(host->equals(*hosts->get(0)));
+}
+
+// This test verifies that an empty host reservation list can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorHostsTestv6, setEmpty) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set empty list.
+ ConstElementPtr hosts = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setHosts(xpath, hosts));
+
+ // Get it back.
+ hosts.reset();
+ EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(hosts);
+}
+
+// This test verifies that one host reservation can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorHostsTestv4, set) {
+ // Create the subnet 10.0.0.0/14 #111.
+ const string& xpath =
+ "/kea-dhcp4-server:config/subnet4[id='111']";
+ string const v_subnet("10.0.0.0/24");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set one host.
+ ElementPtr hosts = Element::createList();
+ ElementPtr host = Element::createMap();
+ host->set("flex-id", Element::create("00:ff"));
+ host->set("ip-address", Element::create("10.0.0.1"));
+ host->set("hostname", Element::create("foo"));
+ hosts->add(host);
+ EXPECT_NO_THROW_LOG(translator_->setHosts(xpath, hosts));
+
+ // Get it back.
+ hosts.reset();
+ EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(hosts);
+ ASSERT_EQ(Element::list, hosts->getType());
+ ASSERT_EQ(1, hosts->size());
+ EXPECT_TRUE(host->equals(*hosts->get(0)));
+}
+
+// This test verifies that several host reservations can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorHostsTestv6, getMany) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Create the host reservation for 2001:db8::1.
+ ostringstream shost;
+ shost << xpath + "/host[identifier-type='hw-address']"
+ << "[identifier='00:01:02:03:04:05']";
+ const string& xaddr = shost.str() + "/ip-addresses";
+ string const s_addr("2001:db8::1");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xaddr, s_addr));
+ sess_->applyChanges();
+
+ // Create another reservation for 2001:db8::2
+ ostringstream shost2;
+ shost2 << xpath + "/host[identifier-type='hw-address']"
+ << "[identifier='00:01:0a:0b:0c:0d']";
+ const string xaddr2 = shost2.str() + "/ip-addresses";
+ string const s_addr2("2001:db8::2");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xaddr2, s_addr2));
+ sess_->applyChanges();
+
+ // Get the host.
+ ConstElementPtr hosts;
+ EXPECT_NO_THROW_LOG(hosts = translator_->getHostsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(hosts);
+
+ EXPECT_EQ(hosts->str(),
+ "[ { \"hw-address\": \"00:01:02:03:04:05\", "
+ "\"ip-addresses\": [ \"2001:db8::1\" ] }, "
+ "{ \"hw-address\": \"00:01:0a:0b:0c:0d\", "
+ "\"ip-addresses\": [ \"2001:db8::2\" ] } ]");
+}
+
+} // anonymous namespace
diff --git a/src/lib/yang/tests/translator_logger_unittests.cc b/src/lib/yang/tests/translator_logger_unittests.cc
new file mode 100644
index 0000000..365e4bd
--- /dev/null
+++ b/src/lib/yang/tests/translator_logger_unittests.cc
@@ -0,0 +1,156 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_logger.h>
+#include <yang/yang_models.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const logger_list[] = "logger list";
+
+/// @brief Test fixture class for @ref TranslatorLoggers.
+class TranslatorLoggersTestv4 :
+ public GenericTranslatorTest<logger_list, TranslatorLoggers> {
+public:
+ /// @brief Constructor
+ TranslatorLoggersTestv4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorLoggersTestv4
+
+class TranslatorLoggersTestv6 :
+ public GenericTranslatorTest<logger_list, TranslatorLoggers> {
+public:
+ /// @brief Constructor
+ TranslatorLoggersTestv6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorLoggersTestv6
+
+// This test verifies that an empty logger list can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorLoggersTestv4, getEmpty) {
+ // Get empty.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr loggers;
+ EXPECT_NO_THROW_LOG(loggers = translator_->getLoggersFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(loggers);
+}
+
+// This test verifies that one logger can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorLoggersTestv6, get) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp6-server:config";
+ const string& xlogger = xpath + "/logger[name='foo']";
+ const string& xseverity = xlogger + "/severity";
+ const string& xoption = xlogger + "/output-option[output='/bar']";
+ const string& xmaxver = xoption + "/maxver";
+ string const s_severity("WARN");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xseverity, s_severity));
+ uint32_t max_ver = 10;
+ string const s_maxver(to_string(max_ver));
+ EXPECT_NO_THROW_LOG(sess_->setItem(xmaxver, s_maxver));
+ sess_->applyChanges();
+
+ // Get empty.
+ ConstElementPtr loggers;
+ EXPECT_NO_THROW_LOG(loggers = translator_->getLoggersFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(loggers);
+ ASSERT_EQ(1, loggers->size());
+ ConstElementPtr logger = loggers->get(0);
+ ASSERT_TRUE(logger);
+ EXPECT_EQ(3, logger->size());
+ ConstElementPtr name = logger->get("name");
+ ASSERT_TRUE(name);
+ ASSERT_EQ(Element::string, name->getType());
+ EXPECT_EQ("foo", name->stringValue());
+ ConstElementPtr severity = logger->get("severity");
+ ASSERT_TRUE(severity);
+ ASSERT_EQ(Element::string, severity->getType());
+ EXPECT_EQ("WARN", severity->stringValue());
+ ConstElementPtr options = logger->get("output_options");
+ ASSERT_TRUE(options);
+ ASSERT_EQ(1, options->size());
+ ConstElementPtr option = options->get(0);
+ ASSERT_TRUE(option);
+ EXPECT_EQ(2, option->size());
+ ConstElementPtr output = option->get("output");
+ ASSERT_TRUE(output);
+ ASSERT_EQ(Element::string, output->getType());
+ EXPECT_EQ("/bar", output->stringValue());
+ ConstElementPtr maxver = option->get("maxver");
+ ASSERT_TRUE(maxver);
+ ASSERT_EQ(Element::integer, maxver->getType());
+ EXPECT_EQ(max_ver, maxver->intValue());
+}
+
+// This test verifies that one logger can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorLoggersTestv4, set) {
+ // Set a value.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ElementPtr option = Element::createMap();
+ option->set("output", Element::create("/bar"));
+ option->set("maxver", Element::create(10));
+ ElementPtr options = Element::createList();
+ options->add(option);
+ ElementPtr logger = Element::createMap();
+ logger->set("name", Element::create("foo"));
+ logger->set("severity", Element::create("WARN"));
+ logger->set("output_options", options);
+ ElementPtr loggers = Element::createList();
+ loggers->add(logger);
+ ASSERT_NO_THROW_LOG(translator_->setLoggers(xpath, loggers));
+
+ // Get it back.
+ ConstElementPtr gots;
+ EXPECT_NO_THROW_LOG(gots = translator_->getLoggersFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(gots);
+ ASSERT_EQ(1, gots->size());
+ ConstElementPtr got = gots->get(0);
+ ASSERT_TRUE(got);
+ EXPECT_EQ(3, got->size());
+ ConstElementPtr name = got->get("name");
+ ASSERT_TRUE(name);
+ ASSERT_EQ(Element::string, name->getType());
+ EXPECT_EQ("foo", name->stringValue());
+ ConstElementPtr severity = logger->get("severity");
+ ASSERT_TRUE(severity);
+ ASSERT_EQ(Element::string, severity->getType());
+ EXPECT_EQ("WARN", severity->stringValue());
+ ConstElementPtr got_os = logger->get("output_options");
+ ASSERT_TRUE(got_os);
+ ASSERT_EQ(1, got_os->size());
+ ConstElementPtr got_o = got_os->get(0);
+ ASSERT_TRUE(got_o);
+ EXPECT_EQ(2, got_o->size());
+ ConstElementPtr output = got_o->get("output");
+ ASSERT_TRUE(output);
+ ASSERT_EQ(Element::string, output->getType());
+ EXPECT_EQ("/bar", output->stringValue());
+ ConstElementPtr maxver = got_o->get("maxver");
+ ASSERT_TRUE(maxver);
+ ASSERT_EQ(Element::integer, maxver->getType());
+ EXPECT_EQ(10, maxver->intValue());
+}
+
+/// @todo: Implement a test that will cover multiple loggers.
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_option_data_unittests.cc b/src/lib/yang/tests/translator_option_data_unittests.cc
new file mode 100644
index 0000000..3917e26
--- /dev/null
+++ b/src/lib/yang/tests/translator_option_data_unittests.cc
@@ -0,0 +1,135 @@
+// Copyright (C) 2018-2023 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#include <config.h>
+
+#include <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_option_data.h>
+#include <yang/yang_models.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const option_data_list[] = "option data list";
+
+/// @brief Test fixture class for @ref TranslatorOptionDataList.
+class TranslatorOptionDataListTestv4 :
+ public GenericTranslatorTest<option_data_list, TranslatorOptionDataList> {
+public:
+ /// @brief Constructor
+ TranslatorOptionDataListTestv4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorOptionDataListTestv4
+
+class TranslatorOptionDataListTestv6 :
+ public GenericTranslatorTest<option_data_list, TranslatorOptionDataList> {
+public:
+ /// @brief Constructor
+ TranslatorOptionDataListTestv6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorOptionDataListTestv6
+
+// This test verifies that an empty option data list can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorOptionDataListTestv4, getEmpty) {
+ // Get the option data list and check if it is empty.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr options;
+ EXPECT_NO_THROW_LOG(options = translator_->getOptionDataListFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(options);
+}
+
+// This test verifies that one option data can be properly translated
+// from YANG to JSON.
+TEST_F(TranslatorOptionDataListTestv6, get) {
+ // Create the option code 100.
+ const string& xpath = "/kea-dhcp6-server:config";
+ const string& xoption = xpath + "/option-data[code='100'][space='dns']";
+ const string& xformat = xoption + "/csv-format";
+ const string& xdata = xoption + "/data";
+ const string& xalways = xoption + "/always-send";
+ const string& xnever = xoption + "/never-send";
+ string const s_false("false");
+ ASSERT_NO_THROW_LOG(sess_->setItem(xformat, s_false));
+ string const s_data("12121212");
+ ASSERT_NO_THROW_LOG(sess_->setItem(xdata, s_data));
+ ASSERT_NO_THROW_LOG(sess_->setItem(xalways, s_false));
+ ASSERT_NO_THROW_LOG(sess_->setItem(xnever, s_false));
+ sess_->applyChanges();
+
+ // Get the option data.
+ ConstElementPtr option;
+ EXPECT_NO_THROW_LOG(option = translator_->getOptionDataFromAbsoluteXpath(xoption));
+ ASSERT_TRUE(option);
+ EXPECT_EQ("{"
+ " \"always-send\": false,"
+ " \"code\": 100,"
+ " \"csv-format\": false,"
+ " \"data\": \"12121212\","
+ " \"never-send\": false,"
+ " \"space\": \"dns\""
+ " }",
+ option->str());
+
+ // Get the option data list.
+ ConstElementPtr options;
+ EXPECT_NO_THROW_LOG(options = translator_->getOptionDataListFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(options);
+ ASSERT_EQ(Element::list, options->getType());
+ EXPECT_EQ(1, options->size());
+ EXPECT_TRUE(option->equals(*options->get(0)));
+}
+
+// This test verifies that an empty option data list can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorOptionDataListTestv4, setEmpty) {
+ // Set empty list.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr options = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setOptionDataList(xpath, options));
+
+ // Get it back.
+ options.reset();
+ EXPECT_NO_THROW_LOG(options = translator_->getOptionDataListFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(options);
+}
+
+// This test verifies that one option data can be properly translated
+// from JSON to YANG.
+TEST_F(TranslatorOptionDataListTestv6, set) {
+ // Set one option data.
+ const string& xpath = "/kea-dhcp6-server:config";
+ ElementPtr options = Element::createList();
+ ElementPtr option = Element::createMap();
+ option->set("code", Element::create(100));
+ option->set("space", Element::create("dns"));
+ option->set("csv-format", Element::create(false));
+ option->set("data", Element::create("12121212"));
+ option->set("always-send", Element::create(false));
+ option->set("never-send", Element::create(false));
+ options->add(option);
+ EXPECT_NO_THROW_LOG(translator_->setOptionDataList(xpath, options));
+
+ // Get it back.
+ ConstElementPtr got;
+ EXPECT_NO_THROW_LOG(got = translator_->getOptionDataListFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(got);
+ ASSERT_EQ(1, got->size());
+ EXPECT_TRUE(option->equals(*got->get(0)));
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_option_def_unittests.cc b/src/lib/yang/tests/translator_option_def_unittests.cc
new file mode 100644
index 0000000..8482b93
--- /dev/null
+++ b/src/lib/yang/tests/translator_option_def_unittests.cc
@@ -0,0 +1,138 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_option_def.h>
+#include <yang/yang_models.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const option_definition_list[] = "option definition list";
+
+/// @brief Test fixture class for @ref TranslatorOptionDefList.
+class TranslatorOptionDefListTestKeaV4 :
+ public GenericTranslatorTest<option_definition_list, TranslatorOptionDefList> {
+public:
+ /// @brief Constructor
+ TranslatorOptionDefListTestKeaV4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorOptionDefListTestKeaV4
+class TranslatorOptionDefListTestKeaV6 :
+ public GenericTranslatorTest<option_definition_list, TranslatorOptionDefList> {
+public:
+ /// @brief Constructor
+ TranslatorOptionDefListTestKeaV6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorOptionDefListTestKeaV6
+class TranslatorOptionDefListTestIetfV6 :
+ public GenericTranslatorTest<option_definition_list, TranslatorOptionDefList> {
+public:
+ /// @brief Constructor
+ TranslatorOptionDefListTestIetfV6() {
+ model_ = IETF_DHCPV6_SERVER;
+ }
+}; // TranslatorOptionDefListTestIetfV6
+
+// This test verifies that an empty option definition list can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorOptionDefListTestKeaV4, getEmpty) {
+ // Get the option definition list and check if it is empty.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr options;
+ EXPECT_NO_THROW_LOG(options = translator_->getOptionDefListFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(options);
+}
+
+// This test verifies that one option definition can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorOptionDefListTestKeaV6, get) {
+ // Create the option code 100.
+ const string& xpath = "/kea-dhcp6-server:config";
+ const string& xdef = xpath + "/option-def[code='100'][space='isc']";
+ const string& xname = xdef + "/name";
+ const string& xtype = xdef + "/type";
+ const string& xarray = xdef + "/array";
+ string const s_name("foo");
+ ASSERT_NO_THROW_LOG(sess_->setItem(xname, s_name));
+ string const s_type("string");
+ ASSERT_NO_THROW_LOG(sess_->setItem(xtype, s_type));
+ string const s_array("false");
+ ASSERT_NO_THROW_LOG(sess_->setItem(xarray, s_array));
+ sess_->applyChanges();
+
+ // Get the option def.
+ ConstElementPtr def;
+ EXPECT_NO_THROW_LOG(def = translator_->getOptionDefFromAbsoluteXpath(xdef));
+ ASSERT_TRUE(def);
+ EXPECT_EQ("{ "
+ "\"array\": false, "
+ "\"code\": 100, "
+ "\"name\": \"foo\", "
+ "\"space\": \"isc\", "
+ "\"type\": \"string\" }",
+ def->str());
+
+ // Get the option definition list.
+ ConstElementPtr defs;
+ EXPECT_NO_THROW_LOG(defs = translator_->getOptionDefListFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(defs);
+ ASSERT_EQ(Element::list, defs->getType());
+ EXPECT_EQ(1, defs->size());
+ EXPECT_TRUE(def->equals(*defs->get(0)));
+}
+
+// This test verifies that an empty option definition list can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorOptionDefListTestKeaV4, setEmpty) {
+ // Set empty list.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr defs = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setOptionDefList(xpath, defs));
+
+ // Get it back.
+ defs.reset();
+ EXPECT_NO_THROW_LOG(defs = translator_->getOptionDefListFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(defs);
+}
+
+// This test verifies that one option definition can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorOptionDefListTestKeaV6, set) {
+ // Set one option def.
+ const string& xpath = "/kea-dhcp6-server:config";
+ ElementPtr defs = Element::createList();
+ ElementPtr def = Element::createMap();
+ def->set("code", Element::create(100));
+ def->set("name", Element::create("foo"));
+ def->set("space", Element::create("isc"));
+ def->set("type", Element::create("string"));
+ def->set("array", Element::create(false));
+ defs->add(def);
+ EXPECT_NO_THROW_LOG(translator_->setOptionDefList(xpath, defs));
+
+ // Get it back.
+ ConstElementPtr got;
+ EXPECT_NO_THROW_LOG(got = translator_->getOptionDefListFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(got);
+ ASSERT_EQ(1, got->size());
+ EXPECT_TRUE(def->equals(*got->get(0)));
+}
+
+} // anonymous namespace
diff --git a/src/lib/yang/tests/translator_pd_pool_unittests.cc b/src/lib/yang/tests/translator_pd_pool_unittests.cc
new file mode 100644
index 0000000..f8c9388
--- /dev/null
+++ b/src/lib/yang/tests/translator_pd_pool_unittests.cc
@@ -0,0 +1,296 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_pd_pool.h>
+#include <yang/yang_models.h>
+
+#include <sstream>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const pd_pool_list[] = "pd pool list";
+
+/// @brief Test fixture class for @ref TranslatorPdPools.
+class TranslatorPdPoolsTestKeaV6 :
+ public GenericTranslatorTest<pd_pool_list, TranslatorPdPools> {
+public:
+ /// @brief Constructor
+ TranslatorPdPoolsTestKeaV6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorPdPoolsTestKeaV6
+class TranslatorPdPoolsTestIetfV6 :
+ public GenericTranslatorTest<pd_pool_list, TranslatorPdPools> {
+public:
+ /// @brief Constructor
+ TranslatorPdPoolsTestIetfV6() {
+ model_ = IETF_DHCPV6_SERVER;
+ }
+}; // TranslatorPdPoolsTestIetfV6
+
+// This test verifies that an empty pd pool list can be properly
+// translated from YANG to JSON using the IETF model.
+TEST_F(TranslatorPdPoolsTestIetfV6, getEmptyIetf) {
+ // Get the pd-pool list and check if it is empty.
+ const string& xpath =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges"
+ "/network-range[network-range-id='111']/pd-pools";
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(pools);
+}
+
+// This test verifies that an empty pd pool list can be properly
+// translated from YANG to JSON using the Kea ad hoc model.
+TEST_F(TranslatorPdPoolsTestKeaV6, getEmptyKea) {
+ // Get the pd-pool list and check if it is empty.
+ const string& xpath = "/kea-dhcp6-server:config/subnet6[id='111']";
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(pools);
+}
+
+// This test verifies that one pd pool can be properly
+// translated from YANG to JSON using the IETF model.
+TEST_F(TranslatorPdPoolsTestIetfV6, getIetf) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& subnet =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges"
+ "/network-range[network-range-id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet_subnet = subnet + "/network-prefix";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet_subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Create the pd-pool 2001:db8:0:1000::/64 #222.
+ const string& xpath = subnet + "/pd-pools/pd-pool[pool-id='222']";
+ const string& prefix = xpath + "/prefix";
+ string const s_prefix("2001:db8:0:1000::/56");
+ EXPECT_NO_THROW_LOG(sess_->setItem(prefix, s_prefix));
+ const string& length = xpath + "/prefix-length";
+ uint8_t len = 56;
+ string const s_length(to_string(len));
+ EXPECT_NO_THROW_LOG(sess_->setItem(length, s_length));
+ sess_->applyChanges();
+
+ // Get the pool.
+ ConstElementPtr pool;
+ EXPECT_NO_THROW_LOG(pool = translator_->getPdPoolFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pool);
+ ElementPtr expected = Element::createMap();
+ expected->set("prefix", Element::create("2001:db8:0:1000::"));
+ expected->set("prefix-len", Element::create(56));
+ EXPECT_TRUE(expected->equals(*pool));
+
+ // Get the pd-pool list and check if the pd-pool is in it.
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(subnet + "/pd-pools"));
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(Element::list, pools->getType());
+ ASSERT_EQ(1, pools->size());
+ EXPECT_TRUE(pool->equals(*pools->get(0)));
+}
+
+// This test verifies that one pd pool can be properly
+// translated from YANG to JSON using the Kea ad hoc model.
+TEST_F(TranslatorPdPoolsTestKeaV6, getKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Create the pd-pool 2001:db8:0:1000::/64.
+ const string& prefix = "2001:db8:0:1000::/56";
+ ostringstream spool;
+ spool << xpath + "/pd-pool[prefix='" << prefix << "']";
+ const string& x_delegated = spool.str() + "/delegated-len";
+ uint8_t dl = 64;
+ string const s_delegated(to_string(dl));
+ EXPECT_NO_THROW_LOG(sess_->setItem(x_delegated, s_delegated));
+ sess_->applyChanges();
+
+ // Get the pool.
+ ConstElementPtr pool;
+ EXPECT_NO_THROW_LOG(pool = translator_->getPdPoolFromAbsoluteXpath(spool.str()));
+ ASSERT_TRUE(pool);
+ ElementPtr expected = Element::createMap();
+ expected->set("prefix", Element::create("2001:db8:0:1000::"));
+ expected->set("prefix-len", Element::create(56));
+ expected->set("delegated-len", Element::create(64));
+ EXPECT_TRUE(expected->equals(*pool));
+
+ // Get the pd-pool list and check if the pd-pool is in it.
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(Element::list, pools->getType());
+ ASSERT_EQ(1, pools->size());
+ EXPECT_TRUE(pool->equals(*pools->get(0)));
+}
+
+// This test verifies that an empty pd pool list can be properly
+// translated from JSON to YANG using the IETF model.
+TEST_F(TranslatorPdPoolsTestIetfV6, setEmptyIetf) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& subnet =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges"
+ "/network-range[network-range-id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet_subnet = subnet + "/network-prefix";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet_subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set empty list.
+ const string& xpath = subnet + "/pd-pools";
+ ConstElementPtr pools = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setPdPools(xpath, pools));
+
+ // Get it back.
+ pools.reset();
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(pools);
+}
+
+// This test verifies that an empty pd pool list can be properly
+// translated from JSON to YANG using the Kea ad hoc model.
+TEST_F(TranslatorPdPoolsTestKeaV6, setEmptyKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set empty list.
+ ConstElementPtr pools = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setPdPools(xpath, pools));
+
+ // Get it back.
+ pools.reset();
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(pools);
+}
+
+// This test verifies that one pd pool can be properly
+// translated from JSON to YANG using the IETF model.
+TEST_F(TranslatorPdPoolsTestIetfV6, setIetf) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& subnet =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges"
+ "/network-range[network-range-id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet_subnet = subnet + "/network-prefix";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet_subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set one pool.
+ const string& xpath = subnet + "/pd-pools";
+ ElementPtr pools = Element::createList();
+ ElementPtr pool = Element::createMap();
+ pool->set("prefix", Element::create("2001:db8:0:1000::"));
+ pool->set("prefix-len", Element::create(56));
+ pools->add(pool);
+ EXPECT_NO_THROW_LOG(translator_->setPdPools(xpath, pools));
+
+ // Get it back.
+ pools.reset();
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(Element::list, pools->getType());
+ ASSERT_EQ(1, pools->size());
+ EXPECT_TRUE(pool->equals(*pools->get(0)));
+}
+
+// This test verifies that one pd pool can be properly
+// translated from JSON to YANG using the kea ad hoc model.
+TEST_F(TranslatorPdPoolsTestKeaV6, setKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set one pool.
+ ElementPtr pools = Element::createList();
+ ElementPtr pool = Element::createMap();
+ pool->set("prefix", Element::create("2001:db8:0:1000::"));
+ pool->set("prefix-len", Element::create(56));
+ pool->set("delegated-len", Element::create(64));
+ pools->add(pool);
+ EXPECT_NO_THROW_LOG(translator_->setPdPools(xpath, pools));
+
+ // Get it back.
+ pools.reset();
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(Element::list, pools->getType());
+ ASSERT_EQ(1, pools->size());
+ EXPECT_TRUE(pool->equals(*pools->get(0)));
+}
+
+// This test verifies that a non-empty list of pd pools can be properly
+// translated from YANG to JSON using the Kea ad hoc model.
+TEST_F(TranslatorPdPoolsTestKeaV6, getListKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Create the first pd-pool 2001:db8:0:1000::/56.
+ const string& prefix = "2001:db8:0:1000::/56";
+ ostringstream spool;
+ spool << xpath + "/pd-pool[prefix='" << prefix << "']";
+ const string& x_delegated = spool.str() + "/delegated-len";
+ uint8_t dl = 64;
+ string const s_delegated(to_string(dl));
+ EXPECT_NO_THROW_LOG(sess_->setItem(x_delegated, s_delegated));
+ sess_->applyChanges();
+
+ // Create the second pd-pool 2001:db8:0:2000::/56
+ const string& prefix2 = "2001:db8:0:2000::/56";
+ ostringstream spool2;
+ spool2 << xpath + "/pd-pool[prefix='" << prefix2 << "']";
+ const string& x_delegated2 = spool2.str() + "/delegated-len";
+ uint8_t dl2 = 60;
+ string const s_delegated2(to_string(dl2));
+ EXPECT_NO_THROW_LOG(sess_->setItem(x_delegated2, s_delegated2));
+ sess_->applyChanges();
+
+ // Get the pools list.
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPdPoolsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pools);
+
+ // Check that both of them are returned properly.
+ EXPECT_EQ(pools->str(),
+ "[ { \"delegated-len\": 64, \"prefix\": \"2001:db8:0:1000::\", "
+ "\"prefix-len\": 56 }, { \"delegated-len\": 60, \"prefix\": "
+ "\"2001:db8:0:2000::\", \"prefix-len\": 56 } ]");
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_pool_unittests.cc b/src/lib/yang/tests/translator_pool_unittests.cc
new file mode 100644
index 0000000..ad0d25f
--- /dev/null
+++ b/src/lib/yang/tests/translator_pool_unittests.cc
@@ -0,0 +1,252 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_pool.h>
+#include <yang/yang_models.h>
+
+#include <sstream>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const pool_list[] = "pool list";
+
+/// @brief Test fixture class for @ref TranslatorPools.
+class TranslatorPoolsTestKeaV4 :
+ public GenericTranslatorTest<pool_list, TranslatorPools> {
+public:
+ /// @brief Constructor
+ TranslatorPoolsTestKeaV4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorPoolsTestKeaV4
+class TranslatorPoolsTestKeaV6 :
+ public GenericTranslatorTest<pool_list, TranslatorPools> {
+public:
+ /// @brief Constructor
+ TranslatorPoolsTestKeaV6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorPoolsTestKeaV6
+class TranslatorPoolsTestIetfV6 :
+ public GenericTranslatorTest<pool_list, TranslatorPools> {
+public:
+ /// @brief Constructor
+ TranslatorPoolsTestIetfV6() {
+ model_ = IETF_DHCPV6_SERVER;
+ }
+}; // TranslatorPoolsTestIetfV6
+
+// This test verifies that an empty pool list can be properly
+// translated from YANG to JSON using IETF model.
+TEST_F(TranslatorPoolsTestIetfV6, getEmptyIetf) {
+ // Get the pool list and check if it is empty.
+ const string& xpath = "/ietf-dhcpv6-server:server/server-config/"
+ "network-ranges/network-range[network-range-id='111']/address-pools";
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(pools);
+}
+
+// This test verifies that an empty pool list can be properly
+// translated from YANG to JSON using Kea ad hoc model.
+TEST_F(TranslatorPoolsTestKeaV6, getEmptyKea) {
+ // Get the pool list and check if it is empty.
+ const string& xpath = "/kea-dhcp6-server:config/subnet6[id='111']";
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(pools);
+}
+
+// This test verifies that one pool can be properly
+// translated from YANG to JSON using IETF model.
+TEST_F(TranslatorPoolsTestIetfV6, getIetf) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& subnet = "/ietf-dhcpv6-server:server/server-config/"
+ "network-ranges/network-range[network-range-id='111']";
+ string const subnet_value("2001:db8::/48");
+ string const& network_prefix_path = subnet + "/network-prefix";
+ EXPECT_NO_THROW_LOG(sess_->setItem(network_prefix_path, subnet_value));
+ sess_->applyChanges();
+
+ // Create the pool 2001:db8::1:0/112 #222.
+ const string& xpath = subnet + "/address-pools";
+ const string& prefix = xpath + "/address-pool[pool-id='222']/pool-prefix";
+ string const value("2001:db8::1:0/112");
+ EXPECT_NO_THROW_LOG(sess_->setItem(prefix, value));
+ sess_->applyChanges();
+
+ // Get the pool.
+ ConstElementPtr pool;
+ EXPECT_NO_THROW_LOG(pool = translator_->getPoolFromAbsoluteXpath(xpath + "/address-pool[pool-id='222']"));
+ ASSERT_TRUE(pool);
+ EXPECT_EQ("{ \"pool\": \"2001:db8::1:0/112\" }", pool->str());
+
+ // Get the pool list and check if the pool is in it.
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(Element::list, pools->getType());
+ ASSERT_EQ(1, pools->size());
+ EXPECT_TRUE(pool->equals(*pools->get(0)));
+}
+
+// This test verifies that one pool can be properly
+// translated from YANG to JSON using Kea ad hoc model.
+TEST_F(TranslatorPoolsTestKeaV6, getKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Create the pool 2001:db8::1:0/112.
+ const string& prefix = "2001:db8::1:0/112";
+ string start_addr;
+ string end_addr;
+ ASSERT_NO_THROW_LOG(TranslatorPool::getAddresses(prefix,
+ start_addr, end_addr));
+ EXPECT_EQ("2001:db8::1:0", start_addr);
+ EXPECT_EQ("2001:db8::1:ffff", end_addr);
+ ostringstream spool;
+ spool << xpath + "/pool[start-address='" << start_addr
+ << "'][end-address='" << end_addr << "']";
+ const string& x_prefix = spool.str() + "/prefix";
+ string const s_prefix("2001:db8::1:0/112");
+ EXPECT_NO_THROW_LOG(sess_->setItem(x_prefix, s_prefix));
+ sess_->applyChanges();
+
+ // Get the pool.
+ ConstElementPtr pool;
+ EXPECT_NO_THROW_LOG(pool = translator_->getPoolFromAbsoluteXpath(spool.str()));
+ ASSERT_TRUE(pool);
+ ElementPtr expected = Element::createMap();
+ expected->set("pool", Element::create("2001:db8::1:0/112"));
+ EXPECT_TRUE(expected->equals(*pool));
+
+ // Get the pool list and check if the pool is in it.
+ ConstElementPtr pools;
+ EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(Element::list, pools->getType());
+ ASSERT_EQ(1, pools->size());
+ EXPECT_TRUE(pool->equals(*pools->get(0)));
+}
+
+// This test verifies that an empty pool list can be properly
+// translated from JSON to YANG using IETF model.
+TEST_F(TranslatorPoolsTestIetfV6, setEmptyIetf) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& subnet = "/ietf-dhcpv6-server:server/server-config/"
+ "network-ranges/network-range[network-range-id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet_subnet = subnet + "/network-prefix";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet_subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set empty list.
+ const string& xpath = subnet + "/address-pools";
+ ConstElementPtr pools = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setPools(xpath, pools));
+
+ // Get it back.
+ pools.reset();
+ EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(pools);
+}
+
+// This test verifies that an empty pool list can be properly
+// translated from JSON to YANG using Kea ad hoc model.
+TEST_F(TranslatorPoolsTestKeaV6, setEmptyKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set empty list.
+ ConstElementPtr pools = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setPools(xpath, pools));
+
+ // Get it back.
+ pools.reset();
+ EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(pools);
+}
+
+// This test verifies that one pool can be properly
+// translated from JSON to YANG using IETF model.
+TEST_F(TranslatorPoolsTestIetfV6, setIetf) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& subnet = "/ietf-dhcpv6-server:server/server-config/"
+ "network-ranges/network-range[network-range-id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet_subnet = subnet + "/network-prefix";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet_subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set one pool.
+ const string& xpath = subnet + "/address-pools";
+ ElementPtr pools = Element::createList();
+ ElementPtr pool = Element::createMap();
+ pool->set("pool", Element::create("2001:db8::1:0/112"));
+ pools->add(pool);
+ EXPECT_NO_THROW_LOG(translator_->setPools(xpath, pools));
+
+ // Get it back.
+ pools.reset();
+ EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(Element::list, pools->getType());
+ ASSERT_EQ(1, pools->size());
+ EXPECT_TRUE(pool->equals(*pools->get(0)));
+}
+
+// This test verifies that one pool can be properly
+// translated from JSON to YANG using Kea ad hoc model.
+TEST_F(TranslatorPoolsTestKeaV6, setKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/kea-dhcp6-server:config/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& subnet = xpath + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(subnet, v_subnet));
+ sess_->applyChanges();
+
+ // Set one pool.
+ ElementPtr pools = Element::createList();
+ ElementPtr pool = Element::createMap();
+ pool->set("pool",
+ Element::create("2001:db8::1 - 2001:db8::100"));
+ pools->add(pool);
+ EXPECT_NO_THROW_LOG(translator_->setPools(xpath, pools));
+
+ // Get it back.
+ pools.reset();
+ EXPECT_NO_THROW_LOG(pools = translator_->getPoolsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(pools);
+ ASSERT_EQ(Element::list, pools->getType());
+ ASSERT_EQ(1, pools->size());
+ EXPECT_TRUE(pool->equals(*pools->get(0)));
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_shared_network_unittests.cc b/src/lib/yang/tests/translator_shared_network_unittests.cc
new file mode 100644
index 0000000..e897713
--- /dev/null
+++ b/src/lib/yang/tests/translator_shared_network_unittests.cc
@@ -0,0 +1,210 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_shared_network.h>
+#include <yang/yang_models.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const shared_networks[] = "shared networks";
+
+/// @brief Test fixture class for @ref TranslatorSharedNetworks.
+class TranslatorSharedNetworksTestKeaV4 :
+ public GenericTranslatorTest<shared_networks, TranslatorSharedNetworks> {
+public:
+ /// @brief Constructor
+ TranslatorSharedNetworksTestKeaV4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorSharedNetworksTestKeaV4
+class TranslatorSharedNetworksTestKeaV6 :
+ public GenericTranslatorTest<shared_networks, TranslatorSharedNetworks> {
+public:
+ /// @brief Constructor
+ TranslatorSharedNetworksTestKeaV6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorSharedNetworksTestKeaV6
+
+// This test verifies that an empty shared network list can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorSharedNetworksTestKeaV4, getEmpty) {
+ // Get the shared network list and check if it is empty.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr networks;
+ EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(networks);
+}
+
+// This test verifies that one shared network can be properly
+// translated from YANG to JSON.
+TEST_F(TranslatorSharedNetworksTestKeaV6, get) {
+ // Create the subnet 2001:db8::/48 #111 in shared network foo.
+ const string& xpath = "/kea-dhcp6-server:config";
+ const string& xnetwork = xpath + "/shared-network[name='foo']";
+ const string& xsubnet = xnetwork + "/subnet6[id='111']/subnet";
+ string const v_subnet("2001:db8::/48");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet, v_subnet));
+ sess_->applyChanges();
+
+ // Get the shared network.
+ ConstElementPtr network;
+ EXPECT_NO_THROW_LOG(network = translator_->getSharedNetworkFromAbsoluteXpath(xnetwork));
+ ASSERT_TRUE(network);
+ ElementPtr subnet = Element::createMap();
+ subnet->set("id", Element::create(111));
+ subnet->set("subnet", Element::create("2001:db8::/48"));
+ ElementPtr subnets = Element::createList();
+ subnets->add(subnet);
+ ElementPtr expected = Element::createMap();
+ expected->set("name", Element::create("foo"));
+ expected->set("subnet6", subnets);
+ EXPECT_TRUE(expected->equals(*network));
+
+ // Get the shared network list and check if the shared network is in it.
+ ConstElementPtr networks;
+ EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(networks);
+ ASSERT_EQ(Element::list, networks->getType());
+ ASSERT_EQ(1, networks->size());
+ EXPECT_TRUE(network->equals(*networks->get(0)));
+}
+
+// This test verifies that an empty shared network list can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorSharedNetworksTestKeaV4, setEmpty) {
+ // Set empty list.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ConstElementPtr networks = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setSharedNetworks(xpath, networks));
+
+ // Get it back.
+ networks.reset();
+ EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(networks);
+}
+
+// This test verifies that one shared network can be properly
+// translated from JSON to YANG.
+TEST_F(TranslatorSharedNetworksTestKeaV6, set) {
+ // Set one shared network.
+ const string& xpath = "/kea-dhcp6-server:config";
+ ElementPtr networks = Element::createList();
+ ElementPtr share = Element::createMap();
+ ElementPtr subnets = Element::createList();
+ ElementPtr subnet = Element::createMap();
+ subnet->set("subnet", Element::create("2001:db8::/48"));
+ subnet->set("id", Element::create(123));
+ subnets->add(subnet);
+ share->set("name", Element::create("foo"));
+ share->set("subnet6", subnets);
+ networks->add(share);
+ EXPECT_NO_THROW_LOG(translator_->setSharedNetworks(xpath, networks));
+
+ // Get it back.
+ networks.reset();
+ EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(networks);
+ ASSERT_EQ(Element::list, networks->getType());
+ ASSERT_EQ(1, networks->size());
+ EXPECT_TRUE(share->equals(*networks->get(0)));
+}
+
+// This test verifies that several shared networks can be properly
+// translated from YANG to JSON. This test adds the following structure:
+//
+// shared-network "foo":
+// - subnet1: 2001:db8:1::/48 (subnet-id 1)
+// - subnet1: 2001:db8:2::/48 (subnet-id 2)
+// shared-network "bar":
+// - subnet1: 2001:db8:101::/48 (subnet-id 101)
+// - subnet1: 2001:db8:102::/48 (subnet-id 102)
+TEST_F(TranslatorSharedNetworksTestKeaV6, getList) {
+ const string& xpath = "/kea-dhcp6-server:config";
+
+ // Those two networks will be added.
+ const string& xnetwork1 = xpath + "/shared-network[name='foo']";
+ const string& xnetwork2 = xpath + "/shared-network[name='bar']";
+
+ // Non-existent network
+ const string& xnetwork3 = xpath + "/shared-network[name='baz']";
+
+ const string& exp_net1 =
+ "{ \"name\": \"foo\", \"subnet6\": [ { \"id\": 1, "
+ "\"subnet\": \"2001:db8:1::/48\" }, "
+ "{ \"id\": 2, \"subnet\": \"2001:db8:2::/48\" } ] }";
+
+ const string& exp_net2 =
+ "{ \"name\": \"bar\", \"subnet6\": [ { \"id\": 101, "
+ "\"subnet\": \"2001:db8:101::/48\" }, "
+ "{ \"id\": 102, \"subnet\": \"2001:db8:102::/48\" } ] }";
+
+ const string exp_both =
+ "[ " + exp_net1 + ", " + exp_net2 + " ]";
+
+ // Create the subnet1: 2001:db8:1::/48 #1 in shared network foo.
+ const string& xsubnet1 = xnetwork1 + "/subnet6[id='1']/subnet";
+ string const v_subnet1("2001:db8:1::/48");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet1, v_subnet1));
+ sess_->applyChanges();
+
+ // Create the subnet2: 2001:db8:2::/48 #2 in shared network foo.
+ const string& xsubnet2 = xnetwork1 + "/subnet6[id='2']/subnet";
+ string const v_subnet2("2001:db8:2::/48");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet2, v_subnet2));
+ sess_->applyChanges();
+
+ // Create the subnet1: 2001:db8:101::/48 #101 in shared network foo.
+ const string& xsubnet3 = xnetwork2 + "/subnet6[id='101']/subnet";
+ string const v_subnet("2001:db8:101::/48");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet3, v_subnet));
+ sess_->applyChanges();
+
+ // Create the subnet2: 2001:db8:2::/48 #2 in shared network foo.
+ const string& xsubnet4 = xnetwork2 + "/subnet6[id='102']/subnet";
+ string const v_subnet4("2001:db8:102::/48");
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet4, v_subnet4));
+ sess_->applyChanges();
+
+ // Ok, now test the getters. Let's start with the easier ones that
+ // return a single network.
+ ConstElementPtr network;
+
+ // Get the first network.
+ EXPECT_NO_THROW_LOG(network = translator_->getSharedNetworkFromAbsoluteXpath(xnetwork1));
+ ASSERT_TRUE(network);
+ EXPECT_EQ(exp_net1, network->str());
+
+ // Get the second network.
+ EXPECT_NO_THROW_LOG(network = translator_->getSharedNetworkFromAbsoluteXpath(xnetwork2));
+ ASSERT_TRUE(network);
+ EXPECT_EQ(exp_net2, network->str());
+
+ // Check that networks with non-existent name are not returned.
+ EXPECT_NO_THROW_LOG(network = translator_->getSharedNetworkFromAbsoluteXpath(xnetwork3));
+ EXPECT_FALSE(network);
+
+ // Now test returns all networks
+ ConstElementPtr networks;
+ EXPECT_NO_THROW_LOG(networks = translator_->getSharedNetworksFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(networks);
+ EXPECT_EQ(exp_both, networks->str());
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_subnet_unittests.cc b/src/lib/yang/tests/translator_subnet_unittests.cc
new file mode 100644
index 0000000..d9a8104
--- /dev/null
+++ b/src/lib/yang/tests/translator_subnet_unittests.cc
@@ -0,0 +1,379 @@
+// 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 <gtest/gtest.h>
+
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator_subnet.h>
+#include <yang/yang_models.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace sysrepo;
+
+namespace {
+
+/// @brief Translator name.
+extern char const subnet_list[] = "subnet list";
+
+/// @brief Test fixture class for @ref TranslatorSubnets.
+class TranslatorSubnetsTestKeaV4 :
+ public GenericTranslatorTest<subnet_list, TranslatorSubnets> {
+public:
+ /// @brief Constructor
+ TranslatorSubnetsTestKeaV4() {
+ model_ = KEA_DHCP4_SERVER;
+ }
+}; // TranslatorSubnetsTestKeaV4
+
+class TranslatorSubnetsTestKeaV6 :
+ public GenericTranslatorTest<subnet_list, TranslatorSubnets> {
+public:
+ /// @brief Constructor
+ TranslatorSubnetsTestKeaV6() {
+ model_ = KEA_DHCP6_SERVER;
+ }
+}; // TranslatorSubnetsTestKeaV6
+
+class TranslatorSubnetsTestIetfV6 :
+ public GenericTranslatorTest<subnet_list, TranslatorSubnets> {
+public:
+ /// @brief Constructor
+ TranslatorSubnetsTestIetfV6() {
+ model_ = IETF_DHCPV6_SERVER;
+ }
+}; // TranslatorSubnetsTestIetfV6
+
+// This test verifies that an empty subnet list can be properly
+// translated from YANG to JSON using IETF model.
+TEST_F(TranslatorSubnetsTestIetfV6, getEmptyIetf) {
+ // Get the subnet list and check if it is empty.
+ const string& xpath =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges";
+ ConstElementPtr subnets;
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(subnets);
+}
+
+// This test verifies that an empty subnet list can be properly
+// translated from YANG to JSON using Kea ad hoc model.
+TEST_F(TranslatorSubnetsTestKeaV6, getEmptyKea) {
+ // Get the subnet list and check if it is empty.
+ const string& xpath = "/kea-dhcp6-server:config";
+ ConstElementPtr subnets;
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(subnets);
+}
+
+// This test verifies that one subnet can be properly
+// translated from YANG to JSON using IETF model.
+TEST_F(TranslatorSubnetsTestIetfV6, getIetf) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges";
+ const string& xsub = xpath + "/network-range[network-range-id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& xsubnet = xsub + "/network-prefix";
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet, v_subnet));
+ sess_->applyChanges();
+
+ // Get the subnet.
+ ConstElementPtr subnet;
+ EXPECT_NO_THROW_LOG(subnet = translator_->getSubnetFromAbsoluteXpath(xsub));
+ ASSERT_TRUE(subnet);
+ EXPECT_EQ("{ \"id\": 111, "
+ "\"subnet\": \"2001:db8::/48\" }",
+ subnet->str());
+
+ // Get the subnet list and check if the subnet is in it.
+ ConstElementPtr subnets;
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(subnets);
+ ASSERT_EQ(Element::list, subnets->getType());
+ ASSERT_EQ(1, subnets->size());
+ ASSERT_TRUE(subnets->get(0));
+ EXPECT_TRUE(subnet->equals(*subnets->get(0)));
+}
+
+// This test verifies that one subnet can be properly
+// translated from YANG to JSON using Kea ad hoc model.
+TEST_F(TranslatorSubnetsTestKeaV6, getKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath = "/kea-dhcp6-server:config";
+ const string& xsub = xpath + "/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& xsubnet = xsub + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet, v_subnet));
+ sess_->applyChanges();
+
+ // Get the subnet.
+ ConstElementPtr subnet;
+ EXPECT_NO_THROW_LOG(subnet = translator_->getSubnetFromAbsoluteXpath(xsub));
+ ASSERT_TRUE(subnet);
+ ElementPtr expected = Element::createMap();
+ expected->set("id", Element::create(111));
+ expected->set("subnet", Element::create("2001:db8::/48"));
+ EXPECT_TRUE(expected->equals(*subnet));
+
+ // Get the subnet list and check if the subnet is in it.
+ ConstElementPtr subnets;
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(subnets);
+ ASSERT_EQ(Element::list, subnets->getType());
+ ASSERT_EQ(1, subnets->size());
+ EXPECT_TRUE(subnet->equals(*subnets->get(0)));
+}
+
+// This test verifies that one subnet with two pools can be properly
+// translated from YANG to JSON using IETF model.
+TEST_F(TranslatorSubnetsTestIetfV6, getPoolsIetf) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges";
+ const string& xsub = xpath + "/network-range[network-range-id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& xsubnet = xsub + "/network-prefix";
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet, v_subnet));
+ sess_->applyChanges();
+
+ // Create the pool 2001:db8::1:0/112 #1.
+ const string& xpool = xsub + "/address-pools";
+ const string& prefix1 = xpool + "/address-pool[pool-id='1']/pool-prefix";
+ string const s_pool1("2001:db8::1:0/112");
+ EXPECT_NO_THROW_LOG(sess_->setItem(prefix1, s_pool1));
+ sess_->applyChanges();
+
+ // Create the pool 2001:db8::2:0/112 #2.
+ const string& prefix2 = xpool + "/address-pool[pool-id='2']/pool-prefix";
+ string const s_pool2("2001:db8::2:0/112");
+ EXPECT_NO_THROW_LOG(sess_->setItem(prefix2, s_pool2));
+ sess_->applyChanges();
+
+ // Get the subnet.
+ ConstElementPtr subnet;
+ EXPECT_NO_THROW_LOG(subnet = translator_->getSubnetFromAbsoluteXpath(xsub));
+ ASSERT_TRUE(subnet);
+ string expected =
+ "{\n"
+ " \"id\": 111,\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"2001:db8::1:0/112\"\n"
+ " },\n"
+ " {\n"
+ " \"pool\": \"2001:db8::2:0/112\"\n"
+ " }\n"
+ " ],\n"
+ " \"subnet\": \"2001:db8::/48\"\n"
+ "}";
+ EXPECT_EQ(expected, prettyPrint(subnet));
+
+ // Get the subnet list and check if the subnet is in it.
+ ConstElementPtr subnets;
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(subnets);
+ ASSERT_EQ(Element::list, subnets->getType());
+ ASSERT_EQ(1, subnets->size());
+ EXPECT_TRUE(subnet->equals(*subnets->get(0)));
+}
+
+// This test verifies that one subnet with two pools can be properly
+// translated from YANG to JSON using Kea ad hoc model.
+TEST_F(TranslatorSubnetsTestKeaV6, getPoolsKea) {
+ // Create the subnet 2001:db8::/48 #111.
+ const string& xpath = "/kea-dhcp6-server:config";
+ const string& xsub = xpath + "/subnet6[id='111']";
+ string const v_subnet("2001:db8::/48");
+ const string& xsubnet = xsub + "/subnet";
+ EXPECT_NO_THROW_LOG(sess_->setItem(xsubnet, v_subnet));
+ sess_->applyChanges();
+
+ // Create the pool 2001:db8::1:0/112.
+ const string& prefix1 = xsub + "/pool[start-address='2001:db8::1:0']" +
+ "[end-address='2001:db8::1:ffff']/prefix";
+ string const s_pool1("2001:db8::1:0/112");
+ EXPECT_NO_THROW_LOG(sess_->setItem(prefix1, s_pool1));
+ sess_->applyChanges();
+
+ // Create the pool 2001:db8::2:0/112.
+ const string& prefix2 = xsub + "/pool[start-address='2001:db8::2:0']" +
+ "[end-address='2001:db8::2:ffff']";
+ EXPECT_NO_THROW_LOG(sess_->setItem(prefix2, nullopt));
+ sess_->applyChanges();
+
+ // Get the subnet.
+ ConstElementPtr subnet;
+ EXPECT_NO_THROW_LOG(subnet = translator_->getSubnetFromAbsoluteXpath(xsub));
+ ASSERT_TRUE(subnet);
+ string expected =
+ "{\n"
+ " \"id\": 111,\n"
+ " \"pools\": [\n"
+ " {\n"
+ " \"pool\": \"2001:db8::1:0/112\"\n"
+ " },\n"
+ " {\n"
+ " \"pool\": \"2001:db8::2:0 - 2001:db8::2:ffff\"\n"
+ " }\n"
+ " ],\n"
+ " \"subnet\": \"2001:db8::/48\"\n"
+ "}";
+ EXPECT_EQ(expected, prettyPrint(subnet));
+
+ // Get the subnet list and check if the subnet is in it.
+ ConstElementPtr subnets;
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(subnets);
+ ASSERT_EQ(Element::list, subnets->getType());
+ ASSERT_EQ(1, subnets->size());
+ EXPECT_TRUE(subnet->equals(*subnets->get(0)));
+}
+
+// This test verifies that an empty subnet list can be properly
+// translated from JSON to YANG using IETF model.
+TEST_F(TranslatorSubnetsTestIetfV6, setEmptyIetf) {
+ // Set empty list.
+ const string& xpath =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges";
+ ConstElementPtr subnets = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets));
+
+ // Get it back.
+ subnets.reset();
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(subnets);
+}
+
+// This test verifies that an empty subnet list can be properly
+// translated from JSON to YANG using Kea ad hoc model.
+TEST_F(TranslatorSubnetsTestKeaV4, setEmptyKea) {
+ // Set empty list.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ElementPtr subnets = Element::createList();
+ EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets));
+
+ // Get it back.
+ subnets.reset();
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_FALSE(subnets);
+}
+
+// This test verifies that one subnet can be properly
+// translated from JSON to YANG using IETF model.
+TEST_F(TranslatorSubnetsTestIetfV6, setIetf) {
+ // Set one subnet.
+ const string& xpath =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges";
+ ElementPtr subnets = Element::createList();
+ ElementPtr subnet = Element::createMap();
+ subnet->set("subnet", Element::create("2001:db8::/48"));
+ subnet->set("id", Element::create(123));
+ subnets->add(subnet);
+ EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets));
+
+ // Get it back.
+ subnets.reset();
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(subnets);
+ ASSERT_EQ(Element::list, subnets->getType());
+ ASSERT_EQ(1, subnets->size());
+ EXPECT_TRUE(subnet->equals(*subnets->get(0)));
+}
+
+// This test verifies that one subnet can be properly
+// translated from JSON to YANG using Kea ad hoc model.
+TEST_F(TranslatorSubnetsTestKeaV4, setKea) {
+ // Set one subnet.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ElementPtr subnets = Element::createList();
+ ElementPtr subnet = Element::createMap();
+ subnet->set("subnet", Element::create("10.0.1.0/24"));
+ subnet->set("id", Element::create(123));
+ subnets->add(subnet);
+ EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets));
+
+ // Get it back.
+ subnets.reset();
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(subnets);
+ ASSERT_EQ(Element::list, subnets->getType());
+ ASSERT_EQ(1, subnets->size());
+ EXPECT_TRUE(subnet->equals(*subnets->get(0)));
+}
+
+// This test verifies that one subnet with two pools can be properly
+// translated from JSON to YANG using IETF model.
+TEST_F(TranslatorSubnetsTestIetfV6, setTwoIetf) {
+ // Set one subnet.
+ const string& xpath =
+ "/ietf-dhcpv6-server:server/server-config/network-ranges";
+ ElementPtr subnets = Element::createList();
+ ElementPtr subnet = Element::createMap();
+ subnet->set("subnet", Element::create("2001:db8::/48"));
+ subnet->set("id", Element::create(123));
+
+ // Add two pools.
+ ElementPtr pools = Element::createList();
+ ElementPtr pool1 = Element::createMap();
+ pool1->set("pool", Element::create("2001:db8::1:0/112"));
+ pools->add(pool1);
+ ElementPtr pool2 = Element::createMap();
+ pool2->set("pool", Element::create("2001:db8::2:0/112"));
+ pools->add(pool2);
+ subnet->set("pools", pools);
+
+ // Add the subnet.
+ subnets->add(subnet);
+ EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets));
+
+ // Get it back.
+ subnets.reset();
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(subnets);
+ ASSERT_EQ(Element::list, subnets->getType());
+ ASSERT_EQ(1, subnets->size());
+ EXPECT_TRUE(subnet->equals(*subnets->get(0)));
+}
+
+// This test verifies that one subnet with two pools can be properly
+// translated from JSON to YANG using Kea ad hoc model.
+TEST_F(TranslatorSubnetsTestKeaV4, setTwoKea) {
+ // Set one subnet.
+ const string& xpath = "/kea-dhcp4-server:config";
+ ElementPtr subnets = Element::createList();
+ ElementPtr subnet = Element::createMap();
+ subnet->set("subnet", Element::create("10.0.1.0/24"));
+ subnet->set("id", Element::create(123));
+
+ // Add two pools.
+ ElementPtr pools = Element::createList();
+ ElementPtr pool1 = Element::createMap();
+ pool1->set("pool", Element::create("10.0.1.0/28"));
+ pools->add(pool1);
+ ElementPtr pool2 = Element::createMap();
+ pool2->set("pool", Element::create("10.0.1.200 - 10.0.1.222"));
+ pools->add(pool2);
+ subnet->set("pools", pools);
+
+ // Add the subnet.
+ subnets->add(subnet);
+ EXPECT_NO_THROW_LOG(translator_->setSubnets(xpath, subnets));
+
+ // Get it back.
+ subnets.reset();
+ EXPECT_NO_THROW_LOG(subnets = translator_->getSubnetsFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(subnets);
+ ASSERT_EQ(Element::list, subnets->getType());
+ ASSERT_EQ(1, subnets->size());
+ EXPECT_TRUE(subnet->equals(*subnets->get(0)));
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/translator_unittests.cc b/src/lib/yang/tests/translator_unittests.cc
new file mode 100644
index 0000000..8532419
--- /dev/null
+++ b/src/lib/yang/tests/translator_unittests.cc
@@ -0,0 +1,892 @@
+// 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 <gtest/gtest.h>
+
+#include <testutils/gtest_utils.h>
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/translator.h>
+
+using namespace std;
+using namespace isc;
+using namespace isc::data;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace libyang;
+using namespace sysrepo;
+
+struct TranslatorTest : ::testing::Test {
+ void SetUp() override {
+ SysrepoSetup::cleanSharedMemory();
+ cleanUp();
+ }
+
+ void TearDown() override {
+ cleanUp();
+ SysrepoSetup::cleanSharedMemory();
+ }
+
+private:
+ void cleanUp() {
+ Session session(sysrepo::Connection{}.sessionStart());
+ session.switchDatastore(sysrepo::Datastore::Candidate);
+ session.deleteItem("/keatest-module:container");
+ session.deleteItem("/keatest-module:kernel-modules");
+ session.deleteItem("/keatest-module:list");
+ session.deleteItem("/keatest-module:main");
+ session.deleteItem("/keatest-module:presence-container");
+ session.applyChanges();
+ }
+}; // TranslatorTest
+
+namespace {
+
+// Test constructor.
+TEST_F(TranslatorTest, constructor) {
+ // Get a session.
+ Session sess(Connection{}.sessionStart());
+ sess.switchDatastore(sysrepo::Datastore::Candidate);
+ // Get a translator object.
+ unique_ptr<Translator> translator;
+ EXPECT_NO_THROW_LOG(translator.reset(new Translator(sess, "")));
+}
+
+// Test basic YANG to JSON value conversion using sysrepo test models.
+TEST_F(TranslatorTest, getItem) {
+ // Get a translator object to play with.
+ Session sess(Connection{}.sessionStart());
+ sess.switchDatastore(sysrepo::Datastore::Candidate);
+ unique_ptr<Translator> translator;
+ ASSERT_NO_THROW_LOG(translator.reset(new Translator(sess, "")));
+ string value;
+ ConstElementPtr element;
+ string xpath;
+
+ // String.
+ xpath = "/keatest-module:main/string";
+ value = "str";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ("str", element->stringValue());
+ element.reset();
+
+ // Bool.
+ xpath = "/keatest-module:main/boolean";
+ value = "true";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::boolean, element->getType());
+ EXPECT_TRUE(element->boolValue());
+ element.reset();
+
+ // Unsigned 8 bit integer.
+ xpath = "/keatest-module:main/ui8";
+ uint8_t u8(8);
+ value = to_string(u8);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::integer, element->getType());
+ EXPECT_EQ(8, element->intValue());
+ element.reset();
+
+ // Unsigned 16 bit integer.
+ xpath = "/keatest-module:main/ui16";
+ uint16_t u16(16);
+ value = to_string(u16);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::integer, element->getType());
+ EXPECT_EQ(16, element->intValue());
+ element.reset();
+
+ // Unsigned 32 bit integer.
+ xpath = "/keatest-module:main/ui32";
+ uint32_t u32(32);
+ value = to_string(u32);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::integer, element->getType());
+ EXPECT_EQ(32, element->intValue());
+ element.reset();
+
+ // Unsigned 64 bit integer.
+ xpath = "/keatest-module:main/ui64";
+ uint64_t u64(64);
+ value = to_string(u64);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::integer, element->getType());
+ EXPECT_EQ(64, element->intValue());
+ element.reset();
+
+ // Empty.
+ xpath = "/keatest-module:main/empty";
+ value = string();
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ(string(), element->stringValue());
+ element.reset();
+
+ // Signed 8 bit integer.
+ xpath = "/keatest-module:main/i8";
+ int8_t s8(8);
+ value = to_string(s8);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::integer, element->getType());
+ EXPECT_EQ(8, element->intValue());
+ element.reset();
+
+ // Signed 16 bit integer.
+ xpath = "/keatest-module:main/i16";
+ int16_t s16(16);
+ value = to_string(s16);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::integer, element->getType());
+ EXPECT_EQ(16, element->intValue());
+ element.reset();
+
+ // Signed 32 bit integer.
+ xpath = "/keatest-module:main/i32";
+ int32_t s32(32);
+ value = to_string(s32);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::integer, element->getType());
+ EXPECT_EQ(32, element->intValue());
+ element.reset();
+
+ // Signed 64 bit integer.
+ xpath = "/keatest-module:main/i64";
+ int64_t s64(64);
+ value = to_string(s64);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::integer, element->getType());
+ EXPECT_EQ(64, element->intValue());
+ element.reset();
+
+ // Identity reference.
+ xpath = "/keatest-module:main/id_ref";
+ value = "keatest-module:id_1";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ("keatest-module:id_1", element->stringValue());
+ element.reset();
+
+ // Enumeration item.
+ xpath = "/keatest-module:main/enum";
+ value = "maybe";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ("maybe", element->stringValue());
+ element.reset();
+
+ // Bits.
+ xpath = "/keatest-module:main/options";
+ value = "strict recursive logging";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ("strict recursive logging", element->stringValue());
+ element.reset();
+
+ // Binary.
+ xpath = "/keatest-module:main/raw";
+ value = "Zm9vYmFy";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ("foobar", element->stringValue());
+ element.reset();
+
+ // Leaf-list: not yet exist.
+ xpath = "/keatest-module:main/numbers";
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(element);
+ element.reset();
+
+ // No easy way to create it empty.
+
+ // Leaf-list: 1, 2 and 3.
+ u8 = 1;
+ value = to_string(u8);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ u8 = 2;
+ value = to_string(u8);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ u8 = 3;
+ value = to_string(u8);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::list, element->getType());
+ EXPECT_EQ(3, element->size());
+ EXPECT_EQ("[ 1, 2, 3 ]", element->str());
+ element.reset();
+
+ // Instance identifier.
+ xpath = "/keatest-module:main/instance_id";
+ value = "/keatest-module:main/numbers[.='1']";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ(value, element->stringValue());
+ element.reset();
+
+ // Union.
+ xpath = "/keatest-module:main/union";
+ value = "8";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ(value, element->stringValue());
+ element.reset();
+ value = "infinity";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ(value, element->stringValue());
+ element.reset();
+
+ // Leafref.
+ xpath = "/keatest-module:main/leafref-i8";
+ value = "9";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ(value, element->stringValue());
+ element.reset();
+
+ // Leafref.
+ xpath = "/keatest-module:main/leafref-raw";
+ value = "ff012345";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ(value, element->stringValue());
+ element.reset();
+
+ // Leafref.
+ xpath = "/keatest-module:main/leafref-string";
+ value = "string through leafref";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::string, element->getType());
+ EXPECT_EQ(value, element->stringValue());
+ element.reset();
+
+ // Decimal 64.
+ xpath = "/keatest-module:main/dec64";
+ value = to_string(9.85);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ sess.applyChanges();
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_TRUE(element);
+ ASSERT_EQ(Element::real, element->getType());
+ EXPECT_EQ("9.85", element->str());
+ element.reset();
+
+ // Not existing.
+ xpath = "/keatest-module:main/no_such_node";
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(element);
+ element.reset();
+
+ // Check error.
+ xpath = "null";
+ EXPECT_NO_THROW_LOG(element = translator->getItemFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(element);
+}
+
+// Check the Translator::deleteItem function.
+TEST_F(TranslatorTest, deleteItem) {
+ ElementPtr got;
+ string xpath;
+
+ // Get a translator object to play with.
+ Translator translator(Connection{}.sessionStart(), "keatest-module");
+
+ // Missing schema node
+ EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main/no_such_node"));
+
+ // Existing schema node, but no data
+ xpath = "/keatest-module:main/string";
+ EXPECT_NO_THROW_LOG(translator.deleteItem(xpath));
+ EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(got);
+ got.reset();
+
+ // Existing schema node, existing data
+ translator.setItem(xpath, Element::create("value"), LeafBaseType::String);
+ EXPECT_NO_THROW_LOG(translator.deleteItem(xpath));
+ EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(got);
+ got.reset();
+
+ // Container schema node, no data
+ EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main"));
+ EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(got);
+ got.reset();
+
+ // Container schema node, existing data
+ translator.setItem(xpath, Element::create("value"), LeafBaseType::String);
+ EXPECT_NO_THROW_LOG(translator.deleteItem("/keatest-module:main"));
+ EXPECT_NO_THROW_LOG(got = translator.getItemFromAbsoluteXpath(xpath));
+ EXPECT_FALSE(got);
+ got.reset();
+}
+
+// Test JSON to basic YANG value conversion using the static method.
+TEST_F(TranslatorTest, valueTo) {
+ optional<string> value;
+
+ // Null.
+ ConstElementPtr element;
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::String));
+ EXPECT_EQ(nullopt, value);
+ EXPECT_FALSE(element);
+
+ // Container.
+ element = Element::createMap();
+ EXPECT_THROW_MSG(Translator::translateToYang(element, LeafBaseType::Unknown), NotImplemented,
+ "Translator::value(): map element");
+
+ // List.
+ element = Element::createList();
+ EXPECT_THROW_MSG(Translator::translateToYang(element, LeafBaseType::Unknown), NotImplemented,
+ "Translator::value(): list element");
+
+ // String.
+ string str("foo");
+ element = Element::create(str);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::String));
+ EXPECT_EQ(element->stringValue(), value);
+
+ // Bool.
+ element = Element::create(false);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Bool));
+ EXPECT_EQ(element->str(), value);
+
+ // Unsigned 8 bit integer.
+ element = Element::create(123);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Uint8));
+ EXPECT_EQ(element->str(), value);
+ element.reset();
+
+ // Unsigned 16 bit integer.
+ element = Element::create(12345);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Uint16));
+ EXPECT_EQ(element->str(), value);
+ element.reset();
+
+ // Unsigned 32 bit integer.
+ element = Element::create(123456789);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Uint32));
+ EXPECT_EQ(element->str(), value);
+ element.reset();
+
+ // Unsigned 64 bit integer.
+ element = Element::create(int64_t(1234567890123456));
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Uint64));
+ EXPECT_EQ("1234567890123456", value);
+ element.reset();
+
+ // Signed 8 bit integer.
+ element = Element::create(-123);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int8));
+ EXPECT_EQ(element->str(), value);
+ element.reset();
+
+ // Signed 16 bit integer.
+ element = Element::create(-12345);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int16));
+ EXPECT_EQ(element->str(), value);
+ element.reset();
+
+ // Signed 32 bit integer.
+ element = Element::create(-123456789);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int32));
+ EXPECT_EQ(element->str(), value);
+ element.reset();
+
+ // Signed 64 bit integer.
+ element = Element::create(int64_t(-1234567890123456));
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Int64));
+ EXPECT_EQ("-1234567890123456", value);
+ element.reset();
+
+ // Identity reference.
+ element = Element::create(str);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::IdentityRef));
+ EXPECT_EQ(element->stringValue(), value);
+
+ // Enumeration item.
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Enum));
+ EXPECT_EQ(element->stringValue(), value);
+
+ // Binary.
+ element = Element::create("foobar");
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Binary));
+ EXPECT_EQ("Zm9vYmFy", value);
+
+ // Bits.
+ element = Element::create("foobar");
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Bits));
+ EXPECT_EQ(element->stringValue(), value);
+
+ // Decimal 64.
+ double d64(.1234);
+ element = Element::create(d64);
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Dec64));
+ EXPECT_EQ(element->str(), value);
+
+ // Empty.
+ element = Element::create(string());
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Empty));
+ EXPECT_EQ(element->stringValue(), value);
+
+ // Leafref.
+ element = Element::create("leafref");
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Leafref));
+ EXPECT_EQ(element->stringValue(), value);
+
+ // Union.
+ element = Element::create("union");
+ EXPECT_NO_THROW_LOG(value = Translator::translateToYang(element, LeafBaseType::Union));
+ EXPECT_EQ(element->stringValue(), value);
+}
+
+// Test JSON to basic YANG value conversion using sysrepo test models.
+TEST_F(TranslatorTest, setItem) {
+ // Get a translator object to play with.
+ Session sess(Connection{}.sessionStart());
+ sess.switchDatastore(sysrepo::Datastore::Candidate);
+ unique_ptr<Translator> translator;
+ ASSERT_NO_THROW_LOG(translator.reset(new Translator(sess, "keatest-module")));
+
+ ElementPtr element;
+ string xpath;
+
+ // String.
+ optional<DataNode> data_node;
+ xpath = "/keatest-module:main/string";
+ element = Element::create("str");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::String));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::String, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Bool.
+ xpath = "/keatest-module:main/boolean";
+ element = Element::create(true);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Bool));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Bool, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Unsigned 8 bit integer.
+ xpath = "/keatest-module:main/ui8";
+ element = Element::create(8);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Uint8));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Uint8, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Unsigned 16 bit integer.
+ xpath = "/keatest-module:main/ui16";
+ element = Element::create(16);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Uint16));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Uint16, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Unsigned 32 bit integer.
+ xpath = "/keatest-module:main/ui32";
+ element = Element::create(32);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Uint32));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Uint32, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Unsigned 64 bit integer.
+ xpath = "/keatest-module:main/ui64";
+ element = Element::create(64);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Uint64));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Uint64, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Empty.
+ xpath = "/keatest-module:main/empty";
+ element = Element::create(string());
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Empty));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Empty, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Signed 8 bit integer.
+ xpath = "/keatest-module:main/i8";
+ element = Element::create(8);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Int8));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Int8, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Signed 16 bit integer.
+ xpath = "/keatest-module:main/i16";
+ element = Element::create(16);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Int16));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Int16, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Signed 32 bit integer.
+ xpath = "/keatest-module:main/i32";
+ element = Element::create(32);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Int32));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Int32, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Signed 64 bit integer.
+ xpath = "/keatest-module:main/i64";
+ element = Element::create(64);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Int64));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Int64, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Identity reference.
+ xpath = "/keatest-module:main/id_ref";
+ element = Element::create("keatest-module:id_1");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::IdentityRef));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::IdentityRef, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Enumeration item.
+ xpath = "/keatest-module:main/enum";
+ element = Element::create("maybe");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Enum));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Enum, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Binary.
+ xpath = "/keatest-module:main/raw";
+ element = Element::create("foobar");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Binary));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Binary, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ("Zm9vYmFy", string(data_node->asTerm().valueStr()));
+
+ // Bits.
+ xpath = "/keatest-module:main/options";
+ element = Element::create("strict recursive logging");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Bits));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Bits, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Decimal 64.
+ xpath = "/keatest-module:main/dec64";
+ double d64(9.85);
+ element = Element::create(d64);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Dec64));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Dec64, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->str(), string(data_node->asTerm().valueStr()));
+
+ // Leaf-list.
+ xpath = "/keatest-module:main/numbers";
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, Element::fromJSON("1"), LeafBaseType::Uint8));
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, Element::fromJSON("2"), LeafBaseType::Uint8));
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, Element::fromJSON("3"), LeafBaseType::Uint8));
+ ElementPtr got(translator->getItemFromAbsoluteXpath(xpath));
+ ASSERT_EQ(LeafBaseType::Dec64, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ("[ 1, 2, 3 ]", got->str());
+
+ // Clean the leaf-list.
+ EXPECT_NO_THROW_LOG(translator->deleteItem(xpath));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ EXPECT_FALSE(data_node);
+ data_node.reset();
+
+ // Instance identifier.
+ xpath = "/keatest-module:main/instance_id";
+ element = Element::create("/keatest-module:main/numbers[.='1']");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::InstanceIdentifier));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::InstanceIdentifier, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Union.
+ xpath = "/keatest-module:main/union";
+ element = Element::create("8");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Union));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Union, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+ element = Element::create("infinity");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Union));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Union, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Leafref.
+ xpath = "/keatest-module:main/leafref-i8";
+ element = Element::create("9");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Leafref));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Leafref, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Leafref.
+ xpath = "/keatest-module:main/leafref-raw";
+ element = Element::create("ff012345");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Leafref));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Leafref, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Leafref.
+ xpath = "/keatest-module:main/leafref-string";
+ element = Element::create("string through");
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Leafref));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ ASSERT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ ASSERT_TRUE(data_node);
+ ASSERT_EQ(LeafBaseType::Leafref, data_node->schema().asLeaf().valueType().base());
+ EXPECT_EQ(element->stringValue(), string(data_node->asTerm().valueStr()));
+
+ // Bad xpath.
+ xpath = "/keatest-module:main/no_such_node";
+ element = Element::create("str");
+ EXPECT_THROW_MSG(translator->setItem(xpath, element, LeafBaseType::String), NetconfError,
+ "setting item '\"str\"' at '" + xpath +
+ "': Session::setItem: Couldn't set "
+ "'/keatest-module:main/no_such_node' to 'str': SR_ERR_INVAL_ARG");
+
+ // Bad type.
+ xpath = "/keatest-module:main/string";
+ element = Element::create(true);
+ EXPECT_NO_THROW_LOG(translator->setItem(xpath, element, LeafBaseType::Bool));
+
+ element = translator->getItemFromAbsoluteXpath(xpath);
+ ASSERT_TRUE(element);
+ EXPECT_EQ(element->getType(), Element::string);
+ EXPECT_EQ(element->str(), "\"true\"");
+
+ // Delete (twice).
+ xpath = "/keatest-module:main/string";
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ EXPECT_TRUE(data_node);
+ EXPECT_NO_THROW_LOG(data_node = data_node->findPath(xpath));
+ EXPECT_TRUE(data_node);
+ ASSERT_TRUE(NodeType::Leaf == data_node->schema().nodeType());
+ EXPECT_EQ("true", data_node->asTerm().valueStr());
+ EXPECT_NO_THROW_LOG(translator->deleteItem(xpath));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ EXPECT_FALSE(data_node);
+ EXPECT_NO_THROW_LOG(translator->deleteItem(xpath));
+ EXPECT_NO_THROW_LOG(data_node = sess.getData(xpath));
+ EXPECT_FALSE(data_node);
+}
+
+// Test YANG container retrieval.
+TEST_F(TranslatorTest, container) {
+ ElementPtr element;
+
+ // Get a translator object to play with.
+ Translator translator(Connection{}.sessionStart(), "keatest-module");
+
+ // Container with no data apparently throws.
+ EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented,
+ "getting node of type 1 not supported, xpath is '/keatest-module:container'");
+ EXPECT_FALSE(element);
+ element.reset();
+
+ EXPECT_NO_THROW_LOG(
+ translator.setItem("/keatest-module:container",
+ ElementPtr(), LeafBaseType::Unknown));
+
+ // Container with data filled in throws when retrieving the container itself.
+ element = Element::create("Leaf value");
+ EXPECT_NO_THROW_LOG(
+ translator.setItem("/keatest-module:container/list[key1='key1'][key2='key2']/leaf",
+ element, LeafBaseType::String));
+ element.reset();
+ EXPECT_THROW_MSG(
+ element = translator.getItemFromAbsoluteXpath("/keatest-module:container"), NotImplemented,
+ "getting node of type 1 not supported, xpath is '/keatest-module:container'");
+ EXPECT_FALSE(element);
+ element.reset();
+ EXPECT_NO_THROW_LOG(
+ element = translator.getItemFromAbsoluteXpath("/keatest-module:container[key1='key1'][key2='key2']"));
+ EXPECT_FALSE(element);
+}
+
+// Test YANG list retrieval.
+TEST_F(TranslatorTest, list) {
+ ElementPtr element;
+
+ // Get a translator to play with.
+ Translator translator(Connection{}.sessionStart(), "keatest-module");
+
+ // List with no data does not throw and returns a null ElementPtr by default.
+ EXPECT_NO_THROW_LOG(
+ element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"));
+ EXPECT_FALSE(element);
+ element.reset();
+
+ // List with data filled in throws when retrieving the list itself.
+ element = Element::create("Leaf value");
+ EXPECT_NO_THROW_LOG(
+ translator.setItem("/keatest-module:container/list[key1='key1'][key2='key2']/leaf", element,
+ LeafBaseType::String));
+ element.reset();
+ EXPECT_THROW_MSG(
+ element = translator.getItemFromAbsoluteXpath("/keatest-module:container/list"), NotImplemented,
+ "getting node of type 16 not supported, xpath is '/keatest-module:container/list'");
+ EXPECT_FALSE(element);
+ element.reset();
+ EXPECT_THROW_MSG(element = translator.getItemFromAbsoluteXpath(
+ "/keatest-module:container/list[key1='key1'][key2='key2']"), NotImplemented,
+ "getting node of type 16 not supported, xpath is "
+ "'/keatest-module:container/list[key1='key1'][key2='key2']'");
+ EXPECT_FALSE(element);
+}
+
+// Test that we can check if a schema node exists.
+TEST_F(TranslatorTest, schemaNodeExists) {
+ // Get a translator to play with.
+ Translator translator(Connection{}.sessionStart(), "keatest-module");
+
+ EXPECT_FALSE(translator.schemaNodeExists("/keatest-module:main/no_such_node"));
+ EXPECT_TRUE(translator.schemaNodeExists("/keatest-module:main"));
+ EXPECT_TRUE(translator.schemaNodeExists("/keatest-module:main/string"));
+ EXPECT_TRUE(translator.schemaNodeExists("/keatest-module:container/list"));
+}
+
+} // anonymous namespace
diff --git a/src/lib/yang/tests/translator_utils_unittests.cc b/src/lib/yang/tests/translator_utils_unittests.cc
new file mode 100644
index 0000000..ddd4cb9
--- /dev/null
+++ b/src/lib/yang/tests/translator_utils_unittests.cc
@@ -0,0 +1,288 @@
+// 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 <gtest/gtest.h>
+
+#include <testutils/gtest_utils.h>
+#include <yang/testutils/translator_test.h>
+#include <yang/tests/sysrepo_setup.h>
+#include <yang/tests/yang_configs.h>
+
+#include <sstream>
+
+using namespace std;
+using namespace isc;
+using namespace isc::yang;
+using namespace isc::yang::test;
+using namespace libyang;
+using namespace sysrepo;
+
+namespace {
+
+// Test LeafBaseType print.
+TEST(YangReprTest, type) {
+ ostringstream os;
+
+ // Verify that string is "string" (vs a number).
+ LeafBaseType t(LeafBaseType::String);
+ os << t;
+ EXPECT_EQ("string", os.str());
+ os.str("");
+
+ // Compiler does not let to create an invalid value...
+}
+
+// Test YangReprItem basic stuff.
+TEST(YangReprTest, item) {
+ // An item.
+ YRItem item1("/foo", "bar", LeafBaseType::String, true);
+ EXPECT_EQ("/foo", item1.xpath_);
+ EXPECT_EQ("bar", item1.value_);
+ EXPECT_TRUE(item1.settable_);
+
+ // EXPECT_EQ doesn't work. Tries to << into a stringstream.
+ EXPECT_TRUE(LeafBaseType::String == item1.type_);
+
+ // Another one.
+ YRItem item2("/foo", "bar", LeafBaseType::String, false);
+ EXPECT_EQ("/foo", item2.xpath_);
+ EXPECT_EQ("bar", item2.value_);
+ EXPECT_FALSE(item2.settable_);
+
+ // EXPECT_EQ doesn't work. Tries to << into a stringstream.
+ EXPECT_TRUE(LeafBaseType::String == item2.type_);
+
+ // Equality.
+ EXPECT_TRUE(item1 == item2);
+ EXPECT_TRUE(item2 == item1);
+ EXPECT_FALSE(item1 != item2);
+ EXPECT_FALSE(item2 != item1);
+ EXPECT_EQ(item1, item2);
+ EXPECT_EQ(item2, item1);
+}
+
+// Test get with test module.
+TEST(YangReprTest, getTest) {
+ SysrepoSetup::cleanSharedMemory();
+
+ // Get a translator object to play with.
+ Session sess(Connection{}.sessionStart());
+ sess.switchDatastore(sysrepo::Datastore::Candidate);
+
+ // Cleanup.
+ EXPECT_NO_THROW_LOG(sess.deleteItem("/keatest-module:container"));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+ EXPECT_NO_THROW_LOG(sess.deleteItem("/keatest-module:main"));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ // Fill the test module.
+ string xpath;
+ string value;
+
+ xpath = "/keatest-module:main/string";
+ value = "str";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/boolean";
+ value = "true";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/ui8";
+ uint8_t u8(8);
+ value = to_string(u8);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/ui16";
+ uint16_t u16(16);
+ value = to_string(u16);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/ui32";
+ uint32_t u32(32);
+ value = to_string(u32);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/ui64";
+ uint64_t u64(64);
+ value = to_string(u64);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/i8";
+ int8_t s8(8);
+ value = to_string(s8);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/i16";
+ int16_t s16(16);
+ value = to_string(s16);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/i32";
+ int32_t s32(32);
+ value = to_string(s32);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/i64";
+ int64_t s64(64);
+ value = to_string(s64);
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/id_ref";
+ value = "keatest-module:id_1";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ xpath = "/keatest-module:main/enum";
+ value = "maybe";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ // Binary.
+ xpath = "/keatest-module:main/raw";
+ value = "Zm9vYmFy";
+ EXPECT_NO_THROW_LOG(sess.setItem(xpath, value));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ // Get it.
+ YangRepr repr(testModel);
+ YRTree tree;
+ EXPECT_NO_THROW_LOG(tree = repr.get(sess));
+
+ // Verify.
+ EXPECT_TRUE(repr.verify(testTree, sess, cerr));
+}
+
+// This test verifies that errors are handled properly.
+TEST(YangReprTrest, getTestErrors) {
+ SysrepoSetup::cleanSharedMemory();
+
+ // Get a translator object to play with.
+ Session sess(Connection{}.sessionStart());
+ sess.switchDatastore(sysrepo::Datastore::Candidate);
+
+ // Cleanup.
+ EXPECT_NO_THROW_LOG(sess.deleteItem("/keatest-module:container"));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+ EXPECT_NO_THROW_LOG(sess.deleteItem("/keatest-module:main"));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ // Get it.
+ YangRepr repr(testModel);
+ YRTree tree;
+ EXPECT_NO_THROW_LOG(repr.set(testTree, sess));
+
+ // Verify.
+ EXPECT_TRUE(repr.verify(testTree, sess, cerr));
+
+ // Change a path. Remove final 'm'.
+ YRTree badpath = testTree;
+ string xpath("/keatest-module:main/enum");
+ YRItem node(badpath.at(xpath));
+ node.xpath_ = "/keatest-module:main/enu";
+ badpath.erase(xpath);
+ badpath.emplace(xpath, node);
+ EXPECT_FALSE(repr.verify(badpath, sess, cerr));
+
+ // Change a value from "str" to "Str".
+ YRTree badvalue = testTree;
+ xpath = "/keatest-module:main/string";
+ badvalue.at(xpath).value_ = "Str";
+ EXPECT_FALSE(repr.verify(badvalue, sess, cerr));
+
+ // Change a type from LeafBaseType::Int32 to LeafBaseType::Uint32.
+ YRTree badtype = testTree;
+ xpath = "/keatest-module:main/i32";
+ badtype.at(xpath).type_ = LeafBaseType::Uint32;
+ EXPECT_FALSE(repr.verify(badtype, sess, cerr));
+
+ // Delete last record.
+ YRTree badextra = testTree;
+ badextra.erase("/keatest-module:kernel-modules");
+ EXPECT_FALSE(repr.verify(badextra, sess, cerr));
+}
+
+// Test set with test module.
+TEST(YangReprTest, setTest) {
+ SysrepoSetup::cleanSharedMemory();
+
+ // Get a translator object to play with.
+ Session sess(Connection{}.sessionStart());
+ sess.switchDatastore(sysrepo::Datastore::Candidate);
+
+ // Cleanup.
+ EXPECT_NO_THROW_LOG(sess.deleteItem("/keatest-module:container"));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+ EXPECT_NO_THROW_LOG(sess.deleteItem("/keatest-module:main"));
+ EXPECT_NO_THROW_LOG(sess.applyChanges());
+
+ // Set the module content.
+ YangRepr repr(testModel);
+ EXPECT_NO_THROW_LOG(repr.set(testTree, sess));
+
+ // Verify it.
+ EXPECT_TRUE(repr.verify(testTree, sess, cerr));
+}
+
+/// @brief Tests specified configuration.
+///
+/// Configuration is set and then verified using YangRepr object.
+///
+/// @param model name of the model to be verified against.
+/// @param tree tree to be verified.
+void sanityCheckConfig(const string& model, const YRTree& tree) {
+ SCOPED_TRACE("\n* Tested model: " + model);
+ SysrepoSetup::cleanSharedMemory();
+
+ // Get a translator object to play with.
+ Session sess(Connection{}.sessionStart());
+ sess.switchDatastore(sysrepo::Datastore::Candidate);
+
+ // Cleanup.
+ Translator translator(sess, model);
+ if (model == "keatest-module") {
+ translator.deleteItem("/keatest-module:container");
+ translator.deleteItem("/keatest-module:kernel-modules");
+ translator.deleteItem("/keatest-module:list");
+ translator.deleteItem("/keatest-module:main");
+ translator.deleteItem("/keatest-module:presence-container");
+ } else {
+ string toplevel_node("config");
+ if (model == IETF_DHCPV6_SERVER) {
+ toplevel_node = "server";
+ }
+ EXPECT_NO_THROW_LOG(translator.deleteItem("/" + model + ":" + toplevel_node));
+ }
+
+ // Get it.
+ YangRepr repr(model);
+
+ EXPECT_NO_THROW_LOG(repr.set(tree, sess));
+ bool result = false;
+ EXPECT_NO_THROW_LOG(result = repr.verify(tree, sess, cerr));
+ EXPECT_TRUE(result);
+}
+
+// This is test environment sanity check. It verifies that all configuration
+// defined in yang_configs.h are sane.
+TEST(YangReprTest, verifyConfigs) {
+ for (auto x : TEST_CONFIGS) {
+ sanityCheckConfig(x.first, x.second);
+ }
+}
+
+} // namespace
diff --git a/src/lib/yang/tests/yang_configs.h b/src/lib/yang/tests/yang_configs.h
new file mode 100644
index 0000000..d3825c9
--- /dev/null
+++ b/src/lib/yang/tests/yang_configs.h
@@ -0,0 +1,655 @@
+// Copyright (C) 2018-2023 Internet Systems Consortium, Inc. ("ISC")
+//
+// This Source Code Form is subject to the terms of the Mozilla Public
+// License, v. 2.0. If a copy of the MPL was not distributed with this
+// file, You can obtain one at http://mozilla.org/MPL/2.0/.
+
+#ifndef ISC_YANG_CONFIGS_H
+#define ISC_YANG_CONFIGS_H
+
+#include <yang/testutils/translator_test.h>
+#include <yang/yang_models.h>
+
+#include <vector>
+
+namespace isc {
+namespace yang {
+namespace test {
+
+/// @brief The test module from sysrepo tests.
+const std::string testModel = "keatest-module";
+const YRTree testTree = YangRepr::buildTreeFromVector({
+ { "/keatest-module:container",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/keatest-module:main",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/keatest-module:main/string",
+ "str", libyang::LeafBaseType::String, true },
+ { "/keatest-module:main/boolean",
+ "true", libyang::LeafBaseType::Bool, true },
+ { "/keatest-module:main/ui8",
+ "8", libyang::LeafBaseType::Uint8, true },
+ { "/keatest-module:main/ui16",
+ "16", libyang::LeafBaseType::Uint16, true },
+ { "/keatest-module:main/ui32",
+ "32", libyang::LeafBaseType::Uint32, true },
+ { "/keatest-module:main/ui64",
+ "64", libyang::LeafBaseType::Uint64, true },
+ { "/keatest-module:main/i8",
+ "8", libyang::LeafBaseType::Int8, true },
+ { "/keatest-module:main/i16",
+ "16", libyang::LeafBaseType::Int16, true },
+ { "/keatest-module:main/i32",
+ "32", libyang::LeafBaseType::Int32, true },
+ { "/keatest-module:main/i64",
+ "64", libyang::LeafBaseType::Int64, true },
+ { "/keatest-module:main/id_ref",
+ "keatest-module:id_1", libyang::LeafBaseType::IdentityRef, true },
+ { "/keatest-module:main/enum",
+ "maybe", libyang::LeafBaseType::Enum, true },
+ { "/keatest-module:main/raw",
+ "Zm9vYmFy", libyang::LeafBaseType::Binary, true },
+ { "/keatest-module:kernel-modules",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+/// @brief A subnet with two pools with ietf-dhcpv6-server model.
+const std::string subnetTwoPoolsModelIetf6 = IETF_DHCPV6_SERVER;
+const YRTree subnetTwoPoolsTreeIetf6 = YangRepr::buildTreeFromVector({
+ { "/ietf-dhcpv6-server:server",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/network-range-id",
+ "111", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/network-prefix",
+ "2001:db8::/48", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/pool-id",
+ "0", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/pool-prefix",
+ "2001:db8::1:0/112", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/start-address",
+ "2001:db8::1:0", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/end-address",
+ "2001:db8::1:ffff", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/max-address-count",
+ "disabled", libyang::LeafBaseType::Enum, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/pool-id",
+ "1", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/pool-prefix",
+ "2001:db8::2:0/112", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/start-address",
+ "2001:db8::2:0", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/end-address",
+ "2001:db8::2:ffff", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/max-address-count",
+ "disabled", libyang::LeafBaseType::Enum, true },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid/type-code",
+ "65535", libyang::LeafBaseType::Uint16, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/host-reservations",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/lease-storage",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/option-sets",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/relay-opaque-paras",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/rsoo-enabled-options",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+/// @brief A subnet with timers with ietf-dhcpv6-server model.
+const std::string subnetTimersModel = IETF_DHCPV6_SERVER;
+const YRTree subnetTimersIetf6 = YangRepr::buildTreeFromVector({
+ { "/ietf-dhcpv6-server:server",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/network-range-id",
+ "111", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/network-prefix",
+ "2001:db8::/48", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/pool-id",
+ "0", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/pool-prefix",
+ "2001:db8::1:0/112", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/start-address",
+ "2001:db8::1:0", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/end-address",
+ "2001:db8::1:ffff", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/renew-time",
+ "1000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/rebind-time",
+ "2000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='0']/max-address-count",
+ "disabled", libyang::LeafBaseType::Enum, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/pool-id",
+ "1", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/pool-prefix",
+ "2001:db8::2:0/112", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/start-address",
+ "2001:db8::2:0", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/end-address",
+ "2001:db8::2:ffff", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/renew-time",
+ "1000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/rebind-time",
+ "2000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools/"
+ "address-pool[pool-id='1']/max-address-count",
+ "disabled", libyang::LeafBaseType::Enum, true },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid/type-code",
+ "65535", libyang::LeafBaseType::Uint16, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/host-reservations",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/lease-storage",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/option-sets",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/relay-opaque-paras",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/rsoo-enabled-options",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+/// @brief A subnet with two pools with ietf-dhcpv6-server model
+/// which validates.
+const std::string validModelIetf6 = IETF_DHCPV6_SERVER;
+const YRTree validTreeIetf6 = YangRepr::buildTreeFromVector({
+ { "/ietf-dhcpv6-server:server",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes"
+ "/vendor-info/ent-num",
+ "2495", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/option-sets",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/network-range-id",
+ "111", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/network-description",
+ "Subnet#111", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/network-prefix",
+ "2001:db8::/48", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/pool-id",
+ "0", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/prefix",
+ "2001:db8:1::/48", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/prefix-length",
+ "48", libyang::LeafBaseType::Uint8, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/valid-lifetime",
+ "4000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/preferred-lifetime",
+ "3000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/renew-time",
+ "1000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/rebind-time",
+ "2000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/rapid-commit",
+ "false", libyang::LeafBaseType::Bool, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/option-set-id",
+ "0", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='0']/max-pd-space-utilization",
+ "disabled", libyang::LeafBaseType::Enum, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/pool-id",
+ "1", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/prefix",
+ "2001:db8:2::/48", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/prefix-length",
+ "48", libyang::LeafBaseType::Uint8, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/valid-lifetime",
+ "4000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/preferred-lifetime",
+ "3000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/renew-time",
+ "1000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/rebind-time",
+ "2000", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/rapid-commit",
+ "false", libyang::LeafBaseType::Bool, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/option-set-id",
+ "0", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools/"
+ "pd-pool[pool-id='1']/max-pd-space-utilization",
+ "disabled", libyang::LeafBaseType::Enum, true },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid/type-code",
+ "65535", libyang::LeafBaseType::Uint16, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/address-pools",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/pd-pools",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='111']/host-reservations",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/lease-storage",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/relay-opaque-paras",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/rsoo-enabled-options",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+/// @brief A subnet with a pool and option data lists with
+/// kea-dhcp4-server:config model.
+const std::string subnetOptionsModelKeaDhcp4 = KEA_DHCP4_SERVER;
+const YRTree subnetOptionsTreeKeaDhcp4 = YangRepr::buildTreeFromVector({
+ { "/kea-dhcp4-server:config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/id",
+ "111", libyang::LeafBaseType::Uint32, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "option-data[code='100'][space='dns']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "option-data[code='100'][space='dns']/code",
+ "100", libyang::LeafBaseType::Uint8, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "option-data[code='100'][space='dns']/space",
+ "dns", libyang::LeafBaseType::String, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "option-data[code='100'][space='dns']/data",
+ "12121212", libyang::LeafBaseType::String, true },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "option-data[code='100'][space='dns']/csv-format",
+ "false", libyang::LeafBaseType::Bool, true },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "option-data[code='100'][space='dns']/always-send",
+ "false", libyang::LeafBaseType::Bool, true },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "option-data[code='100'][space='dns']/never-send",
+ "false", libyang::LeafBaseType::Bool, true },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "pool[start-address='10.0.1.0'][end-address='10.0.1.255']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "pool[start-address='10.0.1.0'][end-address='10.0.1.255']/start-address",
+ "10.0.1.0", libyang::LeafBaseType::String, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "pool[start-address='10.0.1.0'][end-address='10.0.1.255']/end-address",
+ "10.0.1.255", libyang::LeafBaseType::String, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/"
+ "pool[start-address='10.0.1.0'][end-address='10.0.1.255']/prefix",
+ "10.0.1.0/24", libyang::LeafBaseType::String, true },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/subnet",
+ "10.0.0.0/8", libyang::LeafBaseType::String, true },
+ { "/kea-dhcp4-server:config/expired-leases-processing",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/dhcp-ddns",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/config-control",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/sanity-checks",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/interfaces-config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/subnet4[id='111']/relay",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/compatibility",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/multi-threading",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+/// @brief A subnet with a pool and option data lists with
+/// kea-dhcp6-server:config model.
+const std::string subnetOptionsModelKeaDhcp6 = KEA_DHCP6_SERVER;
+const YRTree subnetOptionsTreeKeaDhcp6 = YangRepr::buildTreeFromVector({
+ { "/kea-dhcp6-server:config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/id",
+ "111", libyang::LeafBaseType::Uint32, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "start-address",
+ "2001:db8::1:0", libyang::LeafBaseType::String, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "end-address",
+ "2001:db8::1:ffff", libyang::LeafBaseType::String, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "prefix",
+ "2001:db8::1:0/112", libyang::LeafBaseType::String, true },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "option-data[code='100'][space='dns']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "option-data[code='100'][space='dns']/code",
+ "100", libyang::LeafBaseType::Uint16, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "option-data[code='100'][space='dns']/space",
+ "dns", libyang::LeafBaseType::String, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "option-data[code='100'][space='dns']/data",
+ "12121212", libyang::LeafBaseType::String, true },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "option-data[code='100'][space='dns']/csv-format",
+ "false", libyang::LeafBaseType::Bool, true },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "option-data[code='100'][space='dns']/always-send",
+ "false", libyang::LeafBaseType::Bool, true },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/"
+ "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']/"
+ "option-data[code='100'][space='dns']/never-send",
+ "false", libyang::LeafBaseType::Bool, true },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/subnet",
+ "2001:db8::/48", libyang::LeafBaseType::String, true },
+ { "/kea-dhcp6-server:config/expired-leases-processing",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/dhcp-ddns",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/config-control",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/sanity-checks",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/interfaces-config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/subnet6[id='111']/relay",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/compatibility",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/multi-threading",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+/// @brief Example from the design document.
+const std::string designExampleModel = IETF_DHCPV6_SERVER;
+const YRTree designExampleTree = YangRepr::buildTreeFromVector({
+ { "/ietf-dhcpv6-server:server",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/network-range-id",
+ "1", libyang::LeafBaseType::Uint32, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/network-description",
+ "example", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/pd-pools",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/pd-pools/pd-pool[pool-id='0']",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/pd-pools/pd-pool[pool-id='0']"
+ "/pool-id",
+ "0", libyang::LeafBaseType::Uint32, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/pd-pools/pd-pool[pool-id='0']"
+ "/prefix",
+ "2001:db8:20:b00::/57", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/pd-pools/pd-pool[pool-id='0']"
+ "/prefix-length",
+ "57", libyang::LeafBaseType::Uint8, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/pd-pools/"
+ "pd-pool[pool-id='0']/max-pd-space-utilization",
+ "disabled", libyang::LeafBaseType::Enum, true },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/network-prefix",
+ "2001:db8:20:b00::/56", libyang::LeafBaseType::String, true },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid/type-code",
+ "65535", libyang::LeafBaseType::Uint16, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/host-reservations",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/lease-storage",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/option-sets",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/relay-opaque-paras",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/rsoo-enabled-options",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/ietf-dhcpv6-server:server/server-config/network-ranges/"
+ "network-range[network-range-id='1']/address-pools",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+const YRTree emptyTreeKeaDhcp4 = YangRepr::buildTreeFromVector({
+ { "/kea-dhcp4-server:config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/expired-leases-processing",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/dhcp-ddns",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/config-control",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/sanity-checks",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/interfaces-config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/compatibility",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp4-server:config/multi-threading",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+const YRTree emptyTreeKeaDhcp6 = YangRepr::buildTreeFromVector({
+ { "/kea-dhcp6-server:config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/expired-leases-processing",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/dhcp-ddns",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/config-control",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/sanity-checks",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/interfaces-config",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/compatibility",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+ { "/kea-dhcp6-server:config/multi-threading",
+ std::nullopt, libyang::LeafBaseType::Unknown, false },
+});
+
+/// @brief Set of example configurations.
+const std::vector<std::pair<std::string, YRTree> > TEST_CONFIGS =
+{
+ { testModel, testTree },
+ { subnetTwoPoolsModelIetf6, subnetTwoPoolsTreeIetf6 },
+ { subnetTimersModel, subnetTimersIetf6 },
+ { validModelIetf6, validTreeIetf6 },
+ { subnetOptionsModelKeaDhcp4, subnetOptionsTreeKeaDhcp4 },
+ { subnetOptionsModelKeaDhcp6, subnetOptionsTreeKeaDhcp6 },
+ { designExampleModel, designExampleTree }
+}; // TEST_CONFIGS
+
+} // namespace test
+} // namespace yang
+} // namespace isc
+
+#endif // ISC_YANG_CONFIGS_H