diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f36591741..fd6407541 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -88,6 +88,19 @@ jobs: run: sudo apt-get install libopenblas-dev gfortran - run: ./scripts/all-tests.sh "$FEATURES" ${{ matrix.rust }} + miri: + runs-on: ubuntu-latest + name: miri + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toochain@nightly + with: + components: miri + - uses: Swatinem/rust-cache@v2 + - name: Install openblas + run: sudo apt-get install libopenblas-dev gfortran + - run: ./scripts/miri-tests.sh + cross_test: #if: ${{ github.event_name == 'merge_group' }} runs-on: ubuntu-latest diff --git a/ndarray-rand/tests/tests.rs b/ndarray-rand/tests/tests.rs index 2db040310..4dc4760dd 100644 --- a/ndarray-rand/tests/tests.rs +++ b/ndarray-rand/tests/tests.rs @@ -57,6 +57,7 @@ fn oversampling_without_replacement_should_panic() } quickcheck! { + #[cfg_attr(miri, ignore)] // Takes an insufferably long time fn oversampling_with_replacement_is_fine(m: u8, n: u8) -> TestResult { let (m, n) = (m as usize, n as usize); let a = Array::random((m, n), Uniform::new(0., 2.)); @@ -84,6 +85,7 @@ quickcheck! { } } +#[cfg_attr(miri, ignore)] #[cfg(feature = "quickcheck")] quickcheck! { fn sampling_behaves_as_expected(m: u8, n: u8, strategy: SamplingStrategy) -> TestResult { diff --git a/scripts/miri-tests.sh b/scripts/miri-tests.sh new file mode 100644 index 000000000..e4480db78 --- /dev/null +++ b/scripts/miri-tests.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +set -x +set -e + +# We rely on layout-dependent casts, which should be covered with #[repr(transparent)] +# This should catch if we missed that +RUSTFLAGS="-Zrandomize-layout" + +# General tests +cargo miri test -v --no-default-features +cargo miri test -v -p ndarray -p ndarray-rand --lib --tests + +# BLAS tests +cargo miri test -p ndarray --lib -v --features blas +cargo miri test -p blas-mock-tests -v +cargo miri test -p blas-tests -v --features blas-tests/openblas-system +cargo miri test -p numeric-tests -v --features numeric-tests/test_blas + +# Examples +cargo miri test --examples