| 1 |
[!fuzz] skip |
| 2 |
[short] skip |
| 3 |
env GOCACHE=$WORK/cache |
| 4 |
|
| 5 |
# FuzzA attempts to cause the mutator to create duplicate inputs that generate |
| 6 |
# new coverage. Previously this would trigger a corner case when the fuzzer |
| 7 |
# had an execution limit, causing it to deadlock and sit in the coordinator |
| 8 |
# loop indefinitely, failing to exit once the limit had been exhausted. |
| 9 |
|
| 10 |
go test -fuzz=FuzzA -fuzztime=100x -parallel=1 |
| 11 |
|
| 12 |
-- go.mod -- |
| 13 |
module m |
| 14 |
|
| 15 |
go 1.16 |
| 16 |
-- fuzz_test.go -- |
| 17 |
package fuzz_test |
| 18 |
|
| 19 |
import ( |
| 20 |
"fmt" |
| 21 |
"testing" |
| 22 |
) |
| 23 |
|
| 24 |
func FuzzA(f *testing.F) { |
| 25 |
f.Add([]byte("seed")) |
| 26 |
i := 0 |
| 27 |
f.Fuzz(func(t *testing.T, b []byte) { |
| 28 |
i++ |
| 29 |
if string(b) == "seed" { |
| 30 |
if i == 0 { |
| 31 |
fmt.Println("a") |
| 32 |
} else if i > 1 { |
| 33 |
fmt.Println("b") |
| 34 |
} |
| 35 |
} |
| 36 |
}) |
| 37 |
} |