This is an automated email from the ASF dual-hosted git repository.

swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git


The following commit(s) were added to refs/heads/master by this push:
     new b63993f8 Prevent supurious 2GB test failure (#723)
b63993f8 is described below

commit b63993f82346e0db103ef7d210d95478e729cfc0
Author: Stephen Webb <[email protected]>
AuthorDate: Thu Jul 23 11:28:13 2026 +1000

    Prevent supurious 2GB test failure (#723)
    
    * Condition large message test on 'LOG4CXX_TEST_ONLY_BUILD'
---
 src/test/cpp/CMakeLists.txt        |  1 +
 src/test/cpp/patternlayouttest.cpp | 15 +++++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/test/cpp/CMakeLists.txt b/src/test/cpp/CMakeLists.txt
index 60835675..a23347b8 100644
--- a/src/test/cpp/CMakeLists.txt
+++ b/src/test/cpp/CMakeLists.txt
@@ -126,6 +126,7 @@ endif()
 if(LOG4CXX_TEST_ONLY_BUILD)
   list(APPEND TEST_COMPILE_DEFINITIONS
       "ENABLE_FAILING_APPENDER_SIMULATION_TESTING=1"
+      "ENABLE_2GB_STRING_TESTING=1"
       "LOGLOG_THRESHOLD=1"
   )
 endif()
diff --git a/src/test/cpp/patternlayouttest.cpp 
b/src/test/cpp/patternlayouttest.cpp
index e505709e..d07d8887 100644
--- a/src/test/cpp/patternlayouttest.cpp
+++ b/src/test/cpp/patternlayouttest.cpp
@@ -35,7 +35,7 @@
 #include <log4cxx/helpers/transcoder.h>
 #include <log4cxx/helpers/pool.h>
 #include <apr_strings.h>
-#include <log4cxx/helpers/pool.h>
+#include <log4cxx/helpers/loglog.h>
 #include "testchar.h"
 #include "logunit.h"
 #include <log4cxx/spi/loggerrepository.h>
@@ -63,7 +63,9 @@ using namespace log4cxx::helpers;
 LOGUNIT_CLASS(PatternLayoutTest)
 {
        LOGUNIT_TEST_SUITE(PatternLayoutTest);
+#if ENABLE_2GB_STRING_TESTING
        LOGUNIT_TEST(test2GbMessageFormatting);
+#endif
        LOGUNIT_TEST(test1);
        LOGUNIT_TEST(test2);
        LOGUNIT_TEST(test3);
@@ -106,7 +108,16 @@ public:
 
        void test2GbMessageFormatting()
        {
-               LogString msg(size_t(INT_MAX) + 1000, 'E');
+               LogString msg;
+               try
+               {
+                       msg.append(size_t(INT_MAX) + 1000, 'E');
+               }
+               catch (const std::exception& ex)
+               {
+                       LOGLOG_DEBUG(logger, ex.what() << " - skipping 2Gb 
message formatting test");
+                       return;
+               }
                msg[msg.length() - 1] = 'X';
                LogString output1;
                PatternLayout l1{ LOG4CXX_STR("%-5p %c{2} - %.30m") };

Reply via email to