Add roundtrip-roundtrip fuzz target.

This commit is contained in:
Chris Fallin 2021-12-24 14:29:32 -08:00
parent d5342a0a6a
commit 110fe11fa8
3 changed files with 21 additions and 0 deletions

View file

@ -33,3 +33,9 @@ name = "roundtrip"
path = "fuzz_targets/roundtrip.rs"
test = false
doc = false
[[bin]]
name = "roundtrip_roundtrip"
path = "fuzz_targets/roundtrip_roundtrip.rs"
test = false
doc = false

View file

@ -0,0 +1,14 @@
#![no_main]
use libfuzzer_sys::fuzz_target;
use waffle::Module;
fuzz_target!(|module: wasm_smith::Module| {
let _ = env_logger::try_init();
log::debug!("original module: {:?}", module);
let orig_bytes = module.to_bytes();
let parsed_module = Module::from_wasm_bytes(&orig_bytes[..]).unwrap();
let roundtrip_bytes = parsed_module.to_wasm_bytes();
let parsed_roundtrip_module = Module::from_wasm_bytes(&roundtrip_bytes[..]).unwrap();
let _ = parsed_roundtrip_module.to_wasm_bytes();
});

View file

@ -169,6 +169,7 @@ pub fn produce_func_wasm<FT: FuncTypeSink>(
for operator in &body.operators {
ctx.translate(operator, locations);
}
wasm.operators.push(wasm_encoder::Instruction::End);
wasm
}