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