os

package
v1.18.0-rc.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FillDisk

func FillDisk(t *testing.T, path string)

FillDisk writes 1MiB chunks to path until ENOSPC. Linux can defer ENOSPC reporting until Close (or fsync), so failure from either Write or Close satisfies the helper.

func InUnshareNamespace

func InUnshareNamespace() bool

InUnshareNamespace reports whether the current process is running inside an unshare user+mount namespace (e.g. invoked via `unshare -Umr`). Assumes the outer test runner is NOT root.

func MountTmpfs

func MountTmpfs(t *testing.T, sizeMiB int) string

MountTmpfs mounts a size-capped tmpfs at a fresh t.TempDir() and registers umount via t.Cleanup. Requires InUnshareNamespace() to be true.

func MustLinux

func MustLinux(t *testing.T)

func ReexecInUserNamespace

func ReexecInUserNamespace(t *testing.T, ctx context.Context) bool

ReexecInUserNamespace returns false if already inside an unshare user+mount namespace (caller should run the rest of its test body). Otherwise re-runs this single integration test case inside one via `unshare -Umr`, then returns true on success so the caller can return without running the body twice, or calls t.Fatalf on subprocess failure. The subprocess's ports framework auto-detects it is inside a namespace (mapped euid 0) and probes ports from a high base to avoid collisions with the parent's reservations.

func SkipMacOS added in v1.17.2

func SkipMacOS(t *testing.T)

func SkipUnlessUnshareAvailable

func SkipUnlessUnshareAvailable(t *testing.T)

SkipUnlessUnshareAvailable skips the test unless `unshare -Umr` is actually usable: `unshare` must be on PATH, unprivileged user namespaces must be enabled by the kernel, and the current process must be able to set up the uid_map mapping.

func SkipWindows

func SkipWindows(t *testing.T)

func WriteFileTo added in v1.17.2

func WriteFileTo(t *testing.T, name, data string)

func WriteFileYaml added in v1.17.2

func WriteFileYaml(t *testing.T, data string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

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