Skip to contentSkip to conversation

libpcre2: Enable Ptest Support

PATCH In review Shaik Moin 2 participants 4 messages Jan 20 – Feb 8

lore
Share & tools
lore

Shaik Moin

author
#0 lore raw

PATCH 1/2 libpcre2: Enable Ptest Support

Install libpcre2 test suite and run it as ptest.

Add tests for POSIX wrapper (pcre2posix_test), core PCRE2 engine (RunTest), and grep utility (RunGrepTest).

pcre2posix_test: Verifies the POSIX wrapper API
RunTest: Executes the core PCRE2 test suite through pcre2test
RunGrepTest: Checks pcre2grep to ensure its grep‑style matching works as expected with various patterns and input files.

---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../libpcre/libpcre2/run-ptest                | 45 +++++++++++++++++++
 .../recipes-support/libpcre/libpcre2_10.43.bb | 21 ++++++++-
 3 files changed, 65 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-support/libpcre/libpcre2/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
index 9950e46776..b7393a7c65 100644
@@ -31,6 +31,7 @@ PTESTS_FAST = "\
     libgpg-error\
     libnl \
     libpcre \
+    libpcre2 \
     libssh2 \
     libtimedate-perl \
     libtest-fatal-perl \
meta/recipes-support/libpcre/libpcre2/run-ptest new file +45 -0

45 lines not on this page · raw message

meta/recipes-support/libpcre/libpcre2_10.43.bb +19 -2
index f744df88fa..57c4f0d0e7 100644
@@ -10,7 +10,9 @@ SECTION = "devel"
 LICENSE = "BSD-3-Clause"
 LIC_FILES_CHKSUM = "file://LICENCE;md5=321a5eb46acae6b6c1ff2c7a866d836a"
 
-SRC_URI = "${GITHUB_BASE_URI}/download/pcre2-${PV}/pcre2-${PV}.tar.bz2"
+SRC_URI = "${GITHUB_BASE_URI}/download/pcre2-${PV}/pcre2-${PV}.tar.bz2 \
+           file://run-ptest \
+"
 
 GITHUB_BASE_URI = "https://github.com/PCRE2Project/pcre2/releases"
 UPSTREAM_CHECK_REGEX = "releases/tag/pcre2-(?P<pver>\d+(\.\d+)+)$"
@@ -26,7 +28,7 @@ DEPENDS += "bzip2 zlib"
 
 BINCONFIG = "${bindir}/pcre2-config"
 
-inherit autotools binconfig-disabled github-releases
+inherit autotools binconfig-disabled github-releases ptest
 
 EXTRA_OECONF = "\
     --enable-newline-is-lf \
@@ -53,3 +55,18 @@ FILES:pcre2test = "${bindir}/pcre2test"
 FILES:pcre2test-doc = "${mandir}/man1/pcre2test.1"
 
 BBCLASSEXTEND = "native nativesdk"
+
+do_install_ptest() {
+        t=${D}${PTEST_PATH}
+        cp -r ${S}/testdata $t
+        for i in pcre2posix_test pcre2grep pcre2test; \
+          do cp ${B}/.libs/$i $t; \
+        done
+        for i in RunTest RunGrepTest test-driver; \
+          do cp ${S}/$i $t; \
+        done
+        # Skip the fr_FR locale test. If the locale fr_FR is found, it is tested.
+        # If not found, the test is skipped. The test program assumes fr_FR is non-UTF-8
+        # locale so the test fails if fr_FR is UTF-8 locale.
+        sed -i -e 's:do3=yes:do3=no:g' ${D}${PTEST_PATH}/RunTest
+}
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH 2/2 libpcre2: fix RunGrepTest Failure on Busybox systems

The PCRE2 RunGrepTest script uses the Gnu Coreutils form:
head -1

Busybox does not support this shorthand option and reports:
head: invalid option --'1'

which cause the grep tests fail when running ptest on yocto. Replace head -1 with head -n 1 . This makes RunGrepTest work correctly.

