diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-09-08 16:20:46 +0100 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2018-09-08 16:20:46 +0100 |
commit | a60b9ad963db87c6431de7a9b57e0d2241efdeab (patch) | |
tree | 910bfe4935460d6022cfe897897cf84814482d3e /crates | |
parent | df05c5c3e20cfdfccd0165dd3370fed7c3676cd0 (diff) | |
parent | a37cd5ad43f28e2eddab713266517cf06c256ba7 (diff) |
Merge #63
63: Add trivial fuzzer for parser r=matklad a=killercup
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).
Co-authored-by: Pascal Hertleif <[email protected]>
Diffstat (limited to 'crates')
-rw-r--r-- | crates/libsyntax2/fuzz/.gitignore | 4 | ||||
-rw-r--r-- | crates/libsyntax2/fuzz/Cargo.toml | 22 | ||||
-rw-r--r-- | crates/libsyntax2/fuzz/fuzz_targets/parser.rs | 12 |
3 files changed, 38 insertions, 0 deletions
diff --git a/crates/libsyntax2/fuzz/.gitignore b/crates/libsyntax2/fuzz/.gitignore new file mode 100644 index 000000000..572e03bdf --- /dev/null +++ b/crates/libsyntax2/fuzz/.gitignore | |||
@@ -0,0 +1,4 @@ | |||
1 | |||
2 | target | ||
3 | corpus | ||
4 | artifacts | ||
diff --git a/crates/libsyntax2/fuzz/Cargo.toml b/crates/libsyntax2/fuzz/Cargo.toml new file mode 100644 index 000000000..916cd5b6f --- /dev/null +++ b/crates/libsyntax2/fuzz/Cargo.toml | |||
@@ -0,0 +1,22 @@ | |||
1 | |||
2 | [package] | ||
3 | name = "libsyntax2-fuzz" | ||
4 | version = "0.0.1" | ||
5 | authors = ["Automatically generated"] | ||
6 | publish = false | ||
7 | |||
8 | [package.metadata] | ||
9 | cargo-fuzz = true | ||
10 | |||
11 | [dependencies.libsyntax2] | ||
12 | path = ".." | ||
13 | [dependencies.libfuzzer-sys] | ||
14 | git = "https://github.com/rust-fuzz/libfuzzer-sys.git" | ||
15 | |||
16 | # Prevent this from interfering with workspaces | ||
17 | [workspace] | ||
18 | members = ["."] | ||
19 | |||
20 | [[bin]] | ||
21 | name = "parser" | ||
22 | path = "fuzz_targets/parser.rs" | ||
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; | ||
3 | extern crate libsyntax2; | ||
4 | |||
5 | fuzz_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 | }); | ||