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.
In simplest case, dispatch:
func TestModuleEngine_Call(t *testing.T) { enginetest.RunTestModuleEngine_Call(t, NewEngine) }
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_MemoryGrowInRecursiveCall(t *testing.T, et EngineTester)
- func RunTestEngine_NewModuleEngine(t *testing.T, et EngineTester)
- func RunTestModuleEngine_BeforeListenerStackIterator(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_LookupFunction(t *testing.T, et EngineTester)
- func RunTestModuleEngine_Memory(t *testing.T, et EngineTester)
- type EngineTester
Functions ¶
func RunTestEngine_MemoryGrowInRecursiveCall ¶
func RunTestEngine_MemoryGrowInRecursiveCall(t *testing.T, et EngineTester)
RunTestEngine_MemoryGrowInRecursiveCall ensures that it's safe to grow memory in the recursive Wasm calls.
func RunTestEngine_NewModuleEngine ¶
func RunTestEngine_NewModuleEngine(t *testing.T, et EngineTester)
func RunTestModuleEngine_BeforeListenerStackIterator ¶
func RunTestModuleEngine_BeforeListenerStackIterator(t *testing.T, et EngineTester)
This tests that the StackIterator provided by the Engine to the Before hook of the listener is properly able to walk the stack. As an example, it validates that the following call stack is properly walked:
- f1(2,3,4) [no return, no local]
- calls f2(no arg) [1 return, 1 local]
- calls f3(5) [1 return, no local]
- calls f4(6) [1 return, HOST]
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_LookupFunction ¶
func RunTestModuleEngine_LookupFunction(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 { NewEngine(enabledFeatures api.CoreFeatures) wasm.Engine ListenerFactory() experimental.FunctionListenerFactory }
Source Files ¶
- Version
- v1.0.2
- Published
- Apr 18, 2023
- Platform
- linux/amd64
- Imports
- 10 packages
- Last checked
- 36 minutes ago –
Tools for package owners.