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 <[email protected]> --- 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
-=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#236704): https://lists.openembedded.org/g/openembedded-core/message/236704 Mute This Topic: https://lists.openembedded.org/mt/119211863/21656 Group Owner: [email protected] Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
