gmp: add ptest support
PATCH 1/1 gmp: add ptest support
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).
--- meta/conf/distro/include/ptest-packagelists.inc | 1 + meta/recipes-support/gmp/gmp.inc | 2 +- meta/recipes-support/gmp/gmp/run-ptest | 15 +++++++++++++++ meta/recipes-support/gmp/gmp_6.3.0.bb | 17 +++++++++++++++++ 4 files changed, 34 insertions(+), 1 deletion(-) create mode 100755 meta/recipes-support/gmp/gmp/run-ptest
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -24,6 +24,7 @@ PTESTS_FAST = "\ gdbm \ gdk-pixbuf \ glib-networking \ + gmp \ gzip \ icu \ json-c \
meta/recipes-support/gmp/gmp.inc +1 -1
@@ -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"
meta/recipes-support/gmp/gmp/run-ptest new file +15 -0
@@ -0,0 +1,15 @@ +#!/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|^\./||') + if ./"$test"; then + echo "PASS: $testname" + else + echo "FAIL: $testname" + fi + done +done
meta/recipes-support/gmp/gmp_6.3.0.bb +17 -0
@@ -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 +}
Signature · 1 line
2.34.1
Quoted 11 lines · Pratik Farkase
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 <[email protected]>---
Hi Pratik,
Thanks for your patch.
I believe we are seeing some failing tests on the autobuilder:
AssertionError:
Failed ptests:
{'gmp': ['mpn/t-addaddmul']}
https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/1552
https://autobuilder.yoctoproject.org/valkyrie/#/builders/109/builds/367
https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/1553
Ptest logs can be found here:
https://valkyrie.yocto.io/pub/non-release/20260506-64/testresults/qemuriscv64-ptest/core-image-ptest-gmp/
https://valkyrie.yocto.io/pub/non-release/20260506-64/testresults/qemuarm64-musl-ptest/core-image-ptest-gmp/
Can you have a look at the issue?
Thanks,
Mathieu
Signature · 3 lines
Mathieu Dubois-Briand, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Hi Mathieu,
Thanks for catching this. I see that one test "mpn/t-addaddmul" is failing only for qemuarm64 and qemuriscv64 platforms. The issue is that mpn/t-addaddmul exits with code 77 on architectures without a native mpn_addaddmul_1msb0
implementation (riscv64, arm64). Exit 77 is the autotools convention for
SKIP, but the run-ptest script was treating any non-zero exit as FAIL. I appreciate you catching this as my test setup has qemux86-64 as the MACHINE so i did not see this test failing there.
I have sent a v2 with the fix to handle exit 77 as SKIP.
Best Regards,
Pratik
________________________________________
From: Mathieu Dubois-Briand <[email protected]>
Sent: Wednesday, May 6, 2026 6:19 PM
To: Pratik Farkase; [email protected]
Cc: [email protected]
Subject: Re: [OE-core][PATCH v1] gmp: add ptest support
Quoted 11 lines · Pratik Farkase
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 <[email protected]>---
Hi Pratik,
Thanks for your patch.
I believe we are seeing some failing tests on the autobuilder:
AssertionError:
Failed ptests:
{'gmp': ['mpn/t-addaddmul']}
https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/1552
https://autobuilder.yoctoproject.org/valkyrie/#/builders/109/builds/367
https://autobuilder.yoctoproject.org/valkyrie/#/builders/56/builds/1553
Ptest logs can be found here:
https://valkyrie.yocto.io/pub/non-release/20260506-64/testresults/qemuriscv64-ptest/core-image-ptest-gmp/
https://valkyrie.yocto.io/pub/non-release/20260506-64/testresults/qemuarm64-musl-ptest/core-image-ptest-gmp/
Can you have a look at the issue?
Thanks,
Mathieu
--
Mathieu Dubois-Briand, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
PATCH v2 1/1 gmp: add ptest support
In reply to Pratik FarkaseAdd 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).
---
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
meta/conf/distro/include/ptest-packagelists.inc +1 -0
@@ -24,6 +24,7 @@ PTESTS_FAST = "\ gdbm \ gdk-pixbuf \ glib-networking \ + gmp \ gzip \ icu \ json-c \
meta/recipes-support/gmp/gmp.inc +1 -1
@@ -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"
meta/recipes-support/gmp/gmp/run-ptest new file +19 -0
@@ -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
meta/recipes-support/gmp/gmp_6.3.0.bb +17 -0
@@ -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 +}
Signature · 1 line
2.43.0
meta/recipes-support/gmp/gmp/run-ptest line 3
Quoted 5 lines · Pratik Farkase via lists.openembedded.org
+++ b/meta/recipes-support/gmp/gmp/run-ptest
meta/recipes-support/gmp/gmp/run-ptest new file +3
-0@@ -0,0 +1,19 @@ +#!/bin/sh + +cd "$(dirname "$0")/tests" || exit 1
Overly defensive, just fail
meta/recipes-support/gmp/gmp/run-ptest line 9
Quoted 5 lines
meta/recipes-support/gmp/gmp/run-ptest new file +5
-0+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"
You could just do a find of tests and let it recurse instead of having to know (and keep in sync) the list of directories?
ie instead of iterating the directories and then the files, just do "for test in $(find . -type f -executable|sort) …” inside tests/
meta/recipes-support/gmp/gmp_6.3.0.bb SSTATE_SCAN_FILES += "gmp.h" · line 66
Quoted 7 lines
meta/recipes-support/gmp/gmp_6.3.0.bb +7
-0+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
Could this just be a makefile-getvar to get the check_PROGRAMS value?
Ross