From: Than McIntosh Date: Thu, 1 Dec 2022 16:38:38 +0000 (-0500) Subject: runtime,hash/maphash: eliminate maphash torture test for -race X-Git-Tag: go1.20rc1~54 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=e24380b6fa82682baa4103787373520c7685e38a;p=gostls13.git runtime,hash/maphash: eliminate maphash torture test for -race Disable the "torture" portion of the maphash tests if -race is in effect (these tests can cause timeouts on the longtest -race builder). Fixes #57030. Change-Id: I23d7561dac3e81d979cad9e0efa6f5b7154aadd2 Reviewed-on: https://go-review.googlesource.com/c/go/+/454455 Run-TryBot: Than McIntosh Reviewed-by: Keith Randall TryBot-Result: Gopher Robot Reviewed-by: Keith Randall --- diff --git a/src/hash/maphash/smhasher_test.go b/src/hash/maphash/smhasher_test.go index 6e6f2983a2..27cedc4ce1 100644 --- a/src/hash/maphash/smhasher_test.go +++ b/src/hash/maphash/smhasher_test.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !race + package maphash import ( @@ -18,6 +20,9 @@ import ( // https://code.google.com/p/smhasher/ // This code is a port of some of the Smhasher tests to Go. +// Note: due to the long running time of these tests, they are +// currently disabled in -race mode. + var fixedSeed = MakeSeed() // Sanity checks. diff --git a/src/runtime/hash_test.go b/src/runtime/hash_test.go index e72600641f..d4a2b3f6bb 100644 --- a/src/runtime/hash_test.go +++ b/src/runtime/hash_test.go @@ -6,6 +6,7 @@ package runtime_test import ( "fmt" + "internal/race" "math" "math/rand" . "runtime" @@ -125,6 +126,9 @@ func TestSmhasherAppendedZeros(t *testing.T) { // All 0-3 byte strings have distinct hashes. func TestSmhasherSmallKeys(t *testing.T) { + if race.Enabled { + t.Skip("Too long for race mode") + } h := newHashSet() var b [3]byte for i := 0; i < 256; i++ { @@ -166,6 +170,9 @@ func TestSmhasherTwoNonzero(t *testing.T) { if testing.Short() { t.Skip("Skipping in short mode") } + if race.Enabled { + t.Skip("Too long for race mode") + } h := newHashSet() for n := 2; n <= 16; n++ { twoNonZero(h, n) @@ -208,6 +215,9 @@ func TestSmhasherCyclic(t *testing.T) { if testing.Short() { t.Skip("Skipping in short mode") } + if race.Enabled { + t.Skip("Too long for race mode") + } r := rand.New(rand.NewSource(1234)) const REPEAT = 8 const N = 1000000 @@ -275,6 +285,9 @@ func TestSmhasherPermutation(t *testing.T) { if testing.Short() { t.Skip("Skipping in short mode") } + if race.Enabled { + t.Skip("Too long for race mode") + } permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8) permutation(t, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8) permutation(t, []uint32{0, 1}, 20) @@ -447,6 +460,9 @@ func TestSmhasherAvalanche(t *testing.T) { if testing.Short() { t.Skip("Skipping in short mode") } + if race.Enabled { + t.Skip("Too long for race mode") + } avalancheTest1(t, &BytesKey{make([]byte, 2)}) avalancheTest1(t, &BytesKey{make([]byte, 4)}) avalancheTest1(t, &BytesKey{make([]byte, 8)}) @@ -514,6 +530,9 @@ func avalancheTest1(t *testing.T, k Key) { // All bit rotations of a set of distinct keys func TestSmhasherWindowed(t *testing.T) { + if race.Enabled { + t.Skip("Too long for race mode") + } t.Logf("32 bit keys") windowed(t, &Int32Key{}) t.Logf("64 bit keys")