diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d2c894a..41855da 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -191,8 +191,6 @@ jobs: matrix: os: - ubuntu-latest - # - macos-latest - # - windows-latest runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -214,10 +212,6 @@ jobs: run: cargo install cargo-hack - name: ASAN / LSAN / TSAN (Linux) run: ci/sanitizer.sh - if: matrix.os == 'ubuntu-latest' - - name: ASAN / LSAN / TSAN - run: ci/sanitizer_generic.sh - if: matrix.os != 'ubuntu-latest' miri-tb: name: miri-tb @@ -227,6 +221,12 @@ jobs: - ubuntu-latest - macos-latest - windows-latest + target: + - x86_64-unknown-linux-gnu + - i686-unknown-linux-gnu + - powerpc64-unknown-linux-gnu + cfg: + - all_tests runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -243,11 +243,13 @@ jobs: - name: Install cargo-hack run: cargo install cargo-hack - name: Miri (Linux) - run: ci/miri_tb.sh + run: | + bash ci/miri_tb.sh ${{ matrix.target }} ${{ matrix.cfg }} if: matrix.os == 'ubuntu-latest' - - name: Miri - run: ci/miri_tb_generic.sh - if: matrix.os != 'ubuntu-latest' + - name: Miri (macOS) + run: | + bash ci/miri_tb_generic.sh ${{ matrix.cfg }} + if: matrix.os == 'macos-latest' miri-sb: name: miri-sb @@ -257,6 +259,12 @@ jobs: - ubuntu-latest - macos-latest - windows-latest + target: + - x86_64-unknown-linux-gnu + - i686-unknown-linux-gnu + - powerpc64-unknown-linux-gnu + cfg: + - all_tests runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v3 @@ -273,11 +281,13 @@ jobs: - name: Install cargo-hack run: cargo install cargo-hack - name: Miri (Linux) - run: ci/miri_sb.sh + run: | + bash ci/miri_sb.sh ${{ matrix.target }} ${{ matrix.cfg }} if: matrix.os == 'ubuntu-latest' - - name: Miri - run: ci/miri_sb_generic.sh - if: matrix.os != 'ubuntu-latest' + - name: Miri (macOS) + run: | + bash ci/miri_sb_generic.sh ${{ matrix.cfg }} + if: matrix.os == 'macos-latest' loom: name: loom diff --git a/Cargo.toml b/Cargo.toml index 57b37cb..6d3b702 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,3 +38,10 @@ rpath = false [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] + +[lints.rust] +rust_2018_idioms = "warn" +single_use_lifetimes = "warn" +unexpected_cfgs = { level = "warn", check-cfg = [ + 'cfg(all_tests)', +] } diff --git a/ci/miri_sb.sh b/ci/miri_sb.sh index 0bc803c..9cdc0e3 100755 --- a/ci/miri_sb.sh +++ b/ci/miri_sb.sh @@ -1,13 +1,25 @@ #!/bin/bash set -e +# Check if TARGET and CONFIG_FLAGS are provided, otherwise panic +if [ -z "$1" ]; then + echo "Error: TARGET is not provided" + exit 1 +fi + +if [ -z "$2" ]; then + echo "Error: CONFIG_FLAGS are not provided" + exit 1 +fi + +TARGET=$1 +CONFIG_FLAGS=$2 + rustup toolchain install nightly --component miri rustup override set nightly cargo miri setup export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check" +export RUSTFLAGS="--cfg test_$CONFIG_FLAGS" -cargo miri test --tests --target x86_64-unknown-linux-gnu --all-features -# cargo miri test --tests --target aarch64-unknown-linux-gnu #crossbeam_utils has problem on this platform -cargo miri test --tests --target i686-unknown-linux-gnu --all-features -cargo miri test --tests --target powerpc64-unknown-linux-gnu --all-features +cargo miri test --tests --target $TARGET --lib \ No newline at end of file diff --git a/ci/miri_sb_generic.sh b/ci/miri_sb_generic.sh old mode 100755 new mode 100644 index e47db57..00ac083 --- a/ci/miri_sb_generic.sh +++ b/ci/miri_sb_generic.sh @@ -1,10 +1,18 @@ #!/bin/bash set -e +if [ -z "$1" ]; then + echo "Error: CONFIG_FLAGS are not provided" + exit 1 +fi + +CONFIG_FLAGS=$1 + rustup toolchain install nightly --component miri rustup override set nightly cargo miri setup export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check" +export RUSTFLAGS="--cfg test_$CONFIG_FLAGS" -cargo miri test --tests --all-features +cargo miri test --tests --lib diff --git a/ci/miri_tb.sh b/ci/miri_tb.sh index 8048fa6..5f072ee 100755 --- a/ci/miri_tb.sh +++ b/ci/miri_tb.sh @@ -1,13 +1,26 @@ #!/bin/bash set -e +# Check if TARGET and CONFIG_FLAGS are provided, otherwise panic +if [ -z "$1" ]; then + echo "Error: TARGET is not provided" + exit 1 +fi + +if [ -z "$2" ]; then + echo "Error: CONFIG_FLAGS are not provided" + exit 1 +fi + +TARGET=$1 +CONFIG_FLAGS=$2 + rustup toolchain install nightly --component miri rustup override set nightly cargo miri setup export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check -Zmiri-tree-borrows" +export RUSTFLAGS="--cfg test_$CONFIG_FLAGS" + +cargo miri test --tests --target $TARGET --lib -cargo miri test --tests --target x86_64-unknown-linux-gnu --all-features -# cargo miri test --tests --target aarch64-unknown-linux-gnu #crossbeam_utils has problem on this platform -cargo miri test --tests --target i686-unknown-linux-gnu --all-features -cargo miri test --tests --target powerpc64-unknown-linux-gnu --all-features diff --git a/ci/miri_tb_generic.sh b/ci/miri_tb_generic.sh old mode 100755 new mode 100644 index 591b119..0c313d6 --- a/ci/miri_tb_generic.sh +++ b/ci/miri_tb_generic.sh @@ -1,10 +1,18 @@ #!/bin/bash set -e +if [ -z "$1" ]; then + echo "Error: CONFIG_FLAGS are not provided" + exit 1 +fi + +CONFIG_FLAGS=$1 + rustup toolchain install nightly --component miri rustup override set nightly cargo miri setup export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check -Zmiri-tree-borrows" +export RUSTFLAGS="--cfg test_$CONFIG_FLAGS" -cargo miri test --tests --all-features +cargo miri test --tests --lib diff --git a/ci/sanitizer.sh b/ci/sanitizer.sh index eed854e..20c0edd 100755 --- a/ci/sanitizer.sh +++ b/ci/sanitizer.sh @@ -5,13 +5,17 @@ set -ex export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" # Run address sanitizer -RUSTFLAGS="-Z sanitizer=address" \ +RUSTFLAGS="-Z sanitizer=address --cfg all_tests" \ cargo test --tests --target x86_64-unknown-linux-gnu --all-features # Run leak sanitizer -RUSTFLAGS="-Z sanitizer=leak" \ +RUSTFLAGS="-Z sanitizer=leak --cfg all_tests" \ +cargo test --tests --target x86_64-unknown-linux-gnu --all-features + +# Run memory sanitizer +RUSTFLAGS="-Z sanitizer=memory --cfg all_tests" \ cargo test --tests --target x86_64-unknown-linux-gnu --all-features # Run thread sanitizer -RUSTFLAGS="-Z sanitizer=thread" \ +RUSTFLAGS="-Z sanitizer=thread --cfg all_tests" \ cargo -Zbuild-std test --tests --target x86_64-unknown-linux-gnu --all-features diff --git a/ci/sanitizer_generic.sh b/ci/sanitizer_generic.sh deleted file mode 100755 index 728321e..0000000 --- a/ci/sanitizer_generic.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -set -ex - -export ASAN_OPTIONS="detect_odr_violation=0 detect_leaks=0" - -# Run address sanitizer -RUSTFLAGS="-Z sanitizer=address" \ -cargo test --tests --all-features - -# Run leak sanitizer -RUSTFLAGS="-Z sanitizer=leak" \ -cargo test --tests --all-features -