MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / TestPanicInHostFunctionDuringInstantiate

Function TestPanicInHostFunctionDuringInstantiate

linker_test.go:245–267  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

243}
244
245func TestPanicInHostFunctionDuringInstantiate(t *testing.T) {
246 engine := NewEngine()
247 linker := NewLinker(engine)
248 store := NewStore(engine)
249 err := linker.FuncWrap("foo", "bar", func() {
250 panic("hi")
251 })
252 require.NoError(t, err)
253
254 wasm, err := Wat2Wasm(`
255 (module
256 (import "foo" "bar" (func))
257 (start 0)
258 )
259 `)
260 require.NoError(t, err)
261
262 module, err := NewModule(engine, wasm)
263 require.NoError(t, err)
264 require.PanicsWithValue(t, "hi", func() {
265 linker.Instantiate(store, module)
266 })
267}
268
269func TestPanicInHostFunctionDuringCall(t *testing.T) {
270 engine := NewEngine()

Callers

nothing calls this directly

Calls 7

FuncWrapMethod · 0.95
InstantiateMethod · 0.95
NewEngineFunction · 0.85
NewLinkerFunction · 0.85
NewStoreFunction · 0.85
Wat2WasmFunction · 0.85
NewModuleFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…