Skip to content

Commit 59ec328

Browse files
committed
Fix miri test
1 parent 8ed3324 commit 59ec328

File tree

9 files changed

+20
-14
lines changed

9 files changed

+20
-14
lines changed

crossbeam-channel/tests/golang.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,9 +1580,7 @@ mod race_chan_test {
15801580
}
15811581

15821582
// https://github.com/golang/go/blob/master/test/ken/chan.go
1583-
#[cfg(not(miri))] // Miri is too slow
15841583
mod chan {
1585-
15861584
use super::*;
15871585

15881586
const MESSAGES_PER_CHANEL: u32 = 76;
@@ -2052,6 +2050,7 @@ mod chan {
20522050
}
20532051

20542052
#[test]
2053+
#[cfg_attr(miri, ignore)] // Miri is too slow
20552054
fn main() {
20562055
let mut ctx = Context {
20572056
nproc: Arc::new(Mutex::new(0)),

crossbeam-channel/tests/list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ fn len_empty_full() {
6767
}
6868

6969
#[test]
70+
#[cfg_attr(miri, ignore)] // this test makes timing assumptions, but Miri is so slow it violates them
7071
fn try_recv() {
7172
let (s, r) = unbounded();
7273

crossbeam-channel/tests/select.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,6 @@ fn both_ready() {
408408
.unwrap();
409409
}
410410

411-
#[cfg_attr(miri, ignore)] // Miri is too slow
412411
#[test]
413412
fn loop_try() {
414413
const RUNS: usize = 20;

crossbeam-channel/tests/select_macro.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ fn both_ready() {
284284
.unwrap();
285285
}
286286

287-
#[cfg_attr(miri, ignore)] // Miri is too slow
288287
#[test]
289288
fn loop_try() {
290289
const RUNS: usize = 20;

crossbeam-channel/tests/zero.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,11 @@ fn stress_oneshot() {
328328
}
329329
}
330330

331-
#[cfg_attr(miri, ignore)] // Miri is too slow
332331
#[test]
333332
fn stress_iter() {
333+
#[cfg(miri)]
334+
const COUNT: usize = 50;
335+
#[cfg(not(miri))]
334336
const COUNT: usize = 1000;
335337

336338
let (request_s, request_r) = bounded(0);
@@ -483,10 +485,9 @@ fn fairness() {
483485
}
484486

485487
#[test]
486-
#[cfg_attr(miri, ignore)] // Miri is too slow
487488
fn fairness_duplicates() {
488489
#[cfg(miri)]
489-
const COUNT: usize = 50;
490+
const COUNT: usize = 100;
490491
#[cfg(not(miri))]
491492
const COUNT: usize = 10_000;
492493

crossbeam-epoch/src/collector.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,10 @@ mod tests {
402402
v.push(i as i32);
403403
}
404404

405-
let ptr = v.as_mut_ptr() as usize;
405+
let ptr = v.as_mut_ptr();
406406
let len = v.len();
407407
guard.defer_unchecked(move || {
408-
drop(Vec::from_raw_parts(ptr as *const i32 as *mut i32, len, len));
408+
drop(Vec::from_raw_parts(ptr, len, len));
409409
DESTROYS.fetch_add(len, Ordering::Relaxed);
410410
});
411411
guard.flush();

crossbeam-queue/tests/array_queue.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ fn spsc_ring_buffer() {
193193
}
194194
}
195195

196-
#[cfg_attr(miri, ignore)] // Miri is too slow
197196
#[test]
198197
fn mpmc() {
198+
#[cfg(miri)]
199+
const COUNT: usize = 50;
200+
#[cfg(not(miri))]
199201
const COUNT: usize = 25_000;
200202
const THREADS: usize = 4;
201203

@@ -230,9 +232,11 @@ fn mpmc() {
230232
}
231233
}
232234

233-
#[cfg_attr(miri, ignore)] // Miri is too slow
234235
#[test]
235236
fn mpmc_ring_buffer() {
237+
#[cfg(miri)]
238+
const COUNT: usize = 50;
239+
#[cfg(not(miri))]
236240
const COUNT: usize = 25_000;
237241
const THREADS: usize = 4;
238242

crossbeam-queue/tests/seg_queue.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,11 @@ fn spsc() {
8282
.unwrap();
8383
}
8484

85-
#[cfg_attr(miri, ignore)] // Miri is too slow
8685
#[test]
8786
fn mpmc() {
87+
#[cfg(miri)]
88+
const COUNT: usize = 50;
89+
#[cfg(not(miri))]
8890
const COUNT: usize = 25_000;
8991
const THREADS: usize = 4;
9092

crossbeam-utils/src/atomic/atomic_cell.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,10 +1009,11 @@ where
10091009
// discard the data when a data race is detected. The proper solution would be to
10101010
// do atomic reads and atomic writes, but we can't atomically read and write all
10111011
// kinds of data since `AtomicU8` is not available on stable Rust yet.
1012-
let val = ptr::read_volatile(src);
1012+
// Load as `MaybeUninit` because we may load a value that is not valid as `T`.
1013+
let val = ptr::read_volatile(src as *mut MaybeUninit<T>);
10131014

10141015
if lock.validate_read(stamp) {
1015-
return val;
1016+
return val.assume_init();
10161017
}
10171018
}
10181019

0 commit comments

Comments
 (0)