1 [!fuzz] skip
2 [short] skip
3 env GOCACHE=$WORK/cache
4
5 # Run chatty fuzz targets with an error.
6 ! go test -v chatty_error_fuzz_test.go
7 ! stdout '^ok'
8 stdout 'FAIL'
9 stdout 'error in target'
10
11 # Run chatty fuzz targets with a fatal.
12 ! go test -v chatty_fatal_fuzz_test.go
13 ! stdout '^ok'
14 stdout 'FAIL'
15 stdout 'fatal in target'
16
17 # Run chatty fuzz target with a panic
18 ! go test -v chatty_panic_fuzz_test.go
19 ! stdout ^ok
20 stdout FAIL
21 stdout 'this is bad'
22
23 # Run skipped chatty fuzz targets.
24 go test -v chatty_skipped_fuzz_test.go
25 stdout ok
26 stdout SKIP
27 ! stdout FAIL
28
29 # Run successful chatty fuzz targets.
30 go test -v chatty_fuzz_test.go
31 stdout ok
32 stdout PASS
33 stdout 'all good here'
34 ! stdout FAIL
35
36 # Fuzz successful chatty fuzz target that includes a separate unit test.
37 go test -v chatty_with_test_fuzz_test.go -fuzz=Fuzz -fuzztime=1x
38 stdout ok
39 stdout PASS
40 ! stdout FAIL
41 stdout -count=1 'all good here'
42 # Verify that the unit test is only run once.
43 stdout -count=1 'logged foo'
44
45 -- chatty_error_fuzz_test.go --
46 package chatty_error_fuzz
47
48 import "testing"
49
50 func Fuzz(f *testing.F) {
51 f.Error("error in target")
52 }
53
54 -- chatty_fatal_fuzz_test.go --
55 package chatty_fatal_fuzz
56
57 import "testing"
58
59 func Fuzz(f *testing.F) {
60 f.Fatal("fatal in target")
61 }
62
63 -- chatty_panic_fuzz_test.go --
64 package chatty_panic_fuzz
65
66 import "testing"
67
68 func Fuzz(f *testing.F) {
69 panic("this is bad")
70 }
71
72 -- chatty_skipped_fuzz_test.go --
73 package chatty_skipped_fuzz
74
75 import "testing"
76
77 func Fuzz(f *testing.F) {
78 f.Skip()
79 }
80
81 -- chatty_fuzz_test.go --
82 package chatty_fuzz
83
84 import "testing"
85
86 func Fuzz(f *testing.F) {
87 f.Log("all good here")
88 f.Fuzz(func(*testing.T, []byte) {})
89 }
90
91 -- chatty_with_test_fuzz_test.go --
92 package chatty_with_test_fuzz
93
94 import "testing"
95
96 func TestFoo(t *testing.T) {
97 t.Log("logged foo")
98 }
99
100 func Fuzz(f *testing.F) {
101 f.Log("all good here")
102 f.Fuzz(func(*testing.T, []byte) {})
103 }
104
View as plain text