Skip to content

Commit

Permalink
Run Miri on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
taiki-e committed Nov 3, 2020
1 parent a32a675 commit 47cb177
Show file tree
Hide file tree
Showing 15 changed files with 113 additions and 3 deletions.
3 changes: 3 additions & 0 deletions ci/crossbeam-channel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ cargo test -- --test-threads=1
if [[ "$RUST_VERSION" == "nightly"* ]]; then
cd benchmarks
cargo check --bins
cd ..

RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features

./../ci/miri.sh -- -Zmiri-disable-isolation
fi
3 changes: 3 additions & 0 deletions ci/crossbeam-deque.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ cargo test

if [[ "$RUST_VERSION" == "nightly"* ]]; then
RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features

# -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579
./../ci/miri.sh -- -Zmiri-ignore-leaks
fi
4 changes: 4 additions & 0 deletions ci/crossbeam-epoch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,8 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then
--features sanitize,nightly \
--example sanitize
fi

# -Zmiri-disable-stacked-borrows is needed for https://github.com/crossbeam-rs/crossbeam/issues/545
# -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579
./../ci/miri.sh -- -Zmiri-disable-stacked-borrows -Zmiri-ignore-leaks
fi
2 changes: 2 additions & 0 deletions ci/crossbeam-queue.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ cargo test

if [[ "$RUST_VERSION" == "nightly"* ]]; then
RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features

./../ci/miri.sh
fi
4 changes: 4 additions & 0 deletions ci/crossbeam-skiplist.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then
cargo test --features nightly

RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features

# -Zmiri-disable-stacked-borrows is needed for https://github.com/crossbeam-rs/crossbeam/issues/545
# -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579
./../ci/miri.sh -- -Zmiri-disable-stacked-borrows -Zmiri-ignore-leaks
fi
2 changes: 2 additions & 0 deletions ci/crossbeam-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then
cargo test --features nightly

RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features

./../ci/miri.sh -- -Zmiri-disable-isolation
fi
3 changes: 3 additions & 0 deletions ci/crossbeam.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then
cargo test --features nightly

RUSTDOCFLAGS=-Dwarnings cargo doc --no-deps --all-features

# -Zmiri-ignore-leaks is needed for https://github.com/crossbeam-rs/crossbeam/issues/579
./ci/miri.sh -- -Zmiri-ignore-leaks
fi
16 changes: 16 additions & 0 deletions ci/miri.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

set -ex

export RUSTFLAGS="-D warnings"

if [[ "$OSTYPE" != "linux"* ]]; then
exit 0
fi

MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
rustup set profile minimal
rustup default "$MIRI_NIGHTLY"
rustup component add miri

