Skip to content

Add comprehensive fuzz testing infrastructure with cargo-fuzz#309

Draft
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-299
Draft

Add comprehensive fuzz testing infrastructure with cargo-fuzz#309
Copilot wants to merge 3 commits into
masterfrom
copilot/fix-299

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jun 10, 2025

This PR adds comprehensive fuzz testing capabilities to the micromap crate using cargo-fuzz, significantly improving test coverage and helping ensure the highest possible quality for our tests.

What's Added

Three Comprehensive Fuzz Targets

  1. map_operations - Tests fundamental Map operations:

    • Insert, get, remove operations
    • Clear and retain functionality
    • Uses u8 keys/values with capacity 16
    • Validates basic invariants and memory safety
  2. set_operations - Tests Set operations:

    • Insert, contains, remove operations
    • Set-specific methods: is_disjoint, is_subset, is_superset
    • Uses u8 values with capacity 16
    • Tests interaction between different sets
  3. edge_cases - Tests complex scenarios:

    • Different map capacities (1, 4, 8, 32)
    • Entry API operations
    • Complex predicates and iteration consistency
    • Uses u16 keys/values for broader input space
    • Stress-tests invariants across operations

Documentation

  • Added detailed fuzz/README.md with usage instructions
  • Updated main README.md with fuzz testing section
  • Includes examples for running different targets and continuous fuzzing

Usage

# Install prerequisites
rustup toolchain install nightly
cargo install cargo-fuzz

# Run fuzz tests
cargo +nightly fuzz run map_operations
cargo +nightly fuzz run set_operations  
cargo +nightly fuzz run edge_cases

Benefits

  • Memory Safety: Validates no undefined behavior in release mode
  • Edge Case Discovery: Automatically finds corner cases we might miss
  • Continuous Testing: Can run indefinitely to catch rare issues
  • Regression Prevention: Corpus grows over time, preventing regressions

The fuzz targets have already been tested and successfully explore many code paths, providing confidence in the robustness of the micromap implementation.

Fixes #299.

Co-authored-by: yegor256 <526301+yegor256@users.noreply.github.com>
Copilot AI changed the title [WIP] we don't use fuzz testing Add comprehensive fuzz testing infrastructure with cargo-fuzz Jun 10, 2025
Copilot AI requested a review from yegor256 June 10, 2025 15:38
@yegor256
Copy link
Copy Markdown
Owner

@owtotwo what do you think about this contribution, from AI?

@yegor256
Copy link
Copy Markdown
Owner

@copilot thanks for your contribution, but you broke a few CI pipelines. Please, fix your code to make them pass.

Co-authored-by: yegor256 <526301+yegor256@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jun 10, 2025

@copilot thanks for your contribution, but you broke a few CI pipelines. Please, fix your code to make them pass.

Fixed the CI pipeline failures. The issue was missing SPDX copyright headers in the fuzz test files. Added proper headers and updated REUSE.toml configuration. All CI checks now pass. (dc47794)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

we don't use fuzz testing

2 participants