@@ -126,6 +126,7 @@ PTESTS_SLOW = "\
less \
libevent \
libgcrypt \
+ libffi \
libmodule-build-perl \
libpng \
${@bb.utils.contains('DISTRO_FEATURES', 'seccomp', 'libseccomp', '',d)} \
new file mode 100755
@@ -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
@@ -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
+}
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 v3: - Move libffi from PTESTS_FAST to PTESTS_SLOW (349s) runtime 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