app

package
v0.0.0-...-fc5dc53 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChooseTypes

func ChooseTypes(results []Result, firstOnly bool) []string

ChooseTypes selects which types list to persist when multiple f.Fuzz calls exist. If firstOnly is true, it returns the first. Otherwise it prefers a unanimous list; if they differ, it still returns the first and leaves it to the caller to warn/log.

func ConvertSeedsToGoTests

func ConvertSeedsToGoTests(seedsDir, outDir, jsonPath, funcName string) (int, error)

ConvertSeedsToGoTests:

  1. loads types for funcName from jsonPath,
  2. builds an empty fuzz func: func(t *testing.T, ...types) {},
  3. for each file in seedsDir, calls Source.CreateGoTestcase with the empty func,
  4. writes the generated Go file to outDir, named as <md5(content)>.go.

Returns number of files written.

func LoadTypesFromJSONFile

func LoadTypesFromJSONFile(path, funcName string) ([]string, error)

LoadTypesFromJSONFile returns the type list for funcName from a JSON map.

func MakeEmptyFuzzFunc

func MakeEmptyFuzzFunc(paramTypes []string) (reflect.Value, error)

MakeEmptyFuzzFunc constructs a reflect-made no-op function with signature:

func(t *testing.T, <types...>) {}

It returns a reflect.Value holding the function, suitable to pass to input.Source.CreateGoTestcase.

func MergeFuncTypesIntoJSON

func MergeFuncTypesIntoJSON(jsonOut, funcName string, types []string) error

MergeFuncTypesIntoJSON loads (or creates) jsonOut and adds funcName -> types if the key doesn't already exist. If the key exists and matches, it's a no-op. If the key exists with different types, it does not overwrite (no-op), by design.

Types

type Result

type Result struct {
	Line  int      // 1-based line number of the f.Fuzz call's '('
	Types []string // extracted types in call order, e.g. []{"[]byte","int","int","bool"}
}

Result holds one matched f.Fuzz(...) call found inside the requested function.

func AnalyzeFile

func AnalyzeFile(path, funcName string) ([]Result, error)

AnalyzeFile parses a single .go file and extracts fuzz arg types from f.Fuzz(...) calls inside function funcName, ensuring the receiver is a *testing.F.

func AnalyzeSource

func AnalyzeSource(src []byte, funcName string) ([]Result, error)

AnalyzeSource is handy for unit tests (or callers with in-memory source).

Jump to

Keyboard shortcuts

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