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

     1  # Test that when both race detection and coverage instrumentation are enabled,
     2  # and seed values are being executed, the race detector isn't mistakenly
     3  # triggered.
     4  
     5  [short] skip
     6  [!fuzz] skip
     7  [!race] skip
     8  
     9  # Test with coverage instrumentation enabled (-fuzz) and race instrumentation
    10  # but without actually fuzzing the target (by using a non-matching pattern)
    11  go test -fuzz=xxx -race -v
    12  ! stderr 'race detected during execution of test'
    13  
    14  # Test with just race instrumentation enabled
    15  go test -race -v
    16  ! stderr 'race detected during execution of test'
    17  
    18  # Test with coverage and race instrumentation enabled, and a matching fuzz
    19  # pattern
    20  go test -fuzz=FuzzRace -race -v -fuzztime=200x
    21  ! stderr 'race detected during execution of test'
    22  
    23  -- go.mod --
    24  module test
    25  
    26  -- race_test.go --
    27  package race
    28  
    29  import "testing"
    30  
    31  func FuzzRace(f *testing.F) {
    32  	for i := 0; i < 100; i++ {
    33  		f.Add(i)
    34  	}
    35  
    36  	f.Fuzz(func(t *testing.T, i int) {
    37  		t.Parallel()
    38  	})
    39  }
    40  

View as plain text