Skip to content

Commit

Permalink
Basic infinite precision test
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross35 committed Oct 21, 2024
1 parent 85e9f5b commit ded5a3e
Show file tree
Hide file tree
Showing 8 changed files with 417 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ci/docker/aarch64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ FROM ubuntu:24.04
RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates \
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
gcc-aarch64-linux-gnu m4 make libc6-dev-arm64-cross \
qemu-user-static

ENV TOOLCHAIN_PREFIX=aarch64-linux-gnu-
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/i686-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM ubuntu:24.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc-multilib libc6-dev ca-certificates
gcc-multilib m4 make libc6-dev ca-certificates
2 changes: 1 addition & 1 deletion ci/docker/x86_64-unknown-linux-gnu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ FROM ubuntu:24.04

RUN apt-get update && \
apt-get install -y --no-install-recommends \
gcc libc6-dev ca-certificates
gcc m4 make libc6-dev ca-certificates
12 changes: 12 additions & 0 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@ case "$target" in
*thumb*) extra_flags="$extra_flags --exclude musl-math-sys" ;;
esac

# Configure which targets test against MPFR
case "$target" in
# MSVC cannot link MPFR
*windows-msvc*) ;;
# FIXME: MinGW should be able to build MPFR, but setup in CI is nontrivial.
*windows-gnu*) ;;
# Targets that aren't cross compiled work fine
x86_64*) extra_flags="$extra_flags --features libm-test/multiprecision-tests" ;;
# i686 works fine, i586 does not
i686*) extra_flags="$extra_flags --features libm-test/multiprecision-tests" ;;
esac

# FIXME: `STATUS_DLL_NOT_FOUND` testing macros on CI.
# <https://github.com/rust-lang/rust/issues/128944>
case "$target" in
Expand Down
3 changes: 3 additions & 0 deletions crates/libm-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ default = []
# Generate tests which are random inputs and the outputs are calculated with
# musl libc.
musl-bitwise-tests = ["rand"]
multiprecision-tests = ["dep:az", "dep:rug"]

[dependencies]
anyhow = "1.0.90"
az = { version = "1.2.1", optional = true }
libm = { path = "../.." }
libm-macros = { path = "../libm-macros" }
paste = "1.0.15"
rand = "0.8.5"
rand_chacha = "0.3.1"
rug = { version = "1.26.1", optional = true, default-features = false, features = ["float", "std"] }

[target.'cfg(target_family = "wasm")'.dependencies]
# Enable randomness on WASM
Expand Down
18 changes: 18 additions & 0 deletions crates/libm-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
pub mod gen;
#[cfg(feature = "multiprecision-tests")]
pub mod mpfloat;
mod num_traits;
mod test_traits;

Expand All @@ -11,6 +13,8 @@ include!(concat!(env!("OUT_DIR"), "/all_files.rs"));
/// ULP allowed to differ from musl (note that musl itself may not be accurate).
const MUSL_DEFAULT_ULP: u32 = 2;

const MULTIPREC_DEFAULT_ULP: u32 = 1;

/// Certain functions have different allowed ULP (consider these xfail).
///
/// Currently this includes:
Expand All @@ -30,3 +34,17 @@ pub fn musl_allowed_ulp(name: &str) -> u32 {
_ => MUSL_DEFAULT_ULP,
}
}

pub fn multiprec_allowed_ulp(name: &str) -> u32 {
match name {
"asinh" | "asinhf" => 2,
"atanh" | "atanhf" => 2,
"exp10" | "exp10f" => 3,
"j0" | "j0f" => 2,
"lgamma" | "lgammaf" | "lgamma_r" | "lgammaf_r" => 2,
"sinh" | "sinhf" => 2,
"tanh" | "tanhf" => 2,
"tgamma" => 6,
_ => MULTIPREC_DEFAULT_ULP,
}
}
Loading

0 comments on commit ded5a3e

Please sign in to comment.