]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
libffi: add ptest support
authorPratik Farkase <pratik.farkase@est.tech>
Mon, 25 May 2026 09:30:29 +0000 (11:30 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 5 Jun 2026 14:50:14 +0000 (15:50 +0100)
Add ptest support for libffi using all upstream test suites: bhaible,
call, closures, complex, go, and threads.

Tests are cross-compiled at build time in do_compile_ptest and the
binaries are installed to the ptest directory. No toolchain is needed
on target.

The complex_int test is excluded as it uses non-standard _Complex int
which is unsupported on some architectures (e.g. riscv64).

Tested on qemux86-64 with ptest-runner: 198 PASS, 0 FAIL (5s).

Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/conf/distro/include/ptest-packagelists.inc
meta/recipes-support/libffi/libffi/run-ptest [new file with mode: 0755]
meta/recipes-support/libffi/libffi_3.5.2.bb

index 7049b52a7770796e452b52eec4734fe26d2b09b3..44d25177f647d0aecc38fbc35a85a41efaceac9b 100644 (file)
@@ -35,6 +35,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 (executable)
index 0000000..f253661
--- /dev/null
@@ -0,0 +1,31 @@
+#!/bin/sh
+# SPDX-License-Identifier: MIT
+
+cd "$(dirname "$0")/tests" || exit 1
+
+for t in *; do
+    [ -x "$t" ] || continue
+
+    suite="${t%%__*}"
+    name="${t#*__}"
+
+    case "$suite" in
+        libffi.bhaible)
+            ./"$t" > "$t.out" 2>&1
+            if ! LC_ALL=C uniq -u < "$t.out" | grep -q .; then
+                echo "PASS: $suite/$name"
+            else
+                echo "FAIL: $suite/$name"
+                cat "$t.out"
+            fi
+            rm -f "$t.out"
+            ;;
+        *)
+            if ./"$t" 2>&1; then
+                echo "PASS: $suite/$name"
+            else
+                echo "FAIL: $suite/$name"
+            fi
+            ;;
+    esac
+done
index d3aa90d4293571b1f5f2eeb980cb6901fd5be57f..987d0f59c96318c39d34d144542c8a896b238fed 100644 (file)
@@ -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,42 @@ do_install:append() {
 MIPS_INSTRUCTION_SET = "mips"
 
 BBCLASSEXTEND = "native nativesdk"
+
+do_compile_ptest() {
+    mkdir -p ${B}/ptest-bins
+    cd ${S}/testsuite
+
+    for suite in libffi.call libffi.closures libffi.complex libffi.go libffi.threads; do
+        [ -d $suite ] || continue
+        extra=""
+        [ "$suite" = "libffi.threads" ] && extra="-lpthread"
+
+        for src in $suite/*.c $suite/*.cc; do
+            [ -f "$src" ] || continue
+            grep -q "dg-do run" "$src" || continue
+            name=$(basename "${src%.*}")
+            [ "$name" = "complex_int" ] && continue
+            case "$src" in
+                *.cc) compiler="${CXX}";;
+                *)    compiler="${CC}";;
+            esac
+            $compiler ${CFLAGS} ${LDFLAGS} \
+                -I${B}/include -I${B} -I${S}/testsuite/libffi.call \
+                -o ${B}/ptest-bins/${suite}__${name} "$src" \
+                -L${B}/.libs -lffi $extra 2>/dev/null || true
+        done
+    done
+
+    for t in test-call test-callback; do
+        ${CC} ${CFLAGS} ${LDFLAGS} -I${B}/include -I${B} \
+            -o ${B}/ptest-bins/libffi.bhaible__${t} \
+            libffi.bhaible/${t}.c -L${B}/.libs -lffi || true
+    done
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+    for t in ${B}/ptest-bins/*; do
+        [ -f "$t" ] && install -m 0755 "$t" ${D}${PTEST_PATH}/tests/
+    done
+}