diff options
author | Ghanan Gowripalan <ghanan@google.com> | 2020-07-12 17:20:50 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-07-12 17:22:08 -0700 |
commit | 9c32fd3f4d8f6e63d922c1c58b7d1f1f504fa2bc (patch) | |
tree | dfb5150ec211a268f9f69bfc22d0ba3ecf0795dc /pkg/sleep/sleep_test.go | |
parent | 69f2059e5d38bacac4bcda7912cca580ab70914d (diff) |
Do not copy sleep.Waker
sleep.Waker's fields are modified as values.
PiperOrigin-RevId: 320873451
Diffstat (limited to 'pkg/sleep/sleep_test.go')
-rw-r--r-- | pkg/sleep/sleep_test.go | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/pkg/sleep/sleep_test.go b/pkg/sleep/sleep_test.go index af47e2ba1..1dd11707d 100644 --- a/pkg/sleep/sleep_test.go +++ b/pkg/sleep/sleep_test.go @@ -379,10 +379,7 @@ func TestRace(t *testing.T) { // TestRaceInOrder tests that multiple wakers can continuously send wake requests to // the sleeper and that the wakers are retrieved in the order asserted. func TestRaceInOrder(t *testing.T) { - const wakers = 100 - const wakeRequests = 10000 - - w := make([]Waker, wakers) + w := make([]Waker, 10000) s := Sleeper{} // Associate each waker and start goroutines that will assert them. @@ -390,19 +387,16 @@ func TestRaceInOrder(t *testing.T) { s.AddWaker(&w[i], i) } go func() { - n := 0 - for n < wakeRequests { - wk := w[n%len(w)] - wk.Assert() - n++ + for i := range w { + w[i].Assert() } }() // Wait for all wake up notifications from all wakers. - for i := 0; i < wakeRequests; i++ { - v, _ := s.Fetch(true) - if got, want := v, i%wakers; got != want { - t.Fatalf("got %d want %d", got, want) + for want := range w { + got, _ := s.Fetch(true) + if got != want { + t.Fatalf("got %d want %d", got, want) } } } |