Skip to content

Commit

Permalink
Configure wasm-smith to generate no imports to match our empty import…
Browse files Browse the repository at this point in the history
… object.
  • Loading branch information
nlewycky committed Mar 15, 2021
1 parent fe8a94d commit 400d99f
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 12 deletions.
14 changes: 11 additions & 3 deletions fuzz/fuzz_targets/jit_cranelift.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule};
use wasmer::{imports, CompilerConfig, Instance, Module, Store};
use wasmer_compiler_cranelift::Cranelift;
use wasmer_engine_jit::JIT;
use wasm_smith::Module as FuzzModule;

fuzz_target!(|module: FuzzModule| {
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
struct NoImportsConfig;
impl Config for NoImportsConfig {
fn max_imports(&self) -> usize {
0
}
}

fuzz_target!(|module: ConfiguredModule<NoImportsConfig>| {
let wasm_bytes = module.to_bytes();
let mut compiler = Cranelift::default();
compiler.canonicalize_nans(true);
Expand Down
15 changes: 12 additions & 3 deletions fuzz/fuzz_targets/jit_llvm.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule};
use wasmer::{imports, CompilerConfig, Instance, Module, Store};
use wasmer_compiler_llvm::LLVM;
use wasmer_engine_jit::JIT;
use wasm_smith::Module as FuzzModule;

fuzz_target!(|module: FuzzModule| {
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
struct NoImportsConfig;
impl Config for NoImportsConfig {
fn max_imports(&self) -> usize {
0
}
}

fuzz_target!(|module: ConfiguredModule<NoImportsConfig>| {
let wasm_bytes = module.to_bytes();

let mut compiler = LLVM::default();
compiler.canonicalize_nans(true);
compiler.enable_verifier();
Expand Down
14 changes: 11 additions & 3 deletions fuzz/fuzz_targets/jit_singlepass.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use wasm_smith::Module as FuzzModule;
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule};
use wasmer::{imports, Instance, Module, Store};
use wasmer_compiler_singlepass::Singlepass;
use wasmer_engine_jit::JIT;

fuzz_target!(|module: FuzzModule| {
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
struct NoImportsConfig;
impl Config for NoImportsConfig {
fn max_imports(&self) -> usize {
0
}
}

fuzz_target!(|module: ConfiguredModule<NoImportsConfig>| {
let wasm_bytes = module.to_bytes();
let compiler = Singlepass::default();
let store = Store::new(&JIT::new(compiler).engine());
Expand Down
14 changes: 11 additions & 3 deletions fuzz/fuzz_targets/native_cranelift.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
#![no_main]

use libfuzzer_sys::fuzz_target;
use libfuzzer_sys::{arbitrary, arbitrary::Arbitrary, fuzz_target};
use wasm_smith::{Config, ConfiguredModule};
use wasmer::{imports, Instance, Module, Store};
use wasmer_compiler_cranelift::Cranelift;
use wasmer_engine_native::Native;
use wasm_smith::Module as FuzzModule;

fuzz_target!(|module: FuzzModule| {
#[derive(Arbitrary, Debug, Default, Copy, Clone)]
struct NoImportsConfig;
impl Config for NoImportsConfig {
fn max_imports(&self) -> usize {
0
}
}

fuzz_target!(|module: ConfiguredModule<NoImportsConfig>| {
let serialized = {
let wasm_bytes = module.to_bytes();
let compiler = Cranelift::default();
Expand Down

0 comments on commit 400d99f

Please sign in to comment.