cgrouptest

package standard library
go1.25rc2 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2025 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Overview

Package cgrouptest provides best-effort helpers for running tests inside a cgroup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InCgroupV2

func InCgroupV2(t *testing.T, fn func(*CgroupV2))

InCgroupV2 creates a new v2 cgroup, migrates the current process into it, and then calls fn. When fn returns, the current process is migrated back to the original cgroup and the new cgroup is destroyed.

If a new cgroup cannot be created, the test is skipped.

This must not be used in parallel tests, as it affects the entire process.

Types

type CgroupV2

type CgroupV2 struct {
	// contains filtered or unexported fields
}

func (*CgroupV2) CPUMaxPath

func (c *CgroupV2) CPUMaxPath() string

Path to cpu.max.

func (*CgroupV2) Path

func (c *CgroupV2) Path() string

func (*CgroupV2) SetCPUMax

func (c *CgroupV2) SetCPUMax(quota, period int64) error

Set cpu.max. Pass -1 for quota to disable the limit.

Jump to

Keyboard shortcuts

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