Skip to content

Commit 32d17a2

Browse files
committed
[#3487] Added unsetenv code in fixture
1 parent 8c80464 commit 32d17a2

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/lib/log/tests/logger_unittest.cc

+17-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2011-2022 Internet Systems Consortium, Inc. ("ISC")
1+
// Copyright (C) 2011-2024 Internet Systems Consortium, Inc. ("ISC")
22
//
33
// This Source Code Form is subject to the terms of the Mozilla Public
44
// License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -20,6 +20,7 @@
2020
#include <log/output_option.h>
2121
#include <log/tests/log_test_messages.h>
2222

23+
#include <cstdlib>
2324
#include <iostream>
2425
#include <string>
2526

@@ -34,13 +35,26 @@ using namespace std;
3435

3536
class LoggerTest : public ::testing::Test {
3637
public:
37-
LoggerTest() {
38-
// Initialize logging before each test, even if it is already done in main().
38+
LoggerTest() : kld_value_(0) {
39+
// HasAppender fails when KEA_LOGGER_DESTINATION is set so remove it.
40+
kld_value_ = getenv("KEA_LOGGER_DESTINATION");
41+
if (kld_value_ != 0) {
42+
static_cast<void>(unsetenv("KEA_LOGGER_DESTINATION"));
43+
}
44+
3945
isc::log::initLogger();
4046
}
4147
~LoggerTest() {
4248
LoggerManager::reset();
49+
50+
// Restore KEA_LOGGER_DESTINATION value.
51+
if (kld_value_ != 0) {
52+
static_cast<void>(setenv("KEA_LOGGER_DESTINATION", kld_value_, 1));
53+
}
4354
}
55+
56+
// The KEA_LOGGER_DESTINATION environment variable value.
57+
char* kld_value_;
4458
};
4559

4660
// Check version

0 commit comments

Comments
 (0)