From: Francis Dupont Date: Mon, 24 Mar 2025 14:08:15 +0000 (+0100) Subject: [#3785] Better fix X-Git-Tag: botan2+3~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d53d2ed820af83d570f6e2474c28242ffb7789d1;p=thirdparty%2Fkea.git [#3785] Better fix --- diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc index 8969422d96..d1fefdbc9c 100644 --- a/src/bin/dhcp6/tests/config_parser_unittest.cc +++ b/src/bin/dhcp6/tests/config_parser_unittest.cc @@ -5037,6 +5037,9 @@ TEST_F(Dhcp6ParserTest, allInterfaces) { // All interfaces should be now active. ASSERT_TRUE(test_config.socketOpen("eth0", AF_INET6)); ASSERT_TRUE(test_config.socketOpen("eth1", AF_INET6)); + + // Avoid log4cplus error message. + LogContentTest::reset(); } // This test verifies that it is possible to select subset of interfaces @@ -5074,6 +5077,9 @@ TEST_F(Dhcp6ParserTest, selectedInterfacesAndAddresses) { EXPECT_TRUE(test_config.socketOpen("eth0", AF_INET6)); // The 2001:db8:1::1 address on eth1 was selected. EXPECT_TRUE(test_config.socketOpen("eth1", AF_INET6)); + + // Avoid log4cplus error message. + LogContentTest::reset(); } // This test checks if it is possible to specify relay information diff --git a/src/lib/log/logger_manager_impl.cc b/src/lib/log/logger_manager_impl.cc index 729f3b16df..42a1a1771d 100644 --- a/src/lib/log/logger_manager_impl.cc +++ b/src/lib/log/logger_manager_impl.cc @@ -182,7 +182,6 @@ LoggerManagerImpl::createFileAppender(log4cplus::Logger& logger, lexical_cast(opt.maxver)); properties.setProperty("ImmediateFlush", opt.flush ? "true" : "false"); properties.setProperty("UseLockFile", "true"); - properties.setProperty("ReopenDelay", "0"); fileapp = log4cplus::SharedAppenderPtr( new log4cplus::RollingFileAppender(properties)); } diff --git a/src/lib/testutils/log_utils.cc b/src/lib/testutils/log_utils.cc index e1607f58e9..85c54e2d88 100644 --- a/src/lib/testutils/log_utils.cc +++ b/src/lib/testutils/log_utils.cc @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2025 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 @@ -30,7 +30,6 @@ LogContentTest::LogContentTest() OutputOption option; option.destination = OutputOption::DEST_FILE; option.filename = string(LogContentTest::LOG_FILE); - option.maxsize = 2000000000UL; spec.addOutputOption(option); LoggerManager manager; manager.process(spec); @@ -46,6 +45,19 @@ LogContentTest:: ~LogContentTest() { remFile(); } +void LogContentTest::reset() { + // Reset to default (INFO) with output to stdout. + // To be used to avoid spurious error messages + // "log4cplus:ERROR file is not open: logtest.log". + LoggerSpecification spec(getRootLoggerName()); + OutputOption option; + // Change the default to stdout. + option.stream = OutputOption::STR_STDOUT; + spec.addOutputOption(option); + LoggerManager manager; + manager.process(spec); +} + bool LogContentTest::checkFile() { ifstream file(LOG_FILE); EXPECT_TRUE(file.is_open()); diff --git a/src/lib/testutils/log_utils.h b/src/lib/testutils/log_utils.h index 6696933526..4aeb59d13a 100644 --- a/src/lib/testutils/log_utils.h +++ b/src/lib/testutils/log_utils.h @@ -1,4 +1,4 @@ -// Copyright (C) 2016-2024 Internet Systems Consortium, Inc. ("ISC") +// Copyright (C) 2016-2025 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 @@ -70,6 +70,9 @@ public: /// @brief remove the test log file void remFile(); + /// @brief reset the logger to INFO stdout. + void reset(); + /// @brief Enables or disables verbose mode. /// /// See @ref verbose_ for details.