Commit 90d56e07 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

exec: disable the ExtraFiles test on darwin

Still a mystery. New issue 2603 filed.

R=golang-dev, dsymonds, iant
CC=golang-dev
https://golang.org/cl/5503063
parent 5690ddc7
......@@ -67,6 +67,9 @@ type Cmd struct {
// ExtraFiles specifies additional open files to be inherited by the
// new process. It does not include standard input, standard output, or
// standard error. If non-nil, entry i becomes file descriptor 3+i.
//
// BUG: on OS X 10.6, child processes may sometimes inherit extra fds.
// http://golang.org/issue/2603
ExtraFiles []*os.File
// SysProcAttr holds optional, operating system-specific attributes.
......
......@@ -11,6 +11,8 @@ import (
"io"
"io/ioutil"
"net"
"net/http"
"net/http/httptest"
"os"
"runtime"
"strconv"
......@@ -156,6 +158,14 @@ func TestExtraFiles(t *testing.T) {
}
defer ln.Close()
// Force TLS root certs to be loaded (which might involve
// cgo), to make sure none of that potential C code leaks fds.
ts := httptest.NewTLSServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello"))
}))
defer ts.Close()
http.Get(ts.URL) // ignore result; just calling to force root cert loading
tf, err := ioutil.TempFile("", "")
if err != nil {
t.Fatalf("TempFile: %v", err)
......@@ -256,23 +266,31 @@ func TestHelperProcess(*testing.T) {
fmt.Printf("ReadAll from fd 3: %v", err)
os.Exit(1)
}
// Now verify that there are no other open fds.
var files []*os.File
for wantfd := os.Stderr.Fd() + 2; wantfd <= 100; wantfd++ {
f, err := os.Open(os.Args[0])
if err != nil {
fmt.Printf("error opening file with expected fd %d: %v", wantfd, err)
os.Exit(1)
switch runtime.GOOS {
case "darwin":
// TODO(bradfitz): broken? Sometimes.
// http://golang.org/issue/2603
// Skip this additional part of the test for now.
default:
// Now verify that there are no other open fds.
var files []*os.File
for wantfd := os.Stderr.Fd() + 2; wantfd <= 100; wantfd++ {
f, err := os.Open(os.Args[0])
if err != nil {
fmt.Printf("error opening file with expected fd %d: %v", wantfd, err)
os.Exit(1)
}
if got := f.Fd(); got != wantfd {
fmt.Printf("leaked parent file. fd = %d; want %d\n", got, wantfd)
out, _ := Command("lsof", "-p", fmt.Sprint(os.Getpid())).CombinedOutput()
fmt.Print(string(out))
os.Exit(1)
}
files = append(files, f)
}
if got := f.Fd(); got != wantfd {
fmt.Printf("leaked parent file. fd = %d; want %d", got, wantfd)
fmt.Println(Command("lsof", "-p", fmt.Sprint(os.Getpid())).CombinedOutput())
os.Exit(1)
for _, f := range files {
f.Close()
}
files = append(files, f)
}
for _, f := range files {
f.Close()
}
os.Stderr.Write(bs)
case "exit":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment