aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/fuzz/fuzz_targets
diff options
context:
space:
mode:
authorPascal Hertleif <[email protected]>2018-09-08 15:55:53 +0100
committerPascal Hertleif <[email protected]>2018-09-08 15:55:53 +0100
commita37cd5ad43f28e2eddab713266517cf06c256ba7 (patch)
tree910bfe4935460d6022cfe897897cf84814482d3e /crates/libsyntax2/fuzz/fuzz_targets
parentdf05c5c3e20cfdfccd0165dd3370fed7c3676cd0 (diff)
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).
Diffstat (limited to 'crates/libsyntax2/fuzz/fuzz_targets')
-rw-r--r--crates/libsyntax2/fuzz/fuzz_targets/parser.rs12
1 files changed, 12 insertions, 0 deletions
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 @@
1#![no_main]
2#[macro_use] extern crate libfuzzer_sys;
3extern crate libsyntax2;
4
5fuzz_target!(|data: &[u8]| {
6 if let Ok(text) = std::str::from_utf8(data) {
7 let x = libsyntax2::File::parse(text);
8 let _ = x.ast();
9 let _ = x.syntax();
10 let _ = x.errors();
11 }
12});