From 6370e1103417e1edafe540604c9fe002839d866b Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Fri, 8 Nov 2019 11:10:44 -0800 Subject: [PATCH] Fuzz all the backends. --- fuzz/Cargo.toml | 2 ++ fuzz/fuzz_targets/compile_wasm.rs | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 713443355..8d6a38140 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -12,6 +12,8 @@ cargo-fuzz = true wasmer-runtime = { path = "../lib/runtime" } wasmer-runtime-core = { path = "../lib/runtime-core" } wasmer = { path = "../" } +wasmer-llvm-backend = { path = "../lib/llvm-backend" } +wasmer-singlepass-backend = { path = "../lib/singlepass-backend" } libfuzzer-sys = { git = "https://github.com/rust-fuzz/libfuzzer-sys.git" } # Prevent this from interfering with workspaces diff --git a/fuzz/fuzz_targets/compile_wasm.rs b/fuzz/fuzz_targets/compile_wasm.rs index 4abe062f5..e36d8c396 100644 --- a/fuzz/fuzz_targets/compile_wasm.rs +++ b/fuzz/fuzz_targets/compile_wasm.rs @@ -2,9 +2,24 @@ #[macro_use] extern crate libfuzzer_sys; extern crate wasmer_runtime; +extern crate wasmer_runtime_core; +extern crate wasmer_llvm_backend; +extern crate wasmer_singlepass_backend; -use wasmer_runtime::compile; +use wasmer_runtime::{compile, compile_with}; +use wasmer_runtime_core::backend::Compiler; + +fn get_llvm_compiler() -> impl Compiler { + use wasmer_llvm_backend::LLVMCompiler; + LLVMCompiler::new() +} +fn get_singlepass_compiler() -> impl Compiler { + use wasmer_singlepass_backend::SinglePassCompiler; + SinglePassCompiler::new() +} fuzz_target!(|data: &[u8]| { + let _ = compile_with(data, &get_llvm_compiler()); let _ = compile(data); + let _ = compile_with(data, &get_singlepass_compiler()); });