From: Marcin Siodelski Date: Tue, 13 Nov 2012 12:02:17 +0000 (+0100) Subject: [master] Merge branch 'trac2463' X-Git-Tag: trac2487_base~1^2~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=06069bf9520dc24133605c0ef19ffdeb3414d669;p=thirdparty%2Fkea.git [master] Merge branch 'trac2463' Conflicts: src/bin/dhcp6/tests/config_parser_unittest.cc --- 06069bf9520dc24133605c0ef19ffdeb3414d669 diff --cc src/bin/dhcp6/tests/config_parser_unittest.cc index 780b5db723,7d959a03ab..95c78970ec --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@@ -53,6 -54,9 +53,8 @@@ public } ~Dhcp6ParserTest() { + // Reset configuration database after each test. + resetConfiguration(); - delete srv_; }; /// @brief Create the simple configuration with single option. @@@ -116,6 -120,51 +118,51 @@@ 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); ++ 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