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

Function smoke

tests/all/compile_time_builtins.rs:7–91  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5#[test]
6#[cfg_attr(miri, ignore)]
7fn smoke() -> Result<()> {
8 let engine = Engine::default();
9 let linker = component::Linker::new(&engine);
10
11 let component = unsafe {
12 CodeBuilder::new(&engine)
13 .expose_unsafe_intrinsics("unsafe-intrinsics")
14 .compile_time_builtins_binary_or_text(
15 "host-api",
16 r#"
17 (component
18 (import "unsafe-intrinsics"
19 (instance $intrinsics
20 (export "store-data-address" (func (result u64)))
21 (export "u8-native-load" (func (param "pointer" u64) (result u8)))
22 )
23 )
24
25 (core func $store-data-address' (canon lower (func $intrinsics "store-data-address")))
26 (core func $u8-native-load' (canon lower (func $intrinsics "u8-native-load")))
27
28 (core module $m
29 (import "" "store-data-address" (func $store-data-address (result i64)))
30 (import "" "u8-native-load" (func $u8-native-load (param i64) (result i32)))
31 (func (export "get") (result i32)
32 (call $u8-native-load (call $store-data-address))
33 )
34 )
35
36 (core instance $i
37 (instantiate $m
38 (with "" (instance (export "store-data-address" (func $store-data-address'))
39 (export "u8-native-load" (func $u8-native-load'))))
40 )
41 )
42
43 (func (export "get") (result u8)
44 (canon lift (core func $i "get"))
45 )
46 )
47 "#.as_bytes(),
48 Some(Path::new("host-api.wat")),
49 )?
50 .wasm_binary_or_text(
51 r#"
52 (component
53 (import "host-api"
54 (instance $host-api
55 (export "get" (func (result u8)))
56 )
57 )
58
59 (core func $get' (canon lower (func $host-api "get")))
60
61 (core module $m
62 (import "" "get" (func $get (result i32)))
63 (func (export "double-get") (result i32)
64 (i32.add (call $get) (call $get))

Callers

nothing calls this directly

Calls 9

OkFunction · 0.85
wasm_binary_or_textMethod · 0.80
as_bytesMethod · 0.80
newFunction · 0.50
compile_componentMethod · 0.45
instantiateMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected