diff options
author | 2020-12-29 22:54:48 +0100 | |
---|---|---|
committer | 2020-12-29 22:54:48 +0100 | |
commit | 27a0f9ca6e01b953805684eff535a14eaff937d0 (patch) | |
tree | 41ec3f1a111eadfd43b1ab5e5caf984d5f542991 | |
parent | ed71a7beb3fd0cc67cad08da2643cff2732f6b52 (diff) | |
download | bytes-27a0f9ca6e01b953805684eff535a14eaff937d0.tar.gz bytes-27a0f9ca6e01b953805684eff535a14eaff937d0.tar.zst bytes-27a0f9ca6e01b953805684eff535a14eaff937d0.zip |
CI: run test suite in Miri (#456)
-rw-r--r-- | .github/workflows/ci.yml | 7 | ||||
-rwxr-xr-x | ci/miri.sh | 11 | ||||
-rw-r--r-- | tests/test_bytes.rs | 7 | ||||
-rw-r--r-- | tests/test_bytes_odd_alloc.rs | 2 |
4 files changed, 24 insertions, 3 deletions
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 39303d1..fc03588 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -123,6 +123,13 @@ jobs: run: rustup component add rust-src - name: ASAN / TSAN run: . ci/tsan.sh + miri: + name: miri + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Miri + run: ci/miri.sh # Loom loom: diff --git a/ci/miri.sh b/ci/miri.sh new file mode 100755 index 0000000..88d2b6a --- /dev/null +++ b/ci/miri.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri) +echo "Installing latest nightly with Miri: $MIRI_NIGHTLY" +rustup set profile minimal +rustup default "$MIRI_NIGHTLY" +rustup component add miri + +cargo miri test +cargo miri test --target mips64-unknown-linux-gnuabi64 diff --git a/tests/test_bytes.rs b/tests/test_bytes.rs index 78be4b7..b9e6ce4 100644 --- a/tests/test_bytes.rs +++ b/tests/test_bytes.rs @@ -461,6 +461,7 @@ fn reserve_allocates_at_least_original_capacity() { } #[test] +#[cfg_attr(miri, ignore)] // Miri is too slow fn reserve_max_original_capacity_value() { const SIZE: usize = 128 * 1024; @@ -608,15 +609,15 @@ fn advance_past_len() { #[test] // Only run these tests on little endian systems. CI uses qemu for testing -// little endian... and qemu doesn't really support threading all that well. -#[cfg(target_endian = "little")] +// big endian... and qemu doesn't really support threading all that well. +#[cfg(any(miri, target_endian = "little"))] fn stress() { // Tests promoting a buffer from a vec -> shared in a concurrent situation use std::sync::{Arc, Barrier}; use std::thread; const THREADS: usize = 8; - const ITERS: usize = 1_000; + const ITERS: usize = if cfg!(miri) { 100 } else { 1_000 }; for i in 0..ITERS { let data = [i as u8; 256]; diff --git a/tests/test_bytes_odd_alloc.rs b/tests/test_bytes_odd_alloc.rs index 4ce424b..04ba7c2 100644 --- a/tests/test_bytes_odd_alloc.rs +++ b/tests/test_bytes_odd_alloc.rs @@ -1,6 +1,8 @@ //! Test using `Bytes` with an allocator that hands out "odd" pointers for //! vectors (pointers where the LSB is set). +#![cfg(not(miri))] // Miri does not support custom allocators (also, Miri is "odd" by default with 50% chance) + use std::alloc::{GlobalAlloc, Layout, System}; use std::ptr; |