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

Function TestPanicInHostFunctionDuringCall

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

Source from the content-addressed store, hash-verified

267}
268
269func TestPanicInHostFunctionDuringCall(t *testing.T) {
270 engine := NewEngine()
271 linker := NewLinker(engine)
272 store := NewStore(engine)
273 err := linker.FuncWrap("foo", "bar", func() {
274 panic("hi")
275 })
276 require.NoError(t, err)
277
278 wasm, err := Wat2Wasm(`
279 (module
280 (import "foo" "bar" (func))
281 (func (export "foo") call 0)
282 )
283 `)
284 require.NoError(t, err)
285
286 module, err := NewModule(engine, wasm)
287 require.NoError(t, err)
288 instance, err := linker.Instantiate(store, module)
289 require.NoError(t, err)
290 foo := instance.GetFunc(store, "foo")
291 require.NotNil(t, foo)
292 require.PanicsWithValue(t, "hi", func() {
293 foo.Call(store)
294 })
295}
296
297func TestPanicInHostFunctionDuringCallWithCaller(t *testing.T) {
298 engine := NewEngine()

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…