Commit f882bc87 authored by Cosmos Nicolaou's avatar Cosmos Nicolaou Committed by Brad Fitzpatrick

os/exec: make exec_test.go:TestExtraFilesFDShuffle portable.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/9103045
parent f9c22f7e
......@@ -195,8 +195,28 @@ func basefds() uintptr {
return n
}
func closeUnexpectedFds(t *testing.T, m string) {
for fd := basefds(); fd <= 101; fd++ {
err := os.NewFile(fd, "").Close()
if err == nil {
t.Logf("%s: Something already leaked - closed fd %d", m, fd)
}
}
}
func TestExtraFilesFDShuffle(t *testing.T) {
t.Skip("TODO: TestExtraFilesFDShuffle is too non-portable; skipping")
switch runtime.GOOS {
case "darwin":
// TODO(cnicolaou): http://golang.org/issue/2603
// leads to leaked file descriptors in this test when it's
// run from a builder.
closeUnexpectedFds(t, "TestExtraFilesFDShuffle")
case "netbsd":
// http://golang.org/issue/3955
closeUnexpectedFds(t, "TestExtraFilesFDShuffle")
case "windows":
t.Skip("no operating system support; skipping")
}
// syscall.StartProcess maps all the FDs passed to it in
// ProcAttr.Files (the concatenation of stdin,stdout,stderr and
......@@ -296,12 +316,7 @@ func TestExtraFiles(t *testing.T) {
// our environment.
if !testedAlreadyLeaked {
testedAlreadyLeaked = true
for fd := basefds(); fd <= 101; fd++ {
err := os.NewFile(fd, "").Close()
if err == nil {
t.Logf("Something already leaked - closed fd %d", fd)
}
}
closeUnexpectedFds(t, "TestExtraFiles")
}
// Force network usage, to verify the epoll (or whatever) fd
......
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