]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[master] Merge branch 'trac2463'
authorMarcin Siodelski <marcin@isc.org>
Tue, 13 Nov 2012 12:02:17 +0000 (13:02 +0100)
committerMarcin Siodelski <marcin@isc.org>
Tue, 13 Nov 2012 12:02:17 +0000 (13:02 +0100)
Conflicts:
src/bin/dhcp6/tests/config_parser_unittest.cc

1  2 
src/bin/dhcp6/tests/config_parser_unittest.cc
src/lib/dhcp/subnet.h

index 780b5db7235ee7d046c9cfae1176f23907e93f49,7d959a03ab622f86cb76197cd7dee7fe12dcbd50..95c78970ec3a9fb1a89d45544648138206a63dca
@@@ -53,6 -54,9 +53,8 @@@ public
      }
  
      ~Dhcp6ParserTest() {
 -        delete srv_;
+         // Reset configuration database after each test.
+         resetConfiguration();
      };
  
      /// @brief Create the simple configuration with single option.
          return (stream.str());
      }
  
 -            status = configureDhcp6Server(*srv_, json);
+     /// @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
Simple merge