]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3785] Better fix
authorFrancis Dupont <fdupont@isc.org>
Mon, 24 Mar 2025 14:08:15 +0000 (15:08 +0100)
committerFrancis Dupont <fdupont@isc.org>
Mon, 24 Mar 2025 14:54:17 +0000 (15:54 +0100)
src/bin/dhcp6/tests/config_parser_unittest.cc
src/lib/log/logger_manager_impl.cc
src/lib/testutils/log_utils.cc
src/lib/testutils/log_utils.h

index 8969422d9687795d75be93bfc55a1bc93e6e4a87..d1fefdbc9c7e6361fc51ca5a7bb3954234838c2a 100644 (file)
@@ -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
index 729f3b16df0b994eb87e5f2289679d23b16dc204..42a1a1771de9473889437e3742fd92eaa6647c8d 100644 (file)
@@ -182,7 +182,6 @@ LoggerManagerImpl::createFileAppender(log4cplus::Logger& logger,
                                lexical_cast<string>(opt.maxver));
         properties.setProperty("ImmediateFlush", opt.flush ? "true" : "false");
         properties.setProperty("UseLockFile", "true");
-        properties.setProperty("ReopenDelay", "0");
         fileapp = log4cplus::SharedAppenderPtr(
             new log4cplus::RollingFileAppender(properties));
     }
index e1607f58e91fd02abe924badb4894340ac42c616..85c54e2d88dbdc1dc4fbd8e2611f31d489ffb95c 100644 (file)
@@ -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());
index 669693352666f0661978876203c19428ef1bec9b..4aeb59d13a6dbb811c3f2378109084eefdc80ff5 100644 (file)
@@ -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.