testutils

package
v0.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: Apache-2.0, UNKNOWN, UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const MaxParallelEnv = "GNO_TEST_MAX_PARALLEL"

MaxParallelEnv pins the worker counts derived in this file. Setting it opts out of scaling to fit the machine, which is occasionally useful when profiling or bisecting a memory problem.

Variables

This section is empty.

Functions

func CaptureStdoutAndStderr

func CaptureStdoutAndStderr() func() (string, error)

CaptureStdoutAndStderr temporarily pipes os.Stdout and os.Stderr into a buffer. Imported from https://github.com/moul/u/blob/master/io.go.

func FilterStability

func FilterStability(t *testing.T, mode StabilityMode)

func MaxParallel

func MaxParallel() int

MaxParallel reports how many memory-heavy workers a test suite may run concurrently, for suites that must fix the count up front — a pool of GnoVM stores, say, as opposed to workers started one at a time, which can instead ramp against MemInfo.

Such workers cost hundreds of megabytes of live heap each, so sizing their concurrency off GOMAXPROCS — the default for `go test` parallelism — makes peak memory scale with the core count. That is the wrong axis: these suites are bound by memory, not CPU, and stop getting faster well before they stop getting bigger.

func MaxParallelOverride

func MaxParallelOverride() (int, bool)

MaxParallelOverride reports the MaxParallelEnv setting, if it holds a positive integer.

func MutateByteSlice

func MutateByteSlice(bytez []byte) []byte

Contract: !bytes.Equal(input, output) && len(input) >= len(output) TODO: keep output size the same; search all usage first.

func NewTestCaseDir

func NewTestCaseDir(t *testing.T) (string, func())

NewTestCaseDir creates a new temporary directory for a test case. Returns the directory path and a cleanup function.

func NewTestFile

func NewTestFile(t *testing.T) (*os.File, func())

NewTestFile creates a new temporary file for a test case

Types

type MemInfo

type MemInfo struct {
	// Total is the machine's physical memory.
	Total uint64

	// Available is the kernel's estimate of what can still be allocated
	// without pushing the system into swap. Unlike free memory it accounts for
	// reclaimable caches, and it falls as this process's heap grows — which is
	// what makes it usable as a feedback signal for admitting more workers.
	Available uint64
}

MemInfo is a snapshot of the machine's memory, in bytes.

func ReadMemInfo

func ReadMemInfo() (MemInfo, bool)

ReadMemInfo reports the memory this process may use, from /proc/meminfo narrowed by the memory limits of its cgroup and of every cgroup above it. It returns false if either figure is missing from /proc/meminfo, or if memory is under a cgroup v1 controller: its limits are not read here, and the host figures can sit far beyond them.

type StabilityMode

type StabilityMode string
const (
	Stable StabilityMode = "stable"
	Flappy StabilityMode = "flappy"
	Broken StabilityMode = "broken"
)

Jump to

Keyboard shortcuts

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