Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unittests #2

Merged
merged 32 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
codecov:
require_ci_to_pass: false

ignore:
- "**/integration/"
- "**/examples/"
- "**/benches/"
- "src/swmr/traits/impls/"
- "src/swmr/traits/impls.rs"
- "src/tests.rs"
- "src/swmr/generic/tests.rs"
- "src/swmr/wal/tests.rs"
- "src/unsync/tests.rs"

coverage:
status:
project: # Overall project status
default:
target: auto
if_not_found: success
only_pulls: false
patch: # Status for the patch in pull requests
default:
target: auto
if_not_found: success
only_pulls: true
changes: false # Whether to comment on the coverage changes in pull requests

comment:
layout: "header, diff, files, footer"
behavior: default
require_changes: false
110 changes: 66 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ jobs:
- powerpc64-unknown-linux-gnu
# - mips64-unknown-linux-gnuabi64
- riscv64gc-unknown-linux-gnu
- wasm32-unknown-unknown
- wasm32-unknown-emscripten
- wasm32-wasi
# - wasm32-unknown-unknown
# - wasm32-unknown-emscripten
# - wasm32-wasi
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
Expand All @@ -103,14 +103,14 @@ jobs:
- name: cross build --target ${{ matrix.target }}
run: |
cargo install cross
cross build --target ${{ matrix.target }}
if: matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'wasm32-wasi'
# WASM support
- name: cargo build --target ${{ matrix.target }}
run: |
rustup target add ${{ matrix.target }}
cargo build --target ${{ matrix.target }}
if: matrix.target == 'wasm32-unknown-unknown' || matrix.target == 'wasm32-wasi'
cross build --target ${{ matrix.target }} --all-features
# if: matrix.target != 'wasm32-unknown-unknown' && matrix.target != 'wasm32-wasi'
# # WASM support
# - name: cargo build --target ${{ matrix.target }}
# run: |
# rustup target add ${{ matrix.target }}
# cargo build --target ${{ matrix.target }}
# if: matrix.target == 'wasm32-unknown-unknown' || matrix.target == 'wasm32-wasi'
# - name: cargo build --target ${{ matrix.target }}
# run: |
# rustup target add ${{ matrix.target }}
Expand Down Expand Up @@ -141,15 +141,13 @@ jobs:
- name: Install Rust
# --no-self-update is necessary because the windows environment cannot self-update rustup.exe.
run: rustup update stable --no-self-update && rustup default stable
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Cache ~/.cargo
uses: actions/cache@v3
with:
path: ~/.cargo
key: ${{ runner.os }}-coverage-dotcargo
- name: Run build
run: cargo hack build --feature-powerset --exclude-no-default-features
run: cargo build --all-features

test:
name: test
Expand Down Expand Up @@ -183,7 +181,7 @@ jobs:
path: ~/.cargo
key: ${{ runner.os }}-coverage-dotcargo
- name: Run test
run: cargo hack test --feature-powerset --exclude-no-default-features
run: cargo test --all-features

sanitizer:
name: sanitizer
Expand Down Expand Up @@ -219,14 +217,14 @@ jobs:
run: ci/sanitizer_generic.sh
if: matrix.os != 'ubuntu-latest'

miri-tb:
name: miri-tb
miri-tb-unsync:
name: miri-tb-unsync
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
# - macos-latest
# - windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -243,20 +241,17 @@ jobs:
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Miri (Linux)
run: ci/miri_tb.sh
run: ci/miri_tb_unsync.sh
if: matrix.os == 'ubuntu-latest'
- name: Miri
run: ci/miri_tb_generic.sh
if: matrix.os != 'ubuntu-latest'

miri-sb:
name: miri-sb
miri-tb-swmr:
name: miri-tb-swmr
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
# - macos-latest
# - windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -273,20 +268,17 @@ jobs:
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Miri (Linux)
run: ci/miri_sb.sh
run: ci/miri_tb_swmr.sh
if: matrix.os == 'ubuntu-latest'
- name: Miri
run: ci/miri_sb_generic.sh
if: matrix.os != 'ubuntu-latest'

loom:
name: loom

