aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan C. Mills <bcmills@google.com>2023-07-10 18:40:47 -0400
committerBryan Mills <bcmills@google.com>2023-07-11 13:19:40 +0000
commit4c58d6bf52b87628d0a73041af61e58eed84a310 (patch)
treebfd1add982b369fd7c348c81f519f7560a7e466f
parent6a063b01b0b0effa787c5aed90b585b409fe4688 (diff)
downloadgo-4c58d6bf52b87628d0a73041af61e58eed84a310.tar.gz
go-4c58d6bf52b87628d0a73041af61e58eed84a310.zip
time: increase arbitrary upper bound in TestReset to 10s
The previous upper bound was around 0.375 s, which is empirically too short on a slow, heavily-loaded builder. Since the test doesn't seem to depend on the actual duration in any meaningful way, let's make it several orders of magnitude larger. Fixes #61266. Change-Id: I6dde5e174966ee385db67e3cb87334f463c7e597 Reviewed-on: https://go-review.googlesource.com/c/go/+/508695 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
-rw-r--r--src/time/sleep_test.go26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/time/sleep_test.go b/src/time/sleep_test.go
index 8aac3b68f6..2f791240f9 100644
--- a/src/time/sleep_test.go
+++ b/src/time/sleep_test.go
@@ -418,22 +418,22 @@ func TestReset(t *testing.T) {
// We try to run this test with increasingly larger multiples
// until one works so slow, loaded hardware isn't as flaky,
// but without slowing down fast machines unnecessarily.
- const unit = 25 * Millisecond
- tries := []Duration{
- 1 * unit,
- 3 * unit,
- 7 * unit,
- 15 * unit,
- }
- var err error
- for _, d := range tries {
- err = testReset(d)
+ //
+ // (maxDuration is several orders of magnitude longer than we
+ // expect this test to actually take on a fast, unloaded machine.)
+ d := 1 * Millisecond
+ const maxDuration = 10 * Second
+ for {
+ err := testReset(d)
if err == nil {
- t.Logf("passed using duration %v", d)
- return
+ break
}
+ d *= 2
+ if d > maxDuration {
+ t.Error(err)
+ }
+ t.Logf("%v; trying duration %v", err, d)
}
- t.Error(err)
}
// Test that sleeping (via Sleep or Timer) for an interval so large it