Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
G
golang
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
golang
Commits
178be83e
Commit
178be83e
authored
Dec 19, 2011
by
Brad Fitzpatrick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
exec: add test to verify net package's epoll fd doesn't go to child
R=rsc CC=golang-dev
https://golang.org/cl/5490075
parent
5425db8f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
1 deletion
+34
-1
exec_test.go
src/pkg/os/exec/exec_test.go
+34
-1
No files found.
src/pkg/os/exec/exec_test.go
View file @
178be83e
...
...
@@ -10,6 +10,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net"
"os"
"runtime"
"strconv"
...
...
@@ -146,6 +147,15 @@ func TestExtraFiles(t *testing.T) {
t
.
Logf
(
"no operating system support; skipping"
)
return
}
// Force network usage, to verify the epoll (or whatever) fd
// doesn't leak to the child,
ln
,
err
:=
net
.
Listen
(
"tcp"
,
"127.0.0.1:0"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
defer
ln
.
Close
()
tf
,
err
:=
ioutil
.
TempFile
(
""
,
""
)
if
err
!=
nil
{
t
.
Fatalf
(
"TempFile: %v"
,
err
)
...
...
@@ -167,7 +177,7 @@ func TestExtraFiles(t *testing.T) {
c
.
ExtraFiles
=
[]
*
os
.
File
{
tf
}
bs
,
err
:=
c
.
CombinedOutput
()
if
err
!=
nil
{
t
.
Fatalf
(
"CombinedOutput: %v
"
,
err
)
t
.
Fatalf
(
"CombinedOutput: %v
; output %q"
,
err
,
bs
)
}
if
string
(
bs
)
!=
text
{
t
.
Errorf
(
"got %q; want %q"
,
string
(
bs
),
text
)
...
...
@@ -246,6 +256,29 @@ func TestHelperProcess(*testing.T) {
fmt
.
Printf
(
"ReadAll from fd 3: %v"
,
err
)
os
.
Exit
(
1
)
}
// TODO(bradfitz,iant): the rest of this test is disabled
// for now. remove this block once 5494061 is in.
{
os
.
Stderr
.
Write
(
bs
)
os
.
Exit
(
0
)
}
// 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"
,
got
,
wantfd
)
os
.
Exit
(
1
)
}
files
=
append
(
files
,
f
)
}
for
_
,
f
:=
range
files
{
f
.
Close
()
}
os
.
Stderr
.
Write
(
bs
)
case
"exit"
:
n
,
_
:=
strconv
.
Atoi
(
args
[
0
])
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment