Browse Source

[3696] Remove default lease files after unit tests.

Marcin Siodelski 9 years ago
parent
commit
9497258cf7

+ 6 - 1
src/bin/dhcp4/tests/dhcp4_test_utils.cc

@@ -1,4 +1,4 @@
-// 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
@@ -38,6 +38,11 @@ BaseServerTest::BaseServerTest()
 }
 
 BaseServerTest::~BaseServerTest() {
+    // Remove default lease file.
+    std::ostringstream s2;
+    s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases4.csv";
+    static_cast<void>(::remove(s2.str().c_str()));
+
     // Revert to original data directory.
     CfgMgr::instance().setDataDir(original_datadir_);
 }

+ 1 - 1
src/bin/dhcp4/tests/dhcp4_test_utils.h

@@ -1,4 +1,4 @@
-// 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

+ 0 - 5
src/bin/dhcp4/tests/kea_controller_unittest.cc

@@ -60,11 +60,6 @@ public:
         LeaseMgrFactory::destroy();
         isc::log::setDefaultLoggingOutput();
         static_cast<void>(remove(TEST_FILE));
-
-        // Remove default lease file.
-        std::ostringstream s;
-        s << CfgMgr::instance().getDataDir() << "/kea-leases4.csv";
-        static_cast<void>(remove(s.str().c_str()));
     };
 
     /// @brief writes specified content to a well known file

+ 7 - 1
src/bin/dhcp6/tests/dhcp6_test_utils.cc

@@ -1,4 +1,4 @@
-// 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
@@ -38,6 +38,12 @@ BaseServerTest::~BaseServerTest() {
     std::ostringstream s;
     s << CfgMgr::instance().getDataDir() << "/" << DUID_FILE;
     static_cast<void>(::remove(s.str().c_str()));
+
+    // Remove default lease file.
+    std::ostringstream s2;
+    s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases6.csv";
+    static_cast<void>(::remove(s2.str().c_str()));
+
     // Revert to original data directory.
     CfgMgr::instance().setDataDir(original_datadir_);
 }

+ 0 - 5
src/bin/dhcp6/tests/kea_controller_unittest.cc

@@ -56,11 +56,6 @@ public:
         LeaseMgrFactory::destroy();
         isc::log::setDefaultLoggingOutput();
         static_cast<void>(remove(TEST_FILE));
-
-        // Remove default lease file.
-        std::ostringstream s;
-        s << CfgMgr::instance().getDataDir() << "/kea-leases6.csv";
-        static_cast<void>(remove(s.str().c_str()));
     };
 
     void writeFile(const std::string& file_name, const std::string& content) {