vulncheck: skips android and plan9 tests for Binary

Fixes #52047

Change-Id: I60c8e115555b826bf98a8dc8d41b176936a6fc2b
Reviewed-on: https://go-review.googlesource.com/c/vuln/+/397374
Reviewed-by: Bryan Mills <bcmills@google.com>
Trust: Cherry Mui <cherryyz@google.com>
diff --git a/vulncheck/binary_test.go b/vulncheck/binary_test.go
index 6f5a407..7041a2c 100644
--- a/vulncheck/binary_test.go
+++ b/vulncheck/binary_test.go
@@ -20,8 +20,10 @@
 
 // TODO: we build binary programatically, so what if the underlying tool chain changes?
 func TestBinary(t *testing.T) {
-	// TODO(golang/go#52047): fix
-	t.Skip("fails on android and plan9")
+	// TODO(#52160): investigate why Binary does not process plan9 binaries
+	if !hasGoBuild() || runtime.GOOS == "plan9" {
+		t.Skip("fails on android and plan9")
+	}
 
 	e := packagestest.Export(t, packagestest.Modules, []packagestest.Module{
 		{
@@ -134,3 +136,18 @@
 		t.Errorf("expected 1 vuln symbols got %d", len(res.Vulns))
 	}
 }
+
+// hasGoBuild reports whether the current system can build programs with ``go build''
+// and then run them with os.StartProcess or exec.Command.
+//
+// Duplicated from std/internal/testenv
+func hasGoBuild() bool {
+	if os.Getenv("GO_GCFLAGS") != "" {
+		return false
+	}
+	switch runtime.GOOS {
+	case "android", "js", "ios":
+		return false
+	}
+	return true
+}