From 52cb970c80b235a847cbd66773c0d3f20d036bee Mon Sep 17 00:00:00 2001 From: al8n Date: Sun, 29 Dec 2024 00:04:41 +0800 Subject: [PATCH] cleanup --- .github/workflows/ci.yml | 59 +++++++++++++++++++++++++-- ci/{miri_tb.sh => miri_tb_bounded.sh} | 2 +- ci/miri_tb_unbounded.sh | 33 +++++++++++++++ src/swmr/tests/dynamic/constructor.rs | 6 ++- src/swmr/tests/dynamic/get.rs | 6 ++- src/swmr/tests/dynamic/insert.rs | 6 ++- src/swmr/tests/dynamic/iters.rs | 6 ++- src/swmr/tests/generic/constructor.rs | 6 ++- src/swmr/tests/generic/get.rs | 6 ++- src/swmr/tests/generic/insert.rs | 6 ++- src/swmr/tests/generic/iters.rs | 6 ++- 11 files changed, 122 insertions(+), 20 deletions(-) rename ci/{miri_tb.sh => miri_tb_bounded.sh} (86%) create mode 100755 ci/miri_tb_unbounded.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 62bbb66..406c682 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -260,8 +260,8 @@ jobs: run: ci/sanitizer_generic.sh if: matrix.os != 'ubuntu-latest' - miri-tb: - name: miri-tb-${{ matrix.target }}-${{ matrix.cfg }} + miri-tb-bounded: + name: miri-tb-bounded-${{ matrix.target }}-${{ matrix.cfg }} strategy: matrix: os: @@ -311,7 +311,60 @@ jobs: run: cargo install cargo-hack - name: Miri run: | - bash ci/miri_tb.sh ${{ matrix.target }} ${{ matrix.cfg }} + bash ci/miri_tb_bounded.sh ${{ matrix.target }} ${{ matrix.cfg }} + + miri-tb-unbounded: + name: miri-tb-unbounded-${{ matrix.target }}-${{ matrix.cfg }} + strategy: + matrix: + os: + - ubuntu-latest + # - macos-latest + target: + - x86_64-unknown-linux-gnu + - i686-unknown-linux-gnu + - powerpc64-unknown-linux-gnu + - x86_64-apple-darwin + - aarch64-apple-darwin + cfg: + - generic_insert + - generic_iters + - generic_get + - generic_constructor + - dynamic_insert + - dynamic_iters + - dynamic_get + - dynamic_constructor + # Exclude invalid combinations + exclude: + - os: ubuntu-latest + target: x86_64-apple-darwin + - os: ubuntu-latest + target: aarch64-apple-darwin + # - os: macos-latest + # target: x86_64-unknown-linux-gnu + # - os: macos-latest + # target: i686-unknown-linux-gnu + # - os: macos-latest + # target: powerpc64-unknown-linux-gnu + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Cache cargo build and registry + uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-miri-${{ hashFiles('**/Cargo.lock') }} + restore-keys: | + ${{ runner.os }}-miri- + - name: Install cargo-hack + run: cargo install cargo-hack + - name: Miri + run: | + bash ci/miri_tb_unbounded.sh ${{ matrix.target }} ${{ matrix.cfg }} # valgrind valgrind: diff --git a/ci/miri_tb.sh b/ci/miri_tb_bounded.sh similarity index 86% rename from ci/miri_tb.sh rename to ci/miri_tb_bounded.sh index d379de9..cf0347d 100755 --- a/ci/miri_tb.sh +++ b/ci/miri_tb_bounded.sh @@ -28,5 +28,5 @@ cargo miri setup export MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-disable-isolation -Zmiri-symbolic-alignment-check -Zmiri-tree-borrows -Zmiri-ignore-leaks" export RUSTFLAGS="--cfg test_$CONFIG_FLAGS" -cargo miri test --tests --target $TARGET --lib 2>&1 | ts -i '%.s ' +cargo miri test --tests --target $TARGET --lib --no-default-features --features bounded,std 2>&1 | ts -i '%.s ' diff --git a/ci/miri_tb_unbounded.sh b/ci/miri_tb_unbounded.sh new file mode 100755 index 0000000..d864336 --- /dev/null +++ b/ci/miri_tb_unbounded.sh @@ -0,0 +1,33 @@ +#!/bin/bash +set -euxo pipefail +IFS=$'\n\t' + +# We need 'ts' for the per-line timing +sudo apt-get -y install moreutils +echo + +# 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 + +# Zmiri-ignore-leaks needed because of https://github.com/crossbeam-rs/crossbeam/issues/579 +# -Zmiri-strict-provenance (crossbeam-epoch is not compatible with this flag) +export MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-symbolic-alignment-check -Zmiri-tree-borrows -Zmiri-ignore-leaks" +export RUSTFLAGS="--cfg test_$CONFIG_FLAGS" + +cargo miri test --tests --target $TARGET --lib --no-default-features --features unbounded,std 2>&1 | ts -i '%.s ' + diff --git a/src/swmr/tests/dynamic/constructor.rs b/src/swmr/tests/dynamic/constructor.rs index 6a8e8ba..eea0ce3 100644 --- a/src/swmr/tests/dynamic/constructor.rs +++ b/src/swmr/tests/dynamic/constructor.rs @@ -32,14 +32,14 @@ where } } -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!( "unbounded": OrderWal [Default::default()]: UnboundedTable { zero_reserved, } ); -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!( "unbounded": OrderWal [Default::default()]: UnboundedTable { reserved({ @@ -50,12 +50,14 @@ expand_unit_tests!( } ); +#[cfg(feature = "bounded")] expand_unit_tests!( "bounded": OrderWal [Default::default()]: BoundedTable { zero_reserved, } ); +#[cfg(feature = "bounded")] expand_unit_tests!( "bounded": OrderWal [Default::default()]: BoundedTable { reserved({ diff --git a/src/swmr/tests/dynamic/get.rs b/src/swmr/tests/dynamic/get.rs index f6c7fde..37e16d5 100644 --- a/src/swmr/tests/dynamic/get.rs +++ b/src/swmr/tests/dynamic/get.rs @@ -14,7 +14,7 @@ use crate::{ use super::{Person, MB}; -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!("unbounded": OrderWal [Default::default()]: UnboundedTable { mvcc, gt, @@ -23,6 +23,7 @@ expand_unit_tests!("unbounded": OrderWal [Default::default()]: U lt, }); +#[cfg(feature = "bounded")] expand_unit_tests!("bounded": OrderWal [Default::default()]: BoundedTable { mvcc, gt, @@ -31,7 +32,7 @@ expand_unit_tests!("bounded": OrderWal [Default::default()]: Bound lt, }); -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!("unbounded": OrderWal [Default::default()]: UnboundedTable { insert, unbounded_insert_with_value_builder, @@ -40,6 +41,7 @@ expand_unit_tests!("unbounded": OrderWal [Default::default()]: U unbounded_insert_with_builders, }); +#[cfg(feature = "bounded")] expand_unit_tests!("bounded": OrderWal [Default::default()]: BoundedTable { insert, bounded_insert_with_value_builder, diff --git a/src/swmr/tests/dynamic/insert.rs b/src/swmr/tests/dynamic/insert.rs index 106247c..eee3d77 100644 --- a/src/swmr/tests/dynamic/insert.rs +++ b/src/swmr/tests/dynamic/insert.rs @@ -297,7 +297,7 @@ where (rp1, output, rp2) } -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!( move "unbounded": OrderWal [Default::default()]: UnboundedTable { concurrent_basic |p, _res| { @@ -314,6 +314,7 @@ expand_unit_tests!( } ); +#[cfg(feature = "unbounded")] expand_unit_tests!( move "unbounded": OrderWal [Default::default()]: UnboundedTable { apply |p, (rp1, data, rp2)| { @@ -384,7 +385,7 @@ expand_unit_tests!( } ); -#[cfg(feature = "std")] +#[cfg(feature = "bounded")] expand_unit_tests!( move "bounded": OrderWal [Default::default()]: BoundedTable { concurrent_basic |p, _res| { @@ -401,6 +402,7 @@ expand_unit_tests!( } ); +#[cfg(feature = "bounded")] expand_unit_tests!( move "bounded": OrderWal [Default::default()]: BoundedTable { apply |p, (rp1, data, rp2)| { diff --git a/src/swmr/tests/dynamic/iters.rs b/src/swmr/tests/dynamic/iters.rs index 7296318..9fae162 100644 --- a/src/swmr/tests/dynamic/iters.rs +++ b/src/swmr/tests/dynamic/iters.rs @@ -7,16 +7,17 @@ use crate::{ use super::MB; -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!("unbounded": OrderWal [Default::default()]: UnboundedTable { unbounded_iter_with_tombstone_mvcc, }); +#[cfg(feature = "bounded")] expand_unit_tests!("bounded": OrderWal [Default::default()]: BoundedTable { bounded_iter_with_tombstone_mvcc, }); -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!("unbounded": OrderWal [Default::default()]: UnboundedTable { unbounded_iter_with_tombstone_next_by_entry, unbounded_iter_with_tombstone_next_by_with_tombstone_entry, @@ -40,6 +41,7 @@ macro_rules! bounded_builder { }}; } +#[cfg(feature = "bounded")] expand_unit_tests!("bounded": OrderWal [Default::default()]: BoundedTable { bounded_iter_with_tombstone_next_by_entry(bounded_builder!()), bounded_iter_with_tombstone_next_by_with_tombstone_entry(bounded_builder!()), diff --git a/src/swmr/tests/generic/constructor.rs b/src/swmr/tests/generic/constructor.rs index d86b063..ec90b03 100644 --- a/src/swmr/tests/generic/constructor.rs +++ b/src/swmr/tests/generic/constructor.rs @@ -32,14 +32,14 @@ where } } -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!( "unbounded": OrderWal> [Default::default()]: UnboundedTable<_, _> { zero_reserved, } ); -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!( "unbounded": OrderWal> [Default::default()]: UnboundedTable<_, _> { reserved({ @@ -50,12 +50,14 @@ expand_unit_tests!( } ); +#[cfg(feature = "bounded")] expand_unit_tests!( "bounded": OrderWal> [Default::default()]: BoundedTable<_, _> { zero_reserved, } ); +#[cfg(feature = "bounded")] expand_unit_tests!( "bounded": OrderWal> [Default::default()]: BoundedTable<_, _> { reserved({ diff --git a/src/swmr/tests/generic/get.rs b/src/swmr/tests/generic/get.rs index c22258d..6398f01 100644 --- a/src/swmr/tests/generic/get.rs +++ b/src/swmr/tests/generic/get.rs @@ -15,7 +15,7 @@ use crate::{ use super::{Person, MB}; -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!("unbounded": OrderWal> [Default::default()]: UnboundedTable<_, _> { mvcc, gt, @@ -24,6 +24,7 @@ expand_unit_tests!("unbounded": OrderWal> [Default::def lt, }); +#[cfg(feature = "bounded")] expand_unit_tests!("bounded": OrderWal> [Default::default()]: BoundedTable<_, _> { mvcc, gt, @@ -32,7 +33,7 @@ expand_unit_tests!("bounded": OrderWal> [Default::default lt, }); -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!("unbounded": OrderWal> [Default::default()]: UnboundedTable<_, _> { insert, unbounded_insert_with_value_builder, @@ -41,6 +42,7 @@ expand_unit_tests!("unbounded": OrderWal> [Defaul unbounded_insert_with_builders, }); +#[cfg(feature = "bounded")] expand_unit_tests!("bounded": OrderWal> [Default::default()]: BoundedTable<_, _> { insert, bounded_insert_with_value_builder, diff --git a/src/swmr/tests/generic/insert.rs b/src/swmr/tests/generic/insert.rs index 93aa23f..6221e75 100644 --- a/src/swmr/tests/generic/insert.rs +++ b/src/swmr/tests/generic/insert.rs @@ -311,7 +311,7 @@ where (rp1, output, rp2) } -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!( move "unbounded": OrderWal> [Default::default()]: UnboundedTable<_, _> { concurrent_basic |p, _res| { @@ -328,6 +328,7 @@ expand_unit_tests!( } ); +#[cfg(feature = "unbounded")] expand_unit_tests!( move "unbounded": OrderWal> [Default::default()]: UnboundedTable<_, _> { apply |p, (rp1, data, rp2)| { @@ -385,7 +386,7 @@ expand_unit_tests!( } ); -#[cfg(feature = "std")] +#[cfg(feature = "bounded")] expand_unit_tests!( move "bounded": OrderWal> [Default::default()]: BoundedTable<_, _> { concurrent_basic |p, _res| { @@ -402,6 +403,7 @@ expand_unit_tests!( } ); +#[cfg(feature = "bounded")] expand_unit_tests!( move "bounded": OrderWal> [Default::default()]: BoundedTable<_, _> { apply |p, (rp1, data, rp2)| { diff --git a/src/swmr/tests/generic/iters.rs b/src/swmr/tests/generic/iters.rs index 909bd1e..ae40067 100644 --- a/src/swmr/tests/generic/iters.rs +++ b/src/swmr/tests/generic/iters.rs @@ -7,16 +7,17 @@ use crate::{ use super::MB; -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!("unbounded": OrderWal> [Default::default()]: UnboundedTable<_, _> { unbounded_iter_with_tombstone_mvcc, }); +#[cfg(feature = "bounded")] expand_unit_tests!("bounded": OrderWal> [Default::default()]: BoundedTable<_, _> { bounded_iter_with_tombstone_mvcc, }); -#[cfg(feature = "std")] +#[cfg(feature = "unbounded")] expand_unit_tests!("unbounded": OrderWal> [Default::default()]: UnboundedTable<_, _> { unbounded_iter_with_tombstone_next_by_entry, unbounded_iter_with_tombstone_next_by_with_tombstone_entry, @@ -40,6 +41,7 @@ macro_rules! bounded_builder { }}; } +#[cfg(feature = "bounded")] expand_unit_tests!("bounded": OrderWal> [Default::default()]: BoundedTable<_, _> { bounded_iter_with_tombstone_next_by_entry(bounded_builder!()), bounded_iter_with_tombstone_next_by_with_tombstone_entry(bounded_builder!()),