diff mbox series

icu: Add configure option to enable Automake-style ptest output format

Message ID 20251114114843.2821561-1-jiaying.song.cn@windriver.com
State New
Headers show
Series icu: Add configure option to enable Automake-style ptest output format | expand

Commit Message

Song, Jiaying (CN) Nov. 14, 2025, 11:48 a.m. UTC
From: Jiaying Song <jiaying.song.cn@windriver.com>

Added a new configure option `--enable-ptest-automake-format` to enable Automake-style ptest output format.

Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
---
 ...utput-compatible-with-Automake-forma.patch | 70 +++++++++++++++----
 meta/recipes-support/icu/icu_77-1.bb          |  2 +-
 2 files changed, 59 insertions(+), 13 deletions(-)
diff mbox series

Patch

diff --git a/meta/recipes-support/icu/icu/0001-Make-ICU-ptest-output-compatible-with-Automake-forma.patch b/meta/recipes-support/icu/icu/0001-Make-ICU-ptest-output-compatible-with-Automake-forma.patch
index a3d9b46835..8fbc209097 100644
--- a/meta/recipes-support/icu/icu/0001-Make-ICU-ptest-output-compatible-with-Automake-forma.patch
+++ b/meta/recipes-support/icu/icu/0001-Make-ICU-ptest-output-compatible-with-Automake-forma.patch
@@ -1,49 +1,95 @@ 
-From f56e295e936c6c6d9c7219ef649697891cd11382 Mon Sep 17 00:00:00 2001
+From e92a2b82cbbfa499ba210eca50cb6ca0b5c786a5 Mon Sep 17 00:00:00 2001
 From: Jiaying Song <jiaying.song.cn@windriver.com>
-Date: Mon, 3 Nov 2025 11:34:06 +0800
+Date: Wed, 12 Nov 2025 11:35:43 +0800
 Subject: [PATCH] Make ICU ptest output compatible with Automake format
 
-Change test result format to PASS/FAIL for Automake compatibility
+Change test result format to PASS/FAIL for Automake compatibility, controlled by the --enable-ptest-automake-format option.
 
 Upstream-Status: Submitted [https://github.com/unicode-org/icu/pull/3764]
 
 Signed-off-by: Jiaying Song <jiaying.song.cn@windriver.com>
 ---
- test/intltest/intltest.cpp | 4 ++--
- tools/ctestfw/ctest.c      | 3 ++-
- 2 files changed, 4 insertions(+), 3 deletions(-)
+ configure.ac               | 17 +++++++++++++++++
+ test/intltest/intltest.cpp | 10 +++++++++-
+ tools/ctestfw/ctest.c      |  9 ++++++++-
+ 3 files changed, 34 insertions(+), 2 deletions(-)
 
+diff --git a/configure.ac b/configure.ac
+index da4f170..37872d4 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1165,6 +1165,21 @@ If set, it will REPLACE any automatic list of libraries.],
+ 		*) AC_MSG_ERROR(bad value ${enableval} for --enable-samples) ;;
+ 		esac],
+ 	samples=true)
++
++# Enable Automake-compatible ptest output format (for Yocto/OpenEmbedded)
++AC_ARG_ENABLE([ptest-automake-format],
++    AS_HELP_STRING([--enable-ptest-automake-format],
++                   [Emit ptest output in Automake format (PASS:/FAIL:) for Yocto ptest]),
++    [
++        if test "x$enableval" = "xyes"; then
++            UCONFIG_CPPFLAGS="${UCONFIG_CPPFLAGS} -DU_PTEST_AUTOMAKE_FORMAT=1"
++            AC_MSG_RESULT([enabling Automake ptest format])
++        else
++            AC_MSG_RESULT([disabling Automake ptest format])
++        fi
++    ],
++    [enable_ptest_automake_format=no])
++
+ ICU_CONDITIONAL(SAMPLES, test "$samples" = true)
+ 
+ ICUDATA_CHAR=$U_ENDIAN_CHAR
+@@ -1428,3 +1443,5 @@ then
+ fi
+ 
+ $as_unset _CXX_CXXSUFFIX
++
++
 diff --git a/test/intltest/intltest.cpp b/test/intltest/intltest.cpp
-index 33829b0..07071ea 100644
+index 33829b0..6dfc8cb 100644
 --- a/test/intltest/intltest.cpp
 +++ b/test/intltest/intltest.cpp
