enginetest

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2023 License: Apache-2.0 Imports: 10 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.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

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunTestEngine_InitializeFuncrefGlobals

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

func RunTestEngine_NewModuleEngine

func RunTestEngine_NewModuleEngine(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_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 {
	// IsCompiler returns true if this engine is a compiler.
	IsCompiler() bool

	NewEngine(enabledFeatures api.CoreFeatures) wasm.Engine

	ListenerFactory() experimental.FunctionListenerFactory

	// CompiledFunctionPointerValue returns the opaque compiledFunction's pointer for the `funcIndex`.
	CompiledFunctionPointerValue(tme wasm.ModuleEngine, funcIndex wasm.Index) uint64
}

Jump to

Keyboard shortcuts

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