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 16, 2020
1 parent 9c3a8a8 commit 01412f5
Show file tree
Hide file tree
Showing 27 changed files with 315 additions and 21 deletions.
7 changes: 6 additions & 1 deletion ci/crossbeam-channel.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

cd "$(dirname "$0")"/../crossbeam-channel
set -ex

script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"/../crossbeam-channel

export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
Expand All @@ -11,6 +13,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

"$script_dir"/miri.sh -- -Zmiri-disable-isolation
fi
7 changes: 6 additions & 1 deletion ci/crossbeam-deque.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
#!/bin/bash

cd "$(dirname "$0")"/../crossbeam-deque
set -ex

script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"/../crossbeam-deque

export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
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
"$script_dir"/miri.sh -- -Zmiri-ignore-leaks
fi
8 changes: 7 additions & 1 deletion ci/crossbeam-epoch.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

cd "$(dirname "$0")"/../crossbeam-epoch
set -ex

script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"/../crossbeam-epoch

export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
Expand All @@ -22,4 +24,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
"$script_dir"/miri.sh -- -Zmiri-disable-stacked-borrows -Zmiri-ignore-leaks
fi
6 changes: 5 additions & 1 deletion ci/crossbeam-queue.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#!/bin/bash

cd "$(dirname "$0")"/../crossbeam-queue
set -ex

script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"/../crossbeam-queue

export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
cargo test

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

"$script_dir"/miri.sh
fi
8 changes: 7 additions & 1 deletion ci/crossbeam-skiplist.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

cd "$(dirname "$0")"/../crossbeam-skiplist
set -ex

script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"/../crossbeam-skiplist

export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
Expand All @@ -12,4 +14,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
"$script_dir"/miri.sh -- -Zmiri-disable-stacked-borrows -Zmiri-ignore-leaks
fi
6 changes: 5 additions & 1 deletion ci/crossbeam-utils.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

cd "$(dirname "$0")"/../crossbeam-utils
set -ex

script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"/../crossbeam-utils

export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
Expand All @@ -12,4 +14,6 @@ if [[ "$RUST_VERSION" == "nightly"* ]]; then
cargo test --features nightly

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

"$script_dir"/miri.sh -- -Zmiri-disable-isolation
fi
7 changes: 6 additions & 1 deletion ci/crossbeam.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/bin/bash

cd "$(dirname "$0")"/..
set -ex

script_dir="$(cd "$(dirname "$0")" && pwd)"
cd "$script_dir"/..

export RUSTFLAGS="-D warnings"

cargo check --bins --examples --tests
Expand All @@ -12,4 +14,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
"$script_dir"/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

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

cargo miri test "$@"
2 changes: 2 additions & 0 deletions crossbeam-channel/tests/after.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Tests for the after channel flavor.
#![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow

use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
use std::thread;
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-channel/tests/array.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
//! Tests for the array channel flavor.
#![cfg(not(miri))] // TODO: many assertions failed due to Miri is slow

use std::any::Any;
use std::sync::atomic::AtomicUsize;
use std::sync::atomic::Ordering;
Expand Down
2 changes: 2 additions & 0 deletions crossbeam-channel/tests/golang.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//! - https://golang.org/LICENSE
//! - https://golang.org/PATENTS
#![cfg(not(miri))] // TODO

use std::alloc::{GlobalAlloc, Layout, System};
use std::any::Any;
use std::cell::Cell;
Expand Down
1 change: 1 addition & 0 deletions crossbeam-channel/tests/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fn recv_iter_break() {
.unwrap();
}

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn recv_try_iter() {
let (request_s, request_r) = unbounded();
Expand Down
23 changes: 23 additions & 0 deletions crossbeam-channel/tests/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ fn disconnect_wakes_receiver() {

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

let (s, r) = unbounded();
Expand All @@ -261,6 +264,9 @@ fn spsc() {

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

Expand Down Expand Up @@ -295,6 +301,9 @@ fn mpmc() {

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

for _ in 0..COUNT {
Expand All @@ -308,6 +317,7 @@ fn stress_oneshot() {
}
}

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

#[cfg_attr(miri, ignore)] // Miri is too slow
#[test]
fn drops() {
static DROPS: AtomicUsize = AtomicUsize::new(0);
Expand Down Expand Up @@ -421,6 +432,9 @@ fn drops() {

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

Expand All @@ -441,6 +455,9 @@ fn linearizable() {

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

let (s1, r1) = unbounded::<()>();
Expand All @@ -463,6 +480,9 @@ fn fairness() {

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

let (s, r) = unbounded();
Expand Down Expand Up @@ -496,6 +516,9 @@ fn recv_in_send() {

#[test]
fn channel_through_channel() {
#[cfg(miri)]
const COUNT: usize = 100;
#[cfg(not(miri))]
const COUNT: usize = 1000;

type T = Box<dyn Any + Send>;
Expand Down
Loading

0 comments on commit 01412f5

Please sign in to comment.