Skip to contentSkip to conversation

icu: Add ptest support

PATCH Superseded Daisuke Yamane 2 participants 4 messages Jul 4, 2025 – Jul 5, 2025

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 icu: Add ptest support

Add following patches.
- 0001-test-Add-support-ptest.patch
- Some default paths in test code are invalid at runtime and cause
- test failures. So add a patch to adjust path to test data for ptest
- environment.
- 0001-ICU-23120-Mask-UnicodeStringTest-TestLargeMemory-on-.patch
- Since ICU-77.1, a test case (TestLargeMemory) that fails to build
- in a 32-bit environment. So add a patch to skip this test case.
- This bug has been reported to upstream. See https://unicode-org.atlassian.net/browse/ICU-23120.
Install icu test-suite to run it as a ptest.
Add icu-ptest to PTERSTS_SLOW because it takes more than 30s to complete
on qemuarm64.

root@qemuarm64:~# ptest-runner icu
START: ptest-runner
2025-07-02T17:48
BEGIN: /usr/lib/icu/ptest
___(snip)___
[All tests passed successfully...]
Elapsed Time: 00:01:10.345
PASS: cintltst
----------------------------------------
ALL TESTS SUMMARY:
All tests OK:  intltest iotest cintltst
DURATION: 371
END: /usr/lib/icu/ptest
2025-07-03T18:44
STOP: ptest-runner
TOTAL: 1 FAIL: 0
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 ...nicodeStringTest-TestLargeMemory-on-.patch | 28 +++++++
 .../icu/icu/0001-test-Add-support-ptest.patch | 84 +++++++++++++++++++
 meta/recipes-support/icu/icu/run-ptest        | 40 +++++++++
 meta/recipes-support/icu/icu_77-1.bb          | 26 ++++++
 5 files changed, 179 insertions(+)
 create mode 100644 meta/recipes-support/icu/icu/0001-ICU-23120-Mask-UnicodeStringTest-TestLargeMemory-on-.patch
 create mode 100644 meta/recipes-support/icu/icu/0001-test-Add-support-ptest.patch
 create mode 100755 meta/recipes-support/icu/icu/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
