Skip to content

Commit 1ed709a

Browse files
committed
Add miri and santitizer tests to CI
1 parent 9544337 commit 1ed709a

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

Cargo.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,16 @@ azure-devops = { project = "jonhoo/jonhoo", pipeline = "flurry", build = "15" }
1919
codecov = { repository = "jonhoo/flurry", branch = "master", service = "github" }
2020
maintenance = { status = "experimental" }
2121

22+
[features]
23+
sanitize = ['crossbeam-epoch/sanitize']
24+
2225
[dependencies]
23-
crossbeam-epoch = "0.8"
26+
crossbeam-epoch = "0.9"
2427
parking_lot = "0.10"
2528
num_cpus = "1.12.0"
2629

2730
[dev-dependencies]
2831
rand = "0.7"
32+
33+
[patch.crates-io]
34+
crossbeam-epoch = { git = "https://github.com/cynecx/crossbeam.git", branch = "fix-unsoundness" }

azure-pipelines.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,45 @@ jobs:
2929
condition: ne(variables.CACHE_RESTORED, 'true')
3030
- script: cargo deny check
3131
displayName: cargo deny
32+
- job: miri
33+
displayName: "Run miri on test suite"
34+
dependsOn: deny
35+
continueOnError: true # since miri sometimes isn't on nightly
36+
pool:
37+
vmImage: ubuntu-16.04
38+
steps:
39+
- template: install-rust.yml@templates
40+
parameters:
41+
rust: nightly
42+
components:
43+
- miri
44+
# ignore leaks due to https://github.com/crossbeam-rs/crossbeam/issues/464
45+
- bash: yes | cargo miri -Zmiri-ignore-leaks test
46+
displayName: cargo miri test
47+
- job: asan
48+
dependsOn: deny
49+
displayName: "Run address sanitizer on test suite"
50+
pool:
51+
vmImage: ubuntu-16.04
52+
steps:
53+
- template: install-rust.yml@templates
54+
parameters:
55+
rust: nightly
56+
- script: |
57+
env ASAN_OPTIONS="detect_odr_violation=0" RUSTFLAGS="-Z sanitizer=address" cargo test --release --features sanitize
58+
displayName: cargo -Z sanitizer=address test
59+
- job: lsan
60+
dependsOn: deny
61+
displayName: "Run leak sanitizer on test suite"
62+
pool:
63+
vmImage: ubuntu-16.04
64+
steps:
65+
- template: install-rust.yml@templates
66+
parameters:
67+
rust: nightly
68+
- script: |
69+
env RUSTFLAGS="-Z sanitizer=leak" cargo test --release --features sanitize
70+
displayName: cargo -Z sanitizer=leak test
3271
3372
resources:
3473
repositories:

src/map.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1512,6 +1512,7 @@ where
15121512
}
15131513
}
15141514

1515+
#[cfg(not(miri))]
15151516
#[inline]
15161517
/// Returns the number of physical CPUs in the machine (_O(1)_).
15171518
fn num_cpus() -> usize {
@@ -1520,6 +1521,12 @@ fn num_cpus() -> usize {
15201521
NCPU.load(Ordering::Relaxed)
15211522
}
15221523

1524+
#[cfg(miri)]
1525+
#[inline]
1526+
const fn num_cpus() -> usize {
1527+
1
1528+
}
1529+
15231530
#[test]
15241531
fn capacity() {
15251532
let map = HashMap::<usize, usize>::new();

0 commit comments

Comments
 (0)