-@@ -830,11 +830,11 @@ UBool IntlTest::runTestLoop( char* testname, char* par, char *baseName )
+@@ -830,11 +830,19 @@ UBool IntlTest::runTestLoop( char* testname, char* par, char *baseName )
              saveBaseLoc[0]=0; /* reset path */
              
              if (lastErrorCount == errorCount) {
 -                snprintf( msg, sizeof(msg),  "   } OK:   %s ", name );
++            #ifdef U_PTEST_AUTOMAKE_FORMAT
 +                snprintf(msg, sizeof(msg), "PASS: %s\n   }", name);
++            #else
++                snprintf(msg, sizeof(msg),  "   } OK:   %s ", name );
++            #endif
                  if(!no_time) str_timeDelta(msg+strlen(msg),timeStop-timeStart);
                  lastTestFailed = false;
              }else{
--                snprintf(msg, sizeof(msg), "   } ERRORS (%li) in %s", static_cast<long>(errorCount - lastErrorCount), name);
++            #ifdef U_PTEST_AUTOMAKE_FORMAT
 +                snprintf(msg, sizeof(msg), "FAIL: %s\n   } (ERRORS: %li)", name, static_cast<long>(errorCount - lastErrorCount));
++            #else
+                 snprintf(msg, sizeof(msg), "   } ERRORS (%li) in %s", static_cast<long>(errorCount - lastErrorCount), name);
++            #endif
                  if(!no_time) str_timeDelta(msg+strlen(msg),timeStop-timeStart);
  
                  for(int i=0;i<LL_indentlevel;i++) {
 diff --git a/tools/ctestfw/ctest.c b/tools/ctestfw/ctest.c
-index 7634526..727b164 100644
+index 7634526..1f73650 100644
 --- a/tools/ctestfw/ctest.c
 +++ b/tools/ctestfw/ctest.c
-@@ -413,9 +413,10 @@ static void iterateTestsWithLevel ( const TestNode* root,
+@@ -413,9 +413,16 @@ static void iterateTestsWithLevel ( const TestNode* root,
          ctest_xml_testcase(pathToFunction, pathToFunction, timeSeconds, (myERROR_COUNT!=ERROR_COUNT)?"error":NULL);
  
          if (myERROR_COUNT != ERROR_COUNT) {
 -          log_testinfo_i("} ---[%d ERRORS in %s] ", ERROR_COUNT - myERROR_COUNT, pathToFunction);
-+          log_testinfo_i("\nFAIL: %s\n} ---[ERRORS: %d]", root->name, ERROR_COUNT - myERROR_COUNT);
++        #ifdef U_PTEST_AUTOMAKE_FORMAT
++          log_testinfo_i("\nFAIL: %s\n} ---[ERRORS: %d]", root->name,ERROR_COUNT - myERROR_COUNT);
++        #else
++          log_testinfo_i("} ---[%d ERRORS in %s] ", ERROR_COUNT - myERROR_COUNT,pathToFunction);
++        #endif
            strcpy(ERROR_LOG[ERRONEOUS_FUNCTION_COUNT++], pathToFunction);
          } else {
++        #ifdef U_PTEST_AUTOMAKE_FORMAT
 +          log_testinfo_i("\nPASS: %s\n", root->name);
++        #endif
            if(!ON_LINE) { /* had some output */
              int spaces = FLAG_INDENT-(depth-1);
              log_testinfo_i("} %*s[OK] ", spaces, "---");
diff --git a/meta/recipes-support/icu/icu_77-1.bb b/meta/recipes-support/icu/icu_77-1.bb
index 370c14af81..17fa4a4db2 100644
--- a/meta/recipes-support/icu/icu_77-1.bb
+++ b/meta/recipes-support/icu/icu_77-1.bb
@@ -23,7 +23,7 @@  inherit autotools pkgconfig github-releases
 EXTRA_OECONF = "--with-cross-build=${STAGING_ICU_DIR_NATIVE} --disable-icu-config ac_cv_path_install='install -c'"
 EXTRA_OECONF:class-native = "--disable-icu-config ac_cv_path_install='install -c'"
 EXTRA_OECONF:class-nativesdk = "--with-cross-build=${STAGING_ICU_DIR_NATIVE} --disable-icu-config ac_cv_path_install='install -c'"
-
+EXTRA_OECONF:append:class-target = " --enable-ptest-automake-format"
 EXTRA_OECONF:append:class-target = "${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'be', ' --with-data-packaging=archive', '', d)}"
 TARGET_CXXFLAGS:append = "${@oe.utils.conditional('SITEINFO_ENDIANNESS', 'be', ' -DICU_DATA_DIR=\\""${datadir}/${BPN}/${@icu_install_folder(d)}\\""', '', d)}"