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

Function TestPanicInHostFunctionDuringCallWithCaller

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

Source from the content-addressed store, hash-verified

295}
296
297func TestPanicInHostFunctionDuringCallWithCaller(t *testing.T) {
298 engine := NewEngine()
299 linker := NewLinker(engine)
300 store := NewStore(engine)
301 err := linker.FuncWrap("foo", "bar", func(c *Caller) int32 {
302 panic("hi")
303 })
304 require.NoError(t, err)
305
306 wasm, err := Wat2Wasm(`
307 (module
308 (import "foo" "bar" (func (result i32)))
309 (func (export "foo") call 0 drop)
310 )
311 `)
312 require.NoError(t, err)
313
314 module, err := NewModule(engine, wasm)
315 require.NoError(t, err)
316 instance, err := linker.Instantiate(store, module)
317 require.NoError(t, err)
318 foo := instance.GetFunc(store, "foo")
319 require.NotNil(t, foo)
320 require.PanicsWithValue(t, "hi", func() {
321 foo.Call(store)
322 })
323}

Callers

nothing calls this directly

Calls 9

FuncWrapMethod · 0.95
InstantiateMethod · 0.95
NewEngineFunction · 0.85
NewLinkerFunction · 0.85
NewStoreFunction · 0.85
Wat2WasmFunction · 0.85
NewModuleFunction · 0.85
GetFuncMethod · 0.80
CallMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…