aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/testdata/script/test_fuzz_match.txt
blob: 47e143952acd185e7bc7302bea7604e84bfb301a (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
# TODO(jayconrod): support shared memory on more platforms.
[!darwin] [!linux] [!windows] skip

# Matches only fuzz targets to test.
go test standalone_fuzz_test.go
! stdout '^ok.*\[no tests to run\]'
stdout '^ok'

# Matches only for fuzzing.
go test -fuzz Fuzz -fuzztime 1x standalone_fuzz_test.go
! stdout '^ok.*\[no tests to run\]'
stdout '^ok'

# Matches none for fuzzing but will run the fuzz target as a test.
go test -fuzz ThisWillNotMatch -fuzztime 1x standalone_fuzz_test.go
! stdout '^ok.*no tests to run'
stdout '^ok'
stdout 'no targets to fuzz'

[short] stop

# Matches only fuzz targets to test with -run.
go test -run Fuzz standalone_fuzz_test.go
! stdout '^ok.*\[no tests to run\]'
stdout '^ok'

# Matches no fuzz targets.
go test -run ThisWillNotMatch standalone_fuzz_test.go
stdout '^ok.*no tests to run'
! stdout 'no targets to fuzz'

# Matches more than one fuzz target for fuzzing.
! go test -fuzz Fuzz -fuzztime 1x multiple_fuzz_test.go
! stdout 'no tests to run'
! stdout 'no targets to fuzz'
stdout FAIL
stdout 'will not fuzz, -fuzz matches more than one target'

-- standalone_fuzz_test.go --
package standalone_fuzz

import "testing"

func Fuzz(f *testing.F) {
	f.Fuzz(func (*testing.T, []byte) {})
}

-- multiple_fuzz_test.go --
package multiple_fuzz

import "testing"

func FuzzA(f *testing.F) {
	f.Fuzz(func (*testing.T, []byte) {})
}

func FuzzB(f *testing.F) {
	f.Fuzz(func (*testing.T, []byte) {})
}