# Now, the failing bytes should have been added to the seed corpus for
# the target, and should fail when run without fuzzing.
! go test
+stdout 'testdata[/\\]corpus[/\\]FuzzWithBug[/\\][a-f0-9]{64}'
+stdout 'this input caused a crash!'
! go test -run=FuzzWithNilPanic -fuzz=FuzzWithNilPanic -fuzztime=100x
stdout 'testdata[/\\]corpus[/\\]FuzzWithNilPanic[/\\]'
FMT, flag, runtime/debug, runtime/trace, internal/sysinfo
< testing;
- FMT, crypto/sha256, encoding/json, go/ast, go/parser, go/token, math/rand
+ FMT, crypto/sha256, encoding/json, go/ast, go/parser, go/token, math/rand, encoding/hex, crypto/sha256
< internal/fuzz;
internal/fuzz, internal/testlog, runtime/pprof, regexp
errs = append(errs, fmt.Errorf("%q: %v", filename, err))
continue
}
- corpus = append(corpus, CorpusEntry{Name: file.Name(), Data: data, Values: vals})
+ corpus = append(corpus, CorpusEntry{Name: filename, Data: data, Values: vals})
}
if len(errs) > 0 {
return corpus, &MalformedCorpusError{errs: errs}
}
values = append(values, args[i])
}
- f.corpus = append(f.corpus, corpusEntry{Values: values})
+ f.corpus = append(f.corpus, corpusEntry{Values: values, Name: fmt.Sprintf("seed#%d", len(f.corpus))})
}
// supportedTypes represents all of the supported types which can be fuzzed.
// fn is called in its own goroutine.
//
// TODO(jayconrod,katiehockman): dedupe testdata corpus with entries from f.Add
- // TODO(jayconrod,katiehockman): improve output when running the subtest.
- // e.g. instead of
- // --- FAIL: FuzzSomethingError/#00 (0.00s)
- // do
- // --- FAIL: FuzzSomethingError/<hash> (0.00s)
run := func(e corpusEntry) error {
if e.Values == nil {
// Every code path should have already unmarshaled Data into Values.
// It's our fault if it didn't.
panic(fmt.Sprintf("corpus file %q was not unmarshaled", e.Name))
}
- testName, ok, _ := f.testContext.match.fullName(&f.common, e.Name)
- if !ok || shouldFailFast() {
+ if shouldFailFast() {
return nil
}
+ testName := f.common.name
+ if e.Name != "" {
+ testName = fmt.Sprintf("%s/%s", testName, e.Name)
+ }
// Record the stack trace at the point of this call so that if the subtest
// function - which runs in a separate stack - is marked as a helper, we can
// continue walking the stack into the parent test.