From: Pratik Farkase Date: Mon, 25 May 2026 09:30:29 +0000 (+0200) Subject: libffi: add ptest support X-Git-Url: http://git.ipfire.org/gitweb/index.cgi?a=commitdiff_plain;h=c753fbfa2bd529ff4e4faf3724c68c2462532124;p=thirdparty%2Fopenembedded%2Fopenembedded-core.git libffi: add ptest support 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 Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc index 7049b52a77..44d25177f6 100644 --- a/meta/conf/distro/include/ptest-packagelists.inc +++ b/meta/conf/distro/include/ptest-packagelists.inc @@ -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 index 0000000000..f25366111d --- /dev/null +++ b/meta/recipes-support/libffi/libffi/run-ptest @@ -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 diff --git a/meta/recipes-support/libffi/libffi_3.5.2.bb b/meta/recipes-support/libffi/libffi_3.5.2.bb index d3aa90d429..987d0f59c9 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,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 +}