faultinject

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: Apache-2.0 Imports: 5 Imported by: 0 modules, 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

Overview

Package faultinject provides named checkpoints for self-update fault tests.

Release builds compile Point to an inlinable no-op. Builds tagged selfupdate_faults read DMG_FAULT=<checkpoint>[@user|@system]:<action>[,...] (merged with the link-time Baked value) and act at the matching checkpoint. Actions: kill (os.Exit(137), no cleanup), err (return ErrInjected), hang (block until killed), diskfull (return an error wrapping the OS disk-full errno), panic (a real Go panic, so recovery paths run), sleep<duration> (block that long, Go duration syntax up to 10m, then continue), exit<N> (os.Exit(N)). S6.mutex fires with the scan instance mutex held. With DMG_FAULT_TRACE=<file>, every reached checkpoint name is appended to file.

Checkpoint names may contain ':' (S4.downloaded:<asset>); the action is the text after the last ':'.

Index

Constants

View Source
const Enabled = false

Enabled reports whether fault injection is compiled in.

View Source
const MalformedExitCode = 64

MalformedExitCode is how a fault build exits on a malformed DMG_FAULT or Baked spec: distinct from every fault action and from a Go panic (2), so it can't pass for a crash.

View Source
const MalformedMarker = "faultinject: malformed spec:"

MalformedMarker starts the stderr line written before that exit; drivers fail the test when they see it.

View Source
const MaxSleep = 10 * time.Minute

MaxSleep bounds the sleep<duration> action.

Variables

View Source
var ErrInjected = errors.New("faultinject: injected fault")

ErrInjected is wrapped by every error Point returns for an injected fault.

Functions

func Point

func Point(string) error

Point is a no-op without the selfupdate_faults build tag.

func Validate

func Validate(spec string) error

Validate checks a DMG_FAULT / Baked spec. Test drivers and harnesses call it before launching a process with one, so a typo fails at setup. It is available in every build and reads no environment.

Types

This section is empty.

Jump to

Keyboard shortcuts

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