]> Cypherpunks.ru repositories - gostls13.git/commitdiff
testing: convert numFailed to atomic type
authorcuiweixie <cuiweixie@gmail.com>
Sat, 27 Aug 2022 02:24:49 +0000 (10:24 +0800)
committerGopher Robot <gobot@golang.org>
Mon, 29 Aug 2022 14:52:44 +0000 (14:52 +0000)
Change-Id: Ic3464e95ad8901df5477d7717760b8c6d08ce97b
Reviewed-on: https://go-review.googlesource.com/c/go/+/426078
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/testing/fuzz.go
src/testing/testing.go

index b9f3a3d159801290252fbed68571669e7e69dfe2..e60ecadf2508eda77648264ed2cedec43536bd02 100644 (file)
@@ -14,7 +14,6 @@ import (
        "path/filepath"
        "reflect"
        "runtime"
-       "sync/atomic"
        "time"
 )
 
@@ -615,7 +614,7 @@ func fRunner(f *F, fn func(*F)) {
                // the original panic should still be
                // clear.
                if f.Failed() {
-                       atomic.AddUint32(&numFailed, 1)
+                       numFailed.Add(1)
                }
                err := recover()
                if err == nil {
index ec2d864822247ea9501dc78ed6abbf915d6dbf2c..a38b40e38d21f2795ff504896fb38e46caf53f38 100644 (file)
@@ -443,7 +443,7 @@ var (
        cpuList     []int
        testlogFile *os.File
 
-       numFailed uint32 // number of test failures
+       numFailed atomic.Uint32 // number of test failures
 )
 
 type chattyPrinter struct {
@@ -1312,7 +1312,7 @@ func tRunner(t *T, fn func(t *T)) {
        // a signal saying that the test is done.
        defer func() {
                if t.Failed() {
-                       atomic.AddUint32(&numFailed, 1)
+                       numFailed.Add(1)
                }
 
                if t.raceErrors+race.Errors() > 0 {
@@ -2064,5 +2064,5 @@ func parseCpuList() {
 }
 
 func shouldFailFast() bool {
-       return *failFast && atomic.LoadUint32(&numFailed) > 0
+       return *failFast && numFailed.Load() > 0
 }