feat: add fuzz testing

This commit is contained in:
PoiScript 2019-01-12 14:51:21 +08:00
parent a335929801
commit f35c2d7bab
3 changed files with 37 additions and 0 deletions

3
fuzz/.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
target
corpus
artifacts

21
fuzz/Cargo.toml Normal file
View file

@ -0,0 +1,21 @@
[package]
name = "org-fuzz"
version = "0.0.1"
authors = ["Automatically generated"]
publish = false
[package.metadata]
cargo-fuzz = true
[dependencies.org]
path = ".."
[dependencies.libfuzzer-sys]
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "fuzz_target_1"
path = "fuzz_targets/fuzz_target_1.rs"

View file

@ -0,0 +1,13 @@
#![no_main]
#[macro_use]
extern crate libfuzzer_sys;
extern crate org;
use org::Parser;
#[cfg_attr(rustfmt, rustfmt_skip)]
fuzz_target!(|data: &[u8]| {
if let Ok(s) = std::str::from_utf8(data) {
let _ = Parser::new(s).collect::<Vec<_>>();
}
});