! stdout FAIL
! stdout 'fatal here'
+# Test pass with testdata and f.Add seed corpus
+go test -run FuzzPassString corpustesting/fuzz_testdata_corpus_test.go
+stdout ok
+! stdout FAIL
+
+# Fuzzing pass with testdata and f.Add seed corpus (skip running tests first)
+go test -run=None -fuzz=FuzzPassString corpustesting/fuzz_testdata_corpus_test.go -fuzztime=10x
+stdout ok
+! stdout FAIL
+
+# Fuzzing pass with testdata and f.Add seed corpus
+go test -run=FuzzPassString -fuzz=FuzzPassString corpustesting/fuzz_testdata_corpus_test.go -fuzztime=10x
+stdout ok
+! stdout FAIL
+
# Test panic with malformed seed corpus
! go test -run FuzzFail corpustesting/fuzz_testdata_corpus_test.go
! stdout ^ok
fuzzFn(f)
}
+func FuzzPassString(f *testing.F) {
+ f.Add("some seed corpus")
+ f.Fuzz(func(*testing.T, string) {})
+}
+
func FuzzPanic(f *testing.F) {
f.Fuzz(func(t *testing.T, b []byte) {})
}
-- corpustesting/testdata/corpus/FuzzPass/1 --
go test fuzz v1
[]byte("00000")
+-- corpustesting/testdata/corpus/FuzzPassString/1 --
+go test fuzz v1
+string("hello")
-- corpustesting/testdata/corpus/FuzzPanic/1 --
malformed
-- corpustesting/testdata/corpus/FuzzInNestedDir/anotherdir/1 --
}
func newCoordinator(opts CoordinateFuzzingOpts) (*coordinator, error) {
- // Make sure all of the seed corpus has marshalled data.
+ // Make sure all of the seed corpus given by f.Add has marshalled data.
for i := range opts.Seed {
- if opts.Seed[i].Data == nil {
+ if opts.Seed[i].Data == nil && opts.Seed[i].Values != nil {
opts.Seed[i].Data = marshalCorpusFile(opts.Seed[i].Values...)
}
}