Add fuzzing support

This commit is contained in:
Gabriel Majeri authored and Dzmitry Malyshau committed 2020-07-01 08:53:54 -04:00
1 parent 1f5008f673
commit de3024f6b2
4 files changed
+51

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
target
corpus
artifacts
+32
View File
@@ -0,0 +1,32 @@
[package]
name = "naga-fuzz"
version = "0.0.0"
authors = ["Automatically generated"]
publish = false
edition = "2018"
[package.metadata]
cargo-fuzz = true
[dependencies]
libfuzzer-sys = "0.3"
[dependencies.naga]
path = ".."
features = ["spirv"]
# Prevent this from interfering with workspaces
[workspace]
members = ["."]
[[bin]]
name = "spv_parser"
path = "fuzz_targets/spv_parser.rs"
test = false
doc = false
[[bin]]
name = "wgsl_parser"
path = "fuzz_targets/wgsl_parser.rs"
test = false
doc = false
+8
View File
@@ -0,0 +1,8 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use naga::front::spv::Parser;
fuzz_target!(|data: Vec<u32>| {
// Ensure the parser can handle potentially malformed data without crashing.
let _result = Parser::new(data.into_iter()).parse();
});
+8
View File
@@ -0,0 +1,8 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use naga::front::wgsl::Parser;
fuzz_target!(|data: String| {
// Ensure the parser can handle potentially malformed strings without crashing.
let _result = Parser::new().parse(&data);
});