Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit e386722

Browse files
committed
Basic infinite precision test
1 parent 2ebe17a commit e386722

File tree

8 files changed

+417
-3
lines changed

8 files changed

+417
-3
lines changed

ci/docker/aarch64-unknown-linux-gnu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ FROM ubuntu:24.04
33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends \
55
gcc libc6-dev ca-certificates \
6-
gcc-aarch64-linux-gnu libc6-dev-arm64-cross \
6+
gcc-aarch64-linux-gnu m4 make libc6-dev-arm64-cross \
77
qemu-user-static
88

99
ENV TOOLCHAIN_PREFIX=aarch64-linux-gnu-

ci/docker/i686-unknown-linux-gnu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ FROM ubuntu:24.04
22

33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends \
5-
gcc-multilib libc6-dev ca-certificates
5+
gcc-multilib m4 make libc6-dev ca-certificates

ci/docker/x86_64-unknown-linux-gnu/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ FROM ubuntu:24.04
22

33
RUN apt-get update && \
44
apt-get install -y --no-install-recommends \
5-
gcc libc6-dev ca-certificates
5+
gcc m4 make libc6-dev ca-certificates

ci/run.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ case "$target" in
2424
*thumb*) extra_flags="$extra_flags --exclude musl-math-sys" ;;
2525
esac
2626

27+
# Configure which targets test against MPFR
28+
case "$target" in
29+
# MSVC cannot link MPFR
30+
*windows-msvc*) ;;
31+
# FIXME: MinGW should be able to build MPFR, but setup in CI is nontrivial.
32+
*windows-gnu*) ;;
33+
# Targets that aren't cross compiled work fine
34+
x86_64*) extra_flags="$extra_flags --features libm-test/multiprecision-tests" ;;
35+
# i686 works fine, i586 does not
36+
i686*) extra_flags="$extra_flags --features libm-test/multiprecision-tests" ;;
37+
esac
38+
2739
# FIXME: `STATUS_DLL_NOT_FOUND` testing macros on CI.
2840
# <https://github.com/rust-lang/rust/issues/128944>
2941
case "$target" in

crates/libm-test/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,17 @@ default = []
1010
# Generate tests which are random inputs and the outputs are calculated with
1111
# musl libc.
1212
musl-bitwise-tests = ["rand"]
13+
multiprecision-tests = ["dep:az", "dep:rug"]
1314

1415
[dependencies]
1516
anyhow = "1.0.90"
17+
az = { version = "1.2.1", optional = true }
1618
libm = { path = "../.." }
1719
libm-macros = { path = "../libm-macros" }
1820
paste = "1.0.15"
1921
rand = "0.8.5"
2022
rand_chacha = "0.3.1"
23+
rug = { version = "1.26.1", optional = true, default-features = false, features = ["float", "std"] }
2124

2225
# We can't build musl on MSVC or wasm
2326
[target.'cfg(not(any(target_env = "msvc", target_family = "wasm", target_feature = "thumb-mode")))'.dependencies]

crates/libm-test/src/lib.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
pub mod gen;
2+
#[cfg(feature = "multiprecision-tests")]
3+
pub mod mpfloat;
24
mod num_traits;
35
mod test_traits;
46

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

16+
const MULTIPREC_DEFAULT_ULP: u32 = 1;
17+
1418
/// Certain functions have different allowed ULP (consider these xfail).
1519
///
1620
/// Currently this includes:
@@ -30,3 +34,17 @@ pub fn musl_allowed_ulp(name: &str) -> u32 {
3034
_ => MUSL_DEFAULT_ULP,
3135
}
3236
}
37+
38+
pub fn multiprec_allowed_ulp(name: &str) -> u32 {
39+
match name {
40+
"asinh" | "asinhf" => 2,
41+
"atanh" | "atanhf" => 2,
42+
"exp10" | "exp10f" => 3,
43+
"j0" | "j0f" => 2,
44+
"lgamma" | "lgammaf" | "lgamma_r" | "lgammaf_r" => 2,
45+
"sinh" | "sinhf" => 2,
46+
"tanh" | "tanhf" => 2,
47+
"tgamma" => 6,
48+
_ => MULTIPREC_DEFAULT_ULP,
49+
}
50+
}

0 commit comments

Comments
 (0)