@@ -34,6 +34,7 @@ PTESTS_FAST = "\
libconfig \
libconvert-asn1-perl \
libexif \
+ libffi \
libgpg-error\
libksba \
libmd \
new file mode 100755
@@ -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
@@ -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
+}
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> --- Changes in v5: - Cross-compile tests at build time instead of on target - Minimal run-ptest that just executes pre-compiled binaries - Moved back to PTESTS_FAST (5s runtime vs 327s previously) 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 | 31 ++++++++++++++ meta/recipes-support/libffi/libffi_3.5.2.bb | 42 ++++++++++++++++++- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100755 meta/recipes-support/libffi/libffi/run-ptest