---
 .../0001-test-Fix-head-1-Busybox.patch        | 38 +++++++++++++++++++
 .../recipes-support/libpcre/libpcre2_10.43.bb |  1 +
 2 files changed, 39 insertions(+)
 create mode 100644 meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch
meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch new file +38 -0
new file mode 100644
index 0000000000..abfc995cee
@@ -0,0 +1,38 @@
+From 1b2c3d4e5f6a7b8c9d0 Mon Sep 17 00:00:00 2001
+From: Shaik Moin <[email protected]>
+Date: Tue, 18 Nov 2025 10:30:00 +0530
+Subject: [PATCH] tests: Fix head options for BusyBox compatibility
+
+BusyBox does not accept the GNU coreutils shorthand forms:
+  head -1
+ 
+It requires:
+  head -n 1
+ 
+This causes RunGrepTest test data to fail on
+Yocto-based systems that use BusyBox.
+ 
+Replace all occurrences of `head -1` → `head -n 1`
+ 
+This aligns the scripts with POSIX syntax and fixes failing
+grep tests in RunGrepTest (including testtrygrep).
+ 
+Upstream-Status: Inappropriate [oe-specific]
+Signed-off-by: Shaik Moin <[email protected]>
+---
+ 
+diff --git a/RunGrepTest b/RunGrepTest
+index 1c7bbd2..ab4f310 100755
+--- a/RunGrepTest
++++ b/RunGrepTest
+@@ -728,7 +728,7 @@ echo "---------------------------- Test
+ echo "RC=$?" >>testtrygrep
+
+ echo "---------------------------- Test 132 -----------------------------" >>testtrygrep
+-(cd $srcdir; exec 3<testdata/grepinput; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; echo '---'; head -1 <&3; exec 3<&-) >>testtrygrep 2>&1
++(cd $srcdir; exec 3<testdata/grepinput; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; echo '---'; head -n 1 <&3; exec 3<&-) >>testtrygrep 2>&1
+ echo "RC=$?" >>testtrygrep
+
+ echo "---------------------------- Test 133 -----------------------------" >>testtrygrep
+-- 
+2.34.1
meta/recipes-support/libpcre/libpcre2_10.43.bb +1 -0
index 57c4f0d0e7..f250f35584 100644
@@ -12,6 +12,7 @@ LIC_FILES_CHKSUM = "file://LICENCE;md5=321a5eb46acae6b6c1ff2c7a866d836a"
 
 SRC_URI = "${GITHUB_BASE_URI}/download/pcre2-${PV}/pcre2-${PV}.tar.bz2 \
            file://run-ptest \
+           file://0001-test-Fix-head-1-Busybox.patch \
 "
 
 GITHUB_BASE_URI = "https://github.com/PCRE2Project/pcre2/releases"
Signature · 1 line
2.34.1
#3 lore raw
In reply to Shaik Moin
Quoted 8 lines · Shaik Moin via lists.openembedded.org

Install libpcre2 test suite and run it as ptest.

Add tests for POSIX wrapper (pcre2posix_test), core PCRE2 engine (RunTest), and grep utility (RunGrepTest).

pcre2posix_test: Verifies the POSIX wrapper API
RunTest: Executes the core PCRE2 test suite through pcre2test
RunGrepTest: Checks pcre2grep to ensure its grep‑style matching works as expected with various patterns and input files.

Quoted 7 lines
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 .../libpcre/libpcre2/run-ptest                | 45 +++++++++++++++++++
 .../recipes-support/libpcre/libpcre2_10.43.bb | 21 ++++++++-
 3 files changed, 65 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-support/libpcre/libpcre2/run-ptest

Hello,

Thanks for the patches but adding ptest is not usually acceptable under the stable policy[0]. That also applies to your kirkstone patch.

[0]: https://wiki.yoctoproject.org/wiki/Stable_Release_and_LTS#Stable/LTS_Patch_Acceptance_Policies

Regards,

Signature · 2 lines
Yoann Congal
Smile ECS
#2 lore raw

