stdout 'runtime.Goexit'
go run check_testdata.go FuzzWithNilPanic
+! go test -run=FuzzWithFail -fuzz=FuzzWithFail -fuzztime=5s -parallel=1
+stdout 'testdata[/\\]corpus[/\\]FuzzWithFail[/\\]'
+go run check_testdata.go FuzzWithFail
+
+! go test -run=FuzzWithErrorf -fuzz=FuzzWithErrorf -fuzztime=5s -parallel=1
+stdout 'testdata[/\\]corpus[/\\]FuzzWithErrorf[/\\]'
+# TODO: Uncomment this part of the test once it's fixed
+# stdout 'errorf was called here'
+go run check_testdata.go FuzzWithErrorf
+
+! go test -run=FuzzWithFatalf -fuzz=FuzzWithFatalf -fuzztime=5s -parallel=1
+stdout 'testdata[/\\]corpus[/\\]FuzzWithFatalf[/\\]'
+# TODO: Uncomment this part of the test once it's fixed
+# stdout 'fatalf was called here'
+go run check_testdata.go FuzzWithFatalf
+
! go test -run=FuzzWithBadExit -fuzz=FuzzWithBadExit -fuzztime=5s -parallel=1
stdout 'testdata[/\\]corpus[/\\]FuzzWithBadExit[/\\]'
stdout 'unexpectedly'
})
}
+func FuzzWithFail(f *testing.F) {
+ f.Add([]byte("aa"))
+ f.Fuzz(func(t *testing.T, b []byte) {
+ if string(b) != "aa" {
+ t.Fail()
+ }
+ })
+}
+
+func FuzzWithErrorf(f *testing.F) {
+ f.Add([]byte("aa"))
+ f.Fuzz(func(t *testing.T, b []byte) {
+ if string(b) != "aa" {
+ t.Errorf("errorf was called here")
+ }
+ })
+}
+
+func FuzzWithFatalf(f *testing.F) {
+ f.Add([]byte("aa"))
+ f.Fuzz(func(t *testing.T, b []byte) {
+ if string(b) != "aa" {
+ t.Fatalf("fatalf was called here")
+ }
+ })
+}
+
func FuzzWithTwoTypes(f *testing.F) {
f.Fuzz(func(t *testing.T, a, b []byte) {
if len(a) > 0 && len(b) > 0 {
}
// TODO(jayconrod): what happens if testing.F.Fuzz is never called?
// TODO(jayconrod): time out if the test process hangs.
- } else if resp.Err != "" {
+ } else if resp.Crashed {
// The worker found a crasher. Inform the coordinator.
crasher := crasherEntry{
CorpusEntry: CorpusEntry{Data: value},
// the coordinator (for example, because it expanded coverage).
Interesting bool
- // Err is set if the value in shared memory caused a crash.
+ // Crashed indicates the value in shared memory caused a crash.
+ Crashed bool
+
+ // Err is the error string caused by the value in shared memory. This alone
+ // cannot be used to determine whether this value caused a crash, since a
+ // crash can occur without any output (e.g. with t.Fail()).
Err string
}
mem.setValueLen(len(b))
mem.setValue(b)
if err := ws.fuzzFn(CorpusEntry{Values: vals}); err != nil {
- return fuzzResponse{Err: err.Error()}
+ return fuzzResponse{Crashed: true, Err: err.Error()}
}
// TODO(jayconrod,katiehockman): return early if we find an
// interesting value.