@@ -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,62 @@
+#!/bin/sh
+# SPDX-License-Identifier: MIT
+
+PTEST_DIR=$(cd "$(dirname "$0")" && pwd)
+CC="gcc"
+CXX="g++"
+if ! command -v gcc >/dev/null 2>&1; then
+ CC=$(find /usr/bin -name "*-gcc" | head -n 1)
+ CXX=$(find /usr/bin -name "*-g++" | head -n 1)
+fi
+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 $CC $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%.*}")
+
+ # complex_int uses non-standard _Complex int, fails on some arches (riscv64)
+ [ "$name" = "complex_int" ] && continue
+ case "$src" in
+ *.cc) cc="$CXX";;
+ *) cc="$CC";;
+ 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,10 +20,10 @@ 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
+ oe_multilib_header ffi.h ffitarget.h
}
# Doesn't compile in MIPS16e mode due to use of hand-written
@@ -30,3 +31,21 @@ do_install:append() {
MIPS_INSTRUCTION_SET = "mips"
BBCLASSEXTEND = "native nativesdk"
+
+RDEPENDS:${PN}-ptest += "gcc g++ make"
+
+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. 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, 2 SKIP (327s). Signed-off-by: Pratik Farkase <pratik.farkase@est.tech> --- Changes in v4: - Replace packagegroup-core-buildessential with gcc/g++/make to fix multilib symlinks conflict in lib64-core-image-sato-sdk - Detect compiler dynamically in run-ptest (works without symlinks) - Exclude complex_int test (fails on riscv64) 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 | 62 +++++++++++++++++++ meta/recipes-support/libffi/libffi_3.5.2.bb | 23 ++++++- 3 files changed, 84 insertions(+), 2 deletions(-) create mode 100755 meta/recipes-support/libffi/libffi/run-ptest