package enginetest
import "github.com/tetratelabs/wazero/internal/testing/enginetest"
Package enginetest contains tests common to any wasm.Engine implementation. Defining these as top-level functions is less burden than copy/pasting the implementations, while still allowing test caching to operate.
Ex. In simplest case, dispatch:
func TestModuleEngine_Call(t *testing.T) { enginetest.RunTestModuleEngine_Call(t, NewEngine) }
Ex. Some tests using the Compiler Engine may need to guard as they use compiled features:
func TestModuleEngine_Call(t *testing.T) { requireSupportedOSArch(t) enginetest.RunTestModuleEngine_Call(t, NewEngine) }
Note: These tests intentionally avoid using wasm.Store as it is important to know both the dependencies and the capabilities at the wasm.Engine abstraction.
Index ¶
- func RunTestEngine_InitializeFuncrefGlobals(t *testing.T, et EngineTester)
- func RunTestEngine_NewModuleEngine(t *testing.T, et EngineTester)
- func RunTestEngine_NewModuleEngine_InitTable(t *testing.T, et EngineTester)
- func RunTestModuleEngine_Call(t *testing.T, et EngineTester)
- func RunTestModuleEngine_Call_Errors(t *testing.T, et EngineTester)
- func RunTestModuleEngine_Call_HostFn(t *testing.T, et EngineTester)
- func RunTestModuleEngine_Memory(t *testing.T, et EngineTester)
- type EngineTester
Functions ¶
func RunTestEngine_InitializeFuncrefGlobals ¶
func RunTestEngine_InitializeFuncrefGlobals(t *testing.T, et EngineTester)
func RunTestEngine_NewModuleEngine ¶
func RunTestEngine_NewModuleEngine(t *testing.T, et EngineTester)
func RunTestEngine_NewModuleEngine_InitTable ¶
func RunTestEngine_NewModuleEngine_InitTable(t *testing.T, et EngineTester)
func RunTestModuleEngine_Call ¶
func RunTestModuleEngine_Call(t *testing.T, et EngineTester)
func RunTestModuleEngine_Call_Errors ¶
func RunTestModuleEngine_Call_Errors(t *testing.T, et EngineTester)
func RunTestModuleEngine_Call_HostFn ¶
func RunTestModuleEngine_Call_HostFn(t *testing.T, et EngineTester)
func RunTestModuleEngine_Memory ¶
func RunTestModuleEngine_Memory(t *testing.T, et EngineTester)
RunTestModuleEngine_Memory shows that the byte slice returned from api.Memory Read is not a copy, rather a re-slice of the underlying memory. This allows both host and Wasm to see each other's writes, unless one side changes the capacity of the slice.
Known cases that change the slice capacity: * Host code calls append on a byte slice returned by api.Memory Read * Wasm code calls wasm.OpcodeMemoryGrowName and this changes the capacity (by default, it will).
Types ¶
type EngineTester ¶
type EngineTester interface { // IsCompiler returns true if this engine is a compiler. IsCompiler() bool NewEngine(enabledFeatures wasm.Features) wasm.Engine ListenerFactory() experimental.FunctionListenerFactory // InitTables returns expected table contents ([]wasm.Reference) per table. InitTables(me wasm.ModuleEngine, tableIndexToLen map[wasm.Index]int, tableInits []wasm.TableInitEntry) [][]wasm.Reference // CompiledFunctionPointerValue returns the opaque compiledFunction's pointer for the `funcIndex`. CompiledFunctionPointerValue(tme wasm.ModuleEngine, funcIndex wasm.Index) uint64 }
Source Files ¶
- Version
- v1.0.0-beta.1
- Published
- Aug 30, 2022
- Platform
- linux/amd64
- Imports
- 9 packages
- Last checked
- 3 minutes ago –
Tools for package owners.