From e734190c24d2a5aca5b62c2b1ab7e6136017a25c Mon Sep 17 00:00:00 2001 From: pcpthm Date: Fri, 22 Mar 2019 02:05:12 +0900 Subject: Refactor parser fuzz testing --- crates/ra_syntax/fuzz/Cargo.toml | 8 ++++---- crates/ra_syntax/fuzz/fuzz_targets/parser.rs | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/ra_syntax/fuzz') diff --git a/crates/ra_syntax/fuzz/Cargo.toml b/crates/ra_syntax/fuzz/Cargo.toml index 4a255882e..c54d12813 100644 --- a/crates/ra_syntax/fuzz/Cargo.toml +++ b/crates/ra_syntax/fuzz/Cargo.toml @@ -4,14 +4,14 @@ name = "ra_syntax-fuzz" version = "0.0.1" authors = ["rust-analyzer developers"] publish = false +edition = "2018" [package.metadata] cargo-fuzz = true -[dependencies.ra_syntax] -path = ".." -[dependencies.libfuzzer-sys] -git = "https://github.com/rust-fuzz/libfuzzer-sys.git" +[dependencies] +ra_syntax = { path = ".." } +libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } # Prevent this from interfering with workspaces [workspace] diff --git a/crates/ra_syntax/fuzz/fuzz_targets/parser.rs b/crates/ra_syntax/fuzz/fuzz_targets/parser.rs index 4667d5579..76a8b08d0 100644 --- a/crates/ra_syntax/fuzz/fuzz_targets/parser.rs +++ b/crates/ra_syntax/fuzz/fuzz_targets/parser.rs @@ -1,9 +1,9 @@ #![no_main] -#[macro_use] extern crate libfuzzer_sys; -extern crate ra_syntax; +use libfuzzer_sys::fuzz_target; +use ra_syntax::fuzz::check_parser; fuzz_target!(|data: &[u8]| { if let Ok(text) = std::str::from_utf8(data) { - ra_syntax::check_fuzz_invariants(text) + check_parser(text) } }); -- cgit v1.2.3 From 4c7142d0c9be90c8947deb788993d903b2e0a5d1 Mon Sep 17 00:00:00 2001 From: pcpthm Date: Fri, 22 Mar 2019 02:06:48 +0900 Subject: Add fuzz test for reparsing --- crates/ra_syntax/fuzz/Cargo.toml | 5 +++++ crates/ra_syntax/fuzz/fuzz_targets/reparse.rs | 9 +++++++++ 2 files changed, 14 insertions(+) create mode 100644 crates/ra_syntax/fuzz/fuzz_targets/reparse.rs (limited to 'crates/ra_syntax/fuzz') diff --git a/crates/ra_syntax/fuzz/Cargo.toml b/crates/ra_syntax/fuzz/Cargo.toml index c54d12813..613ad2857 100644 --- a/crates/ra_syntax/fuzz/Cargo.toml +++ b/crates/ra_syntax/fuzz/Cargo.toml @@ -11,6 +11,7 @@ cargo-fuzz = true [dependencies] ra_syntax = { path = ".." } +ra_text_edit = { path = "../../ra_text_edit" } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } # Prevent this from interfering with workspaces @@ -20,3 +21,7 @@ members = ["."] [[bin]] name = "parser" path = "fuzz_targets/parser.rs" + +[[bin]] +name = "reparse" +path = "fuzz_targets/reparse.rs" diff --git a/crates/ra_syntax/fuzz/fuzz_targets/reparse.rs b/crates/ra_syntax/fuzz/fuzz_targets/reparse.rs new file mode 100644 index 000000000..45524d4c1 --- /dev/null +++ b/crates/ra_syntax/fuzz/fuzz_targets/reparse.rs @@ -0,0 +1,9 @@ +#![no_main] +use libfuzzer_sys::fuzz_target; +use ra_syntax::fuzz::CheckReparse; + +fuzz_target!(|data: &[u8]| { + if let Some(check) = CheckReparse::from_data(data) { + check.run(); + } +}); -- cgit v1.2.3