gotools/cmd/signature-fuzzer/internal/fuzz-generator/generator.go

type GenConfig

const CallerName

const CheckerName

type 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).
func SetTunables(t TunableParams) {}

var defaultTypeFractions

const StructTfIdx

const ArrayTfIdx

const MapTfIdx

const PointerTfIdx

const NumericTfIdx

const FloatTfIdx

const ComplexTfIdx

const ByteTfIdx

const StringTfIdx

var tunables

func DefaultTunables() TunableParams {}

func checkTunables(t TunableParams) {}

func (t *TunableParams) DisableReflectionCalls() {}

func (t *TunableParams) DisableRecursiveCalls() {}

func (t *TunableParams) DisableMethodCalls() {}

func (t *TunableParams) DisableTakeAddr() {}

func (t *TunableParams) DisableDefer() {}

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

func (t *TunableParams) LimitOutputs(n 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 ParseMaskString(arg string, tag string) (map[int]int, error) {}

func writeCom(b *bytes.Buffer, i int) {}

var Verbctl

func verb(vlevel int, s string, a ...interface{}

type funcdef

type genstate

func (s *genstate) intFlavor() string {}

func (s *genstate) intBits() uint32 {}

func (s *genstate) floatBits() uint32 {}

func (s *genstate) genAddrTaken() addrTakenHow {}

func (s *genstate) pushTunables() {}

func (s *genstate) popTunables() {}

// redistributeFraction accepts a value 'toIncorporate' and updates
// 'typeFraction' to add in the values from 'toIncorporate' equally to
// all slots not in 'avoid'. This is done by successively walking
// through 'typeFraction' adding 1 to each non-avoid slot, then
// repeating until we've added a total of 'toIncorporate' elements.
// See precludeSelectedTypes below for more info.
func (s *genstate) redistributeFraction(toIncorporate uint8, avoid []int) {}

// precludeSelectedTypes accepts a set of values (t, t2, ...)
// corresponding to slots in 'typeFractions', sums up the values from
// the slots, zeroes out the slots, and finally takes the values and
// redistributes them equally to the other slots.  For example,
// suppose 'typeFractions' starts as [10, 10, 10, 15, 20, 15, 5, 5, 10],
// then we decide we want to eliminate or 'knock out' map types and
// pointer types (slots 2 and 3 in the array above) going forward.  To
// restore the invariant that values in 'typeFractions' sum to 100, we
// take the values from slots 2 and 3 (a total of 25) and evenly
// distribute those values to the other slots in the array.
func (s *genstate) precludeSelectedTypes(t int, t2 ...int) {}

func (s *genstate) GenMapKeyType(f *funcdef, depth int, pidx int) parm {}

func (s *genstate) GenParm(f *funcdef, depth int, mkctl bool, pidx int) parm {}

func (s *genstate) GenReturn(f *funcdef, depth int, pidx int) parm {}

// GenFunc cooks up the random signature (and other attributes) of a
// given checker function, returning a funcdef object that describes
// the new fcn.
func (s *genstate) GenFunc(fidx int, pidx int) *funcdef {}

func genDeref(p parm) (parm, string) {}

func (s *genstate) eqFuncRef(f *funcdef, t parm, caller bool) string {}

// emitCompareFunc creates an 'equals' function for a specific
// generated type (this is basically a way to compare objects that
// contain pointer fields / pointery things).
func (s *genstate) emitCompareFunc(f *funcdef, b *bytes.Buffer, p parm) {}

// emitStructAndArrayDefs writes out definitions of the random types
// we happened to cook up while generating code for a specific
// function pair.
func (s *genstate) emitStructAndArrayDefs(f *funcdef, b *bytes.Buffer) {}

// GenValue method of genstate wraps the parm method of the same
// name, but optionally returns a call to a function to produce
// the value as opposed to a literal value.
func (s *genstate) GenValue(f *funcdef, p parm, value int, caller bool) (string, int) {}

func (s *genstate) emitMapKeyTmps(f *funcdef, b *bytes.Buffer, pidx int, value int, caller bool) int {}

func (s *genstate) emitCheckReturnsInCaller(f *funcdef, b *bytes.Buffer, pidx int, reflectCall bool) {}

func (s *genstate) emitCaller(f *funcdef, b *bytes.Buffer, pidx int) {}

func checkableElements(p parm) int {}

type funcdesc

func (s *genstate) emitDerefFuncs(b *bytes.Buffer, emit bool) {}

func (s *genstate) emitAssignFuncs(b *bytes.Buffer, emit bool) {}

func (s *genstate) emitNewFuncs(b *bytes.Buffer, emit bool) {}

func (s *genstate) emitGlobalVars(b *bytes.Buffer, emit bool) {}

func (s *genstate) emitGenValFuncs(f *funcdef, b *bytes.Buffer, emit bool) {}

func (s *genstate) emitAddrTakenHelpers(f *funcdef, b *bytes.Buffer, emit bool) {}

func (s *genstate) genGlobVar(p parm) string {}

func (s *genstate) genParamDerefFunc(p parm) string {}

func (s *genstate) genAssignFunc(p parm) string {}

func (s *genstate) genAllocFunc(p parm) string {}

func (s *genstate) genParamRef(p parm, idx int) string {}

func (s *genstate) genReturnAssign(b *bytes.Buffer, r parm, idx int, val string) {}

func (s *genstate) emitParamElemCheck(f *funcdef, b *bytes.Buffer, p parm, pvar string, cvar string, paramidx int, elemidx int) {}

func (s *genstate) emitParamChecks(f *funcdef, b *bytes.Buffer, pidx int, value int) (int, bool) {}

// emitDeferChecks creates code like
//
//	defer func(...args...) {
//	  check arg
//	  check param
//	}(...)
//
// where we randomly choose to either pass a param through to the
// function literal, or have the param captured by the closure, then
// check its value in the defer.
func (s *genstate) emitDeferChecks(f *funcdef, b *bytes.Buffer, pidx int, value int) int {}

func (s *genstate) emitVarAssign(f *funcdef, b *bytes.Buffer, r parm, rname string, value int, caller bool) int {}

func (s *genstate) emitChecker(f *funcdef, b *bytes.Buffer, pidx int, emit bool) {}

// complexityMeasure returns an integer that estimates how complex a
// given test function is relative to some other function. The more
// parameters + returns and the more complicated the types of the
// params/returns, the higher the number returned here. In theory this
// could be worked into the minimization process (e.g. pick the least
// complex func that reproduces the failure), but for now that isn't
// wired up yet.
func (f *funcdef) complexityMeasure() int {}

// emitRecursiveCall generates a recursive call to the test function in question.
func (s *genstate) emitRecursiveCall(f *funcdef) string {}

// emitReturn generates a return sequence.
func (s *genstate) emitReturn(f *funcdef, b *bytes.Buffer, doRecursiveCall bool) {}

func (s *genstate) GenPair(calloutfile *os.File, checkoutfile *os.File, fidx int, pidx int, b *bytes.Buffer, seed int64, emit bool) int64 {}

func (s *genstate) openOutputFile(filename string, pk string, imports []string, ipref string) *os.File {}

type miscVals

const utilsTemplate

func (s *genstate) emitUtils(outf *os.File, maxfail int, numtpk int) {}

const mainPreamble

func (s *genstate) emitMain(outf *os.File, numit int, fcnmask map[int]int, pkmask map[int]int) {}

func makeDir(d string) {}

func (s *genstate) callerPkg(which int) string {}

func (s *genstate) callerFile(which int) string {}

func (s *genstate) checkerPkg(which int) string {}

func (s *genstate) checkerFile(which int) string {}

func (s *genstate) utilsPkg() string {}

func (s *genstate) beginPackage(pkidx int) {}

func runImports(files []string) {}

// shouldEmitFP returns true if we should actually emit code for the function
// with the specified package + fcn indices. For "regular" runs, fcnmask and pkmask
// will be empty, meaning we want to emit every function in every package. The
// fuzz-runner program also tries to do testcase "minimization", which means that it
// will try to whittle down the set of packages and functions (by running the generator
// using the fcnmask and pkmask options) to emit only specific packages or functions.
func shouldEmitFP(fn int, pk int, fcnmask map[int]int, pkmask map[int]int) bool {}

// Generate is the top level code generation hook for this package.
// Emits code according to the schema in config object 'c'.
func Generate(c GenConfig) int {}