Skip to content

Commit

Permalink
ci: run tests with sanitizers on Linux and MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
mxinden committed Oct 2, 2024
1 parent a4c4ccd commit 6132493
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 1 deletion.
20 changes: 19 additions & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- uses: ./.github/actions/rust
with:
version: ${{ matrix.rust-toolchain }}
components: ${{ matrix.rust-toolchain == 'stable' && 'llvm-tools-preview' || '' }}
components: ${{ matrix.rust-toolchain == 'stable' && 'llvm-tools-preview,' || '' }} ${{ matrix.rust-toolchain == 'nightly' && 'rust-src,' || '' }}
tools: ${{ matrix.rust-toolchain == 'stable' && 'cargo-llvm-cov, ' || '' }} cargo-nextest
token: ${{ secrets.GITHUB_TOKEN }}

Expand Down Expand Up @@ -97,6 +97,24 @@ jobs:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
if: matrix.type == 'debug' && matrix.rust-toolchain == 'stable'

- name: Run tests with sanitizers
if: (matrix.os == 'ubuntu-latest' || matrix.os == 'macos-latest') && matrix.rust-toolchain == 'nightly'
env:
RUST_LOG: trace
run: |
if [ "${{ matrix.os }}" = "ubuntu-latest" ]; then
TARGET="x86_64-unknown-linux-gnu"
SANITIZERS="address thread leak"
elif [ "${{ matrix.os }}" = "macos-latest" ]; then
TARGET="aarch64-apple-darwin"
# no leak sanitizer support yet
SANITIZERS="address thread"
fi
for sanitizer in $SANITIZERS; do
echo "Running tests with $sanitizer sanitizer..."
RUSTFLAGS="-Z sanitizer=$sanitizer" RUSTDOCFLAGS="-Z sanitizer=$sanitizer" cargo +nightly nextest run -Z build-std --target "$TARGET"
done
bench:
needs: [check]
uses: ./.github/workflows/bench.yml
11 changes: 11 additions & 0 deletions neqo-common/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,15 @@ fn main() {
if target.contains("windows") {
println!("cargo:rustc-link-lib=winmm");
}

// `cfg(sanitize = "..")` is not stabilized.
//
// See <https://doc.rust-lang.org/stable/unstable-book/language-features/cfg-sanitize.html>.
println!("cargo:rustc-check-cfg=cfg(neqo_sanitize_address)");
if env::var("CARGO_CFG_SANITIZE")
.unwrap_or_default()
.contains("address")
{
println!("cargo:rustc-cfg=neqo_sanitize_address");
}
}
3 changes: 3 additions & 0 deletions neqo-common/src/hrtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ mod test {

/// Note that you have to run this test alone or other tests will
/// grab the high resolution timer and this will run faster.
#[cfg(not(neqo_sanitize_address))] // Sanitizer is too slow to uphold timing assumptions.
#[test]
fn baseline() {
check_delays(GENEROUS);
Expand All @@ -430,6 +431,7 @@ mod test {
check_delays(ONE_AND_A_BIT);
}

#[cfg(not(neqo_sanitize_address))] // Sanitizer is too slow to uphold timing assumptions.
#[test]
fn multithread_baseline() {
let thr = spawn(move || {
Expand All @@ -448,6 +450,7 @@ mod test {
thr.join().unwrap();
}

#[cfg(not(neqo_sanitize_address))] // Sanitizer is too slow to uphold timing assumptions.
#[test]
fn mixed_multi() {
let thr = spawn(move || {
Expand Down

0 comments on commit 6132493

Please sign in to comment.