Skip to content

Commit b89988c

Browse files
committed
internal/poll: remove outdated tests
TestFileFdsAreInitialised and TestSerialFdsAreInitialised were added to ensure handles passed to os.NewFile were not added to the runtime poller. This used to be problematic because the poller could crash if an external I/O event was received (see #21172). This is not an issue anymore since CL 482495 and #19098. Change-Id: I292ceae27724fefe6f438a398ebfe351dd5231d1 Reviewed-on: https://go-review.googlesource.com/c/go/+/665315 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Damien Neil <dneil@google.com>
1 parent 05ed8a0 commit b89988c

File tree

1 file changed

+0
-71
lines changed

1 file changed

+0
-71
lines changed

src/internal/poll/fd_windows_test.go

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -20,77 +20,6 @@ func init() {
2020
poll.InitWSA()
2121
}
2222

23-
// checkFileIsNotPartOfNetpoll verifies that f is not managed by netpoll.
24-
func checkFileIsNotPartOfNetpoll(t *testing.T, f *os.File) {
25-
t.Helper()
26-
sc, err := f.SyscallConn()
27-
if err != nil {
28-
t.Fatal(err)
29-
}
30-
if err := sc.Control(func(fd uintptr) {
31-
// Only try to associate the file with an IOCP if the handle is opened for overlapped I/O,
32-
// else the association will always fail.
33-
overlapped, err := windows.IsNonblock(syscall.Handle(fd))
34-
if err != nil {
35-
t.Fatalf("%v fd=%v: %v", f.Name(), fd, err)
36-
}
37-
if overlapped {
38-
// If the file is part of netpoll, then associating it with another IOCP should fail.
39-
if _, err := windows.CreateIoCompletionPort(syscall.Handle(fd), 0, 0, 1); err != nil {
40-
t.Fatalf("%v fd=%v: is part of netpoll, but should not be: %v", f.Name(), fd, err)
41-
}
42-
}
43-
}); err != nil {
44-
t.Fatalf("%v fd=%v: is not initialized", f.Name(), f.Fd())
45-
}
46-
}
47-
48-
func TestFileFdsAreInitialised(t *testing.T) {
49-
t.Parallel()
50-
exe, err := os.Executable()
51-
if err != nil {
52-
t.Fatal(err)
53-
}
54-
f, err := os.Open(exe)
55-
if err != nil {
56-
t.Fatal(err)
57-
}
58-
defer f.Close()
59-
60-
checkFileIsNotPartOfNetpoll(t, f)
61-
}
62-
63-
func TestSerialFdsAreInitialised(t *testing.T) {
64-
t.Parallel()
65-
for _, name := range []string{"COM1", "COM2", "COM3", "COM4"} {
66-
t.Run(name, func(t *testing.T) {
67-
t.Parallel()
68-
h, err := syscall.CreateFile(syscall.StringToUTF16Ptr(name),
69-
syscall.GENERIC_READ|syscall.GENERIC_WRITE,
70-
0,
71-
nil,
72-
syscall.OPEN_EXISTING,
73-
syscall.FILE_ATTRIBUTE_NORMAL|syscall.FILE_FLAG_OVERLAPPED,
74-
0)
75-
if err != nil {
76-
if errno, ok := err.(syscall.Errno); ok {
77-
switch errno {
78-
case syscall.ERROR_FILE_NOT_FOUND,
79-
syscall.ERROR_ACCESS_DENIED:
80-
t.Log("Skipping: ", err)
81-
return
82-
}
83-
}
84-
t.Fatal(err)
85-
}
86-
f := os.NewFile(uintptr(h), name)
87-
defer f.Close()
88-
89-
checkFileIsNotPartOfNetpoll(t, f)
90-
})
91-
}
92-
}
93-
9423
func TestWSASocketConflict(t *testing.T) {
9524
t.Parallel()
9625
s, err := windows.WSASocket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_TCP, nil, 0, windows.WSA_FLAG_OVERLAPPED)

0 commit comments

Comments
 (0)