index 4253c7b062..ac767b5cd3 100644
@@ -105,6 +105,7 @@ PTESTS_SLOW = "\
     glib-2.0 \
     gnutls \
     gstreamer1.0 \
+    icu \
     less \
     libevent \
     libgcrypt \
meta/recipes-support/icu/icu/0001-ICU-23120-Mask-UnicodeStringTest-TestLargeMemory-on-.patch new file +28 -0
new file mode 100644
index 0000000000..e2e9546679
@@ -0,0 +1,28 @@
+From 4b3e6888c2aaba6465f1bc96f61b17a2513050f3 Mon Sep 17 00:00:00 2001
+From: David Seifert <[email protected]>
+Date: Sat, 21 Jun 2025 12:28:15 +0200
+Subject: [PATCH] ICU-23120 Mask UnicodeStringTest::TestLargeMemory on 32-bit
+ platforms
+
+Upstream-Status: Submitted [https://github.com/unicode-org/icu/pull/3496]
+Signed-off-by: Daisuke Yamane <[email protected]>
+---
+ test/intltest/ustrtest.cpp | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/test/intltest/ustrtest.cpp b/test/intltest/ustrtest.cpp
+index 56976b3e3d2..26225f5b5b5 100644
+--- a/test/intltest/ustrtest.cpp
++++ b/test/intltest/ustrtest.cpp
+@@ -2353,7 +2353,7 @@ void UnicodeStringTest::TestUnicodeStringInsertAppendToSelf() {
+ }
+ 
+ void UnicodeStringTest::TestLargeMemory() {
+-#if U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED
++#if (U_PLATFORM_IS_LINUX_BASED || U_PLATFORM_IS_DARWIN_BASED) && (UINTPTR_MAX == 0xFFFFFFFFFFFFFFFF)
+     if(quick) { return; }
+     IcuTestErrorCode status(*this, "TestLargeMemory");
+     constexpr uint32_t len = 2147483643;
+-- 
+2.43.0
+
meta/recipes-support/icu/icu/0001-test-Add-support-ptest.patch new file +84 -0

84 lines not on this page · raw message

meta/recipes-support/icu/icu/run-ptest new file +40 -0
new file mode 100755
index 0000000000..9a428cf205
@@ -0,0 +1,40 @@
+#!/bin/sh
+
+TESTS="intltest iotest cintltst"
+TMP="$(mktemp -d)"
+STATUS_R="${TMP}/status.$$"
+TOPDIR=$(dirname "$(realpath $0)")
+for t in ${TESTS}; do
+	cd ${TOPDIR}/test/$t
+	./$t -E${STATUS_R}.$t || (echo "FAIL: $t"; touch ${STATUS_R}.$t; cp ${STATUS_R}.$t ${STATUS_R}.$t.FAIL)
+	[ ! -f ${STATUS_R}.$t.FAIL ] && touch ${STATUS_R}.$t.PASS && echo "PASS: $t"
+	echo "----------------------------------------"
+	if [ -s "${STATUS_R}.$t.FAIL" ];then
+		echo "-------------"
+		echo "| ***     FAILING TEST SUMMARY FOR:              $t"
+		cat ${STATUS_R}.$t.FAIL
+		echo "| *** END FAILING TEST SUMMARY FOR:              $t"
+	fi
+done
+
+goods=""
+bads=""
+for t in ${TESTS}; do
+	if [ -f "${STATUS_R}.$t.FAIL" ];then
+		bads="${bads} $t"
+	elif [ -f "${STATUS_R}.$t.PASS" ];then
+		goods="${goods} $t"
+	else
+		echo "*** subtest did not complete - $t"
+		bads="${bads} $t"
+	fi
+done
+echo "ALL TESTS SUMMARY:"
+if [ ! "x${bads}" = "x" ];then
+	echo "ok: ${goods}"
+	echo "===== ERRS: ${bads}"
+	exit 1
+else
+	echo "All tests OK: ${goods}"
+fi
+rm -rf ${TMP}
meta/recipes-support/icu/icu_77-1.bb +26 -0
index e655b18ad2..6bd3c5d89b 100644
@@ -119,6 +119,9 @@ SRC_URI = "${BASE_SRC_URI};name=code \
            ${DATA_SRC_URI};name=data \
            file://filter.json \
            file://0001-icu-Added-armeb-support.patch \
+           file://0001-ICU-23120-Mask-UnicodeStringTest-TestLargeMemory-on-.patch \
+           file://0001-test-Add-support-ptest.patch \
+           file://run-ptest \
            "
 
 SRC_URI:append:class-target = "\
@@ -160,3 +163,26 @@ do_make_icudata() {
 }
 
 addtask make_icudata before do_configure after do_patch do_prepare_recipe_sysroot
+
+inherit ptest
+RDEPENDS:${PN}-ptest += "bash"
+
+do_compile_ptest() {
+    oe_runmake -C test everything PTEST_PATH=${PTEST_PATH}
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/test
+    install -d ${D}${PTEST_PATH}/data
+    cp -r ${S}/test/testdata ${D}/${PTEST_PATH}/test
+    cp -r ${S}/data/unidata ${D}/${PTEST_PATH}/data/
+    cp -r ${S}/data/sprep ${D}/${PTEST_PATH}/data/
+    cp -r ${S}/../testdata ${D}/${PTEST_PATH}/
+    cp -r ${B}/test/testdata/out ${D}/${PTEST_PATH}/test/testdata
+
+    list="intltest iotest cintltst"
+    for i in $list; do
+        install -d ${D}${PTEST_PATH}/test/${i}/
+        install -m 755 ${B}/test/${i}/${i} ${D}/${PTEST_PATH}/test/${i}/
+    done
+}
Signature · 1 line
2.43.0
#1 lore raw
Quoted 2 lines · Daisuke Yamane via lists.openembedded.org

Add icu-ptest to PTERSTS_SLOW because it takes more than 30s to complete on qemuarm64.

Was this on an arm64 host with kvm enabled in via runqemu option? Otherwise the measurement isn't correct, as it goes through software emulation and is a lot slower than the actual CI execution.

If your host is x86_64, then you need to build for qemux86_64, and run that with kvm.

Quoted 29 lines
meta/recipes-support/icu/icu/run-ptest new file +29 -0
+#!/bin/sh
+
+TESTS="intltest iotest cintltst"
+TMP="$(mktemp -d)"
+STATUS_R="${TMP}/status.$$"
+TOPDIR=$(dirname "$(realpath $0)")
+for t in ${TESTS}; do
+       cd ${TOPDIR}/test/$t
+       ./$t -E${STATUS_R}.$t || (echo "FAIL: $t"; touch ${STATUS_R}.$t; cp ${STATUS_R}.$t ${STATUS_R}.$t.FAIL)
+       [ ! -f ${STATUS_R}.$t.FAIL ] && touch ${STATUS_R}.$t.PASS && echo "PASS: $t"
+       echo "----------------------------------------"
+       if [ -s "${STATUS_R}.$t.FAIL" ];then
+               echo "-------------"
+               echo "| ***     FAILING TEST SUMMARY FOR:              $t"
+               cat ${STATUS_R}.$t.FAIL
+               echo "| *** END FAILING TEST SUMMARY FOR:              $t"
+       fi
+done
+
+goods=""
+bads=""
+for t in ${TESTS}; do
+       if [ -f "${STATUS_R}.$t.FAIL" ];then
+               bads="${bads} $t"
+       elif [ -f "${STATUS_R}.$t.PASS" ];then
+               goods="${goods} $t"
+       else
+               echo "*** subtest did not complete - $t"
+               bads="${bads} $t"

meta/recipes-support/icu/icu/run-ptest line 39

Quoted 10 lines
meta/recipes-support/icu/icu/run-ptest new file +10 -0
+       fi
+done
+echo "ALL TESTS SUMMARY:"
+if [ ! "x${bads}" = "x" ];then
+       echo "ok: ${goods}"
+       echo "===== ERRS: ${bads}"
+       exit 1
+else
+       echo "All tests OK: ${goods}"
+fi

This is a direct copy-paste of the icu Makefile:
https://github.com/unicode-org/icu/blob/main/icu4c/source/test/Makefile.in

I don't think it's necessary to make it this complicated (and potentially have to keep it in sync with the Makefile), we can perhaps just run the tests, and see what they print; if PASS/FAIL isn't there, then the script can add that.

Quoted 5 lines
meta/recipes-support/icu/icu_77-1.bb +5 -0
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/test
+    install -d ${D}${PTEST_PATH}/data
+    cp -r ${S}/test/testdata ${D}/${PTEST_PATH}/test
+    cp -r ${S}/data/unidata ${D}/${PTEST_PATH}/data/

meta/recipes-support/icu/icu_77-1.bb do_make_icudata() { · line 188

Quoted 10 lines
meta/recipes-support/icu/icu_77-1.bb +10 -0
+    cp -r ${S}/data/sprep ${D}/${PTEST_PATH}/data/
+    cp -r ${S}/../testdata ${D}/${PTEST_PATH}/
+    cp -r ${B}/test/testdata/out ${D}/${PTEST_PATH}/test/testdata
+
+    list="intltest iotest cintltst"
+    for i in $list; do
+        install -d ${D}${PTEST_PATH}/test/${i}/
+        install -m 755 ${B}/test/${i}/${i} ${D}/${PTEST_PATH}/test/${i}/
+    done
+}

The same Makefile linked above has a rule for installing the tests. Can that be used instead? Maybe it also installs some way to run them?

In any case, do not hardcode the particular test names; that changes over time, and it's better to have some dynamic way of installing (e.g. by file name pattern or executable bit).

Alex

#2 lore raw

2025年7月4日(金) 17:49 Alexander Kanavin <[email protected]>:

Quoted 7 lines
Quoted 2 lines · Daisuke Yamane via lists.openembedded.org

Add icu-ptest to PTERSTS_SLOW because it takes more than 30s to complete on qemuarm64.

Quoted 6 lines

Was this on an arm64 host with kvm enabled in via runqemu option? Otherwise the measurement isn't correct, as it goes through software emulation and is a lot slower than the actual CI execution.

If your host is x86_64, then you need to build for qemux86_64, and run that with kvm.

Enabling KVM on qemux86_64 and running ptest, the intltest test was intrrupted due to oom-killer.
(I'm not sure why, but it seems that qemuarm64 didn't trigger the oom-killer.)

|          TestBug22584 {
| [   30.217322] intltest invoked oom-killer:
| gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0,
| oom_score_adj=0
| [   30.217717] CPU: 2 UID: 0 PID: 278 Comm: intltest Not tainted
| 6.12.31-yocto-standard #1
| [   30.217719] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009),
| BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014

Increasing the memory for qemux86_64 from 256MB to 512MB caused the test to pass in 28 seconds.
In this case, should I add icu to PTESTS_PROBLEMS, or add a patch to skip tests that fail and add icu to PTEST_FAST?

Quoted 44 lines
Quoted 30 lines
meta/recipes-support/icu/icu/run-ptest new file +29 -0
+#!/bin/sh
+
+TESTS="intltest iotest cintltst"
+TMP="$(mktemp -d)"
+STATUS_R="${TMP}/status.$$"
+TOPDIR=$(dirname "$(realpath $0)")
+for t in ${TESTS}; do
+       cd ${TOPDIR}/test/$t
+       ./$t -E${STATUS_R}.$t || (echo "FAIL: $t"; touch ${STATUS_R}.$t; cp ${STATUS_R}.$t ${STATUS_R}.$t.FAIL)
+       [ ! -f ${STATUS_R}.$t.FAIL ] && touch ${STATUS_R}.$t.PASS && echo "PASS: $t"
+       echo "----------------------------------------"
+       if [ -s "${STATUS_R}.$t.FAIL" ];then
+               echo "-------------"
+               echo "| ***     FAILING TEST SUMMARY FOR:              $t"
+               cat ${STATUS_R}.$t.FAIL
+               echo "| *** END FAILING TEST SUMMARY FOR:              $t"
+       fi
+done
+
+goods=""
+bads=""
+for t in ${TESTS}; do
+       if [ -f "${STATUS_R}.$t.FAIL" ];then
+               bads="${bads} $t"
+       elif [ -f "${STATUS_R}.$t.PASS" ];then
+               goods="${goods} $t"
+       else
+               echo "*** subtest did not complete - $t"
+               bads="${bads} $t"

meta/recipes-support/icu/icu/run-ptest line 39

Quoted 10 lines
meta/recipes-support/icu/icu/run-ptest new file +10 -0
+       fi
+done
+echo "ALL TESTS SUMMARY:"
+if [ ! "x${bads}" = "x" ];then
+       echo "ok: ${goods}"
+       echo "===== ERRS: ${bads}"
+       exit 1
+else
+       echo "All tests OK: ${goods}"
+fi

This is a direct copy-paste of the icu Makefile:
https://github.com/unicode-org/icu/blob/main/icu4c/source/test/Makefile.in

Quoted 4 lines

I don't think it's necessary to make it this complicated (and potentially have to keep it in sync with the Makefile), we can perhaps just run the tests, and see what they print; if PASS/FAIL isn't there, then the script can add that.

Got it. In v2, I'll simplify the script so that it just confirms the results.

Quoted 20 lines
Quoted 6 lines
meta/recipes-support/icu/icu_77-1.bb +5 -0
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/test
+    install -d ${D}${PTEST_PATH}/data
+    cp -r ${S}/test/testdata ${D}/${PTEST_PATH}/test
+    cp -r ${S}/data/unidata ${D}/${PTEST_PATH}/data/

meta/recipes-support/icu/icu_77-1.bb do_make_icudata() { · line 188

Quoted 10 lines
meta/recipes-support/icu/icu_77-1.bb +10 -0
+    cp -r ${S}/data/sprep ${D}/${PTEST_PATH}/data/
+    cp -r ${S}/../testdata ${D}/${PTEST_PATH}/
+    cp -r ${B}/test/testdata/out ${D}/${PTEST_PATH}/test/testdata
+
+    list="intltest iotest cintltst"
+    for i in $list; do
+        install -d ${D}${PTEST_PATH}/test/${i}/
+        install -m 755 ${B}/test/${i}/${i} ${D}/${PTEST_PATH}/test/${i}/
+    done
+}

The same Makefile linked above has a rule for installing the tests. Can that be used instead? Maybe it also installs some way to run them?

Quoted 3 lines

In any case, do not hardcode the particular test names; that changes over time, and it's better to have some dynamic way of installing (e.g. by file name pattern or executable bit).

Indeed, there is an install rule in Makefile.in, but since no installation process is actually implemented, it cannot be used.
In v2, I will detect executable binaries in the test directory and install them.

Quoted 2 lines

Alex

#3 lore raw
Quoted 13 lines · Daisuke Yamane

Enabling KVM on qemux86_64 and running ptest, the intltest test was intrrupted due to oom-killer.
(I'm not sure why, but it seems that qemuarm64 didn't trigger the oom-killer.)

|          TestBug22584 {
| [   30.217322] intltest invoked oom-killer:
| gfp_mask=0x140cca(GFP_HIGHUSER_MOVABLE|__GFP_COMP), order=0,
| oom_score_adj=0
| [   30.217717] CPU: 2 UID: 0 PID: 278 Comm: intltest Not tainted
| 6.12.31-yocto-standard #1
| [   30.217719] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009),
| BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
Quoted 4 lines

Increasing the memory for qemux86_64 from 256MB to 512MB caused the test to pass in 28 seconds.
In this case, should I add icu to PTESTS_PROBLEMS, or add a patch to skip tests that fail and add icu to PTEST_FAST?

Neither. The correct way to run ptests is to build core-image-ptest-icu image, and use that with runqemu, rather than add the ptest package to some stock image (which I assume you've done until now). This would also match how autobuilder is going to run ptests, so any issues it would have can be directly reproduced.

As you can see in meta/recipes-core/images/core-image-ptest.bb, ptest images by default have 1G of RAM, and that can be increased further per ptest.

Alex