...

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

Documentation: cmd/go/testdata/script

     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
     8env GOCACHE=$WORK/cache
     9
    10# Test with coverage instrumentation enabled (-fuzz) and race instrumentation
    11# but without actually fuzzing the target (by using a non-matching pattern)
    12go test -fuzz=xxx -race -v
    13! stderr 'race detected during execution of test'
    14
    15# Test with just race instrumentation enabled
    16go test -race -v
    17! stderr 'race detected during execution of test'
    18
    19# Test with coverage and race instrumentation enabled, and a matching fuzz
    20# pattern
    21go test -fuzz=FuzzRace -race -v -fuzztime=200x
    22! stderr 'race detected during execution of test'
    23
    24-- go.mod --
    25module test
    26
    27-- race_test.go --
    28package race
    29
    30import "testing"
    31
    32func FuzzRace(f *testing.F) {
    33	for i := 0; i < 100; i++ {
    34		f.Add(i)
    35	}
    36
    37	f.Fuzz(func(t *testing.T, i int) {
    38		t.Parallel()
    39	})
    40}

View as plain text