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

Function call_exported_func

crates/fuzzing/tests/oom/instance.rs:10–45  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9#[test]
10fn call_exported_func() -> Result<()> {
11 let module_bytes = {
12 let mut config = Config::new();
13 config.concurrency_support(false);
14 let engine = Engine::new(&config)?;
15 let module = Module::new(
16 &engine,
17 r#"
18 (module
19 (func (export "add") (param i32 i32) (result i32)
20 (i32.add (local.get 0) (local.get 1))
21 )
22 )
23 "#,
24 )?;
25 module.serialize()?
26 };
27
28 let mut config = Config::new();
29 config.enable_compiler(false);
30 config.concurrency_support(false);
31 let engine = Engine::new(&config)?;
32
33 let module = unsafe { Module::deserialize(&engine, &module_bytes)? };
34 let linker = Linker::<()>::new(&engine);
35 let instance_pre = linker.instantiate_pre(&module)?;
36
37 OomTest::new().test(|| {
38 let mut store = Store::try_new(&engine, ())?;
39 let instance = instance_pre.instantiate(&mut store)?;
40 let add = instance.get_typed_func::<(i32, i32), i32>(&mut store, "add")?;
41 let result = add.call(&mut store, (1, 2))?;
42 assert_eq!(result, 3);
43 Ok(())
44 })
45}
46
47#[test]
48fn instance_new() -> Result<()> {

Callers

nothing calls this directly

Calls 11

OkFunction · 0.85
enable_compilerMethod · 0.80
newFunction · 0.50
deserializeFunction · 0.50
try_newFunction · 0.50
concurrency_supportMethod · 0.45
serializeMethod · 0.45
instantiate_preMethod · 0.45
testMethod · 0.45
instantiateMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected