130 Commits

Author SHA1 Message Date
Trevor Gross
1073858c72 Add a test against musl libm
Check our functions against `musl-math-sys`. This is similar to the
existing musl tests that go through binary serialization, but works on
more platforms.
2024-10-28 12:59:38 -05:00
Trevor Gross
98647ddc2f Introduce a generic way to control checks for specific cases
Sometimes we want to be able to xfail specific inputs without changing
the checked ULP for all cases or skipping the tests. There are also some
cases where we need to perform extra checks for only specific functions.

Add a trait that provides a hook for providing extra checks or skipping
existing checks on a per-function or per-input basis.
2024-10-28 12:59:38 -05:00
Trevor Gross
593fa8f3cb Add a deterministic random generator
Create a test generator that creates a known number of random inputs and
caches them, such that the same inputs are used for all functions.
2024-10-28 12:59:38 -05:00
Trevor Gross
128e572054 Add a helper for cached test inputs
Add a type that caches values used to implement `GenerateInput` on a
variety of signatures.
2024-10-28 12:59:38 -05:00
Trevor Gross
d45f6f6fad Add traits for testing
These traits give us a more generic way to interface with tuples used
for (1) test input, (2) function arguments, and (3) test input.
2024-10-28 12:59:38 -05:00
Trevor Gross
8be6ef1e0a Add numeric traits
These traits are simplified versions of what we have in
`compiler_builtins` and will be used for tests.
2024-10-28 12:59:38 -05:00
Trevor Gross
05c9691f15 Add a test that for_each_fn correctly lists all functions
Create a new test that checks `for_each_fn` against `ALL_FUNCTIONS`,
i.e. the manually entered function list against the automatically
collected list. If any are missing (e.g. new symbol added), then this
will produce an error.
2024-10-28 12:59:38 -05:00
Trevor Gross
0acb3e2b50 Collect all function names to an array
Use a build script for `libm-test` to enumerate all symbols provided by
`libm` and provide this list in a variable. This will allow us to make
sure no functions are missed anytime they must be manually listed.

Additionally, introduce some helper config options.
2024-10-28 12:59:38 -05:00
Trevor Gross
56deb13bd4 Add a procedural macro for expanding all function signatures
Introduce `libm_test::for_each_function`. which macro takes a callback
macro and invokes it once per function signature. This provides an
easier way of registering various tests and benchmarks without
duplicating the function names and signatures each time.
2024-10-28 12:59:38 -05:00
Trevor Gross
36b52c7d1b Introduce musl-math-sys for bindings to musl math symbols
This crate builds math symbols from a musl checkout and provides a Rust
interface. The intent is that we will be able to compare our
implementations against musl on more than just linux (which are the only
currently the only targets we run `*-musl` targets against for
comparison).

Musl libc can't compile on anything other than Linux; however, the
routines in `src/math` are cross platform enough to build on MacOS and
windows-gnu with only minor adjustments. We take advantage of this and
build only needed files using `cc`.

The build script also performs remapping (via defines) so that e.g.
`cos` gets defined as `musl_cos`. This gives us more certainty that we
are actually testing against the intended symbol; without it, it is easy
to unknowingly link to system libraries or even Rust's `libm` itself and
wind up with an ineffective test. There is also a small procedure to
verify remapping worked correctly by checking symbols in object files.
2024-10-28 12:59:38 -05:00
Trevor Gross
ab0c8e84fb Run cargo fmt with new settings
Apply the changes from the `.rustfmt.toml` file added in the previous
commit.
2024-10-26 20:28:28 -05:00
Trevor Gross
47961340db Add release-plz for automated releases 2024-10-26 17:58:38 -05:00
Trevor Gross
a68516ed6a Rename the musl-bitwise-tests feature to test-musl-serialized
We will have more test features in the near future, and it would be nice
for them all to have a common `test-` prefix. Reverse the existing
feature so this is the case.
2024-10-25 20:57:19 -04:00
Trevor Gross
d3943b1863 Set edition to 2021 for all crates 2024-10-07 00:22:14 -05:00
Trevor Gross
d8c234b959 Do library updates necessary with dependency upgrades 2024-10-05 22:28:38 -05:00
Trevor Gross
cb305df194 Upgrade all dependencies
None of these affect the distributed library.
2024-10-05 22:24:14 -05:00
Trevor Gross
c236051681 Rename the musl-reference-tests feature to musl-bitwise-tests
The plan is to add more test related features that could be considered
"reference tests". Rename the feature here to avoid future confusion.
2024-10-05 21:42:28 -05:00
Trevor Gross
f59dd82cca Move musl-reference-tests to a new libm-test crate
There isn't any reason for this feature to be exposed or part of the
build script. Move it to a separate crate.

We will also want more tests that require some support functions; this
will create a place for them.
2024-10-05 15:54:39 -05:00
Guillaume Gomez
7bc2291ac5 Rename only-soft-floats feature into force-soft-floats 2024-08-07 11:29:47 +02:00
Guillaume Gomez
c1a498db17 Add only-soft-floats feature to prevent using any intrinsics or arch-specific code 2024-08-06 21:23:34 +02:00
Trevor Gross
c7eadedd5f Deny warnings in CI
The main crate already has `#![deny(warnings)]`. Set RUSTFLAGS in CI to
enforce this for other crates in the workspace.
2024-05-06 04:51:41 -05:00
Jules Bertholet
90128a1abb Add benchmarks 2022-11-07 23:43:39 -05:00
Alex Crichton
72b440075e Use macros for more division/array checks (#244)
* Use macros for more division/array checks

This commit moves over more array accesses to the `i!` macro to avoid
bounds checks when debug assertions are disabled. This is surfaced from
rust-lang/compiler-builtins#360 where recent changes in codegen units
has caused some bounds checks to not get elided in release mode. This
also adds a `div!` macro to work around rust-lang/rust#72751.

* Don't test/bench our shim crate

It's not intended to run all our tests
2020-05-29 14:16:51 -05:00
Lokathor
9811b57af2 swap stable to be unstable 2019-09-05 08:32:38 -06:00
gnzlbg
f6e48dd17d Re-export the stable libm feature 2019-07-02 08:33:11 +02:00
gnzlbg
cc1671fc57 Do not enable default features in benchmarks 2019-07-02 08:32:31 +02:00
gnzlbg
53c6687ef5 Move benchmarks into its own crate 2019-07-02 08:22:03 +02:00
Alex Crichton
7cb4a204a2 Rework how testing is done
Use a build script to generate musl reference outputs and then ensure
that everything gets hooked up to actually run reference tests.
2019-05-02 10:48:55 -07:00
Alex Crichton
8560077059 Remove newlib generator
It's broken and we can try to add it back later if necessary
2019-05-02 08:12:23 -07:00
Alex Crichton
ae69253dc7 Move crates to crates folder 2019-05-02 08:12:00 -07:00