aboutsummaryrefslogtreecommitdiff
path: root/src/cmd
diff options
context:
space:
mode:
authorRoland Shoemaker <roland@golang.org>2022-01-05 12:25:28 -0800
committerRoland Shoemaker <roland@golang.org>2022-01-05 21:22:03 +0000
commit2b39d86344608423138b648b98157470d3809ee7 (patch)
tree029001fe4d0b49235e324594063eca50b8347dc9 /src/cmd
parent88cafe0f58cf7374722a2a98d8919c32bb8795e5 (diff)
downloadgo-2b39d86344608423138b648b98157470d3809ee7.tar.gz
go-2b39d86344608423138b648b98157470d3809ee7.zip
cmd/go: add fuzzing coverage test
Adds a test script for fuzzing coverage instrumentation. Fixes #48654 Change-Id: Ieea7b4146bd5581baae869441cc1c652dd7485f5 Reviewed-on: https://go-review.googlesource.com/c/go/+/375736 Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Trust: Roland Shoemaker <roland@golang.org> Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
Diffstat (limited to 'src/cmd')
-rw-r--r--src/cmd/go/testdata/script/test_fuzz_cov.txt33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/cmd/go/testdata/script/test_fuzz_cov.txt b/src/cmd/go/testdata/script/test_fuzz_cov.txt
new file mode 100644
index 0000000000..05b634889f
--- /dev/null
+++ b/src/cmd/go/testdata/script/test_fuzz_cov.txt
@@ -0,0 +1,33 @@
+# Test that coverage instrumentation is working. Without the instrumentation
+# it is _extremely_ unlikely that the fuzzer would produce this particular
+# input in any reasonable amount of time.
+
+[short] skip
+[!fuzz-instrumented] skip
+
+! go test -fuzz=FuzzCov
+! stderr 'cov instrumentation working'
+
+-- go.mod --
+module test
+
+-- cov_test.go --
+package cov
+
+import "testing"
+
+func FuzzCov(f *testing.F) {
+ f.Fuzz(func(t *testing.T, b []byte) {
+ if len(b) == 8 &&
+ b[0] == 'h' &&
+ b[1] == 'e' &&
+ b[2] == 'l' &&
+ b[3] == 'l' &&
+ b[4] == 'o' &&
+ b[5] == ' ' &&
+ b[6] == ':' &&
+ b[7] == ')' {
+ panic("cov instrumentation working")
+ }
+ })
+}