Skip to content

Commit

Permalink
Merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
finnbear committed Jan 7, 2025
2 parents 21793d1 + 6046426 commit fd91a36
Show file tree
Hide file tree
Showing 15 changed files with 538 additions and 19 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
components: rustfmt
- name: Check formatting
run: cargo fmt --all -- --check
- name: Check formatting (fuzzer)
run: cargo fmt --manifest-path fuzz/Cargo.toml --all -- --check

clippy:
runs-on: ubuntu-latest
Expand All @@ -24,6 +26,8 @@ jobs:
components: clippy
- name: Run clippy
run: cargo clippy --all-targets --all-features -- -D warnings
- name: Run clippy (fuzzer)
run: cargo clippy --manifest-path fuzz/Cargo.toml --all-targets --all-features -- -D warnings

coverage:
runs-on: ubuntu-latest
Expand All @@ -41,6 +45,28 @@ jobs:
fail_ci_if_error: true
token: ${{ secrets.CODECOV_TOKEN }}

fuzz:
name: fuzz
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rust-src

- name: Install cargo-fuzz
uses: baptiste0928/cargo-install@v3
with:
crate: cargo-fuzz
locked: false

- name: Fuzz for a limited time
run: |
RUST_BACKTRACE=1 cargo fuzz run fuzz -- -max_total_time=60
build-and-test-no-simd:
name: CI with ${{ matrix.rust }} on ${{ matrix.os }} [no SIMD]
runs-on: ${{ matrix.os }}
Expand Down
6 changes: 6 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"rust-analyzer.linkedProjects": [
"./Cargo.toml",
"./fuzz/Cargo.toml",
]
}
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## 0.11.0 - 2025-??-??
- Fix panic on empty `DistanceTraverseIterator` [#117](https://github.com/svenstaro/bvh/pull/117) (thanks @finnbear)
- Fix center() for very large AABBs [#118](https://github.com/svenstaro/bvh/pull/118) (thanks @finnbear)
- Fix more cases where an empty BVH would panic [#116](https://github.com/svenstaro/bvh/pull/116) (thanks @finnbear)
- Add fuzzing suite [#113](https://github.com/svenstaro/bvh/pull/113) (thanks @finnbear)

## 0.10.0 - 2024-07-06
- Don't panic when traversing empty BVH [#106](https://github.com/svenstaro/bvh/pull/106) (thanks @finnbear)
- Implement ordered traverse [#98](https://github.com/svenstaro/bvh/pull/98) (thanks @dashedman)
Expand Down
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,25 @@ BVH requiring a check, thus leading to a higher intersection duration.

The benchmark suite uses features from the [test crate](https://doc.rust-lang.org/unstable-book/library-features/test.html) and therefore cannot be run on stable rust.
Using a nightly toolchain, run `cargo bench --features bench`.

## Testing

### Unit tests

This project aspires to be fully tested, and that starts with a unit test suite. Use
`cargo test` to run all the tests. The tests automatically run in CI, too. Contributors
are expected to add tests for all new functionality.

### Proptest

This project uses [`proptest`](https://altsysrq.github.io/proptest-book/) as a second
line of defense against bugs, allowing random instances of certain tests to be tested.
These tests run alongside unit-tests.

### Fuzzer

This project uses [`cargo fuzz`](https://rust-fuzz.github.io/book/cargo-fuzz.html) as
a third line of defense against bugs, meaning that the `fuzz/` directory was generated
using `cargo fuzz init`. At the moment, there is a single fuzz target, and running
`cargo fuzz run fuzz` will fuzz until an assertion is violated. The fuzzer automatically
runs in CI, too.
3 changes: 3 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
target
corpus
artifacts
28 changes: 28 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
[package]
name = "bvh-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"

[package.metadata]
cargo-fuzz = true

[dependencies]
arbitrary = { version = "1.4.1", features = ["derive"] }
libfuzzer-sys = "0.4"
nalgebra = "0.33"
ordered-float = { version = "4.6.0", features = ["arbitrary"] }

[dependencies.bvh]
path = ".."

# Prevent this from interfering with workspaces
[workspace]
members = ["."]

[[bin]]
name = "fuzz"
path = "fuzz_targets/fuzz.rs"
test = false
doc = false
Loading

0 comments on commit fd91a36

Please sign in to comment.