]> Cypherpunks repositories - gostls13.git/commitdiff
os/exec: disable fd check in TestHelperProcess on Plan 9
authorDavid du Colombier <0intro@gmail.com>
Mon, 13 Jan 2014 22:03:22 +0000 (23:03 +0100)
committerDavid du Colombier <0intro@gmail.com>
Mon, 13 Jan 2014 22:03:22 +0000 (23:03 +0100)
On Plan 9, we can observe the following open file descriptors:

  0 r  c    0 (000000000000000a   0 00)     0        0 /dev/null
  1 rw |    0 (0000000001df6742   0 00) 65536       54 #|/data1
  2 rw |    0 (0000000001df6782   0 00) 65536        0 #|/data1
  3 rw M 1956 (0000000000d66dd2   0 00)  8192       12 /tmp/333163398
  4 r  c    0 (0000000000000001   0 00)     0      528 /dev/bintime
  5 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
  6 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
  7 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
  8 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
  9 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
 10 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
 11 r  c    0 (000000000000000f   0 00)     0       32 /dev/random
 12 r  M 1956 (0000000000d66dd1 854 00)  8192        0 /tmp/go-build843954301/os/exec/_test/exec.test
 13 r  c    0 (000000000000000a   0 00)     0        0 /dev/null
 14 rw |    0 (0000000001df6801   0 00) 65536        0 #|/data
 15 rw |    0 (0000000001df6802   0 00) 65536     1275 #|/data1

R=rsc, bradfitz, aram
CC=golang-codereviews
https://golang.org/cl/51420044

src/pkg/os/exec/exec_test.go

index 144fd46bcdcd6b277a7f422c22d5ffac8ceae1d8..ad71503a838b9254e92bab26e550971f9d1893d6 100644 (file)
@@ -480,6 +480,8 @@ func TestHelperProcess(*testing.T) {
        switch runtime.GOOS {
        case "dragonfly", "freebsd", "netbsd", "openbsd":
                ofcmd = "fstat"
+       case "plan9":
+               ofcmd = "/bin/cat"
        }
 
        args := os.Args
@@ -570,6 +572,10 @@ func TestHelperProcess(*testing.T) {
                        // the cloned file descriptors that result from opening
                        // /dev/urandom.
                        // http://golang.org/issue/3955
+               case "plan9":
+                       // TODO(0intro): Determine why Plan 9 is leaking
+                       // file descriptors.
+                       // http://golang.org/issue/7118
                case "solaris":
                        // TODO(aram): This fails on Solaris because libc opens
                        // its own files, as it sees fit. Darwin does the same,
@@ -585,7 +591,14 @@ func TestHelperProcess(*testing.T) {
                                }
                                if got := f.Fd(); got != wantfd {
                                        fmt.Printf("leaked parent file. fd = %d; want %d\n", got, wantfd)
-                                       out, _ := exec.Command(ofcmd, "-p", fmt.Sprint(os.Getpid())).CombinedOutput()
+                                       var args []string
+                                       switch runtime.GOOS {
+                                       case "plan9":
+                                               args = []string{fmt.Sprintf("/proc/%d/fd", os.Getpid())}
+                                       default:
+                                               args = []string{"-p", fmt.Sprint(os.Getpid())}
+                                       }
+                                       out, _ := exec.Command(ofcmd, args...).CombinedOutput()
                                        fmt.Print(string(out))
                                        os.Exit(1)
                                }