From d06c31c94caefa2de32f9a8bcc857498fd9c1232 Mon Sep 17 00:00:00 2001 From: Emmanuel T Odeke Date: Mon, 18 Nov 2019 10:40:02 -0500 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- internal/socket/socket_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/socket/socket_test.go b/internal/socket/socket_test.go index 2300cec2..038e8e91 100644 --- a/internal/socket/socket_test.go +++ b/internal/socket/socket_test.go @@ -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)) } })