Browse Source

[2355] CfgMgr.addOptionDefs unit test was failing with duplicat definition
exception under Ubuntu. Added logic to reset all of CfgMgr data between tests. Did not fail under Mac OS-X. New unit tests added for options definition tests were leaving data in CfgMgr.

Thomas Markwalder 12 years ago
parent
commit
aedbd11c67

+ 1 - 0
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc

@@ -163,6 +163,7 @@ public:
         // make sure we start with a clean configuration
         CfgMgr::instance().deleteSubnets4();
         CfgMgr::instance().deleteSubnets6();
+        //CfgMgr::instance().deleteOptionDefs();
     }
 
     ~CfgMgrTest() {

+ 8 - 1
src/lib/dhcpsrv/tests/dhcp_parsers_unittest.cc

@@ -13,11 +13,11 @@
 // PERFORMANCE OF THIS SOFTWARE.
 
 #include <config.h>
-
 #include <config/ccsession.h>
 #include <dhcp/option.h>
 #include <dhcp/option_custom.h>
 #include <dhcp/option_int.h>
+#include <dhcpsrv/cfgmgr.h>
 #include <dhcpsrv/subnet.h>
 #include <dhcpsrv/dhcp_parsers.h>
 #include <exceptions/exceptions.h>
@@ -246,6 +246,10 @@ public:
         reset_context();
     }
 
+    ~ParseConfigTest() {
+        reset_context();
+    }
+
     /// @brief Parses a configuration.   
     ///
     /// Parse the given configuration, populating the context storage with
@@ -418,6 +422,9 @@ public:
     /// during a given test if needed.
     void reset_context(){
         // Note set context universe to V6 as it has to be something.
+        CfgMgr::instance().deleteSubnets4();
+        CfgMgr::instance().deleteSubnets6();
+        CfgMgr::instance().deleteOptionDefs();
         parser_context_.reset(new ParserContext(Option::V6));
     }