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

Commit 68c49a2

Browse files
committed
Test jn and jnf
1 parent f0122d3 commit 68c49a2

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

build.rs

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ mod musl_reference_tests {
2828
// defining a function we want to test.
2929
const IGNORED_FILES: &[&str] = &[
3030
"fenv.rs",
31-
"jn.rs", // passed, but very slow
32-
"jnf.rs", // passed, but very slow
3331
];
3432

3533
struct Function {
@@ -143,15 +141,28 @@ mod musl_reference_tests {
143141
fn generate_random_tests<R: Rng>(functions: &mut [Function], rng: &mut R) {
144142
for function in functions {
145143
for _ in 0..NTESTS {
146-
function.tests.push(generate_test(&function.args, rng));
144+
function.tests.push(generate_test(function, rng));
147145
}
148146
}
149147

150-
fn generate_test<R: Rng>(args: &[Ty], rng: &mut R) -> Test {
151-
let inputs = args.iter().map(|ty| ty.gen_i64(rng)).collect();
152-
// zero output for now since we'll generate it later
148+
fn generate_test<R: Rng>(function: &Function, rng: &mut R) -> Test {
149+
let mut inputs = function
150+
.args
151+
.iter()
152+
.map(|ty| ty.gen_i64(rng))
153+
.collect::<Vec<_>>();
154+
155+
// First argument to this function appears to be a number of
156+
// iterations, so passing in massive random numbers causes it to
157+
// take forever to execute, so make sure we're not running random
158+
// math code until the heat death of the universe.
159+
if function.name == "jn" || function.name == "jnf" {
160+
inputs[0] &= 0xffff;
161+
}
162+
153163
Test {
154164
inputs,
165+
// zero output for now since we'll generate it later
155166
outputs: vec![],
156167
}
157168
}
@@ -165,15 +176,19 @@ mod musl_reference_tests {
165176
return match self {
166177
Ty::F32 => {
167178
if r.gen_range(0, 20) < 1 {
168-
let i = *[f32::NAN, f32::INFINITY, f32::NEG_INFINITY].choose(r).unwrap();
179+
let i = *[f32::NAN, f32::INFINITY, f32::NEG_INFINITY]
180+
.choose(r)
181+
.unwrap();
169182
i.to_bits().into()
170183
} else {
171184
r.gen::<f32>().to_bits().into()
172185
}
173186
}
174187
Ty::F64 => {
175188
if r.gen_range(0, 20) < 1 {
176-
let i = *[f64::NAN, f64::INFINITY, f64::NEG_INFINITY].choose(r).unwrap();
189+
let i = *[f64::NAN, f64::INFINITY, f64::NEG_INFINITY]
190+
.choose(r)
191+
.unwrap();
177192
i.to_bits() as i64
178193
} else {
179194
r.gen::<f64>().to_bits() as i64

0 commit comments

Comments
 (0)