Add roundtrip-roundtrip fuzz target.
This commit is contained in:
parent
d5342a0a6a
commit
110fe11fa8
|
@ -33,3 +33,9 @@ name = "roundtrip"
|
||||||
path = "fuzz_targets/roundtrip.rs"
|
path = "fuzz_targets/roundtrip.rs"
|
||||||
test = false
|
test = false
|
||||||
doc = false
|
doc = false
|
||||||
|
|
||||||
|
[[bin]]
|
||||||
|
name = "roundtrip_roundtrip"
|
||||||
|
path = "fuzz_targets/roundtrip_roundtrip.rs"
|
||||||
|
test = false
|
||||||
|
doc = false
|
||||||
|
|
14
fuzz/fuzz_targets/roundtrip_roundtrip.rs
Normal file
14
fuzz/fuzz_targets/roundtrip_roundtrip.rs
Normal 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();
|
||||||
|
});
|
|
@ -169,6 +169,7 @@ pub fn produce_func_wasm<FT: FuncTypeSink>(
|
||||||
for operator in &body.operators {
|
for operator in &body.operators {
|
||||||
ctx.translate(operator, locations);
|
ctx.translate(operator, locations);
|
||||||
}
|
}
|
||||||
|
wasm.operators.push(wasm_encoder::Instruction::End);
|
||||||
|
|
||||||
wasm
|
wasm
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue