Documentation
¶
Index ¶
- Constants
- func CaptureStdoutAndStderr() func() (string, error)
- func FilterStability(t *testing.T, mode StabilityMode)
- func MaxParallel() int
- func MaxParallelOverride() (int, bool)
- func MutateByteSlice(bytez []byte) []byte
- func NewTestCaseDir(t *testing.T) (string, func())
- func NewTestFile(t *testing.T) (*os.File, func())
- type MemInfo
- type StabilityMode
Constants ¶
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 ¶
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 ¶
MaxParallelOverride reports the MaxParallelEnv setting, if it holds a positive integer.
func MutateByteSlice ¶
Contract: !bytes.Equal(input, output) && len(input) >= len(output) TODO: keep output size the same; search all usage first.
func NewTestCaseDir ¶
NewTestCaseDir creates a new temporary directory for a test case. Returns the directory path and a cleanup function.
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 ¶
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" )