From: Austin Clements Date: Wed, 26 Jun 2019 18:35:05 +0000 (-0400) Subject: sync: only check for successful PopHeads in long mode X-Git-Tag: go1.13rc1~151 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=9caaac2c92f866383b52fca544b9871acf5fda1c;p=gostls13.git sync: only check for successful PopHeads in long mode In TestPoolDequeue it's surprisingly common for the queue to stay nearly empty the whole time and for a racing PopTail to happen in the window between the producer doing a PushHead and doing a PopHead. In short mode, there are only 100 PopTail attempts. On linux/amd64, it's not uncommon for this to fail 50% of the time. On linux/arm64, it's not uncommon for this to fail 100% of the time, causing the test to fail. This CL fixes this by only checking for a successful PopTail in long mode. Long mode makes 200,000 PopTail attempts, and has never been observed to fail. Fixes #31422. Change-Id: If464d55eb94fcb0b8d78fbc441d35be9f056a290 Reviewed-on: https://go-review.googlesource.com/c/go/+/183981 Run-TryBot: Austin Clements TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- diff --git a/src/sync/pool_test.go b/src/sync/pool_test.go index 814c4a6812..ad98350b2b 100644 --- a/src/sync/pool_test.go +++ b/src/sync/pool_test.go @@ -236,10 +236,12 @@ func testPoolDequeue(t *testing.T, d PoolDequeue) { t.Errorf("expected have[%d] = 1, got %d", i, count) } } - if nPopHead == 0 { - // In theory it's possible in a valid schedule for - // popHead to never succeed, but in practice it almost - // always succeeds, so this is unlikely to flake. + // Check that at least some PopHeads succeeded. We skip this + // check in short mode because it's common enough that the + // queue will stay nearly empty all the time and a PopTail + // will happen during the window between every PushHead and + // PopHead. + if !testing.Short() && nPopHead == 0 { t.Errorf("popHead never succeeded") } }