Skip to content

Commit f38a510

Browse files
author
Bryan C. Mills
committed
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 <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 4569f1b commit f38a510

File tree

1 file changed

+30
-49
lines changed

1 file changed

+30
-49
lines changed

src/os/exec/exec_test.go

Lines changed: 30 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -821,59 +821,40 @@ func TestHelperProcess(*testing.T) {
821821
fmt.Printf("ReadAll from fd 3: %v", err)
822822
os.Exit(1)
823823
}
824-
switch runtime.GOOS {
825-
case "dragonfly":
826-
// TODO(jsing): Determine why DragonFly is leaking
827-
// file descriptors...
828-
case "darwin":
829-
// TODO(bradfitz): broken? Sometimes.
830-
// https://golang.org/issue/2603
831-
// Skip this additional part of the test for now.
832-
case "netbsd":
833-
// TODO(jsing): This currently fails on NetBSD due to
834-
// the cloned file descriptors that result from opening
835-
// /dev/urandom.
836-
// https://golang.org/issue/3955
837-
case "illumos", "solaris":
838-
// TODO(aram): This fails on Solaris because libc opens
839-
// its own files, as it sees fit. Darwin does the same,
840-
// see: https://golang.org/issue/2603
841-
default:
842-
// Now verify that there are no other open fds.
843-
var files []*os.File
844-
for wantfd := basefds() + 1; wantfd <= 100; wantfd++ {
845-
if poll.IsPollDescriptor(wantfd) {
846-
continue
824+
// Now verify that there are no other open fds.
825+
var files []*os.File
826+
for wantfd := basefds() + 1; wantfd <= 100; wantfd++ {
827+
if poll.IsPollDescriptor(wantfd) {
828+
continue
829+
}
830+
f, err := os.Open(os.Args[0])
831+
if err != nil {
832+
fmt.Printf("error opening file with expected fd %d: %v", wantfd, err)
833+
os.Exit(1)
834+
}
835+
if got := f.Fd(); got != wantfd {
836+
fmt.Printf("leaked parent file. fd = %d; want %d\n", got, wantfd)
837+
var args []string
838+
switch runtime.GOOS {
839+
case "plan9":
840+
args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())}
841+
case "aix":
842+
args = []string{fmt.Sprint(os.Getpid())}
843+
default:
844+
args = []string{"-p", fmt.Sprint(os.Getpid())}
847845
}
848-
f, err := os.Open(os.Args[0])
846+
cmd := exec.Command(ofcmd, args...)
847+
out, err := cmd.CombinedOutput()
849848
if err != nil {
850-
fmt.Printf("error opening file with expected fd %d: %v", wantfd, err)
851-
os.Exit(1)
849+
fmt.Fprintf(os.Stderr, "%s failed: %v\n", strings.Join(cmd.Args, " "), err)
852850
}
853-
if got := f.Fd(); got != wantfd {
854-
fmt.Printf("leaked parent file. fd = %d; want %d\n", got, wantfd)
855-
var args []string
856-
switch runtime.GOOS {
857-
case "plan9":
858-
args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())}
859-
case "aix":
860-
args = []string{fmt.Sprint(os.Getpid())}
861-
default:
862-
args = []string{"-p", fmt.Sprint(os.Getpid())}
863-
}
864-
cmd := exec.Command(ofcmd, args...)
865-
out, err := cmd.CombinedOutput()
866-
if err != nil {
867-
fmt.Fprintf(os.Stderr, "%s failed: %v\n", strings.Join(cmd.Args, " "), err)
868-
}
869-
fmt.Printf("%s", out)
870-
os.Exit(1)
871-
}
872-
files = append(files, f)
873-
}
874-
for _, f := range files {
875-
f.Close()
851+
fmt.Printf("%s", out)
852+
os.Exit(1)
876853
}
854+
files = append(files, f)
855+
}
856+
for _, f := range files {
857+
f.Close()
877858
}
878859
// Referring to fd3 here ensures that it is not
879860
// garbage collected, and therefore closed, while

0 commit comments

Comments
 (0)