...

Text file src/cmd/go/testdata/script/test_fuzz_cov.txt

Documentation: cmd/go/testdata/script

     1# Test that coverage instrumentation is working. Without the instrumentation
     2# it is _extremely_ unlikely that the fuzzer would produce this particular
     3# input in any reasonable amount of time.
     4
     5[short] skip
     6[!fuzz-instrumented] skip
     7env GOCACHE=$WORK/cache
     8
     9# TODO(#51484): enabled debugging info to help diagnose a deadlock in the fuzzer
    10env GODEBUG=fuzzdebug=1
    11! go test -fuzz=FuzzCov -v
    12! stderr 'cov instrumentation working'
    13
    14-- go.mod --
    15module test
    16
    17-- cov_test.go --
    18package cov
    19
    20import "testing"
    21
    22func FuzzCov(f *testing.F) {
    23	f.Fuzz(func(t *testing.T, b []byte) {
    24		if len(b) == 8 &&
    25			b[0] == 'h' &&
    26			b[1] == 'e' &&
    27			b[2] == 'l' &&
    28			b[3] == 'l' &&
    29			b[4] == 'o' &&
    30			b[5] == ' ' &&
    31			b[6] == ':' &&
    32			b[7] == ')' {
    33			panic("cov instrumentation working")
    34		}
    35	})
    36}

View as plain text