File tree 3 files changed +36
-2
lines changed
3 files changed +36
-2
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,21 @@ jobs:
160
160
rm -rf /tmp/.buildx-cache
161
161
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
162
162
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
+
163
178
rustfmt :
164
179
name : Rustfmt
165
180
runs-on : ubuntu-latest
@@ -190,6 +205,7 @@ jobs:
190
205
- test
191
206
- rustfmt
192
207
- clippy
208
+ - miri
193
209
runs-on : ubuntu-latest
194
210
# GitHub branch protection is exceedingly silly and treats "jobs skipped because a dependency
195
211
# 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() {
128
128
#[ test]
129
129
fn memcmp_ne ( ) {
130
130
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 {
132
134
let mut diff_arr = arr1;
133
135
diff_arr. 0 [ i] = 127 ;
134
136
let expect = diff_arr. 0 [ i] . cmp ( & arr2. 0 [ i] ) ;
135
- for k in i + 1 ..256 {
137
+ for k in i + 1 ..limit {
136
138
let result = unsafe { memcmp ( diff_arr. 0 . as_ptr ( ) , arr2. 0 . as_ptr ( ) , k) } ;
137
139
assert_eq ! ( expect, result. cmp( & 0 ) ) ;
138
140
}
You can’t perform that action at this time.
0 commit comments