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

Function check_wasm

tests/all/native_debug/translate.rs:9–26  ·  view source on GitHub ↗
(wasm_path: &str, directives: &str)

Source from the content-addressed store, hash-verified

7use wasmtime::{Result, format_err};
8
9fn check_wasm(wasm_path: &str, directives: &str) -> Result<()> {
10 println!("check {wasm_path}");
11 let wasm = read(wasm_path)?;
12 let obj_file = NamedTempFile::new()?;
13 let obj_path = obj_file.path().to_str().unwrap();
14 compile_cranelift(&wasm, Some(wasm_path.as_ref()), None, obj_path)?;
15 let dump = get_dwarfdump(obj_path, DwarfDumpSection::DebugInfo)?;
16 let mut builder = CheckerBuilder::new();
17 builder
18 .text(directives)
19 .map_err(|e| format_err!("unable to build checker: {e:?}"))?;
20 let checker = builder.finish();
21 let check = checker
22 .explain(&dump, NO_VARIABLES)
23 .map_err(|e| format_err!("{e:?}"))?;
24 assert!(check.0, "didn't pass check {}", check.1);
25 Ok(())
26}
27
28#[test]
29#[ignore]

Calls 11

compile_craneliftFunction · 0.85
get_dwarfdumpFunction · 0.85
OkFunction · 0.85
to_strMethod · 0.80
readFunction · 0.50
newFunction · 0.50
unwrapMethod · 0.45
pathMethod · 0.45
as_refMethod · 0.45
textMethod · 0.45
finishMethod · 0.45