miri-tb-swmr-generic:
name: miri-tb-swmr-generic
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
# - macos-latest
# - windows-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
Expand All @@ -297,14 +289,45 @@ jobs:
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-loom-${{ hashFiles('**/Cargo.lock') }}
key: ${{ runner.os }}-miri-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-loom-
- name: Install Rust
run: rustup update $nightly && rustup default $nightly
- name: Loom tests
run: cargo test --tests --features loom,memmap

${{ runner.os }}-miri-
- name: Install cargo-hack
run: cargo install cargo-hack
- name: Miri (Linux)
run: ci/miri_tb_swmr_generic.sh
if: matrix.os == 'ubuntu-latest'

# miri-sb:
# name: miri-sb
# strategy:
# matrix:
# os:
# - ubuntu-latest
# - macos-latest
# - windows-latest
# runs-on: ${{ matrix.os }}
# steps:
# - uses: actions/checkout@v3
# - name: Cache cargo build and registry
# uses: actions/cache@v3
# 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 (Linux)
# run: ci/miri_sb.sh
# if: matrix.os == 'ubuntu-latest'
# - name: Miri
# run: ci/miri_sb_generic.sh
# if: matrix.os != 'ubuntu-latest'

# valgrind
valgrind:
name: valgrind
Expand Down Expand Up @@ -351,7 +374,6 @@ jobs:
- cross
- test
- sanitizer
- loom
steps:
- uses: actions/checkout@v3
- name: Install latest nightly
Expand Down
13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@ harness = false

[features]
default = ["std"]
alloc = ["rarena-allocator/alloc", "crossbeam-skiplist/alloc", "dbutils/alloc"]
std = ["rarena-allocator/default", "crossbeam-skiplist/default", "bitflags/default", "dbutils/default", "among/default", "faststr?/default", "bytes?/default", "smol_str?/default"]

xxhash3 = ["dbutils/xxhash3"]
xxhash64 = ["dbutils/xxhash64"]
xxhash3 = ["dbutils/xxhash3", "std"]
xxhash64 = ["dbutils/xxhash64", "std"]

## only for miri testing
test-unsync = ["std"]
test-swmr = ["std"]
test-swmr-generic = ["std"]

[dependencies]
among = { version = "0.1", default-features = false }
Expand All @@ -39,7 +43,10 @@ faststr = { version = "0.2", default-features = false, optional = true }
tracing = { version = "0.1", optional = true }

[dev-dependencies]
arbitrary = { version = "1", features = ["derive"] }
criterion = "0.5"
names = "0.14"
rand = "0.8"
tempfile = "3"

[profile.bench]
Expand Down
2 changes: 1 addition & 1 deletion ci/miri_sb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-symbolic-alignment-check"

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
Expand Down
2 changes: 1 addition & 1 deletion ci/miri_sb_generic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ 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 MIRIFLAGS="-Zmiri-disable-isolation -Zmiri-symbolic-alignment-check"

cargo miri test --tests --all-features
2 changes: 1 addition & 1 deletion ci/miri_tb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ 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 MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-tree-borrows"

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
Expand Down
2 changes: 1 addition & 1 deletion ci/miri_tb_generic.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ 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 MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-tree-borrows"

cargo miri test --tests --all-features
13 changes: 13 additions & 0 deletions ci/miri_tb_swmr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

export MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-tree-borrows"

cargo miri test --tests --target x86_64-unknown-linux-gnu --features test-swmr
# 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 --features test-swmr
cargo miri test --tests --target powerpc64-unknown-linux-gnu --features test-swmr
13 changes: 13 additions & 0 deletions ci/miri_tb_swmr_generic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

export MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-tree-borrows"

cargo miri test --tests --target x86_64-unknown-linux-gnu --features test-swmr-generic
# 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 --features test-swmr-generic
cargo miri test --tests --target powerpc64-unknown-linux-gnu --features test-swmr-generic
13 changes: 13 additions & 0 deletions ci/miri_tb_unsync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
set -e

rustup toolchain install nightly --component miri
rustup override set nightly
cargo miri setup

export MIRIFLAGS="-Zmiri-symbolic-alignment-check -Zmiri-disable-isolation -Zmiri-tree-borrows"

cargo miri test --tests --target x86_64-unknown-linux-gnu --features test-unsync
# 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 --features test-unsync
cargo miri test --tests --target powerpc64-unknown-linux-gnu --features test-unsync
Loading
Loading