Skip to content

Commit

Permalink
Refactor pica-format crate (#809)
Browse files Browse the repository at this point in the history
Signed-off-by: Nico Wagner <[email protected]>
  • Loading branch information
nwagner84 authored Aug 28, 2024
1 parent 590aee0 commit 3057f9e
Show file tree
Hide file tree
Showing 9 changed files with 442 additions and 372 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,11 @@ jobs:
strategy:
matrix:
item:
- { name: pica-record-ref, fuzz-dir: crates/pica-record/fuzz, target: fuzz-record-ref, max-total-time: 300 }
- { name: pica-format, fuzz-dir: crates/pica-format/fuzz, target: fuzz-format, max-total-time: 300 }
- { name: pica-path, fuzz-dir: crates/pica-path/fuzz, target: fuzz-path, max-total-time: 300 }
- { name: pica-record-matcher, fuzz-dir: crates/pica-matcher/fuzz, target: fuzz-record-matcher, max-total-time: 300 }
- { name: pica-record-ref, fuzz-dir: crates/pica-record/fuzz, target: fuzz-record-ref, max-total-time: 300 }
- { name: pica-select-query, fuzz-dir: crates/pica-select/fuzz, target: fuzz-query, max-total-time: 300 }
- { name: pica-path, fuzz-dir: crates/pica-path/fuzz, target: fuzz-path, max-total-time: 300 }
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@nightly
Expand Down
1 change: 1 addition & 0 deletions crates/pica-format/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ rust-version.workspace = true

[dependencies]
bstr = { workspace = true }
pica-matcher = { workspace = true }
pica-record = { workspace = true }
thiserror = { workspace = true }
winnow = { workspace = true, features = ["simd"] }
Expand Down
4 changes: 4 additions & 0 deletions crates/pica-format/fuzz/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
target
corpus
artifacts
coverage
24 changes: 24 additions & 0 deletions crates/pica-format/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "pica-format-fuzz"
version = "0.0.0"
publish = false
edition = "2021"

[package.metadata]
cargo-fuzz = true

[dependencies]
libfuzzer-sys = "0.4"

[dependencies.pica-format]
path = ".."

[workspace]
members = ["."]

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

use std::str::FromStr;

use libfuzzer_sys::fuzz_target;
use pica_format::Format;

fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let _format = Format::from_str(s);
}
});
Loading

0 comments on commit 3057f9e

Please sign in to comment.