diff options
author | Francis Dupont <fdupont@isc.org> | 2024-07-10 11:57:28 +0200 |
---|---|---|
committer | Francis Dupont <fdupont@isc.org> | 2024-08-22 16:49:31 +0200 |
commit | 32d17a2461a0b06e5548254e8e5c11c76f7ccad6 (patch) | |
tree | d093d05465355b2f61b0110ea8fc6f38e7f28bc2 | |
parent | [#3513] address review (diff) | |
download | kea-32d17a2461a0b06e5548254e8e5c11c76f7ccad6.tar.xz kea-32d17a2461a0b06e5548254e8e5c11c76f7ccad6.zip |
[#3487] Added unsetenv code in fixture
-rw-r--r-- | src/lib/log/tests/logger_unittest.cc | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/lib/log/tests/logger_unittest.cc b/src/lib/log/tests/logger_unittest.cc index cc2fb9586a..9e86cfd903 100644 --- a/src/lib/log/tests/logger_unittest.cc +++ b/src/lib/log/tests/logger_unittest.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2011-2022 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2011-2024 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 @@ -20,6 +20,7 @@ #include <log/output_option.h> #include <log/tests/log_test_messages.h> +#include <cstdlib> #include <iostream> #include <string> @@ -34,13 +35,26 @@ using namespace std; class LoggerTest : public ::testing::Test { public: - LoggerTest() { - // Initialize logging before each test, even if it is already done in main(). + LoggerTest() : kld_value_(0) { + // HasAppender fails when KEA_LOGGER_DESTINATION is set so remove it. + kld_value_ = getenv("KEA_LOGGER_DESTINATION"); + if (kld_value_ != 0) { + static_cast<void>(unsetenv("KEA_LOGGER_DESTINATION")); + } + isc::log::initLogger(); } ~LoggerTest() { LoggerManager::reset(); + + // Restore KEA_LOGGER_DESTINATION value. + if (kld_value_ != 0) { + static_cast<void>(setenv("KEA_LOGGER_DESTINATION", kld_value_, 1)); + } } + + // The KEA_LOGGER_DESTINATION environment variable value. + char* kld_value_; }; // Check version |