MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / log_wasm

Function log_wasm

crates/fuzzing/src/oracles.rs:54–79  ·  view source on GitHub ↗

Logs a wasm file to the filesystem to make it easy to figure out what wasm was used when debugging.

(wasm: &[u8])

Source from the content-addressed store, hash-verified

52/// Logs a wasm file to the filesystem to make it easy to figure out what wasm
53/// was used when debugging.
54pub fn log_wasm(wasm: &[u8]) {
55 super::init_fuzzing();
56
57 if !log::log_enabled!(log::Level::Debug) {
58 return;
59 }
60
61 let i = CNT.fetch_add(1, SeqCst);
62 let name = format!("testcase{i}.wasm");
63 std::fs::write(&name, wasm).expect("failed to write wasm file");
64 log::debug!("wrote wasm file to `{name}`");
65 let wat = format!("testcase{i}.wat");
66 match wasmprinter::print_bytes(wasm) {
67 Ok(s) => {
68 std::fs::write(&wat, s).expect("failed to write wat file");
69 log::debug!("wrote wat file to `{wat}`");
70 }
71 // If wasmprinter failed remove a `*.wat` file, if any, to avoid
72 // confusing a preexisting one with this wasm which failed to get
73 // printed.
74 Err(e) => {
75 log::debug!("failed to print to wat: {e}");
76 drop(std::fs::remove_file(&wat));
77 }
78 }
79}
80
81/// The `T` in `Store<T>` for fuzzing stores, used to limit resource
82/// consumption during fuzzing.

Callers 10

compile_moduleFunction · 0.85
gc_opsFunction · 0.85
exception_opsFunction · 0.85
static_api_testFunction · 0.85
gc_accessFunction · 0.85
make_api_callsFunction · 0.85
check_memory_accessesFunction · 0.85
check_stacksFunction · 0.85
execute_oneFunction · 0.85

Calls 5

init_fuzzingFunction · 0.85
print_bytesFunction · 0.85
writeFunction · 0.50
dropFunction · 0.50
expectMethod · 0.45

Tested by

no test coverage detected