Commit 06069bf9 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac2463'

Conflicts:
	src/bin/dhcp6/tests/config_parser_unittest.cc
parents 42c59bc2 436eae01
This diff is collapsed.
......@@ -53,6 +53,8 @@ public:
}
~Dhcp6ParserTest() {
// Reset configuration database after each test.
resetConfiguration();
};
/// @brief Create the simple configuration with single option.
......@@ -116,6 +118,51 @@ public:
return (stream.str());
}
/// @brief Reset configuration database.
///
/// This function resets configuration data base by
/// removing all subnets and option-data. Reset must
/// be performed after each test to make sure that
/// contents of the database do not affect result of
/// subsequent tests.
void resetConfiguration() {
ConstElementPtr status;
string config = "{ \"interface\": [ \"all\" ],"
"\"preferred-lifetime\": 3000,"
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"valid-lifetime\": 4000, "
"\"subnet6\": [ ], "
"\"option-data\": [ ] }";
try {
ElementPtr json = Element::fromJSON(config);
status = configureDhcp6Server(srv_, json);
} catch (const std::exception& ex) {
FAIL() << "Fatal error: unable to reset configuration database"
<< " after the test. The following configuration was used"
<< " to reset database: " << std::endl
<< config << std::endl
<< " and the following error message was returned:"
<< ex.what() << std::endl;
}
// returned value should be 0 (configuration success)
if (!status) {
FAIL() << "Fatal error: unable to reset configuration database"
<< " after the test. Configuration function returned"
<< " NULL pointer" << std::endl;
}
comment_ = parseAnswer(rcode_, status);
if (rcode_ != 0) {
FAIL() << "Fatal error: unable to reset configuration database"
<< " after the test. Configuration function returned"
<< " error code " << rcode_ << std::endl;
}
}
/// @brief Test invalid option parameter value.
///
/// This test function constructs the simple configuration
......@@ -691,7 +738,7 @@ TEST_F(Dhcp6ParserTest, stdOptionData) {
// Option code 3 means OPTION_IA_NA.
params["code"] = "3";
params["data"] = "ABCDEF01 02030405 06070809";
std::string config = createConfigWithOption(params);
ElementPtr json = Element::fromJSON(config);
......
......@@ -69,6 +69,12 @@ public:
/// @param persist if true option is always sent.
OptionDescriptor(OptionPtr& opt, bool persist)
: option(opt), persistent(persist) {};
/// @brief Constructor
///
/// @param persist if true option is always sent.
OptionDescriptor(bool persist)
: option(OptionPtr()), persistent(persist) {};
};
/// @brief Extractor class to extract key with another key.
......
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