Commit f45d0b5d authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰

[master] Merge branch 'trac4297' (hook libs can now take parameters)

parents db358c1a 12b174bb
......@@ -57,13 +57,24 @@
"library": "/opt/charging.so"
},
{
"library": "/opt/local/notification.so"
"library": "/opt/local/notification.so",
"parameters": {
"mail": "spam@example.com",
"floor": 13,
"debug": false,
"users": [ "alice", "bob", "charlie" ],
"languages": {
"french": "bonjour",
"klingon": "yl'el"
}
}
}
]
:
}</userinput>
</screen>
</para>
<note><para>
This is a change to the syntax used in Kea 0.9.2 and earlier, where
hooks-libraries was a list of strings, each string being the name of
......@@ -71,6 +82,30 @@
specification of library-specific parameters, a feature that will be
added to a future version of Kea.
</para></note>
<note>
<para>
The library reloading behavior has changed in Kea 1.1. Libraries are
reloaded, even if their list hasn't changed. Kea does that, because
the parameters specified for the library (or the files those
parameters point to) may have changed.
</para>
</note>
<para>
Libraries may have additional parameters. Those are not mandatory in the
sense that there may be libraries that don't require them. However, for
specific library there is often specific requirement for specify certain
set of parameters. Please consult the documentation for your library
for details. In the example above, the first library has no parameters.
The second library has five parameters, specifying mail (string
parameter), floor (integer parameter), debug (boolean parameter) and
even lists (list of strings) and maps (containing strings). Nested
parameters could be used if the library supports it. This topic is
explained in detail in the Hooks Developer's Guide in Configuring Hooks
Libraries section.
</para>
<para>
Notes:
<itemizedlist mark='bullet'>
......
......@@ -45,7 +45,7 @@ ControlledDhcpv4Srv::commandLibReloadHandler(const string&, ConstElementPtr) {
/// @todo delete any stored CalloutHandles referring to the old libraries
/// Get list of currently loaded libraries and reload them.
vector<string> loaded = HooksManager::getLibraryNames();
HookLibsCollection loaded = HooksManager::getLibraryInfo();
bool status = HooksManager::loadLibraries(loaded);
if (!status) {
LOG_ERROR(dhcp4_logger, DHCP4_HOOKS_LIBS_RELOAD_FAIL);
......
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2016 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
......@@ -233,15 +233,15 @@ TEST_F(CtrlChannelDhcpv4SrvTest, libreload) {
ASSERT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
// Load two libraries
std::vector<std::string> libraries;
libraries.push_back(CALLOUT_LIBRARY_1);
libraries.push_back(CALLOUT_LIBRARY_2);
HookLibsCollection libraries;
libraries.push_back(make_pair(CALLOUT_LIBRARY_1, ConstElementPtr()));
libraries.push_back(make_pair(CALLOUT_LIBRARY_2, ConstElementPtr()));
HooksManager::loadLibraries(libraries);
// Check they are loaded.
std::vector<std::string> loaded_libraries =
HooksManager::getLibraryNames();
ASSERT_TRUE(libraries == loaded_libraries);
ASSERT_TRUE(extractNames(libraries) == loaded_libraries);
// ... which also included checking that the marker file created by the
// load functions exists and holds the correct value (of "12" - the
......
......@@ -51,7 +51,7 @@ ConstElementPtr
ControlledDhcpv6Srv::commandLibReloadHandler(const string&, ConstElementPtr) {
/// @todo delete any stored CalloutHandles referring to the old libraries
/// Get list of currently loaded libraries and reload them.
vector<string> loaded = HooksManager::getLibraryNames();
HookLibsCollection loaded = HooksManager::getLibraryInfo();
bool status = HooksManager::loadLibraries(loaded);
if (!status) {
LOG_ERROR(dhcp6_logger, DHCP6_HOOKS_LIBS_RELOAD_FAIL);
......
// Copyright (C) 2012-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2016 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
......@@ -249,14 +249,14 @@ TEST_F(CtrlDhcpv6SrvTest, libreload) {
ASSERT_FALSE(checkMarkerFileExists(UNLOAD_MARKER_FILE));
// Load two libraries
std::vector<std::string> libraries;
libraries.push_back(CALLOUT_LIBRARY_1);
libraries.push_back(CALLOUT_LIBRARY_2);
HookLibsCollection libraries;
libraries.push_back(make_pair(CALLOUT_LIBRARY_1, ConstElementPtr()));
libraries.push_back(make_pair(CALLOUT_LIBRARY_2, ConstElementPtr()));
HooksManager::loadLibraries(libraries);
// Check they are loaded.
std::vector<std::string> loaded_libraries =
HooksManager::getLibraryNames();
HookLibsCollection loaded_libraries =
HooksManager::getLibraryInfo();
ASSERT_TRUE(libraries == loaded_libraries);
// ... which also included checking that the marker file created by the
......
# The following build order must be maintained.
SUBDIRS = exceptions util log hooks cryptolink dns cc asiolink testutils dhcp config \
SUBDIRS = exceptions util log cryptolink dns cc hooks asiolink testutils dhcp config \
stats asiodns dhcp_ddns eval dhcpsrv cfgrpt
......@@ -13,4 +13,9 @@ libkea_cc_la_LIBADD += $(BOOST_LIBS)
libkea_cc_la_LDFLAGS = -no-undefined -version-info 1:0:0
# Since data.h is now used in the hooks interface, it needs to be
# installed on target system.
libkea_cc_includedir = $(pkgincludedir)/cc
libkea_cc_include_HEADERS = data.h
CLEANFILES = *.gcno *.gcda
......@@ -254,6 +254,8 @@ HooksLibrariesParser::build(ConstElementPtr value) {
// This is the new syntax. Iterate through it and get each map.
BOOST_FOREACH(ConstElementPtr library_entry, value->listValue()) {
ConstElementPtr parameters;
// Is it a map?
if (library_entry->getType() != Element::map) {
isc_throw(DhcpConfigError, "hooks library configuration error:"
......@@ -264,6 +266,13 @@ HooksLibrariesParser::build(ConstElementPtr value) {
// Iterate iterate through each element in the map. We check
// whether we have found a library element.
bool lib_found = false;
string libname = "";
// Let's explicitly reset the parameters, so we won't cover old
// values from the previous loop round.
parameters.reset();
BOOST_FOREACH(ConfigPair entry_item, library_entry->mapValue()) {
if (entry_item.first == "library") {
if (entry_item.second->getType() != Element::string) {
......@@ -275,7 +284,7 @@ HooksLibrariesParser::build(ConstElementPtr value) {
// Get the name of the library and add it to the list after
// removing quotes.
string libname = (entry_item.second)->stringValue();
libname = (entry_item.second)->stringValue();
// Remove leading/trailing quotes and any leading/trailing
// spaces.
......@@ -287,10 +296,14 @@ HooksLibrariesParser::build(ConstElementPtr value) {
" blank (" <<
entry_item.second->getPosition() << ")");
}
libraries_.push_back(libname);
// Note we have found the library name.
lib_found = true;
} else {
// If there are parameters, let's remember them.
if (entry_item.first == "parameters") {
parameters = entry_item.second;
}
}
}
if (! lib_found) {
......@@ -299,19 +312,26 @@ HooksLibrariesParser::build(ConstElementPtr value) {
" name of the library" <<
" (" << library_entry->getPosition() << ")");
}
libraries_.push_back(make_pair(libname, parameters));
}
// Check if the list of libraries has changed. If not, nothing is done
// - the command "DhcpN libreload" is required to reload the same
// libraries (this prevents needless reloads when anything else in the
// configuration is changed).
// We no longer rely on this. Parameters can change. And even if the
// parameters stay the same, they could point to files that could
// change.
vector<string> current_libraries = HooksManager::getLibraryNames();
if (current_libraries == libraries_) {
if (current_libraries.empty() && libraries_.empty()) {
return;
}
// Library list has changed, validate each of the libraries specified.
vector<string> error_libs = HooksManager::validateLibraries(libraries_);
vector<string> lib_names = isc::hooks::extractNames(libraries_);
vector<string> error_libs = HooksManager::validateLibraries(lib_names);
if (!error_libs.empty()) {
// Construct the list of libraries in error for the message.
......@@ -334,15 +354,15 @@ HooksLibrariesParser::commit() {
/// Commits the list of libraries to the configuration manager storage if
/// the list of libraries has changed.
if (changed_) {
// TODO Delete any stored CalloutHandles before reloading the
// libraries
/// @todo: Delete any stored CalloutHandles before reloading the
/// libraries
HooksManager::loadLibraries(libraries_);
}
}
// Method for testing
void
HooksLibrariesParser::getLibraries(std::vector<std::string>& libraries,
HooksLibrariesParser::getLibraries(isc::hooks::HookLibsCollection& libraries,
bool& changed) {
libraries = libraries_;
changed = changed_;
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2016 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
......@@ -16,6 +16,7 @@
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/subnet.h>
#include <dhcpsrv/parsers/dhcp_config_parser.h>
#include <hooks/libinfo.h>
#include <exceptions/exceptions.h>
#include <util/optional_value.h>
......@@ -35,9 +36,6 @@ typedef OptionSpaceContainer<OptionContainer, OptionDescriptor,
/// @brief Shared pointer to option storage.
typedef boost::shared_ptr<OptionStorage> OptionStoragePtr;
/// @brief Shared pointer to collection of hooks libraries.
typedef boost::shared_ptr<std::vector<std::string> > HooksLibsStoragePtr;
/// @brief A template class that stores named elements of a given data type.
///
/// This template class is provides data value storage for configuration
......@@ -218,7 +216,7 @@ public:
/// the list of current names can be obtained from the HooksManager) or it
/// is non-null (this is the new list of names, reload the libraries when
/// possible).
HooksLibsStoragePtr hooks_libraries_;
isc::hooks::HookLibsCollectionPtr hooks_libraries_;
/// @brief The parsing universe of this context.
Option::Universe universe_;
......@@ -508,11 +506,11 @@ public:
/// new configuration.
/// @param [out] changed true if the list is different from that currently
/// loaded.
void getLibraries(std::vector<std::string>& libraries, bool& changed);
void getLibraries(isc::hooks::HookLibsCollection& libraries, bool& changed);
private:
/// List of hooks libraries.
std::vector<std::string> libraries_;
/// List of hooks libraries with their configuration parameters
isc::hooks::HookLibsCollection libraries_;
/// Indicator flagging that the list of libraries has changed.
bool changed_;
......
......@@ -40,7 +40,7 @@ if HAVE_GTEST
# to unexpected errors. For this reason, the --enable-static-link option is
# ignored for unit tests built here.
noinst_LTLIBRARIES = libco1.la libco2.la
noinst_LTLIBRARIES = libco1.la libco2.la libco3.la
# -rpath /nowhere is a hack to trigger libtool to not create a
# convenience archive, resulting in shared modules
......@@ -55,6 +55,11 @@ libco2_la_CXXFLAGS = $(AM_CXXFLAGS)
libco2_la_CPPFLAGS = $(AM_CPPFLAGS)
libco2_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
libco3_la_SOURCES = callout_params_library.cc
libco3_la_CXXFLAGS = $(AM_CXXFLAGS)
libco3_la_CPPFLAGS = $(AM_CPPFLAGS)
libco3_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
TESTS += libdhcpsrv_unittests
libdhcpsrv_unittests_SOURCES = run_unittests.cc
......
......@@ -847,7 +847,7 @@ public:
}
}
vector<string> libraries; // no libraries at this time
HookLibsCollection libraries; // no libraries at this time
HooksManager::loadLibraries(libraries);
// Install a callout: lease4_expire or lease6_expire.
......@@ -877,7 +877,7 @@ public:
}
}
vector<string> libraries; // no libraries at this time
HookLibsCollection libraries; // no libraries at this time
HooksManager::loadLibraries(libraries);
// Install a callout: lease4_expire or lease6_expire.
......@@ -905,7 +905,7 @@ public:
expire(i, 2000 - i);
}
vector<string> libraries;
HookLibsCollection libraries;
HooksManager::loadLibraries(libraries);
// Install a callout: lease4_expire or lease6_expire. Each callout
......
// Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2015-2016 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
......@@ -137,7 +137,7 @@ TEST_F(HookAllocEngine6Test, lease6_select) {
ASSERT_TRUE(engine);
// Initialize Hooks Manager
vector<string> libraries; // no libraries at this time
HookLibsCollection libraries; // no libraries at this time
HooksManager::loadLibraries(libraries);
// Install pkt6_receive_callout
......@@ -207,7 +207,7 @@ TEST_F(HookAllocEngine6Test, change_lease6_select) {
ASSERT_TRUE(engine);
// Initialize Hooks Manager
vector<string> libraries; // no libraries at this time
HookLibsCollection libraries; // no libraries at this time
HooksManager::loadLibraries(libraries);
// Install a callout
......@@ -368,7 +368,7 @@ TEST_F(HookAllocEngine4Test, lease4_select) {
ASSERT_TRUE(engine);
// Initialize Hooks Manager
vector<string> libraries; // no libraries at this time
HookLibsCollection libraries; // no libraries at this time
HooksManager::loadLibraries(libraries);
// Install pkt4_receive_callout
......@@ -435,7 +435,7 @@ TEST_F(HookAllocEngine4Test, change_lease4_select) {
ASSERT_TRUE(engine);
// Initialize Hooks Manager
vector<string> libraries; // no libraries at this time
HookLibsCollection libraries; // no libraries at this time
HooksManager::loadLibraries(libraries);
// Install a callout
......
// Copyright (C) 2016 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/.
/// @file
/// @brief Callout Library
///
/// This is the source of a test library for the DHCP parser tests that
/// specify parameters. It will attempt to obtain its own parameters.
#include <config.h>
#include <hooks/hooks.h>
extern "C" {
// Framework functions
int
version() {
return (KEA_HOOKS_VERSION);
}
};
......@@ -1034,7 +1034,7 @@ TEST_F(ParseConfigTest, noHooksLibraries) {
ASSERT_TRUE(rcode == 0) << error_text_;
// Check that the parser recorded nothing.
std::vector<std::string> libraries;
isc::hooks::HookLibsCollection libraries;
bool changed;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_FALSE(changed);
......@@ -1059,12 +1059,12 @@ TEST_F(ParseConfigTest, oneHooksLibrary) {
ASSERT_TRUE(rcode == 0) << error_text_;
// Check that the parser recorded a single library.
std::vector<std::string> libraries;
HookLibsCollection libraries;
bool changed;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_TRUE(changed);
ASSERT_EQ(1, libraries.size());
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0]);
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0].first);
// Check that the change was propagated to the hooks manager.
hooks_libraries = HooksManager::getLibraryNames();
......@@ -1087,13 +1087,13 @@ TEST_F(ParseConfigTest, twoHooksLibraries) {
ASSERT_TRUE(rcode == 0) << error_text_;
// Check that the parser recorded two libraries in the expected order.
std::vector<std::string> libraries;
HookLibsCollection libraries;
bool changed;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_TRUE(changed);
ASSERT_EQ(2, libraries.size());
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0]);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[1]);
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0].first);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[1].first);
// Verify that the change was propagated to the hooks manager.
hooks_libraries = HooksManager::getLibraryNames();
......@@ -1124,15 +1124,16 @@ TEST_F(ParseConfigTest, reconfigureSameHooksLibraries) {
rcode = parseConfiguration(config);
ASSERT_TRUE(rcode == 0) << error_text_;
// The list has not changed between the two parse operations and this is
// what we should see.
std::vector<std::string> libraries;
// The list has not changed between the two parse operations. However,
// the paramters (or the files they could point to) could have
// changed, so the libraries are reloaded anyway.
HookLibsCollection libraries;
bool changed;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_FALSE(changed);
EXPECT_TRUE(changed);
ASSERT_EQ(2, libraries.size());
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0]);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[1]);
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0].first);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[1].first);
// ... and check that the same two libraries are still loaded in the
// HooksManager.
......@@ -1167,13 +1168,13 @@ TEST_F(ParseConfigTest, reconfigureReverseHooksLibraries) {
ASSERT_TRUE(rcode == 0) << error_text_;
// The list has changed, and this is what we should see.
std::vector<std::string> libraries;
HookLibsCollection libraries;
bool changed;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_TRUE(changed);
ASSERT_EQ(2, libraries.size());
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[0]);
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[1]);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[0].first);
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[1].first);
// ... and check that this was propagated to the HooksManager.
hooks_libraries = HooksManager::getLibraryNames();
......@@ -1206,7 +1207,7 @@ TEST_F(ParseConfigTest, reconfigureZeroHooksLibraries) {
ASSERT_TRUE(rcode == 0) << error_text_;
// The list has changed, and this is what we should see.
std::vector<std::string> libraries;
HookLibsCollection libraries;
bool changed;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_TRUE(changed);
......@@ -1240,14 +1241,14 @@ TEST_F(ParseConfigTest, invalidHooksLibraries) {
// Check that the parser recorded the names but, as they were in error,
// does not flag them as changed.
vector<string> libraries;
HookLibsCollection libraries;
bool changed;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_FALSE(changed);
ASSERT_EQ(3, libraries.size());
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0]);
EXPECT_EQ(NOT_PRESENT_LIBRARY, libraries[1]);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[2]);
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0].first);
EXPECT_EQ(NOT_PRESENT_LIBRARY, libraries[1].first);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[2].first);
// ...and check it did not alter the libraries in the hooks manager.
hooks_libraries = HooksManager::getLibraryNames();
......@@ -1284,14 +1285,14 @@ TEST_F(ParseConfigTest, reconfigureInvalidHooksLibraries) {
// Check that the parser recorded the names but, as the library set was
// incorrect, did not mark the configuration as changed.
vector<string> libraries;
HookLibsCollection libraries;
bool changed;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_FALSE(changed);
ASSERT_EQ(3, libraries.size());
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0]);
EXPECT_EQ(NOT_PRESENT_LIBRARY, libraries[1]);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[2]);
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0].first);
EXPECT_EQ(NOT_PRESENT_LIBRARY, libraries[1].first);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[2].first);
// ... but check that the hooks manager was not updated with the incorrect
// names.
......@@ -1373,6 +1374,71 @@ TEST_F(ParseConfigTest, invalidSyntaxHooksLibraries) {
"Error text returned from parse failure is " << error_text_;
}
// Check that some parameters may have configuration parameters configured.
TEST_F(ParseConfigTest, HooksLibrariesParameters) {
// Check that no libraries are currently loaded
vector<string> hooks_libraries = HooksManager::getLibraryNames();
EXPECT_TRUE(hooks_libraries.empty());
// Configuration string. This contains an invalid library which should
// trigger an error in the "build" stage.
const std::string config = setHooksLibrariesConfig(CALLOUT_LIBRARY_1,
CALLOUT_LIBRARY_2,
CALLOUT_PARAMS_LIBRARY);
// Verify that the configuration fails to parse. (Syntactically it's OK,
// but the library is invalid).
const int rcode = parseConfiguration(config);
ASSERT_EQ(0, rcode);
// Check that the parser recorded the names.
HookLibsCollection libraries;
bool changed = false;
hooks_libraries_parser_->getLibraries(libraries, changed);
EXPECT_TRUE(changed);
ASSERT_EQ(3, libraries.size());
EXPECT_EQ(CALLOUT_LIBRARY_1, libraries[0].first);
EXPECT_EQ(CALLOUT_LIBRARY_2, libraries[1].first);
EXPECT_EQ(CALLOUT_PARAMS_LIBRARY, libraries[2].first);
// Also, check that the third library has its parameters specified.
// They were set by setHooksLibrariesConfig. The first has no
// parameters, the second one has an empty map and the third
// one has actual parameters.
EXPECT_FALSE(libraries[0].second);
EXPECT_TRUE(libraries[1].second);
ASSERT_TRUE(libraries[2].second);
// Ok, get the parameter for the third library.
ConstElementPtr params = libraries[2].second;
// It must be a map.
ASSERT_EQ(Element::map, params->getType());
// This map should have 3 parameters:
// - svalue (and will expect its value to be "string value")
// - ivalue (and will expect its value to be 42)
// - bvalue (and will expect its value to be true)
ConstElementPtr svalue = params->get("svalue");
ConstElementPtr ivalue = params->get("ivalue");
ConstElementPtr bvalue = params->get("bvalue");
// There should be no extra parameters.
EXPECT_FALSE(params->get("nonexistent"));
ASSERT_TRUE(svalue);
ASSERT_TRUE(ivalue);
ASSERT_TRUE(bvalue);
ASSERT_EQ(Element::string, svalue->getType());
ASSERT_EQ(Element::integer, ivalue->getType());
ASSERT_EQ(Element::boolean, bvalue->getType());
EXPECT_EQ("string value", svalue->stringValue());
EXPECT_EQ(42, ivalue->intValue());
EXPECT_EQ(true, bvalue->boolValue());
}
/// @brief Checks that a valid, enabled D2 client configuration works correctly.
TEST_F(ParseConfigTest, validD2Config) {
......@@ -1895,8 +1961,8 @@ public:
// Allocate container for hooks libraries and add one library name.
ctx.hooks_libraries_.reset(new std::vector<std::string>());
ctx.hooks_libraries_->push_back("library1");
ctx.hooks_libraries_.reset(new std::vector<HookLibInfo>());
ctx.hooks_libraries_->push_back(make_pair("library1", ConstElementPtr()));
// We will use ctx_new to assign another context to it or copy
// construct.
......@@ -1977,7 +2043,7 @@ public:
ASSERT_TRUE(ctx_new->hooks_libraries_);
{
ASSERT_EQ(1, ctx_new->hooks_libraries_->size());
EXPECT_EQ("library1", (*ctx_new->hooks_libraries_)[0]);
EXPECT_EQ("library1", (*ctx_new->hooks_libraries_)[0].first);
}
// New context has the same universe.
......@@ -2091,9 +2157,9 @@ public:
// Change the list of libraries. this should not affect the list in the
// new context.
ctx.hooks_libraries_->clear();
ctx.hooks_libraries_->push_back("library2");
ctx.hooks_libraries_->push_back(make_pair("library2", ConstElementPtr()));
ASSERT_EQ(1, ctx_new->hooks_libraries_->size());
EXPECT_EQ("library1", (*ctx_new->hooks_libraries_)[0]);
EXPECT_EQ("library1", (*ctx_new->hooks_libraries_)[0].first);
// Change the universe. This should not affect the universe value in the
// new context.
......