Skip to content

Commit

Permalink
[#3487] Added unsetenv code in fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
fxdupont committed Aug 22, 2024
1 parent 8c80464 commit 32d17a2
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/lib/log/tests/logger_unittest.cc
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -20,6 +20,7 @@
#include <log/output_option.h>
#include <log/tests/log_test_messages.h>

#include <cstdlib>
#include <iostream>
#include <string>

Expand All @@ -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
Expand Down

0 comments on commit 32d17a2

Please sign in to comment.