Commit f38a5106 authored by Bryan C. Mills's avatar Bryan C. Mills

os/exec: re-enable TestExtraFiles checks skipped on various OSes

The issues associated with these skipped checks are closed.
If they are working around unfixed bugs, the issues should remain open.
If they are working around unfixable properties of the system, the skips
should refer to those properties rather than closed issues.

Updates #2603
Updates #3955
Updates #25628

Change-Id: I3491c69b2ef5bad0fb12001fe8f7e06b424883ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/201718
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent 4569f1ba
......@@ -821,59 +821,40 @@ func TestHelperProcess(*testing.T) {
fmt.Printf("ReadAll from fd 3: %v", err)
os.Exit(1)
}
switch runtime.GOOS {
case "dragonfly":
// TODO(jsing): Determine why DragonFly is leaking
// file descriptors...
case "darwin":
// TODO(bradfitz): broken? Sometimes.
// https://golang.org/issue/2603
// Skip this additional part of the test for now.
case "netbsd":
// TODO(jsing): This currently fails on NetBSD due to
// the cloned file descriptors that result from opening
// /dev/urandom.
// https://golang.org/issue/3955
case "illumos", "solaris":
// TODO(aram): This fails on Solaris because libc opens
// its own files, as it sees fit. Darwin does the same,
// see: https://golang.org/issue/2603
default:
// Now verify that there are no other open fds.
var files []*os.File
for wantfd := basefds() + 1; wantfd <= 100; wantfd++ {
if poll.IsPollDescriptor(wantfd) {
continue
// Now verify that there are no other open fds.
var files []*os.File
for wantfd := basefds() + 1; wantfd <= 100; wantfd++ {
if poll.IsPollDescriptor(wantfd) {
continue
}
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)
var args []string
switch runtime.GOOS {
case "plan9":
args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())}
case "aix":
args = []string{fmt.Sprint(os.Getpid())}
default:
args = []string{"-p", fmt.Sprint(os.Getpid())}
}
f, err := os.Open(os.Args[0])
cmd := exec.Command(ofcmd, args...)
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf("error opening file with expected fd %d: %v", wantfd, err)
os.Exit(1)
fmt.Fprintf(os.Stderr, "%s failed: %v\n", strings.Join(cmd.Args, " "), err)
}
if got := f.Fd(); got != wantfd {
fmt.Printf("leaked parent file. fd = %d; want %d\n", got, wantfd)
var args []string
switch runtime.GOOS {
case "plan9":
args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())}
case "aix":
args = []string{fmt.Sprint(os.Getpid())}
default:
args = []string{"-p", fmt.Sprint(os.Getpid())}
}
cmd := exec.Command(ofcmd, args...)
out, err := cmd.CombinedOutput()
if err != nil {
fmt.Fprintf(os.Stderr, "%s failed: %v\n", strings.Join(cmd.Args, " "), err)
}
fmt.Printf("%s", out)
os.Exit(1)
}
files = append(files, f)
}
for _, f := range files {
f.Close()
fmt.Printf("%s", out)
os.Exit(1)
}
files = append(files, f)
}
for _, f := range files {
f.Close()
}
// Referring to fd3 here ensures that it is not
// garbage collected, and therefore closed, while
......
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