diff mbox series

mpfr: add ptest support

Message ID 20261019130535.123457-1-pratik.farkase@est.tech
State New
Headers show
Series mpfr: add ptest support | expand

Commit Message

Pratik Farkase Oct. 19, 2026, 1:05 p.m. UTC
Build mpfr's upstream 'make check' programs and run them under ptest.
The tests read their .dat input files relative to the compiled-in SRCDIR,
so build them with srcdir=. and install the data files alongside the
binaries, which run-ptest executes from the tests directory.

Tested on qemux86-64 with ptest-runner: 195 tests, all pass.

Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 meta/recipes-support/mpfr/mpfr/run-ptest      | 20 +++++++++++++++++++
 meta/recipes-support/mpfr/mpfr_4.2.2.bb       | 19 ++++++++++++++++--
 3 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100755 meta/recipes-support/mpfr/mpfr/run-ptest
diff mbox series

Patch

diff --git a/meta/conf/distro/include/ptest-packagelists.inc b/meta/conf/distro/include/ptest-packagelists.inc
index 518962cbaa..a77cf7f5be 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -66,6 +66,7 @@  PTESTS_FAST = "\
     lua \
     lzo \
     m4 \
+    mpfr \
     nettle \
     npth \
     opkg \
diff --git a/meta/recipes-support/mpfr/mpfr/run-ptest b/meta/recipes-support/mpfr/mpfr/run-ptest
new file mode 100755
index 0000000000..ddc2e1845f
--- /dev/null
+++ b/meta/recipes-support/mpfr/mpfr/run-ptest
@@ -0,0 +1,20 @@ 
+#!/bin/sh
+
+cd "$(dirname "$0")/tests" || exit 1
+
+for t in t*; do
+    # Only the executable test programs, not data files or libraries.
+    [ -f "$t" ] && [ -x "$t" ] || continue
+    case "$t" in
+        *.la|*.sh) continue ;;
+    esac
+
+    ./"$t"
+    rc=$?
+
+    case "$rc" in
+        0)  echo "PASS: $t" ;;
+        77) echo "SKIP: $t" ;;
+        *)  echo "FAIL: $t" ;;
+    esac
+done
diff --git a/meta/recipes-support/mpfr/mpfr_4.2.2.bb b/meta/recipes-support/mpfr/mpfr_4.2.2.bb
index 4d1747c3fd..6b48940171 100644
--- a/meta/recipes-support/mpfr/mpfr_4.2.2.bb
+++ b/meta/recipes-support/mpfr/mpfr_4.2.2.bb
@@ -4,7 +4,7 @@  HOMEPAGE = "https://www.mpfr.org/"
 LICENSE = "LGPL-3.0-or-later"
 SECTION = "devel"
 
-inherit autotools texinfo
+inherit autotools texinfo ptest
 
 LIC_FILES_CHKSUM = "file://COPYING;md5=1ebbd3e34237af26da5dc08a4e440464 \
                     file://COPYING.LESSER;md5=3000208d539ec061b899bce1d9ce9404 \
@@ -13,9 +13,24 @@  CVE_PRODUCT = "gnu_mpfr"
 
 DEPENDS = "gmp"
 
-SRC_URI = "https://www.mpfr.org/mpfr-${PV}/mpfr-${PV}.tar.xz"
+SRC_URI = "https://www.mpfr.org/mpfr-${PV}/mpfr-${PV}.tar.xz \
+           file://run-ptest \
+           "
 SRC_URI[sha256sum] = "b67ba0383ef7e8a8563734e2e889ef5ec3c3b898a01d00fa0a6869ad81c6ce01"
 
 UPSTREAM_CHECK_URI = "http://www.mpfr.org/mpfr-current/"
 
+do_compile_ptest() {
+    oe_runmake -C ${B}/tests check TESTS= srcdir=.
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+    find ${B}/tests -maxdepth 1 -type f -executable ! -name "*.la" | while read -r t; do
+        ${B}/libtool --mode=install install -m 0755 "$t" ${D}${PTEST_PATH}/tests/
+    done
+    # Data files consumed by tfpif, tinp_str and tmul.
+    install -m 0644 ${S}/tests/*.dat ${D}${PTEST_PATH}/tests/
+}
+
 BBCLASSEXTEND = "native nativesdk"