mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-30 22:12:15 +00:00
liballoc: more compact way to adjust test sizes for Miri
This commit is contained in:
parent
f1c30519f3
commit
eb1de2ff39
@ -386,10 +386,8 @@ fn test_vec_from_vecdeque() {
|
|||||||
assert!(vec.into_iter().eq(vd));
|
assert!(vec.into_iter().eq(vd));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let max_pwr = 7;
|
let max_pwr = if cfg!(miri) { 5 } else { 7 };
|
||||||
#[cfg(miri)]
|
|
||||||
let max_pwr = 5;
|
|
||||||
|
|
||||||
for cap_pwr in 0..max_pwr {
|
for cap_pwr in 0..max_pwr {
|
||||||
// Make capacity as a (2^x)-1, so that the ring size is 2^x
|
// Make capacity as a (2^x)-1, so that the ring size is 2^x
|
||||||
|
@ -409,16 +409,14 @@ fn panic_safe() {
|
|||||||
}
|
}
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
const DATASZ: usize = 32;
|
const DATASZ: usize = 32;
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
const NTEST: usize = 10;
|
let ntest = if cfg!(miri) { 1 } else { 10 };
|
||||||
#[cfg(miri)]
|
|
||||||
const NTEST: usize = 1;
|
|
||||||
|
|
||||||
// don't use 0 in the data -- we want to catch the zeroed-out case.
|
// don't use 0 in the data -- we want to catch the zeroed-out case.
|
||||||
let data = (1..=DATASZ).collect::<Vec<_>>();
|
let data = (1..=DATASZ).collect::<Vec<_>>();
|
||||||
|
|
||||||
// since it's a fuzzy test, run several tries.
|
// since it's a fuzzy test, run several tries.
|
||||||
for _ in 0..NTEST {
|
for _ in 0..ntest {
|
||||||
for i in 1..=DATASZ {
|
for i in 1..=DATASZ {
|
||||||
DROP_COUNTER.store(0, Ordering::SeqCst);
|
DROP_COUNTER.store(0, Ordering::SeqCst);
|
||||||
|
|
||||||
|
@ -28,10 +28,8 @@ const MIN_INSERTS_HEIGHT_2: usize = NODE_CAPACITY + (NODE_CAPACITY + 1) * NODE_C
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_basic_large() {
|
fn test_basic_large() {
|
||||||
let mut map = BTreeMap::new();
|
let mut map = BTreeMap::new();
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let size = 10000;
|
let size = if cfg!(miri) { MIN_INSERTS_HEIGHT_2 } else { 10000 };
|
||||||
#[cfg(miri)]
|
|
||||||
let size = MIN_INSERTS_HEIGHT_2;
|
|
||||||
assert_eq!(map.len(), 0);
|
assert_eq!(map.len(), 0);
|
||||||
|
|
||||||
for i in 0..size {
|
for i in 0..size {
|
||||||
@ -155,10 +153,8 @@ fn test_basic_small() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iter() {
|
fn test_iter() {
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let size = 10000;
|
let size = if cfg!(miri) { 200 } else { 10000 };
|
||||||
#[cfg(miri)]
|
|
||||||
let size = 200;
|
|
||||||
|
|
||||||
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
||||||
|
|
||||||
@ -180,10 +176,8 @@ fn test_iter() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iter_rev() {
|
fn test_iter_rev() {
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let size = 10000;
|
let size = if cfg!(miri) { 200 } else { 10000 };
|
||||||
#[cfg(miri)]
|
|
||||||
let size = 200;
|
|
||||||
|
|
||||||
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
||||||
|
|
||||||
@ -289,10 +283,8 @@ fn test_values_mut() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_iter_mixed() {
|
fn test_iter_mixed() {
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let size = 10000;
|
let size = if cfg!(miri) { 200 } else { 10000 };
|
||||||
#[cfg(miri)]
|
|
||||||
let size = 200;
|
|
||||||
|
|
||||||
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
||||||
|
|
||||||
@ -525,10 +517,8 @@ fn test_range_backwards_4() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_range_1000() {
|
fn test_range_1000() {
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let size = 1000;
|
let size = if cfg!(miri) { MIN_INSERTS_HEIGHT_2 as u32 } else { 1000 };
|
||||||
#[cfg(miri)]
|
|
||||||
let size = MIN_INSERTS_HEIGHT_2 as u32;
|
|
||||||
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
||||||
|
|
||||||
fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
|
fn test(map: &BTreeMap<u32, u32>, size: u32, min: Bound<&u32>, max: Bound<&u32>) {
|
||||||
@ -566,10 +556,8 @@ fn test_range_borrowed_key() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_range() {
|
fn test_range() {
|
||||||
let size = 200;
|
let size = 200;
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let step = 1;
|
let step = if cfg!(miri) { 66 } else { 1 };
|
||||||
#[cfg(miri)]
|
|
||||||
let step = 66;
|
|
||||||
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
||||||
|
|
||||||
for i in (0..size).step_by(step) {
|
for i in (0..size).step_by(step) {
|
||||||
@ -589,10 +577,8 @@ fn test_range() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_range_mut() {
|
fn test_range_mut() {
|
||||||
let size = 200;
|
let size = 200;
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let step = 1;
|
let step = if cfg!(miri) { 66 } else { 1 };
|
||||||
#[cfg(miri)]
|
|
||||||
let step = 66;
|
|
||||||
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect();
|
||||||
|
|
||||||
for i in (0..size).step_by(step) {
|
for i in (0..size).step_by(step) {
|
||||||
@ -1263,10 +1249,8 @@ fn test_split_off_empty_left() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_off_large_random_sorted() {
|
fn test_split_off_large_random_sorted() {
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let mut data = rand_data(1529);
|
let mut data = if cfg!(miri) { rand_data(529) } else { rand_data(1529) };
|
||||||
#[cfg(miri)]
|
|
||||||
let mut data = rand_data(529);
|
|
||||||
// special case with maximum height.
|
// special case with maximum height.
|
||||||
data.sort();
|
data.sort();
|
||||||
|
|
||||||
|
@ -621,10 +621,8 @@ fn test_split_off_empty_left() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_off_large_random_sorted() {
|
fn test_split_off_large_random_sorted() {
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let mut data = rand_data(1529);
|
let mut data = if cfg!(miri) { rand_data(529) } else { rand_data(1529) };
|
||||||
#[cfg(miri)]
|
|
||||||
let mut data = rand_data(529);
|
|
||||||
// special case with maximum height.
|
// special case with maximum height.
|
||||||
data.sort();
|
data.sort();
|
||||||
|
|
||||||
|
@ -463,15 +463,9 @@ fn test_sort() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_sort_stability() {
|
fn test_sort_stability() {
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let large_range = 500..510;
|
let large_range = if cfg!(miri) { 0..0 } else { 500..510 };
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
let rounds = if cfg!(miri) { 1 } else { 10 };
|
||||||
let rounds = 10;
|
|
||||||
|
|
||||||
#[cfg(miri)]
|
|
||||||
let large_range = 0..0; // empty range
|
|
||||||
#[cfg(miri)]
|
|
||||||
let rounds = 1;
|
|
||||||
|
|
||||||
for len in (2..25).chain(large_range) {
|
for len in (2..25).chain(large_range) {
|
||||||
for _ in 0..rounds {
|
for _ in 0..rounds {
|
||||||
@ -1727,15 +1721,9 @@ fn panic_safe() {
|
|||||||
|
|
||||||
let mut rng = thread_rng();
|
let mut rng = thread_rng();
|
||||||
|
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
let lens = (1..20).chain(70..MAX_LEN);
|
let lens = if cfg!(miri) { (1..10).chain(20..21) } else { (1..20).chain(70..MAX_LEN) };
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
let moduli: &[u32] = if cfg!(miri) { &[5] } else { &[5, 20, 50] };
|
||||||
let moduli = &[5, 20, 50];
|
|
||||||
|
|
||||||
#[cfg(miri)]
|
|
||||||
let lens = 1..10;
|
|
||||||
#[cfg(miri)]
|
|
||||||
let moduli = &[5];
|
|
||||||
|
|
||||||
for len in lens {
|
for len in lens {
|
||||||
for &modulus in moduli {
|
for &modulus in moduli {
|
||||||
|
@ -954,16 +954,14 @@ fn test_append_permutations() {
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(miri))] // Miri is too slow
|
// Miri is too slow
|
||||||
const MAX: usize = 5;
|
let max = if cfg!(miri) { 3 } else { 5 };
|
||||||
#[cfg(miri)]
|
|
||||||
const MAX: usize = 3;
|
|
||||||
|
|
||||||
// Many different permutations of both the `VecDeque` getting appended to
|
// Many different permutations of both the `VecDeque` getting appended to
|
||||||
// and the one getting appended are generated to check `append`.
|
// and the one getting appended are generated to check `append`.
|
||||||
// This ensures all 6 code paths of `append` are tested.
|
// This ensures all 6 code paths of `append` are tested.
|
||||||
for src_push_back in 0..MAX {
|
for src_push_back in 0..max {
|
||||||
for src_push_front in 0..MAX {
|
for src_push_front in 0..max {
|
||||||
// doesn't pop more values than are pushed
|
// doesn't pop more values than are pushed
|
||||||
for src_pop_back in 0..(src_push_back + src_push_front) {
|
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) {
|
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,
|
src_pop_front,
|
||||||
);
|
);
|
||||||
|
|
||||||
for dst_push_back in 0..MAX {
|
for dst_push_back in 0..max {
|
||||||
for dst_push_front 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_back in 0..(dst_push_back + dst_push_front) {
|
||||||
for dst_pop_front in
|
for dst_pop_front in
|
||||||
0..(dst_push_back + dst_push_front - dst_pop_back)
|
0..(dst_push_back + dst_push_front - dst_pop_back)
|
||||||
|
Loading…
Reference in New Issue
Block a user