aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@golang.org>2018-08-01 14:50:11 -0700
committerIan Lance Taylor <iant@golang.org>2018-08-01 23:10:11 +0000
commita7df7b9cdb34133aba9ba1581bc1f5ea6650309c (patch)
treed89334fe697413c04edfd41a2fb2120ef16f3c78
parent859a944ee2edf19bbc6d72ca52ccd9c3f6d687e2 (diff)
downloadgo-a7df7b9cdb34133aba9ba1581bc1f5ea6650309c.tar.gz
go-a7df7b9cdb34133aba9ba1581bc1f5ea6650309c.zip
misc/cgo/testcshared: force descriptor 30 to be closed when execing test
Fixes #26730 Change-Id: I3396598282c814e75c0c4ef16f692dbe83d2935e Reviewed-on: https://go-review.googlesource.com/127395 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
-rw-r--r--misc/cgo/testcshared/cshared_test.go10
1 files changed, 10 insertions, 0 deletions
diff --git a/misc/cgo/testcshared/cshared_test.go b/misc/cgo/testcshared/cshared_test.go
index 77cefc5a66..89b19d653a 100644
--- a/misc/cgo/testcshared/cshared_test.go
+++ b/misc/cgo/testcshared/cshared_test.go
@@ -201,6 +201,16 @@ func run(t *testing.T, env []string, args ...string) string {
t.Helper()
cmd := exec.Command(args[0], args[1:]...)
cmd.Env = env
+
+ if GOOS != "windows" {
+ // TestUnexportedSymbols relies on file descriptor 30
+ // being closed when the program starts, so enforce
+ // that in all cases. (The first three descriptors are
+ // stdin/stdout/stderr, so we just need to make sure
+ // that cmd.ExtraFiles[27] exists and is nil.)
+ cmd.ExtraFiles = make([]*os.File, 28)
+ }
+
out, err := cmd.CombinedOutput()
if err != nil {
t.Fatalf("command failed: %v\n%v\n%s\n", args, err, out)