]> Cypherpunks repositories - gostls13.git/commitdiff
runtime,hash/maphash: eliminate maphash torture test for -race
authorThan McIntosh <thanm@google.com>
Thu, 1 Dec 2022 16:38:38 +0000 (11:38 -0500)
committerThan McIntosh <thanm@google.com>
Thu, 1 Dec 2022 19:24:55 +0000 (19:24 +0000)
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 <thanm@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
src/hash/maphash/smhasher_test.go
src/runtime/hash_test.go

index 6e6f2983a21f4295798baed4c2d9cf9419f91a98..27cedc4ce1302fece2cecbd26a0954c7ef9f2f51 100644 (file)
@@ -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.
index e72600641f2b9ed7df2283b5f5c879a50954a44d..d4a2b3f6bb5039cc84228fca9a484cc5f2fc8e07 100644 (file)
@@ -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")