Run Miri on CI

This commit is contained in:
Taiki Endo 2022-07-03 00:18:22 +09:00
parent 10ff11b94f
commit 6a2ee40336
2 changed files with 23 additions and 4 deletions

View File

@ -59,6 +59,19 @@ jobs:
run: rustup update stable
- run: cargo fmt --all --check
miri:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup toolchain install nightly --component miri && rustup default nightly
- run: cargo miri test
env:
# -Zmiri-ignore-leaks is needed because we use detached threads in tests/docs: https://github.com/rust-lang/miri/issues/1371
# TODO: enable -Zmiri-strict-provenance once https://github.com/matklad/once_cell/pull/185 merged and released.
MIRIFLAGS: -Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-ignore-leaks
RUSTFLAGS: ${{ env.RUSTFLAGS }} -Z randomize-layout
security_audit:
runs-on: ubuntu-latest
steps:

View File

@ -23,16 +23,18 @@ fn sleep() {
#[test]
fn chan() {
const N: i32 = if cfg!(miri) { 50 } else { 100_000 };
future::block_on(async {
let (s, r) = mpsc::sync_channel::<i32>(100);
let handle = thread::spawn(move || {
for i in 0..100_000 {
for i in 0..N {
s.send(i).unwrap();
}
});
let mut r = Unblock::new(r.into_iter());
for i in 0i32..100_000 {
for i in 0..N {
assert_eq!(r.next().await, Some(i));
}
@ -43,8 +45,10 @@ fn chan() {
#[test]
fn read() {
const N: usize = if cfg!(miri) { 20_000 } else { 20_000_000 };
future::block_on(async {
let mut v1 = vec![0u8; 20_000_000];
let mut v1 = vec![0u8; N];
for i in 0..v1.len() {
v1[i] = i as u8;
}
@ -60,8 +64,10 @@ fn read() {
#[test]
fn write() {
const N: usize = if cfg!(miri) { 20_000 } else { 20_000_000 };
future::block_on(async {
let mut v1 = vec![0u8; 20_000_000];
let mut v1 = vec![0u8; N];
for i in 0..v1.len() {
v1[i] = i as u8;
}