Start experimenting with cargo fuzz. This isn't very usable yet.
This commit is contained in:
3
fuzz/.gitignore
vendored
Normal file
3
fuzz/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
target
|
||||||
|
corpus
|
||||||
|
artifacts
|
||||||
34
fuzz/Cargo.toml
Normal file
34
fuzz/Cargo.toml
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
[package]
|
||||||
|
name = "wasmstandalone_fuzz"
|
||||||
|
version = "0.0.1"
|
||||||
|
authors = ["The Cretonne Project Developers"]
|
||||||
|
publish = false
|
||||||
|
|
||||||
|
[package.metadata]
|
||||||
|
cargo-fuzz = true
|
||||||
|
|
||||||
|
[dependencies.wasmstandalone_runtime]
|
||||||
|
path = "../lib/runtime"
|
||||||
|
|
||||||
|
[dependencies.wasmstandalone_execute]
|
||||||
|
path = "../lib/execute"
|
||||||
|
|
||||||
|
[dependencies.cretonne]
|
||||||
|
git = "https://github.com/stoklund/cretonne.git"
|
||||||
|
|
||||||
|
[dependencies.cretonne-wasm]
|
||||||
|
git = "https://github.com/stoklund/cretonne.git"
|
||||||
|
|
||||||
|
[dependencies.cretonne-native]
|
||||||
|
git = "https://github.com/stoklund/cretonne.git"
|
||||||
|
|
||||||
|
[dependencies.libfuzzer-sys]
|
||||||
|
git = "https://github.com/rust-fuzz/libfuzzer-sys.git"
|
||||||
|
|
||||||
|
# Prevent this from interfering with workspaces
|
||||||
|
[workspace]
|
||||||
|
members = ["."]
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "compile"
|
||||||
|
path = "fuzz_targets/compile.rs"
|
||||||
28
fuzz/fuzz_targets/compile.rs
Normal file
28
fuzz/fuzz_targets/compile.rs
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#![no_main]
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate libfuzzer_sys;
|
||||||
|
extern crate cretonne;
|
||||||
|
extern crate cton_wasm;
|
||||||
|
extern crate cton_native;
|
||||||
|
extern crate wasmstandalone_runtime;
|
||||||
|
extern crate wasmstandalone_execute;
|
||||||
|
|
||||||
|
use cretonne::settings;
|
||||||
|
use cton_wasm::translate_module;
|
||||||
|
|
||||||
|
fuzz_target!(|data: &[u8]| {
|
||||||
|
let (flag_builder, isa_builder) = cton_native::builders().unwrap_or_else(|_| {
|
||||||
|
panic!("host machine is not a supported target");
|
||||||
|
});
|
||||||
|
let isa = isa_builder.finish(settings::Flags::new(&flag_builder));
|
||||||
|
let mut runtime = wasmstandalone_runtime::Runtime::with_flags(isa.flags().clone());
|
||||||
|
let translation = match translate_module(&data, &mut runtime) {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err(_) => return,
|
||||||
|
};
|
||||||
|
let _exec = match wasmstandalone_execute::compile_module(&translation, &*isa, &runtime) {
|
||||||
|
Ok(x) => x,
|
||||||
|
Err(_) => return,
|
||||||
|
};
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user