From: Pratik Farkase <pratik.farkase@est.tech>
To: openembedded-core@lists.openembedded.org
Cc: pratik.farkase@ericsson.com, Pratik Farkase <pratik.farkase@est.tech>
Subject: [OE-core][PATCH v2] libffi: add ptest support
Date: Fri, 8 May 2026 12:24:05 +0200 [thread overview]
Message-ID: <20260508102405.16791-1-pratik.farkase@est.tech> (raw)
In-Reply-To: <20260507085242.39646-1-pratik.farkase@est.tech>
Add ptest support for libffi using all upstream test suites: bhaible,
call, closures, complex, go, and threads.
Tests are compiled on-target against the installed libffi. Headers
(including the generated fficonfig.h) and a linker symlink are installed
in the ptest directory to avoid depending on libffi-dev.
Tested on qemux86-64 with ptest-runner: 199 PASS, 0 FAIL, 2 SKIP (349s).
Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
---
Changes in v2 :
- Include all upstream test suites instead of only bhaible
- Install fficonfig.h required by ffitest.h
- Add support for C++ tests (closures/unwindtest*.cc)
- Add -lpthread for threads suite
---
.../distro/include/ptest-packagelists.inc | 1 +
meta/recipes-support/libffi/libffi/run-ptest | 53 +++++++++++++++++++
meta/recipes-support/libffi/libffi_3.5.2.bb | 21 +++++++-
3 files changed, 74 insertions(+), 1 deletion(-)
create mode 100755 meta/recipes-support/libffi/libffi/run-ptest
diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index 50b6a8a41e..79b541a199 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -34,6 +34,7 @@ PTESTS_FAST = "\
libconfig \
libconvert-asn1-perl \
libexif \
+ libffi \
libgpg-error\
libksba \
libmd \
diff --git a/meta/recipes-support/libffi/libffi/run-ptest b/meta/recipes-support/libffi/libffi/run-ptest
new file mode 100755
index 0000000000..9f72becda1
--- /dev/null
+++ b/meta/recipes-support/libffi/libffi/run-ptest
@@ -0,0 +1,53 @@
+#!/bin/sh
+# SPDX-License-Identifier: MIT
+
+PTEST_DIR=$(cd "$(dirname "$0")" && pwd)
+CFLAGS="-O2 -Wall -I$PTEST_DIR/include -L$PTEST_DIR/lib"
+
+# bhaible tests validate by comparing paired output lines
+for t in test-call test-callback; do
+ src="$PTEST_DIR/testsuite/libffi.bhaible/$t.c"
+ if gcc $CFLAGS -o "$PTEST_DIR/$t" "$src" -lffi 2>&1; then
+ "$PTEST_DIR/$t" > "$PTEST_DIR/$t.out" 2>&1
+ if ! LC_ALL=C uniq -u < "$PTEST_DIR/$t.out" | grep -q .; then
+ echo "PASS: libffi.bhaible/$t"
+ else
+ echo "FAIL: libffi.bhaible/$t"
+ cat "$PTEST_DIR/$t.out"
+ fi
+ else
+ echo "SKIP: libffi.bhaible/$t"
+ fi
+ rm -f "$PTEST_DIR/$t" "$PTEST_DIR/$t.out"
+done
+
+# Individual test programs from upstream dejagnu suites
+for suite in libffi.call libffi.closures libffi.complex libffi.go libffi.threads; do
+ dir="$PTEST_DIR/testsuite/$suite"
+ [ -d "$dir" ] || continue
+
+ extra=""
+ [ "$suite" = "libffi.threads" ] && extra="-lpthread"
+
+ for src in "$dir"/*.c "$dir"/*.cc; do
+ [ -f "$src" ] || continue
+ grep -q "dg-do run" "$src" || continue
+
+ name=$(basename "${src%.*}")
+ case "$src" in
+ *.cc) cc="g++";;
+ *) cc="gcc";;
+ esac
+
+ if $cc $CFLAGS -o "$PTEST_DIR/$name" "$src" -lffi $extra 2>&1; then
+ if "$PTEST_DIR/$name" 2>&1; then
+ echo "PASS: $suite/$name"
+ else
+ echo "FAIL: $suite/$name"
+ fi
+ else
+ echo "SKIP: $suite/$name"
+ fi
+ rm -f "$PTEST_DIR/$name"
+ done
+done
diff --git a/meta/recipes-support/libffi/libffi_3.5.2.bb b/meta/recipes-support/libffi/libffi_3.5.2.bb
index d3aa90d429..ec2b8032d3 100644
--- a/meta/recipes-support/libffi/libffi_3.5.2.bb
+++ b/meta/recipes-support/libffi/libffi_3.5.2.bb
@@ -12,6 +12,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=ce4763670c5b7756000561f9af1ab178"
SRC_URI = "${GITHUB_BASE_URI}/download/v${PV}/${BPN}-${PV}.tar.gz \
file://not-win32.patch \
+ file://run-ptest \
"
SRC_URI[sha256sum] = "f3a3082a23b37c293a4fcd1053147b371f2ff91fa7ea1b2a52e335676bac82dc"
@@ -19,7 +20,7 @@ EXTRA_OECONF = "--disable-builddir"
EXTRA_OECONF:class-native += "--with-gcc-arch=generic"
EXTRA_OEMAKE:class-target = "LIBTOOLFLAGS='--tag=CC'"
-inherit autotools texinfo multilib_header github-releases
+inherit autotools texinfo multilib_header github-releases ptest
do_install:append() {
oe_multilib_header ffi.h ffitarget.h
@@ -30,3 +31,21 @@ do_install:append() {
MIPS_INSTRUCTION_SET = "mips"
BBCLASSEXTEND = "native nativesdk"
+
+RDEPENDS:${PN}-ptest += "packagegroup-core-buildessential"
+
+do_install_ptest() {
+ install -d ${D}${PTEST_PATH}/testsuite
+ for suite in libffi.bhaible libffi.call libffi.closures libffi.complex \
+ libffi.go libffi.threads; do
+ cp -r ${S}/testsuite/$suite ${D}${PTEST_PATH}/testsuite/
+ done
+
+ install -d ${D}${PTEST_PATH}/include
+ install -m 0644 ${B}/fficonfig.h ${D}${PTEST_PATH}/include/
+ install -m 0644 ${B}/include/ffi.h ${D}${PTEST_PATH}/include/
+ install -m 0644 ${B}/include/ffitarget.h ${D}${PTEST_PATH}/include/
+
+ install -d ${D}${PTEST_PATH}/lib
+ ln -sf ${libdir}/libffi.so.8 ${D}${PTEST_PATH}/lib/libffi.so
+}
--
2.43.0
next prev parent reply other threads:[~2026-05-08 10:24 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-07 8:52 [OE-core][PATCH v1] libffi: add ptest support Pratik Farkase
2026-05-08 10:24 ` Pratik Farkase [this message]
2026-05-08 11:25 ` [OE-core][PATCH v2] " Marko, Peter
2026-05-08 11:38 ` Pratik Farkase
2026-05-08 11:36 ` [OE-core][PATCH v3] " Pratik Farkase
2026-05-11 6:09 ` Mathieu Dubois-Briand
2026-05-11 9:00 ` Pratik Farkase
2026-05-11 12:25 ` Mathieu Dubois-Briand
2026-05-12 8:30 ` Pratik Farkase
2026-05-12 15:16 ` Mathieu Dubois-Briand
2026-05-13 5:33 ` Mathieu Dubois-Briand
2026-05-13 8:27 ` Pratik Farkase
2026-05-13 11:31 ` Mathieu Dubois-Briand
2026-05-13 13:30 ` Pratik Farkase
2026-05-13 13:27 ` [OE-core][PATCH v4] " Pratik Farkase
2026-05-20 16:02 ` Ross Burton
2026-05-21 8:30 ` Pratik Farkase
2026-05-25 9:30 ` [OE-core][PATCH v5] " Pratik Farkase
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260508102405.16791-1-pratik.farkase@est.tech \
--to=pratik.farkase@est.tech \
--cc=openembedded-core@lists.openembedded.org \
--cc=pratik.farkase@ericsson.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox