Skip to content

Commit e24380b

Browse files
committed
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 <[email protected]> Reviewed-by: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 36b87f2 commit e24380b

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

src/hash/maphash/smhasher_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5+
//go:build !race
6+
57
package maphash
68

79
import (
@@ -18,6 +20,9 @@ import (
1820
// https://code.google.com/p/smhasher/
1921
// This code is a port of some of the Smhasher tests to Go.
2022

23+
// Note: due to the long running time of these tests, they are
24+
// currently disabled in -race mode.
25+
2126
var fixedSeed = MakeSeed()
2227

2328
// Sanity checks.

src/runtime/hash_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package runtime_test
66

77
import (
88
"fmt"
9+
"internal/race"
910
"math"
1011
"math/rand"
1112
. "runtime"
@@ -125,6 +126,9 @@ func TestSmhasherAppendedZeros(t *testing.T) {
125126

126127
// All 0-3 byte strings have distinct hashes.
127128
func TestSmhasherSmallKeys(t *testing.T) {
129+
if race.Enabled {
130+
t.Skip("Too long for race mode")
131+
}
128132
h := newHashSet()
129133
var b [3]byte
130134
for i := 0; i < 256; i++ {
@@ -166,6 +170,9 @@ func TestSmhasherTwoNonzero(t *testing.T) {
166170
if testing.Short() {
167171
t.Skip("Skipping in short mode")
168172
}
173+
if race.Enabled {
174+
t.Skip("Too long for race mode")
175+
}
169176
h := newHashSet()
170177
for n := 2; n <= 16; n++ {
171178
twoNonZero(h, n)
@@ -208,6 +215,9 @@ func TestSmhasherCyclic(t *testing.T) {
208215
if testing.Short() {
209216
t.Skip("Skipping in short mode")
210217
}
218+
if race.Enabled {
219+
t.Skip("Too long for race mode")
220+
}
211221
r := rand.New(rand.NewSource(1234))
212222
const REPEAT = 8
213223
const N = 1000000
@@ -275,6 +285,9 @@ func TestSmhasherPermutation(t *testing.T) {
275285
if testing.Short() {
276286
t.Skip("Skipping in short mode")
277287
}
288+
if race.Enabled {
289+
t.Skip("Too long for race mode")
290+
}
278291
permutation(t, []uint32{0, 1, 2, 3, 4, 5, 6, 7}, 8)
279292
permutation(t, []uint32{0, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 8)
280293
permutation(t, []uint32{0, 1}, 20)
@@ -447,6 +460,9 @@ func TestSmhasherAvalanche(t *testing.T) {
447460
if testing.Short() {
448461
t.Skip("Skipping in short mode")
449462
}
463+
if race.Enabled {
464+
t.Skip("Too long for race mode")
465+
}
450466
avalancheTest1(t, &BytesKey{make([]byte, 2)})
451467
avalancheTest1(t, &BytesKey{make([]byte, 4)})
452468
avalancheTest1(t, &BytesKey{make([]byte, 8)})
@@ -514,6 +530,9 @@ func avalancheTest1(t *testing.T, k Key) {
514530

515531
// All bit rotations of a set of distinct keys
516532
func TestSmhasherWindowed(t *testing.T) {
533+
if race.Enabled {
534+
t.Skip("Too long for race mode")
535+
}
517536
t.Logf("32 bit keys")
518537
windowed(t, &Int32Key{})
519538
t.Logf("64 bit keys")

0 commit comments

Comments
 (0)