diff options
author | Bryan C. Mills <bcmills@google.com> | 2021-10-28 15:00:33 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2021-10-28 20:43:02 +0000 |
commit | e741e2fe0e51840b16bfc84d8daaba7670e7aac9 (patch) | |
tree | 65f5efb6f05d5b511099b0c93c5dfc03ca09b4d2 /src/cmd/internal | |
parent | 834e36ec778c11b068a2d5354343d4668e5a9ceb (diff) | |
download | go-e741e2fe0e51840b16bfc84d8daaba7670e7aac9.tar.gz go-e741e2fe0e51840b16bfc84d8daaba7670e7aac9.zip |
cmd/go: consolidate fuzz-support checks
We had been repeating conditions for specific platforms and
architectures to gate fuzzing tests, but the more of those tests we
add the more we will have to update if the set of supported platforms
and archictures expands over time.
We also ought to provide a friendlier error message when
'go test -fuzz' is used on non-supported platforms.
This change adds predicates in cmd/internal/sys, which already
contains similar predicates for related functionality (such as the
race detector), and uses those predicates in 'go test' and TestScript.
For #48495
Change-Id: If24c3997aeb4d201258e21e5b6cf4f7c08fbadd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/359481
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Katie Hockman <katie@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Diffstat (limited to 'src/cmd/internal')
-rw-r--r-- | src/cmd/internal/sys/supported.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/cmd/internal/sys/supported.go b/src/cmd/internal/sys/supported.go index 473e390587..18ca50f927 100644 --- a/src/cmd/internal/sys/supported.go +++ b/src/cmd/internal/sys/supported.go @@ -45,6 +45,29 @@ func ASanSupported(goos, goarch string) bool { } } +// FuzzSupported reports whether goos/goarch supports fuzzing +// ('go test -fuzz=.'). +func FuzzSupported(goos, goarch string) bool { + switch goos { + case "darwin", "linux", "windows": + return true + default: + return false + } +} + +// FuzzInstrumented reports whether fuzzing on goos/goarch uses coverage +// instrumentation. (FuzzInstrumented implies FuzzSupported.) +func FuzzInstrumented(goos, goarch string) bool { + switch goarch { + case "amd64", "arm64": + // TODO(#14565): support more architectures. + return FuzzSupported(goos, goarch) + default: + return false + } +} + // MustLinkExternal reports whether goos/goarch requires external linking. // (This is the opposite of internal/testenv.CanInternalLink. Keep them in sync.) func MustLinkExternal(goos, goarch string) bool { |