From 040eee1aa49b49df4698d83a05af57c220127fd1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 4 May 2024 13:36:04 +0200 Subject: Adding upstream version 2.2.0. Signed-off-by: Daniel Baumann --- src/lib/yang/Makefile.am | 73 ++ src/lib/yang/Makefile.in | 1040 ++++++++++++++++ src/lib/yang/adaptor.cc | 308 +++++ src/lib/yang/adaptor.h | 133 ++ src/lib/yang/adaptor_config.cc | 658 ++++++++++ src/lib/yang/adaptor_config.h | 292 +++++ src/lib/yang/adaptor_host.cc | 68 ++ src/lib/yang/adaptor_host.h | 47 + src/lib/yang/adaptor_option.cc | 128 ++ src/lib/yang/adaptor_option.h | 111 ++ src/lib/yang/adaptor_pool.cc | 87 ++ src/lib/yang/adaptor_pool.h | 98 ++ src/lib/yang/adaptor_subnet.cc | 73 ++ src/lib/yang/adaptor_subnet.h | 66 + src/lib/yang/pretests/Makefile.am | 14 + src/lib/yang/pretests/Makefile.in | 823 +++++++++++++ src/lib/yang/pretests/sysrepo_setup_tests.cc | 126 ++ src/lib/yang/sysrepo_error.h | 26 + src/lib/yang/tests/Makefile.am | 60 + src/lib/yang/tests/Makefile.in | 1285 ++++++++++++++++++++ src/lib/yang/tests/adaptor_config_unittests.cc | 145 +++ src/lib/yang/tests/adaptor_host_unittests.cc | 119 ++ src/lib/yang/tests/adaptor_option_unittests.cc | 241 ++++ src/lib/yang/tests/adaptor_pool_unittests.cc | 274 +++++ src/lib/yang/tests/adaptor_subnet_unittests.cc | 213 ++++ src/lib/yang/tests/adaptor_unittests.cc | 394 ++++++ src/lib/yang/tests/config_unittests.cc | 417 +++++++ src/lib/yang/tests/json_configs.h | 174 +++ src/lib/yang/tests/run_unittests.cc | 20 + src/lib/yang/tests/sysrepo_setup.h | 99 ++ src/lib/yang/tests/translator_class_unittests.cc | 125 ++ .../tests/translator_control_socket_unittests.cc | 176 +++ .../yang/tests/translator_database_unittests.cc | 327 +++++ src/lib/yang/tests/translator_host_unittests.cc | 188 +++ src/lib/yang/tests/translator_logger_unittests.cc | 159 +++ .../yang/tests/translator_option_data_unittests.cc | 136 +++ .../yang/tests/translator_option_def_unittests.cc | 144 +++ src/lib/yang/tests/translator_pd_pool_unittests.cc | 290 +++++ src/lib/yang/tests/translator_pool_unittests.cc | 250 ++++ .../tests/translator_shared_network_unittests.cc | 209 ++++ src/lib/yang/tests/translator_subnet_unittests.cc | 379 ++++++ src/lib/yang/tests/translator_unittests.cc | 683 +++++++++++ src/lib/yang/tests/translator_utils_unittests.cc | 270 ++++ src/lib/yang/tests/yang_configs.h | 591 +++++++++ src/lib/yang/testutils/Makefile.am | 24 + src/lib/yang/testutils/Makefile.in | 840 +++++++++++++ src/lib/yang/testutils/translator_test.cc | 421 +++++++ src/lib/yang/testutils/translator_test.h | 159 +++ src/lib/yang/translator.cc | 318 +++++ src/lib/yang/translator.h | 177 +++ src/lib/yang/translator_class.cc | 245 ++++ src/lib/yang/translator_class.h | 169 +++ src/lib/yang/translator_config.cc | 770 ++++++++++++ src/lib/yang/translator_config.h | 548 +++++++++ src/lib/yang/translator_control_socket.cc | 111 ++ src/lib/yang/translator_control_socket.h | 120 ++ src/lib/yang/translator_database.cc | 204 ++++ src/lib/yang/translator_database.h | 205 ++++ src/lib/yang/translator_host.cc | 261 ++++ src/lib/yang/translator_host.h | 198 +++ src/lib/yang/translator_logger.cc | 261 ++++ src/lib/yang/translator_logger.h | 214 ++++ src/lib/yang/translator_option_data.cc | 197 +++ src/lib/yang/translator_option_data.h | 168 +++ src/lib/yang/translator_option_def.cc | 208 ++++ src/lib/yang/translator_option_def.h | 175 +++ src/lib/yang/translator_pd_pool.cc | 365 ++++++ src/lib/yang/translator_pd_pool.h | 230 ++++ src/lib/yang/translator_pool.cc | 359 ++++++ src/lib/yang/translator_pool.h | 249 ++++ src/lib/yang/translator_shared_network.cc | 422 +++++++ src/lib/yang/translator_shared_network.h | 260 ++++ src/lib/yang/translator_subnet.cc | 575 +++++++++ src/lib/yang/translator_subnet.h | 386 ++++++ src/lib/yang/yang.dox | 204 ++++ src/lib/yang/yang_models.h | 37 + src/lib/yang/yang_revisions.h | 35 + src/lib/yang/yang_revisions.h.skel | 27 + 78 files changed, 20681 insertions(+) create mode 100644 src/lib/yang/Makefile.am create mode 100644 src/lib/yang/Makefile.in create mode 100644 src/lib/yang/adaptor.cc create mode 100644 src/lib/yang/adaptor.h create mode 100644 src/lib/yang/adaptor_config.cc create mode 100644 src/lib/yang/adaptor_config.h create mode 100644 src/lib/yang/adaptor_host.cc create mode 100644 src/lib/yang/adaptor_host.h create mode 100644 src/lib/yang/adaptor_option.cc create mode 100644 src/lib/yang/adaptor_option.h create mode 100644 src/lib/yang/adaptor_pool.cc create mode 100644 src/lib/yang/adaptor_pool.h create mode 100644 src/lib/yang/adaptor_subnet.cc create mode 100644 src/lib/yang/adaptor_subnet.h create mode 100644 src/lib/yang/pretests/Makefile.am create mode 100644 src/lib/yang/pretests/Makefile.in create mode 100644 src/lib/yang/pretests/sysrepo_setup_tests.cc create mode 100644 src/lib/yang/sysrepo_error.h create mode 100644 src/lib/yang/tests/Makefile.am create mode 100644 src/lib/yang/tests/Makefile.in create mode 100644 src/lib/yang/tests/adaptor_config_unittests.cc create mode 100644 src/lib/yang/tests/adaptor_host_unittests.cc create mode 100644 src/lib/yang/tests/adaptor_option_unittests.cc create mode 100644 src/lib/yang/tests/adaptor_pool_unittests.cc create mode 100644 src/lib/yang/tests/adaptor_subnet_unittests.cc create mode 100644 src/lib/yang/tests/adaptor_unittests.cc create mode 100644 src/lib/yang/tests/config_unittests.cc create mode 100644 src/lib/yang/tests/json_configs.h create mode 100644 src/lib/yang/tests/run_unittests.cc create mode 100644 src/lib/yang/tests/sysrepo_setup.h create mode 100644 src/lib/yang/tests/translator_class_unittests.cc create mode 100644 src/lib/yang/tests/translator_control_socket_unittests.cc create mode 100644 src/lib/yang/tests/translator_database_unittests.cc create mode 100644 src/lib/yang/tests/translator_host_unittests.cc create mode 100644 src/lib/yang/tests/translator_logger_unittests.cc create mode 100644 src/lib/yang/tests/translator_option_data_unittests.cc create mode 100644 src/lib/yang/tests/translator_option_def_unittests.cc create mode 100644 src/lib/yang/tests/translator_pd_pool_unittests.cc create mode 100644 src/lib/yang/tests/translator_pool_unittests.cc create mode 100644 src/lib/yang/tests/translator_shared_network_unittests.cc create mode 100644 src/lib/yang/tests/translator_subnet_unittests.cc create mode 100644 src/lib/yang/tests/translator_unittests.cc create mode 100644 src/lib/yang/tests/translator_utils_unittests.cc create mode 100644 src/lib/yang/tests/yang_configs.h create mode 100644 src/lib/yang/testutils/Makefile.am create mode 100644 src/lib/yang/testutils/Makefile.in create mode 100644 src/lib/yang/testutils/translator_test.cc create mode 100644 src/lib/yang/testutils/translator_test.h create mode 100644 src/lib/yang/translator.cc create mode 100644 src/lib/yang/translator.h create mode 100644 src/lib/yang/translator_class.cc create mode 100644 src/lib/yang/translator_class.h create mode 100644 src/lib/yang/translator_config.cc create mode 100644 src/lib/yang/translator_config.h create mode 100644 src/lib/yang/translator_control_socket.cc create mode 100644 src/lib/yang/translator_control_socket.h create mode 100644 src/lib/yang/translator_database.cc create mode 100644 src/lib/yang/translator_database.h create mode 100644 src/lib/yang/translator_host.cc create mode 100644 src/lib/yang/translator_host.h create mode 100644 src/lib/yang/translator_logger.cc create mode 100644 src/lib/yang/translator_logger.h create mode 100644 src/lib/yang/translator_option_data.cc create mode 100644 src/lib/yang/translator_option_data.h create mode 100644 src/lib/yang/translator_option_def.cc create mode 100644 src/lib/yang/translator_option_def.h create mode 100644 src/lib/yang/translator_pd_pool.cc create mode 100644 src/lib/yang/translator_pd_pool.h create mode 100644 src/lib/yang/translator_pool.cc create mode 100644 src/lib/yang/translator_pool.h create mode 100644 src/lib/yang/translator_shared_network.cc create mode 100644 src/lib/yang/translator_shared_network.h create mode 100644 src/lib/yang/translator_subnet.cc create mode 100644 src/lib/yang/translator_subnet.h create mode 100644 src/lib/yang/yang.dox create mode 100644 src/lib/yang/yang_models.h create mode 100644 src/lib/yang/yang_revisions.h create mode 100644 src/lib/yang/yang_revisions.h.skel (limited to 'src/lib/yang') diff --git a/src/lib/yang/Makefile.am b/src/lib/yang/Makefile.am new file mode 100644 index 0000000..78b6678 --- /dev/null +++ b/src/lib/yang/Makefile.am @@ -0,0 +1,73 @@ +SUBDIRS = . testutils pretests tests + +AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) +AM_CPPFLAGS += $(SYSREPO_CPPFLAGS) +AM_CPPFLAGS += $(SYSREPO_INCLUDEDIR) +AM_CXXFLAGS = $(KEA_CXXFLAGS) + +lib_LTLIBRARIES = libkea-yang.la +libkea_yang_la_SOURCES = adaptor.cc adaptor.h +libkea_yang_la_SOURCES += adaptor_host.cc adaptor_host.h +libkea_yang_la_SOURCES += adaptor_pool.cc adaptor_pool.h +libkea_yang_la_SOURCES += adaptor_option.cc adaptor_option.h +libkea_yang_la_SOURCES += adaptor_subnet.cc adaptor_subnet.h +libkea_yang_la_SOURCES += adaptor_config.cc adaptor_config.h +libkea_yang_la_SOURCES += sysrepo_error.h +libkea_yang_la_SOURCES += translator.cc translator.h +libkea_yang_la_SOURCES += translator_control_socket.cc +libkea_yang_la_SOURCES += translator_control_socket.h +libkea_yang_la_SOURCES += translator_database.cc translator_database.h +libkea_yang_la_SOURCES += translator_logger.cc translator_logger.h +libkea_yang_la_SOURCES += translator_option_data.cc +libkea_yang_la_SOURCES += translator_option_data.h +libkea_yang_la_SOURCES += translator_option_def.cc +libkea_yang_la_SOURCES += translator_option_def.h +libkea_yang_la_SOURCES += translator_class.cc translator_class.h +libkea_yang_la_SOURCES += translator_pool.cc translator_pool.h +libkea_yang_la_SOURCES += translator_pd_pool.cc translator_pd_pool.h +libkea_yang_la_SOURCES += translator_host.cc translator_host.h +libkea_yang_la_SOURCES += translator_subnet.cc translator_subnet.h +libkea_yang_la_SOURCES += translator_shared_network.cc +libkea_yang_la_SOURCES += translator_shared_network.h +libkea_yang_la_SOURCES += translator_config.cc translator_config.h +libkea_yang_la_SOURCES += yang_models.h yang_revisions.h + +libkea_yang_la_LIBADD = $(top_builddir)/src/lib/asiolink/libkea-asiolink.la +libkea_yang_la_LIBADD += $(top_builddir)/src/lib/cc/libkea-cc.la +libkea_yang_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la +libkea_yang_la_LIBADD += $(top_builddir)/src/lib/util/libkea-util.la +libkea_yang_la_LIBADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la +libkea_yang_la_LIBADD += $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(SYSREPO_LIBS) + +libkea_yang_la_LDFLAGS = -no-undefined -version-info 29:0:0 + +# Specify the headers for copying into the installation directory tree. +libkea_yang_includedir = $(pkgincludedir)/yang +libkea_yang_include_HEADERS = \ + adaptor.h \ + adaptor_config.h \ + adaptor_host.h \ + adaptor_option.h \ + adaptor_pool.h \ + adaptor_subnet.h \ + sysrepo_error.h \ + translator.h \ + translator_class.h \ + translator_config.h \ + translator_control_socket.h \ + translator_database.h \ + translator_host.h \ + translator_logger.h \ + translator_option_data.h \ + translator_option_def.h \ + translator_pd_pool.h \ + translator_pool.h \ + translator_shared_network.h \ + translator_subnet.h \ + yang_models.h \ + yang_revisions.h + +EXTRA_DIST = yang.dox yang_revisions.h.skel + +CLEANFILES = *.gcno *.gcda diff --git a/src/lib/yang/Makefile.in b/src/lib/yang/Makefile.in new file mode 100644 index 0000000..c229989 --- /dev/null +++ b/src/lib/yang/Makefile.in @@ -0,0 +1,1040 @@ +# 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@ +subdir = src/lib/yang +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4macros/ax_boost_for_kea.m4 \ + $(top_srcdir)/m4macros/ax_cpp11.m4 \ + $(top_srcdir)/m4macros/ax_crypto.m4 \ + $(top_srcdir)/m4macros/ax_find_library.m4 \ + $(top_srcdir)/m4macros/ax_gssapi.m4 \ + $(top_srcdir)/m4macros/ax_gtest.m4 \ + $(top_srcdir)/m4macros/ax_isc_rpath.m4 \ + $(top_srcdir)/m4macros/ax_sysrepo.m4 \ + $(top_srcdir)/m4macros/libtool.m4 \ + $(top_srcdir)/m4macros/ltoptions.m4 \ + $(top_srcdir)/m4macros/ltsugar.m4 \ + $(top_srcdir)/m4macros/ltversion.m4 \ + $(top_srcdir)/m4macros/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(libkea_yang_include_HEADERS) \ + $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__uninstall_files_from_dir = { \ + test -z "$$files" \ + || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ + || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ + $(am__cd) "$$dir" && rm -f $$files; }; \ + } +am__installdirs = "$(DESTDIR)$(libdir)" \ + "$(DESTDIR)$(libkea_yang_includedir)" +LTLIBRARIES = $(lib_LTLIBRARIES) +am__DEPENDENCIES_1 = +libkea_yang_la_DEPENDENCIES = \ + $(top_builddir)/src/lib/asiolink/libkea-asiolink.la \ + $(top_builddir)/src/lib/cc/libkea-cc.la \ + $(top_builddir)/src/lib/log/libkea-log.la \ + $(top_builddir)/src/lib/util/libkea-util.la \ + $(top_builddir)/src/lib/exceptions/libkea-exceptions.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \ + $(am__DEPENDENCIES_1) +am_libkea_yang_la_OBJECTS = adaptor.lo adaptor_host.lo adaptor_pool.lo \ + adaptor_option.lo adaptor_subnet.lo adaptor_config.lo \ + translator.lo translator_control_socket.lo \ + translator_database.lo translator_logger.lo \ + translator_option_data.lo translator_option_def.lo \ + translator_class.lo translator_pool.lo translator_pd_pool.lo \ + translator_host.lo translator_subnet.lo \ + translator_shared_network.lo translator_config.lo +libkea_yang_la_OBJECTS = $(am_libkea_yang_la_OBJECTS) +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 = +libkea_yang_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ + $(AM_CXXFLAGS) $(CXXFLAGS) $(libkea_yang_la_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)/adaptor.Plo \ + ./$(DEPDIR)/adaptor_config.Plo ./$(DEPDIR)/adaptor_host.Plo \ + ./$(DEPDIR)/adaptor_option.Plo ./$(DEPDIR)/adaptor_pool.Plo \ + ./$(DEPDIR)/adaptor_subnet.Plo ./$(DEPDIR)/translator.Plo \ + ./$(DEPDIR)/translator_class.Plo \ + ./$(DEPDIR)/translator_config.Plo \ + ./$(DEPDIR)/translator_control_socket.Plo \ + ./$(DEPDIR)/translator_database.Plo \ + ./$(DEPDIR)/translator_host.Plo \ + ./$(DEPDIR)/translator_logger.Plo \ + ./$(DEPDIR)/translator_option_data.Plo \ + ./$(DEPDIR)/translator_option_def.Plo \ + ./$(DEPDIR)/translator_pd_pool.Plo \ + ./$(DEPDIR)/translator_pool.Plo \ + ./$(DEPDIR)/translator_shared_network.Plo \ + ./$(DEPDIR)/translator_subnet.Plo +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 = $(libkea_yang_la_SOURCES) +DIST_SOURCES = $(libkea_yang_la_SOURCES) +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +HEADERS = $(libkea_yang_include_HEADERS) +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + distdir distdir-am +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ASCIIDOC = @ASCIIDOC@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_INCLUDES = @BOOST_INCLUDES@ +BOOST_LIBS = @BOOST_LIBS@ +BOTAN_TOOL = @BOTAN_TOOL@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONTRIB_DIR = @CONTRIB_DIR@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRYPTO_CFLAGS = @CRYPTO_CFLAGS@ +CRYPTO_INCLUDES = @CRYPTO_INCLUDES@ +CRYPTO_LDFLAGS = @CRYPTO_LDFLAGS@ +CRYPTO_LIBS = @CRYPTO_LIBS@ +CRYPTO_PACKAGE = @CRYPTO_PACKAGE@ +CRYPTO_RPATH = @CRYPTO_RPATH@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISTCHECK_BOOST_CONFIGURE_FLAG = @DISTCHECK_BOOST_CONFIGURE_FLAG@ +DISTCHECK_CONTRIB_CONFIGURE_FLAG = @DISTCHECK_CONTRIB_CONFIGURE_FLAG@ +DISTCHECK_CRYPTO_CONFIGURE_FLAG = @DISTCHECK_CRYPTO_CONFIGURE_FLAG@ +DISTCHECK_GTEST_CONFIGURE_FLAG = @DISTCHECK_GTEST_CONFIGURE_FLAG@ +DISTCHECK_KEA_SHELL_CONFIGURE_FLAG = @DISTCHECK_KEA_SHELL_CONFIGURE_FLAG@ +DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG = @DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG@ +DISTCHECK_PERFDHCP_CONFIGURE_FLAG = @DISTCHECK_PERFDHCP_CONFIGURE_FLAG@ +DISTCHECK_PREMIUM_CONFIGURE_FLAG = @DISTCHECK_PREMIUM_CONFIGURE_FLAG@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GENHTML = @GENHTML@ +GREP = @GREP@ +GSSAPI_CFLAGS = @GSSAPI_CFLAGS@ +GSSAPI_LIBS = @GSSAPI_LIBS@ +GTEST_CONFIG = @GTEST_CONFIG@ +GTEST_INCLUDES = @GTEST_INCLUDES@ +GTEST_LDADD = @GTEST_LDADD@ +GTEST_LDFLAGS = @GTEST_LDFLAGS@ +GTEST_SOURCE = @GTEST_SOURCE@ +HAVE_SYSREPO = @HAVE_SYSREPO@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KEA_CXXFLAGS = @KEA_CXXFLAGS@ +KEA_SRCID = @KEA_SRCID@ +KRB5_CONFIG = @KRB5_CONFIG@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOG4CPLUS_INCLUDES = @LOG4CPLUS_INCLUDES@ +LOG4CPLUS_LIBS = @LOG4CPLUS_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ +MYSQL_LIBS = @MYSQL_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_VERSION_TYPE = @PACKAGE_VERSION_TYPE@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PDFLATEX = @PDFLATEX@ +PERL = @PERL@ +PGSQL_CPPFLAGS = @PGSQL_CPPFLAGS@ +PGSQL_LIBS = @PGSQL_LIBS@ +PKGPYTHONDIR = @PKGPYTHONDIR@ +PKG_CONFIG = @PKG_CONFIG@ +PLANTUML = @PLANTUML@ +PREMIUM_DIR = @PREMIUM_DIR@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +SED = @SED@ +SEP = @SEP@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPHINXBUILD = @SPHINXBUILD@ +SRPD_PLUGINS_PATH = @SRPD_PLUGINS_PATH@ +SR_REPO_PATH = @SR_REPO_PATH@ +STRIP = @STRIP@ +SYSREPOCPP_VERSION = @SYSREPOCPP_VERSION@ +SYSREPO_CPPFLAGS = @SYSREPO_CPPFLAGS@ +SYSREPO_INCLUDEDIR = @SYSREPO_INCLUDEDIR@ +SYSREPO_LIBS = @SYSREPO_LIBS@ +SYSREPO_VERSION = @SYSREPO_VERSION@ +USE_LCOV = @USE_LCOV@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WARNING_GCC_44_STRICT_ALIASING_CFLAG = @WARNING_GCC_44_STRICT_ALIASING_CFLAG@ +YACC = @YACC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = . testutils pretests tests +AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib \ + $(BOOST_INCLUDES) $(SYSREPO_CPPFLAGS) $(SYSREPO_INCLUDEDIR) +AM_CXXFLAGS = $(KEA_CXXFLAGS) +lib_LTLIBRARIES = libkea-yang.la +libkea_yang_la_SOURCES = adaptor.cc adaptor.h adaptor_host.cc \ + adaptor_host.h adaptor_pool.cc adaptor_pool.h \ + adaptor_option.cc adaptor_option.h adaptor_subnet.cc \ + adaptor_subnet.h adaptor_config.cc adaptor_config.h \ + sysrepo_error.h translator.cc translator.h \ + translator_control_socket.cc translator_control_socket.h \ + translator_database.cc translator_database.h \ + translator_logger.cc translator_logger.h \ + translator_option_data.cc translator_option_data.h \ + translator_option_def.cc translator_option_def.h \ + translator_class.cc translator_class.h translator_pool.cc \ + translator_pool.h translator_pd_pool.cc translator_pd_pool.h \ + translator_host.cc translator_host.h translator_subnet.cc \ + translator_subnet.h translator_shared_network.cc \ + translator_shared_network.h translator_config.cc \ + translator_config.h yang_models.h yang_revisions.h +libkea_yang_la_LIBADD = \ + $(top_builddir)/src/lib/asiolink/libkea-asiolink.la \ + $(top_builddir)/src/lib/cc/libkea-cc.la \ + $(top_builddir)/src/lib/log/libkea-log.la \ + $(top_builddir)/src/lib/util/libkea-util.la \ + $(top_builddir)/src/lib/exceptions/libkea-exceptions.la \ + $(LOG4CPLUS_LIBS) $(BOOST_LIBS) $(SYSREPO_LIBS) +libkea_yang_la_LDFLAGS = -no-undefined -version-info 29:0:0 + +# Specify the headers for copying into the installation directory tree. +libkea_yang_includedir = $(pkgincludedir)/yang +libkea_yang_include_HEADERS = \ + adaptor.h \ + adaptor_config.h \ + adaptor_host.h \ + adaptor_option.h \ + adaptor_pool.h \ + adaptor_subnet.h \ + sysrepo_error.h \ + translator.h \ + translator_class.h \ + translator_config.h \ + translator_control_socket.h \ + translator_database.h \ + translator_host.h \ + translator_logger.h \ + translator_option_data.h \ + translator_option_def.h \ + translator_pd_pool.h \ + translator_pool.h \ + translator_shared_network.h \ + translator_subnet.h \ + yang_models.h \ + yang_revisions.h + +EXTRA_DIST = yang.dox yang_revisions.h.skel +CLEANFILES = *.gcno *.gcda +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .cc .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/lib/yang/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/lib/yang/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): + +install-libLTLIBRARIES: $(lib_LTLIBRARIES) + @$(NORMAL_INSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \ + } + +uninstall-libLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \ + done + +clean-libLTLIBRARIES: + -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES) + @list='$(lib_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libkea-yang.la: $(libkea_yang_la_OBJECTS) $(libkea_yang_la_DEPENDENCIES) $(EXTRA_libkea_yang_la_DEPENDENCIES) + $(AM_V_CXXLD)$(libkea_yang_la_LINK) -rpath $(libdir) $(libkea_yang_la_OBJECTS) $(libkea_yang_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adaptor.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adaptor_config.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adaptor_host.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adaptor_option.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adaptor_pool.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/adaptor_subnet.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_class.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_config.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_control_socket.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_database.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_host.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_logger.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_option_data.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_option_def.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_pd_pool.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_pool.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_shared_network.Plo@am__quote@ # am--include-marker +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/translator_subnet.Plo@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 $@ $< + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-libkea_yang_includeHEADERS: $(libkea_yang_include_HEADERS) + @$(NORMAL_INSTALL) + @list='$(libkea_yang_include_HEADERS)'; test -n "$(libkea_yang_includedir)" || list=; \ + if test -n "$$list"; then \ + echo " $(MKDIR_P) '$(DESTDIR)$(libkea_yang_includedir)'"; \ + $(MKDIR_P) "$(DESTDIR)$(libkea_yang_includedir)" || exit 1; \ + fi; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(libkea_yang_includedir)'"; \ + $(INSTALL_HEADER) $$files "$(DESTDIR)$(libkea_yang_includedir)" || exit $$?; \ + done + +uninstall-libkea_yang_includeHEADERS: + @$(NORMAL_UNINSTALL) + @list='$(libkea_yang_include_HEADERS)'; test -n "$(libkea_yang_includedir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + dir='$(DESTDIR)$(libkea_yang_includedir)'; $(am__uninstall_files_from_dir) + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LTLIBRARIES) $(HEADERS) +installdirs: installdirs-recursive +installdirs-am: + for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(libkea_yang_includedir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \ + mostlyclean-am + +distclean: distclean-recursive + -rm -f ./$(DEPDIR)/adaptor.Plo + -rm -f ./$(DEPDIR)/adaptor_config.Plo + -rm -f ./$(DEPDIR)/adaptor_host.Plo + -rm -f ./$(DEPDIR)/adaptor_option.Plo + -rm -f ./$(DEPDIR)/adaptor_pool.Plo + -rm -f ./$(DEPDIR)/adaptor_subnet.Plo + -rm -f ./$(DEPDIR)/translator.Plo + -rm -f ./$(DEPDIR)/translator_class.Plo + -rm -f ./$(DEPDIR)/translator_config.Plo + -rm -f ./$(DEPDIR)/translator_control_socket.Plo + -rm -f ./$(DEPDIR)/translator_database.Plo + -rm -f ./$(DEPDIR)/translator_host.Plo + -rm -f ./$(DEPDIR)/translator_logger.Plo + -rm -f ./$(DEPDIR)/translator_option_data.Plo + -rm -f ./$(DEPDIR)/translator_option_def.Plo + -rm -f ./$(DEPDIR)/translator_pd_pool.Plo + -rm -f ./$(DEPDIR)/translator_pool.Plo + -rm -f ./$(DEPDIR)/translator_shared_network.Plo + -rm -f ./$(DEPDIR)/translator_subnet.Plo + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: install-libkea_yang_includeHEADERS + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: install-libLTLIBRARIES + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/adaptor.Plo + -rm -f ./$(DEPDIR)/adaptor_config.Plo + -rm -f ./$(DEPDIR)/adaptor_host.Plo + -rm -f ./$(DEPDIR)/adaptor_option.Plo + -rm -f ./$(DEPDIR)/adaptor_pool.Plo + -rm -f ./$(DEPDIR)/adaptor_subnet.Plo + -rm -f ./$(DEPDIR)/translator.Plo + -rm -f ./$(DEPDIR)/translator_class.Plo + -rm -f ./$(DEPDIR)/translator_config.Plo + -rm -f ./$(DEPDIR)/translator_control_socket.Plo + -rm -f ./$(DEPDIR)/translator_database.Plo + -rm -f ./$(DEPDIR)/translator_host.Plo + -rm -f ./$(DEPDIR)/translator_logger.Plo + -rm -f ./$(DEPDIR)/translator_option_data.Plo + -rm -f ./$(DEPDIR)/translator_option_def.Plo + -rm -f ./$(DEPDIR)/translator_pd_pool.Plo + -rm -f ./$(DEPDIR)/translator_pool.Plo + -rm -f ./$(DEPDIR)/translator_shared_network.Plo + -rm -f ./$(DEPDIR)/translator_subnet.Plo + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: uninstall-libLTLIBRARIES \ + uninstall-libkea_yang_includeHEADERS + +.MAKE: $(am__recursive_targets) install-am install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ + am--depfiles check check-am clean clean-generic \ + clean-libLTLIBRARIES clean-libtool 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-libLTLIBRARIES \ + install-libkea_yang_includeHEADERS install-man install-pdf \ + install-pdf-am install-ps install-ps-am install-strip \ + installcheck installcheck-am installdirs installdirs-am \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags tags-am uninstall uninstall-am \ + uninstall-libLTLIBRARIES uninstall-libkea_yang_includeHEADERS + +.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/adaptor.cc b/src/lib/yang/adaptor.cc new file mode 100644 index 0000000..2de0a29 --- /dev/null +++ b/src/lib/yang/adaptor.cc @@ -0,0 +1,308 @@ +// 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 + +#include +#include + +#include + +using namespace std; +using namespace isc::data; + +namespace isc { +namespace yang { + +Adaptor::Adaptor() { +} + +Adaptor::~Adaptor() { +} + +ConstElementPtr +Adaptor::getContext(ConstElementPtr parent) +{ + ConstElementPtr context = parent->get("user-context"); + ConstElementPtr comment = parent->get("comment"); + if (!comment) { + return (context); + } + ElementPtr result; + if (context) { + result = copy(context); + } else { + result = Element::createMap(); + } + result->set("comment", comment); + return (result); +} + +void +Adaptor::fromParent(const string& name, ConstElementPtr parent, + ConstElementPtr list) { + ConstElementPtr param = parent->get(name); + if (!param) { + return; + } + BOOST_FOREACH(ElementPtr item, list->listValue()) { + // don't override. Skip this entry if it already has the parameter. + if (item->contains(name)) { + continue; + } + item->set(name, param); + } +} + +void +Adaptor::toParent(const string& name, ElementPtr parent, + ConstElementPtr list) { + ConstElementPtr param; + bool first = true; + BOOST_FOREACH(ElementPtr item, list->listValue()) { + if (first) { + first = false; + param = item->get(name); + } else if ((!param && item->contains(name)) || + (param && !item->contains(name)) || + (param && item->contains(name) && + !param->equals(*item->get(name)))) { + isc_throw(BadValue, + "inconsistent value of " << name + << " in " << list->str()); + } + } + if (!first && param) { + BOOST_FOREACH(ElementPtr item, list->listValue()) { + if (param) { + item->remove(name); + } + } + parent->set(name, param); + } +} + +namespace { + +/// @brief Apply insert. +/// +/// This function applies an insert action at the given scope: +/// - in a map it adds the value at the key when the key does not exist +/// - in a list it appends the value +/// - in other scope type it does nothing +/// @note a copy of the value is used to avoid unwanted sharing/side effects. +/// +/// @param key The key of the modification. +/// @param value The value of the modification. +/// @param scope The place to apply the insert. +void applyInsert(ConstElementPtr key, ConstElementPtr value, + ElementPtr scope) { + if (scope->getType() == Element::map) { + if (!key || !value || (key->getType() != Element::string)) { + return; + } + string name = key->stringValue(); + if (!name.empty() && !scope->contains(name)) { + scope->set(name, copy(value)); + } + } else if (scope->getType() == Element::list) { + if (value) { + scope->add(copy(value)); + } + } +} + +/// @brief Apply replace. +/// +/// This function works only on map scopes and acts as insert at the +/// exception the new value is set even if the key already exists. +/// +/// @param key The key of the modification. +/// @param value The value of the modification. +/// @param scope The place to apply the replace. +void applyReplace(ConstElementPtr key, ConstElementPtr value, + ElementPtr scope) { + if ((scope->getType() != Element::map) || + !key || !value || (key->getType() != Element::string)) { + return; + } + string name = key->stringValue(); + if (!name.empty()) { + scope->set(name, copy(value)); + } +} + +/// @brief Apply delete. +/// +/// This function deletes the value designed by the key from the given scope: +/// - in a map the key is the key of the value to remove +/// - in a list the key is: +/// * when it is an integer the index of the value to remove +/// * when it is a map the key / value pair which belongs to the value +/// to remove +/// - in other scope type it does nothing +/// +/// @param key The key item of the path. +/// @param scope The place to apply the delete. +void applyDelete(ConstElementPtr key, ElementPtr scope) { + if (scope->getType() == Element::map) { + if (!key || (key->getType() != Element::string)) { + return; + } + string name = key->stringValue(); + if (!name.empty()) { + scope->remove(name); + } + } else if (scope->getType() == Element::list) { + if (!key) { + return; + } else if (key->getType() == Element::integer) { + int index = key->intValue(); + if ((index >= 0) && (index < scope->size())) { + scope->remove(index); + } + } else if (key->getType() == Element::map) { + ConstElementPtr entry = key->get("key"); + ConstElementPtr value = key->get("value"); + if (!entry || !value || (entry->getType() != Element::string)) { + return; + } + string name = entry->stringValue(); + if (name.empty()) { + return; + } + for (int i = 0; i < scope->size(); ++i) { + ConstElementPtr item = scope->get(i); + if (!item || (item->getType() != Element::map)) { + continue; + } + ConstElementPtr compare = item->get(name); + if (compare && value->equals(*compare)) { + scope->remove(i); + return; + } + } + } + } +} + +/// @brief Apply action. +/// +/// This function applies one action (insert, replace or delete) using +/// applyInsert, applyReplace or applyDelete. +/// +/// @param actions The action list. +/// @param scope The current scope. +/// @param next The index of the next action. +void applyAction(ConstElementPtr actions, ElementPtr scope, size_t next) { + if (next == actions->size()) { + return; + } + ConstElementPtr action = actions->get(next); + ++next; + if (!action || (action->getType() != Element::map) || + !action->contains("action")) { + applyAction(actions, scope, next); + return; + } + string name = action->get("action")->stringValue(); + if (name == "insert") { + applyInsert(action->get("key"), action->get("value"), scope); + } else if (name == "replace") { + applyReplace(action->get("key"), action->get("value"), scope); + } else if (name == "delete") { + applyDelete(action->get("key"), scope); + } + applyAction(actions, scope, next); +} + +/// @brief Apply recursively actions following the path and going down +/// in the to-be-modified structure. +/// +/// The recursive call when the end of the path is not reached is done: +/// - in a map on the value at the key +/// - in a list the next path item is: +/// * if it is a positive integer on the value at the index +/// * if it is -1 on all elements of the list +/// * if a map on the element where the key / value pair belongs to +/// +/// @param path The search list. +/// @param actions The action list. +/// @param scope The current scope. +/// @param next The index of the next item to use in the path. +void applyDown(ConstElementPtr path, ConstElementPtr actions, ElementPtr scope, + size_t next) { + if (!scope) { + return; + } + if (next == path->size()) { + applyAction(actions, scope, 0); + return; + } + ConstElementPtr step = path->get(next); + ++next; + if (scope->getType() == Element::map) { + if (!step || (step->getType() != Element::string)) { + return; + } + string name = step->stringValue(); + if (name.empty() || !scope->contains(name)) { + return; + } + ElementPtr down = boost::const_pointer_cast(scope->get(name)); + if (down) { + applyDown(path, actions, down, next); + } + } else if (scope->getType() == Element::list) { + if (!step) { + return; + } + auto downs = scope->listValue(); + if (step->getType() == Element::map) { + ConstElementPtr key = step->get("key"); + ConstElementPtr value = step->get("value"); + if (!key || !value || (key->getType() != Element::string)) { + return; + } + string name = key->stringValue(); + if (name.empty()) { + return; + } + for (ElementPtr down : downs) { + if (!down || (down->getType() != Element::map)) { + continue; + } + ConstElementPtr compare = down->get(name); + if (compare && value->equals(*compare)) { + applyDown(path, actions, down, next); + return; + } + } + } else if (step->getType() != Element::integer) { + return; + } + int index = step->intValue(); + if (index == -1) { + for (ElementPtr down : downs) { + applyDown(path, actions, down, next); + } + } else if ((index >= 0) && (index < scope->size())) { + applyDown(path, actions, scope->getNonConst(index), next); + } + } +} + +} // end of anonymous namespace + +/// Apply recursively starting at the beginning of the path. +void +Adaptor::modify(ConstElementPtr path, ConstElementPtr actions, + ElementPtr config) { + applyDown(path, actions, config, 0); +} + +} // end of namespace isc::yang +} // end of namespace isc diff --git a/src/lib/yang/adaptor.h b/src/lib/yang/adaptor.h new file mode 100644 index 0000000..8d1fdf3 --- /dev/null +++ b/src/lib/yang/adaptor.h @@ -0,0 +1,133 @@ +// 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 ISC_ADAPTOR_H +#define ISC_ADAPTOR_H 1 + +#include +#include + +namespace isc { +namespace yang { + +/// @brief Missing key error. +class MissingKey : public isc::Exception { +public: + MissingKey(const char* file, size_t line, const char* what) : + isc::Exception(file, line, what) + {} +}; + +/// @brief JSON adaptor between canonical Kea and YANG models. +/// +/// An adaptor slightly modifies a JSON configuration between canonical Kea +/// what required or rendered by a YANG model, e.g. moving a parameter +/// to/from a parent. +/// The basic adaptor provides a set of tools. +class Adaptor { +public: + + /// @brief Constructor. + Adaptor(); + + /// @brief Destructor. + virtual ~Adaptor(); + + /// @brief Get user context. + /// + /// Get user-context and/or comment and return it with the comment + /// if exists moved inside the user-context (without checking if + /// there is already a comment as it should never be the case). + /// + /// This behavior is used to handle comments. For historical purposes + /// Kea allows to define comments in some scopes. Once the user-context + /// has been introduced, the comment (as a separate text field) + /// disappeared and was moved to comment key within user-context. + /// Nevertheless, the old syntax is still supported. + static isc::data::ConstElementPtr + getContext(isc::data::ConstElementPtr parent); + + /// @brief Moves a parameter from parent to a list of children. + /// + /// Move a parameter from the parent to each item in a list. + /// If the parameter exists in a child, it is skipped for this + /// particular child, not overridden. + /// + /// @param name The parameter name. + /// @param parent The parent element. + /// @param list The children list. + static void fromParent(const std::string& name, + isc::data::ConstElementPtr parent, + isc::data::ConstElementPtr list); + + /// @brief Moves a parameter to a parent. + /// + /// Move a parameter from children to the parent. All children + /// on the list must have the parameter specified and it has to have + /// the same value. + /// + /// @param name The parameter name. + /// @param parent The parent element. + /// @param list The children list. + static void toParent(const std::string& name, + isc::data::ElementPtr parent, + isc::data::ConstElementPtr list); + + /// @brief Modify a configuration in its JSON element format. + /// + /// Smart merging tool, e.g. completing a from yang configuration. + /// + /// A modification is a path and actions: + /// - path item can be: + /// * a string: current scope is a map, go down following the string + /// as a key. + /// * a number: current scope is a list, go down the number as an index. + /// * special value -1: current scope is a list, apply to all items. + /// * map { "": }: current scope is a list, go down to + /// the item using the key / value pair. + /// - an action can be: insert, replace or delete: + /// * insert adds a value at a key: + /// . in a map the key is the new entry key + /// . in a list an integer key is the new element index + /// . in a list a map key is the key / value pair the to-be-modified + /// element contains + /// * replace adds or replaces if it already exists a value at + /// an entry key in a map. + /// * delete removes a value designed by a key + /// + /// For instance to add a control-socket entry in a configuration + /// from a generic (vs Kea) model: + /// @code + /// path := [ ] + /// actions := [ { + /// "action": "insert", + /// "key": "Dhcp4", + /// "value": + /// { + /// "control-socket": + /// { + /// "socket-type": "unix", + /// "socket-name": "/tmp/kea4-ctrl-socket" + /// } + /// } + /// } + /// @endcode + /// + /// @param path The search list to follow down to the place to + /// apply the action list. + /// @param actions The action list + /// @param config The configuration (JSON map) to modify. + /// @note modify does not throw but returns on unexpected conditions. + static void modify(isc::data::ConstElementPtr path, + isc::data::ConstElementPtr actions, + isc::data::ElementPtr config); + +}; + +} // end of namespace isc::yang +} // end of namespace isc + +#endif // ISC_ADAPTOR_H diff --git a/src/lib/yang/adaptor_config.cc b/src/lib/yang/adaptor_config.cc new file mode 100644 index 0000000..2fff557 --- /dev/null +++ b/src/lib/yang/adaptor_config.cc @@ -0,0 +1,658 @@ +// 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 + +#include + +using namespace std; +using namespace isc::data; +using namespace isc::dhcp; + +namespace { +const string DHCP4_SPACE = "dhcp4"; +const string DHCP6_SPACE = "dhcp6"; +} + +namespace isc { +namespace yang { + +AdaptorConfig::AdaptorConfig() { +} + +AdaptorConfig::~AdaptorConfig() { +} + +bool +AdaptorConfig::subnetsCollectID(ConstElementPtr subnets, SubnetIDSet& set) { + bool have_ids = true; + + if (!subnets || subnets->empty()) { + // There are no subnets defined, so technically there are no ids. + // However, the flag is used to determine whether the code later + // needs to call assignIDs. Since there is no need to assign + // anything, the code returns true here. + return (true); + } + + // If there are subnets defined, let's go over them one by one and + // collect subnet-ids used in them. + for (ConstElementPtr subnet : subnets->listValue()) { + if (!collectID(subnet, set)) { + have_ids = false; + } + } + return (have_ids); +} + +bool +AdaptorConfig::sharedNetworksCollectID(ConstElementPtr networks, + SubnetIDSet& set, + const string& subsel) { + if (!networks || networks->empty()) { + // There are no shared networks defined, so technically there are no + // ids. However, the flag is used to determine whether the code later + // needs to call assignIDs. Since there is no need to assign anything, + // the code returns true here. + return (true); + } + + // This determines if EVERY subnet has subnet-id defined. + bool have_ids = true; + for (size_t i = 0; i < networks->size(); ++i) { + ElementPtr network = networks->getNonConst(i); + ConstElementPtr subnets = network->get(subsel); + if (subnets) { + if (!subnets->empty()) { + // If there are subnets, collect their subnet-ids. If any + // of them doesn't have a subnet-id, return false. + if (!subnetsCollectID(subnets, set)) { + have_ids = false; + } + } else { + // There's empty subnets list, so just remove it. + network->remove(subsel); + } + } + } + return (have_ids); +} + +void +AdaptorConfig::subnetsAssignID(ConstElementPtr subnets, SubnetIDSet& set, + SubnetID& next) { + if (!subnets || subnets->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < subnets->size(); ++i) { + ElementPtr subnet = subnets->getNonConst(i); + assignID(subnet, set, next); + } +} + +void +AdaptorConfig::sharedNetworksAssignID(ConstElementPtr networks, + SubnetIDSet& set, SubnetID& next, + const string& subsel) { + if (!networks || networks->empty()) { + // nothing to do here. + return; + } + + for (ConstElementPtr network : networks->listValue()) { + ConstElementPtr subnets = network->get(subsel); + if (!subnets || subnets->empty()) { + continue; + } + + for (size_t i = 0; i < subnets->size(); ++i) { + ElementPtr subnet = subnets->getNonConst(i); + assignID(subnet, set, next); + } + } +} + +void +AdaptorConfig::sanitizePools(ConstElementPtr pools) { + if (!pools || pools->empty()) { + // nothing to do here. + return; + } + + // Canonize (clean up name, remove extra spaces, add one space where + // needed) every pool on the list. + for (size_t i = 0; i < pools->size(); ++i) { + ElementPtr pool = pools->getNonConst(i); + AdaptorPool::canonizePool(pool); + } +} + +void +AdaptorConfig::sanitizePoolsInSubnets(ConstElementPtr subnets) { + if (!subnets || subnets->empty()) { + // nothing to do here. + return; + } + + for (ConstElementPtr subnet : subnets->listValue()) { + sanitizePools(subnet->get("pools")); + } +} + +void +AdaptorConfig::sanitizePoolsInSharedNetworks(ConstElementPtr networks, + const string& subsel) { + if (!networks || networks->empty()) { + // nothing to do here. + return; + } + + for (ConstElementPtr network : networks->listValue()) { + sanitizePoolsInSubnets(network->get(subsel)); + } +} + +void +AdaptorConfig::sanitizeOptionDefList(ConstElementPtr defs, + const string& space, + OptionCodes& codes) { + if (!defs || defs->empty()) { + // nothing to do here. + return; + } + + // Do sanity checks on every option definition and fill any missing + // fields with default values. + for (size_t i = 0; i < defs->size(); ++i) { + ElementPtr def = defs->getNonConst(i); + checkCode(def); + checkType(def); + setSpace(def, space); + collect(def, codes); + } +} + +void +AdaptorConfig::sanitizeOptionDataList(ConstElementPtr options, + const string& space, + const OptionCodes& codes) { + if (!options || options->empty()) { + // nothing to do here. + return; + } + + // Sanitize option-data. The only missing elements we may possibly + // need to fill are option space and option code. + for (size_t i = 0; i < options->size(); ++i) { + ElementPtr option = options->getNonConst(i); + setSpace(option, space); + setCode(option, codes); + } +} + +void +AdaptorConfig::sanitizeOptionClasses(ConstElementPtr classes, + const string& space, + OptionCodes& codes) { + if (!classes || classes->empty()) { + // nothing to do here. + return; + } + + // For every client class defined... + for (size_t i = 0; i < classes->size(); ++i) { + ElementPtr cclass = classes->getNonConst(i); + + if (space == DHCP4_SPACE) { + ConstElementPtr options = cclass->get("option-def"); + if (options) { + if (!options->empty()) { + // If present, sanitize it. + sanitizeOptionDefList(options, space, codes); + } else { + // If empty, remove it. + cclass->remove("option-def"); + } + } + } + + // also sanitize option data. + ConstElementPtr options = cclass->get("option-data"); + if (options) { + if (!options->empty()) { + // If present, sanitize it. + sanitizeOptionDataList(options, space, codes); + } else { + // If empty, remove it. + cclass->remove("option-data"); + } + } + } +} + +void +AdaptorConfig::sanitizeOptionPools(ConstElementPtr pools, const string& space, + const OptionCodes& codes) { + if (!pools || pools->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < pools->size(); ++i) { + ElementPtr pool = pools->getNonConst(i); + ConstElementPtr options = pool->get("option-data"); + if (options) { + if (!options->empty()) { + sanitizeOptionDataList(options, space, codes); + } else { + pool->remove("option-data"); + } + } + } +} + +void +AdaptorConfig::sanitizeOptionHosts(ConstElementPtr hosts, const string& space, + const OptionCodes& codes) { + if (!hosts || hosts->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < hosts->size(); ++i) { + ElementPtr host = hosts->getNonConst(i); + ConstElementPtr options = host->get("option-data"); + if (options) { + if (!options->empty()) { + sanitizeOptionDataList(options, space, codes); + } else { + host->remove("option-data"); + } + } + } +} + +void +AdaptorConfig::sanitizeOptionSubnets(ConstElementPtr subnets, + const string& space, + const OptionCodes& codes) { + if (!subnets || subnets->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < subnets->size(); ++i) { + ElementPtr subnet = subnets->getNonConst(i); + + // Let's try to sanitize option-data first. + ConstElementPtr options = subnet->get("option-data"); + if (options) { + if (!options->empty()) { + sanitizeOptionDataList(options, space, codes); + } else { + subnet->remove("option-data"); + } + } + + // Then try to sanitize pools. + ConstElementPtr pools = subnet->get("pools"); + if (pools) { + if (!pools->empty()) { + sanitizeOptionPools(pools, space, codes); + } else { + subnet->remove("pools"); + } + } + + // If this is v6, also sanitize pd-pools. + if (space == DHCP6_SPACE) { + ConstElementPtr pools = subnet->get("pd-pools"); + if (pools) { + if (!pools->empty()) { + sanitizeOptionPools(pools, space, codes); + } else { + subnet->remove("pd-pools"); + } + } + } + + // Finally, sanitize host reservations. + ConstElementPtr hosts = subnet->get("reservations"); + if (hosts) { + if (!hosts->empty()) { + sanitizeOptionHosts(hosts, space, codes); + } else { + subnet->remove("reservations"); + } + } + } +} + +void +AdaptorConfig::sanitizeOptionSharedNetworks(ConstElementPtr networks, + const string& space, + const OptionCodes& codes) { + if (!networks || networks->empty()) { + // nothing to do here. + return; + } + + // For every shared network... + for (size_t i = 0; i < networks->size(); ++i) { + ElementPtr network = networks->getNonConst(i); + + // try to sanitize shared network options first. + ConstElementPtr options = network->get("option-data"); + if (options) { + if (!options->empty()) { + sanitizeOptionDataList(options, space, codes); + } else { + network->remove("option-data"); + } + } + string subnet = "subnet"; + if (space == DHCP4_SPACE) { + subnet += "4"; + } else { + subnet += "6"; + } + + // Now try to sanitize subnets. + ConstElementPtr subnets = network->get(subnet); + if (subnets) { + if (!subnets->empty()) { + sanitizeOptionSubnets(subnets, space, codes); + } else { + network->remove(subnet); + } + } + } +} + +void +AdaptorConfig::sanitizeRequireClassesPools(ConstElementPtr pools) { + if (!pools || pools->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < pools->size(); ++i) { + ElementPtr pool = pools->getNonConst(i); + ConstElementPtr requires = pool->get("require-client-classes"); + if (requires && requires->empty()) { + pool->remove("require-client-classes"); + } + } +} + +void +AdaptorConfig::sanitizeRequireClassesSubnets(ConstElementPtr subnets) { + if (!subnets || subnets->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < subnets->size(); ++i) { + ElementPtr subnet = subnets->getNonConst(i); + sanitizeRequireClassesPools(subnet->get("pools")); + sanitizeRequireClassesPools(subnet->get("pd-pools")); + ConstElementPtr requires = subnet->get("require-client-classes"); + if (requires && requires->empty()) { + subnet->remove("require-client-classes"); + } + } +} + +void +AdaptorConfig::requireClassesSharedNetworks(ConstElementPtr networks, + const string& subsel) { + if (!networks || networks->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < networks->size(); ++i) { + ElementPtr network = networks->getNonConst(i); + sanitizeRequireClassesSubnets(network->get(subsel)); + ConstElementPtr requires = network->get("require-client-classes"); + if (requires && requires->empty()) { + network->remove("require-client-classes"); + } + } +} + +void +AdaptorConfig::sanitizeHostList(ConstElementPtr hosts) { + + if (!hosts || hosts->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < hosts->size(); ++i) { + ElementPtr host = hosts->getNonConst(i); + quoteIdentifier(host); + } +} + +void +AdaptorConfig::sanitizeHostSubnets(ConstElementPtr subnets) { + + if (!subnets || subnets->empty()) { + // nothing to do here. + return; + } + + for (ConstElementPtr subnet : subnets->listValue()) { + sanitizeHostList(subnet->get("reservations")); + } +} + +void +AdaptorConfig::SanitizeHostsInSharedNetworks(ConstElementPtr networks, + const string& space) { + if (!networks || networks->empty()) { + // nothing to do here. + return; + } + + for (ConstElementPtr network : networks->listValue()) { + if (space == DHCP4_SPACE) { + sanitizeHostSubnets(network->get("subnet4")); + } else { + sanitizeHostSubnets(network->get("subnet6")); + } + } +} + +void +AdaptorConfig::sanitizeRelaySubnets(ConstElementPtr subnets) { + if (!subnets || subnets->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < subnets->size(); ++i) { + ElementPtr subnet = subnets->getNonConst(i); + updateRelay(subnet); + } +} + +void +AdaptorConfig::sanitizeRelayInSharedNetworks(ConstElementPtr networks, + const string& subsel) { + if (!networks || networks->empty()) { + // nothing to do here. + return; + } + + for (size_t i = 0; i < networks->size(); ++i) { + ElementPtr network = networks->getNonConst(i); + updateRelay(network); + sanitizeRelaySubnets(network->get(subsel)); + } +} + +void +AdaptorConfig::sanitizeDatabase(ConstElementPtr dhcp) { + ConstElementPtr database = dhcp->get("hosts-database"); + if (!database) { + // nothing to do here. + return; + } + + ElementPtr mutable_dhcp = boost::const_pointer_cast(dhcp); + mutable_dhcp->remove("hosts-database"); + ElementPtr list = Element::createList(); + list->add(boost::const_pointer_cast(database)); + mutable_dhcp->set("hosts-databases", list); +} + +void +AdaptorConfig::sanitizeRelaySuppliedOptions(ConstElementPtr dhcp) { + ConstElementPtr options = dhcp->get("relay-supplied-options"); + if (!options || !options->empty()) { + // nothing to do here. + return; + } + ElementPtr mutable_dhcp = boost::const_pointer_cast(dhcp); + mutable_dhcp->remove("relay-supplied-options"); +} + +void +AdaptorConfig::preProcess(ElementPtr dhcp, const string& subsel, + const string& space) { + if (!dhcp) { + isc_throw(BadValue, "preProcess: null DHCP config"); + } + bool have_ids = true; + SubnetIDSet set; + ConstElementPtr subnets = dhcp->get(subsel); + if (subnets) { + if (!subnets->empty()) { + if (!subnetsCollectID(subnets, set)) { + have_ids = false; + } + } else { + dhcp->remove(subsel); + } + } + ConstElementPtr networks = dhcp->get("shared-networks"); + if (networks) { + if (!networks->empty()) { + if (!sharedNetworksCollectID(networks, set, subsel)) { + have_ids = false; + } + } else { + dhcp->remove("shared-networks"); + } + } + + if (!have_ids) { + SubnetID next(1); + subnetsAssignID(subnets, set, next); + sharedNetworksAssignID(networks, set, next, subsel); + } + + OptionCodes codes; + initCodes(codes, space);; + ConstElementPtr defs = dhcp->get("option-def"); + if (defs) { + if (!defs->empty()) { + sanitizeOptionDefList(defs, space, codes); + } else { + dhcp->remove("option-def"); + } + } + ConstElementPtr options = dhcp->get("option-data"); + if (options) { + if (!options->empty()) { + sanitizeOptionDataList(options, space, codes); + } else { + dhcp->remove("option-data"); + } + } + ConstElementPtr classes = dhcp->get("client-classes"); + if (classes) { + if (!classes->empty()) { + sanitizeOptionClasses(classes, space, codes); + } else { + dhcp->remove("client-classes"); + } + } + ConstElementPtr hosts = dhcp->get("reservations"); + if (hosts) { + if (!hosts->empty()) { + sanitizeHostList(hosts); + sanitizeOptionHosts(hosts, space, codes); + } else { + dhcp->remove("reservations"); + } + } + sanitizeOptionSubnets(subnets, space, codes); + sanitizeOptionSharedNetworks(networks, space, codes); + + sanitizePoolsInSubnets(subnets); + sanitizePoolsInSharedNetworks(networks, subsel); + + sanitizeHostSubnets(subnets); + SanitizeHostsInSharedNetworks(networks, space); + + sanitizeRelaySubnets(subnets); + sanitizeRelayInSharedNetworks(networks, subsel); + + sanitizeRequireClassesSubnets(subnets); + requireClassesSharedNetworks(networks, subsel); + + sanitizeDatabase(dhcp); + + if (space == DHCP6_SPACE) { + sanitizeRelaySuppliedOptions(dhcp); + } +} + +void +AdaptorConfig::preProcess4(ConstElementPtr config) { + if (!config) { + isc_throw(BadValue, "preProcess4: null config"); + } + if (config->getType() != Element::map) { + isc_throw(BadValue, "preProcess4: not map: " << config->str()); + } + if (config->contains("Logging")) { + isc_throw(BadValue, "preProcess4: got Logging object"); + } + ConstElementPtr dhcp = config->get("Dhcp4"); + if (!dhcp) { + return; + } + ElementPtr mutable_dhcp = boost::const_pointer_cast(dhcp); + preProcess(mutable_dhcp, "subnet4", DHCP4_SPACE); +} + +void +AdaptorConfig::preProcess6(ConstElementPtr config) { + if (!config) { + isc_throw(BadValue, "preProcess6: null config"); + } + if (config->getType() != Element::map) { + isc_throw(BadValue, "preProcess6: not map: " << config->str()); + } + if (config->contains("Logging")) { + isc_throw(BadValue, "preProcess6: got Logging object"); + } + ConstElementPtr dhcp = config->get("Dhcp6"); + if (!dhcp) { + return; + } + ElementPtr mutable_dhcp = boost::const_pointer_cast(dhcp); + preProcess(mutable_dhcp, "subnet6", DHCP6_SPACE); +} + +} // end of namespace isc::yang +} // end of namespace isc diff --git a/src/lib/yang/adaptor_config.h b/src/lib/yang/adaptor_config.h new file mode 100644 index 0000000..88cfd4c --- /dev/null +++ b/src/lib/yang/adaptor_config.h @@ -0,0 +1,292 @@ +// 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 ISC_ADAPTOR_CONFIG_H +#define ISC_ADAPTOR_CONFIG_H 1 + +#include +#include +#include +#include +#include + +namespace isc { +namespace yang { + +/// @brief JSON adaptor for Kea server configurations. +/// +/// Currently only from JSON to YANG for DHCPv4 and DHCPv6 available +/// as preProcess4 and preProcess6 class methods, filling some required +/// (by YANG) fields (e.g. subnet IDs, or option code and space), or +/// transforming a hand-written JSON configuration into a canonical form. +class AdaptorConfig : public AdaptorHost, public AdaptorOption, + public AdaptorSubnet { +public: + + /// @brief Constructor. + AdaptorConfig(); + + /// @brief Destructor. + virtual ~AdaptorConfig(); + + /// @brief Pre process a DHCPv4 configuration. + /// + /// Assign subnet IDs, check and set defaults in options, etc. + /// Note even though the parameter is a ConstElementPtr and is not modified, + /// sub-structures can modify it, so if you need a copy do a deep one. + /// + /// @param config The configuration. + /// @throw MissingKey when a required key is missing. + /// @throw BadValue when null or not a map or deprecated Logging present. + /// @note Does nothing if "Dhcp4" is not present in the map. + static void preProcess4(isc::data::ConstElementPtr config); + + /// @brief Pre process a DHCPv6 configuration. + /// + /// Assign subnet IDs, check and set default in options, etc. + /// Note even though the parameter is a ConstElementPtr and is not modified, + /// sub-structures can modify it, so if you need a copy do a deep one. + /// + /// @param config The configuration. + /// @throw MissingKey when a required key is missing. + /// @throw BadValue when null or not a map or deprecated Logging present. + /// @note Does nothing if "Dhcp6" is not present in the map. + static void preProcess6(isc::data::ConstElementPtr config); + +protected: + /// @brief Collects subnet-ids on all subnets. + /// + /// It will go over all subnets and collect their ids. It will then return + /// true if all subnets have ids. If the subnets list is empty, it will also + /// return true. False will be returned if there is at least one subnet that + /// doesn't have subnet-id. + /// + /// @param subnets The subnet list. + /// @param set The reference to the set of assigned IDs. + /// @return True if all subnets have an ID, false otherwise. + static bool subnetsCollectID(isc::data::ConstElementPtr subnets, + SubnetIDSet& set); + + /// @brief Collects subnet-ids in all subnets in all shared network list. + /// + /// It will go over all subnets in all shared networks specified to collect + /// their subnet-ids. It will then return true if all subnets have ids. If + /// the subnets list is empty, it will also return true. False will be + /// returned if there is at least one subnet that doesn't have subnet-id. + /// + /// @param networks The shared network list. + /// @param set The reference to the set of assigned IDs. + /// @param subsel The subnet list name. + /// @return True if all subnets have an ID, false otherwise. + static bool sharedNetworksCollectID(isc::data::ConstElementPtr networks, + SubnetIDSet& set, + const std::string& subsel); + + /// @brief Assigns subnet-id to every subnet in a subnet list. + /// + /// Only those subnets that don't have one subnet-id assigned yet, + /// will get a new subnet-id value. + /// + /// @param subnets The subnet list. + /// @param set The reference to the set of assigned IDs. + /// @param next The next ID. + static void subnetsAssignID(isc::data::ConstElementPtr subnets, + SubnetIDSet& set, isc::dhcp::SubnetID& next); + + /// @brief Assigns subnet-id to every subnet in a shared network list. + /// + /// Only those subnets that don't have one subnet-id assigned yet, + /// will get a new subnet-id value. + /// + /// @param networks The shared network list. + /// @param set The reference to the set of assigned IDs. + /// @param next The next ID. + /// @param subsel The subnet list name. + static void sharedNetworksAssignID(isc::data::ConstElementPtr networks, + SubnetIDSet& set, + isc::dhcp::SubnetID& next, + const std::string& subsel); + + /// @brief Sanitizes all pools in a pools list. + /// + /// Goes over each pool and cleans up its definition (removes extra spaces, + /// adds one space before and after - ). + /// + /// @param pools The pool list. + static void sanitizePools(isc::data::ConstElementPtr pools); + + /// @brief Sanitizes all pools in a subnets list. + /// + /// @param subnets The subnet list. + static void sanitizePoolsInSubnets(isc::data::ConstElementPtr subnets); + + /// @brief Sanitizes all pools in all subnets in a shared network list. + /// + /// @param networks The shared network list. + /// @param subsel The subnet list name. + static void sanitizePoolsInSharedNetworks(isc::data::ConstElementPtr networks, + const std::string& subsel); + + /// @brief Collect option definitions from an option definition list. + /// + /// Collects options definitions, but also sets missing option space + /// with default. + /// + /// @param defs The option definition list. + /// @param space The default space name (missing will be filled with this) + /// @param codes Option definitions. + static void sanitizeOptionDefList(isc::data::ConstElementPtr defs, + const std::string& space, + OptionCodes& codes); + + /// @brief Set missing option codes to an option data list. + /// + /// @param options The option data list. + /// @param space The default space name. + /// @param codes Option definitions. + static void sanitizeOptionDataList(isc::data::ConstElementPtr options, + const std::string& space, + const OptionCodes& codes); + + /// @brief Collect option definitions from a client class list + /// and set missing option codes. + /// + /// @param classes The client class list. + /// @param space The default space name. + /// @param codes Option definitions. + static void sanitizeOptionClasses(isc::data::ConstElementPtr classes, + const std::string& space, + OptionCodes& codes); + + /// @brief Set missing option codes to a pool list. + /// + /// @param pools The pool list. + /// @param space The default space name. + /// @param codes Option definitions. + static void sanitizeOptionPools(isc::data::ConstElementPtr pools, + const std::string& space, + const OptionCodes& codes); + + /// @brief Set missing option codes to a host reservation list. + /// + /// @param hosts The host reservation list. + /// @param space The default space name. + /// @param codes Option definitions. + static void sanitizeOptionHosts(isc::data::ConstElementPtr hosts, + const std::string& space, + const OptionCodes& codes); + + /// @brief Set missing option codes to a subnet list. + /// + /// @param subnets The subnet list. + /// @param space The default space name. + /// @param codes Option definitions. + static void sanitizeOptionSubnets(isc::data::ConstElementPtr subnets, + const std::string& space, + const OptionCodes& codes); + + /// @brief Set missing option codes to a shared network list. + /// + /// @param networks The shared network list. + /// @param space The default space name. + /// @param codes Option definitions. + static void sanitizeOptionSharedNetworks(isc::data::ConstElementPtr networks, + const std::string& space, + const OptionCodes& codes); + + /// @brief Process require client classes in a pool list. + /// + /// Remove empty require client class list. + /// + /// @param pools The pool list. + static void sanitizeRequireClassesPools(isc::data::ConstElementPtr pools); + + /// @brief Process require client classes in a subnet list. + /// + /// Remove empty require client class lists. + /// + /// @param subnets The subnet list. + static void sanitizeRequireClassesSubnets(isc::data::ConstElementPtr subnets); + + /// @brief Process require client classes in a shared network list. + /// + /// Remove empty require client class lists. + /// + /// @param networks The shared network list. + /// @param subsel The subnet list name. + static void requireClassesSharedNetworks(isc::data::ConstElementPtr networks, + const std::string& subsel); + + /// @brief Process host reservation list. + /// + /// Quote when needed flex-id identifiers. + /// + /// @param hosts The host reservation list. + static void sanitizeHostList(isc::data::ConstElementPtr hosts); + + /// @brief Process host reservations in a subnet list. + /// + /// Quote when needed flex-id identifiers. + /// + /// @param subnets The subnet list. + static void sanitizeHostSubnets(isc::data::ConstElementPtr subnets); + + /// @brief Process host reservations in a shared network list. + /// + /// Quote when needed flex-id identifiers. + /// + /// @param networks The shared network list. + /// @param space The default space name. + static void SanitizeHostsInSharedNetworks(isc::data::ConstElementPtr networks, + const std::string& space); + + /// @brief Sanitizes relay information in subnets in a subnet list. + /// + /// Force the use of ip-addresses when it finds an ip-address entry. + /// + /// @param subnets The subnet list. + static void sanitizeRelaySubnets(isc::data::ConstElementPtr subnets); + + /// @brief Sanitizes relay information in a shared network list. + /// + /// Force the use of ip-addresses when it finds an ip-address entry. + /// + /// @param networks The shared network list. + /// @param subsel The subnet list name. + static void sanitizeRelayInSharedNetworks(isc::data::ConstElementPtr networks, + const std::string& subsel); + + /// @brief Update (hosts) database. + /// + /// Force the use of hosts-databases vs. hosts-database. + /// + /// @param dhcp The DHCP server. + static void sanitizeDatabase(isc::data::ConstElementPtr dhcp); + + /// @brief Update relay supplied options. + /// + /// Remove empty relay supplied option list. + /// + /// @param dhcp The DHCPv6 server. + static void sanitizeRelaySuppliedOptions(isc::data::ConstElementPtr dhcp); + + /// @brief Pre process a configuration. + /// + /// Assign subnet IDs, check and set default in options, etc. + /// + /// @param dhcp The server configuration. + /// @param subsel The subnet list name. + /// @param space The default option space name. + /// @throw MissingKey when a required key is missing. + static void preProcess(isc::data::ElementPtr dhcp, + const std::string& subsel, + const std::string& space); +}; + +} // end of namespace isc::yang +} // end of namespace isc + +#endif // ISC_ADAPTOR_CONFIG_H diff --git a/src/lib/yang/adaptor_host.cc b/src/lib/yang/adaptor_host.cc new file mode 100644 index 0000000..9df7d5b --- /dev/null +++ b/src/lib/yang/adaptor_host.cc @@ -0,0 +1,68 @@ +// 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 + +#include +#include +#include +#include +#include + +using namespace std; +using namespace isc::data; +using namespace isc::util; + +namespace isc { +namespace yang { + +const string +AdaptorHost::STD_CHARACTERS = + "0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-.@_"; + +AdaptorHost::AdaptorHost() { +} + +AdaptorHost::~AdaptorHost() { +} + +void +AdaptorHost::quoteIdentifier(ElementPtr host) { + ConstElementPtr flex_id = host->get("flex-id"); + if (!flex_id) { + return; + } + const string& id = flex_id->stringValue(); + // Empty is allowed. + if (id.empty()) { + return; + } + // No special and no not printable characters? + if (id.find_first_not_of(STD_CHARACTERS) == string::npos) { + return; + } + // Quoted identifier? + vector binary = str::quotedStringToBinary(id); + if (binary.empty()) { + binary.assign(id.begin(), id.end()); + } + // Convert in hexadecimal (from DUID::toText()). + stringstream tmp; + tmp << hex; + bool delim = false; + for (vector::const_iterator it = binary.begin(); + it != binary.end(); ++it) { + if (delim) { + tmp << ":"; + } + tmp << setw(2) << setfill('0') << static_cast(*it); + delim = true; + } + host->set("flex-id", Element::create(tmp.str())); +} + +} // end of namespace isc::yang +} // end of namespace isc diff --git a/src/lib/yang/adaptor_host.h b/src/lib/yang/adaptor_host.h new file mode 100644 index 0000000..62f80c1 --- /dev/null +++ b/src/lib/yang/adaptor_host.h @@ -0,0 +1,47 @@ +// 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 ISC_ADAPTOR_HOST_H +#define ISC_ADAPTOR_HOST_H 1 + +#include + +namespace isc { +namespace yang { + +/// @brief JSON adaptor for host reservations quoting identifiers. +/// +/// The identifier type and identifier value are used as keys in YANG +/// host reservation lists so some constraints were put on their contents. +/// For instance a quoted flex-id identifier raises an error (keys +/// are between quotes in setItem commands). +class AdaptorHost { +public: + + /// @brief The string of standard (vs special or not printable) + /// characters (digit, letters, -, ., @, _). + static const std::string STD_CHARACTERS; + + /// @brief Constructor. + AdaptorHost(); + + /// @brief Destructor. + virtual ~AdaptorHost(); + + /// @brief Quote when needed a host identifier. + /// + /// Check if the flex-id identifier includes a special (including quote) + /// or not printable character. When it is the case produce and replace + /// by a hexadecimal identifier trying first for a quoted identifier. + /// + /// @param host The host. + static void quoteIdentifier(isc::data::ElementPtr host); +}; + +} // end of namespace isc::yang +} // end of namespace isc + +#endif // ISC_ADAPTOR_HOST_H diff --git a/src/lib/yang/adaptor_option.cc b/src/lib/yang/adaptor_option.cc new file mode 100644 index 0000000..c40554a --- /dev/null +++ b/src/lib/yang/adaptor_option.cc @@ -0,0 +1,128 @@ +// 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 + +#include +#include +#include + +using namespace std; +using namespace isc::data; +using namespace isc::dhcp; + +namespace isc { +namespace yang { + +AdaptorOption::AdaptorOption() { +} + +AdaptorOption::~AdaptorOption() { +} + +void +AdaptorOption::setSpace(ElementPtr option, const string& space) { + if (!option->contains("space")) { + option->set("space", Element::create(space)); + } +} + +void +AdaptorOption::checkType(ConstElementPtr option) { + if (!option->contains("type")) { + isc_throw(MissingKey, "missing type in option definition " + << option->str()); + } +} + +void +AdaptorOption::checkCode(ConstElementPtr option) { + if (!option->contains("code")) { + isc_throw(MissingKey, "missing code in option " << option->str()); + } +} + +void +AdaptorOption::collect(ConstElementPtr option, OptionCodes& codes) { + ConstElementPtr name = option->get("name"); + if (name) { + ConstElementPtr space = option->get("space"); + ConstElementPtr code = option->get("code"); + string index = space->stringValue() + "@" + name->stringValue(); + uint16_t val = static_cast(code->intValue()); + codes.insert(std::pair(index, val)); + } +} + +void +AdaptorOption::setCode(ElementPtr option, const OptionCodes& codes) { + ConstElementPtr code = option->get("code"); + if (!code) { + ConstElementPtr name = option->get("name"); + if (!name) { + isc_throw(MissingKey, "missing name and code in option " + << option->str()); + } + ConstElementPtr space = option->get("space"); + string index = space->stringValue() + "@" + name->stringValue(); + OptionCodes::const_iterator it = codes.find(index); + if (it == codes.end()) { + isc_throw(MissingKey, "can't get code from option " + << option->str()); + } + option->set("code", Element::create(static_cast(it->second))); + } +} + +void +AdaptorOption::initCodes(OptionCodes& codes, const string& space) { + if (space == DHCP4_OPTION_SPACE) { + initCodesInternal(codes, space, STANDARD_V4_OPTION_DEFINITIONS, + STANDARD_V4_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, space, LAST_RESORT_V4_OPTION_DEFINITIONS, + LAST_RESORT_V4_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, "vendor-4491", + DOCSIS3_V4_OPTION_DEFINITIONS, + DOCSIS3_V4_OPTION_DEFINITIONS_SIZE); + } else if (space == DHCP6_OPTION_SPACE) { + initCodesInternal(codes, space, STANDARD_V6_OPTION_DEFINITIONS, + STANDARD_V6_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, "vendor-4491", + DOCSIS3_V6_OPTION_DEFINITIONS, + DOCSIS3_V6_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, MAPE_V6_OPTION_SPACE, + MAPE_V6_OPTION_DEFINITIONS, + MAPE_V6_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, MAPT_V6_OPTION_SPACE, + MAPT_V6_OPTION_DEFINITIONS, + MAPT_V6_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, LW_V6_OPTION_SPACE, + LW_V6_OPTION_DEFINITIONS, + LW_V6_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, V4V6_RULE_OPTION_SPACE, + V4V6_RULE_OPTION_DEFINITIONS, + V4V6_RULE_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, V4V6_BIND_OPTION_SPACE, + V4V6_BIND_OPTION_DEFINITIONS, + V4V6_BIND_OPTION_DEFINITIONS_SIZE); + initCodesInternal(codes, "vendor-2495", + ISC_V6_OPTION_DEFINITIONS, + ISC_V6_OPTION_DEFINITIONS_SIZE); + } +} + +void +AdaptorOption::initCodesInternal(OptionCodes& codes, const string& space, + const OptionDefParams* params, + size_t params_size) { + for (size_t i = 0; i < params_size; ++i) { + string index = space + "@" + params[i].name; + codes.insert(std::pair(index, params[i].code)); + } +} + +} // end of namespace isc::yang +} // end of namespace isc diff --git a/src/lib/yang/adaptor_option.h b/src/lib/yang/adaptor_option.h new file mode 100644 index 0000000..a3842c7 --- /dev/null +++ b/src/lib/yang/adaptor_option.h @@ -0,0 +1,111 @@ +// 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 ISC_ADAPTOR_OPTION_H +#define ISC_ADAPTOR_OPTION_H 1 + +#include +#include +#include + +namespace isc { + +namespace dhcp { +/// @brief Forward declaration of option definition parameters. +struct OptionDefParams; +}; + +namespace yang { + +/// @brief Map for DHCP option definitions handling code and +/// an index built from space and name. +/// +/// The map is used to store space+name to code mappings so for +/// an option data without a code entry the code entry can be supplied. +typedef std::map OptionCodes; + +/// @brief JSON adaptor for option data or definition setting defaults. +/// +/// Both option data and option definition lists are keyed by the code +/// and space pair so both must be available in setOptionXXX methods. +/// For space there is an implicit default so setSpace must be called +/// to add this default to option entries without space. +/// Note remaining adaptors assume this was done first. +/// +/// checkCode and checkType can be used to check if code or type is present +/// (type is mandatory in option definitions). +/// +/// A missing code can be found in standard definitions (loaded by initCodes) +/// or in configuration option definitions (at global and client classes +/// scopes). setCode uses the space+name to code map to set missing codes +/// and raises an error when it can't. +class AdaptorOption { +public: + + /// @brief Constructor. + AdaptorOption(); + + /// @brief Destructor. + virtual ~AdaptorOption(); + + /// @brief Set space. + /// + /// @param option The option. + /// @param space The default space name. + static void setSpace(isc::data::ElementPtr option, + const std::string& space); + + /// @brief Checks if type is specified in option definition. + /// + /// @param option The option. + /// @throw MissingKey if the type is not present. + static void checkType(isc::data::ConstElementPtr option); + + /// @brief Check if code is specified in option defintion. + /// + /// @param option The option. + /// @throw MissingKey if the code is not present. + static void checkCode(isc::data::ConstElementPtr option); + + /// @brief Collect definition. + /// + /// This method looks at an option definition and adds the + /// space+name to code mapping into the OptionCodes codes store + /// aka definitions. + /// + /// @param option The option definition. + /// @param codes The reference to option definitions. + static void collect(isc::data::ConstElementPtr option, OptionCodes& codes); + + /// @brief Set code from name and definitions. + /// + /// @param option The option data. + /// @param codes Option definitions. + static void setCode(isc::data::ElementPtr option, + const OptionCodes& codes); + + /// @brief Initialize code map. + /// + /// @param codes The reference to option definitions. + /// @param space The space name. + static void initCodes(OptionCodes& codes, const std::string& space); + +protected: + /// @brief Initialize code map from option definition parameters. + /// + /// @param codes The reference to option definitions. + /// @param space The space name. + /// @param params Array of option definition parameters + /// @param params_size The size of the array. + static void initCodesInternal(OptionCodes& codes, const std::string& space, + const isc::dhcp::OptionDefParams* params, + size_t params_size); +}; + +} // end of namespace isc::yang +} // end of namespace isc + +#endif // ISC_ADAPTOR_OPTION_H diff --git a/src/lib/yang/adaptor_pool.cc b/src/lib/yang/adaptor_pool.cc new file mode 100644 index 0000000..4a84bc0 --- /dev/null +++ b/src/lib/yang/adaptor_pool.cc @@ -0,0 +1,87 @@ +// 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 + +#include +#include + +using namespace std; +using namespace isc::data; + +namespace isc { +namespace yang { + +AdaptorPool::AdaptorPool() { +} + +AdaptorPool::~AdaptorPool() { +} + +void +AdaptorPool::canonizePool(ElementPtr pool) { + const string& orig = pool->get("pool")->stringValue(); + vector v; + for (char ch : orig) { + if ((ch == ' ') || (ch == '\t') || (ch == '\n')) { + continue; + } else if (ch == '-') { + v.push_back(' '); + v.push_back(ch); + v.push_back(' '); + } else { + v.push_back(ch); + } + } + string canon; + canon.assign(v.begin(), v.end()); + if (orig != canon) { + pool->set("pool", Element::create(canon)); + } +} + +void +AdaptorPool::fromSubnet(const string& model, ConstElementPtr subnet, + ConstElementPtr pools) { + if (model == IETF_DHCPV6_SERVER) { + fromSubnetIetf6(subnet, pools); + } else if ((model != KEA_DHCP4_SERVER) && + (model != KEA_DHCP6_SERVER)) { + isc_throw(NotImplemented, + "fromSubnet not implemented for the model: " << model); + } +} + +void +AdaptorPool::fromSubnetIetf6(ConstElementPtr subnet, ConstElementPtr pools) { + Adaptor::fromParent("valid-lifetime", subnet, pools); + Adaptor::fromParent("preferred-lifetime", subnet, pools); + Adaptor::fromParent("renew-timer", subnet, pools); + Adaptor::fromParent("rebind-timer", subnet, pools); +} + +void +AdaptorPool::toSubnet(const string& model, ElementPtr subnet, + ConstElementPtr pools) { + if (model == IETF_DHCPV6_SERVER) { + toSubnetIetf6(subnet, pools); + } else if ((model != KEA_DHCP4_SERVER) && + (model != KEA_DHCP6_SERVER)) { + isc_throw(NotImplemented, + "toSubnet not implemented for the model: " << model); + } +} + +void +AdaptorPool::toSubnetIetf6(ElementPtr subnet, ConstElementPtr pools) { + Adaptor::toParent("valid-lifetime", subnet, pools); + Adaptor::toParent("preferred-lifetime", subnet, pools); + Adaptor::toParent("renew-timer", subnet, pools); + Adaptor::toParent("rebind-timer", subnet, pools); +} + +} // end of namespace isc::yang +} // end of namespace isc diff --git a/src/lib/yang/adaptor_pool.h b/src/lib/yang/adaptor_pool.h new file mode 100644 index 0000000..2c92681 --- /dev/null +++ b/src/lib/yang/adaptor_pool.h @@ -0,0 +1,98 @@ +// 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 ISC_ADAPTOR_POOL_H +#define ISC_ADAPTOR_POOL_H 1 + +#include +#include + +namespace isc { +namespace yang { + +/// @brief JSON adaptor for pools between canonical Kea and YANG models. +/// +/// First adaptor canonizePool checks and fixes if needed the pool entry +/// to a canonical form which is no space for prefix and one space each +/// side of the minus character for ranges. +/// +/// Second adaptor is specific to the IETF DHCPv6 model (and does nothing +/// with a Kea DHCP model): it moves timer definitions from the subnet scope, +/// i.e. the scope where they are in Kea, to the pool scope, i.e. the scope +/// where they are in the IETF model, and back. The from way leaves timers +/// in the subnet scope as they are ignored by the translator, the to way +/// removes timers from pools as they are not expected by Kea at this scope. +class AdaptorPool { +public: + + /// @brief Constructor. + AdaptorPool(); + + /// @brief Destructor. + virtual ~AdaptorPool(); + + /// @brief Canonize pool. + /// + /// Remove spaces and replace "-" by " - " for readability. + /// @param pool The pool. + static void canonizePool(isc::data::ElementPtr pool); + + /// @brief Moves parameters from subnets to pools. + /// + /// Move parameters from the subnet to each pool. Currently the only + /// supported model is ietf-dhcpv6-server. The parameters moved are + /// valid-lifetime, preferred-lifetime, renew-timer, rebind-timer. + /// + /// @param model Model name. + /// @param subnet The subnet element. + /// @param pools The children pools. + /// @throw NotImplemented on unexpected model. + static void fromSubnet(const std::string& model, + isc::data::ConstElementPtr subnet, + isc::data::ConstElementPtr pools); + + /// @brief Move parameters from pools to the subnet. + /// + /// Move parameters from pool to its parent subnet. Currently the only + /// supported model is ietf-dhcpv6-server. The parameters moved are + /// valid-lifetime, preferred-lifetime, renew-timer, rebind-timer. + /// + /// @note: currently it is the only from YANG to JSON aka + /// post-processing adaptor. + /// + /// @param model Model name. + /// @param subnet The subnet element. + /// @param pools The children pools. + /// @throw NotImplemented on unexpected model. + /// @throw BadValue on inconsistent (different timer values) pools. + static void toSubnet(const std::string& model, + isc::data::ElementPtr subnet, + isc::data::ConstElementPtr pools); + +protected: + /// @brief From subnets for ietf-dhcpv6-server. + /// + /// Use common and move valid-lifetime and preferred-lifetime. + /// + /// @param subnet The subnet element. + /// @param pools The children pools. + static void fromSubnetIetf6(isc::data::ConstElementPtr subnet, + isc::data::ConstElementPtr pools); + + /// @brief To subnet for ietf-dhcpv6-server. + /// + /// Use common and move valid-lifetime and preferred-lifetime. + /// + /// @param subnet The subnet element. + /// @param pools The children pools. + static void toSubnetIetf6(isc::data::ElementPtr subnet, + isc::data::ConstElementPtr pools); +}; + +} // end of namespace isc::yang +} // end of namespace isc + +#endif // ISC_ADAPTOR_POOL_H diff --git a/src/lib/yang/adaptor_subnet.cc b/src/lib/yang/adaptor_subnet.cc new file mode 100644 index 0000000..5e4d6f3 --- /dev/null +++ b/src/lib/yang/adaptor_subnet.cc @@ -0,0 +1,73 @@ +// 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 + +#include + +using namespace std; +using namespace isc::data; +using namespace isc::dhcp; + +namespace isc { +namespace yang { + +AdaptorSubnet::AdaptorSubnet() { +} + +AdaptorSubnet::~AdaptorSubnet() { +} + +bool +AdaptorSubnet::collectID(ConstElementPtr subnet, SubnetIDSet& set) { + ConstElementPtr id = subnet->get("id"); + if (id) { + set.insert(static_cast(id->intValue())); + return (true); + } + return (false); +} + +void +AdaptorSubnet::assignID(ElementPtr subnet, SubnetIDSet& set, SubnetID& next) { + ConstElementPtr id = subnet->get("id"); + if (!id) { + // Skip already used. + while (set.count(next) > 0) { + ++next; + } + subnet->set("id", Element::create(static_cast(next))); + set.insert(next); + ++next; + } +} + +void +AdaptorSubnet::updateRelay(ElementPtr subnet) { + ConstElementPtr relay = subnet->get("relay"); + if (!relay) { + return; + } + ConstElementPtr addresses = relay->get("ip-addresses"); + if (!addresses) { + ConstElementPtr address = relay->get("ip-address"); + if (!address) { + subnet->remove("relay"); + return; + } + ElementPtr addr = Element::create(address->stringValue()); + ElementPtr addrs = Element::createList(); + addrs->add(addr); + ElementPtr updated = Element::createMap(); + updated->set("ip-addresses", addrs); + subnet->set("relay", updated); + } else if (addresses->size() == 0) { + subnet->remove("relay"); + } +} + +} // end of namespace isc::yang +} // end of namespace isc diff --git a/src/lib/yang/adaptor_subnet.h b/src/lib/yang/adaptor_subnet.h new file mode 100644 index 0000000..acdf541 --- /dev/null +++ b/src/lib/yang/adaptor_subnet.h @@ -0,0 +1,66 @@ +// 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 ISC_ADAPTOR_SUBNET_H +#define ISC_ADAPTOR_SUBNET_H 1 + +#include +#include +#include + +namespace isc { +namespace yang { + +/// @brief Set of SubnetIDs. +typedef std::set SubnetIDSet; + +/// @brief JSON adaptor for subnets adding IDs and canonizes relays. +/// +/// Adding IDs is done in two passes walking through subnets. +/// -1- Add in the set used values and return false when there is no ID +/// so the caller can decide if the second pass is needed. +/// -2- For a subnet without an ID, assigned the next unused ID. +/// +/// For relays an old syntax ip-address is translated into a new syntax +/// ip-addresses. Note as all canonization adaptor it is optional, i.e., +/// code should work without it. +class AdaptorSubnet { +public: + + /// @brief Constructor. + AdaptorSubnet(); + + /// @brief Destructor. + virtual ~AdaptorSubnet(); + + /// @brief Collect a subnet ID. + /// + /// @param subnet The subnet. + /// @param set The reference to the set of assigned IDs. + /// @return True if the subnet has an ID, false otherwise. + static bool collectID(isc::data::ConstElementPtr subnet, SubnetIDSet& set); + + /// @brief Assign subnet ID. + /// + /// @param subnet The subnet. + /// @param set The reference to the set of assigned IDs. + /// @param next The next ID. + static void assignID(isc::data::ElementPtr subnet, SubnetIDSet& set, + isc::dhcp::SubnetID& next); + + /// @brief Update relay. + /// + /// Force the use of ip-addresses when it finds an ip-address entry. + /// Can be used for shared networks too. + /// + /// @param subnet The subnet. + static void updateRelay(isc::data::ElementPtr subnet); +}; + +} // end of namespace isc::yang +} // end of namespace isc + +#endif // ISC_ADAPTOR_SUBNET_H diff --git a/src/lib/yang/pretests/Makefile.am b/src/lib/yang/pretests/Makefile.am new file mode 100644 index 0000000..e27e503 --- /dev/null +++ b/src/lib/yang/pretests/Makefile.am @@ -0,0 +1,14 @@ +CLEANFILES = *.gcno *.gcda + +TESTS = sysrepo_setup_tests + +sysrepo_setup_tests_SOURCES = sysrepo_setup_tests.cc +sysrepo_setup_tests_CPPFLAGS = -I$(top_builddir)/src/lib +sysrepo_setup_tests_CPPFLAGS += -I$(top_srcdir)/src/lib +sysrepo_setup_tests_CPPFLAGS += $(SYSREPO_CPPFLAGS) +sysrepo_setup_tests_CPPFLAGS += $(SYSREPO_INCLUDEDIR) +sysrepo_setup_tests_CPPFLAGS += -DSYSREPO_REPO=\"@SR_REPO_PATH@\" +sysrepo_setup_tests_LDFLAGS = $(AM_LDFLAGS) +sysrepo_setup_tests_LDADD = $(SYSREPO_LIBS) + +noinst_PROGRAMS = $(TESTS) diff --git a/src/lib/yang/pretests/Makefile.in b/src/lib/yang/pretests/Makefile.in new file mode 100644 index 0000000..9203afe --- /dev/null +++ b/src/lib/yang/pretests/Makefile.in @@ -0,0 +1,823 @@ +# 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 = sysrepo_setup_tests$(EXEEXT) +noinst_PROGRAMS = $(am__EXEEXT_1) +subdir = src/lib/yang/pretests +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4macros/ax_boost_for_kea.m4 \ + $(top_srcdir)/m4macros/ax_cpp11.m4 \ + $(top_srcdir)/m4macros/ax_crypto.m4 \ + $(top_srcdir)/m4macros/ax_find_library.m4 \ + $(top_srcdir)/m4macros/ax_gssapi.m4 \ + $(top_srcdir)/m4macros/ax_gtest.m4 \ + $(top_srcdir)/m4macros/ax_isc_rpath.m4 \ + $(top_srcdir)/m4macros/ax_sysrepo.m4 \ + $(top_srcdir)/m4macros/libtool.m4 \ + $(top_srcdir)/m4macros/ltoptions.m4 \ + $(top_srcdir)/m4macros/ltsugar.m4 \ + $(top_srcdir)/m4macros/ltversion.m4 \ + $(top_srcdir)/m4macros/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__EXEEXT_1 = sysrepo_setup_tests$(EXEEXT) +PROGRAMS = $(noinst_PROGRAMS) +am_sysrepo_setup_tests_OBJECTS = \ + sysrepo_setup_tests-sysrepo_setup_tests.$(OBJEXT) +sysrepo_setup_tests_OBJECTS = $(am_sysrepo_setup_tests_OBJECTS) +am__DEPENDENCIES_1 = +sysrepo_setup_tests_DEPENDENCIES = $(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 = +sysrepo_setup_tests_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ + $(AM_CXXFLAGS) $(CXXFLAGS) $(sysrepo_setup_tests_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)/sysrepo_setup_tests-sysrepo_setup_tests.Po +am__mv = mv -f +CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) +LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \ + $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ + $(AM_CXXFLAGS) $(CXXFLAGS) +AM_V_CXX = $(am__v_CXX_@AM_V@) +am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@) +am__v_CXX_0 = @echo " CXX " $@; +am__v_CXX_1 = +CXXLD = $(CXX) +CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \ + $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ +AM_V_CXXLD = $(am__v_CXXLD_@AM_V@) +am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@) +am__v_CXXLD_0 = @echo " CXXLD " $@; +am__v_CXXLD_1 = +SOURCES = $(sysrepo_setup_tests_SOURCES) +DIST_SOURCES = $(sysrepo_setup_tests_SOURCES) +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_GTEST_CONFIGURE_FLAG = @DISTCHECK_GTEST_CONFIGURE_FLAG@ +DISTCHECK_KEA_SHELL_CONFIGURE_FLAG = @DISTCHECK_KEA_SHELL_CONFIGURE_FLAG@ +DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG = @DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG@ +DISTCHECK_PERFDHCP_CONFIGURE_FLAG = @DISTCHECK_PERFDHCP_CONFIGURE_FLAG@ +DISTCHECK_PREMIUM_CONFIGURE_FLAG = @DISTCHECK_PREMIUM_CONFIGURE_FLAG@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GENHTML = @GENHTML@ +GREP = @GREP@ +GSSAPI_CFLAGS = @GSSAPI_CFLAGS@ +GSSAPI_LIBS = @GSSAPI_LIBS@ +GTEST_CONFIG = @GTEST_CONFIG@ +GTEST_INCLUDES = @GTEST_INCLUDES@ +GTEST_LDADD = @GTEST_LDADD@ +GTEST_LDFLAGS = @GTEST_LDFLAGS@ +GTEST_SOURCE = @GTEST_SOURCE@ +HAVE_SYSREPO = @HAVE_SYSREPO@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KEA_CXXFLAGS = @KEA_CXXFLAGS@ +KEA_SRCID = @KEA_SRCID@ +KRB5_CONFIG = @KRB5_CONFIG@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOG4CPLUS_INCLUDES = @LOG4CPLUS_INCLUDES@ +LOG4CPLUS_LIBS = @LOG4CPLUS_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ +MYSQL_LIBS = @MYSQL_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_VERSION_TYPE = @PACKAGE_VERSION_TYPE@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PDFLATEX = @PDFLATEX@ +PERL = @PERL@ +PGSQL_CPPFLAGS = @PGSQL_CPPFLAGS@ +PGSQL_LIBS = @PGSQL_LIBS@ +PKGPYTHONDIR = @PKGPYTHONDIR@ +PKG_CONFIG = @PKG_CONFIG@ +PLANTUML = @PLANTUML@ +PREMIUM_DIR = @PREMIUM_DIR@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +SED = @SED@ +SEP = @SEP@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPHINXBUILD = @SPHINXBUILD@ +SRPD_PLUGINS_PATH = @SRPD_PLUGINS_PATH@ +SR_REPO_PATH = @SR_REPO_PATH@ +STRIP = @STRIP@ +SYSREPOCPP_VERSION = @SYSREPOCPP_VERSION@ +SYSREPO_CPPFLAGS = @SYSREPO_CPPFLAGS@ +SYSREPO_INCLUDEDIR = @SYSREPO_INCLUDEDIR@ +SYSREPO_LIBS = @SYSREPO_LIBS@ +SYSREPO_VERSION = @SYSREPO_VERSION@ +USE_LCOV = @USE_LCOV@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WARNING_GCC_44_STRICT_ALIASING_CFLAG = @WARNING_GCC_44_STRICT_ALIASING_CFLAG@ +YACC = @YACC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +CLEANFILES = *.gcno *.gcda +sysrepo_setup_tests_SOURCES = sysrepo_setup_tests.cc +sysrepo_setup_tests_CPPFLAGS = -I$(top_builddir)/src/lib \ + -I$(top_srcdir)/src/lib $(SYSREPO_CPPFLAGS) \ + $(SYSREPO_INCLUDEDIR) -DSYSREPO_REPO=\"@SR_REPO_PATH@\" +sysrepo_setup_tests_LDFLAGS = $(AM_LDFLAGS) +sysrepo_setup_tests_LDADD = $(SYSREPO_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/pretests/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/lib/yang/pretests/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 + +sysrepo_setup_tests$(EXEEXT): $(sysrepo_setup_tests_OBJECTS) $(sysrepo_setup_tests_DEPENDENCIES) $(EXTRA_sysrepo_setup_tests_DEPENDENCIES) + @rm -f sysrepo_setup_tests$(EXEEXT) + $(AM_V_CXXLD)$(sysrepo_setup_tests_LINK) $(sysrepo_setup_tests_OBJECTS) $(sysrepo_setup_tests_LDADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sysrepo_setup_tests-sysrepo_setup_tests.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 $@ $< + +sysrepo_setup_tests-sysrepo_setup_tests.o: sysrepo_setup_tests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sysrepo_setup_tests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sysrepo_setup_tests-sysrepo_setup_tests.o -MD -MP -MF $(DEPDIR)/sysrepo_setup_tests-sysrepo_setup_tests.Tpo -c -o sysrepo_setup_tests-sysrepo_setup_tests.o `test -f 'sysrepo_setup_tests.cc' || echo '$(srcdir)/'`sysrepo_setup_tests.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sysrepo_setup_tests-sysrepo_setup_tests.Tpo $(DEPDIR)/sysrepo_setup_tests-sysrepo_setup_tests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sysrepo_setup_tests.cc' object='sysrepo_setup_tests-sysrepo_setup_tests.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) $(sysrepo_setup_tests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sysrepo_setup_tests-sysrepo_setup_tests.o `test -f 'sysrepo_setup_tests.cc' || echo '$(srcdir)/'`sysrepo_setup_tests.cc + +sysrepo_setup_tests-sysrepo_setup_tests.obj: sysrepo_setup_tests.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(sysrepo_setup_tests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT sysrepo_setup_tests-sysrepo_setup_tests.obj -MD -MP -MF $(DEPDIR)/sysrepo_setup_tests-sysrepo_setup_tests.Tpo -c -o sysrepo_setup_tests-sysrepo_setup_tests.obj `if test -f 'sysrepo_setup_tests.cc'; then $(CYGPATH_W) 'sysrepo_setup_tests.cc'; else $(CYGPATH_W) '$(srcdir)/sysrepo_setup_tests.cc'; fi` +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/sysrepo_setup_tests-sysrepo_setup_tests.Tpo $(DEPDIR)/sysrepo_setup_tests-sysrepo_setup_tests.Po +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='sysrepo_setup_tests.cc' object='sysrepo_setup_tests-sysrepo_setup_tests.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) $(sysrepo_setup_tests_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o sysrepo_setup_tests-sysrepo_setup_tests.obj `if test -f 'sysrepo_setup_tests.cc'; then $(CYGPATH_W) 'sysrepo_setup_tests.cc'; else $(CYGPATH_W) '$(srcdir)/sysrepo_setup_tests.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)/sysrepo_setup_tests-sysrepo_setup_tests.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)/sysrepo_setup_tests-sysrepo_setup_tests.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/pretests/sysrepo_setup_tests.cc b/src/lib/yang/pretests/sysrepo_setup_tests.cc new file mode 100644 index 0000000..6668cc4 --- /dev/null +++ b/src/lib/yang/pretests/sysrepo_setup_tests.cc @@ -0,0 +1,126 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#define KEATEST_MODULE +#include + +#include + +#include +#include + +using namespace std; +using namespace sysrepo; +using namespace isc::yang; + +using libyang::S_Context; +using libyang::S_Module; + +const string REPOSITORY = SYSREPO_REPO; + +/// @brief Returns nicely formed error message if module is missing +/// +/// @param name name of the YANG module to complain about +/// @param revision revision of the YANG module +/// @return a text explaining what the problem is and how to fix it +string missingModuleText(const string& name, const string& revision) { + stringstream tmp; + tmp << "ERROR: YANG module " << name << " is not installed." << endl + << "The environment is not suitable for running unit tests." << endl + << "Please install the module " << name << ":" << endl + << "$ sysrepoctl -i ./src/share/yang/modules/" << name << "@" << revision << ".yang" << endl + << endl; + return (tmp.str()); +} + +/// @brief Returns nicely formed error message if module does not have +/// the expected revision. +/// +/// @param name name of the YANG module to complain about +/// @param expected expected revision of the YANG module +/// @param got got (bad) revision of the YANG module +string badRevisionModuleText(const string& name, const string& expected, + const string& got) { + stringstream tmp; + tmp << endl + << "ERROR: YANG module " << name << " is not installed with the right " + << "revision: got " << got << ", but expected " << expected << "." << endl + << "Please remove the module " << name << " and reinstall it: " << endl + << "$ sysrepoctl -u " << name << endl + << "$ sysrepoctl -i ./src/share/yang/modules/" << name << "@" << expected << ".yang" << endl + << endl; + return (tmp.str()); +} + +/// @brief Checks sysrepo setup: +/// - connection establishment +/// - session establishment +/// - test module +/// - type modules +/// - IETF module +/// - Kea modules. +/// - daemon required +int main() { + S_Connection conn; + try { + conn = std::make_shared(); + } catch (const sysrepo_exception& ex) { + cerr << "ERROR: Can't initialize sysrepo: " << ex.what() << endl; + cerr << "ERROR: Make sure you have the right permissions to the sysrepo repository." << endl; + return (1); + } + + S_Session sess; + try { + sess.reset(new Session(conn, SR_DS_CANDIDATE)); + } catch (const sysrepo_exception& ex) { + cerr << "ERROR: Can't establish a sysrepo session: " + << ex.what() << endl; + return (2); + } + + vector modules; + try { + S_Context context(sess->get_context()); + modules = context->get_module_iter(); + } catch (const sysrepo_exception& ex) { + cerr << "ERROR: Can't retrieve available modules: " << ex.what() << endl; + return (3); + } + + std::unordered_map installed_modules; + for (S_Module const& module : modules) { + if (!module->name()) { + cerr << "ERROR: module name is mangled" << endl; + return (4); + } + string const name(module->name()); + if (!module->rev() || !module->rev()->date()) { + cerr << "ERROR: module revision is mangled" << endl; + return (5); + } + string const revision(module->rev()->date()); + installed_modules.emplace(name, revision); + } + + for (auto const& kv : YANG_REVISIONS) { + std::string const& name(kv.first); + std::string const& expected_revision(kv.second); + if (!installed_modules.count(name)) { + cerr << missingModuleText(name, expected_revision); + return (6); + } + string const& revision(installed_modules.at(name)); + if (expected_revision != revision) { + cerr << badRevisionModuleText(name, expected_revision, revision); + return (7); + } + } + + return 0; +} diff --git a/src/lib/yang/sysrepo_error.h b/src/lib/yang/sysrepo_error.h new file mode 100644 index 0000000..c4f3a61 --- /dev/null +++ b/src/lib/yang/sysrepo_error.h @@ -0,0 +1,26 @@ +// 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 ISC_SYSREPO_ERROR_H +#define ISC_SYSREPO_ERROR_H 1 + +#include + +namespace isc { +namespace yang { + +/// @brief Sysrepo error. +class SysrepoError : public isc::Exception { +public: + SysrepoError(const char* file, size_t line, const char* what) : + isc::Exception(file, line, what) + {} +}; + +} // end of namespace isc::yang +} // end of namespace isc + +#endif // ISC_SYSREPO_ERROR_H diff --git a/src/lib/yang/tests/Makefile.am b/src/lib/yang/tests/Makefile.am new file mode 100644 index 0000000..9fe7693 --- /dev/null +++ b/src/lib/yang/tests/Makefile.am @@ -0,0 +1,60 @@ +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) +AM_CPPFLAGS += $(SYSREPO_CPPFLAGS) +AM_CPPFLAGS += $(SYSREPO_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) +run_unittests_LDADD += $(SYSREPO_LIBS) $(GTEST_LDADD) + +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..4f60eb2 --- /dev/null +++ b/src/lib/yang/tests/Makefile.in @@ -0,0 +1,1285 @@ +# 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_crypto.m4 \ + $(top_srcdir)/m4macros/ax_find_library.m4 \ + $(top_srcdir)/m4macros/ax_gssapi.m4 \ + $(top_srcdir)/m4macros/ax_gtest.m4 \ + $(top_srcdir)/m4macros/ax_isc_rpath.m4 \ + $(top_srcdir)/m4macros/ax_sysrepo.m4 \ + $(top_srcdir)/m4macros/libtool.m4 \ + $(top_srcdir)/m4macros/ltoptions.m4 \ + $(top_srcdir)/m4macros/ltsugar.m4 \ + $(top_srcdir)/m4macros/ltversion.m4 \ + $(top_srcdir)/m4macros/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +@HAVE_GTEST_TRUE@am__EXEEXT_1 = 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) +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_GTEST_CONFIGURE_FLAG = @DISTCHECK_GTEST_CONFIGURE_FLAG@ +DISTCHECK_KEA_SHELL_CONFIGURE_FLAG = @DISTCHECK_KEA_SHELL_CONFIGURE_FLAG@ +DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG = @DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG@ +DISTCHECK_PERFDHCP_CONFIGURE_FLAG = @DISTCHECK_PERFDHCP_CONFIGURE_FLAG@ +DISTCHECK_PREMIUM_CONFIGURE_FLAG = @DISTCHECK_PREMIUM_CONFIGURE_FLAG@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GENHTML = @GENHTML@ +GREP = @GREP@ +GSSAPI_CFLAGS = @GSSAPI_CFLAGS@ +GSSAPI_LIBS = @GSSAPI_LIBS@ +GTEST_CONFIG = @GTEST_CONFIG@ +GTEST_INCLUDES = @GTEST_INCLUDES@ +GTEST_LDADD = @GTEST_LDADD@ +GTEST_LDFLAGS = @GTEST_LDFLAGS@ +GTEST_SOURCE = @GTEST_SOURCE@ +HAVE_SYSREPO = @HAVE_SYSREPO@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KEA_CXXFLAGS = @KEA_CXXFLAGS@ +KEA_SRCID = @KEA_SRCID@ +KRB5_CONFIG = @KRB5_CONFIG@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOG4CPLUS_INCLUDES = @LOG4CPLUS_INCLUDES@ +LOG4CPLUS_LIBS = @LOG4CPLUS_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ +MYSQL_LIBS = @MYSQL_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_VERSION_TYPE = @PACKAGE_VERSION_TYPE@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PDFLATEX = @PDFLATEX@ +PERL = @PERL@ +PGSQL_CPPFLAGS = @PGSQL_CPPFLAGS@ +PGSQL_LIBS = @PGSQL_LIBS@ +PKGPYTHONDIR = @PKGPYTHONDIR@ +PKG_CONFIG = @PKG_CONFIG@ +PLANTUML = @PLANTUML@ +PREMIUM_DIR = @PREMIUM_DIR@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +SED = @SED@ +SEP = @SEP@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPHINXBUILD = @SPHINXBUILD@ +SRPD_PLUGINS_PATH = @SRPD_PLUGINS_PATH@ +SR_REPO_PATH = @SR_REPO_PATH@ +STRIP = @STRIP@ +SYSREPOCPP_VERSION = @SYSREPOCPP_VERSION@ +SYSREPO_CPPFLAGS = @SYSREPO_CPPFLAGS@ +SYSREPO_INCLUDEDIR = @SYSREPO_INCLUDEDIR@ +SYSREPO_LIBS = @SYSREPO_LIBS@ +SYSREPO_VERSION = @SYSREPO_VERSION@ +USE_LCOV = @USE_LCOV@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WARNING_GCC_44_STRICT_ALIASING_CFLAG = @WARNING_GCC_44_STRICT_ALIASING_CFLAG@ +YACC = @YACC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib \ + $(BOOST_INCLUDES) $(SYSREPO_CPPFLAGS) $(SYSREPO_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@ $(SYSREPO_LIBS) $(GTEST_LDADD) +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..1a5affa --- /dev/null +++ b/src/lib/yang/tests/adaptor_config_unittests.cc @@ -0,0 +1,145 @@ +// 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 + +#include +#include +#include +#include + +#include + +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 std::string& fname, bool v6, ElementPtr& result) { + ElementPtr json; + ElementPtr reference_json; + + string decommented = decommentJSONfile(fname); + + EXPECT_NO_THROW(json = Element::fromJSONFile(decommented, true)); + reference_json = moveComments(json); + + // remove the temporary file + EXPECT_NO_THROW(::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; +} + +}; + +TEST_F(AdaptorConfigTest, loadExamples4) { + vector configs = { + "advanced.json", + "all-keys-netconf.json", + "backends.json", + "classify.json", + "classify2.json", + "comments.json", + "config-backend.json", + "dhcpv4-over-dhcpv6.json", + "global-reservations.json", + "ha-load-balancing-primary.json", + "hooks.json", + "hooks-radius.json", + "leases-expiration.json", + "multiple-options.json", + //"mysql-reservations.json", commented for new TLS parameters + "pgsql-reservations.json", + "reservations.json", + "several-subnets.json", + "shared-network.json", + "single-subnet.json", + "with-ddns.json", + }; + + ElementPtr x; + + for (int i = 0; i configs = { + "advanced.json", + "all-keys-netconf.json", + "backends.json", + "classify.json", + "classify2.json", + "comments.json", + "config-backend.json", + "dhcpv4-over-dhcpv6.json", + "duid.json", + "global-reservations.json", + "ha-hot-standby.json", + "hooks.json", + "iPXE.json", + "leases-expiration.json", + "multiple-options.json", + //"mysql-reservations.json", commented for new TLS parameters + "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 + +#include +#include + +#include + +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(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(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(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(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(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(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..1b23f05 --- /dev/null +++ b/src/lib/yang/tests/adaptor_option_unittests.cc @@ -0,0 +1,241 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include +#include +#include +#include + +#include + +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(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(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(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(AdaptorOption::checkType(json), MissingKey); +} + +// 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(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(AdaptorOption::checkCode(json), MissingKey); +} + +// 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_THROW(codes.at("foo@bar"), out_of_range); +} + +// 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(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(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(AdaptorOption::setCode(json, codes), MissingKey); +} + +// 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(AdaptorOption::setCode(json, codes), MissingKey); +} + +/// @brief Test class to make initCodes public. +class TestAdaptorOption : public AdaptorOption { +public: + using AdaptorOption::initCodesInternal; +}; + +// 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_THROW(codes.at("dhcp6@clientid"), out_of_range); + + // 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_THROW(codes.at("dhcp4@subnet-mask"), out_of_range); + + // 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"]); +} + +} // end of 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..dd70716 --- /dev/null +++ b/src/lib/yang/tests/adaptor_pool_unittests.cc @@ -0,0 +1,274 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include + +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(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(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(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(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(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(AdaptorPool::fromSubnet(KEA_DHCP4_SERVER, json, pools)); + EXPECT_TRUE(copied->equals(*json)); + // The model is checked first. + EXPECT_NO_THROW(AdaptorPool::fromSubnet(KEA_DHCP6_SERVER, json, pools)); + EXPECT_TRUE(copied->equals(*json)); + + // Check that the model name is actually checked. + EXPECT_THROW(AdaptorPool::fromSubnet("non-existent-module", json, pools), + NotImplemented); +} + +// 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(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(AdaptorPool::toSubnet(KEA_DHCP4_SERVER, json, pools)); + EXPECT_TRUE(copied->equals(*json)); + // The model is checked first. + EXPECT_NO_THROW(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(AdaptorPool::toSubnet("keatest-module", json, pools), + NotImplemented); +} + +// 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(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(AdaptorPool::toSubnet(IETF_DHCPV6_SERVER, json, pools), + BadValue); +} + +}; // end of 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..54ec710 --- /dev/null +++ b/src/lib/yang/tests/adaptor_subnet_unittests.cc @@ -0,0 +1,213 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include + +#include + +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... + +}; // end of 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..fc75ad1 --- /dev/null +++ b/src/lib/yang/tests/adaptor_unittests.cc @@ -0,0 +1,394 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include + +#include + +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"; + ConstElementPtr 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"; + + ConstElementPtr json = Element::fromJSON(config); + EXPECT_NO_THROW(Adaptor::fromParent("param1", json, json->get("list"))); + EXPECT_NO_THROW(Adaptor::fromParent("param2", json, json->get("list"))); + EXPECT_NO_THROW(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(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(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(Adaptor::toParent("param3",json, json->get("list")), + BadValue); + EXPECT_THROW(Adaptor::toParent("param4",json, json->get("list")), + BadValue); + EXPECT_THROW(Adaptor::toParent("param5",json, json->get("list")), + BadValue); + // 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)); +} + +}; // end of 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..7a655a7 --- /dev/null +++ b/src/lib/yang/tests/config_unittests.cc @@ -0,0 +1,417 @@ +// 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 + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +#include + +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 +std::string generateDiff(std::string left, std::string right) { + std::vector left_lines; + boost::split(left_lines, left, boost::is_any_of("\n")); + std::vector 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 +std::string generateDiff(std::string, std::string) { + return (""); +} +#endif + +/// @brief Test Fixture class for Yang <-> JSON configs. +class ConfigTest : public ::testing::Test { +public: + virtual ~ConfigTest() = default; + + void SetUp() override { + SysrepoSetup::cleanSharedMemory(); + connection_ = std::make_shared(); + session_.reset(new Session(connection_, SR_DS_CANDIDATE)); + translator_.reset(new TranslatorBasic(session_, model_)); + cleanModelData(); + } + + void TearDown() override { + cleanModelData(); + translator_.reset(); + session_.reset(); + connection_.reset(); + SysrepoSetup::cleanSharedMemory(); + } + + void cleanModelData() { + std::string toplevel_node("config"); + if (model_ == IETF_DHCPV6_SERVER) { + toplevel_node = "server"; + } + translator_->delItem("/" + 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(ConstElementPtr 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); + ConstElementPtr 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 Validate. + /// + /// @note A tree must be loaded first. + /// + bool validate() { + YangRepr repr(model_); + return (repr.validate(session_, cerr)); + } + + /// @brief The model. + string model_; + + /// @brief The sysrepo connection. + S_Connection connection_; + + /// @brief The sysrepo session. + S_Session session_; + + std::unique_ptr translator_; +}; + +struct ConfigTestKeaV4 : ConfigTest { + ConfigTestKeaV4() { + model_ = KEA_DHCP4_SERVER; + } +}; +struct ConfigTestKeaV6 : ConfigTest { + ConfigTestKeaV6() { + model_ = KEA_DHCP6_SERVER; + } +}; +struct ConfigTestIetfV6 : ConfigTest { + ConfigTestIetfV6() { + model_ = IETF_DHCPV6_SERVER; + } +}; + +// Check empty config with ietf-dhcpv6-server model. +TEST_F(ConfigTestIetfV6, emptyIetf6) { + YRTree tree; + ASSERT_NO_THROW_LOG(load(tree)); + EXPECT_TRUE(verify(tree)); + + ConstElementPtr 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)); + + ConstElementPtr 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)); + + ConstElementPtr 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)); + + EXPECT_FALSE(validate()); +} + +// 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)); + + EXPECT_TRUE(validate()); +} + +// 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)); + + EXPECT_TRUE(validate()); +} + +// 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)); + + // If this validation fails, make sure you have the model *and its + // dependencies* are installed. Note when you install ietf-dhcpv6-server + // module, its dependencies are semi-installed, which is not sufficient. + // This can be detected in output of sysrepoctl -l. + // Note the ietf-interfaces module. The conformance status must be + // "installed". "implemented" (installed as dependency) is not enough. + EXPECT_TRUE(validate()); +} + +// Check Kea4 example files. +TEST_F(ConfigTestKeaV4, examples4) { + vector 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", + "global-reservations.json", + "ha-load-balancing-primary.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; + cout << "Testing file " << path << endl; + ConstElementPtr json; + ASSERT_NO_THROW_LOG(json = loadFile(path)); + json = isc::test::moveComments(json); + EXPECT_TRUE(verify(json)); + EXPECT_TRUE(validate()); + } +} + +// Check Kea6 example files. +TEST_F(ConfigTestKeaV6, examples6) { + vector 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", + "duid.json", + "global-reservations.json", + "ha-hot-standby.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; + cout << "Testing file " << path << endl; + ConstElementPtr json; + ASSERT_NO_THROW_LOG(json = loadFile(path)); + json = isc::test::moveComments(json); + EXPECT_TRUE(verify(json)); + EXPECT_TRUE(validate()); + } +} + +// 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..1f7e4a4 --- /dev/null +++ b/src/lib/yang/tests/json_configs.h @@ -0,0 +1,174 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef ISC_JSON_CONFIGS_H +#define ISC_JSON_CONFIGS_H + +#include + +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" + " }\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" + " }\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..c0847ca --- /dev/null +++ b/src/lib/yang/tests/run_unittests.cc @@ -0,0 +1,20 @@ +// Copyright (C) 2018 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +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..27cf213 --- /dev/null +++ b/src/lib/yang/tests/sysrepo_setup.h @@ -0,0 +1,99 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef SYSREPO_SETUP_H +#define SYSREPO_SETUP_H + +#include + +#include +#include +#include + +#include + +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; + } + } +}; + +/// @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 +class GenericTranslatorTest : public ::testing::Test { +public: + virtual ~GenericTranslatorTest() = default; + + void SetUp() override { + SysrepoSetup::cleanSharedMemory(); + conn_.reset(new sysrepo::Connection()); + sess_.reset(new sysrepo::Session(conn_, SR_DS_CANDIDATE)); + t_obj_.reset(new translator_t(sess_, model_)); + cleanModelData(); + } + + void TearDown() override { + cleanModelData(); + t_obj_.reset(); + sess_.reset(); + conn_.reset(); + SysrepoSetup::cleanSharedMemory(); + } + + void cleanModelData() { + std::string toplevel_node("config"); + if (model_ == IETF_DHCPV6_SERVER) { + toplevel_node = "server"; + } + t_obj_->delItem("/" + model_ + ":" + toplevel_node); + } + + /// @brief Sysrepo connection. + sysrepo::S_Connection conn_; + + /// @brief Sysrepo session. + sysrepo::S_Session sess_; + + /// @brief Shared pointer to the transaction object. + boost::shared_ptr t_obj_; + std::string model_; +}; + +} // 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..3dcb518 --- /dev/null +++ b/src/lib/yang/tests/translator_class_unittests.cc @@ -0,0 +1,125 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include +#include + +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 { +public: + + /// Constructor. + TranslatorClassesTestv4() { + model_ = KEA_DHCP4_SERVER; + } +}; +class TranslatorClassesTestv6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorClassesTestv6() { + model_ = KEA_DHCP6_SERVER; + } +}; + +// 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(classes = t_obj_->getClasses(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"; + S_Val v_test(new Val("not member('ALL')", SR_STRING_T)); + EXPECT_NO_THROW(sess_->set_item(xtest.c_str(), v_test)); + + // Get the client class. + ConstElementPtr cclass; + EXPECT_NO_THROW(cclass = t_obj_->getClass(xclass)); + ASSERT_TRUE(cclass); + ElementPtr expected = Element::createMap(); + expected->set("name", Element::create(string("foo"))); + expected->set("test", Element::create(string("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(classes = t_obj_->getClasses(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(t_obj_->setClasses(xpath, classes)); + + // Get it back. + classes.reset(); + EXPECT_NO_THROW(classes = t_obj_->getClasses(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(string("foo"))); + cclass->set("test", Element::create(string("''==''"))); + cclass->set("only-if-required", Element::create(false)); + classes->add(cclass); + EXPECT_NO_THROW(t_obj_->setClasses(xpath, classes)); + + // Get it back. + ConstElementPtr got; + EXPECT_NO_THROW(got = t_obj_->getClasses(xpath)); + ASSERT_TRUE(got); + ASSERT_EQ(Element::list, got->getType()); + ASSERT_EQ(1, got->size()); + EXPECT_TRUE(cclass->equals(*got->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +} // 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..3d9d4fe --- /dev/null +++ b/src/lib/yang/tests/translator_control_socket_unittests.cc @@ -0,0 +1,176 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include + +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 control_socket[] = "control socket"; + +/// @brief Test fixture class for @ref TranslatorControlSocket. +class TranslatorControlSocketTestv4 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorControlSocketTestv4() { + model_ = KEA_DHCP4_SERVER; + } + + virtual ~TranslatorControlSocketTestv4() = default; +}; +class TranslatorControlSocketTestv6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorControlSocketTestv6() { + model_ = KEA_DHCP6_SERVER; + } + + virtual ~TranslatorControlSocketTestv6() = default; +}; +class TranslatorControlSocketTestCtrlAgent : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorControlSocketTestCtrlAgent() { + model_ = KEA_CTRL_AGENT; + } + + virtual ~TranslatorControlSocketTestCtrlAgent() = default; +}; + +// 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(sock = t_obj_->getControlSocket(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"; + S_Val s_name(new Val("/tmp/kea.sock")); + EXPECT_NO_THROW(sess_->set_item(xname.c_str(), s_name)); + S_Val s_type(new Val("unix", SR_ENUM_T)); + EXPECT_NO_THROW(sess_->set_item(xtype.c_str(), s_type)); + S_Val s_context(new Val("{ \"foo\": 1 }")); + EXPECT_NO_THROW(sess_->set_item(xcontext.c_str(), s_context)); + + // Get it. + ConstElementPtr sock; + EXPECT_NO_THROW(sock = t_obj_->getControlSocket(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(string("/tmp/kea.sock"))); + sock->set("socket-type", Element::create(string("unix"))); + sock->set("comment", Element::create(string("a comment"))); + try { + t_obj_->setControlSocket(xpath, sock); + } catch (const std::exception& ex) { + cerr << "setControlSocket fail with " << ex.what() << endl; + } + ASSERT_NO_THROW_LOG(t_obj_->setControlSocket(xpath, sock)); + + // Get it back. + ConstElementPtr got; + EXPECT_NO_THROW(got = t_obj_->getControlSocket(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()); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +// 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"; + S_Val s_name(new Val("/tmp/kea.sock")); + EXPECT_NO_THROW(sess_->set_item(xname.c_str(), s_name)); + S_Val s_type(new Val("unix", SR_ENUM_T)); + EXPECT_NO_THROW(sess_->set_item(xtype.c_str(), s_type)); + S_Val s_context(new Val("{ \"foo\": 1 }")); + EXPECT_NO_THROW(sess_->set_item(xcontext.c_str(), s_context)); + sess_->apply_changes(); + + // Get it back. + ConstElementPtr sock; + EXPECT_NO_THROW(sock = t_obj_->getControlSocket(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(t_obj_->setControlSocket(xpath, ConstElementPtr())); + + // Get it back. + EXPECT_NO_THROW(sock = t_obj_->getControlSocket(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..6c4eb29 --- /dev/null +++ b/src/lib/yang/tests/translator_database_unittests.cc @@ -0,0 +1,327 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include + +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 { +public: + TranslatorDatabaseTestv4() { + model_ = KEA_DHCP4_SERVER; + } + + virtual ~TranslatorDatabaseTestv4() = default; +}; + +class TranslatorDatabaseTestv6 : + public GenericTranslatorTest { +public: + TranslatorDatabaseTestv6() { + model_ = KEA_DHCP6_SERVER; + } + + virtual ~TranslatorDatabaseTestv6() = default; +}; + +// 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(database = t_obj_->getDatabase(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"; + S_Val s_type(new Val("memfile")); + EXPECT_NO_THROW(sess_->set_item(xtype.c_str(), s_type)); + uint32_t li = 3600; + S_Val s_interval(new Val(li)); + EXPECT_NO_THROW(sess_->set_item(xinterval.c_str(), s_interval)); + + // Get empty. + ConstElementPtr database; + EXPECT_NO_THROW(database = t_obj_->getDatabase(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(string("memfile"))); + database->set("lfc-interval", Element::create(3600)); + ASSERT_NO_THROW_LOG(t_obj_->setDatabase(xpath, database)); + + // Get it back. + ConstElementPtr got; + EXPECT_NO_THROW(got = t_obj_->getDatabase(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"; + S_Val s_type(new Val("memfile")); + EXPECT_NO_THROW(sess_->set_item(xtype.c_str(), s_type)); + uint32_t li = 3600; + S_Val s_interval(new Val(li)); + EXPECT_NO_THROW(sess_->set_item(xinterval.c_str(), s_interval)); + sess_->apply_changes(); + + // Reset to empty. + ASSERT_NO_THROW_LOG(t_obj_->setDatabase(xpath, ConstElementPtr())); + + // Get it back. + ConstElementPtr database; + EXPECT_NO_THROW(database = t_obj_->getDatabase(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 { +public: + + /// Constructor. + TranslatorDatabasesTestv4() { + model_ = KEA_DHCP4_SERVER; + } +}; + +class TranslatorDatabasesTestv6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorDatabasesTestv6() { + model_ = KEA_DHCP6_SERVER; + } +}; + +// 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(databases = t_obj_->getDatabases(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"; + S_Val s_name(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xname.c_str(), s_name)); + S_Val s_user(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xuser.c_str(), s_user)); + S_Val s_password(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xpassword.c_str(), s_password)); + S_Val s_host(new Val("localhost")); + EXPECT_NO_THROW(sess_->set_item(xhost.c_str(), s_host)); + uint16_t mport = 3306; + S_Val s_port(new Val(mport)); + EXPECT_NO_THROW(sess_->set_item(xport.c_str(), s_port)); + + // Get empty. + ConstElementPtr databases; + EXPECT_NO_THROW(databases = t_obj_->getDatabases(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(string("memfile"))); + database->set("lfc-interval", Element::create(3600)); + ElementPtr databases = Element::createList(); + databases->add(database); + ASSERT_NO_THROW_LOG(t_obj_->setDatabases(xpath, databases)); + + // Get it back. + ConstElementPtr gots; + EXPECT_NO_THROW(gots = t_obj_->getDatabases(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()); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +// 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"; + S_Val s_name(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xname.c_str(), s_name)); + S_Val s_user(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xuser.c_str(), s_user)); + S_Val s_password(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xpassword.c_str(), s_password)); + S_Val s_host(new Val("localhost")); + EXPECT_NO_THROW(sess_->set_item(xhost.c_str(), s_host)); + uint16_t mport = 3306; + S_Val s_port(new Val(mport)); + EXPECT_NO_THROW(sess_->set_item(xport.c_str(), s_port)); + sess_->apply_changes(); + + // Reset to empty. + EXPECT_NO_THROW(t_obj_->setDatabase(xdatabase, ConstElementPtr())); + + // Get empty. + ConstElementPtr databases; + EXPECT_NO_THROW(databases = t_obj_->getDatabases(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"; + S_Val s_name(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xname.c_str(), s_name)); + S_Val s_user(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xuser.c_str(), s_user)); + S_Val s_password(new Val("kea")); + EXPECT_NO_THROW(sess_->set_item(xpassword.c_str(), s_password)); + S_Val s_host(new Val("localhost")); + EXPECT_NO_THROW(sess_->set_item(xhost.c_str(), s_host)); + uint16_t mport = 3306; + S_Val s_port(new Val(mport)); + EXPECT_NO_THROW(sess_->set_item(xport.c_str(), s_port)); + sess_->apply_changes(); + + // Reset to empty. + EXPECT_NO_THROW(t_obj_->setDatabases(xdatabase, ConstElementPtr())); + + // Get empty. + ConstElementPtr databases; + EXPECT_NO_THROW(databases = t_obj_->getDatabases(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..26fd202 --- /dev/null +++ b/src/lib/yang/tests/translator_host_unittests.cc @@ -0,0 +1,188 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include +#include + +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 host_reservations[] = "host reservations"; + +/// @brief Test fixture class for @ref TranslatorHosts. +class TranslatorHostsTestv4 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorHostsTestv4() { + model_ = KEA_DHCP4_SERVER; + } +}; + +class TranslatorHostsTestv6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorHostsTestv6() { + model_ = KEA_DHCP6_SERVER; + } +}; + +// 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(hosts = t_obj_->getHosts(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // 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"; + S_Val s_addr(new Val("2001:db8::1")); + EXPECT_NO_THROW(sess_->set_item(xaddr.c_str(), s_addr)); + + // Get the host. + ConstElementPtr host; + EXPECT_NO_THROW(host = t_obj_->getHost(shost.str())); + ASSERT_TRUE(host); + ElementPtr expected = Element::createMap(); + ElementPtr addresses = Element::createList(); + addresses->add(Element::create(string("2001:db8::1"))); + expected->set("hw-address", Element::create(string("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(hosts = t_obj_->getHosts(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // Set empty list. + ConstElementPtr hosts = Element::createList(); + EXPECT_NO_THROW(t_obj_->setHosts(xpath, hosts)); + + // Get it back. + hosts.reset(); + EXPECT_NO_THROW(hosts = t_obj_->getHosts(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']"; + S_Val v_subnet(new Val("10.0.0.0/24", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // Set one host. + ElementPtr hosts = Element::createList(); + ElementPtr host = Element::createMap(); + host->set("flex-id", Element::create(string("00:ff"))); + host->set("ip-address", Element::create(string("10.0.0.1"))); + host->set("hostname", Element::create(string("foo"))); + hosts->add(host); + EXPECT_NO_THROW(t_obj_->setHosts(xpath, hosts)); + + // Get it back. + hosts.reset(); + EXPECT_NO_THROW(hosts = t_obj_->getHosts(xpath)); + ASSERT_TRUE(hosts); + ASSERT_EQ(Element::list, hosts->getType()); + ASSERT_EQ(1, hosts->size()); + EXPECT_TRUE(host->equals(*hosts->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +// 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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // 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"; + S_Val s_addr(new Val("2001:db8::1")); + EXPECT_NO_THROW(sess_->set_item(xaddr.c_str(), s_addr)); + + // 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"; + S_Val s_addr2(new Val("2001:db8::2")); + EXPECT_NO_THROW(sess_->set_item(xaddr2.c_str(), s_addr2)); + + // Get the host. + ConstElementPtr hosts; + EXPECT_NO_THROW(hosts = t_obj_->getHosts(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\" ] } ]"); +} + +}; // end of 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..2dbfbcc --- /dev/null +++ b/src/lib/yang/tests/translator_logger_unittests.cc @@ -0,0 +1,159 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include + +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 { +public: + + /// Constructor. + TranslatorLoggersTestv4() { + model_ = KEA_DHCP4_SERVER; + } +}; +class TranslatorLoggersTestv6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorLoggersTestv6() { + model_ = KEA_DHCP6_SERVER; + } +}; + +// 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(loggers = t_obj_->getLoggers(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"; + S_Val s_severity(new Val("WARN", SR_ENUM_T)); + EXPECT_NO_THROW(sess_->set_item(xseverity.c_str(), s_severity)); + uint32_t max_ver = 10; + S_Val s_maxver(new Val(max_ver)); + EXPECT_NO_THROW(sess_->set_item(xmaxver.c_str(), s_maxver)); + + // Get empty. + ConstElementPtr loggers; + EXPECT_NO_THROW(loggers = t_obj_->getLoggers(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(string("/bar"))); + option->set("maxver", Element::create(10)); + ElementPtr options = Element::createList(); + options->add(option); + ElementPtr logger = Element::createMap(); + logger->set("name", Element::create(string("foo"))); + logger->set("severity", Element::create(string("WARN"))); + logger->set("output_options", options); + ElementPtr loggers = Element::createList(); + loggers->add(logger); + ASSERT_NO_THROW_LOG(t_obj_->setLoggers(xpath, loggers)); + + // Get it back. + ConstElementPtr gots; + EXPECT_NO_THROW(gots = t_obj_->getLoggers(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()); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +/// @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..b02284c --- /dev/null +++ b/src/lib/yang/tests/translator_option_data_unittests.cc @@ -0,0 +1,136 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include +#include + +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 { +public: + + /// Constructor. + TranslatorOptionDataListTestv4() { + model_ = KEA_DHCP4_SERVER; + } +}; + +class TranslatorOptionDataListTestv6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorOptionDataListTestv6() { + model_ = KEA_DHCP6_SERVER; + } +}; + +// 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(options = t_obj_->getOptionDataList(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& xsend = xoption + "/always-send"; + S_Val s_false(new Val(false)); + ASSERT_NO_THROW_LOG(sess_->set_item(xformat.c_str(), s_false)); + S_Val s_data(new Val("12121212")); + ASSERT_NO_THROW_LOG(sess_->set_item(xdata.c_str(), s_data)); + ASSERT_NO_THROW_LOG(sess_->set_item(xsend.c_str(), s_false)); + + // Get the option data. + ConstElementPtr option; + EXPECT_NO_THROW(option = t_obj_->getOptionData(xoption)); + ASSERT_TRUE(option); + EXPECT_EQ("{" + " \"always-send\": false," + " \"code\": 100," + " \"csv-format\": false," + " \"data\": \"12121212\"," + " \"space\": \"dns\"" + " }", + option->str()); + + // Get the option data list. + ConstElementPtr options; + EXPECT_NO_THROW(options = t_obj_->getOptionDataList(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(t_obj_->setOptionDataList(xpath, options)); + + // Get it back. + options.reset(); + EXPECT_NO_THROW(options = t_obj_->getOptionDataList(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(string("dns"))); + option->set("csv-format", Element::create(false)); + option->set("data", Element::create(string("12121212"))); + option->set("always-send", Element::create(false)); + options->add(option); + EXPECT_NO_THROW(t_obj_->setOptionDataList(xpath, options)); + + // Get it back. + ConstElementPtr got; + EXPECT_NO_THROW(got = t_obj_->getOptionDataList(xpath)); + ASSERT_TRUE(got); + ASSERT_EQ(1, got->size()); + EXPECT_TRUE(option->equals(*got->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +} // 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..d6c3cdf --- /dev/null +++ b/src/lib/yang/tests/translator_option_def_unittests.cc @@ -0,0 +1,144 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include +#include + +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 { +public: + + /// Constructor. + TranslatorOptionDefListTestKeaV4() { + model_ = KEA_DHCP4_SERVER; + } +}; +class TranslatorOptionDefListTestKeaV6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorOptionDefListTestKeaV6() { + model_ = KEA_DHCP6_SERVER; + } +}; +class TranslatorOptionDefListTestIetfV6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorOptionDefListTestIetfV6() { + model_ = IETF_DHCPV6_SERVER; + } +}; + +// 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(options = t_obj_->getOptionDefList(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"; + S_Val s_name(new Val("foo")); + ASSERT_NO_THROW_LOG(sess_->set_item(xname.c_str(), s_name)); + S_Val s_type(new Val("string")); + ASSERT_NO_THROW_LOG(sess_->set_item(xtype.c_str(), s_type)); + S_Val s_array(new Val(false)); + ASSERT_NO_THROW_LOG(sess_->set_item(xarray.c_str(), s_array)); + + // Get the option def. + ConstElementPtr def; + EXPECT_NO_THROW(def = t_obj_->getOptionDef(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(defs = t_obj_->getOptionDefList(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(t_obj_->setOptionDefList(xpath, defs)); + + // Get it back. + defs.reset(); + EXPECT_NO_THROW(defs = t_obj_->getOptionDefList(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(string("foo"))); + def->set("space", Element::create(string("isc"))); + def->set("type", Element::create(string("string"))); + def->set("array", Element::create(false)); + defs->add(def); + EXPECT_NO_THROW(t_obj_->setOptionDefList(xpath, defs)); + + // Get it back. + ConstElementPtr got; + EXPECT_NO_THROW(got = t_obj_->getOptionDefList(xpath)); + ASSERT_TRUE(got); + ASSERT_EQ(1, got->size()); + EXPECT_TRUE(def->equals(*got->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +}; // end of 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..8d5b3fe --- /dev/null +++ b/src/lib/yang/tests/translator_pd_pool_unittests.cc @@ -0,0 +1,290 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include +#include + +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 { +public: + + /// Constructor. + TranslatorPdPoolsTestKeaV6() { + model_ = KEA_DHCP6_SERVER; + } +}; +class TranslatorPdPoolsTestIetfV6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorPdPoolsTestIetfV6() { + model_ = IETF_DHCPV6_SERVER; + } +}; + +// 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(pools = t_obj_->getPdPools(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(pools = t_obj_->getPdPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet_subnet = subnet + "/network-prefix"; + EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet)); + + // 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"; + S_Val s_prefix(new Val("2001:db8:0:1000::/56")); + EXPECT_NO_THROW(sess_->set_item(prefix.c_str(), s_prefix)); + const string& length = xpath + "/prefix-length"; + uint8_t len = 56; + S_Val s_length(new Val(len)); + EXPECT_NO_THROW(sess_->set_item(length.c_str(), s_length)); + + // Get the pool. + ConstElementPtr pool; + EXPECT_NO_THROW(pool = t_obj_->getPdPool(xpath)); + ASSERT_TRUE(pool); + ElementPtr expected = Element::createMap(); + expected->set("prefix", Element::create(string("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(pools = t_obj_->getPdPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // 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; + S_Val s_delegated(new Val(dl)); + EXPECT_NO_THROW(sess_->set_item(x_delegated.c_str(), s_delegated)); + + // Get the pool. + ConstElementPtr pool; + EXPECT_NO_THROW(pool = t_obj_->getPdPool(spool.str())); + ASSERT_TRUE(pool); + ElementPtr expected = Element::createMap(); + expected->set("prefix", Element::create(string("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(pools = t_obj_->getPdPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet_subnet = subnet + "/network-prefix"; + EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet)); + + // Set empty list. + const string& xpath = subnet + "/pd-pools"; + ConstElementPtr pools = Element::createList(); + EXPECT_NO_THROW(t_obj_->setPdPools(xpath, pools)); + + // Get it back. + pools.reset(); + EXPECT_NO_THROW(pools = t_obj_->getPdPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // Set empty list. + ConstElementPtr pools = Element::createList(); + EXPECT_NO_THROW(t_obj_->setPdPools(xpath, pools)); + + // Get it back. + pools.reset(); + EXPECT_NO_THROW(pools = t_obj_->getPdPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet_subnet = subnet + "/network-prefix"; + EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet)); + + // Set one pool. + const string& xpath = subnet + "/pd-pools"; + ElementPtr pools = Element::createList(); + ElementPtr pool = Element::createMap(); + pool->set("prefix", Element::create(string("2001:db8:0:1000::"))); + pool->set("prefix-len", Element::create(56)); + pools->add(pool); + EXPECT_NO_THROW(t_obj_->setPdPools(xpath, pools)); + + // Get it back. + pools.reset(); + EXPECT_NO_THROW(pools = t_obj_->getPdPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // Set one pool. + ElementPtr pools = Element::createList(); + ElementPtr pool = Element::createMap(); + pool->set("prefix", Element::create(string("2001:db8:0:1000::"))); + pool->set("prefix-len", Element::create(56)); + pool->set("delegated-len", Element::create(64)); + pools->add(pool); + EXPECT_NO_THROW(t_obj_->setPdPools(xpath, pools)); + + // Get it back. + pools.reset(); + EXPECT_NO_THROW(pools = t_obj_->getPdPools(xpath)); + ASSERT_TRUE(pools); + ASSERT_EQ(Element::list, pools->getType()); + ASSERT_EQ(1, pools->size()); + EXPECT_TRUE(pool->equals(*pools->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +// 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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // 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; + S_Val s_delegated(new Val(dl)); + EXPECT_NO_THROW(sess_->set_item(x_delegated.c_str(), s_delegated)); + + // 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; + S_Val s_delegated2(new Val(dl2)); + EXPECT_NO_THROW(sess_->set_item(x_delegated2.c_str(), s_delegated2)); + + + // Get the pools list. + ConstElementPtr pools; + EXPECT_NO_THROW(pools = t_obj_->getPdPools(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..d8386b5 --- /dev/null +++ b/src/lib/yang/tests/translator_pool_unittests.cc @@ -0,0 +1,250 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include +#include + +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 { +public: + + /// Constructor. + TranslatorPoolsTestKeaV4() { + model_ = KEA_DHCP4_SERVER; + } +}; + +class TranslatorPoolsTestKeaV6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorPoolsTestKeaV6() { + model_ = KEA_DHCP6_SERVER; + } +}; +class TranslatorPoolsTestIetfV6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorPoolsTestIetfV6() { + model_ = IETF_DHCPV6_SERVER; + } +}; + +// 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(pools = t_obj_->getPools(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(pools = t_obj_->getPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet_subnet = subnet + "/network-prefix"; + EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet)); + + // 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"; + S_Val s_val(new Val("2001:db8::1:0/112")); + EXPECT_NO_THROW(sess_->set_item(prefix.c_str(), s_val)); + + // Get the pool. + ConstElementPtr pool; + EXPECT_NO_THROW(pool = t_obj_->getPool(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(pools = t_obj_->getPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // 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"; + S_Val s_prefix(new Val("2001:db8::1:0/112", SR_STRING_T)); + EXPECT_NO_THROW(sess_->set_item(x_prefix.c_str(), s_prefix)); + + // Get the pool. + ConstElementPtr pool; + EXPECT_NO_THROW(pool = t_obj_->getPool(spool.str())); + ASSERT_TRUE(pool); + ElementPtr expected = Element::createMap(); + expected->set("pool", Element::create(string("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(pools = t_obj_->getPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet_subnet = subnet + "/network-prefix"; + EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet)); + + // Set empty list. + const string& xpath = subnet + "/address-pools"; + ConstElementPtr pools = Element::createList(); + EXPECT_NO_THROW(t_obj_->setPools(xpath, pools)); + + // Get it back. + pools.reset(); + EXPECT_NO_THROW(pools = t_obj_->getPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // Set empty list. + ConstElementPtr pools = Element::createList(); + EXPECT_NO_THROW(t_obj_->setPools(xpath, pools)); + + // Get it back. + pools.reset(); + EXPECT_NO_THROW(pools = t_obj_->getPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet_subnet = subnet + "/network-prefix"; + EXPECT_NO_THROW(sess_->set_item(subnet_subnet.c_str(), v_subnet)); + + // Set one pool. + const string& xpath = subnet + "/address-pools"; + ElementPtr pools = Element::createList(); + ElementPtr pool = Element::createMap(); + pool->set("pool", Element::create(string("2001:db8::1:0/112"))); + pools->add(pool); + EXPECT_NO_THROW(t_obj_->setPools(xpath, pools)); + + // Get it back. + pools.reset(); + EXPECT_NO_THROW(pools = t_obj_->getPools(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& subnet = xpath + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(subnet.c_str(), v_subnet)); + + // Set one pool. + ElementPtr pools = Element::createList(); + ElementPtr pool = Element::createMap(); + pool->set("pool", + Element::create(string("2001:db8::1 - 2001:db8::100"))); + pools->add(pool); + EXPECT_NO_THROW(t_obj_->setPools(xpath, pools)); + + // Get it back. + pools.reset(); + EXPECT_NO_THROW(pools = t_obj_->getPools(xpath)); + ASSERT_TRUE(pools); + ASSERT_EQ(Element::list, pools->getType()); + ASSERT_EQ(1, pools->size()); + EXPECT_TRUE(pool->equals(*pools->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +} // 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..2534700 --- /dev/null +++ b/src/lib/yang/tests/translator_shared_network_unittests.cc @@ -0,0 +1,209 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include + +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 { +public: + + /// Constructor. + TranslatorSharedNetworksTestKeaV4() { + model_ = KEA_DHCP4_SERVER; + } +}; +class TranslatorSharedNetworksTestKeaV6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorSharedNetworksTestKeaV6() { + model_ = KEA_DHCP6_SERVER; + } +}; + +// 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(networks = t_obj_->getSharedNetworks(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"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet)); + + // Get the shared network. + ConstElementPtr network; + EXPECT_NO_THROW(network = t_obj_->getSharedNetwork(xnetwork)); + ASSERT_TRUE(network); + ElementPtr subnet = Element::createMap(); + subnet->set("id", Element::create(111)); + subnet->set("subnet", Element::create(string("2001:db8::/48"))); + ElementPtr subnets = Element::createList(); + subnets->add(subnet); + ElementPtr expected = Element::createMap(); + expected->set("name", Element::create(string("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(networks = t_obj_->getSharedNetworks(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(t_obj_->setSharedNetworks(xpath, networks)); + + // Get it back. + networks.reset(); + EXPECT_NO_THROW(networks = t_obj_->getSharedNetworks(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(string("2001:db8::/48"))); + subnet->set("id", Element::create(123)); + subnets->add(subnet); + share->set("name", Element::create(string("foo"))); + share->set("subnet6", subnets); + networks->add(share); + EXPECT_NO_THROW(t_obj_->setSharedNetworks(xpath, networks)); + + // Get it back. + networks.reset(); + EXPECT_NO_THROW(networks = t_obj_->getSharedNetworks(xpath)); + ASSERT_TRUE(networks); + ASSERT_EQ(Element::list, networks->getType()); + ASSERT_EQ(1, networks->size()); + EXPECT_TRUE(share->equals(*networks->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +// 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"; + S_Val v_subnet1(new Val("2001:db8:1::/48", SR_STRING_T)); + EXPECT_NO_THROW(sess_->set_item(xsubnet1.c_str(), v_subnet1)); + + // Create the subnet2: 2001:db8:2::/48 #2 in shared network foo. + const string& xsubnet2 = xnetwork1 + "/subnet6[id='2']/subnet"; + S_Val v_subnet2(new Val("2001:db8:2::/48", SR_STRING_T)); + EXPECT_NO_THROW(sess_->set_item(xsubnet2.c_str(), v_subnet2)); + + // Create the subnet1: 2001:db8:101::/48 #101 in shared network foo. + const string& xsubnet3 = xnetwork2 + "/subnet6[id='101']/subnet"; + S_Val v_subnet(new Val("2001:db8:101::/48", SR_STRING_T)); + EXPECT_NO_THROW(sess_->set_item(xsubnet3.c_str(), v_subnet)); + + // Create the subnet2: 2001:db8:2::/48 #2 in shared network foo. + const string& xsubnet4 = xnetwork2 + "/subnet6[id='102']/subnet"; + S_Val v_subnet4(new Val("2001:db8:102::/48", SR_STRING_T)); + EXPECT_NO_THROW(sess_->set_item(xsubnet4.c_str(), v_subnet4)); + + // 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(network = t_obj_->getSharedNetwork(xnetwork1)); + ASSERT_TRUE(network); + EXPECT_EQ(exp_net1, network->str()); + + // Get the second network. + EXPECT_NO_THROW(network = t_obj_->getSharedNetwork(xnetwork2)); + ASSERT_TRUE(network); + EXPECT_EQ(exp_net2, network->str()); + + // Check that networks with non-existent name are not returned. + EXPECT_THROW(network = t_obj_->getSharedNetwork(xnetwork3), Unexpected); + + // Now test returns all networks + ConstElementPtr networks; + EXPECT_NO_THROW(networks = t_obj_->getSharedNetworks(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..cc34596 --- /dev/null +++ b/src/lib/yang/tests/translator_subnet_unittests.cc @@ -0,0 +1,379 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include + +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 { +public: + + /// Constructor. + TranslatorSubnetsTestKeaV4() { + model_ = KEA_DHCP4_SERVER; + } +}; +class TranslatorSubnetsTestKeaV6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorSubnetsTestKeaV6() { + model_ = KEA_DHCP6_SERVER; + } +}; +class TranslatorSubnetsTestIetfV6 : + public GenericTranslatorTest { +public: + + /// Constructor. + TranslatorSubnetsTestIetfV6() { + model_ = IETF_DHCPV6_SERVER; + } +}; + +// 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(subnets = t_obj_->getSubnets(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(subnets = t_obj_->getSubnets(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& xsubnet = xsub + "/network-prefix"; + EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet)); + + // Get the subnet. + ConstElementPtr subnet; + EXPECT_NO_THROW(subnet = t_obj_->getSubnet(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(subnets = t_obj_->getSubnets(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& xsubnet = xsub + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet)); + + // Get the subnet. + ConstElementPtr subnet; + EXPECT_NO_THROW(subnet = t_obj_->getSubnet(xsub)); + ASSERT_TRUE(subnet); + ElementPtr expected = Element::createMap(); + expected->set("id", Element::create(111)); + expected->set("subnet", Element::create(string("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(subnets = t_obj_->getSubnets(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& xsubnet = xsub + "/network-prefix"; + EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet)); + + // 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"; + S_Val s_pool1(new Val("2001:db8::1:0/112")); + EXPECT_NO_THROW(sess_->set_item(prefix1.c_str(), s_pool1)); + + // Create the pool 2001:db8::2:0/112 #2. + const string& prefix2 = xpool + "/address-pool[pool-id='2']/pool-prefix"; + S_Val s_pool2(new Val("2001:db8::2:0/112")); + EXPECT_NO_THROW(sess_->set_item(prefix2.c_str(), s_pool2)); + + // Get the subnet. + ConstElementPtr subnet; + EXPECT_NO_THROW(subnet = t_obj_->getSubnet(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(subnets = t_obj_->getSubnets(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']"; + S_Val v_subnet(new Val("2001:db8::/48", SR_STRING_T)); + const string& xsubnet = xsub + "/subnet"; + EXPECT_NO_THROW(sess_->set_item(xsubnet.c_str(), v_subnet)); + + // 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"; + S_Val s_pool1(new Val("2001:db8::1:0/112", SR_STRING_T)); + EXPECT_NO_THROW(sess_->set_item(prefix1.c_str(), s_pool1)); + + // 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']"; + S_Val s_pool2; + EXPECT_NO_THROW(sess_->set_item(prefix2.c_str(), s_pool2)); + + // Get the subnet. + ConstElementPtr subnet; + EXPECT_NO_THROW(subnet = t_obj_->getSubnet(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(subnets = t_obj_->getSubnets(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(t_obj_->setSubnets(xpath, subnets)); + + // Get it back. + subnets.reset(); + EXPECT_NO_THROW(subnets = t_obj_->getSubnets(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(t_obj_->setSubnets(xpath, subnets)); + + // Get it back. + subnets.reset(); + EXPECT_NO_THROW(subnets = t_obj_->getSubnets(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(string("2001:db8::/48"))); + subnet->set("id", Element::create(123)); + subnets->add(subnet); + EXPECT_NO_THROW(t_obj_->setSubnets(xpath, subnets)); + + // Get it back. + subnets.reset(); + EXPECT_NO_THROW(subnets = t_obj_->getSubnets(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(string("10.0.1.0/24"))); + subnet->set("id", Element::create(123)); + subnets->add(subnet); + EXPECT_NO_THROW(t_obj_->setSubnets(xpath, subnets)); + + // Get it back. + subnets.reset(); + EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath)); + ASSERT_TRUE(subnets); + ASSERT_EQ(Element::list, subnets->getType()); + ASSERT_EQ(1, subnets->size()); + EXPECT_TRUE(subnet->equals(*subnets->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +// 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(string("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(string("2001:db8::1:0/112"))); + pools->add(pool1); + ElementPtr pool2 = Element::createMap(); + pool2->set("pool", Element::create(string("2001:db8::2:0/112"))); + pools->add(pool2); + subnet->set("pools", pools); + + // Add the subnet. + subnets->add(subnet); + EXPECT_NO_THROW(t_obj_->setSubnets(xpath, subnets)); + + // Get it back. + subnets.reset(); + EXPECT_NO_THROW(subnets = t_obj_->getSubnets(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(string("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(string("10.0.1.0/28"))); + pools->add(pool1); + ElementPtr pool2 = Element::createMap(); + pool2->set("pool", Element::create(string("10.0.1.200 - 10.0.1.222"))); + pools->add(pool2); + subnet->set("pools", pools); + + // Add the subnet. + subnets->add(subnet); + EXPECT_NO_THROW(t_obj_->setSubnets(xpath, subnets)); + + // Get it back. + subnets.reset(); + EXPECT_NO_THROW(subnets = t_obj_->getSubnets(xpath)); + ASSERT_TRUE(subnets); + ASSERT_EQ(Element::list, subnets->getType()); + ASSERT_EQ(1, subnets->size()); + EXPECT_TRUE(subnet->equals(*subnets->get(0))); + + // Check it validates. + EXPECT_NO_THROW(sess_->validate()); +} + +} // 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..a602b28 --- /dev/null +++ b/src/lib/yang/tests/translator_unittests.cc @@ -0,0 +1,683 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include + +#include + +#include + +using namespace std; +using namespace isc; +using namespace isc::data; +using namespace isc::yang; +using namespace sysrepo; + +using libyang::S_Data_Node; + +namespace { + +// Test constructor. +TEST(TranslatorBasicTest, constructor) { + // Get a connection. + S_Connection conn(std::make_shared()); + // Get a session. + S_Session sess(new Session(conn, SR_DS_CANDIDATE)); + // Get a translator object. + boost::scoped_ptr t_obj; + EXPECT_NO_THROW(t_obj.reset(new TranslatorBasic(sess, ""))); +} + +// Test basic yang value to JSON using the static method. +TEST(TranslatorBasicTest, valueFrom) { + S_Val s_val; + ConstElementPtr elem; + + // Null. + EXPECT_THROW(TranslatorBasic::value(s_val), BadValue); + + // No easy and direct way to build a container or a list... + + // String. + string str("foo"); + s_val.reset(new Val(str.c_str(), SR_STRING_T)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::string, elem->getType()); + EXPECT_EQ(str, elem->stringValue()); + elem.reset(); + + // Bool. + s_val.reset(new Val(false, SR_BOOL_T)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::boolean, elem->getType()); + EXPECT_FALSE(elem->boolValue()); + elem.reset(); + + // Unsigned 8 bit integer. + uint8_t u8(123); + s_val.reset(new Val(u8)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(u8, elem->intValue()); + elem.reset(); + + // Unsigned 16 bit integer. + uint16_t u16(12345); + s_val.reset(new Val(u16)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(u16, elem->intValue()); + elem.reset(); + + // Unsigned 32 bit integer. + uint32_t u32(123456789); + s_val.reset(new Val(u32)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(u32, elem->intValue()); + elem.reset(); + + // Signed 8 bit integer. + int8_t s8(-123); + s_val.reset(new Val(s8)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(s8, elem->intValue()); + elem.reset(); + + // Signed 16 bit integer. + int16_t s16(-12345); + s_val.reset(new Val(s16)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(s16, elem->intValue()); + elem.reset(); + + // Signed 32 bit integer. + int32_t s32(-123456789); + s_val.reset(new Val(s32)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(s32, elem->intValue()); + elem.reset(); + + // Identity reference. + s_val.reset(new Val(str.c_str(), SR_IDENTITYREF_T)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::string, elem->getType()); + EXPECT_EQ(str, elem->stringValue()); + elem.reset(); + + // Enumeration item. + s_val.reset(new Val(str.c_str(), SR_ENUM_T)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::string, elem->getType()); + EXPECT_EQ(str, elem->stringValue()); + elem.reset(); + + // Binary. + string binary("Zm9vYmFy"); + s_val.reset(new Val(binary.c_str(), SR_BINARY_T)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::string, elem->getType()); + EXPECT_EQ("foobar", elem->stringValue()); + elem.reset(); + + // Decimal 64. + double d64(.1234); + s_val.reset(new Val(d64)); + EXPECT_NO_THROW(elem = TranslatorBasic::value(s_val)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::real, elem->getType()); + EXPECT_DOUBLE_EQ(d64, elem->doubleValue()); +} + +// Test basic yang value to JSON using sysrepo test models. +TEST(TranslatorBasicTest, getItem) { + // Get a translator object to play with. + S_Connection conn(std::make_shared()); + S_Session sess(new Session(conn, SR_DS_CANDIDATE)); + boost::scoped_ptr t_obj; + ASSERT_NO_THROW_LOG(t_obj.reset(new TranslatorBasic(sess, ""))); + S_Val s_val; + ConstElementPtr elem; + string xpath; + + // String. + xpath = "/keatest-module:main/string"; + s_val.reset(new Val("str", SR_STRING_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::string, elem->getType()); + EXPECT_EQ("str", elem->stringValue()); + elem.reset(); + + // Bool. + xpath = "/keatest-module:main/boolean"; + s_val.reset(new Val(true, SR_BOOL_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::boolean, elem->getType()); + EXPECT_TRUE(elem->boolValue()); + elem.reset(); + + // Unsigned 8 bit integer. + xpath = "/keatest-module:main/ui8"; + uint8_t u8(8); + s_val.reset(new Val(u8)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(8, elem->intValue()); + elem.reset(); + + // Unsigned 16 bit integer. + xpath = "/keatest-module:main/ui16"; + uint16_t u16(16); + s_val.reset(new Val(u16)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(16, elem->intValue()); + elem.reset(); + + // Unsigned 32 bit integer. + xpath = "/keatest-module:main/ui32"; + uint32_t u32(32); + s_val.reset(new Val(u32)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(32, elem->intValue()); + elem.reset(); + + // Signed 8 bit integer. + xpath = "/keatest-module:main/i8"; + int8_t s8(8); + s_val.reset(new Val(s8)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(8, elem->intValue()); + elem.reset(); + + // Signed 16 bit integer. + xpath = "/keatest-module:main/i16"; + int16_t s16(16); + s_val.reset(new Val(s16)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(16, elem->intValue()); + elem.reset(); + + // Signed 32 bit integer. + xpath = "/keatest-module:main/i32"; + int32_t s32(32); + s_val.reset(new Val(s32)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::integer, elem->getType()); + EXPECT_EQ(32, elem->intValue()); + elem.reset(); + + // Identity reference. + xpath = "/keatest-module:main/id_ref"; + s_val.reset(new Val("keatest-module:id_1", SR_IDENTITYREF_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::string, elem->getType()); + EXPECT_EQ("keatest-module:id_1", elem->stringValue()); + elem.reset(); + + // Enumeration item. + xpath = "/keatest-module:main/enum"; + s_val.reset(new Val("maybe", SR_ENUM_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::string, elem->getType()); + EXPECT_EQ("maybe", elem->stringValue()); + elem.reset(); + + // Binary. + xpath = "/keatest-module:main/raw"; + s_val.reset(new Val("Zm9vYmFy", SR_BINARY_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::string, elem->getType()); + EXPECT_EQ("foobar", elem->stringValue()); + elem.reset(); + + // Leaf-list: not yet exist. + xpath = "/keatest-module:main/numbers"; + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + EXPECT_FALSE(elem); + elem.reset(); + + // No easy way to create it empty. + + // Leaf-list: 1, 2 and 3. + u8 = 1; + s_val.reset(new Val(u8)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + u8 = 2; + s_val.reset(new Val(u8)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + u8 = 3; + s_val.reset(new Val(u8)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItems(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::list, elem->getType()); + EXPECT_EQ(3, elem->size()); + EXPECT_EQ("[ 1, 2, 3 ]", elem->str()); + elem.reset(); + + // Unknown / unsupported. + xpath = "/keatest-module:main/dec64"; + s_val.reset(new Val(9.85)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(elem = t_obj->getItem(xpath)); + ASSERT_TRUE(elem); + ASSERT_EQ(Element::real, elem->getType()); + EXPECT_EQ("9.85", elem->str()); + elem.reset(); + + // Not found. + xpath = "/keatest-module:main/no_such_string"; + + // sysrepo_exception: "Invalid argument" + EXPECT_THROW(sess->delete_item(xpath.c_str()), sysrepo_exception); + EXPECT_THROW(elem = t_obj->getItem(xpath), SysrepoError); + EXPECT_FALSE(elem); + elem.reset(); + + // Check error. + xpath = "null"; + try { + elem = t_obj->getItem(xpath); + ADD_FAILURE() << "expected exception"; + } catch (const SysrepoError& ex) { + EXPECT_EQ("sysrepo error getting item at 'null': libyang error", + string(ex.what())); + } catch (const std::exception& ex) { + ADD_FAILURE() << "unexpected exception with: " << ex.what(); + } +} + +// Test JSON to basic yang value using the static method. +TEST(TranslatorBasicTest, valueTo) { + + // Null. + ConstElementPtr elem; + EXPECT_THROW(TranslatorBasic::value(elem, SR_STRING_T), BadValue); + + // Container. + elem = Element::createMap(); + EXPECT_THROW(TranslatorBasic::value(elem, SR_CONTAINER_T), NotImplemented); + EXPECT_THROW(TranslatorBasic::value(elem, SR_CONTAINER_PRESENCE_T), NotImplemented); + + // List. + elem = Element::createList(); + S_Val s_val; + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_LIST_T)); + EXPECT_FALSE(s_val); + s_val.reset(); + + // String. + string str("foo"); + elem = Element::create(str); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_STRING_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_STRING_T, s_val->type()); + EXPECT_EQ(str, string(s_val->data()->get_string())); + s_val.reset(); + + // Bool. + elem = Element::create(false); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_BOOL_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_BOOL_T, s_val->type()); + EXPECT_FALSE(s_val->data()->get_bool()); + s_val.reset(); + + // Unsigned 8 bit integer. + elem = Element::create(123); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_UINT8_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_UINT8_T, s_val->type()); + EXPECT_EQ(123, s_val->data()->get_uint8()); + elem.reset(); + + // Unsigned 16 bit integer. + elem = Element::create(12345); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_UINT16_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_UINT16_T, s_val->type()); + EXPECT_EQ(12345, s_val->data()->get_uint16()); + elem.reset(); + + // Unsigned 32 bit integer. + elem = Element::create(123456789); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_UINT32_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_UINT32_T, s_val->type()); + EXPECT_EQ(123456789, s_val->data()->get_uint32()); + elem.reset(); + + // Signed 8 bit integer. + elem = Element::create(-123); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_INT8_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_INT8_T, s_val->type()); + EXPECT_EQ(-123, s_val->data()->get_int8()); + elem.reset(); + + // Signed 16 bit integer. + elem = Element::create(-12345); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_INT16_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_INT16_T, s_val->type()); + EXPECT_EQ(-12345, s_val->data()->get_int16()); + elem.reset(); + + // Signed 32 bit integer. + elem = Element::create(-123456789); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_INT32_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_INT32_T, s_val->type()); + EXPECT_EQ(-123456789, s_val->data()->get_int32()); + elem.reset(); + + // Identity reference. + elem = Element::create(str); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_IDENTITYREF_T)); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_IDENTITYREF_T, s_val->type()); + EXPECT_EQ(str, string(s_val->data()->get_identityref())); + s_val.reset(); + + // Enumeration item. + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_ENUM_T)); + ASSERT_TRUE(s_val); + EXPECT_EQ(str, string(s_val->data()->get_enum())); + s_val.reset(); + + // Binary. + elem = Element::create(string("foobar")); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_BINARY_T)); + ASSERT_TRUE(s_val); + EXPECT_EQ("Zm9vYmFy", string(s_val->data()->get_binary())); + s_val.reset(); + + // Decimal 64. + double d64(.1234); + elem = Element::create(d64); + EXPECT_NO_THROW(s_val = TranslatorBasic::value(elem, SR_DECIMAL64_T)); + ASSERT_TRUE(s_val); + EXPECT_DOUBLE_EQ(d64, s_val->data()->get_decimal64()); + s_val.reset(); +} + +// Test JSON to basic yang value using sysrepo test models. +TEST(TranslatorBasicTest, setItem) { + // Get a translator object to play with. + S_Connection conn(std::make_shared()); + S_Session sess(new Session(conn, SR_DS_CANDIDATE)); + boost::scoped_ptr t_obj; + ASSERT_NO_THROW_LOG(t_obj.reset(new TranslatorBasic(sess, ""))); + + // Container. + string xpath = "/keatest-module:container"; + ConstElementPtr elem = Element::createMap(); + EXPECT_THROW(t_obj->setItem(xpath, elem, SR_CONTAINER_T), NotImplemented); + EXPECT_THROW(t_obj->setItem(xpath, elem, SR_CONTAINER_PRESENCE_T), + NotImplemented); + + // String. + S_Val s_val; + xpath = "/keatest-module:main/string"; + elem = Element::create(string("str")); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_STRING_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_STRING_T, s_val->type()); + EXPECT_EQ("str", string(s_val->data()->get_string())); + s_val.reset(); + + // Bool. + xpath = "/keatest-module:main/boolean"; + elem = Element::create(true); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_BOOL_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_BOOL_T, s_val->type()); + EXPECT_TRUE(s_val->data()->get_bool()); + s_val.reset(); + + // Unsigned 8 bit integer. + xpath = "/keatest-module:main/ui8"; + elem = Element::create(8); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_UINT8_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_UINT8_T, s_val->type()); + EXPECT_EQ(8, s_val->data()->get_uint8()); + s_val.reset(); + + // Unsigned 16 bit integer. + xpath = "/keatest-module:main/ui16"; + elem = Element::create(16); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_UINT16_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_UINT16_T, s_val->type()); + EXPECT_EQ(16, s_val->data()->get_uint16()); + s_val.reset(); + + // Unsigned 32 bit integer. + xpath = "/keatest-module:main/ui32"; + elem = Element::create(32); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_UINT32_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_UINT32_T, s_val->type()); + EXPECT_EQ(32, s_val->data()->get_uint32()); + s_val.reset(); + + // Signed 8 bit integer. + xpath = "/keatest-module:main/i8"; + elem = Element::create(8); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_INT8_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_INT8_T, s_val->type()); + EXPECT_EQ(8, s_val->data()->get_int8()); + s_val.reset(); + + // Signed 16 bit integer. + xpath = "/keatest-module:main/i16"; + elem = Element::create(16); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_INT16_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_INT16_T, s_val->type()); + EXPECT_EQ(16, s_val->data()->get_int16()); + s_val.reset(); + + // Signed 32 bit integer. + xpath = "/keatest-module:main/i32"; + elem = Element::create(32); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_INT32_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_INT32_T, s_val->type()); + EXPECT_EQ(32, s_val->data()->get_int32()); + s_val.reset(); + + // Identity reference. + xpath = "/keatest-module:main/id_ref"; + elem = Element::create(string("keatest-module:id_1")); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_IDENTITYREF_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_IDENTITYREF_T, s_val->type()); + EXPECT_EQ("keatest-module:id_1", string(s_val->data()->get_identityref())); + s_val.reset(); + + // Enumeration item. + xpath = "/keatest-module:main/enum"; + elem = Element::create(string("maybe")); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_ENUM_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_ENUM_T, s_val->type()); + EXPECT_EQ("maybe", string(s_val->data()->get_enum())); + s_val.reset(); + + // Binary. + xpath = "/keatest-module:main/raw"; + elem = Element::create(string("foobar")); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_BINARY_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_BINARY_T, s_val->type()); + EXPECT_EQ("Zm9vYmFy", string(s_val->data()->get_binary())); + s_val.reset(); + + // Decimal 64. + xpath = "/keatest-module:main/dec64"; + double d64(9.85); + elem = Element::create(d64); + EXPECT_NO_THROW(t_obj->setItem(xpath, elem, SR_DECIMAL64_T)); + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + ASSERT_TRUE(s_val); + ASSERT_EQ(SR_DECIMAL64_T, s_val->type()); + EXPECT_DOUBLE_EQ(d64, s_val->data()->get_decimal64()); + s_val.reset(); + + // Leaf-list. + xpath = "/keatest-module:main/numbers"; + S_Data_Node data_node; + EXPECT_NO_THROW(data_node = sess->get_subtree(xpath.c_str())); + EXPECT_FALSE(data_node); + data_node.reset(); + + // Fill it. + sess->set_item_str(xpath.c_str(), "1"); + sess->set_item_str(xpath.c_str(), "2"); + sess->set_item_str(xpath.c_str(), "3"); + sess->apply_changes(); + + // sysrepo_exception: "Invalid argument" + EXPECT_THROW(data_node = sess->get_subtree(xpath.c_str()), + sysrepo_exception); + EXPECT_FALSE(data_node); + data_node.reset(); + + // Clean it. + EXPECT_NO_THROW(t_obj->delItem(xpath)); + EXPECT_NO_THROW(data_node = sess->get_subtree(xpath.c_str())); + EXPECT_FALSE(data_node); + data_node.reset(); + + // Bad xpath. + xpath = "/keatest-module:main/no_such_string"; + elem = Element::create(string("str")); + try { + t_obj->setItem(xpath, elem, SR_STRING_T); + ADD_FAILURE() << "expected exception"; + } catch (const SysrepoError& ex) { + string expected = "sysrepo error setting item '\"str\"' at '" + + xpath + "': Invalid argument"; + EXPECT_EQ(expected, string(ex.what())); + } catch (const std::exception& ex) { + ADD_FAILURE() << "unexpected exception with: " << ex.what(); + } + + // Bad type. + xpath = "/keatest-module:main/string"; + elem = Element::create(true); + try { + t_obj->setItem(xpath, elem, SR_BOOL_T); + } catch (const SysrepoError& ex) { + ADD_FAILURE() << "unexpected exception with: " << ex.what(); + } catch (const std::exception& ex) { + ADD_FAILURE() << "unexpected exception with: " << ex.what(); + } + + // In sysrepo 1.x, set_item() is based on set_item_str() which sets the + // value in textual format. After setting a value with SR_BOOL_T, it's value + // is now "true". :) + elem = t_obj->getItem(xpath); + ASSERT_TRUE(elem); + EXPECT_EQ(elem->getType(), Element::string); + EXPECT_EQ(elem->str(), "\"true\""); + + // Delete (twice). + xpath = "/keatest-module:main/string"; + EXPECT_NO_THROW(s_val = sess->get_item(xpath.c_str())); + EXPECT_TRUE(s_val); + s_val.reset(); + EXPECT_NO_THROW(t_obj->delItem(xpath)); + + // sysrepo_exception: "Item not found" + EXPECT_THROW(s_val = sess->get_item(xpath.c_str()), sysrepo_exception); + EXPECT_FALSE(s_val); + EXPECT_NO_THROW(t_obj->delItem(xpath)); +} + +// Test yang list item retrieval. +TEST(TranslatorBasicTest, list) { + // Get a translator object to play with. + S_Connection conn(std::make_shared()); + S_Session sess(new Session(conn, SR_DS_CANDIDATE)); + boost::scoped_ptr t_obj; + ASSERT_NO_THROW_LOG(t_obj.reset(new TranslatorBasic(sess, ""))); + string xpath; + + // Empty list. + ElementPtr element; + EXPECT_NO_THROW(element = t_obj->getItem("/keatest-module:container/list")); + EXPECT_FALSE(element); + element.reset(); + + // Retried with a filled list. + xpath = "/keatest-module:container/list[key1='key1'][key2='key2']/leaf"; + S_Val s_val(new Val("Leaf value")); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(element = t_obj->getItem("/keatest-module:container/list")); + ASSERT_TRUE(element); + EXPECT_NO_THROW(element = t_obj->getItem("/keatest-module:container/list[key1='key1'][key2='key2']")); + ASSERT_TRUE(element); +} + +} // 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..bc68f12 --- /dev/null +++ b/src/lib/yang/tests/translator_utils_unittests.cc @@ -0,0 +1,270 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +#include + +#include + +using namespace std; +using namespace isc; +using namespace isc::yang; +using namespace isc::yang::test; +using namespace sysrepo; + +namespace { + +// Test sr_type_t print. +TEST(YangReprTest, type) { + ostringstream os; + + // Verify that string is "string" (vs a number). + sr_type_t t = SR_STRING_T; + 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", SR_STRING_T, true); + EXPECT_EQ("/foo", item1.xpath_); + EXPECT_EQ("bar", item1.value_); + EXPECT_EQ(SR_STRING_T, item1.type_); + EXPECT_TRUE(item1.settable_); + + // Another one. + YRItem item2("/foo", "bar", SR_STRING_T, false); + EXPECT_EQ("/foo", item2.xpath_); + EXPECT_EQ("bar", item2.value_); + EXPECT_EQ(SR_STRING_T, item2.type_); + EXPECT_FALSE(item2.settable_); + + // 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. + S_Connection conn(std::make_shared()); + S_Session sess(new Session(conn, SR_DS_CANDIDATE)); + + // Cleanup. + EXPECT_NO_THROW(sess->delete_item("/keatest-module:container")); + EXPECT_NO_THROW(sess->apply_changes()); + EXPECT_NO_THROW(sess->delete_item("/keatest-module:main")); + EXPECT_NO_THROW(sess->apply_changes()); + + // Fill the test module. + string xpath; + S_Val s_val; + + xpath = "/keatest-module:main/string"; + s_val.reset(new Val("str", SR_STRING_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/boolean"; + s_val.reset(new Val(true, SR_BOOL_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/ui8"; + uint8_t u8(8); + s_val.reset(new Val(u8)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/ui16"; + uint16_t u16(16); + s_val.reset(new Val(u16)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/ui32"; + uint32_t u32(32); + s_val.reset(new Val(u32)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/i8"; + int8_t s8(8); + s_val.reset(new Val(s8)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/i16"; + int16_t s16(16); + s_val.reset(new Val(s16)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/i32"; + int32_t s32(32); + s_val.reset(new Val(s32)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/id_ref"; + s_val.reset(new Val("keatest-module:id_1", SR_IDENTITYREF_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + xpath = "/keatest-module:main/enum"; + s_val.reset(new Val("maybe", SR_ENUM_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + // Binary. + xpath = "/keatest-module:main/raw"; + s_val.reset(new Val("Zm9vYmFy", SR_BINARY_T)); + EXPECT_NO_THROW(sess->set_item(xpath.c_str(), s_val)); + EXPECT_NO_THROW(sess->apply_changes()); + + // Get it. + YangRepr repr(testModel); + YRTree tree; + EXPECT_NO_THROW(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. + S_Connection conn(std::make_shared()); + S_Session sess(new Session(conn, SR_DS_CANDIDATE)); + + // Cleanup. + EXPECT_NO_THROW(sess->delete_item("/keatest-module:container")); + EXPECT_NO_THROW(sess->apply_changes()); + EXPECT_NO_THROW(sess->delete_item("/keatest-module:main")); + EXPECT_NO_THROW(sess->apply_changes()); + + // Get it. + YangRepr repr(testModel); + YRTree tree; + EXPECT_NO_THROW(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 SR_INT32_T to SR_UINT32_T. + YRTree badtype = testTree; + xpath = "/keatest-module:main/i32"; + badtype.at(xpath).type_ = SR_UINT32_T; + EXPECT_FALSE(repr.verify(badtype, sess, cerr)); + + // Add a record at the end. + YRTree badmissing = testTree; + xpath = "/keatest-module:presence-container"; + badmissing.emplace(xpath, YRItem(xpath, "", SR_CONTAINER_PRESENCE_T, false)); + EXPECT_FALSE(repr.verify(badmissing, 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. + S_Connection conn(std::make_shared()); + S_Session sess(new Session(conn, SR_DS_CANDIDATE)); + + // Cleanup. + EXPECT_NO_THROW(sess->delete_item("/keatest-module:container")); + EXPECT_NO_THROW(sess->apply_changes()); + EXPECT_NO_THROW(sess->delete_item("/keatest-module:main")); + EXPECT_NO_THROW(sess->apply_changes()); + + // Set the module content. + YangRepr repr(testModel); + EXPECT_NO_THROW(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 std::string& model, const YRTree& tree) { + SysrepoSetup::cleanSharedMemory(); + + // Get a translator object to play with. + S_Connection conn(std::make_shared()); + S_Session sess(new Session(conn, SR_DS_CANDIDATE)); + + // Cleanup. + TranslatorBasic translator(sess, model); + std::string toplevel_node("config"); + if (model == IETF_DHCPV6_SERVER) { + toplevel_node = "server"; + } + translator.delItem("/" + model + ":" + toplevel_node); + + // Get it. + YangRepr repr(model); + + EXPECT_NO_THROW(repr.set(tree, sess)) + << " for model " << model; + bool result = false; + EXPECT_NO_THROW(result = repr.verify(tree, sess, cerr)) + << " for model " << model; + EXPECT_TRUE(result) + << " for model " << model; +} + +// 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..71a89ea --- /dev/null +++ b/src/lib/yang/tests/yang_configs.h @@ -0,0 +1,591 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef ISC_YANG_CONFIGS_H +#define ISC_YANG_CONFIGS_H + +#include +#include + +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", "", SR_CONTAINER_T, false }, + { "/keatest-module:main", "", SR_CONTAINER_T, false }, + { "/keatest-module:main/string", "str", SR_STRING_T, true }, + { "/keatest-module:main/boolean", "true", SR_BOOL_T, true }, + { "/keatest-module:main/ui8", "8", SR_UINT8_T, true }, + { "/keatest-module:main/ui16", "16", SR_UINT16_T, true }, + { "/keatest-module:main/ui32", "32", SR_UINT32_T, true }, + { "/keatest-module:main/i8", "8", SR_INT8_T, true }, + { "/keatest-module:main/i16", "16", SR_INT16_T, true }, + { "/keatest-module:main/i32", "32", SR_INT32_T, true }, + { "/keatest-module:main/id_ref", "keatest-module:id_1", + SR_IDENTITYREF_T, true }, + { "/keatest-module:main/enum", "maybe", SR_ENUM_T, true }, + { "/keatest-module:main/raw", "Zm9vYmFy", SR_BINARY_T, true }, + { "/keatest-module:kernel-modules", "", SR_CONTAINER_T, 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", "", SR_CONTAINER_PRESENCE_T, false }, + { "/ietf-dhcpv6-server:server/server-config", "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']", "", SR_LIST_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/network-range-id", + "111", SR_UINT32_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/network-prefix", + "2001:db8::/48", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/address-pools/" + "address-pool[pool-id='0']", "", SR_LIST_T, 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", SR_UINT32_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_ENUM_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/address-pools/" + "address-pool[pool-id='1']", "", SR_LIST_T, 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", SR_UINT32_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_ENUM_T, true }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid/type-code", + "65535", SR_UINT16_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/address-pools", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/pd-pools", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/host-reservations", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/lease-storage", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/option-sets", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/relay-opaque-paras", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/rsoo-enabled-options", + "", SR_CONTAINER_T, 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", "", SR_CONTAINER_PRESENCE_T, false }, + { "/ietf-dhcpv6-server:server/server-config", "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']", "", SR_LIST_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/network-range-id", + "111", SR_UINT32_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/network-prefix", + "2001:db8::/48", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/address-pools/" + "address-pool[pool-id='0']", "", SR_LIST_T, 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", SR_UINT32_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_UINT32_T, 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", SR_UINT32_T, 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", SR_ENUM_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/address-pools/" + "address-pool[pool-id='1']", "", SR_LIST_T, 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", SR_UINT32_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_UINT32_T, 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", SR_UINT32_T, 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", SR_ENUM_T, true }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid/type-code", + "65535", SR_UINT16_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/address-pools", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/pd-pools", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/host-reservations", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/lease-storage", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/option-sets", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/relay-opaque-paras", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/rsoo-enabled-options", + "", SR_CONTAINER_T, 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", "", SR_CONTAINER_PRESENCE_T, false }, + { "/ietf-dhcpv6-server:server/server-config", "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes" + "/vendor-info/ent-num", "2495", SR_UINT32_T, true }, + { "/ietf-dhcpv6-server:server/server-config/option-sets", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/option-sets" + "/option-set[option-set-id='0']", "", SR_LIST_T, false }, + { "/ietf-dhcpv6-server:server/server-config/option-sets" + "/option-set[option-set-id='0']/option-set-id", + "0", SR_UINT32_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']", "", SR_LIST_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/network-range-id", + "111", SR_UINT32_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/network-description", + "Subnet#111", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/network-prefix", + "2001:db8::/48", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='0']", "", SR_LIST_T, 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", SR_UINT32_T, 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", SR_STRING_T, 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", SR_UINT8_T, 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", SR_UINT32_T, 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", SR_UINT32_T, 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", SR_UINT32_T, 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", SR_UINT32_T, 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", SR_BOOL_T, 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", SR_UINT32_T, 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", SR_ENUM_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/pd-pools/" + "pd-pool[pool-id='1']", "", SR_LIST_T, 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", SR_UINT32_T, 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", SR_STRING_T, 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", SR_UINT8_T, 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", SR_UINT32_T, 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", SR_UINT32_T, 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", SR_UINT32_T, 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", SR_UINT32_T, 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", SR_BOOL_T, 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", SR_UINT32_T, 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", SR_ENUM_T, true }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid/type-code", + "65535", SR_UINT16_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/address-pools", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/pd-pools", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='111']/host-reservations", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/lease-storage", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/option-sets", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/relay-opaque-paras", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/rsoo-enabled-options", + "", SR_CONTAINER_T, 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", "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/subnet4[id='111']", "", + SR_LIST_T, false }, + { "/kea-dhcp4-server:config/subnet4[id='111']/id", + "111", SR_UINT32_T, false }, + { "/kea-dhcp4-server:config/subnet4[id='111']/" + "option-data[code='100'][space='dns']", "", SR_LIST_T, false }, + { "/kea-dhcp4-server:config/subnet4[id='111']/" + "option-data[code='100'][space='dns']/code", + "100", SR_UINT8_T, false }, + { "/kea-dhcp4-server:config/subnet4[id='111']/" + "option-data[code='100'][space='dns']/space", + "dns", SR_STRING_T, false }, + { "/kea-dhcp4-server:config/subnet4[id='111']/" + "option-data[code='100'][space='dns']/data", + "12121212", SR_STRING_T, true }, + { "/kea-dhcp4-server:config/subnet4[id='111']/" + "option-data[code='100'][space='dns']/csv-format", + "false", SR_BOOL_T, true }, + { "/kea-dhcp4-server:config/subnet4[id='111']/" + "option-data[code='100'][space='dns']/always-send", + "false", SR_BOOL_T, true }, + { "/kea-dhcp4-server:config/subnet4[id='111']/" + "pool[start-address='10.0.1.0'][end-address='10.0.1.255']", + "", SR_LIST_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_STRING_T, true }, + { "/kea-dhcp4-server:config/subnet4[id='111']/subnet", + "10.0.0.0/8", SR_STRING_T, true }, + { "/kea-dhcp4-server:config/expired-leases-processing", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/dhcp-ddns", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/config-control", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/sanity-checks", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/interfaces-config", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/subnet4[id='111']/relay", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/compatibility", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/multi-threading", + "", SR_CONTAINER_T, 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", "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/subnet6[id='111']", "", + SR_LIST_T, false }, + { "/kea-dhcp6-server:config/subnet6[id='111']/id", + "111", SR_UINT32_T, false }, + { "/kea-dhcp6-server:config/subnet6[id='111']/" + "pool[start-address='2001:db8::1:0'][end-address='2001:db8::1:ffff']", + "", SR_LIST_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_STRING_T, 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']", + "", SR_LIST_T, 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", SR_UINT16_T, 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", SR_STRING_T, 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", SR_STRING_T, 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", SR_BOOL_T, 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", SR_BOOL_T, true }, + { "/kea-dhcp6-server:config/subnet6[id='111']/subnet", + "2001:db8::/48", SR_STRING_T, true }, + { "/kea-dhcp6-server:config/expired-leases-processing", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/dhcp-ddns", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/config-control", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/sanity-checks", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/interfaces-config", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/subnet6[id='111']/relay", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/compatibility", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/multi-threading", + "", SR_CONTAINER_T, false }, +}); + +/// @brief Example from the design document. +const std::string designExampleModel = IETF_DHCPV6_SERVER; +const YRTree designExampleTree = YangRepr::buildTreeFromVector({ + { "/ietf-dhcpv6-server:server", "", SR_CONTAINER_PRESENCE_T, false }, + { "/ietf-dhcpv6-server:server/server-config", "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']", "", SR_LIST_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/network-range-id", + "1", SR_UINT32_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/network-description", + "example", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/pd-pools", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/pd-pools/pd-pool[pool-id='0']", + "", SR_LIST_T, 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", SR_UINT32_T, 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", SR_STRING_T, 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", SR_UINT8_T, 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", SR_ENUM_T, true }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/network-prefix", + "2001:db8:20:b00::/56", SR_STRING_T, true }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid/type-code", + "65535", SR_UINT16_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/host-reservations", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/duid", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/lease-storage", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/serv-attributes/vendor-info", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/option-sets", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/relay-opaque-paras", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/rsoo-enabled-options", + "", SR_CONTAINER_T, false }, + { "/ietf-dhcpv6-server:server/server-config/network-ranges/" + "network-range[network-range-id='1']/address-pools", + "", SR_CONTAINER_T, false }, +}); + +const YRTree emptyTreeKeaDhcp4 = YangRepr::buildTreeFromVector({ + { "/kea-dhcp4-server:config", "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/expired-leases-processing", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/dhcp-ddns", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/config-control", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/sanity-checks", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/interfaces-config", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/compatibility", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp4-server:config/multi-threading", + "", SR_CONTAINER_T, false }, +}); + +const YRTree emptyTreeKeaDhcp6 = YangRepr::buildTreeFromVector({ + { "/kea-dhcp6-server:config", "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/expired-leases-processing", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/dhcp-ddns", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/config-control", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/sanity-checks", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/interfaces-config", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/compatibility", + "", SR_CONTAINER_T, false }, + { "/kea-dhcp6-server:config/multi-threading", + "", SR_CONTAINER_T, false }, +}); + +/// @brief Set of example configurations. +const std::vector > TEST_CONFIGS = +{ + { testModel, testTree }, + { subnetTwoPoolsModelIetf6, subnetTwoPoolsTreeIetf6 }, + { subnetTimersModel, subnetTimersIetf6 }, + { validModelIetf6, validTreeIetf6 }, + { subnetOptionsModelKeaDhcp4, subnetOptionsTreeKeaDhcp4 }, + { subnetOptionsModelKeaDhcp6, subnetOptionsTreeKeaDhcp6 }, + { designExampleModel, designExampleTree } +}; + +} // namespace test +} // namespace yang +} // namespace isc + +#endif // ISC_YANG_CONFIGS_H diff --git a/src/lib/yang/testutils/Makefile.am b/src/lib/yang/testutils/Makefile.am new file mode 100644 index 0000000..21035d0 --- /dev/null +++ b/src/lib/yang/testutils/Makefile.am @@ -0,0 +1,24 @@ +SUBDIRS = . + +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib +AM_CPPFLAGS += $(BOOST_INCLUDES) +AM_CPPFLAGS += $(SYSREPO_CPPFLAGS) +AM_CPPFLAGS += $(SYSREPO_INCLUDEDIR) +AM_CXXFLAGS = $(KEA_CXXFLAGS) + +CLEANFILES = *.gcno *.gcda + +if HAVE_GTEST + +noinst_LTLIBRARIES = libyangtest.la + +libyangtest_la_SOURCES = translator_test.cc translator_test.h + +libyangtest_la_CXXFLAGS = $(AM_CXXFLAGS) +libyangtest_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) +libyangtest_la_LDFLAGS = $(AM_LDFLAGS) + +libyangtest_la_LIBADD = $(top_builddir)/src/lib/yang/libkea-yang.la +libyangtest_la_LIBADD += $(top_builddir)/src/lib/log/libkea-log.la + +endif diff --git a/src/lib/yang/testutils/Makefile.in b/src/lib/yang/testutils/Makefile.in new file mode 100644 index 0000000..97c2fdd --- /dev/null +++ b/src/lib/yang/testutils/Makefile.in @@ -0,0 +1,840 @@ +# 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@ +subdir = src/lib/yang/testutils +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/m4macros/ax_boost_for_kea.m4 \ + $(top_srcdir)/m4macros/ax_cpp11.m4 \ + $(top_srcdir)/m4macros/ax_crypto.m4 \ + $(top_srcdir)/m4macros/ax_find_library.m4 \ + $(top_srcdir)/m4macros/ax_gssapi.m4 \ + $(top_srcdir)/m4macros/ax_gtest.m4 \ + $(top_srcdir)/m4macros/ax_isc_rpath.m4 \ + $(top_srcdir)/m4macros/ax_sysrepo.m4 \ + $(top_srcdir)/m4macros/libtool.m4 \ + $(top_srcdir)/m4macros/ltoptions.m4 \ + $(top_srcdir)/m4macros/ltsugar.m4 \ + $(top_srcdir)/m4macros/ltversion.m4 \ + $(top_srcdir)/m4macros/lt~obsolete.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) +mkinstalldirs = $(install_sh) -d +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +LTLIBRARIES = $(noinst_LTLIBRARIES) +@HAVE_GTEST_TRUE@libyangtest_la_DEPENDENCIES = \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/yang/libkea-yang.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/log/libkea-log.la +am__libyangtest_la_SOURCES_DIST = translator_test.cc translator_test.h +@HAVE_GTEST_TRUE@am_libyangtest_la_OBJECTS = \ +@HAVE_GTEST_TRUE@ libyangtest_la-translator_test.lo +libyangtest_la_OBJECTS = $(am_libyangtest_la_OBJECTS) +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 = +libyangtest_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \ + $(libyangtest_la_CXXFLAGS) $(CXXFLAGS) \ + $(libyangtest_la_LDFLAGS) $(LDFLAGS) -o $@ +@HAVE_GTEST_TRUE@am_libyangtest_la_rpath = +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)/libyangtest_la-translator_test.Plo +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 = $(libyangtest_la_SOURCES) +DIST_SOURCES = $(am__libyangtest_la_SOURCES_DIST) +RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \ + ctags-recursive dvi-recursive html-recursive info-recursive \ + install-data-recursive install-dvi-recursive \ + install-exec-recursive install-html-recursive \ + install-info-recursive install-pdf-recursive \ + install-ps-recursive install-recursive installcheck-recursive \ + installdirs-recursive pdf-recursive ps-recursive \ + tags-recursive uninstall-recursive +am__can_run_installinfo = \ + case $$AM_UPDATE_INFO_DIR in \ + n|no|NO) false;; \ + *) (install-info --version) >/dev/null 2>&1;; \ + esac +RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ + distclean-recursive maintainer-clean-recursive +am__recursive_targets = \ + $(RECURSIVE_TARGETS) \ + $(RECURSIVE_CLEAN_TARGETS) \ + $(am__extra_recursive_targets) +AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \ + distdir distdir-am +am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) +# Read a list of newline-separated strings from the standard input, +# and print each of them once, without duplicates. Input order is +# *not* preserved. +am__uniquify_input = $(AWK) '\ + BEGIN { nonempty = 0; } \ + { items[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in items) print i; }; } \ +' +# Make sure the list of sources is unique. This is necessary because, +# e.g., the same source file might be shared among _SOURCES variables +# for different programs/libraries. +am__define_uniq_tagged_files = \ + list='$(am__tagged_files)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | $(am__uniquify_input)` +ETAGS = etags +CTAGS = ctags +DIST_SUBDIRS = $(SUBDIRS) +am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +am__relativize = \ + dir0=`pwd`; \ + sed_first='s,^\([^/]*\)/.*$$,\1,'; \ + sed_rest='s,^[^/]*/*,,'; \ + sed_last='s,^.*/\([^/]*\)$$,\1,'; \ + sed_butlast='s,/*[^/]*$$,,'; \ + while test -n "$$dir1"; do \ + first=`echo "$$dir1" | sed -e "$$sed_first"`; \ + if test "$$first" != "."; then \ + if test "$$first" = ".."; then \ + dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ + dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ + else \ + first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ + if test "$$first2" = "$$first"; then \ + dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ + else \ + dir2="../$$dir2"; \ + fi; \ + dir0="$$dir0"/"$$first"; \ + fi; \ + fi; \ + dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ + done; \ + reldir="$$dir2" +ACLOCAL = @ACLOCAL@ +AMTAR = @AMTAR@ +AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ +AR = @AR@ +ASCIIDOC = @ASCIIDOC@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +BOOST_INCLUDES = @BOOST_INCLUDES@ +BOOST_LIBS = @BOOST_LIBS@ +BOTAN_TOOL = @BOTAN_TOOL@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CONTRIB_DIR = @CONTRIB_DIR@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CRYPTO_CFLAGS = @CRYPTO_CFLAGS@ +CRYPTO_INCLUDES = @CRYPTO_INCLUDES@ +CRYPTO_LDFLAGS = @CRYPTO_LDFLAGS@ +CRYPTO_LIBS = @CRYPTO_LIBS@ +CRYPTO_PACKAGE = @CRYPTO_PACKAGE@ +CRYPTO_RPATH = @CRYPTO_RPATH@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DISTCHECK_BOOST_CONFIGURE_FLAG = @DISTCHECK_BOOST_CONFIGURE_FLAG@ +DISTCHECK_CONTRIB_CONFIGURE_FLAG = @DISTCHECK_CONTRIB_CONFIGURE_FLAG@ +DISTCHECK_CRYPTO_CONFIGURE_FLAG = @DISTCHECK_CRYPTO_CONFIGURE_FLAG@ +DISTCHECK_GTEST_CONFIGURE_FLAG = @DISTCHECK_GTEST_CONFIGURE_FLAG@ +DISTCHECK_KEA_SHELL_CONFIGURE_FLAG = @DISTCHECK_KEA_SHELL_CONFIGURE_FLAG@ +DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG = @DISTCHECK_LOG4CPLUS_CONFIGURE_FLAG@ +DISTCHECK_PERFDHCP_CONFIGURE_FLAG = @DISTCHECK_PERFDHCP_CONFIGURE_FLAG@ +DISTCHECK_PREMIUM_CONFIGURE_FLAG = @DISTCHECK_PREMIUM_CONFIGURE_FLAG@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +GENHTML = @GENHTML@ +GREP = @GREP@ +GSSAPI_CFLAGS = @GSSAPI_CFLAGS@ +GSSAPI_LIBS = @GSSAPI_LIBS@ +GTEST_CONFIG = @GTEST_CONFIG@ +GTEST_INCLUDES = @GTEST_INCLUDES@ +GTEST_LDADD = @GTEST_LDADD@ +GTEST_LDFLAGS = @GTEST_LDFLAGS@ +GTEST_SOURCE = @GTEST_SOURCE@ +HAVE_SYSREPO = @HAVE_SYSREPO@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +KEA_CXXFLAGS = @KEA_CXXFLAGS@ +KEA_SRCID = @KEA_SRCID@ +KRB5_CONFIG = @KRB5_CONFIG@ +LCOV = @LCOV@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LEX = @LEX@ +LEXLIB = @LEXLIB@ +LEX_OUTPUT_ROOT = @LEX_OUTPUT_ROOT@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LOG4CPLUS_INCLUDES = @LOG4CPLUS_INCLUDES@ +LOG4CPLUS_LIBS = @LOG4CPLUS_LIBS@ +LTLIBOBJS = @LTLIBOBJS@ +LT_SYS_LIBRARY_PATH = @LT_SYS_LIBRARY_PATH@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MKDIR_P = @MKDIR_P@ +MYSQL_CPPFLAGS = @MYSQL_CPPFLAGS@ +MYSQL_LIBS = @MYSQL_LIBS@ +NM = @NM@ +NMEDIT = @NMEDIT@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PACKAGE_VERSION_TYPE = @PACKAGE_VERSION_TYPE@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PDFLATEX = @PDFLATEX@ +PERL = @PERL@ +PGSQL_CPPFLAGS = @PGSQL_CPPFLAGS@ +PGSQL_LIBS = @PGSQL_LIBS@ +PKGPYTHONDIR = @PKGPYTHONDIR@ +PKG_CONFIG = @PKG_CONFIG@ +PLANTUML = @PLANTUML@ +PREMIUM_DIR = @PREMIUM_DIR@ +PYTHON = @PYTHON@ +PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@ +PYTHON_PLATFORM = @PYTHON_PLATFORM@ +PYTHON_PREFIX = @PYTHON_PREFIX@ +PYTHON_VERSION = @PYTHON_VERSION@ +RANLIB = @RANLIB@ +SED = @SED@ +SEP = @SEP@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +SPHINXBUILD = @SPHINXBUILD@ +SRPD_PLUGINS_PATH = @SRPD_PLUGINS_PATH@ +SR_REPO_PATH = @SR_REPO_PATH@ +STRIP = @STRIP@ +SYSREPOCPP_VERSION = @SYSREPOCPP_VERSION@ +SYSREPO_CPPFLAGS = @SYSREPO_CPPFLAGS@ +SYSREPO_INCLUDEDIR = @SYSREPO_INCLUDEDIR@ +SYSREPO_LIBS = @SYSREPO_LIBS@ +SYSREPO_VERSION = @SYSREPO_VERSION@ +USE_LCOV = @USE_LCOV@ +VALGRIND = @VALGRIND@ +VERSION = @VERSION@ +WARNING_GCC_44_STRICT_ALIASING_CFLAG = @WARNING_GCC_44_STRICT_ALIASING_CFLAG@ +YACC = @YACC@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +pkgpyexecdir = @pkgpyexecdir@ +pkgpythondir = @pkgpythondir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +pyexecdir = @pyexecdir@ +pythondir = @pythondir@ +runstatedir = @runstatedir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +SUBDIRS = . +AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib \ + $(BOOST_INCLUDES) $(SYSREPO_CPPFLAGS) $(SYSREPO_INCLUDEDIR) +AM_CXXFLAGS = $(KEA_CXXFLAGS) +CLEANFILES = *.gcno *.gcda +@HAVE_GTEST_TRUE@noinst_LTLIBRARIES = libyangtest.la +@HAVE_GTEST_TRUE@libyangtest_la_SOURCES = translator_test.cc translator_test.h +@HAVE_GTEST_TRUE@libyangtest_la_CXXFLAGS = $(AM_CXXFLAGS) +@HAVE_GTEST_TRUE@libyangtest_la_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) +@HAVE_GTEST_TRUE@libyangtest_la_LDFLAGS = $(AM_LDFLAGS) +@HAVE_GTEST_TRUE@libyangtest_la_LIBADD = \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/yang/libkea-yang.la \ +@HAVE_GTEST_TRUE@ $(top_builddir)/src/lib/log/libkea-log.la +all: all-recursive + +.SUFFIXES: +.SUFFIXES: .cc .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/lib/yang/testutils/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --foreign src/lib/yang/testutils/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-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } + +libyangtest.la: $(libyangtest_la_OBJECTS) $(libyangtest_la_DEPENDENCIES) $(EXTRA_libyangtest_la_DEPENDENCIES) + $(AM_V_CXXLD)$(libyangtest_la_LINK) $(am_libyangtest_la_rpath) $(libyangtest_la_OBJECTS) $(libyangtest_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libyangtest_la-translator_test.Plo@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 $@ $< + +libyangtest_la-translator_test.lo: translator_test.cc +@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libyangtest_la_CPPFLAGS) $(CPPFLAGS) $(libyangtest_la_CXXFLAGS) $(CXXFLAGS) -MT libyangtest_la-translator_test.lo -MD -MP -MF $(DEPDIR)/libyangtest_la-translator_test.Tpo -c -o libyangtest_la-translator_test.lo `test -f 'translator_test.cc' || echo '$(srcdir)/'`translator_test.cc +@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libyangtest_la-translator_test.Tpo $(DEPDIR)/libyangtest_la-translator_test.Plo +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='translator_test.cc' object='libyangtest_la-translator_test.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libyangtest_la_CPPFLAGS) $(CPPFLAGS) $(libyangtest_la_CXXFLAGS) $(CXXFLAGS) -c -o libyangtest_la-translator_test.lo `test -f 'translator_test.cc' || echo '$(srcdir)/'`translator_test.cc + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs + +# This directory's subdirectories are mostly independent; you can cd +# into them and run 'make' without going through this Makefile. +# To change the values of 'make' variables: instead of editing Makefiles, +# (1) if the variable is set in 'config.status', edit 'config.status' +# (which will cause the Makefiles to be regenerated when you run 'make'); +# (2) otherwise, pass the desired values on the 'make' command line. +$(am__recursive_targets): + @fail=; \ + if $(am__make_keepgoing); then \ + failcom='fail=yes'; \ + else \ + failcom='exit 1'; \ + fi; \ + dot_seen=no; \ + target=`echo $@ | sed s/-recursive//`; \ + case "$@" in \ + distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ + *) list='$(SUBDIRS)' ;; \ + esac; \ + for subdir in $$list; do \ + echo "Making $$target in $$subdir"; \ + if test "$$subdir" = "."; then \ + dot_seen=yes; \ + local_target="$$target-am"; \ + else \ + local_target="$$target"; \ + fi; \ + ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ + || eval $$failcom; \ + done; \ + if test "$$dot_seen" = "no"; then \ + $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ + fi; test -z "$$fail" + +ID: $(am__tagged_files) + $(am__define_uniq_tagged_files); mkid -fID $$unique +tags: tags-recursive +TAGS: tags + +tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + set x; \ + here=`pwd`; \ + if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ + include_option=--etags-include; \ + empty_fix=.; \ + else \ + include_option=--include; \ + empty_fix=; \ + fi; \ + list='$(SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + test ! -f $$subdir/TAGS || \ + set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ + fi; \ + done; \ + $(am__define_uniq_tagged_files); \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: ctags-recursive + +CTAGS: ctags +ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) + $(am__define_uniq_tagged_files); \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" +cscopelist: cscopelist-recursive + +cscopelist-am: $(am__tagged_files) + list='$(am__tagged_files)'; \ + case "$(srcdir)" in \ + [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ + *) sdir=$(subdir)/$(srcdir) ;; \ + esac; \ + for i in $$list; do \ + if test -f "$$i"; then \ + echo "$(subdir)/$$i"; \ + else \ + echo "$$sdir/$$i"; \ + fi; \ + done >> $(top_builddir)/cscope.files + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) distdir-am + +distdir-am: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done + @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ + if test "$$subdir" = .; then :; else \ + $(am__make_dryrun) \ + || test -d "$(distdir)/$$subdir" \ + || $(MKDIR_P) "$(distdir)/$$subdir" \ + || exit 1; \ + dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ + $(am__relativize); \ + new_distdir=$$reldir; \ + dir1=$$subdir; dir2="$(top_distdir)"; \ + $(am__relativize); \ + new_top_distdir=$$reldir; \ + echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ + echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ + ($(am__cd) $$subdir && \ + $(MAKE) $(AM_MAKEFLAGS) \ + top_distdir="$$new_top_distdir" \ + distdir="$$new_distdir" \ + am__remove_distdir=: \ + am__skip_length_check=: \ + am__skip_mode_fix=: \ + distdir) \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-recursive +all-am: Makefile $(LTLIBRARIES) +installdirs: installdirs-recursive +installdirs-am: +install: install-recursive +install-exec: install-exec-recursive +install-data: install-data-recursive +uninstall: uninstall-recursive + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-recursive +install-strip: + if test -z '$(STRIP)'; then \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + install; \ + else \ + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ + fi +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-recursive + +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-recursive + -rm -f ./$(DEPDIR)/libyangtest_la-translator_test.Plo + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-recursive + +dvi-am: + +html: html-recursive + +html-am: + +info: info-recursive + +info-am: + +install-data-am: + +install-dvi: install-dvi-recursive + +install-dvi-am: + +install-exec-am: + +install-html: install-html-recursive + +install-html-am: + +install-info: install-info-recursive + +install-info-am: + +install-man: + +install-pdf: install-pdf-recursive + +install-pdf-am: + +install-ps: install-ps-recursive + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-recursive + -rm -f ./$(DEPDIR)/libyangtest_la-translator_test.Plo + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-recursive + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-recursive + +pdf-am: + +ps: ps-recursive + +ps-am: + +uninstall-am: + +.MAKE: $(am__recursive_targets) install-am install-strip + +.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \ + am--depfiles check check-am clean clean-generic clean-libtool \ + clean-noinstLTLIBRARIES cscopelist-am ctags ctags-am distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + installdirs-am maintainer-clean maintainer-clean-generic \ + mostlyclean mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool pdf pdf-am ps ps-am tags tags-am uninstall \ + uninstall-am + +.PRECIOUS: Makefile + + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/src/lib/yang/testutils/translator_test.cc b/src/lib/yang/testutils/translator_test.cc new file mode 100644 index 0000000..16fa33b --- /dev/null +++ b/src/lib/yang/testutils/translator_test.cc @@ -0,0 +1,421 @@ +// Copyright (C) 2018-2019,2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include + +#include + +#include + +using namespace std; +using namespace isc::data; +using namespace sysrepo; +namespace isc { +namespace yang { +namespace test { + +YangRepr::YangReprItem +YangRepr::YangReprItem::get(const string& xpath, S_Session session) { + string val_xpath = xpath; + string value = ""; + sr_type_t type = SR_UNKNOWN_T; + bool settable = true; + try { + S_Val s_val = session->get_item(xpath.c_str()); + if (!s_val) { + isc_throw(BadValue, "YangReprItem failed at '" << xpath << "'"); + } + val_xpath = string(s_val->xpath()); + type = s_val->type(); + ostringstream num_value; + switch (type) { + case SR_CONTAINER_T: + case SR_CONTAINER_PRESENCE_T: + settable = false; + break; + + case SR_LIST_T: + break; + + case SR_STRING_T: + value = s_val->data()->get_string(); + break; + + case SR_BOOL_T: + value = s_val->data()->get_bool() ? "true" : "false"; + break; + + case SR_UINT8_T: + num_value << static_cast(s_val->data()->get_uint8()); + value = num_value.str(); + break; + + case SR_UINT16_T: + num_value << s_val->data()->get_uint16(); + value = num_value.str(); + break; + + case SR_UINT32_T: + num_value << s_val->data()->get_uint32(); + value = num_value.str(); + break; + + case SR_INT8_T: + num_value << static_cast(s_val->data()->get_int8()); + value = num_value.str(); + break; + + case SR_INT16_T: + num_value << s_val->data()->get_int16(); + value = num_value.str(); + break; + + case SR_INT32_T: + num_value << s_val->data()->get_int32(); + value = num_value.str(); + break; + + case SR_DECIMAL64_T: + num_value << s_val->data()->get_decimal64(); + value = num_value.str(); + break; + + case SR_IDENTITYREF_T: + value = s_val->data()->get_identityref(); + break; + + case SR_ENUM_T: + value = s_val->data()->get_enum(); + break; + + case SR_BINARY_T: + value = s_val->data()->get_binary(); + break; + + default: + isc_throw(NotImplemented, + "YangReprItem called with unsupported type: " << type); + } + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, + "sysrepo error in YangReprItem: " << ex.what()); + } + return (YangReprItem(val_xpath, value, type, settable)); +} + +YangRepr::Tree +YangRepr::get(S_Session session) const { + Tree result; + try { + TranslatorBasic tb(session, model_); + string const xpath0("/" + model_ + ":*//."); + tb.forAll(xpath0, [&](libyang::S_Data_Node const& node) { + string const& xpath(node->path()); + result.emplace(xpath, YangReprItem::get(xpath, session)); + }); + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, + "sysrepo error in YangRepr::getTree: " << ex.what()); + } + return (result); +} + +bool +YangRepr::verify(const Tree& expected, S_Session session, + ostream& errs) const { + bool result(true); + const Tree& received = get(session); + for (auto const& kv : received) { + string const& xpath(kv.first); + YangReprItem const& received_node(kv.second); + + auto iterator(expected.find(xpath)); + if (iterator == expected.end()) { + errs << "received " << received_node << ", but was not expected" + << endl; + result = false; + continue; + } + + YangReprItem const expected_node(iterator->second); + if (expected_node != received_node) { + errs << "expected " << expected_node << ", but received " + << received_node << endl; + result = false; + } + } + + for (auto const& kv : expected) { + string const& xpath(kv.first); + YangReprItem const& expected_node(kv.second); + + auto iterator(received.find(xpath)); + if (iterator == received.end()) { + errs << "expected " << expected_node << ", but was not received" + << endl; + result = false; + } + } + + return result; +} + +void +YangRepr::set(const Tree& tree, S_Session session) const { + for (auto const& kv : tree) { + YangReprItem const& item(kv.second); + if (!item.settable_) { + continue; + } + try { + S_Val s_val; + switch (item.type_) { + case SR_CONTAINER_T: + case SR_CONTAINER_PRESENCE_T: + isc_throw(NotImplemented, + "YangRepr::set called for a container"); + + case SR_LIST_T: + isc_throw(NotImplemented, + "YangRepr::set called for a list"); + break; + + case SR_STRING_T: + case SR_IDENTITYREF_T: + case SR_ENUM_T: + case SR_BINARY_T: + s_val.reset(new Val(item.value_.c_str(), item.type_)); + break; + + case SR_BOOL_T: + if (item.value_ == "true") { + s_val.reset(new Val(true, SR_BOOL_T)); + } else if (item.value_ == "false") { + s_val.reset(new Val(false, SR_BOOL_T)); + } else { + isc_throw(BadValue, "'" << item.value_ << "' not a bool"); + } + break; + + case SR_UINT8_T: + try { + uint8_t u8 = boost::lexical_cast(item.value_); + s_val.reset(new Val(u8)); + } catch (const boost::bad_lexical_cast&) { + isc_throw(BadValue, + "'" << item.value_ << "' not an uint8"); + } + break; + + case SR_UINT16_T: + try { + uint16_t u16 = boost::lexical_cast(item.value_); + s_val.reset(new Val(u16)); + } catch (const boost::bad_lexical_cast&) { + isc_throw(BadValue, + "'" << item.value_ << "' not an uint16"); + } + break; + + case SR_UINT32_T: + try { + uint32_t u32 = boost::lexical_cast(item.value_); + s_val.reset(new Val(u32)); + } catch (const boost::bad_lexical_cast&) { + isc_throw(BadValue, + "'" << item.value_ << "' not an uint32"); + } + break; + + case SR_INT8_T: + try { + int8_t i8 = boost::lexical_cast(item.value_); + s_val.reset(new Val(i8)); + } catch (const boost::bad_lexical_cast&) { + isc_throw(BadValue, + "'" << item.value_ << "' not an int8"); + } + break; + + case SR_INT16_T: + try { + int16_t i16 = boost::lexical_cast(item.value_); + s_val.reset(new Val(i16)); + } catch (const boost::bad_lexical_cast&) { + isc_throw(BadValue, + "'" << item.value_ << "' not an int16"); + } + break; + + case SR_INT32_T: + try { + int32_t i32 = boost::lexical_cast(item.value_); + s_val.reset(new Val(i32)); + } catch (const boost::bad_lexical_cast&) { + isc_throw(BadValue, + "'" << item.value_ << "' not an int32"); + } + break; + + case SR_DECIMAL64_T: + try { + double d64 = boost::lexical_cast(item.value_); + s_val.reset(new Val(d64)); + } catch (const boost::bad_lexical_cast&) { + isc_throw(BadValue, + "'" << item.value_ << "' not a real"); + } + break; + + default: + isc_throw(NotImplemented, + "YangRepr::set called with unsupported type: " + << item.type_); + } + session->set_item(item.xpath_.c_str(), s_val); + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, + "sysrepo error in YangRepr::set for " << item + << ", error: " << ex.what()); + } + } + session->apply_changes(); +} + +bool +YangRepr::validate(S_Session session, ostream& errs) const { + try { + // Try to validate. If it succeeds, then we're done here. + session->validate(); + return (true); + } catch (const std::exception& ex) { + errs << "validate fails with " << ex.what() << endl; + } + try { + // If we get here, it means the validate() threw exceptions. + S_Errors errors(session->get_error()); + if (!errors) { + // This is really weird. An exception was thrown, but + // get_last_errors() didn't return anything. Maybe we're out of + // memory or something? + errs << "no errors" << endl; + return (false); + } + size_t const count(errors->error_cnt()); + errs << "got " << count << " errors" << endl; + for (size_t i = 0; i < count ; ++i) { + const char* message(errors->message(i)); + const char* xpath(errors->xpath(i)); + if (!message || !xpath) { + continue; + } + errs << message << " at " << xpath << endl; + } + } catch (const std::exception& ex) { + errs << "double error " << ex.what(); + } + return (false); +} + +ostream& +operator<<(ostream& os, sr_type_t type) { + switch (type) { + case SR_CONTAINER_T: + os << "container"; + break; + case SR_CONTAINER_PRESENCE_T: + os << "container presence"; + break; + case SR_LIST_T: + os << "list"; + break; + case SR_STRING_T: + os << "string"; + break; + case SR_BOOL_T: + os << "bool"; + break; + case SR_UINT8_T: + os << "uint8"; + break; + case SR_UINT16_T: + os << "uint16"; + break; + case SR_UINT32_T: + os << "uint32"; + break; + case SR_INT8_T: + os << "int8"; + break; + case SR_INT16_T: + os << "int16"; + break; + case SR_INT32_T: + os << "int32"; + break; + case SR_IDENTITYREF_T: + os << "identity ref"; + break; + case SR_ENUM_T: + os << "enum"; + break; + case SR_BINARY_T: + os << "binary"; + break; + case SR_LEAF_EMPTY_T: + os << "leaf empty"; + break; + case SR_BITS_T: + os << "bits"; + break; + case SR_DECIMAL64_T: + os << "decimal64"; + break; + case SR_INSTANCEID_T: + os << "instance id"; + break; + case SR_INT64_T: + os << "int64"; + break; + case SR_UINT64_T: + os << "uint64"; + break; + case SR_ANYXML_T: + os << "any xml"; + break; + case SR_ANYDATA_T: + os << "any data"; + break; +#ifdef SR_UNION_T + case SR_UNION_T: + os << "union"; + break; +#endif + default: + os << type; + break; + } + return (os); +} + +ostream& operator<<(ostream& os, const YangRepr::YangReprItem& item) { + os << item.xpath_ << " = (" << item.type_ << ") '" << item.value_ << "'"; + return (os); +} + +ostream& operator<<(ostream& os, const YangRepr::Tree& tree) { + for (auto const& kv : tree) { + YangRepr::YangReprItem const& item(kv.second); + os << item << endl; + } + return (os); +} + +} // namespace test +} // namespace yang +} // namespace isc diff --git a/src/lib/yang/testutils/translator_test.h b/src/lib/yang/testutils/translator_test.h new file mode 100644 index 0000000..b334fbd --- /dev/null +++ b/src/lib/yang/testutils/translator_test.h @@ -0,0 +1,159 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef ISC_TRANSLATOR_TEST_H +#define ISC_TRANSLATOR_TEST_H 1 + +#include +#include +#include +#include + +namespace isc { +namespace yang { +namespace test { + +/// @brief Yang/sysrepo datastore textual representation class. +/// +/// This class allows to store a configuration tree in YANG format. +/// It is used in tests to conduct operations on whole configurations. +class YangRepr { +public: + + /// @brief Constructor. + /// + /// @param model The model name. + YangRepr(const std::string& model) : model_(model) { + } + + /// @brief A struct representing a single entry. + struct YangReprItem { + /// @brief Constructor with content. + /// + /// @param xpath The xpath. + /// @param value The textual value. + /// @param type The type of the value. + /// @param settable The settable flag. + YangReprItem(std::string xpath, std::string value, + sr_type_t type, bool settable) + : xpath_(xpath), value_(value), type_(type), settable_(settable) { + } + + /// @brief Retrieves configuration parameter from sysrepo. + /// + /// @param xpath The xpath of an element to be retrieved. + /// @param session Sysrepo session. + /// @return YangReprItem instance representing configuration parameter. + static YangReprItem get(const std::string& xpath, + sysrepo::S_Session session); + + /// @brief The xpath. + std::string xpath_; + + /// @brief The textual value. + std::string value_; + + /// @brief The type of the value. + sr_type_t type_; + + /// @brief The settable flag. + bool settable_; + + /// @brief The equal operator ignoring settable. + /// + /// @param other the other object to compare with. + /// @return true if equal. + bool operator==(const YangReprItem& other) const { + return ((xpath_ == other.xpath_) && + (value_ == other.value_) && + (type_ == other.type_)); + } + + /// @brief The unequal operator ignoring settable. + /// + /// @param other the other object to compare with. + /// @return false if equal. + bool operator!=(const YangReprItem& other) const { + return (!(*this == other)); + } + }; + + /// @brief Tree type. + /// + /// Indexed by xpath so that we can check against an entry received from + /// sysrepo which has empirically proven to not come in a certain order + /// starting with sysrepo 1.x. Relying on the order would have made a linear + /// data structure more fitting. + using Tree = std::unordered_map; + + /// @brief Get tree from session. + /// + /// @param session Sysrepo session. + Tree get(sysrepo::S_Session session) const; + + /// @brief Verifies a tree. + /// + /// @param expected The expected value. + /// @param session Sysrepo session. + /// @param errs Error stream. + /// @return true if verification succeeds, false with errors displayed. + /// on errs if it fails. + bool verify(const Tree& expected, sysrepo::S_Session session, + std::ostream& errs) const; + + /// @brief Sets specified tree in a sysrepo. + /// + /// The actual access parameters are specified within session. + /// + /// @param tree The tree to install. + /// @param session Sysrepo session. + void set(const Tree& tree, sysrepo::S_Session session) const; + + /// @brief Validate. + /// + /// @param session Sysrepo session. + /// @param errs Error stream. + /// @return True if validation succeeds, false with errors displayed + /// on errs if it fails. + bool validate(sysrepo::S_Session session, std::ostream& errs) const; + + /// @brief Convenience function that indexes a collection of items by xpath. + /// + /// @param v the input vector + /// + /// @return the output map + static Tree buildTreeFromVector(std::vector const& v) { + Tree tree; + for (YangReprItem const& item : v) { + tree.emplace(item.xpath_, item); + } + return tree; + } + + /// @brief The model name. + std::string model_; +}; + +/// @brief Alias for Items. +typedef YangRepr::YangReprItem YRItem; + +/// @brief Alias for Trees. +typedef YangRepr::Tree YRTree; + +/// @brief Overrides standard output operator for sr_type_t. +std::ostream& operator<<(std::ostream& os, sr_type_t type); + +/// @brief Overrides standard output operator for @c YangReprItem object. +std::ostream& operator<<(std::ostream& os, const YRItem& item); + +/// @brief Overrides standard output operator for @c Tree object. +std::ostream& operator<<(std::ostream& os, const YRTree& tree); + +} // namespace test +} // namespace yang +} // namespace isc + +#endif // ISC_TRANSLATOR_TEST_H diff --git a/src/lib/yang/translator.cc b/src/lib/yang/translator.cc new file mode 100644 index 0000000..9e38cfa --- /dev/null +++ b/src/lib/yang/translator.cc @@ -0,0 +1,318 @@ +// Copyright (C) 2018-2019,2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include + +using namespace std; +using namespace isc::data; +using namespace isc::util::encode; +using namespace sysrepo; + +namespace { + +string encode64(const string& input) { + vector binary; + binary.resize(input.size()); + memmove(&binary[0], input.c_str(), binary.size()); + return (encodeBase64(binary)); +} + +string decode64(const string& input) { + vector binary; + decodeBase64(input, binary); + string result; + result.resize(binary.size()); + memmove(&result[0], &binary[0], result.size()); + return (result); +} + +} // end of anonymous namespace + +namespace isc { +namespace yang { + +TranslatorBasic::TranslatorBasic(S_Session session, const string& model) + : session_(session), model_(model) { +} + +TranslatorBasic::~TranslatorBasic() { +} + +ElementPtr +TranslatorBasic::value(sysrepo::S_Val s_val) { + if (!s_val) { + isc_throw(BadValue, "value called with null"); + } + switch (s_val->type()) { + case SR_CONTAINER_T: + case SR_CONTAINER_PRESENCE_T: + // Internal node. + return (ElementPtr()); + + case SR_LIST_T: + return (Element::createList()); + + case SR_STRING_T: + return (Element::create(string(s_val->data()->get_string()))); + + case SR_BOOL_T: + return (Element::create(s_val->data()->get_bool() ? true : false)); + + case SR_UINT8_T: + return (Element::create(static_cast(s_val->data()->get_uint8()))); + + case SR_UINT16_T: + return (Element::create(static_cast(s_val->data()->get_uint16()))); + + case SR_UINT32_T: + return (Element::create(static_cast(s_val->data()->get_uint32()))); + + case SR_INT8_T: + return (Element::create(static_cast(s_val->data()->get_int8()))); + + case SR_INT16_T: + return (Element::create(static_cast(s_val->data()->get_int16()))); + + case SR_INT32_T: + return (Element::create(static_cast(s_val->data()->get_int32()))); + + case SR_DECIMAL64_T: + return (Element::create(s_val->data()->get_decimal64())); + + case SR_IDENTITYREF_T: + return (Element::create(string(s_val->data()->get_identityref()))); + + case SR_ENUM_T: + return (Element::create(string(s_val->data()->get_enum()))); + + case SR_BINARY_T: + return (Element::create(decode64(s_val->data()->get_binary()))); + + default: + isc_throw(NotImplemented, + "value called with unsupported type: " << s_val->type()); + } +} + +ElementPtr +TranslatorBasic::getItem(const string& xpath) { + S_Val s_val; + try { + s_val = session_->get_item(xpath.c_str()); + } catch (const sysrepo_exception& ex) { + if (std::string(ex.what()).find("Item not found") != string::npos) { + // The YANG configuration node was not there. + return nullptr; + } + isc_throw(SysrepoError, "sysrepo error getting item at '" << xpath + << "': " << ex.what()); + } + if (!s_val) { + return (ElementPtr()); + } + return (value(s_val)); +} + +ElementPtr +TranslatorBasic::getItems(const string& xpath) { + S_Vals s_vals(getValuesFromItems(xpath)); + if (!s_vals) { + return (ElementPtr()); + } + ElementPtr result(Element::createList()); + try { + for (size_t i = 0; i < s_vals->val_cnt(); ++i) { + S_Val s_val = s_vals->val(i); + result->add(value(s_val)); + } + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, "sysrepo error getting item at '" + << xpath << "': " << ex.what()); + } + return (result); +} + +S_Val +TranslatorBasic::value(ConstElementPtr elem, sr_type_t type) { + if (!elem) { + isc_throw(BadValue, "value called with null"); + } + S_Val s_val; + switch (type) { + case SR_CONTAINER_T: + case SR_CONTAINER_PRESENCE_T: + isc_throw(NotImplemented, "value called for a container"); + + case SR_LIST_T: + if (elem->getType() != Element::list) { + isc_throw(BadValue, "value for a list called with not a list: " + << elem->str()); + } + // Return null. + break; + + case SR_STRING_T: + case SR_IDENTITYREF_T: + case SR_ENUM_T: + if (elem->getType() != Element::string) { + isc_throw(BadValue, + "value for a string called with not a string: " + << elem->str()); + } + s_val.reset(new Val(elem->stringValue().c_str(), type)); + break; + + case SR_BOOL_T: + if (elem->getType() != Element::boolean) { + isc_throw(BadValue, + "value for a boolean called with not a boolean: " + << elem->str()); + } + s_val.reset(new Val(elem->boolValue(), type)); + break; + + case SR_UINT8_T: + if (elem->getType() != Element::integer) { + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); + } + s_val.reset(new Val(elem->intValue(), type)); + break; + + case SR_UINT16_T: + if (elem->getType() != Element::integer) { + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); + } + s_val.reset(new Val(elem->intValue(), type)); + break; + + case SR_UINT32_T: + if (elem->getType() != Element::integer) { + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); + } + s_val.reset(new Val(elem->intValue(), type)); + break; + + case SR_INT8_T: + if (elem->getType() != Element::integer) { + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); + } + s_val.reset(new Val(elem->intValue(), type)); + break; + + case SR_INT16_T: + if (elem->getType() != Element::integer) { + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); + } + s_val.reset(new Val(elem->intValue(), type)); + break; + + case SR_INT32_T: + if (elem->getType() != Element::integer) { + isc_throw(BadValue, + "value for an integer called with not an integer: " + << elem->str()); + } + s_val.reset(new Val(elem->intValue(), type)); + break; + + case SR_DECIMAL64_T: + if (elem->getType() != Element::real) { + isc_throw(BadValue, "value for a real called with not a real"); + } + s_val.reset(new Val(elem->doubleValue())); + break; + + case SR_BINARY_T: + if (elem->getType() != Element::string) { + isc_throw(BadValue, + "value for a base64 called with not a string: " + << elem->str()); + } + s_val.reset(new Val(encode64(elem->stringValue()).c_str(), type)); + break; + + default: + isc_throw(NotImplemented, + "value called with unsupported type: " << type); + } + + return (s_val); +} + +void +TranslatorBasic::setItem(const string& xpath, ConstElementPtr elem, + sr_type_t type) { + S_Val s_val = value(elem, type); + try { + session_->set_item(xpath.c_str(), s_val); + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, + "sysrepo error setting item '" << elem->str() + << "' at '" << xpath << "': " << ex.what()); + } + session_->apply_changes(); +} + +void +TranslatorBasic::checkAndGetLeaf(ElementPtr& storage, + const std::string& xpath, + const std::string& name) { + ConstElementPtr x = getItem(xpath + "/" + name); + if (x) { + storage->set(name, x); + } +} + +void TranslatorBasic::checkAndSetLeaf(ConstElementPtr const& from, + string const& xpath, + string const& name, + sr_type_t const type) { + ConstElementPtr const& x(from->get(name)); + if (x) { + setItem(xpath + "/" + name, x, type); + } +} + +void +TranslatorBasic::delItem(const std::string& xpath) { + try { + session_->delete_item(xpath.c_str()); + } catch (const sysrepo_exception& ex) { + if (std::string(ex.what()).find("Invalid argument") != string::npos) { + // The YANG configuration node was not there. + return; + } + isc_throw(SysrepoError, + "sysrepo error deleting item at '" + << xpath << "': " << ex.what()); + } + session_->apply_changes(); +} + +S_Vals TranslatorBasic::getValuesFromItems(std::string const& xpath) { + try { + return session_->get_items(xpath.c_str()); + } catch (sysrepo::sysrepo_exception const& exception) { + isc_throw(SysrepoError, "sysrepo error getting items: " << exception.what()); + } +} + +} // namespace yang +} // namespace isc diff --git a/src/lib/yang/translator.h b/src/lib/yang/translator.h new file mode 100644 index 0000000..838e2d6 --- /dev/null +++ b/src/lib/yang/translator.h @@ -0,0 +1,177 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef ISC_TRANSLATOR_H +#define ISC_TRANSLATOR_H 1 + +#include +#include + +#include + +namespace isc { +namespace yang { + +/// @brief Between YANG and JSON translator class for basic values. +class TranslatorBasic { +public: + /// @brief Constructor. + /// + /// @param session Sysrepo session. + /// @param model Model name (used and shared by derived classes). + TranslatorBasic(sysrepo::S_Session session, const std::string& model); + + /// @brief Destructor. + virtual ~TranslatorBasic(); + + /// @brief Translate basic value from YANG to JSON. + /// + /// @note Please don't use this outside tests. + /// + /// @param s_val The value. + /// @return The Element representing the sysrepo value. + /// @throw NotImplemented when the value type is not supported. + static isc::data::ElementPtr value(sysrepo::S_Val s_val); + + /// @brief Get and translate basic value from YANG to JSON. + /// + /// @note Should be const as it is read only... + /// + /// @param xpath The xpath of the basic value. + /// @return The Element representing the item at xpath or null + /// when not found. + /// @throw SysrepoError when sysrepo raises an error. + /// @throw NotImplemented when the value type is not supported. + isc::data::ElementPtr getItem(const std::string& xpath); + + /// @brief Get and translate a list of basic values from YANG to JSON. + /// + /// @param xpath The xpath of the list of basic values. + /// @return The ListElement representing the leaf-list at xpath or + /// null when not found. + isc::data::ElementPtr getItems(const std::string& xpath); + + /// @brief Retrieves an item and stores it in the specified storage. + /// + /// This will attempt to retrieve an item and, if exists, will + /// store it in the storage. + /// + /// @param storage ElementMap where result will be stored + /// @param xpath xpath location of data that will be extracted from sysrepo + /// @param name name of the parameter + void checkAndGetLeaf(isc::data::ElementPtr& storage, + const std::string& xpath, + const std::string& name); + + /// @brief Get the values of all siblings at a certain xpath. + /// + /// @param xpath the xpath to the element to be retrieved from, usually a + /// list + /// + /// @return all the entries populated with values + sysrepo::S_Vals getValuesFromItems(std::string const& xpath); + + /// @brief Translate basic value from JSON to YANG. + /// + /// @note Please don't use this outside tests. + /// + /// @param elem The JSON element. + /// @param type The sysrepo type. + static sysrepo::S_Val value(isc::data::ConstElementPtr elem, + sr_type_t type); + + /// @brief Translate and set basic value from JSON to YANG. + /// + /// @param xpath The xpath of the basic value. + /// @param elem The JSON element. + /// @param type The sysrepo type. + void setItem(const std::string& xpath, isc::data::ConstElementPtr elem, + sr_type_t type); + + + /// @brief Get an element from given ElementPtr node and set it in sysrepo + /// at given xpath. + /// + /// @param from the parent configuration node from which to take the value + /// @param xpath the xpath to the YANG node without the last node + /// @param name the name of the YANG node which should also match the map + /// key in the JSON configuration + /// @param type the sysrepo node type + void checkAndSetLeaf(isc::data::ConstElementPtr const& from, + std::string const& xpath, + std::string const& name, + sr_type_t const type); + + + /// @brief Delete basic value from YANG. + /// + /// @param xpath The xpath of the basic value. + void delItem(const std::string& xpath); + + /// @brief Run a function for a node and all its children. + /// + /// @tparam functor_t typename of the function to be called + /// + /// @param xpath the xpath to be travelled + /// @param f the function to be called on the node itself and each + /// descendant + template + void forAll(std::string const& xpath, functor_t f) { + libyang::S_Data_Node data_node(session_->get_data(xpath.c_str())); + if (!data_node) { + return; + } + + for (libyang::S_Data_Node& root : data_node->tree_for()) { + for (libyang::S_Data_Node const& n : root->tree_dfs()) { + f(n); + } + } + } + + /// @brief Retrieve a list as ElementPtr from sysrepo from a certain xpath. + /// + /// @tparam T typename of the translator that holds the function that will + /// be called on the xpath of each child from the list + /// + /// @param xpath the xpath to the element to be retrieved from, usually a + /// list + /// @param t address of a translator instance that holds the function that + /// will be called on the xpath of each child from the list + /// @param f the function that will be called on the xpath of each child + /// from the list + template + isc::data::ElementPtr getList(std::string const& xpath, + T& t, + isc::data::ElementPtr (T::*f)(std::string const& xpath)) { + isc::data::ElementPtr result; + sysrepo::S_Vals values(getValuesFromItems(xpath)); + if (values) { + for (size_t i(0); i < values->val_cnt(); ++i) { + isc::data::ElementPtr x((t.*f)(values->val(i)->xpath())); + if (x) { + if (!result) { + result = isc::data::Element::createList(); + } + result->add(x); + } + } + } + return result; + } + +protected: + /// @brief The sysrepo session. + sysrepo::S_Session session_; + + /// @brief The model. + std::string model_; +}; + +} // namespace yang +} // namespace isc + +#endif // ISC_TRANSLATOR_H diff --git a/src/lib/yang/translator_class.cc b/src/lib/yang/translator_class.cc new file mode 100644 index 0000000..0bfddf3 --- /dev/null +++ b/src/lib/yang/translator_class.cc @@ -0,0 +1,245 @@ +// Copyright (C) 2018-2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include + +#include +#include +#include +#include + +using namespace std; +using namespace isc::data; +using namespace sysrepo; + +namespace isc { +namespace yang { + +TranslatorClass::TranslatorClass(S_Session session, const string& model) + : TranslatorBasic(session, model), + TranslatorOptionData(session, model), + TranslatorOptionDataList(session, model), + TranslatorOptionDef(session, model), + TranslatorOptionDefList(session, model) { +} + +TranslatorClass::~TranslatorClass() { +} + +ElementPtr +TranslatorClass::getClass(const string& xpath) { + try { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER)) { + return (getClassKea(xpath)); + } + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, + "sysrepo error getting client class at '" << xpath + << "': " << ex.what()); + } + isc_throw(NotImplemented, + "getClass not implemented for the model: " << model_); +} + +ElementPtr +TranslatorClass::getClassKea(const string& xpath) { + ConstElementPtr name = getItem(xpath + "/name"); + if (!name) { + // Can't happen as the name is the key. + isc_throw(Unexpected, "getClassKea requires name: " << xpath); + } + ElementPtr result = Element::createMap(); + result->set("name", name); + ConstElementPtr test = getItem(xpath + "/test"); + if (test) { + result->set("test", test); + } + ConstElementPtr required = getItem(xpath + "/only-if-required"); + if (required) { + result->set("only-if-required", required); + } + ConstElementPtr options = getOptionDataList(xpath); + if (options && (options->size() > 0)) { + result->set("option-data", options); + } + checkAndGetLeaf(result, xpath, "valid-lifetime"); + checkAndGetLeaf(result, xpath, "min-valid-lifetime"); + checkAndGetLeaf(result, xpath, "max-valid-lifetime"); + if (model_ == KEA_DHCP4_SERVER) { + ConstElementPtr defs = getOptionDefList(xpath); + if (defs && (defs->size() > 0)) { + result->set("option-def", defs); + } + ConstElementPtr next = getItem(xpath + "/next-server"); + if (next) { + result->set("next-server", next); + } + ConstElementPtr hostname = getItem(xpath + "/server-hostname"); + if (hostname) { + result->set("server-hostname", hostname); + } + ConstElementPtr boot = getItem(xpath + "/boot-file-name"); + if (boot) { + result->set("boot-file-name", boot); + } + } else if (model_ == KEA_DHCP6_SERVER) { + checkAndGetLeaf(result, xpath, "preferred-lifetime"); + checkAndGetLeaf(result, xpath, "min-preferred-lifetime"); + checkAndGetLeaf(result, xpath, "max-preferred-lifetime"); + } + ConstElementPtr context = getItem(xpath + "/user-context"); + if (context) { + result->set("user-context", Element::fromJSON(context->stringValue())); + } + return (result); +} + +void +TranslatorClass::setClass(const string& xpath, ConstElementPtr elem) { + try { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER)) { + setClassKea(xpath, elem); + } else { + isc_throw(NotImplemented, + "setClass not implemented for the model: " << model_); + } + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, + "sysrepo error setting client class '" << elem->str() + << "' at '" << xpath << "': " << ex.what()); + } +} + +void +TranslatorClass::setClassKea(const string& xpath, ConstElementPtr elem) { + bool created = false; + // Skip key name. + ConstElementPtr test = elem->get("test"); + if (test) { + setItem(xpath + "/test", test, SR_STRING_T); + created = true; + } + ConstElementPtr required = elem->get("only-if-required"); + if (required) { + setItem(xpath + "/only-if-required", required, SR_BOOL_T); + created = true; + } + ConstElementPtr options = elem->get("option-data"); + if (options) { + setOptionDataList(xpath, options); + created = true; + } + checkAndSetLeaf(elem, xpath, "valid-lifetime", SR_UINT32_T); + checkAndSetLeaf(elem, xpath, "min-valid-lifetime", SR_UINT32_T); + checkAndSetLeaf(elem, xpath, "max-valid-lifetime", SR_UINT32_T); + if (model_ == KEA_DHCP4_SERVER) { + ConstElementPtr defs = elem->get("option-def"); + if (defs) { + setOptionDefList(xpath, defs); + created = true; + } + ConstElementPtr next = elem->get("next-server"); + if (next) { + setItem(xpath + "/next-server", next, SR_STRING_T); + created = true; + } + ConstElementPtr hostname = elem->get("server-hostname"); + if (hostname) { + setItem(xpath + "/server-hostname", hostname, SR_STRING_T); + created = true; + } + ConstElementPtr boot = elem->get("boot-file-name"); + if (boot) { + setItem(xpath + "/boot-file-name", boot, SR_STRING_T); + created = true; + } + } else if (model_ == KEA_DHCP6_SERVER) { + checkAndSetLeaf(elem, xpath, "preferred-lifetime", SR_UINT32_T); + checkAndSetLeaf(elem, xpath, "min-preferred-lifetime", SR_UINT32_T); + checkAndSetLeaf(elem, xpath, "max-preferred-lifetime", SR_UINT32_T); + } + ConstElementPtr context = Adaptor::getContext(elem); + if (context) { + setItem(xpath + "/user-context", Element::create(context->str()), + SR_STRING_T); + created = true; + } + // There is no mandatory fields outside the key so force creation. + if (!created) { + ConstElementPtr list = Element::createList(); + setItem(xpath, list, SR_LIST_T); + } +} + +TranslatorClasses::TranslatorClasses(S_Session session, const string& model) + : TranslatorBasic(session, model), + TranslatorOptionData(session, model), + TranslatorOptionDataList(session, model), + TranslatorOptionDef(session, model), + TranslatorOptionDefList(session, model), + TranslatorClass(session, model) { +} + +TranslatorClasses::~TranslatorClasses() { +} + +ConstElementPtr +TranslatorClasses::getClasses(const string& xpath) { + try { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER)) { + return (getClassesKea(xpath)); + } + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, + "sysrepo error getting client classes at '" << xpath + << "': " << ex.what()); + } + isc_throw(NotImplemented, + "getClasses not implemented for the model: " << model_); +} + +ElementPtr +TranslatorClasses::getClassesKea(const string& xpath) { + return getList(xpath + "/client-class", *this, + &TranslatorClass::getClass); +} + +void +TranslatorClasses::setClasses(const string& xpath, ConstElementPtr elem) { + try { + if ((model_ == KEA_DHCP4_SERVER) || + (model_ == KEA_DHCP6_SERVER)) { + setClassesKea(xpath, elem); + } else { + isc_throw(NotImplemented, + "setClasses not implemented for the model: " << model_); + } + } catch (const sysrepo_exception& ex) { + isc_throw(SysrepoError, + "sysrepo error setting client classes '" << elem->str() + << "' at '" << xpath << "': " << ex.what()); + } +} + +void +TranslatorClasses::setClassesKea(const string& xpath, ConstElementPtr elem) { + for (size_t i = 0; i < elem->size(); ++i) { + ConstElementPtr cclass = elem->get(i); + if (!cclass->contains("name")) { + isc_throw(BadValue, "client class without name: " << elem->str()); + } + string name = cclass->get("name")->stringValue(); + ostringstream key; + key << xpath << "/client-class[name='" << name << "']"; + setClass(key.str(), cclass); + } +} + +} // namespace yang +} // namespace isc diff --git a/src/lib/yang/translator_class.h b/src/lib/yang/translator_class.h new file mode 100644 index 0000000..ca2f9cb --- /dev/null +++ b/src/lib/yang/translator_class.h @@ -0,0 +1,169 @@ +// Copyright (C) 2018,2021 Internet Systems Consortium, Inc. ("ISC") +// +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef ISC_TRANSLATOR_CLASS_H +#define ISC_TRANSLATOR_CLASS_H 1 + +#include +#include +#include + +namespace isc { +namespace yang { + +/// Client class translation between YANG and JSON +/// +/// JSON syntax for all Kea servers with client class is: +/// @code +/// { +/// "name": , +/// "test": , +/// "only-if-required": , +/// "option-data":