cargo miri test "${@}"
11 changes: 11 additions & 0 deletions crossbeam-deque/tests/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ fn is_empty() {

#[test]
fn spsc() {
#[cfg(miri)]
const STEPS: usize = 500;
#[cfg(not(miri))]
const STEPS: usize = 50_000;

let w = Worker::new_fifo();
Expand Down Expand Up @@ -100,6 +103,9 @@ fn spsc() {
#[test]
fn stampede() {
const THREADS: usize = 8;
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 50_000;

let w = Worker::new_fifo();
Expand Down Expand Up @@ -141,6 +147,9 @@ fn stampede() {
#[test]
fn stress() {
const THREADS: usize = 8;
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 50_000;

let w = Worker::new_fifo();
Expand Down Expand Up @@ -197,6 +206,7 @@ fn stress() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn no_starvation() {
const THREADS: usize = 8;
Expand Down Expand Up @@ -256,6 +266,7 @@ fn no_starvation() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn destructors() {
const THREADS: usize = 8;
Expand Down
14 changes: 14 additions & 0 deletions crossbeam-deque/tests/injector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ fn is_empty() {

#[test]
fn spsc() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;

let q = Injector::new();
Expand Down Expand Up @@ -73,6 +76,9 @@ fn spsc() {

#[test]
fn mpmc() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 25_000;
const THREADS: usize = 4;

Expand Down Expand Up @@ -111,6 +117,9 @@ fn mpmc() {
#[test]
fn stampede() {
const THREADS: usize = 8;
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 50_000;

let q = Injector::new();
Expand Down Expand Up @@ -152,6 +161,9 @@ fn stampede() {
#[test]
fn stress() {
const THREADS: usize = 8;
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 50_000;

let q = Injector::new();
Expand Down Expand Up @@ -208,6 +220,7 @@ fn stress() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn no_starvation() {
const THREADS: usize = 8;
Expand Down Expand Up @@ -267,6 +280,7 @@ fn no_starvation() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn destructors() {
const THREADS: usize = 8;
Expand Down
11 changes: 11 additions & 0 deletions crossbeam-deque/tests/lifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ fn is_empty() {

#[test]
fn spsc() {
#[cfg(miri)]
const STEPS: usize = 500;
#[cfg(not(miri))]
const STEPS: usize = 50_000;

let w = Worker::new_lifo();
Expand Down Expand Up @@ -100,6 +103,9 @@ fn spsc() {
#[test]
fn stampede() {
const THREADS: usize = 8;
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 50_000;

let w = Worker::new_lifo();
Expand Down Expand Up @@ -141,6 +147,9 @@ fn stampede() {
#[test]
fn stress() {
const THREADS: usize = 8;
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 50_000;

let w = Worker::new_lifo();
Expand Down Expand Up @@ -197,6 +206,7 @@ fn stress() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn no_starvation() {
const THREADS: usize = 8;
Expand Down Expand Up @@ -256,6 +266,7 @@ fn no_starvation() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn destructors() {
const THREADS: usize = 8;
Expand Down
30 changes: 27 additions & 3 deletions crossbeam-epoch/src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,18 @@ mod tests {

#[test]
fn pin_holds_advance() {
#[cfg(miri)]
const N: usize = 500;
#[cfg(not(miri))]
const N: usize = 500_000;

let collector = Collector::new();

thread::scope(|scope| {
for _ in 0..NUM_THREADS {
scope.spawn(|_| {
let handle = collector.register();
for _ in 0..500_000 {
for _ in 0..N {
let guard = &handle.pin();

let before = collector.global.epoch.load(Ordering::Relaxed);
Expand All @@ -201,6 +206,9 @@ mod tests {

#[test]
fn incremental() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);

Expand Down Expand Up @@ -229,12 +237,16 @@ mod tests {
let guard = &handle.pin();
collector.global.collect(guard);
}
assert!(DESTROYS.load(Ordering::Relaxed) == 100_000);
assert!(DESTROYS.load(Ordering::Relaxed) == COUNT);
}

#[test]
fn buffering() {
const COUNT: usize = 10;
#[cfg(miri)]
const N: usize = 500;
#[cfg(not(miri))]
const N: usize = 100_000;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);

let collector = Collector::new();
Expand All @@ -251,7 +263,7 @@ mod tests {
}
}

for _ in 0..100_000 {
for _ in 0..N {
collector.global.collect(&handle.pin());
}
assert!(DESTROYS.load(Ordering::Relaxed) < COUNT);
Expand All @@ -267,6 +279,9 @@ mod tests {

#[test]
fn count_drops() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DROPS: AtomicUsize = AtomicUsize::new(0);

Expand Down Expand Up @@ -300,6 +315,9 @@ mod tests {

#[test]
fn count_destroy() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);

Expand Down Expand Up @@ -366,6 +384,9 @@ mod tests {

#[test]
fn destroy_array() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DESTROYS: AtomicUsize = AtomicUsize::new(0);

Expand Down Expand Up @@ -401,6 +422,9 @@ mod tests {
#[test]
fn stress() {
const THREADS: usize = 8;
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 100_000;
static DROPS: AtomicUsize = AtomicUsize::new(0);

Expand Down
3 changes: 3 additions & 0 deletions crossbeam-epoch/src/sync/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ mod test {
}
}

#[cfg(miri)]
const CONC_COUNT: i64 = 1000;
#[cfg(not(miri))]
const CONC_COUNT: i64 = 1000000;

#[test]
Expand Down
7 changes: 7 additions & 0 deletions crossbeam-queue/tests/array_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ fn len_empty_full() {
assert_eq!(q.is_full(), false);
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn len() {
const COUNT: usize = 25_000;
Expand Down Expand Up @@ -114,6 +115,7 @@ fn len() {
assert_eq!(q.len(), 0);
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn spsc() {
const COUNT: usize = 100_000;
Expand Down Expand Up @@ -142,6 +144,7 @@ fn spsc() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn mpmc() {
const COUNT: usize = 25_000;
Expand Down Expand Up @@ -178,6 +181,7 @@ fn mpmc() {
}
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn drops() {
const RUNS: usize = 100;
Expand Down Expand Up @@ -231,6 +235,9 @@ fn drops() {

#[test]
fn linearizable() {
#[cfg(miri)]
const COUNT: usize = 500;
#[cfg(not(miri))]
const COUNT: usize = 25_000;
const THREADS: usize = 4;

Expand Down
3 changes: 3 additions & 0 deletions crossbeam-queue/tests/seg_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ fn len() {
assert_eq!(q.len(), 0);
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn spsc() {
const COUNT: usize = 100_000;
Expand Down Expand Up @@ -79,6 +80,7 @@ fn spsc() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn mpmc() {
const COUNT: usize = 25_000;
Expand Down Expand Up @@ -115,6 +117,7 @@ fn mpmc() {
}
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn drops() {
static DROPS: AtomicUsize = AtomicUsize::new(0);
Expand Down

0 comments on commit 47cb177

Please sign in to comment.