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

     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
     7  
     8  ! go test -fuzz=FuzzCov
     9  ! stderr 'cov instrumentation working'
    10  
    11  -- go.mod --
    12  module test
    13  
    14  -- cov_test.go --
    15  package cov
    16  
    17  import "testing"
    18  
    19  func FuzzCov(f *testing.F) {
    20  	f.Fuzz(func(t *testing.T, b []byte) {
    21  		if len(b) == 8 &&
    22  			b[0] == 'h' &&
    23  			b[1] == 'e' &&
    24  			b[2] == 'l' &&
    25  			b[3] == 'l' &&
    26  			b[4] == 'o' &&
    27  			b[5] == ' ' &&
    28  			b[6] == ':' &&
    29  			b[7] == ')' {
    30  			panic("cov instrumentation working")
    31  		}
    32  	})
    33  }
    34  

View as plain text