close(done)
}()
+ timer := time.NewTimer(quiescent)
+ defer timer.Stop()
select {
case <-done:
t.Fatalf("%s unexpectedly did not block", desc)
- return nil
+ case <-timer.C:
+ }
+
+ return func(t *testing.T) {
+ logTimer := time.NewTimer(quiescent)
+ defer logTimer.Stop()
- case <-time.After(quiescent):
- return func(t *testing.T) {
+ select {
+ case <-logTimer.C:
+ // We expect the operation to have unblocked by now,
+ // but maybe it's just slow. Write to the test log
+ // in case the test times out, but don't fail it.
t.Helper()
- select {
- case <-time.After(probablyStillBlocked):
- t.Fatalf("%s is unexpectedly still blocked after %v", desc, probablyStillBlocked)
- case <-done:
- }
+ t.Logf("%s is unexpectedly still blocked after %v", desc, quiescent)
+
+ // Wait for the operation to actually complete, no matter how long it
+ // takes. If the test has deadlocked, this will cause the test to time out
+ // and dump goroutines.
+ <-done
+
+ case <-done:
}
}
}
if _, err := os.Stat(filepath.Join(dir, "locked")); !os.IsNotExist(err) {
break locked
}
+ timer := time.NewTimer(1 * time.Millisecond)
select {
case <-qDone:
+ timer.Stop()
break locked
- case <-time.After(1 * time.Millisecond):
+ case <-timer.C:
}
}