From 9497258cf787509099b9e012eef5fe315b51f9c2 Mon Sep 17 00:00:00 2001 From: Marcin Siodelski Date: Tue, 12 Jan 2016 16:49:00 +0100 Subject: [PATCH] [3696] Remove default lease files after unit tests. --- src/bin/dhcp4/tests/dhcp4_test_utils.cc | 7 ++++++- src/bin/dhcp4/tests/dhcp4_test_utils.h | 2 +- src/bin/dhcp4/tests/kea_controller_unittest.cc | 5 ----- src/bin/dhcp6/tests/dhcp6_test_utils.cc | 8 +++++++- src/bin/dhcp6/tests/kea_controller_unittest.cc | 5 ----- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.cc b/src/bin/dhcp4/tests/dhcp4_test_utils.cc index 5d60592de4..f55e06ccd8 100644 --- a/src/bin/dhcp4/tests/dhcp4_test_utils.cc +++ b/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(::remove(s2.str().c_str())); + // Revert to original data directory. CfgMgr::instance().setDataDir(original_datadir_); } diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.h b/src/bin/dhcp4/tests/dhcp4_test_utils.h index ebfa97325c..46a5342134 100644 --- a/src/bin/dhcp4/tests/dhcp4_test_utils.h +++ b/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 diff --git a/src/bin/dhcp4/tests/kea_controller_unittest.cc b/src/bin/dhcp4/tests/kea_controller_unittest.cc index a31a5103c4..09bd30b511 100644 --- a/src/bin/dhcp4/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp4/tests/kea_controller_unittest.cc @@ -60,11 +60,6 @@ public: LeaseMgrFactory::destroy(); isc::log::setDefaultLoggingOutput(); static_cast(remove(TEST_FILE)); - - // Remove default lease file. - std::ostringstream s; - s << CfgMgr::instance().getDataDir() << "/kea-leases4.csv"; - static_cast(remove(s.str().c_str())); }; /// @brief writes specified content to a well known file diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.cc b/src/bin/dhcp6/tests/dhcp6_test_utils.cc index 0598bbad93..e7f06b7969 100644 --- a/src/bin/dhcp6/tests/dhcp6_test_utils.cc +++ b/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(::remove(s.str().c_str())); + + // Remove default lease file. + std::ostringstream s2; + s2 << CfgMgr::instance().getDataDir() << "/" << "kea-leases6.csv"; + static_cast(::remove(s2.str().c_str())); + // Revert to original data directory. CfgMgr::instance().setDataDir(original_datadir_); } diff --git a/src/bin/dhcp6/tests/kea_controller_unittest.cc b/src/bin/dhcp6/tests/kea_controller_unittest.cc index 103e450f06..e957235a94 100644 --- a/src/bin/dhcp6/tests/kea_controller_unittest.cc +++ b/src/bin/dhcp6/tests/kea_controller_unittest.cc @@ -56,11 +56,6 @@ public: LeaseMgrFactory::destroy(); isc::log::setDefaultLoggingOutput(); static_cast(remove(TEST_FILE)); - - // Remove default lease file. - std::ostringstream s; - s << CfgMgr::instance().getDataDir() << "/kea-leases6.csv"; - static_cast(remove(s.str().c_str())); }; void writeFile(const std::string& file_name, const std::string& content) {