Documentation
¶
Index ¶
- func FillDisk(t *testing.T, path string)
- func InUnshareNamespace() bool
- func MountTmpfs(t *testing.T, sizeMiB int) string
- func MustLinux(t *testing.T)
- func ReexecInUserNamespace(t *testing.T, ctx context.Context) bool
- func SkipMacOS(t *testing.T)
- func SkipUnlessUnshareAvailable(t *testing.T)
- func SkipWindows(t *testing.T)
- func WriteFileTo(t *testing.T, name, data string)
- func WriteFileYaml(t *testing.T, data string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FillDisk ¶
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 ¶
MountTmpfs mounts a size-capped tmpfs at a fresh t.TempDir() and registers umount via t.Cleanup. Requires InUnshareNamespace() to be true.
func ReexecInUserNamespace ¶
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 SkipUnlessUnshareAvailable ¶
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 WriteFileTo ¶ added in v1.17.2
Types ¶
This section is empty.