diff options
author | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
---|---|---|
committer | Michael Stapelberg <stapelberg@debian.org> | 2014-06-19 09:22:53 +0200 |
commit | 8a39ee361feb9bf46d728ff1ba4f07ca1d9610b1 (patch) | |
tree | 4449f2036cccf162e8417cc5841a35815b3e7ac5 /src/pkg/time/sleep_test.go | |
parent | c8bf49ef8a92e2337b69c14b9b88396efe498600 (diff) | |
download | golang-upstream/1.3.tar.gz |
Imported Upstream version 1.3upstream/1.3
Diffstat (limited to 'src/pkg/time/sleep_test.go')
-rw-r--r-- | src/pkg/time/sleep_test.go | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/pkg/time/sleep_test.go b/src/pkg/time/sleep_test.go index 468725950..03f8e732c 100644 --- a/src/pkg/time/sleep_test.go +++ b/src/pkg/time/sleep_test.go @@ -74,26 +74,13 @@ func benchmark(b *testing.B, bench func(n int)) { for i := 0; i < len(garbage); i++ { garbage[i] = AfterFunc(Hour, nil) } - - const batch = 1000 - P := runtime.GOMAXPROCS(-1) - N := int32(b.N / batch) - b.ResetTimer() - var wg sync.WaitGroup - wg.Add(P) - - for p := 0; p < P; p++ { - go func() { - for atomic.AddInt32(&N, -1) >= 0 { - bench(batch) - } - wg.Done() - }() - } - - wg.Wait() + b.RunParallel(func(pb *testing.PB) { + for pb.Next() { + bench(1000) + } + }) b.StopTimer() for i := 0; i < len(garbage); i++ { @@ -360,19 +347,18 @@ func TestReset(t *testing.T) { // Test that sleeping for an interval so large it overflows does not // result in a short sleep duration. func TestOverflowSleep(t *testing.T) { - const timeout = 25 * Millisecond const big = Duration(int64(1<<63 - 1)) select { case <-After(big): t.Fatalf("big timeout fired") - case <-After(timeout): + case <-After(25 * Millisecond): // OK } const neg = Duration(-1 << 63) select { case <-After(neg): // OK - case <-After(timeout): + case <-After(1 * Second): t.Fatalf("negative timeout didn't fire") } } @@ -398,6 +384,9 @@ func TestIssue5745(t *testing.T) { } func TestOverflowRuntimeTimer(t *testing.T) { + if testing.Short() { + t.Skip("skipping in short mode, see issue 6874") + } if err := CheckRuntimeTimerOverflow(); err != nil { t.Fatalf(err.Error()) } |