From 9ce0d259b47188d8c2f3701a5ebbbff7c20ac647 Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 29 Nov 2022 17:32:38 -0800 Subject: [PATCH] WIP. --- fuzz/fuzz_targets/straightline_differential.rs | 17 ++++++++++++++++- src/lib.rs | 4 ++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/fuzz/fuzz_targets/straightline_differential.rs b/fuzz/fuzz_targets/straightline_differential.rs index a2e59ec..291155d 100644 --- a/fuzz/fuzz_targets/straightline_differential.rs +++ b/fuzz/fuzz_targets/straightline_differential.rs @@ -1,5 +1,6 @@ #![no_main] use libfuzzer_sys::{arbitrary, fuzz_target}; +use std::sync::atomic::{AtomicU64, Ordering}; use waffle::Module; @@ -139,13 +140,15 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { }; let parsed_module = Module::from_wasm_bytes(&orig_bytes[..]).unwrap(); - let roundtrip_bytes = parsed_module.to_wasm_bytes(); + let roundtrip_bytes = parsed_module.to_wasm_bytes().unwrap(); if let Ok(filename) = std::env::var("FUZZ_DUMP_WASM") { std::fs::write(format!("{}_orig.wasm", filename), &orig_bytes[..]).unwrap(); std::fs::write(format!("{}_roundtrip.wasm", filename), &roundtrip_bytes[..]).unwrap(); } + let total = TOTAL.fetch_add(1, Ordering::Relaxed); + let roundtrip_module = wasmtime::Module::new(&engine, &roundtrip_bytes[..]) .expect("failed to parse roundtripped wasm"); let roundtrip_instance = wasmtime::Instance::new(&mut store, &roundtrip_module, &[]) @@ -193,4 +196,16 @@ fuzz_target!(|module: wasm_smith::ConfiguredModule| { let b_data = b.data(&store); assert_eq!(a_data, b_data); } + + success(total); }); + +static TOTAL: AtomicU64 = AtomicU64::new(0); +static SUCCESS: AtomicU64 = AtomicU64::new(0); + +fn success(total: u64) { + let value = SUCCESS.fetch_add(1, Ordering::Relaxed); + if value % 1000 == 0 { + eprintln!("SUCCESS: {} / TOTAL: {}", value, total); + } +} diff --git a/src/lib.rs b/src/lib.rs index 7fd4848..eb0af2f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,14 +8,14 @@ pub use wasmparser; mod backend; pub mod cfg; pub mod entity; +mod errors; mod frontend; mod ir; mod op_traits; mod ops; pub mod passes; mod scoped_map; -mod errors; +pub use errors::*; pub use ir::*; pub use ops::{Ieee32, Ieee64, Operator}; -pub use errors::*;