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>
diff --git a/internal/socket/socket_test.go b/internal/socket/socket_test.go
index 2300cec..038e8e9 100644
--- a/internal/socket/socket_test.go
+++ b/internal/socket/socket_test.go
@@ -359,7 +359,9 @@
 				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))
 			}
 		})