os

package
v1.19.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 13 Imported by: 1 module, 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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FillDisk added in v1.18.0

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 added in v1.18.0

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 added in v1.18.0

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 added in v1.18.0

func MustLinux(t *testing.T)

func ReexecInUserNamespace added in v1.18.0

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 SkipNotWindows added in v1.19.0

func SkipNotWindows(t *testing.T)

func SkipUnlessUnshareAvailable added in v1.18.0

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 WriteFileHeld added in v1.19.0

func WriteFileHeld(t *testing.T, _ string, _ []byte) (release func())

WriteFileHeld holds a file without sharing, which only Windows can do.

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