//
// RunFuzzWorker returns an error if it could not communicate with the
// coordinator process.
-func RunFuzzWorker(ctx context.Context, fn func([]byte) error) error {
+func RunFuzzWorker(ctx context.Context, fn func(CorpusEntry) error) error {
comm, err := getWorkerComm()
if err != nil {
return err
// fuzzFn runs the worker's fuzz function on the given input and returns
// an error if it finds a crasher (the process may also exit or crash).
- fuzzFn func([]byte) error
+ fuzzFn func(CorpusEntry) error
}
// serve reads serialized RPC messages on fuzzIn. When serve receives a message,
b := mem.valueRef()
ws.m.mutate(&b)
mem.setValueLen(len(b))
- if err := ws.fuzzFn(b); err != nil {
+ if err := ws.fuzzFn(CorpusEntry{Data: b}); err != nil {
return fuzzResponse{Err: err.Error()}
}
// TODO(jayconrod,katiehockman): return early if we find an
case f.context.runFuzzWorker != nil:
// Fuzzing is enabled, and this is a worker process. Follow instructions
// from the coordinator.
- err := f.context.runFuzzWorker(func(input []byte) error {
+ err := f.context.runFuzzWorker(func(e corpusEntry) error {
t := &T{
common: common{
signal: make(chan bool),
},
context: newTestContext(1, nil),
}
- go run(t, input)
+ go run(t, e.Data)
<-t.signal
if t.Failed() {
return errors.New(string(t.output))
runMatch *matcher
fuzzMatch *matcher
coordinateFuzzing func(time.Duration, int, []corpusEntry, string, string) error
- runFuzzWorker func(func([]byte) error) error
+ runFuzzWorker func(func(corpusEntry) error) error
readCorpus func(string) ([]corpusEntry, error)
}
testlog.SetPanicOnExit0(v)
}
-func (TestDeps) CoordinateFuzzing(timeout time.Duration, parallel int, seed []fuzz.CorpusEntry, corpusDir, cacheDir string) error {
+func (TestDeps) CoordinateFuzzing(timeout time.Duration, parallel int, seed []fuzz.CorpusEntry, corpusDir, cacheDir string) (err error) {
// Fuzzing may be interrupted with a timeout or if the user presses ^C.
// In either case, we'll stop worker processes gracefully and save
// crashers and interesting values.
ctx, stop := signal.NotifyContext(ctx, os.Interrupt)
defer stop()
defer cancel()
- err := fuzz.CoordinateFuzzing(ctx, parallel, seed, corpusDir, cacheDir)
+ err = fuzz.CoordinateFuzzing(ctx, parallel, seed, corpusDir, cacheDir)
if err == ctx.Err() {
return nil
}
return err
}
-func (TestDeps) RunFuzzWorker(fn func([]byte) error) error {
+func (TestDeps) RunFuzzWorker(fn func(fuzz.CorpusEntry) error) error {
// Worker processes may or may not receive a signal when the user presses ^C
// On POSIX operating systems, a signal sent to a process group is delivered
// to all processes in that group. This is not the case on Windows.
func (f matchStringOnly) CoordinateFuzzing(time.Duration, int, []corpusEntry, string, string) error {
return errMain
}
-func (f matchStringOnly) RunFuzzWorker(func([]byte) error) error { return errMain }
-func (f matchStringOnly) ReadCorpus(string) ([]corpusEntry, error) { return nil, errMain }
+func (f matchStringOnly) RunFuzzWorker(func(corpusEntry) error) error { return errMain }
+func (f matchStringOnly) ReadCorpus(string) ([]corpusEntry, error) { return nil, errMain }
// Main is an internal function, part of the implementation of the "go test" command.
// It was exported because it is cross-package and predates "internal" packages.
StopTestLog() error
WriteProfileTo(string, io.Writer, int) error
CoordinateFuzzing(time.Duration, int, []corpusEntry, string, string) error
- RunFuzzWorker(func([]byte) error) error
+ RunFuzzWorker(func(corpusEntry) error) error
ReadCorpus(string) ([]corpusEntry, error)
}