aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/test_fuzz_chatty.txt
blob: 9ebd480c9017f009921f667e7d53fe7f98f04f8c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# TODO(jayconrod): support shared memory on more platforms.
[!darwin] [!linux] [!windows] skip

[short] skip

# Run chatty fuzz targets with an error.
! go test -v chatty_error_fuzz_test.go
! stdout '^ok'
stdout 'FAIL'
stdout 'error in target'

# Run chatty fuzz targets with a fatal.
! go test -v chatty_fatal_fuzz_test.go
! stdout '^ok'
stdout 'FAIL'
stdout 'fatal in target'

# Run chatty fuzz target with a panic
! go test -v chatty_panic_fuzz_test.go
! stdout ^ok
stdout FAIL
stdout 'this is bad'

# Run skipped chatty fuzz targets.
go test -v chatty_skipped_fuzz_test.go
stdout ok
stdout SKIP
! stdout FAIL

# Run successful chatty fuzz targets.
go test -v chatty_fuzz_test.go
stdout ok
stdout PASS
stdout 'all good here'
! stdout FAIL

# Fuzz successful chatty fuzz target that includes a separate unit test.
go test -v chatty_with_test_fuzz_test.go -fuzz=Fuzz -fuzztime=1x
stdout ok
stdout PASS
! stdout FAIL
# TODO: It's currently the case that it's logged twice. Fix that, and change
# this check to verify it.
stdout 'all good here'
# Verify that the unit test is only run once.
! stdout '(?s)logged foo.*logged foo'

-- chatty_error_fuzz_test.go --
package chatty_error_fuzz

import "testing"

func Fuzz(f *testing.F) {
    f.Error("error in target")
}

-- chatty_fatal_fuzz_test.go --
package chatty_fatal_fuzz

import "testing"

func Fuzz(f *testing.F) {
    f.Fatal("fatal in target")
}

-- chatty_panic_fuzz_test.go --
package chatty_panic_fuzz

import "testing"

func Fuzz(f *testing.F) {
    panic("this is bad")
}

-- chatty_skipped_fuzz_test.go --
package chatty_skipped_fuzz

import "testing"

func Fuzz(f *testing.F) {
    f.Skip()
}

-- chatty_fuzz_test.go --
package chatty_fuzz

import "testing"

func Fuzz(f *testing.F) {
    f.Log("all good here")
    f.Fuzz(func(*testing.T, []byte) {})
}

-- chatty_with_test_fuzz_test.go --
package chatty_with_test_fuzz

import "testing"

func TestFoo(t *testing.T) {
    t.Log("logged foo")
}

func Fuzz(f *testing.F) {
    f.Log("all good here")
    f.Fuzz(func(*testing.T, []byte) {})
}