diff options
| author | Tyler Mandry <tmandry@gmail.com> | 2019-12-09 14:33:06 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-12-09 14:33:06 -0800 |
| commit | e77582008888fdc7a6dc60263eddbcb8d4f74ad0 (patch) | |
| tree | d0bd248a9d637751925c6a3cc186557d39b711e8 /src/libcore | |
| parent | a0e00f824a9cda3ee144a9f9f72f79a93b9cda39 (diff) | |
| parent | ab73d10a6ea034892d38fa8203954764c7e9df55 (diff) | |
Rollup merge of #67119 - RalfJung:miri-test-libstd, r=alexcrichton
libstd miri tests: avoid warnings Ignore tests in a way that all the code still gets compiled, to get rid of all the "unused" warnings that otherwise show up when running the test suite in Miri.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/tests/hash/mod.rs | 6 | ||||
| -rw-r--r-- | src/libcore/tests/num/dec2flt/mod.rs | 17 | ||||
| -rw-r--r-- | src/libcore/tests/num/flt2dec/mod.rs | 2 | ||||
| -rw-r--r-- | src/libcore/tests/num/flt2dec/strategy/dragon.rs | 2 | ||||
| -rw-r--r-- | src/libcore/tests/num/flt2dec/strategy/grisu.rs | 2 | ||||
| -rw-r--r-- | src/libcore/tests/ptr.rs | 6 | ||||
| -rw-r--r-- | src/libcore/tests/slice.rs | 8 |
7 files changed, 25 insertions, 18 deletions
diff --git a/src/libcore/tests/hash/mod.rs b/src/libcore/tests/hash/mod.rs index 348245e24f6..ba0220f0d92 100644 --- a/src/libcore/tests/hash/mod.rs +++ b/src/libcore/tests/hash/mod.rs @@ -71,14 +71,16 @@ fn test_writer_hasher() { let ptr = 5_usize as *mut i32; assert_eq!(hash(&ptr), 5); + if cfg!(miri) { // Miri cannot hash pointers + return; + } + 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/num/dec2flt/mod.rs b/src/libcore/tests/num/dec2flt/mod.rs index 4b772e12b6c..6bb348fd752 100644 --- a/src/libcore/tests/num/dec2flt/mod.rs +++ b/src/libcore/tests/num/dec2flt/mod.rs @@ -31,7 +31,11 @@ fn ordinary() { test_literal!(0.1); test_literal!(12345.); test_literal!(0.9999999); - #[cfg(not(miri))] // Miri is too slow + + if cfg!(miri) { // Miri is too slow + return; + } + test_literal!(2.2250738585072014e-308); } @@ -53,7 +57,7 @@ fn large() { } #[test] -#[cfg(not(miri))] // Miri is too slow +#[cfg_attr(miri, ignore)] // Miri is too slow fn subnormals() { test_literal!(5e-324); test_literal!(91e-324); @@ -65,7 +69,7 @@ fn subnormals() { } #[test] -#[cfg(not(miri))] // Miri is too slow +#[cfg_attr(miri, ignore)] // Miri is too slow fn infinity() { test_literal!(1e400); test_literal!(1e309); @@ -77,9 +81,12 @@ fn infinity() { fn zero() { test_literal!(0.0); test_literal!(1e-325); - #[cfg(not(miri))] // Miri is too slow + + if cfg!(miri) { // Miri is too slow + return; + } + test_literal!(1e-326); - #[cfg(not(miri))] // Miri is too slow test_literal!(1e-500); } diff --git a/src/libcore/tests/num/flt2dec/mod.rs b/src/libcore/tests/num/flt2dec/mod.rs index f85369ce40b..2f94ea2fc4b 100644 --- a/src/libcore/tests/num/flt2dec/mod.rs +++ b/src/libcore/tests/num/flt2dec/mod.rs @@ -256,7 +256,6 @@ pub fn f32_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8]) check_shortest!(f(minf32) => b"1", -44); } -#[cfg(not(miri))] // Miri is too slow pub fn f32_exact_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8], i16) -> (usize, i16) { let minf32 = ldexp_f32(1.0, -149); @@ -362,7 +361,6 @@ pub fn f64_shortest_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8]) check_shortest!(f(minf64) => b"5", -323); } -#[cfg(not(miri))] // Miri is too slow pub fn f64_exact_sanity_test<F>(mut f: F) where F: FnMut(&Decoded, &mut [u8], i16) -> (usize, i16) { let minf64 = ldexp_f64(1.0, -1074); diff --git a/src/libcore/tests/num/flt2dec/strategy/dragon.rs b/src/libcore/tests/num/flt2dec/strategy/dragon.rs index 0c545b4d887..3d985c6796b 100644 --- a/src/libcore/tests/num/flt2dec/strategy/dragon.rs +++ b/src/libcore/tests/num/flt2dec/strategy/dragon.rs @@ -22,7 +22,7 @@ fn shortest_sanity_test() { } #[test] -#[cfg(not(miri))] // Miri is too slow +#[cfg_attr(miri, ignore)] // Miri is too slow fn exact_sanity_test() { // This test ends up running what I can only assume is some corner-ish case // of the `exp2` library function, defined in whatever C runtime we're diff --git a/src/libcore/tests/num/flt2dec/strategy/grisu.rs b/src/libcore/tests/num/flt2dec/strategy/grisu.rs index 13396646463..ff8373c6455 100644 --- a/src/libcore/tests/num/flt2dec/strategy/grisu.rs +++ b/src/libcore/tests/num/flt2dec/strategy/grisu.rs @@ -41,7 +41,7 @@ fn shortest_sanity_test() { } #[test] -#[cfg(not(miri))] // Miri is too slow +#[cfg_attr(miri, ignore)] // Miri is too slow fn exact_sanity_test() { // See comments in dragon.rs's exact_sanity_test for why this test is // ignored on MSVC diff --git a/src/libcore/tests/ptr.rs b/src/libcore/tests/ptr.rs index 4f5a9be579e..eea736bc88f 100644 --- a/src/libcore/tests/ptr.rs +++ b/src/libcore/tests/ptr.rs @@ -289,7 +289,7 @@ fn write_unaligned_drop() { } #[test] -#[cfg(not(miri))] // Miri does not compute a maximal `mid` for `align_offset` +#[cfg_attr(miri, ignore)] // Miri does not compute a maximal `mid` for `align_offset` 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,7 +304,7 @@ fn align_offset_zst() { } #[test] -#[cfg(not(miri))] // Miri does not compute a maximal `mid` for `align_offset` +#[cfg_attr(miri, ignore)] // Miri does not compute a maximal `mid` for `align_offset` fn align_offset_stride1() { // For pointers of stride = 1, the pointer can always be aligned. The offset is equal to // number of bytes. @@ -326,7 +326,7 @@ fn align_offset_stride1() { } #[test] -#[cfg(not(miri))] // Miri is too slow +#[cfg_attr(miri, ignore)] // Miri is too slow fn align_offset_weird_strides() { #[repr(packed)] struct A3(u16, u8); diff --git a/src/libcore/tests/slice.rs b/src/libcore/tests/slice.rs index eac18e93ab6..cc274b4aecf 100644 --- a/src/libcore/tests/slice.rs +++ b/src/libcore/tests/slice.rs @@ -1183,7 +1183,7 @@ fn test_rotate_right() { } #[test] -#[cfg(not(miri))] // Miri is too slow +#[cfg_attr(miri, ignore)] // Miri is too slow fn brute_force_rotate_test_0() { // In case of edge cases involving multiple algorithms let n = 300; @@ -1302,7 +1302,7 @@ fn sort_unstable() { #[test] #[cfg(not(target_arch = "wasm32"))] -#[cfg(not(miri))] // Miri is too slow +#[cfg_attr(miri, ignore)] // Miri is too slow fn partition_at_index() { use core::cmp::Ordering::{Equal, Greater, Less}; use rand::rngs::StdRng; @@ -1505,7 +1505,7 @@ pub mod memchr { } #[test] -#[cfg(not(miri))] // Miri does not compute a maximal `mid` for `align_offset` +#[cfg_attr(miri, ignore)] // Miri does not compute a maximal `mid` for `align_offset` fn test_align_to_simple() { let bytes = [1u8, 2, 3, 4, 5, 6, 7]; let (prefix, aligned, suffix) = unsafe { bytes.align_to::<u16>() }; @@ -1535,7 +1535,7 @@ fn test_align_to_zst() { } #[test] -#[cfg(not(miri))] // Miri does not compute a maximal `mid` for `align_offset` +#[cfg_attr(miri, ignore)] // Miri does not compute a maximal `mid` for `align_offset` fn test_align_to_non_trivial() { #[repr(align(8))] struct U64(u64, u64); |
