internal/socket: pass race detection if CGO is not enabled

Follows up CL 205461 by recognizing that -race cannot
run if CGO is not enabled, hence won't broadly fail
the test.

Fixes golang/go#35668

Change-Id: I6a47e6fc7c4afd0bf225fc9876c96b29efa863ce
Reviewed-on: https://go-review.googlesource.com/c/net/+/207677
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This commit is contained in:
Emmanuel T Odeke
2019-11-18 10:40:02 -05:00
committed by Emmanuel Odeke
parent f9c8255933
commit d06c31c94c

View File

@@ -359,7 +359,9 @@ func main() {
t.Fatalf("failed to write file: %v", err)
}
got, err := exec.Command(goBinary, "run", "-race", src).CombinedOutput()
if !strings.Contains(string(got), "WARNING: DATA RACE") {
if strings.Contains(string(got), "-race requires cgo") {
t.Log("CGO is not enabled so can't use -race")
} else if !strings.Contains(string(got), "WARNING: DATA RACE") {
t.Errorf("race not detected for test %d: err:%v out:%s", i, err, string(got))
}
})