waitTimeout waits for the waitgroup for the specified max timeout. Returns true if waiting timed out.
(wg *sync.WaitGroup, timeout time.Duration)
| 22 | // waitTimeout waits for the waitgroup for the specified max timeout. |
| 23 | // Returns true if waiting timed out. |
| 24 | func waitTimeout(wg *sync.WaitGroup, timeout time.Duration) bool { |
| 25 | c := make(chan struct{}) |
| 26 | go func() { |
| 27 | defer close(c) |
| 28 | wg.Wait() |
| 29 | }() |
| 30 | select { |
| 31 | case <-c: |
| 32 | return false // completed normally |
| 33 | case <-time.After(timeout): |
| 34 | return true // timed out |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | func TestRouteWatch(t *testing.T) { |
| 39 | logger := termlog.NewLog() |