Skip to content

Commit 27a0f9c

Browse files
authored
CI: run test suite in Miri (#456)
1 parent ed71a7b commit 27a0f9c

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

.github/workflows/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ jobs:
123123
run: rustup component add rust-src
124124
- name: ASAN / TSAN
125125
run: . ci/tsan.sh
126+
miri:
127+
name: miri
128+
runs-on: ubuntu-latest
129+
steps:
130+
- uses: actions/checkout@v2
131+
- name: Miri
132+
run: ci/miri.sh
126133

127134
# Loom
128135
loom:

ci/miri.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
set -e
3+
4+
MIRI_NIGHTLY=nightly-$(curl -s https://rust-lang.github.io/rustup-components-history/x86_64-unknown-linux-gnu/miri)
5+
echo "Installing latest nightly with Miri: $MIRI_NIGHTLY"
6+
rustup set profile minimal
7+
rustup default "$MIRI_NIGHTLY"
8+
rustup component add miri
9+
10+
cargo miri test
11+
cargo miri test --target mips64-unknown-linux-gnuabi64

tests/test_bytes.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ fn reserve_allocates_at_least_original_capacity() {
461461
}
462462

463463
#[test]
464+
#[cfg_attr(miri, ignore)] // Miri is too slow
464465
fn reserve_max_original_capacity_value() {
465466
const SIZE: usize = 128 * 1024;
466467

@@ -608,15 +609,15 @@ fn advance_past_len() {
608609

609610
#[test]
610611
// Only run these tests on little endian systems. CI uses qemu for testing
611-
// little endian... and qemu doesn't really support threading all that well.
612-
#[cfg(target_endian = "little")]
612+
// big endian... and qemu doesn't really support threading all that well.
613+
#[cfg(any(miri, target_endian = "little"))]
613614
fn stress() {
614615
// Tests promoting a buffer from a vec -> shared in a concurrent situation
615616
use std::sync::{Arc, Barrier};
616617
use std::thread;
617618

618619
const THREADS: usize = 8;
619-
const ITERS: usize = 1_000;
620+
const ITERS: usize = if cfg!(miri) { 100 } else { 1_000 };
620621

621622
for i in 0..ITERS {
622623
let data = [i as u8; 256];

tests/test_bytes_odd_alloc.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Test using `Bytes` with an allocator that hands out "odd" pointers for
22
//! vectors (pointers where the LSB is set).
33
4+
#![cfg(not(miri))] // Miri does not support custom allocators (also, Miri is "odd" by default with 50% chance)
5+
46
use std::alloc::{GlobalAlloc, Layout, System};
57
use std::ptr;
68

0 commit comments

Comments
 (0)