Skip to content

Commit

Permalink
test: add basic fuzz
Browse files Browse the repository at this point in the history
  • Loading branch information
snormore committed Apr 24, 2024
1 parent 96a0937 commit bac54f3
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
64 changes: 64 additions & 0 deletions fuzz/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "owned_ref_cell-fuzz"
version = "0.0.0"
publish = false
edition = "2021"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.owned_ref_cell]
path = ".."

[[bin]]
name = "fuzz_basic_borrows"
path = "fuzz_targets/fuzz_basic_borrows.rs"
test = false
doc = false
bench = false
20 changes: 20 additions & 0 deletions fuzz/fuzz_targets/fuzz_basic_borrows.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use owned_ref_cell::OwnedRefCell;

fuzz_target!(|data: &[u8]| {
let mut cell = OwnedRefCell::new(0);

for &byte in data.iter() {
match byte % 3 {
0 => {
let _ = cell.try_borrow();
}
1 => {
let _ = cell.try_borrow_mut();
}
_ => {}
}
}
});

0 comments on commit bac54f3

Please sign in to comment.