...
1[short] skip
2[!fuzz-instrumented] skip
3
4env GOCACHE=$WORK/cache
5! go test -fuzz=FuzzDead -v
6# This is a somewhat inexact check, but since we don't prefix the error with anything
7# and as the error suffix is platform dependent, this is the best we can do. In the
8# deadlock failure case, the test will just deadlock and timeout anyway, so it should
9# be clear that that failure mode is different.
10stdout 'open'
11
12-- go.mod --
13module test
14
15-- cov_test.go --
16package dead
17
18import (
19 "os"
20 "path/filepath"
21 "testing"
22 "time"
23)
24
25func FuzzDead(f *testing.F) {
26 go func() {
27 c := filepath.Join(os.Getenv("GOCACHE"), "fuzz", "test", "FuzzDead")
28 t := time.NewTicker(time.Second)
29 for range t.C {
30 files, _ := os.ReadDir(c)
31 if len(files) > 0 {
32 os.RemoveAll(c)
33 }
34 }
35 }()
36
37 f.Fuzz(func(t *testing.T, b []byte) {
38 if len(b) == 8 &&
39 b[0] == 'h' &&
40 b[1] == 'e' &&
41 b[2] == 'l' &&
42 b[3] == 'l' &&
43 b[4] == 'o' &&
44 b[5] == ' ' &&
45 b[6] == ':' &&
46 b[7] == ')' {
47 return
48 }
49 })
50}
View as plain text