]> Cypherpunks.ru repositories - gostls13.git/commit
testing: use monotonic counts to attribute races in subtests
authorBryan C. Mills <bcmills@google.com>
Mon, 26 Jun 2023 22:08:44 +0000 (18:08 -0400)
committerGopher Robot <gobot@golang.org>
Wed, 25 Oct 2023 20:44:25 +0000 (20:44 +0000)
commit55b8e16b2eb79db2acf28e0e8c914370e216b788
tree387be0c7b16e098d81685b36ff5839fefcf6acc7
parenta57c5736c5ceb0cb81764fe4b2ed8c86deafe4ba
testing: use monotonic counts to attribute races in subtests

This implements the approach I described in
https://go-review.git.corp.google.com/c/go/+/494057/1#message-5c9773bded2f89b4058848cb036b860aa6716de3.

Specifically:

- Each level of test atomically records the cumulative number of races
  seen as of the last race-induced test failure.

- When a subtest fails, it logs the race error, and then updates its
  parents' counters so that they will not log the same error.

- We check each test or benchmark for races before it starts running
  each of its subtests or sub-benchmark, before unblocking parallel
  subtests, and after running any cleanup functions.

With this implementation, it should be the case that every test that
is running when a race is detected reports that race, and any race
reported for a subtest is not redundantly reported for its parent.

The regression tests are based on those added in CL 494057 and
CL 501895, with a few additions based on my own review of the code.

Fixes #60083.

Change-Id: I578ae929f192a7a951b31b17ecb560cbbf1ef7a1
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/506300
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/runtime/race/output_test.go
src/testing/benchmark.go
src/testing/fuzz.go
src/testing/testing.go
src/testing/testing_test.go