From a37cd5ad43f28e2eddab713266517cf06c256ba7 Mon Sep 17 00:00:00 2001 From: Pascal Hertleif Date: Sat, 8 Sep 2018 16:55:53 +0200 Subject: Add trivial fuzzer for parser As described in #61, fuzz testing some parts of this would be ~~fun~~ helpful. So, I started with the most trivial fuzzer I could think of: Put random stuff into File::parse and see what happens. To speed things up, I also did cp src/**/*.rs fuzz/corpus/parser/ in the `crates/libsyntax2/` directory (running the fuzzer once will generate the necessary directories). --- crates/libsyntax2/fuzz/fuzz_targets/parser.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 crates/libsyntax2/fuzz/fuzz_targets/parser.rs (limited to 'crates/libsyntax2/fuzz/fuzz_targets') diff --git a/crates/libsyntax2/fuzz/fuzz_targets/parser.rs b/crates/libsyntax2/fuzz/fuzz_targets/parser.rs new file mode 100644 index 000000000..f941855e8 --- /dev/null +++ b/crates/libsyntax2/fuzz/fuzz_targets/parser.rs @@ -0,0 +1,12 @@ +#![no_main] +#[macro_use] extern crate libfuzzer_sys; +extern crate libsyntax2; + +fuzz_target!(|data: &[u8]| { + if let Ok(text) = std::str::from_utf8(data) { + let x = libsyntax2::File::parse(text); + let _ = x.ast(); + let _ = x.syntax(); + let _ = x.errors(); + } +}); -- cgit v1.2.3