mirror of
https://github.com/golang/go
synced 2024-11-24 11:20:07 -07:00
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
This commit is contained in:
parent
5690ddc7fa
commit
90d56e072f
@ -67,6 +67,9 @@ type Cmd struct {
|
|||||||
// ExtraFiles specifies additional open files to be inherited by the
|
// ExtraFiles specifies additional open files to be inherited by the
|
||||||
// new process. It does not include standard input, standard output, or
|
// new process. It does not include standard input, standard output, or
|
||||||
// standard error. If non-nil, entry i becomes file descriptor 3+i.
|
// 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
|
ExtraFiles []*os.File
|
||||||
|
|
||||||
// SysProcAttr holds optional, operating system-specific attributes.
|
// SysProcAttr holds optional, operating system-specific attributes.
|
||||||
|
@ -11,6 +11,8 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net"
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
@ -156,6 +158,14 @@ func TestExtraFiles(t *testing.T) {
|
|||||||
}
|
}
|
||||||
defer ln.Close()
|
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("", "")
|
tf, err := ioutil.TempFile("", "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("TempFile: %v", err)
|
t.Fatalf("TempFile: %v", err)
|
||||||
@ -256,23 +266,31 @@ func TestHelperProcess(*testing.T) {
|
|||||||
fmt.Printf("ReadAll from fd 3: %v", err)
|
fmt.Printf("ReadAll from fd 3: %v", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
// Now verify that there are no other open fds.
|
switch runtime.GOOS {
|
||||||
var files []*os.File
|
case "darwin":
|
||||||
for wantfd := os.Stderr.Fd() + 2; wantfd <= 100; wantfd++ {
|
// TODO(bradfitz): broken? Sometimes.
|
||||||
f, err := os.Open(os.Args[0])
|
// http://golang.org/issue/2603
|
||||||
if err != nil {
|
// Skip this additional part of the test for now.
|
||||||
fmt.Printf("error opening file with expected fd %d: %v", wantfd, err)
|
default:
|
||||||
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)
|
||||||
|
}
|
||||||
|
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 {
|
for _, f := range files {
|
||||||
fmt.Printf("leaked parent file. fd = %d; want %d", got, wantfd)
|
f.Close()
|
||||||
fmt.Println(Command("lsof", "-p", fmt.Sprint(os.Getpid())).CombinedOutput())
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
}
|
||||||
files = append(files, f)
|
|
||||||
}
|
|
||||||
for _, f := range files {
|
|
||||||
f.Close()
|
|
||||||
}
|
}
|
||||||
os.Stderr.Write(bs)
|
os.Stderr.Write(bs)
|
||||||
case "exit":
|
case "exit":
|
||||||
|
Loading…
Reference in New Issue
Block a user