Commit 39d8d30f authored by Francis Dupont's avatar Francis Dupont

[219-allow-an-option-value-to-be-set-from-an-expression] Checkpoint: almost finished

parent 248b058a
......@@ -1695,6 +1695,7 @@ AC_CONFIG_FILES([Makefile
src/hooks/Makefile
src/hooks/dhcp/Makefile
src/hooks/dhcp/flex_option/Makefile
src/hooks/dhcp/flex_option/libloadtests/Makefile
src/hooks/dhcp/flex_option/tests/Makefile
src/hooks/dhcp/high_availability/Makefile
src/hooks/dhcp/high_availability/tests/Makefile
......@@ -1702,11 +1703,11 @@ AC_CONFIG_FILES([Makefile
src/hooks/dhcp/lease_cmds/tests/Makefile
src/hooks/dhcp/mysql_cb/Makefile
src/hooks/dhcp/mysql_cb/tests/Makefile
src/hooks/dhcp/stat_cmds/Makefile
src/hooks/dhcp/stat_cmds/tests/Makefile
src/hooks/dhcp/user_chk/Makefile
src/hooks/dhcp/user_chk/tests/Makefile
src/hooks/dhcp/user_chk/tests/test_data_files_config.h
src/hooks/dhcp/stat_cmds/Makefile
src/hooks/dhcp/stat_cmds/tests/Makefile
src/lib/Makefile
src/lib/asiodns/Makefile
src/lib/asiodns/tests/Makefile
......
SUBDIRS = . tests
SUBDIRS = . libloadtests tests
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)
......
......@@ -24,7 +24,8 @@ using namespace std;
namespace isc {
namespace flex_option {
FlexOptionImpl::OptionConfig::OptionConfig(uint16_t code) : code_(code) {
FlexOptionImpl::OptionConfig::OptionConfig(uint16_t code)
: code_(code), action_(NONE) {
}
FlexOptionImpl::OptionConfig::~OptionConfig() {
......@@ -217,6 +218,11 @@ FlexOptionImpl::parseOptionConfig(ConstElementPtr option) {
<< remove << "] error: " << ex.what());
}
}
if (opt_cfg->getAction() == NONE) {
isc_throw(BadValue, "no action: " << option->str());
}
option_config_map_[code] = opt_cfg;
}
} // end of namespace flex_option
......
......@@ -194,6 +194,14 @@ public:
}
}
protected:
/// @brief Get a mutable reference to the option config map
///
/// @return The option config map.
OptionConfigMap& getMutableOptionConfigMap() {
return (option_config_map_);
}
private:
/// @brief The option config map (code and pointer to option config).
OptionConfigMap option_config_map_;
......
SUBDIRS = .
AM_CPPFLAGS = -I$(top_builddir)/src/lib -I$(top_srcdir)/src/lib
AM_CPPFLAGS += -I$(top_builddir)/src/hooks/dhcp/flex_option -I$(top_srcdir)/src/hooks/dhcp/flex_option
AM_CPPFLAGS += $(BOOST_INCLUDES)
AM_CPPFLAGS += -DFLEX_OPTION_LIB_SO=\"$(abs_top_builddir)/src/hooks/dhcp/flex_option/.libs/libdhcp_flex_option.so\"
AM_CPPFLAGS += -DINSTALL_PROG=\"$(abs_top_srcdir)/install-sh\"
AM_CXXFLAGS = $(KEA_CXXFLAGS)
if USE_STATIC_LINK
AM_LDFLAGS = -static
endif
# Unit test data files need to get installed.
EXTRA_DIST =
CLEANFILES = *.gcno *.gcda
# TESTS_ENVIRONMENT = $(LIBTOOL) --mode=execute $(VALGRIND_COMMAND)
LOG_COMPILER = $(LIBTOOL)
AM_LOG_FLAGS = --mode=execute
TESTS =
if HAVE_GTEST
TESTS += flex_option_unittests
flex_option_unittests_SOURCES = run_unittests.cc
flex_option_unittests_SOURCES += load_unload_unittests.cc
flex_option_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES)
flex_option_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS)
flex_option_unittests_CXXFLAGS = $(AM_CXXFLAGS)
flex_option_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/database/libkea-database.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/cc/libkea-cc.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libkea-asiolink.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/dns/libkea-dns++.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/cryptolink/libkea-cryptolink.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/log/libkea-log.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/util/libkea-util.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libkea-exceptions.la
flex_option_unittests_LDADD += $(LOG4CPLUS_LIBS)
flex_option_unittests_LDADD += $(CRYPTO_LIBS)
flex_option_unittests_LDADD += $(BOOST_LIBS)
flex_option_unittests_LDADD += $(GTEST_LDADD)
endif
noinst_PROGRAMS = $(TESTS)
......@@ -12,20 +12,21 @@
#include <config.h>
#include <exceptions/exceptions.h>
#include <flex_option.h>
#include <hooks/hooks_manager.h>
#include <gtest/gtest.h>
#include <cc/data.h>
#include <errno.h>
using namespace std;
using namespace isc;
using namespace hooks;
using namespace isc::hooks;
using namespace isc::data;
using namespace isc::dhcp;
namespace {
/// @brief Test fixture for testing loading and unloading the flex-id library
/// @brief Test fixture for testing loading and unloading the flex-option library
class LibLoadTest : public ::testing::Test {
public:
/// @brief Constructor
......
......@@ -4,37 +4,16 @@
// 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/.
/// @file This file contains tests which verify flexible option callouts.
#include <config.h>
#include <asiolink/asio_wrapper.h>
#include <exceptions/exceptions.h>
#include <dhcp/dhcp4.h>
#include <dhcp/dhcp6.h>
#include <dhcp/option.h>
#include <dhcp/pkt4.h>
#include <dhcp/pkt6.h>
#include <dhcpsrv/host.h>
#include <dhcp/option.h>
#include <dhcp/option_string.h>
#include <hooks/callout_manager.h>
#include <hooks/hooks.h>
#include <flex_option.h>
#include <flex_option_log.h>
#include <log/logger_support.h>
#include <gtest/gtest.h>
using namespace std;
using namespace isc;
using namespace isc::dhcp;
using namespace isc::hooks;
using namespace isc::flex_option;
int
main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv);
isc::log::initLogger();
int result = RUN_ALL_TESTS();
extern "C" {
extern int pkt4_send(CalloutHandle& handle);
extern int pkt6_send(CalloutHandle& handle);
return (result);
}
namespace {
} // end of anonymous namespace
......@@ -26,8 +26,7 @@ if HAVE_GTEST
TESTS += flex_option_unittests
flex_option_unittests_SOURCES = run_unittests.cc
flex_option_unittests_SOURCES += callout_unittests.cc
flex_option_unittests_SOURCES += load_unload_unittests.cc
flex_option_unittests_SOURCES += flex_option_unittests.cc
flex_option_unittests_CPPFLAGS = $(AM_CPPFLAGS) $(GTEST_INCLUDES) $(LOG4CPLUS_INCLUDES)
......@@ -35,7 +34,8 @@ flex_option_unittests_LDFLAGS = $(AM_LDFLAGS) $(CRYPTO_LDFLAGS) $(GTEST_LDFLAGS
flex_option_unittests_CXXFLAGS = $(AM_CXXFLAGS)
flex_option_unittests_LDADD = $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
flex_option_unittests_LDADD = $(top_builddir)/src/hooks/dhcp/flex_option/libflex_option.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libkea-dhcpsrv.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/eval/libkea-eval.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libkea-dhcp++.la
flex_option_unittests_LDADD += $(top_builddir)/src/lib/hooks/libkea-hooks.la
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment