diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 490c7047c4..3938211c33 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -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 }} @@ -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 --features ci --target "$TARGET" + done + bench: needs: [check] uses: ./.github/workflows/bench.yml diff --git a/neqo-common/build.rs b/neqo-common/build.rs index 9047b1f5d0..473ae60738 100644 --- a/neqo-common/build.rs +++ b/neqo-common/build.rs @@ -11,4 +11,12 @@ fn main() { if target.contains("windows") { println!("cargo:rustc-link-lib=winmm"); } + + // `cfg(sanitize = "..")` is not stabilized. + // + // See . + println!("cargo:rustc-check-cfg=cfg(neqo_sanitize)"); + if env::var("CARGO_CFG_SANITIZE").is_ok() { + println!("cargo:rustc-cfg=neqo_sanitize"); + } } diff --git a/neqo-common/src/hrtime.rs b/neqo-common/src/hrtime.rs index 7d676620db..7187b7727d 100644 --- a/neqo-common/src/hrtime.rs +++ b/neqo-common/src/hrtime.rs @@ -374,7 +374,9 @@ impl Drop for Time { // inaccuracies are too high to pass the tests. #[cfg(all( test, - not(all(any(target_os = "macos", target_os = "windows"), feature = "ci")) + not(all(any(target_os = "macos", target_os = "windows"), feature = "ci")), + // Sanitizers are too slow to uphold timing assumptions. + not(neqo_sanitize), ))] mod test { use std::{