liballoc: more compact way to adjust test sizes for Miri

This commit is contained in:
Ralf Jung 2020-04-23 20:05:01 +02:00
parent f1c30519f3
commit eb1de2ff39
6 changed files with 35 additions and 71 deletions

View File

@ -386,10 +386,8 @@ fn test_vec_from_vecdeque() {
assert!(vec.into_iter().eq(vd));
}
#[cfg(not(miri))] // Miri is too slow
let max_pwr = 7;
#[cfg(miri)]
let max_pwr = 5;
// Miri is too slow
let max_pwr = if cfg!(miri) { 5 } else { 7 };
for cap_pwr in 0..max_pwr {
// Make capacity as a (2^x)-1, so that the ring size is 2^x

View File

@ -409,16 +409,14 @@ fn panic_safe() {
}
let mut rng = thread_rng();
const DATASZ: usize = 32;
#[cfg(not(miri))] // Miri is too slow
const NTEST: usize = 10;
#[cfg(miri)]
const NTEST: usize = 1;
// Miri is too slow
let ntest = if cfg!(miri) { 1 } else { 10 };
// don't use 0 in the data -- we want to catch the zeroed-out case.
let data = (1..=DATASZ).collect::<Vec<_>>();
// since it's a fuzzy test, run several tries.
for _ in 0..NTEST {
for _ in 0..ntest {
for i in 1..=DATASZ {
DROP_COUNTER.store(0, Ordering::SeqCst);

View File

@ -28,10 +28,8 @@ const MIN_INSERTS_HEIGHT_2: usize = NODE_CAPACITY + (NODE_CAPACITY + 1) * NODE_C
#[test]
fn test_basic_large() {
let mut map = BTreeMap::new();
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = MIN_INSERTS_HEIGHT_2;
// Miri is too slow
let size = if cfg!(miri) { MIN_INSERTS_HEIGHT_2 } else { 10000 };
assert_eq!(map.len(), 0);
for i in 0..size {
@ -155,10 +153,8 @@ fn test_basic_small() {
#[test]
fn test_iter() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Miri is too slow
let size = if cfg!(miri) { 200 } else { 10000 };
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@ -180,10 +176,8 @@ fn test_iter() {
#[test]
fn test_iter_rev() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Miri is too slow
let size = if cfg!(miri) { 200 } else { 10000 };
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@ -289,10 +283,8 @@ fn test_values_mut() {
#[test]
fn test_iter_mixed() {
#[cfg(not(miri))] // Miri is too slow
let size = 10000;
#[cfg(miri)]
let size = 200;
// Miri is too slow
let size = if cfg!(miri) { 200 } else { 10000 };
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
@ -525,10 +517,8 @@ fn test_range_backwards_4() {
#[test]
fn test_range_1000() {
#[cfg(not(miri))] // Miri is too slow
let size = 1000;
#[cfg(miri)]
let size = MIN_INSERTS_HEIGHT_2 as u32;
// Miri is too slow
let size = if cfg!(miri) { MIN_INSERTS_HEIGHT_2 as u32 } else { 1000 };
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
@ -566,10 +556,8 @@ fn test_range_borrowed_key() {
#[test]
fn test_range() {
let size = 200;
#[cfg(not(miri))] // Miri is too slow
let step = 1;
#[cfg(miri)]
let step = 66;
// Miri is too slow
let step = if cfg!(miri) { 66 } else { 1 };
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
for i in (0..size).step_by(step) {
@ -589,10 +577,8 @@ fn test_range() {
#[test]
fn test_range_mut() {
let size = 200;
#[cfg(not(miri))] // Miri is too slow
let step = 1;
#[cfg(miri)]
let step = 66;
// Miri is too slow
let step = if cfg!(miri) { 66 } else { 1 };
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
for i in (0..size).step_by(step) {
@ -1263,10 +1249,8 @@ fn test_split_off_empty_left() {
#[test]
fn test_split_off_large_random_sorted() {
#[cfg(not(miri))] // Miri is too slow
let mut data = rand_data(1529);
#[cfg(miri)]
let mut data = rand_data(529);
// Miri is too slow
let mut data = if cfg!(miri) { rand_data(529) } else { rand_data(1529) };
// special case with maximum height.
data.sort();

View File

@ -621,10 +621,8 @@ fn test_split_off_empty_left() {
#[test]
fn test_split_off_large_random_sorted() {
#[cfg(not(miri))] // Miri is too slow
let mut data = rand_data(1529);
#[cfg(miri)]
let mut data = rand_data(529);
// Miri is too slow
let mut data = if cfg!(miri) { rand_data(529) } else { rand_data(1529) };
// special case with maximum height.
data.sort();

View File

@ -463,15 +463,9 @@ fn test_sort() {
#[test]
fn test_sort_stability() {
#[cfg(not(miri))] // Miri is too slow
let large_range = 500..510;
#[cfg(not(miri))] // Miri is too slow
let rounds = 10;
#[cfg(miri)]
let large_range = 0..0; // empty range
#[cfg(miri)]
let rounds = 1;
// Miri is too slow
let large_range = if cfg!(miri) { 0..0 } else { 500..510 };
let rounds = if cfg!(miri) { 1 } else { 10 };
for len in (2..25).chain(large_range) {
for _ in 0..rounds {
@ -1727,15 +1721,9 @@ fn panic_safe() {
let mut rng = thread_rng();
#[cfg(not(miri))] // Miri is too slow
let lens = (1..20).chain(70..MAX_LEN);
#[cfg(not(miri))] // Miri is too slow
let moduli = &[5, 20, 50];
#[cfg(miri)]
let lens = 1..10;
#[cfg(miri)]
let moduli = &[5];
// Miri is too slow
let lens = if cfg!(miri) { (1..10).chain(20..21) } else { (1..20).chain(70..MAX_LEN) };
let moduli: &[u32] = if cfg!(miri) { &[5] } else { &[5, 20, 50] };
for len in lens {
for &modulus in moduli {

View File

@ -954,16 +954,14 @@ fn test_append_permutations() {
out
}
#[cfg(not(miri))] // Miri is too slow
const MAX: usize = 5;
#[cfg(miri)]
const MAX: usize = 3;
// Miri is too slow
let max = if cfg!(miri) { 3 } else { 5 };
// Many different permutations of both the `VecDeque` getting appended to
// and the one getting appended are generated to check `append`.
// This ensures all 6 code paths of `append` are tested.
for src_push_back in 0..MAX {
for src_push_front in 0..MAX {
for src_push_back in 0..max {
for src_push_front in 0..max {
// doesn't pop more values than are pushed
for src_pop_back in 0..(src_push_back + src_push_front) {
for src_pop_front in 0..(src_push_back + src_push_front - src_pop_back) {
@ -974,8 +972,8 @@ fn test_append_permutations() {
src_pop_front,
);
for dst_push_back in 0..MAX {
for dst_push_front in 0..MAX {
for dst_push_back in 0..max {
for dst_push_front in 0..max {
for dst_pop_back in 0..(dst_push_back + dst_push_front) {
for dst_pop_front in
0..(dst_push_back + dst_push_front - dst_pop_back)