File tree Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Expand file tree Collapse file tree 3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,21 @@ jobs:
160160 rm -rf /tmp/.buildx-cache
161161 mv /tmp/.buildx-cache-new /tmp/.buildx-cache
162162
163+ miri :
164+ name : Miri
165+ runs-on : ubuntu-latest
166+ steps :
167+ - uses : actions/checkout@v4
168+ with :
169+ submodules : true
170+ - name : Install Rust (rustup)
171+ run : rustup update nightly --no-self-update && rustup default nightly
172+ shell : bash
173+ - run : rustup component add miri
174+ - run : cargo miri setup
175+ - uses : Swatinem/rust-cache@v2
176+ - run : ./ci/miri.sh
177+
163178 rustfmt :
164179 name : Rustfmt
165180 runs-on : ubuntu-latest
@@ -190,6 +205,7 @@ jobs:
190205 - test
191206 - rustfmt
192207 - clippy
208+ - miri
193209 runs-on : ubuntu-latest
194210 # GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
195211 # failed" as success. So we have to do some contortions to ensure the job fails if any of its
Original file line number Diff line number Diff line change 1+ #! /bin/bash
2+ set -ex
3+
4+ # We need Tree Borrows as some of our raw pointer patterns are not
5+ # compatible with Stacked Borrows.
6+ export MIRIFLAGS=" -Zmiri-tree-borrows"
7+
8+ # One target that sets `mem-unaligned` and one that does not,
9+ # and a big-endian target.
10+ TARGETS=(x86_64-unknown-linux-gnu
11+ armv7-unknown-linux-gnueabihf
12+ s390x-unknown-linux-gnu)
13+ for TARGET in " ${TARGETS[@]} " ; do
14+ # Only run the `mem` tests to avoid this taking too long.
15+ cargo miri test --manifest-path testcrate/Cargo.toml --features no-asm --target $TARGET -- mem
16+ done
Original file line number Diff line number Diff line change @@ -128,11 +128,13 @@ fn memcmp_eq() {
128128#[ test]
129129fn memcmp_ne ( ) {
130130 let arr1 @ arr2 = gen_arr :: < 256 > ( ) ;
131- for i in 0 ..256 {
131+ // Reduce iteration count in Miri as it is too slow otherwise.
132+ let limit = if cfg ! ( miri) { 64 } else { 256 } ;
133+ for i in 0 ..limit {
132134 let mut diff_arr = arr1;
133135 diff_arr. 0 [ i] = 127 ;
134136 let expect = diff_arr. 0 [ i] . cmp ( & arr2. 0 [ i] ) ;
135- for k in i + 1 ..256 {
137+ for k in i + 1 ..limit {
136138 let result = unsafe { memcmp ( diff_arr. 0 . as_ptr ( ) , arr2. 0 . as_ptr ( ) , k) } ;
137139 assert_eq ! ( expect, result. cmp( & 0 ) ) ;
138140 }
You can’t perform that action at this time.
0 commit comments