From 0a62b7dc92978b03150f58db0dd15f98069ad44e Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 10:21:52 +0200 Subject: [PATCH 1/4] make some vec_deque tests less exhaustive in Miri --- .../alloc/src/collections/vec_deque/tests.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/library/alloc/src/collections/vec_deque/tests.rs b/library/alloc/src/collections/vec_deque/tests.rs index e5edfe02a525f..d74f91c752c04 100644 --- a/library/alloc/src/collections/vec_deque/tests.rs +++ b/library/alloc/src/collections/vec_deque/tests.rs @@ -107,7 +107,8 @@ fn test_insert() { let cap = tester.capacity(); // len is the length *after* insertion - for len in 1..cap { + let minlen = if cfg!(miri) { cap - 1 } else { 1 }; // Miri is too slow + for len in minlen..cap { // 0, 1, 2, .., len - 1 let expected = (0..).take(len).collect::>(); for tail_pos in 0..cap { @@ -221,7 +222,8 @@ fn test_remove() { let cap = tester.capacity(); // len is the length *after* removal - for len in 0..cap - 1 { + let minlen = if cfg!(miri) { cap - 2 } else { 0 }; // Miri is too slow + for len in minlen..cap - 1 { // 0, 1, 2, .., len - 1 let expected = (0..).take(len).collect::>(); for tail_pos in 0..cap { @@ -251,7 +253,8 @@ fn test_range() { let mut tester: VecDeque = VecDeque::with_capacity(7); let cap = tester.capacity(); - for len in 0..=cap { + let minlen = if cfg!(miri) { cap - 1 } else { 0 }; // Miri is too slow + for len in minlen..=cap { for tail in 0..=cap { for start in 0..=len { for end in start..=len { @@ -384,7 +387,8 @@ fn test_split_off() { let cap = tester.capacity(); // len is the length *before* splitting - for len in 0..cap { + let minlen = if cfg!(miri) { cap - 1 } else { 0 }; // Miri is too slow + for len in minlen..cap { // index to split at for at in 0..=len { // 0, 1, 2, .., at - 1 (may be empty) @@ -495,8 +499,9 @@ fn test_vec_from_vecdeque() { fn test_clone_from() { let m = vec![1; 8]; let n = vec![2; 12]; - for pfv in 0..8 { - for pfu in 0..8 { + let limit = if cfg!(miri) { 4 } else { 8 }; // Miri is too slow + for pfv in 0..limit { + for pfu in 0..limit { for longer in 0..2 { let (vr, ur) = if longer == 0 { (&m, &n) } else { (&n, &m) }; let mut v = VecDeque::from(vr.clone()); From 7e168a696f23bf3bbb8b23ac83240910a92ff7a3 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 10:32:31 +0200 Subject: [PATCH 2/4] reduce slice::panic_safe test size further in Miri --- library/alloc/tests/slice.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index 75b76bb73ed9e..e5675915300da 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -1722,7 +1722,7 @@ fn panic_safe() { let mut rng = thread_rng(); // Miri is too slow - let lens = if cfg!(miri) { (1..10).chain(20..21) } else { (1..20).chain(70..MAX_LEN) }; + let lens = if cfg!(miri) { (1..10).chain(0..0) } else { (1..20).chain(70..MAX_LEN) }; let moduli: &[u32] = if cfg!(miri) { &[5] } else { &[5, 20, 50] }; for len in lens { From 7468f632ff4bdb34a7422dad66a548d0672c4aa1 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 11:52:53 +0200 Subject: [PATCH 3/4] also reduce some libcore test iteration counts --- library/core/tests/num/flt2dec/random.rs | 2 +- library/core/tests/num/flt2dec/strategy/grisu.rs | 1 + library/core/tests/slice.rs | 4 ++-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/library/core/tests/num/flt2dec/random.rs b/library/core/tests/num/flt2dec/random.rs index 0ebc0881f5223..e5656eb204c73 100644 --- a/library/core/tests/num/flt2dec/random.rs +++ b/library/core/tests/num/flt2dec/random.rs @@ -188,7 +188,7 @@ fn exact_f32_random_equivalence_test() { fn exact_f64_random_equivalence_test() { use core::num::flt2dec::strategy::dragon::format_exact as fallback; // Miri is too slow - let n = if cfg!(miri) { 3 } else { 1_000 }; + let n = if cfg!(miri) { 2 } else { 1_000 }; for k in 1..21 { f64_random_equivalence_test( diff --git a/library/core/tests/num/flt2dec/strategy/grisu.rs b/library/core/tests/num/flt2dec/strategy/grisu.rs index ff8373c64551b..7e6c8add3339d 100644 --- a/library/core/tests/num/flt2dec/strategy/grisu.rs +++ b/library/core/tests/num/flt2dec/strategy/grisu.rs @@ -2,6 +2,7 @@ use super::super::*; use core::num::flt2dec::strategy::grisu::*; #[test] +#[cfg_attr(miri, ignore)] // Miri is too slow fn test_cached_power() { assert_eq!(CACHED_POW10.first().unwrap().1, CACHED_POW10_FIRST_E); assert_eq!(CACHED_POW10.last().unwrap().1, CACHED_POW10_LAST_E); diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 8e240832c13b8..35502031da437 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -1268,14 +1268,14 @@ fn sort_unstable() { use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng}; // Miri is too slow - let large_range = if cfg!(miri) { 0..0 } else { 500..510 }; + let lens = if cfg!(miri) { (2..20).chain(0..0) } else { (2..25).chain(500..510) }; let rounds = if cfg!(miri) { 1 } else { 100 }; let mut v = [0; 600]; let mut tmp = [0; 600]; let mut rng = StdRng::from_entropy(); - for len in (2..25).chain(large_range) { + for len in lens { let v = &mut v[0..len]; let tmp = &mut tmp[0..len]; From ff0c3a920996ae0b09a652c1c894329f7acdc28d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 31 Jul 2020 14:03:42 +0200 Subject: [PATCH 4/4] expand comments --- library/alloc/tests/slice.rs | 2 +- library/core/tests/slice.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/alloc/tests/slice.rs b/library/alloc/tests/slice.rs index e5675915300da..147f7f7d0c729 100644 --- a/library/alloc/tests/slice.rs +++ b/library/alloc/tests/slice.rs @@ -1721,7 +1721,7 @@ fn panic_safe() { let mut rng = thread_rng(); - // Miri is too slow + // Miri is too slow (but still need to `chain` to make the types match) let lens = if cfg!(miri) { (1..10).chain(0..0) } else { (1..20).chain(70..MAX_LEN) }; let moduli: &[u32] = if cfg!(miri) { &[5] } else { &[5, 20, 50] }; diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 35502031da437..4f54ea2bd92e3 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -1267,7 +1267,7 @@ fn sort_unstable() { use core::slice::heapsort; use rand::{rngs::StdRng, seq::SliceRandom, Rng, SeedableRng}; - // Miri is too slow + // Miri is too slow (but still need to `chain` to make the types match) let lens = if cfg!(miri) { (2..20).chain(0..0) } else { (2..25).chain(500..510) }; let rounds = if cfg!(miri) { 1 } else { 100 };