Re: [OE-core][scarthgap][PATCH 2/2] libpcre2: fix RunGrepTest Failure on Busybox systems

In reply to Shaik Moin
Quoted 10 lines · Shaik Moin via lists.openembedded.org

The PCRE2 RunGrepTest script uses the Gnu Coreutils form:
head -1

Busybox does not support this shorthand option and reports:
head: invalid option --'1'

which cause the grep tests fail when running ptest on yocto. Replace head -1 with head -n 1 . This makes RunGrepTest work correctly.

Quoted 6 lines
---
 .../0001-test-Fix-head-1-Busybox.patch        | 38 +++++++++++++++++++
 .../recipes-support/libpcre/libpcre2_10.43.bb |  1 +
 2 files changed, 39 insertions(+)
 create mode 100644 meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch

Hello,

Is this patch also needed on master? If yes, please send it there.

Thanks!

Quoted 12 lines
meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch new file +5 -0
new file mode 100644
index 0000000000..abfc995cee
@@ -0,0 +1,38 @@
+From 1b2c3d4e5f6a7b8c9d0 Mon Sep 17 00:00:00 2001
+From: Shaik Moin <[email protected]>
+Date: Tue, 18 Nov 2025 10:30:00 +0530
+Subject: [PATCH] tests: Fix head options for BusyBox compatibility
+

meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch line 15

Quoted 10 lines
meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch new file +10 -0
+BusyBox does not accept the GNU coreutils shorthand forms:
+  head -1
+ 
+It requires:
+  head -n 1
+ 
+This causes RunGrepTest test data to fail on
+Yocto-based systems that use BusyBox.
+ 
+Replace all occurrences of `head -1` → `head -n 1`

This commit message (and also in 1/2) looks to have an encoding problem.

meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch line 20

Quoted 5 lines
meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch new file +5 -0
+ 
+This aligns the scripts with POSIX syntax and fixes failing
+grep tests in RunGrepTest (including testtrygrep).
+ 
+Upstream-Status: Inappropriate [oe-specific]

I disagree: To me, this patch looks appropriate for upstream.

Quoted 30 lines
meta/recipes-support/libpcre/libpcre2/0001-test-Fix-head-1-Busybox.patch new file +18 -0
+Signed-off-by: Shaik Moin <[email protected]>
+---
+ 
+diff --git a/RunGrepTest b/RunGrepTest
+index 1c7bbd2..ab4f310 100755
+--- a/RunGrepTest
++++ b/RunGrepTest
+@@ -728,7 +728,7 @@ echo "---------------------------- Test
+ echo "RC=$?" >>testtrygrep
+
+ echo "---------------------------- Test 132 -----------------------------" >>testtrygrep
+-(cd $srcdir; exec 3<testdata/grepinput; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; echo '---'; head -1 <&3; exec 3<&-) >>testtrygrep 2>&1
++(cd $srcdir; exec 3<testdata/grepinput; $valgrind $vjs $pcre2grep -m1 -A3 '^match' <&3; echo '---'; head -n 1 <&3; exec 3<&-) >>testtrygrep 2>&1
+ echo "RC=$?" >>testtrygrep
+
+ echo "---------------------------- Test 133 -----------------------------" >>testtrygrep
+-- 
+2.34.1
meta/recipes-support/libpcre/libpcre2_10.43.bb +1 -0
index 57c4f0d0e7..f250f35584 100644
@@ -12,6 +12,7 @@ LIC_FILES_CHKSUM = "file://LICENCE;md5=321a5eb46acae6b6c1ff2c7a866d836a"
 
 SRC_URI = "${GITHUB_BASE_URI}/download/pcre2-${PV}/pcre2-${PV}.tar.bz2 \
            file://run-ptest \
+           file://0001-test-Fix-head-1-Busybox.patch \
 "
 
 GITHUB_BASE_URI = "https://github.com/PCRE2Project/pcre2/releases"
Signature · 2 lines
Yoann Congal
Smile ECS