From 7ade0c89984c251614e7359effbfea6ef013f0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= Date: Wed, 15 Jul 2026 11:54:57 +0200 Subject: gnu: symfpu: Enable the test suite. * gnu/packages/maths.scm (symfpu)[#:phases]: Add 'fix-tests and 'check. [source]{origin}: Add patch required to fix a single test case. [description]: Fix typo. * gnu/packages/patches/symfpu-fix-rounding-test-case.patch: New patch. * gnu/local.mk (dist_patch_DATA): Register it. --- gnu/local.mk | 1 + gnu/packages/maths.scm | 37 ++++++++++++++++++++-- .../patches/symfpu-fix-rounding-test-case.patch | 15 +++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 gnu/packages/patches/symfpu-fix-rounding-test-case.patch diff --git a/gnu/local.mk b/gnu/local.mk index 405a203cc3e..64c215fc31d 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2198,6 +2198,7 @@ dist_patch_DATA = \ %D%/packages/patches/stk-5.0.1-fix-typo.patch \ %D%/packages/patches/strace-readlink-tests.patch \ %D%/packages/patches/sunxi-tools-remove-sys-io.patch \ + %D%/packages/patches/symfpu-fix-rounding-test-case.patch \ %D%/packages/patches/patch-hurd-path-max.patch \ %D%/packages/patches/perl-5.14-autosplit-default-time.patch \ %D%/packages/patches/perl-5.14-module-pluggable-search.patch \ diff --git a/gnu/packages/maths.scm b/gnu/packages/maths.scm index 72a963db701..db6eceabeae 100644 --- a/gnu/packages/maths.scm +++ b/gnu/packages/maths.scm @@ -8397,7 +8397,8 @@ s-expression-based format.") (commit (string-append "symfpu-" version "-dual-license")))) (file-name (git-file-name name version)) (sha256 - (base32 "13a9y0spyi6pggbhjgwi9g2qy822h1zakzhhwvm8qgk5c4njv3c6")))) + (base32 "13a9y0spyi6pggbhjgwi9g2qy822h1zakzhhwvm8qgk5c4njv3c6")) + (patches (search-patches "symfpu-fix-rounding-test-case.patch")))) (build-system copy-build-system) (arguments (list @@ -8407,6 +8408,38 @@ s-expression-based format.") ("utils" "include/symfpu/utils" #:exclude ("Makefile"))) #:phases #~(modify-phases %standard-phases + ;; Make sure that the tests exit with a zero exit status by default. + ;; Generated tests have assert(3) statements which exit with a + ;; non-zero exit status on test failure. + (add-after 'unpack 'fix-tests + (lambda _ + (substitute* "applications/test.cpp" + (("return 1") "return 0")))) + (add-before 'install 'check + (lambda* (#:key tests? #:allow-other-keys) + (when tests? + ;; To ensure the test application builds prior to 'install, + ;; set up a symlink and modify CXXFLAGS to find the headers. + (symlink #$source "symfpu") + (invoke "make" "CXXFLAGS=-I." "test") + + ;; Run tests in their breadth (i.e., --allTests) but on a very + ;; small value range as otherwise the tests run for a long time. + (invoke "./test" + "--allTests" + "--printC" + "--start=0" + "--end=125" + "--verbose") + + ;; Test script generates C code which we then compile & execute. + (for-each + (lambda (file) + (let ((case (string-drop-right file (string-length ".c")))) + (format #t "Running test case ~a~%" case) + (invoke "g++" "-std=gnu++11" "-o" case file) + (invoke (string-append "./" case)))) + (find-files "." "^testC..*\\.c$"))))) (add-before 'install 'build-pkgconfig (lambda* (#:key outputs #:allow-other-keys) (with-output-to-file "symfpu.pc" @@ -8427,7 +8460,7 @@ s-expression-based format.") "Concrete and symbolic implementation of IEEE-754 floating-point numbers") (description "SoftFPU is a C++ library implementing concrete and symbolic -mantics for floating point numbers as defined in the IEEE-764 Standard +mantics for floating point numbers as defined in the IEEE-754 Standard r Floating-Point Arithmetic. It is templated in terms of the t-vectors, propositions, floating-point formats and rounding mode types ed. This allow the same code to be executed as an arbitrary precision diff --git a/gnu/packages/patches/symfpu-fix-rounding-test-case.patch b/gnu/packages/patches/symfpu-fix-rounding-test-case.patch new file mode 100644 index 00000000000..120807653d3 --- /dev/null +++ b/gnu/packages/patches/symfpu-fix-rounding-test-case.patch @@ -0,0 +1,15 @@ +Taken from: https://github.com/martin-cs/symfpu/pull/13 + +diff --git a/applications/test.cpp b/applications/test.cpp +index 2a92a40..4f6b157 100644 +--- a/applications/test.cpp ++++ b/applications/test.cpp +@@ -1186,7 +1186,7 @@ int main (int argc, char **argv) { + {0,0, "min", INST(binaryFunction, min), "fminf(f,g)", "(fp.min f g)"}, + {0,1, "sqrt", INST(unaryRoundedFunction, sqrt), "sqrtf(f)", "(fp.sqrt rm f)"}, + {0,1, "round_to_integral", INST(unaryRoundedFunction, rti), "(fegetround()==FE_TONEAREST) ? rintf(f) : (fegetround()==FE_UPWARD) ? ceilf(f) : (fegetround()==FE_DOWNWARD) ? floorf(f) : truncf(f)", "(fp.roundToIntegral rm f)"}, +- {0,1, "fma", INST(ternaryRoundedFunction, fma), "fmaf(f,g)", "(fp.fma rm f g h)"}, ++ {0,1, "fma", INST(ternaryRoundedFunction, fma), "fmaf(f,g,h)", "(fp.fma rm f g h)"}, + {0,0, "remainder", INST(binaryFunction, rem), "remainderf(f,g)", "(fp.remainder f g)"}, + {0,0, NULL, NULL, NULL, NULL, NULL, NULL} + }; -- cgit v1.2.3