test: switch from roundtrip based tests to e2e based fuzzers#59
Conversation
for more information, see https://pre-commit.ci
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Pull request overview
This PR refactors the fuzzing infrastructure to use oracle-based testing, where the C++ implementation serves as a reference to verify the Rust implementation's correctness. It builds upon PR #58 which introduced the unified CodecToSlice trait API. The testing strategy shifts from simple roundtrip tests to end-to-end oracle comparisons that compare both compressed output and decompression results between Rust and C++ implementations.
Changes:
- Introduces unified
CodecToSlice<In, Out = In>trait implementations for both Rust and C++ codecs - Replaces roundtrip-based fuzzers with oracle-based fuzzers that compare Rust implementation against C++
- Moves
Integer<u32>implementation frominteger_codec.rstocodec.rsfor better code organization
Reviewed changes
Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/lib.rs |
Adds the CodecToSlice trait definition for unified compression API |
src/rust/integer_compression/codec.rs |
Implements CodecToSlice for Rust Codec enum and moves Integer<u32> impl here |
src/rust/integer_compression/integer_codec.rs |
Removes duplicate Integer<u32> impl (moved to codec.rs) |
src/rust/error.rs |
Adds InvalidInputLength error variant for input size validation |
src/cpp/mod.rs |
Implements CodecToSlice for C++ codecs (both 32-bit and 64-bit variants) and adds tests |
fuzz/fuzz_targets/fastpfor_rust.rs |
Removed old roundtrip-based fuzzer |
fuzz/fuzz_targets/cpp_roundtrip.rs |
New comprehensive roundtrip fuzzer for C++ codecs |
fuzz/fuzz_targets/rust_compress_oracle.rs |
New oracle fuzzer comparing Rust compression against C++ |
fuzz/fuzz_targets/rust_decompress_oracle.rs |
New oracle fuzzer comparing Rust decompression against C++ |
fuzz/Cargo.toml |
Updates fuzzer binary definitions |
fuzz/README.md |
Updates documentation for new fuzzing approach |
.github/workflows/ci.yml |
Updates CI to run new fuzzer targets |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #[derive(arbitrary::Arbitrary, Debug)] | ||
| struct FuzzInput { | ||
| data: Vec<u32>, | ||
| codec: FuzzCodec, | ||
| } | ||
|
|
||
| #[derive(arbitrary::Arbitrary, Debug, Clone, Copy, PartialEq, Eq)] | ||
| enum FuzzCodec { | ||
| FastPFOR256, | ||
| FastPFOR128, | ||
| VariableByte, | ||
| JustCopy, | ||
| } | ||
|
|
||
| impl From<FuzzCodec> for rust::Codec { | ||
| fn from(codec: FuzzCodec) -> Self { | ||
| match codec { | ||
| FuzzCodec::FastPFOR256 => rust::Codec::from(rust::FastPFOR::new( | ||
| rust::DEFAULT_PAGE_SIZE, | ||
| rust::BLOCK_SIZE_256, | ||
| )), | ||
| FuzzCodec::FastPFOR128 => rust::Codec::from(rust::FastPFOR::new( | ||
| rust::DEFAULT_PAGE_SIZE, | ||
| rust::BLOCK_SIZE_128, | ||
| )), | ||
| FuzzCodec::VariableByte => rust::Codec::from(rust::VariableByte::new()), | ||
| FuzzCodec::JustCopy => rust::Codec::from(rust::JustCopy::new()), | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The FuzzInput and FuzzCodec structures, along with the From implementation, are duplicated across both rust_compress_oracle.rs and rust_decompress_oracle.rs. Consider extracting these shared types into a common module (e.g., fuzz/common.rs or similar) to reduce duplication and ensure consistency.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This is stacked on top of #58