18
18
use std:: sync:: LazyLock ;
19
19
20
20
use libm_test:: gen:: CachedInput ;
21
+ use libm_test:: musl_allowed_ulp;
21
22
use libm_test:: { CheckOutput , GenerateInput , TupleCall } ;
22
23
use musl_math_sys as musl;
23
24
use rand:: { Rng , SeedableRng } ;
@@ -40,29 +41,6 @@ const NTESTS: usize = {
40
41
ntests
41
42
} ;
42
43
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
-
66
44
/// Tested inputs.
67
45
static TEST_CASES : LazyLock < CachedInput > = LazyLock :: new ( || make_test_cases ( NTESTS ) ) ;
68
46
@@ -123,17 +101,14 @@ macro_rules! musl_rand_tests {
123
101
& TEST_CASES
124
102
} ;
125
103
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) ;
130
105
131
106
let cases = <CachedInput as GenerateInput <$RustArgs>>:: get_cases( inputs) ;
132
107
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) ;
135
110
136
- mres . validate( cres , input, ulp) ;
111
+ musl_res . validate( crate_res , input, ulp) . unwrap ( ) ;
137
112
}
138
113
}
139
114
} } ;
0 commit comments