Skip to content

Commit a2bbf7d

Browse files
committed
Auto merge of #60077 - RalfJung:miri-alloc-tests, r=joshtriplett
make liballoc internal test suite mostly pass in Miri I discovered, to my surprise, that liballoc has two test suites: `liballoc/tests`, and a bunch of stuff embedded directly within liballoc. The latter was not covered by [miri-test-libstd](https://github.com/RalfJung/miri-test-libstd) yet. This disables in Miri the tests that Miri cannot support or runs too slowly.
2 parents 22fa4bb + 2bc8c54 commit a2bbf7d

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/liballoc/alloc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ mod tests {
252252
}
253253

254254
#[bench]
255+
#[cfg(not(miri))] // Miri does not support benchmarks
255256
fn alloc_owned_small(b: &mut Bencher) {
256257
b.iter(|| {
257258
let _: Box<_> = box 10;

src/liballoc/collections/linked_list.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1354,6 +1354,7 @@ mod tests {
13541354

13551355
#[test]
13561356
#[cfg_attr(target_os = "emscripten", ignore)]
1357+
#[cfg(not(miri))] // Miri does not support threads
13571358
fn test_send() {
13581359
let n = list_from(&[1, 2, 3]);
13591360
thread::spawn(move || {
@@ -1371,6 +1372,7 @@ mod tests {
13711372
for _ in 0..25 {
13721373
fuzz_test(3);
13731374
fuzz_test(16);
1375+
#[cfg(not(miri))] // Miri is too slow
13741376
fuzz_test(189);
13751377
}
13761378
}

src/liballoc/collections/vec_deque.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -2799,6 +2799,7 @@ mod tests {
27992799
use super::VecDeque;
28002800

28012801
#[bench]
2802+
#[cfg(not(miri))] // Miri does not support benchmarks
28022803
fn bench_push_back_100(b: &mut test::Bencher) {
28032804
let mut deq = VecDeque::with_capacity(101);
28042805
b.iter(|| {
@@ -2811,6 +2812,7 @@ mod tests {
28112812
}
28122813

28132814
#[bench]
2815+
#[cfg(not(miri))] // Miri does not support benchmarks
28142816
fn bench_push_front_100(b: &mut test::Bencher) {
28152817
let mut deq = VecDeque::with_capacity(101);
28162818
b.iter(|| {
@@ -2823,6 +2825,7 @@ mod tests {
28232825
}
28242826

28252827
#[bench]
2828+
#[cfg(not(miri))] // Miri does not support benchmarks
28262829
fn bench_pop_back_100(b: &mut test::Bencher) {
28272830
let mut deq = VecDeque::<i32>::with_capacity(101);
28282831

@@ -2836,6 +2839,7 @@ mod tests {
28362839
}
28372840

28382841
#[bench]
2842+
#[cfg(not(miri))] // Miri does not support benchmarks
28392843
fn bench_pop_front_100(b: &mut test::Bencher) {
28402844
let mut deq = VecDeque::<i32>::with_capacity(101);
28412845

@@ -3103,7 +3107,12 @@ mod tests {
31033107
assert!(vec.into_iter().eq(vd));
31043108
}
31053109

3106-
for cap_pwr in 0..7 {
3110+
#[cfg(not(miri))] // Miri is too slow
3111+
let max_pwr = 7;
3112+
#[cfg(miri)]
3113+
let max_pwr = 5;
3114+
3115+
for cap_pwr in 0..max_pwr {
31073116
// Make capacity as a (2^x)-1, so that the ring size is 2^x
31083117
let cap = (2i32.pow(cap_pwr) - 1) as usize;
31093118

src/liballoc/sync.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1678,6 +1678,7 @@ mod tests {
16781678

16791679
#[test]
16801680
#[cfg_attr(target_os = "emscripten", ignore)]
1681+
#[cfg(not(miri))] // Miri does not support threads
16811682
fn manually_share_arc() {
16821683
let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
16831684
let arc_v = Arc::new(v);
@@ -1982,6 +1983,7 @@ mod tests {
19821983

19831984
#[test]
19841985
#[cfg_attr(target_os = "emscripten", ignore)]
1986+
#[cfg(not(miri))] // Miri does not support threads
19851987
fn test_weak_count_locked() {
19861988
let mut a = Arc::new(atomic::AtomicBool::new(false));
19871989
let a2 = a.clone();

0 commit comments

Comments
 (0)