generator

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Param not address taken.
	StructTfIdx = iota
	ArrayTfIdx
	MapTfIdx
	PointerTfIdx
	NumericTfIdx
	FloatTfIdx
	ComplexTfIdx
	ByteTfIdx
	StringTfIdx
)
View Source
const (
	// Param not address taken.
	SkipAll     = -1
	SkipNone    = 0
	SkipPayload = 1
)
View Source
const (
	RandCtlNochecks = 0
	RandCtlChecks   = 1 << iota
	RandCtlCapture
	RandCtlPanic
)
View Source
const CallerName = "Caller"
View Source
const CheckerName = "Checker"

Variables

View Source
var Verbctl int = 0

Functions

func Generate

func Generate(c GenConfig) int

Generate is the top level code generation hook for this package. Emits code according to the schema in config object 'c'.

func NewWrapRand

func NewWrapRand(seed int64, ctl int) *wraprand

func ParseMaskString

func ParseMaskString(arg string, tag string) (map[int]int, error)

ParseMaskString parses a string of the form K,J,...,M-N,Q-R,...,Z e.g. comma-separated integers or ranges of integers, returning the result in a form suitable for FcnMask or PkgMask fields in a Config. Here "tag" holds the mask flavor (fcn or pkg) and "arg" is the string argument to be parsed.

func SetTunables

func SetTunables(t TunableParams)

SetTunables accepts a TunableParams object, checks to make sure that the settings in it are sane/logical, and applies the parameters for any subsequent calls to the Generate function. This function will issue a fatal error if any of the tunable params are incorrect/insane (for example, a 'percentage' value outside the range of 0-100).

Types

type GenConfig

type GenConfig struct {
	// Tag is a string prefix prepended to functions within
	// the generated code.
	Tag string

	// Output directory in to which we'll emit generated code.
	// This will be created if it does not exist.
	OutDir string

	// Packagepath prefix given to the generated code.
	PkgPath string

	// Number of test packages created within the generated corpus.
	// Each test package is essentially an independent collection
	// generated code; the point of having multiple packages is to
	// be able to get faster builds (more parallelism), and to avoid
	// the compile time issues that crop up with 'giant' packages.
	NumTestPackages int

	// Number of test function pairs within each generated test package.
	// Each pair consists of a "caller" function and  "callee" function.
	NumTestFunctions int

	// Seed for random number generator.
	Seed int64

	// Pragma is a "// go:..." compiler directive to apply to the
	// callee function as part of a generated function pair.
	Pragma string

	// Function and package mask used for minimization purposes.
	// If a given mask is non-nil, then the generator will only
	// emit code for a given func or package if its index is
	// present in the mask map.
	FcnMask map[int]int
	PkgMask map[int]int

	// Maximum number of failures to encounter before bailing out.
	MaxFail int

	// forcestackgrowth if set tells the generator to insert
	// calls to runtime.gcTestMoveStackOnNextCall at various points
	// in the generated code.
	ForceStackGrowth bool

	// Random number generator control flag (debugging)
	RandCtl int

	// Tells the generator to run "goimports" on the emitted code.
	RunGoImports bool

	// Debugging/testing hook. If set to 1, emit code that will cause the
	// build to fail; if set to 2, emit code that will cause a test to fail.
	EmitBad int

	// If EmitBad above is set, then these can be used to select the ID of
	// a specific bad func/package.
	BadPackageIdx int
	BadFuncIdx    int
}

GenConfig contains configuration parameters relating to the mechanics of the code generation, e.g. how many packages/functions to emit, path to a directory into which we place the generated code, prefixes/packagenames for the generate code, and so on.

type TunableParams

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

TunableParams contains configuration parameters that control the flavor of code generated for a given test function. This includes things like the number of params/returns, the percentages of types (int, struct, etc) of the params/returns, and so on.

func DefaultTunables

func DefaultTunables() TunableParams

func (*TunableParams) DisableDefer

func (t *TunableParams) DisableDefer()

func (*TunableParams) DisableMethodCalls

func (t *TunableParams) DisableMethodCalls()

func (*TunableParams) DisableRecursiveCalls

func (t *TunableParams) DisableRecursiveCalls()

func (*TunableParams) DisableReflectionCalls

func (t *TunableParams) DisableReflectionCalls()

func (*TunableParams) DisableTakeAddr

func (t *TunableParams) DisableTakeAddr()

func (*TunableParams) LimitInputs

func (t *TunableParams) LimitInputs(n int) error

func (*TunableParams) LimitOutputs

func (t *TunableParams) LimitOutputs(n int) error

Jump to

Keyboard shortcuts

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