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

Commit 7c9a327

Browse files
committed
fixup! Add a test against musl libm
1 parent 9af3e68 commit 7c9a327

File tree

1 file changed

+5
-30
lines changed

1 file changed

+5
-30
lines changed

crates/libm-test/tests/compare_built_musl.rs

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use std::sync::LazyLock;
1919

2020
use libm_test::gen::CachedInput;
21+
use libm_test::musl_allowed_ulp;
2122
use libm_test::{CheckOutput, GenerateInput, TupleCall};
2223
use musl_math_sys as musl;
2324
use rand::{Rng, SeedableRng};
@@ -40,29 +41,6 @@ const NTESTS: usize = {
4041
ntests
4142
};
4243

43-
/// ULP allowed to differ from musl (note that musl itself may not be accurate).
44-
const ALLOWED_ULP: u32 = 2;
45-
46-
/// Certain functions have different allowed ULP (consider these xfail).
47-
///
48-
/// Currently this includes:
49-
/// - gamma functions that have higher errors
50-
/// - 32-bit functions fall back to a less precise algorithm.
51-
const ULP_OVERRIDES: &[(&str, u32)] = &[
52-
#[cfg(x86_no_sse)]
53-
("asinhf", 6),
54-
("lgamma", 6),
55-
("lgamma_r", 6),
56-
("lgammaf", 6),
57-
("lgammaf_r", 6),
58-
("tanh", 4),
59-
("tgamma", 8),
60-
#[cfg(not(target_pointer_width = "64"))]
61-
("exp10", 4),
62-
#[cfg(not(target_pointer_width = "64"))]
63-
("exp10f", 4),
64-
];
65-
6644
/// Tested inputs.
6745
static TEST_CASES: LazyLock<CachedInput> = LazyLock::new(|| make_test_cases(NTESTS));
6846

@@ -123,17 +101,14 @@ macro_rules! musl_rand_tests {
123101
&TEST_CASES
124102
};
125103

126-
let ulp = match ULP_OVERRIDES.iter().find(|(name, _val)| name == &fname) {
127-
Some((_name, val)) => *val,
128-
None => ALLOWED_ULP,
129-
};
104+
let ulp = musl_allowed_ulp(fname);
130105

131106
let cases = <CachedInput as GenerateInput<$RustArgs>>::get_cases(inputs);
132107
for input in cases {
133-
let mres = input.call(musl::$fn_name as $CFn);
134-
let cres = input.call(libm::$fn_name as $RustFn);
108+
let musl_res = input.call(musl::$fn_name as $CFn);
109+
let crate_res = input.call(libm::$fn_name as $RustFn);
135110

136-
mres.validate(cres, input, ulp);
111+
musl_res.validate(crate_res, input, ulp).unwrap();
137112
}
138113
}
139114
} };

0 commit comments

Comments
 (0)