enginetest

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 6, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

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.RunTestModuleEngineCall(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.RunTestModuleEngineCall(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

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTestEngineMemoryGrowInRecursiveCall

func RunTestEngineMemoryGrowInRecursiveCall(t *testing.T, et EngineTester)

RunTestEngineMemoryGrowInRecursiveCall ensures that it's safe to grow memory in the recursive Wasm calls.

func RunTestEngineNewModuleEngine

func RunTestEngineNewModuleEngine(t *testing.T, et EngineTester)

func RunTestModuleEngineBeforeListenerGlobals

func RunTestModuleEngineBeforeListenerGlobals(t *testing.T, et EngineTester)

This tests that the Globals provided by the Engine to the Before hook of the listener is properly able to read the values of the globals.

func RunTestModuleEngineBeforeListenerStackIterator

func RunTestModuleEngineBeforeListenerStackIterator(t *testing.T, et EngineTester)

RunTestModuleEngineBeforeListenerStackIterator 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:

  1. f1(2,3,4) [no return, no local]
  2. calls f2(no arg) [1 return, 1 local]
  3. calls f3(5) [1 return, no local]
  4. calls f4(6) [1 return, HOST]

func RunTestModuleEngineCall

func RunTestModuleEngineCall(t *testing.T, et EngineTester)

func RunTestModuleEngineCallHostFn

func RunTestModuleEngineCallHostFn(t *testing.T, et EngineTester)

func RunTestModuleEngineCallWithStack

func RunTestModuleEngineCallWithStack(t *testing.T, et EngineTester)

func RunTestModuleEngineLookupFunction

func RunTestModuleEngineLookupFunction(t *testing.T, et EngineTester)

func RunTestModuleEngineMemory

func RunTestModuleEngineMemory(t *testing.T, et EngineTester)

RunTestModuleEngineMemory 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).

func RunTestModuleEngineStackIteratorOffset

func RunTestModuleEngineStackIteratorOffset(t *testing.T, et EngineTester)

func RunTestModuleEngine_Call_Errors

func RunTestModuleEngine_Call_Errors(t *testing.T, et EngineTester)

Types

type EngineTester

type EngineTester interface {
	NewEngine(enabledFeatures api.CoreFeatures) wasm.Engine

	ListenerFactory() experimental.FunctionListenerFactory
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL