From 26ade1cfaa095350f27c90a144779a250312cb26 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 9 Feb 2019 11:32:09 +0100 Subject: [PATCH 1/8] mark failures expected due to panics --- src/libcore/tests/iter.rs | 4 ++-- src/libcore/tests/option.rs | 6 +++--- src/libcore/tests/result.rs | 6 +++--- src/libcore/tests/slice.rs | 14 +++++++------- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 51a6017de1b5f..04c5bf7e95b41 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -255,7 +255,7 @@ fn test_iterator_step_by_nth_overflow() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_iterator_step_by_zero() { let mut it = (0..).step_by(0); it.next(); @@ -1417,7 +1417,7 @@ fn test_rposition() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_rposition_panic() { let v: [(Box<_>, Box<_>); 4] = [(box 0, box 0), (box 0, box 0), diff --git a/src/libcore/tests/option.rs b/src/libcore/tests/option.rs index 1ba886ce037ee..87ce2720c5918 100644 --- a/src/libcore/tests/option.rs +++ b/src/libcore/tests/option.rs @@ -69,7 +69,7 @@ fn test_option_dance() { } #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_option_too_much_dance() { struct A; let mut y = Some(A); @@ -130,7 +130,7 @@ fn test_unwrap() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_unwrap_panic1() { let x: Option = None; x.unwrap(); @@ -138,7 +138,7 @@ fn test_unwrap_panic1() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_unwrap_panic2() { let x: Option = None; x.unwrap(); diff --git a/src/libcore/tests/result.rs b/src/libcore/tests/result.rs index 7bfd396f68d17..bbc8568517667 100644 --- a/src/libcore/tests/result.rs +++ b/src/libcore/tests/result.rs @@ -117,7 +117,7 @@ fn test_unwrap_or_else() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics pub fn test_unwrap_or_else_panic() { fn handler(msg: &'static str) -> isize { if msg == "I got this." { @@ -139,7 +139,7 @@ pub fn test_expect_ok() { } #[test] #[should_panic(expected="Got expected error: \"All good\"")] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics pub fn test_expect_err() { let err: Result = Err("All good"); err.expect("Got expected error"); @@ -153,7 +153,7 @@ pub fn test_expect_err_err() { } #[test] #[should_panic(expected="Got expected ok: \"All good\"")] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics pub fn test_expect_err_ok() { let err: Result<&'static str, isize> = Ok("All good"); err.expect_err("Got expected ok"); diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 04d646ea01d03..454c1235c813a 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -782,7 +782,7 @@ mod slice_index { // to be used in `should_panic`) #[test] #[should_panic(expected = "out of range")] - #[cfg(not(miri))] + #[cfg(not(miri))] // Miri does not support panics fn assert_range_eq_can_fail_by_panic() { assert_range_eq!([0, 1, 2], 0..5, [0, 1, 2]); } @@ -792,7 +792,7 @@ mod slice_index { // to be used in `should_panic`) #[test] #[should_panic(expected = "==")] - #[cfg(not(miri))] + #[cfg(not(miri))] // Miri does not support panics fn assert_range_eq_can_fail_by_inequality() { assert_range_eq!([0, 1, 2], 0..2, [0, 1, 2]); } @@ -842,7 +842,7 @@ mod slice_index { #[test] #[should_panic(expected = $expect_msg)] - #[cfg(not(miri))] + #[cfg(not(miri))] // Miri does not support panics fn index_fail() { let v = $data; let v: &[_] = &v; @@ -851,7 +851,7 @@ mod slice_index { #[test] #[should_panic(expected = $expect_msg)] - #[cfg(not(miri))] + #[cfg(not(miri))] // Miri does not support panics fn index_mut_fail() { let mut v = $data; let v: &mut [_] = &mut v; @@ -1306,7 +1306,7 @@ fn test_copy_within() { #[test] #[should_panic(expected = "src is out of bounds")] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_copy_within_panics_src_too_long() { let mut bytes = *b"Hello, World!"; // The length is only 13, so 14 is out of bounds. @@ -1315,7 +1315,7 @@ fn test_copy_within_panics_src_too_long() { #[test] #[should_panic(expected = "dest is out of bounds")] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_copy_within_panics_dest_too_long() { let mut bytes = *b"Hello, World!"; // The length is only 13, so a slice of length 4 starting at index 10 is out of bounds. @@ -1323,7 +1323,7 @@ fn test_copy_within_panics_dest_too_long() { } #[test] #[should_panic(expected = "src end is before src start")] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_copy_within_panics_src_inverted() { let mut bytes = *b"Hello, World!"; // 2 is greater than 1, so this range is invalid. From 7f5dc49214b05a469c5c4974fc4e605cb72822ea Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 9 Feb 2019 13:16:23 +0100 Subject: [PATCH 2/8] review or fix miri failures in iter, slice, cell, time --- src/libcore/tests/cell.rs | 5 +++-- src/libcore/tests/iter.rs | 8 ++------ src/libcore/tests/slice.rs | 8 +++----- src/libcore/tests/time.rs | 5 +++-- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/libcore/tests/cell.rs b/src/libcore/tests/cell.rs index 73bdaab5861e6..b16416022c04e 100644 --- a/src/libcore/tests/cell.rs +++ b/src/libcore/tests/cell.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use core::cell::*; use core::default::Default; use std::mem::drop; @@ -111,6 +109,7 @@ fn double_borrow_single_release_no_borrow_mut() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn discard_doesnt_unborrow() { let x = RefCell::new(0); let _b = x.borrow(); @@ -351,6 +350,7 @@ fn refcell_ref_coercion() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn refcell_swap_borrows() { let x = RefCell::new(0); let _b = x.borrow(); @@ -360,6 +360,7 @@ fn refcell_swap_borrows() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn refcell_replace_borrows() { let x = RefCell::new(0); let _b = x.borrow(); diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index 04c5bf7e95b41..bc951829bd7b9 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -190,7 +190,6 @@ fn test_iterator_step_by() { } #[test] -#[cfg(not(miri))] fn test_iterator_step_by_nth() { let mut it = (0..16).step_by(5); assert_eq!(it.nth(0), Some(0)); @@ -209,7 +208,6 @@ fn test_iterator_step_by_nth() { } #[test] -#[cfg(not(miri))] fn test_iterator_step_by_nth_overflow() { #[cfg(target_pointer_width = "8")] type Bigger = u16; @@ -262,7 +260,6 @@ fn test_iterator_step_by_zero() { } #[test] -#[cfg(not(miri))] fn test_iterator_step_by_size_hint() { struct StubSizeHint(usize, Option); impl Iterator for StubSizeHint { @@ -1657,7 +1654,6 @@ fn test_range_inclusive_nth() { } #[test] -#[cfg(not(miri))] fn test_range_step() { #![allow(deprecated)] @@ -1665,7 +1661,9 @@ fn test_range_step() { assert_eq!((1..21).rev().step_by(5).collect::>(), [20, 15, 10, 5]); assert_eq!((1..21).rev().step_by(6).collect::>(), [20, 14, 8, 2]); assert_eq!((200..255).step_by(50).collect::>(), [200, 250]); + #[cfg(not(miri))] // Miri cannot compare empty slices assert_eq!((200..-5).step_by(1).collect::>(), []); + #[cfg(not(miri))] // Miri cannot compare empty slices assert_eq!((200..200).step_by(1).collect::>(), []); assert_eq!((0..20).step_by(1).size_hint(), (20, Some(20))); @@ -1681,7 +1679,6 @@ fn test_range_step() { } #[test] -#[cfg(not(miri))] fn test_step_by_skip() { assert_eq!((0..640).step_by(128).skip(1).collect::>(), [128, 256, 384, 512]); assert_eq!((0..=50).step_by(10).nth(3), Some(30)); @@ -1689,7 +1686,6 @@ fn test_step_by_skip() { } #[test] -#[cfg(not(miri))] fn test_range_inclusive_step() { assert_eq!((0..=50).step_by(10).collect::>(), [0, 10, 20, 30, 40, 50]); assert_eq!((0..=5).step_by(1).collect::>(), [0, 1, 2, 3, 4, 5]); diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index 454c1235c813a..31d16e0e32057 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -1015,7 +1015,7 @@ fn test_rotate_right() { #[test] #[cfg(not(target_arch = "wasm32"))] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support entropy fn sort_unstable() { use core::cmp::Ordering::{Equal, Greater, Less}; use core::slice::heapsort; @@ -1171,7 +1171,7 @@ pub mod memchr { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri cannot compute actual alignment of an allocation fn test_align_to_simple() { let bytes = [1u8, 2, 3, 4, 5, 6, 7]; let (prefix, aligned, suffix) = unsafe { bytes.align_to::() }; @@ -1187,7 +1187,6 @@ fn test_align_to_simple() { } #[test] -#[cfg(not(miri))] fn test_align_to_zst() { let bytes = [1, 2, 3, 4, 5, 6, 7]; let (prefix, aligned, suffix) = unsafe { bytes.align_to::<()>() }; @@ -1196,7 +1195,7 @@ fn test_align_to_zst() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri cannot compute actual alignment of an allocation fn test_align_to_non_trivial() { #[repr(align(8))] struct U64(u64, u64); #[repr(align(8))] struct U64U64U32(u64, u64, u32); @@ -1208,7 +1207,6 @@ fn test_align_to_non_trivial() { } #[test] -#[cfg(not(miri))] fn test_align_to_empty_mid() { use core::mem; diff --git a/src/libcore/tests/time.rs b/src/libcore/tests/time.rs index d39bd06930a36..f7d00304df5b6 100644 --- a/src/libcore/tests/time.rs +++ b/src/libcore/tests/time.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use core::time::Duration; #[test] @@ -109,12 +107,14 @@ fn checked_sub() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn sub_bad1() { let _ = Duration::new(0, 0) - Duration::new(0, 1); } #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn sub_bad2() { let _ = Duration::new(0, 0) - Duration::new(1, 0); } @@ -287,6 +287,7 @@ fn debug_formatting_precision_two() { } #[test] +#[cfg(not(miri))] // FIXME: A bug in Miri breaks padding in string formatting fn debug_formatting_precision_high() { assert_eq!(format!("{:.5?}", Duration::new(0, 23_678)), "23.67800µs"); From 72be9a607bd127cdd5cdb3f1f53af725f4eeef98 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 9 Feb 2019 16:19:21 +0100 Subject: [PATCH 3/8] review or fix remaining miri failures in libcore --- src/libcore/tests/fmt/mod.rs | 2 +- src/libcore/tests/hash/mod.rs | 4 ++-- src/libcore/tests/iter.rs | 2 -- src/libcore/tests/num/bignum.rs | 14 ++++++++++++++ src/libcore/tests/num/dec2flt/mod.rs | 2 ++ src/libcore/tests/num/flt2dec/mod.rs | 2 ++ src/libcore/tests/num/mod.rs | 2 -- src/libcore/tests/ptr.rs | 9 +++++++-- 8 files changed, 28 insertions(+), 9 deletions(-) diff --git a/src/libcore/tests/fmt/mod.rs b/src/libcore/tests/fmt/mod.rs index b10b63fc484cb..3baa445e652f8 100644 --- a/src/libcore/tests/fmt/mod.rs +++ b/src/libcore/tests/fmt/mod.rs @@ -1,4 +1,4 @@ -#![cfg(not(miri))] +#![cfg(not(miri))] // FIXME: A bug in Miri breaks padding in string formatting mod builders; mod float; diff --git a/src/libcore/tests/hash/mod.rs b/src/libcore/tests/hash/mod.rs index bf3039a7e51e8..1000088e6b063 100644 --- a/src/libcore/tests/hash/mod.rs +++ b/src/libcore/tests/hash/mod.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - mod sip; use std::hash::{Hash, Hasher}; @@ -75,9 +73,11 @@ fn test_writer_hasher() { let cs: &mut [u8] = &mut [1, 2, 3]; let ptr = cs.as_ptr(); let slice_ptr = cs as *const [u8]; + #[cfg(not(miri))] // Miri cannot hash pointers assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64); let slice_ptr = cs as *mut [u8]; + #[cfg(not(miri))] // Miri cannot hash pointers assert_eq!(hash(&slice_ptr), hash(&ptr) + cs.len() as u64); } diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs index bc951829bd7b9..9b76a4af98824 100644 --- a/src/libcore/tests/iter.rs +++ b/src/libcore/tests/iter.rs @@ -1661,9 +1661,7 @@ fn test_range_step() { assert_eq!((1..21).rev().step_by(5).collect::>(), [20, 15, 10, 5]); assert_eq!((1..21).rev().step_by(6).collect::>(), [20, 14, 8, 2]); assert_eq!((200..255).step_by(50).collect::>(), [200, 250]); - #[cfg(not(miri))] // Miri cannot compare empty slices assert_eq!((200..-5).step_by(1).collect::>(), []); - #[cfg(not(miri))] // Miri cannot compare empty slices assert_eq!((200..200).step_by(1).collect::>(), []); assert_eq!((0..20).step_by(1).size_hint(), (20, Some(20))); diff --git a/src/libcore/tests/num/bignum.rs b/src/libcore/tests/num/bignum.rs index b873f1dd0652f..956c22c998219 100644 --- a/src/libcore/tests/num/bignum.rs +++ b/src/libcore/tests/num/bignum.rs @@ -3,6 +3,7 @@ use core::num::bignum::tests::Big8x3 as Big; #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_from_u64_overflow() { Big::from_u64(0x1000000); } @@ -19,12 +20,14 @@ fn test_add() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_add_overflow_1() { Big::from_small(1).add(&Big::from_u64(0xffffff)); } #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_add_overflow_2() { Big::from_u64(0xffffff).add(&Big::from_small(1)); } @@ -42,6 +45,7 @@ fn test_add_small() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_add_small_overflow() { Big::from_u64(0xffffff).add_small(1); } @@ -57,12 +61,14 @@ fn test_sub() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_sub_underflow_1() { Big::from_u64(0x10665).sub(&Big::from_u64(0x10666)); } #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_sub_underflow_2() { Big::from_small(0).sub(&Big::from_u64(0x123456)); } @@ -76,6 +82,7 @@ fn test_mul_small() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mul_small_overflow() { Big::from_u64(0x800000).mul_small(2); } @@ -94,12 +101,14 @@ fn test_mul_pow2() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mul_pow2_overflow_1() { Big::from_u64(0x1).mul_pow2(24); } #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mul_pow2_overflow_2() { Big::from_u64(0x123).mul_pow2(16); } @@ -118,12 +127,14 @@ fn test_mul_pow5() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mul_pow5_overflow_1() { Big::from_small(1).mul_pow5(12); } #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mul_pow5_overflow_2() { Big::from_small(230).mul_pow5(8); } @@ -141,12 +152,14 @@ fn test_mul_digits() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mul_digits_overflow_1() { Big::from_u64(0x800000).mul_digits(&[2]); } #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mul_digits_overflow_2() { Big::from_u64(0x1000).mul_digits(&[0, 0x10]); } @@ -206,6 +219,7 @@ fn test_get_bit() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_get_bit_out_of_range() { Big::from_small(42).get_bit(24); } diff --git a/src/libcore/tests/num/dec2flt/mod.rs b/src/libcore/tests/num/dec2flt/mod.rs index 8f1cd32c3563c..faeaabbf95ada 100644 --- a/src/libcore/tests/num/dec2flt/mod.rs +++ b/src/libcore/tests/num/dec2flt/mod.rs @@ -52,6 +52,7 @@ fn large() { } #[test] +#[cfg(not(miri))] // Miri is too slow fn subnormals() { test_literal!(5e-324); test_literal!(91e-324); @@ -63,6 +64,7 @@ fn subnormals() { } #[test] +#[cfg(not(miri))] // Miri is too slow fn infinity() { test_literal!(1e400); test_literal!(1e309); diff --git a/src/libcore/tests/num/flt2dec/mod.rs b/src/libcore/tests/num/flt2dec/mod.rs index fed9ce73b2a8e..d362c7994d806 100644 --- a/src/libcore/tests/num/flt2dec/mod.rs +++ b/src/libcore/tests/num/flt2dec/mod.rs @@ -1,3 +1,5 @@ +#![cfg(not(miri))] // Miri does not implement ldexp, which most tests here need + use std::prelude::v1::*; use std::{str, i16, f32, f64, fmt}; diff --git a/src/libcore/tests/num/mod.rs b/src/libcore/tests/num/mod.rs index ab638e06cc10d..a17c094679ea8 100644 --- a/src/libcore/tests/num/mod.rs +++ b/src/libcore/tests/num/mod.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use core::convert::{TryFrom, TryInto}; use core::cmp::PartialEq; use core::fmt::Debug; diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs index 5784559082266..2c53e4832a8cc 100644 --- a/src/libcore/tests/ptr.rs +++ b/src/libcore/tests/ptr.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use core::ptr::*; use core::cell::RefCell; @@ -42,6 +40,7 @@ fn test() { } #[test] +#[cfg(not(miri))] // This test performs invalid OOB pointer arithmetic fn test_is_null() { let p: *const isize = null(); assert!(p.is_null()); @@ -147,6 +146,7 @@ fn test_as_ref() { } #[test] +#[cfg(not(miri))] // This test is UB according to Stacked Borrows fn test_as_mut() { unsafe { let p: *mut isize = null_mut(); @@ -208,6 +208,7 @@ fn test_ptr_addition() { } #[test] +#[cfg(not(miri))] // This test performs invalid OOB pointer arithmetic fn test_ptr_subtraction() { unsafe { let xs = vec![0,1,2,3,4,5,6,7,8,9]; @@ -251,6 +252,7 @@ fn test_unsized_nonnull() { #[test] #[allow(warnings)] +#[cfg(not(miri))] // Miri cannot hash pointers // Have a symbol for the test below. It doesn’t need to be an actual variadic function, match the // ABI, or even point to an actual executable code, because the function itself is never invoked. #[no_mangle] @@ -290,6 +292,7 @@ fn write_unaligned_drop() { } #[test] +#[cfg(not(miri))] // Miri cannot compute actual alignment of an allocation fn align_offset_zst() { // For pointers of stride = 0, the pointer is already aligned or it cannot be aligned at // all, because no amount of elements will align the pointer. @@ -304,6 +307,7 @@ fn align_offset_zst() { } #[test] +#[cfg(not(miri))] // Miri cannot compute actual alignment of an allocation fn align_offset_stride1() { // For pointers of stride = 1, the pointer can always be aligned. The offset is equal to // number of bytes. @@ -320,6 +324,7 @@ fn align_offset_stride1() { } #[test] +#[cfg(not(miri))] // Miri is too slow fn align_offset_weird_strides() { #[repr(packed)] struct A3(u16, u8); From e24af6c2b32679e398b2a2b1bc81ab9c258d8765 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 13 Feb 2019 13:25:46 +0100 Subject: [PATCH 4/8] the formatting issue got fixed --- src/libcore/tests/fmt/builders.rs | 1 + src/libcore/tests/fmt/mod.rs | 4 ++-- src/libcore/tests/time.rs | 1 - 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/tests/fmt/builders.rs b/src/libcore/tests/fmt/builders.rs index fd7192cc15119..391250f998640 100644 --- a/src/libcore/tests/fmt/builders.rs +++ b/src/libcore/tests/fmt/builders.rs @@ -488,6 +488,7 @@ mod debug_list { } #[test] +#[cfg(not(miri))] // FIXME uses code in liballoc, investigate Stacked Borrows failure fn test_formatting_parameters_are_forwarded() { use std::collections::{BTreeMap, BTreeSet}; #[derive(Debug)] diff --git a/src/libcore/tests/fmt/mod.rs b/src/libcore/tests/fmt/mod.rs index 3baa445e652f8..df1deeaeb97b7 100644 --- a/src/libcore/tests/fmt/mod.rs +++ b/src/libcore/tests/fmt/mod.rs @@ -1,10 +1,9 @@ -#![cfg(not(miri))] // FIXME: A bug in Miri breaks padding in string formatting - mod builders; mod float; mod num; #[test] +#[cfg(not(miri))] // Miri cannot print pointers fn test_format_flags() { // No residual flags left by pointer formatting let p = "".as_ptr(); @@ -14,6 +13,7 @@ fn test_format_flags() { } #[test] +#[cfg(not(miri))] // Miri cannot print pointers fn test_pointer_formats_data_pointer() { let b: &[u8] = b""; let s: &str = ""; diff --git a/src/libcore/tests/time.rs b/src/libcore/tests/time.rs index f7d00304df5b6..09aae4583482f 100644 --- a/src/libcore/tests/time.rs +++ b/src/libcore/tests/time.rs @@ -287,7 +287,6 @@ fn debug_formatting_precision_two() { } #[test] -#[cfg(not(miri))] // FIXME: A bug in Miri breaks padding in string formatting fn debug_formatting_precision_high() { assert_eq!(format!("{:.5?}", Duration::new(0, 23_678)), "23.67800µs"); From b17ca0107755f60a1760f1dca17240cd70d15c5f Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 13 Feb 2019 13:59:51 +0100 Subject: [PATCH 5/8] review failures in binary_heap, str, vec_deque --- src/liballoc/tests/arc.rs | 2 -- src/liballoc/tests/binary_heap.rs | 2 +- src/liballoc/tests/rc.rs | 2 -- src/liballoc/tests/str.rs | 39 ++++++++++++++----------------- src/liballoc/tests/vec_deque.rs | 11 ++++----- 5 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/liballoc/tests/arc.rs b/src/liballoc/tests/arc.rs index 7c5a8926126e3..2759b1b1cac27 100644 --- a/src/liballoc/tests/arc.rs +++ b/src/liballoc/tests/arc.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use std::any::Any; use std::sync::{Arc, Weak}; use std::cell::RefCell; diff --git a/src/liballoc/tests/binary_heap.rs b/src/liballoc/tests/binary_heap.rs index c1a1c5d88781f..1d4a3edc1ac42 100644 --- a/src/liballoc/tests/binary_heap.rs +++ b/src/liballoc/tests/binary_heap.rs @@ -282,7 +282,7 @@ fn assert_covariance() { // // Destructors must be called exactly once per element. #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn panic_safe() { static DROP_COUNTER: AtomicUsize = AtomicUsize::new(0); diff --git a/src/liballoc/tests/rc.rs b/src/liballoc/tests/rc.rs index 1be01d1a7ce1a..18f82e8041008 100644 --- a/src/liballoc/tests/rc.rs +++ b/src/liballoc/tests/rc.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use std::any::Any; use std::rc::{Rc, Weak}; use std::cell::RefCell; diff --git a/src/liballoc/tests/str.rs b/src/liballoc/tests/str.rs index a1dc763f6d8ff..b33a564218888 100644 --- a/src/liballoc/tests/str.rs +++ b/src/liballoc/tests/str.rs @@ -31,7 +31,6 @@ fn test_rfind() { } #[test] -#[cfg(not(miri))] fn test_collect() { let empty = ""; let s: String = empty.chars().collect(); @@ -119,7 +118,6 @@ fn test_concat_for_different_types() { #[test] fn test_concat_for_different_lengths() { let empty: &[&str] = &[]; - #[cfg(not(miri))] test_concat!("", empty); test_concat!("a", ["a"]); test_concat!("ab", ["a", "b"]); @@ -148,7 +146,6 @@ fn test_join_for_different_types() { #[test] fn test_join_for_different_lengths() { let empty: &[&str] = &[]; - #[cfg(not(miri))] test_join!("", empty, "-"); test_join!("a", ["a"], "-"); test_join!("a-b", ["a", "b"], "-"); @@ -162,7 +159,6 @@ fn test_join_for_different_lengths_with_long_separator() { assert_eq!("~~~~~".len(), 15); let empty: &[&str] = &[]; - #[cfg(not(miri))] test_join!("", empty, "~~~~~"); test_join!("a", ["a"], "~~~~~"); test_join!("a~~~~~b", ["a", "b"], "~~~~~"); @@ -170,7 +166,7 @@ fn test_join_for_different_lengths_with_long_separator() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn test_unsafe_slice() { assert_eq!("ab", unsafe {"abc".get_unchecked(0..2)}); assert_eq!("bc", unsafe {"abc".get_unchecked(1..3)}); @@ -243,7 +239,6 @@ fn test_replacen() { #[test] fn test_replace() { let a = "a"; - #[cfg(not(miri))] assert_eq!("".replace(a, "b"), ""); assert_eq!("a".replace(a, "b"), "b"); assert_eq!("ab".replace(a, "b"), "bb"); @@ -303,7 +298,6 @@ fn test_replace_pattern() { // The current implementation of SliceIndex fails to handle methods // orthogonally from range types; therefore, it is worth testing // all of the indexing operations on each input. -#[cfg(not(miri))] mod slice_index { // Test a slicing operation **that should succeed,** // testing it on all of the indexing methods. @@ -357,6 +351,7 @@ mod slice_index { // to be used in `should_panic`) #[test] #[should_panic(expected = "out of bounds")] + #[cfg(not(miri))] // Miri does not support panics fn assert_range_eq_can_fail_by_panic() { assert_range_eq!("abc", 0..5, "abc"); } @@ -366,6 +361,7 @@ mod slice_index { // to be used in `should_panic`) #[test] #[should_panic(expected = "==")] + #[cfg(not(miri))] // Miri does not support panics fn assert_range_eq_can_fail_by_inequality() { assert_range_eq!("abc", 0..2, "abc"); } @@ -413,6 +409,7 @@ mod slice_index { #[test] #[should_panic(expected = $expect_msg)] + #[cfg(not(miri))] // Miri does not support panics fn index_fail() { let v: String = $data.into(); let v: &str = &v; @@ -421,6 +418,7 @@ mod slice_index { #[test] #[should_panic(expected = $expect_msg)] + #[cfg(not(miri))] // Miri does not support panics fn index_mut_fail() { let mut v: String = $data.into(); let v: &mut str = &mut v; @@ -490,6 +488,7 @@ mod slice_index { #[test] #[cfg(not(target_arch = "asmjs"))] // hits an OOM + #[cfg(not(miri))] // Miri is too slow fn simple_big() { fn a_million_letter_x() -> String { let mut i = 0; @@ -515,6 +514,7 @@ mod slice_index { #[test] #[should_panic] + #[cfg(not(miri))] // Miri does not support panics fn test_slice_fail() { &"中华Việt Nam"[0..2]; } @@ -666,12 +666,14 @@ mod slice_index { // check the panic includes the prefix of the sliced string #[test] #[should_panic(expected="byte index 1024 is out of bounds of `Lorem ipsum dolor sit amet")] + #[cfg(not(miri))] // Miri does not support panics fn test_slice_fail_truncated_1() { &LOREM_PARAGRAPH[..1024]; } // check the truncation in the panic message #[test] #[should_panic(expected="luctus, im`[...]")] + #[cfg(not(miri))] // Miri does not support panics fn test_slice_fail_truncated_2() { &LOREM_PARAGRAPH[..1024]; } @@ -686,7 +688,7 @@ fn test_str_slice_rangetoinclusive_ok() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_str_slice_rangetoinclusive_notok() { let s = "abcαβγ"; &s[..=3]; @@ -702,7 +704,7 @@ fn test_str_slicemut_rangetoinclusive_ok() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_str_slicemut_rangetoinclusive_notok() { let mut s = "abcαβγ".to_owned(); let s: &mut str = &mut s; @@ -892,7 +894,7 @@ fn test_as_bytes() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_as_bytes_fail() { // Don't double free. (I'm not sure if this exercises the // original problem code path anymore.) @@ -982,7 +984,7 @@ fn test_split_at_mut() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_split_at_boundscheck() { let s = "ศไทย中华Việt Nam"; s.split_at(1); @@ -1078,7 +1080,7 @@ fn test_rev_iterator() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn test_chars_decoding() { let mut bytes = [0; 4]; for c in (0..0x110000).filter_map(std::char::from_u32) { @@ -1090,7 +1092,7 @@ fn test_chars_decoding() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn test_chars_rev_decoding() { let mut bytes = [0; 4]; for c in (0..0x110000).filter_map(std::char::from_u32) { @@ -1320,7 +1322,6 @@ fn test_splitator() { } #[test] -#[cfg(not(miri))] fn test_str_default() { use std::default::Default; @@ -1380,7 +1381,7 @@ fn test_bool_from_str() { assert_eq!("not even a boolean".parse::().ok(), None); } -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn check_contains_all_substrings(s: &str) { assert!(s.contains("")); for i in 0..s.len() { @@ -1391,7 +1392,7 @@ fn check_contains_all_substrings(s: &str) { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn strslice_issue_16589() { assert!("bananas".contains("nana")); @@ -1401,7 +1402,6 @@ fn strslice_issue_16589() { } #[test] -#[cfg(not(miri))] fn strslice_issue_16878() { assert!(!"1234567ah012345678901ah".contains("hah")); assert!(!"00abc01234567890123456789abc".contains("bcabc")); @@ -1409,7 +1409,7 @@ fn strslice_issue_16878() { #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn test_strslice_contains() { let x = "There are moments, Jeeves, when one asks oneself, 'Do trousers matter?'"; check_contains_all_substrings(x); @@ -1547,7 +1547,6 @@ fn trim_ws() { #[test] fn to_lowercase() { - #[cfg(not(miri))] assert_eq!("".to_lowercase(), ""); assert_eq!("AÉDžaé ".to_lowercase(), "aédžaé "); @@ -1581,7 +1580,6 @@ fn to_lowercase() { #[test] fn to_uppercase() { - #[cfg(not(miri))] assert_eq!("".to_uppercase(), ""); assert_eq!("aéDžßfiᾀ".to_uppercase(), "AÉDŽSSFIἈΙ"); } @@ -1613,7 +1611,6 @@ fn test_cow_from() { } #[test] -#[cfg(not(miri))] fn test_repeat() { assert_eq!("".repeat(3), ""); assert_eq!("abc".repeat(0), ""); diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index b47e7c867e675..d3439fed3cf3c 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -108,7 +108,7 @@ fn test_index() { #[test] #[should_panic] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support panics fn test_index_out_of_bounds() { let mut deq = VecDeque::new(); for i in 1..4 { @@ -907,24 +907,21 @@ fn test_append() { // normal append a.append(&mut b); assert_eq!(a.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); - #[cfg(not(miri))] assert_eq!(b.iter().cloned().collect::>(), []); // append nothing to something a.append(&mut b); assert_eq!(a.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); - #[cfg(not(miri))] assert_eq!(b.iter().cloned().collect::>(), []); // append something to nothing b.append(&mut a); assert_eq!(b.iter().cloned().collect::>(), [1, 2, 3, 4, 5, 6]); - #[cfg(not(miri))] assert_eq!(a.iter().cloned().collect::>(), []); } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri is too slow fn test_append_permutations() { fn construct_vec_deque( push_back: usize, @@ -1125,7 +1122,7 @@ fn test_reserve_exact_2() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support signalling OOM fn test_try_reserve() { // These are the interesting cases: @@ -1227,7 +1224,7 @@ fn test_try_reserve() { } #[test] -#[cfg(not(miri))] +#[cfg(not(miri))] // Miri does not support signalling OOM fn test_try_reserve_exact() { // This is exactly the same as test_try_reserve with the method changed. From 4c1a1c38305d72fc564f554ae980105d74331108 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 13 Feb 2019 17:18:47 +0100 Subject: [PATCH 6/8] review failures in btree, string --- src/liballoc/tests/btree/map.rs | 28 ++++++++++++++++++++++++++++ src/liballoc/tests/btree/mod.rs | 2 -- src/liballoc/tests/string.rs | 13 +++++++++++-- src/liballoc/tests/vec_deque.rs | 4 +++- src/libcore/tests/fmt/builders.rs | 1 - 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs index aaf504073285d..a92e747904895 100644 --- a/src/liballoc/tests/btree/map.rs +++ b/src/liballoc/tests/btree/map.rs @@ -7,6 +7,7 @@ use std::iter::FromIterator; use super::DeterministicRng; #[test] +#[cfg(not(miri))] // Miri is too slow fn test_basic_large() { let mut map = BTreeMap::new(); let size = 10000; @@ -69,7 +70,10 @@ fn test_basic_small() { #[test] fn test_iter() { + #[cfg(not(miri))] // Miri is too slow let size = 10000; + #[cfg(miri)] + let size = 100; // Forwards let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); @@ -91,7 +95,10 @@ fn test_iter() { #[test] fn test_iter_rev() { + #[cfg(not(miri))] // Miri is too slow let size = 10000; + #[cfg(miri)] + let size = 100; // Forwards let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); @@ -127,7 +134,10 @@ fn test_values_mut() { #[test] fn test_iter_mixed() { + #[cfg(not(miri))] // Miri is too slow let size = 10000; + #[cfg(miri)] + let size = 100; // Forwards let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); @@ -214,6 +224,7 @@ fn test_range_equal_empty_cases() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_range_equal_excluded() { let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect(); map.range((Excluded(2), Excluded(2))); @@ -221,6 +232,7 @@ fn test_range_equal_excluded() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_range_backwards_1() { let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect(); map.range((Included(3), Included(2))); @@ -228,6 +240,7 @@ fn test_range_backwards_1() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_range_backwards_2() { let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect(); map.range((Included(3), Excluded(2))); @@ -235,6 +248,7 @@ fn test_range_backwards_2() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_range_backwards_3() { let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect(); map.range((Excluded(3), Included(2))); @@ -242,6 +256,7 @@ fn test_range_backwards_3() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_range_backwards_4() { let map: BTreeMap<_, _> = (0..5).map(|i| (i, i)).collect(); map.range((Excluded(3), Excluded(2))); @@ -249,7 +264,10 @@ fn test_range_backwards_4() { #[test] fn test_range_1000() { + #[cfg(not(miri))] // Miri is too slow let size = 1000; + #[cfg(miri)] + let size = 100; let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); fn test(map: &BTreeMap, size: u32, min: Bound<&u32>, max: Bound<&u32>) { @@ -286,7 +304,10 @@ fn test_range_borrowed_key() { #[test] fn test_range() { + #[cfg(not(miri))] // Miri is too slow let size = 200; + #[cfg(miri)] + let size = 20; let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); for i in 0..size { @@ -305,7 +326,10 @@ fn test_range() { #[test] fn test_range_mut() { + #[cfg(not(miri))] // Miri is too slow let size = 200; + #[cfg(miri)] + let size = 20; let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); for i in 0..size { @@ -479,7 +503,10 @@ fn test_bad_zst() { #[test] fn test_clone() { let mut map = BTreeMap::new(); + #[cfg(not(miri))] // Miri is too slow let size = 100; + #[cfg(miri)] + let size = 20; assert_eq!(map.len(), 0); for i in 0..size { @@ -631,6 +658,7 @@ create_append_test!(test_append_145, 145); create_append_test!(test_append_170, 170); create_append_test!(test_append_181, 181); create_append_test!(test_append_239, 239); +#[cfg(not(miri))] // Miri is too slow create_append_test!(test_append_1700, 1700); fn rand_data(len: usize) -> Vec<(u32, u32)> { diff --git a/src/liballoc/tests/btree/mod.rs b/src/liballoc/tests/btree/mod.rs index 653b3f5bcb49d..4c704d0f8c28f 100644 --- a/src/liballoc/tests/btree/mod.rs +++ b/src/liballoc/tests/btree/mod.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - mod map; mod set; diff --git a/src/liballoc/tests/string.rs b/src/liballoc/tests/string.rs index e6ca54c408865..7e93d84fe3b97 100644 --- a/src/liballoc/tests/string.rs +++ b/src/liballoc/tests/string.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use std::borrow::Cow; use std::collections::CollectionAllocErr::*; use std::mem::size_of; @@ -233,6 +231,7 @@ fn test_split_off_empty() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_split_off_past_end() { let orig = "Hello, world!"; let mut split = String::from(orig); @@ -241,6 +240,7 @@ fn test_split_off_past_end() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_split_off_mid_char() { let mut orig = String::from("山"); orig.split_off(1); @@ -289,6 +289,7 @@ fn test_str_truncate_invalid_len() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_str_truncate_split_codepoint() { let mut s = String::from("\u{FC}"); // ü s.truncate(1); @@ -323,6 +324,7 @@ fn remove() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn remove_bad() { "ศ".to_string().remove(1); } @@ -358,11 +360,13 @@ fn insert() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn insert_bad1() { "".to_string().insert(1, 't'); } #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn insert_bad2() { "ệ".to_string().insert(1, 't'); } @@ -443,6 +447,7 @@ fn test_replace_range() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_replace_range_char_boundary() { let mut s = "Hello, 世界!".to_owned(); s.replace_range(..8, ""); @@ -459,6 +464,7 @@ fn test_replace_range_inclusive_range() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_replace_range_out_of_bounds() { let mut s = String::from("12345"); s.replace_range(5..6, "789"); @@ -466,6 +472,7 @@ fn test_replace_range_out_of_bounds() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_replace_range_inclusive_out_of_bounds() { let mut s = String::from("12345"); s.replace_range(5..=5, "789"); @@ -525,6 +532,7 @@ fn test_reserve_exact() { } #[test] +#[cfg(not(miri))] // Miri does not support signalling OOM fn test_try_reserve() { // These are the interesting cases: @@ -602,6 +610,7 @@ fn test_try_reserve() { } #[test] +#[cfg(not(miri))] // Miri does not support signalling OOM fn test_try_reserve_exact() { // This is exactly the same as test_try_reserve with the method changed. diff --git a/src/liballoc/tests/vec_deque.rs b/src/liballoc/tests/vec_deque.rs index d3439fed3cf3c..e0cb0e7a9e70c 100644 --- a/src/liballoc/tests/vec_deque.rs +++ b/src/liballoc/tests/vec_deque.rs @@ -921,7 +921,6 @@ fn test_append() { } #[test] -#[cfg(not(miri))] // Miri is too slow fn test_append_permutations() { fn construct_vec_deque( push_back: usize, @@ -945,7 +944,10 @@ fn test_append_permutations() { out } + #[cfg(not(miri))] // Miri is too slow const MAX: usize = 5; + #[cfg(miri)] + const MAX: usize = 3; // Many different permutations of both the `VecDeque` getting appended to // and the one getting appended are generated to check `append`. diff --git a/src/libcore/tests/fmt/builders.rs b/src/libcore/tests/fmt/builders.rs index 391250f998640..fd7192cc15119 100644 --- a/src/libcore/tests/fmt/builders.rs +++ b/src/libcore/tests/fmt/builders.rs @@ -488,7 +488,6 @@ mod debug_list { } #[test] -#[cfg(not(miri))] // FIXME uses code in liballoc, investigate Stacked Borrows failure fn test_formatting_parameters_are_forwarded() { use std::collections::{BTreeMap, BTreeSet}; #[derive(Debug)] From 767dadf8e0fb435ced260e8633add31d8fa7ccff Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 13 Feb 2019 17:49:11 +0100 Subject: [PATCH 7/8] review failures in heap, slice, vec --- src/liballoc/tests/heap.rs | 2 -- src/liballoc/tests/slice.rs | 22 ++++++++++++++++++++-- src/liballoc/tests/vec.rs | 12 ++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/src/liballoc/tests/heap.rs b/src/liballoc/tests/heap.rs index 7bc1aac7c8b59..c225ebfa96b91 100644 --- a/src/liballoc/tests/heap.rs +++ b/src/liballoc/tests/heap.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use std::alloc::{Global, Alloc, Layout, System}; /// Issue #45955. diff --git a/src/liballoc/tests/slice.rs b/src/liballoc/tests/slice.rs index 2a9fdfa9324d5..feba46b0fad78 100644 --- a/src/liballoc/tests/slice.rs +++ b/src/liballoc/tests/slice.rs @@ -1,5 +1,3 @@ -#![cfg(not(miri))] - use std::cell::Cell; use std::cmp::Ordering::{self, Equal, Greater, Less}; use std::mem; @@ -260,6 +258,7 @@ fn test_swap_remove() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_swap_remove_fail() { let mut v = vec![1]; let _ = v.swap_remove(0); @@ -391,6 +390,7 @@ fn test_reverse() { } #[test] +#[cfg(not(miri))] // Miri does not support entropy fn test_sort() { let mut rng = thread_rng(); @@ -467,6 +467,7 @@ fn test_sort() { } #[test] +#[cfg(not(miri))] // Miri does not support entropy fn test_sort_stability() { for len in (2..25).chain(500..510) { for _ in 0..10 { @@ -631,6 +632,7 @@ fn test_insert() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_insert_oob() { let mut a = vec![1, 2, 3]; a.insert(4, 5); @@ -655,6 +657,7 @@ fn test_remove() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_remove_fail() { let mut a = vec![1]; let _ = a.remove(0); @@ -936,6 +939,7 @@ fn test_windowsator() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_windowsator_0() { let v = &[1, 2, 3, 4]; let _it = v.windows(0); @@ -960,6 +964,7 @@ fn test_chunksator() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_chunksator_0() { let v = &[1, 2, 3, 4]; let _it = v.chunks(0); @@ -984,6 +989,7 @@ fn test_chunks_exactator() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_chunks_exactator_0() { let v = &[1, 2, 3, 4]; let _it = v.chunks_exact(0); @@ -1008,6 +1014,7 @@ fn test_rchunksator() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_rchunksator_0() { let v = &[1, 2, 3, 4]; let _it = v.rchunks(0); @@ -1032,6 +1039,7 @@ fn test_rchunks_exactator() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_rchunks_exactator_0() { let v = &[1, 2, 3, 4]; let _it = v.rchunks_exact(0); @@ -1084,6 +1092,7 @@ fn test_vec_default() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_overflow_does_not_cause_segfault() { let mut v = vec![]; v.reserve_exact(!0); @@ -1093,6 +1102,7 @@ fn test_overflow_does_not_cause_segfault() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_overflow_does_not_cause_segfault_managed() { let mut v = vec![Rc::new(1)]; v.reserve_exact(!0); @@ -1268,6 +1278,7 @@ fn test_mut_chunks_rev() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mut_chunks_0() { let mut v = [1, 2, 3, 4]; let _it = v.chunks_mut(0); @@ -1300,6 +1311,7 @@ fn test_mut_chunks_exact_rev() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mut_chunks_exact_0() { let mut v = [1, 2, 3, 4]; let _it = v.chunks_exact_mut(0); @@ -1332,6 +1344,7 @@ fn test_mut_rchunks_rev() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mut_rchunks_0() { let mut v = [1, 2, 3, 4]; let _it = v.rchunks_mut(0); @@ -1364,6 +1377,7 @@ fn test_mut_rchunks_exact_rev() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_mut_rchunks_exact_0() { let mut v = [1, 2, 3, 4]; let _it = v.rchunks_exact_mut(0); @@ -1397,6 +1411,7 @@ fn test_box_slice_clone() { #[test] #[allow(unused_must_use)] // here, we care about the side effects of `.clone()` #[cfg_attr(target_os = "emscripten", ignore)] +#[cfg(not(miri))] // Miri does not support panics fn test_box_slice_clone_panics() { use std::sync::Arc; use std::sync::atomic::{AtomicUsize, Ordering}; @@ -1461,6 +1476,7 @@ fn test_copy_from_slice() { #[test] #[should_panic(expected = "destination and source slices have different lengths")] +#[cfg(not(miri))] // Miri does not support panics fn test_copy_from_slice_dst_longer() { let src = [0, 1, 2, 3]; let mut dst = [0; 5]; @@ -1469,6 +1485,7 @@ fn test_copy_from_slice_dst_longer() { #[test] #[should_panic(expected = "destination and source slices have different lengths")] +#[cfg(not(miri))] // Miri does not support panics fn test_copy_from_slice_dst_shorter() { let src = [0, 1, 2, 3]; let mut dst = [0; 3]; @@ -1588,6 +1605,7 @@ thread_local!(static SILENCE_PANIC: Cell = Cell::new(false)); #[test] #[cfg_attr(target_os = "emscripten", ignore)] // no threads +#[cfg(not(miri))] // Miri does not support panics fn panic_safe() { let prev = panic::take_hook(); panic::set_hook(Box::new(move |info| { diff --git a/src/liballoc/tests/vec.rs b/src/liballoc/tests/vec.rs index 545332bcd6a2f..6e4ca1d90e642 100644 --- a/src/liballoc/tests/vec.rs +++ b/src/liballoc/tests/vec.rs @@ -368,6 +368,7 @@ fn test_vec_truncate_drop() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_vec_truncate_fail() { struct BadElem(i32); impl Drop for BadElem { @@ -391,6 +392,7 @@ fn test_index() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_index_out_of_bounds() { let vec = vec![1, 2, 3]; let _ = vec[3]; @@ -398,6 +400,7 @@ fn test_index_out_of_bounds() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_slice_out_of_bounds_1() { let x = vec![1, 2, 3, 4, 5]; &x[!0..]; @@ -405,6 +408,7 @@ fn test_slice_out_of_bounds_1() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_slice_out_of_bounds_2() { let x = vec![1, 2, 3, 4, 5]; &x[..6]; @@ -412,6 +416,7 @@ fn test_slice_out_of_bounds_2() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_slice_out_of_bounds_3() { let x = vec![1, 2, 3, 4, 5]; &x[!0..4]; @@ -419,6 +424,7 @@ fn test_slice_out_of_bounds_3() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_slice_out_of_bounds_4() { let x = vec![1, 2, 3, 4, 5]; &x[1..6]; @@ -426,6 +432,7 @@ fn test_slice_out_of_bounds_4() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_slice_out_of_bounds_5() { let x = vec![1, 2, 3, 4, 5]; &x[3..2]; @@ -433,6 +440,7 @@ fn test_slice_out_of_bounds_5() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_swap_remove_empty() { let mut vec = Vec::::new(); vec.swap_remove(0); @@ -503,6 +511,7 @@ fn test_drain_items_zero_sized() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_drain_out_of_bounds() { let mut v = vec![1, 2, 3, 4, 5]; v.drain(5..6); @@ -576,6 +585,7 @@ fn test_drain_max_vec_size() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_drain_inclusive_out_of_bounds() { let mut v = vec![1, 2, 3, 4, 5]; v.drain(5..=5); @@ -605,6 +615,7 @@ fn test_splice_inclusive_range() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_splice_out_of_bounds() { let mut v = vec![1, 2, 3, 4, 5]; let a = [10, 11, 12]; @@ -613,6 +624,7 @@ fn test_splice_out_of_bounds() { #[test] #[should_panic] +#[cfg(not(miri))] // Miri does not support panics fn test_splice_inclusive_out_of_bounds() { let mut v = vec![1, 2, 3, 4, 5]; let a = [10, 11, 12]; From c154bf7db4d5737b55c6f85c69df136c374db3a5 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 13 Feb 2019 18:11:57 +0100 Subject: [PATCH 8/8] miri: test with slightly larger BTrees --- src/liballoc/tests/btree/map.rs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/liballoc/tests/btree/map.rs b/src/liballoc/tests/btree/map.rs index a92e747904895..f14750089c956 100644 --- a/src/liballoc/tests/btree/map.rs +++ b/src/liballoc/tests/btree/map.rs @@ -7,10 +7,12 @@ use std::iter::FromIterator; use super::DeterministicRng; #[test] -#[cfg(not(miri))] // Miri is too slow fn test_basic_large() { let mut map = BTreeMap::new(); + #[cfg(not(miri))] // Miri is too slow let size = 10000; + #[cfg(miri)] + let size = 200; assert_eq!(map.len(), 0); for i in 0..size { @@ -73,7 +75,7 @@ fn test_iter() { #[cfg(not(miri))] // Miri is too slow let size = 10000; #[cfg(miri)] - let size = 100; + let size = 200; // Forwards let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); @@ -98,7 +100,7 @@ fn test_iter_rev() { #[cfg(not(miri))] // Miri is too slow let size = 10000; #[cfg(miri)] - let size = 100; + let size = 200; // Forwards let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); @@ -137,7 +139,7 @@ fn test_iter_mixed() { #[cfg(not(miri))] // Miri is too slow let size = 10000; #[cfg(miri)] - let size = 100; + let size = 200; // Forwards let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); @@ -267,7 +269,7 @@ fn test_range_1000() { #[cfg(not(miri))] // Miri is too slow let size = 1000; #[cfg(miri)] - let size = 100; + let size = 200; let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); fn test(map: &BTreeMap, size: u32, min: Bound<&u32>, max: Bound<&u32>) { @@ -307,7 +309,7 @@ fn test_range() { #[cfg(not(miri))] // Miri is too slow let size = 200; #[cfg(miri)] - let size = 20; + let size = 30; let map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); for i in 0..size { @@ -329,7 +331,7 @@ fn test_range_mut() { #[cfg(not(miri))] // Miri is too slow let size = 200; #[cfg(miri)] - let size = 20; + let size = 30; let mut map: BTreeMap<_, _> = (0..size).map(|i| (i, i)).collect(); for i in 0..size { @@ -506,7 +508,7 @@ fn test_clone() { #[cfg(not(miri))] // Miri is too slow let size = 100; #[cfg(miri)] - let size = 20; + let size = 30; assert_eq!(map.len(), 0); for i in 0..size {