Skip to content

Commit

Permalink
Add miri and santitizer tests to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhoo committed Jan 29, 2020
1 parent 9544337 commit 1ed709a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
8 changes: 7 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ azure-devops = { project = "jonhoo/jonhoo", pipeline = "flurry", build = "15" }
codecov = { repository = "jonhoo/flurry", branch = "master", service = "github" }
maintenance = { status = "experimental" }

[features]
sanitize = ['crossbeam-epoch/sanitize']

[dependencies]
crossbeam-epoch = "0.8"
crossbeam-epoch = "0.9"
parking_lot = "0.10"
num_cpus = "1.12.0"

[dev-dependencies]
rand = "0.7"

[patch.crates-io]
crossbeam-epoch = { git = "https://github.com/cynecx/crossbeam.git", branch = "fix-unsoundness" }
39 changes: 39 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,45 @@ jobs:
condition: ne(variables.CACHE_RESTORED, 'true')
- script: cargo deny check
displayName: cargo deny
- job: miri
displayName: "Run miri on test suite"
dependsOn: deny
continueOnError: true # since miri sometimes isn't on nightly
pool:
vmImage: ubuntu-16.04
steps:
- template: install-rust.yml@templates
parameters:
rust: nightly
components:
- miri
# ignore leaks due to https://github.com/crossbeam-rs/crossbeam/issues/464
- bash: yes | cargo miri -Zmiri-ignore-leaks test
displayName: cargo miri test
- job: asan
dependsOn: deny
displayName: "Run address sanitizer on test suite"
pool:
vmImage: ubuntu-16.04
steps:
- template: install-rust.yml@templates
parameters:
rust: nightly
- script: |
env ASAN_OPTIONS="detect_odr_violation=0" RUSTFLAGS="-Z sanitizer=address" cargo test --release --features sanitize
displayName: cargo -Z sanitizer=address test
- job: lsan
dependsOn: deny
displayName: "Run leak sanitizer on test suite"
pool:
vmImage: ubuntu-16.04
steps:
- template: install-rust.yml@templates
parameters:
rust: nightly
- script: |
env RUSTFLAGS="-Z sanitizer=leak" cargo test --release --features sanitize
displayName: cargo -Z sanitizer=leak test
resources:
repositories:
Expand Down
7 changes: 7 additions & 0 deletions src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,7 @@ where
}
}

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

#[cfg(miri)]
#[inline]
const fn num_cpus() -> usize {
1
}

#[test]
fn capacity() {
let map = HashMap::<usize, usize>::new();
Expand Down

0 comments on commit 1ed709a

Please sign in to comment.