testutils

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package testutils links the L3B dataplane type constructors for shared-memory tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewStorage

func NewStorage(t *testing.T) string

NewStorage loads the production L3B module and inert object types into a ready fixture without creating workers or active configuration.

func ReadModuleCounterIDs

func ReadModuleCounterIDs(module ffi.ModuleConfig, count int) ([]uint64, error)

ReadModuleCounterIDs copies IDs from an idle, live unpublished module candidate.

func ReadRealRing added in v0.4.0

func ReadRealRing(agent *ffi.Agent, name string, capacity uint32) ([]uint32, error)

ReadRealRing copies installed selector indexes without processing packets.

The caller keeps the agent alive and runs no concurrent mutations.

func SessionCapacityErrno added in v0.4.0

func SessionCapacityErrno(indexSize uint32) syscall.Errno

SessionCapacityErrno reports native admission using an empty allocator.

Types

type AllocationWitness

type AllocationWitness struct {
	Matches            uint64
	RegisteredCounters uint64
	ReservedBlocks     uint64
	ReservedBytes      uint64
	Exhausted          bool
}

AllocationWitness proves successful registration and complete arena exhaustion.

func WithRealServerAllocationFailure

func WithRealServerAllocationFailure(
	service string,
	operation func() error,
) (witness AllocationWitness, err error)

WithRealServerAllocationFailure exhausts an idle arena after two real counters.

The operation must keep its agent alive and perform only synchronous candidate construction with two reals. Reservations are released before returning, even on panic; other users must not allocate or free from this arena concurrently.

type CounterFailure

type CounterFailure struct {
	Name             string
	Size             uint64
	RegisteredBefore uint64
}

CounterFailure describes one semantic registration boundary and its prefix.

func RequiredCounterFailures

func RequiredCounterFailures() []CounterFailure

RequiredCounterFailures selects every boundary for a service with two reals.

type CounterKey

type CounterKey struct {
	Name string
	Link bool
}

CounterKey distinguishes service counters from their module-link counters.

type CounterLink struct {
	Device     string
	Pipeline   string
	Function   string
	Chain      string
	ModuleType string
	Module     string
}

CounterLink identifies the module-to-service relation wired by a test.

type CounterState

type CounterState struct {
	Size   uint64
	Offset uint64
	Values [2]uint64
}

CounterState records the published mapping and its per-worker values.

type CounterWitness

type CounterWitness struct {
	Matches          uint64
	Failures         uint64
	RegisteredBefore uint64
}

CounterWitness proves the selected registry prefix reached one refusal.

func WithCounterFailure

func WithCounterFailure(
	service string,
	failure CounterFailure,
	operation func() error,
) (witness CounterWitness, err error)

WithCounterFailure refuses one registration during a synchronous operation.

Thread-local state is cleared on every exit, including panics. Untargeted registrations use the production implementation; this is not allocator OOM.

type LookupWitness

type LookupWitness struct {
	Lookups             []ServiceLookup
	CounterLookups      uint64
	UnprotectedObjects  uint64
	UnprotectedCounters uint64
	ProvenanceErrors    uint64
	RacingObjects       uint64
}

LookupWitness records real lookup hits, missing protection and provenance errors.

func WithLinkedServiceLookup

func WithLinkedServiceLookup(
	agent *ffi.Agent,
	operation func() error,
) (witness LookupWitness, err error)

WithLinkedServiceLookup observes a synchronous update without pinning its reads.

The caller keeps the agent alive. Thread-local observation is disarmed on every exit; unrelated threads and unarmed calls use the real implementation unchanged.

type PublishedCounterState

type PublishedCounterState struct {
	Service         uintptr
	Table           uintptr
	TableReferences uint64
	ObjectStorage   uintptr
	LinkStorage     uintptr
	Counters        map[CounterKey]CounterState
}

PublishedCounterState is a non-owning snapshot of a settled generation.

func ReadCounterState

func ReadCounterState(
	executionContext uintptr,
	service string,
	link CounterLink,
) (PublishedCounterState, error)

ReadCounterState snapshots both registries without changing their ownership.

The caller must keep the worker generation alive and run no concurrent config updates or packets while reading its ordinary counter values.

type ServiceLookup

type ServiceLookup struct {
	Generation       uintptr
	GenerationNumber uint64
	Object           uintptr
	CounterRegistry  uintptr
	CounterID        uint64
	// Racing marks a lookup diverted from the published generation by a
	// concurrent publication while its reader still held the pin; the
	// provenance fields above stay unset for it.
	Racing bool
}

ServiceLookup binds a copied counter ID to its protected generation and object.

Addresses are identity values, not handles that may be dereferenced afterward.

Jump to

Keyboard shortcuts

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