diff mbox series

[v2] gmp: add ptest support

Message ID 20260506185128.10489-1-pratik.farkase@est.tech
State Under Review
Headers show
Series [v2] gmp: add ptest support | expand

Commit Message

Pratik Farkase May 6, 2026, 6:51 p.m. UTC
Add ptest support for gmp, running the full upstream unit test suite
(200 tests) covering mpz, mpn, mpf, mpq, rand, misc, and C++ bindings.

Tests are compiled with 'make check TESTS=' to build without executing,
then installed via libtool to the ptest directory preserving the upstream
subdirectory structure.

Tested on qemux86-64 with ptest-runner: 200 PASS, 0 FAIL (268s).

Signed-off-by: Pratik Farkase <pratik.farkase@est.tech>
---
Changes in v2 :
- Handle exit code 77 as SKIP per autotools convention. Fixes
  mpn/t-addaddmul failure on riscv64 and arm64 where
  mpn_addaddmul_1msb0 has no native implementation.
---
 .../distro/include/ptest-packagelists.inc     |  1 +
 meta/recipes-support/gmp/gmp.inc              |  2 +-
 meta/recipes-support/gmp/gmp/run-ptest        | 19 +++++++++++++++++++
 meta/recipes-support/gmp/gmp_6.3.0.bb         | 17 +++++++++++++++++
 4 files changed, 38 insertions(+), 1 deletion(-)
 create mode 100755 meta/recipes-support/gmp/gmp/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 50b6a8a41e..1e6989ae38 100644
--- a/meta/conf/distro/include/ptest-packagelists.inc
+++ b/meta/conf/distro/include/ptest-packagelists.inc
@@ -24,6 +24,7 @@  PTESTS_FAST = "\
     gdbm \
     gdk-pixbuf \
     glib-networking \
+    gmp \
     gzip \
     icu \
     json-c \
diff --git a/meta/recipes-support/gmp/gmp.inc b/meta/recipes-support/gmp/gmp.inc
index 1872226616..106521954d 100644
--- a/meta/recipes-support/gmp/gmp.inc
+++ b/meta/recipes-support/gmp/gmp.inc
@@ -3,7 +3,7 @@  DESCRIPTION = "GMP is a free library for arbitrary precision arithmetic, operati
 HOMEPAGE = "http://gmplib.org/"
 SECTION = "devel"
 
-inherit autotools texinfo multilib_header
+inherit autotools texinfo multilib_header ptest
 
 PACKAGECONFIG ??= ""
 PACKAGECONFIG[readline] = "--with-readline=yes,--with-readline=no,readline"
diff --git a/meta/recipes-support/gmp/gmp/run-ptest b/meta/recipes-support/gmp/gmp/run-ptest
new file mode 100755
index 0000000000..c0fde816c1
--- /dev/null
+++ b/meta/recipes-support/gmp/gmp/run-ptest
@@ -0,0 +1,19 @@ 
+#!/bin/sh
+
+cd "$(dirname "$0")/tests" || exit 1
+
+for d in . mpz mpn mpf mpq rand misc cxx; do
+    [ -d "$d" ] || continue
+    for test in $(find "$d" -maxdepth 1 -type f -executable | sort); do
+        testname=$(echo "$test" | sed 's|^\./||')
+        ./"$test"
+        ret=$?
+        if [ $ret -eq 0 ]; then
+            echo "PASS: $testname"
+        elif [ $ret -eq 77 ]; then
+            echo "SKIP: $testname"
+        else
+            echo "FAIL: $testname"
+        fi
+    done
+done
diff --git a/meta/recipes-support/gmp/gmp_6.3.0.bb b/meta/recipes-support/gmp/gmp_6.3.0.bb
index 8f18bdca1b..ffdd3e4397 100644
--- a/meta/recipes-support/gmp/gmp_6.3.0.bb
+++ b/meta/recipes-support/gmp/gmp_6.3.0.bb
@@ -16,6 +16,7 @@  SRC_URI = "https://gmplib.org/download/${BPN}/${BP}${REVISION}.tar.bz2 \
            file://0001-confiure.ac-Believe-the-cflags-from-environment.patch \
            file://0001-Complete-function-prototype-in-acinclude.m4-for-C23-.patch \
            file://0001-acinclude.m4-Add-parameter-names-in-prototype-for-g.patch \
+           file://run-ptest \
            "
 SRC_URI[sha256sum] = "ac28211a7cfb609bae2e2c8d6058d66c8fe96434f740cf6fe2e47b000d1c20cb"
 
@@ -51,3 +52,19 @@  SSTATE_SCAN_FILES += "gmp.h"
 MIPS_INSTRUCTION_SET = "mips"
 
 BBCLASSEXTEND = "native nativesdk"
+
+do_compile_ptest() {
+    oe_runmake -C ${B}/tests check TESTS=
+}
+
+do_install_ptest() {
+    install -d ${D}${PTEST_PATH}/tests
+
+    for d in . mpz mpn mpf mpq rand misc cxx; do
+        install -d ${D}${PTEST_PATH}/tests/$d
+        find ${B}/tests/$d -maxdepth 1 -type f -executable \
+            ! -name "*.la" | while read -r t; do
+            ${B}/libtool --mode=install install -m 0755 "$t" ${D}${PTEST_PATH}/tests/$d/
+        done
+    done
+}