aboutsummaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorqmuntal <quimmuntal@gmail.com>2025-04-14 11:22:04 +0200
committerQuim Muntal <quimmuntal@gmail.com>2025-04-17 22:15:25 -0700
commitb89988c5ca47a6a2022db689fa882134397d0f32 (patch)
treee635db923c90a59f817632c0892a4fc9a5be5f6b /src/internal
parent05ed8a00e07e93fd40cf8269bdf16d6d2b34740d (diff)
downloadgo-b89988c5ca47a6a2022db689fa882134397d0f32.tar.xz
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>
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/poll/fd_windows_test.go71
1 files changed, 0 insertions, 71 deletions
diff --git a/src/internal/poll/fd_windows_test.go b/src/internal/poll/fd_windows_test.go
index 772008293e..6c7604fd74 100644
--- a/src/internal/poll/fd_windows_test.go
+++ b/src/internal/poll/fd_windows_test.go
@@ -20,77 +20,6 @@ func init() {
poll.InitWSA()
}
-// checkFileIsNotPartOfNetpoll verifies that f is not managed by netpoll.
-func checkFileIsNotPartOfNetpoll(t *testing.T, f *os.File) {
- t.Helper()
- sc, err := f.SyscallConn()
- if err != nil {
- t.Fatal(err)
- }
- if err := sc.Control(func(fd uintptr) {
- // Only try to associate the file with an IOCP if the handle is opened for overlapped I/O,
- // else the association will always fail.
- overlapped, err := windows.IsNonblock(syscall.Handle(fd))
- if err != nil {
- t.Fatalf("%v fd=%v: %v", f.Name(), fd, err)
- }
- if overlapped {
- // If the file is part of netpoll, then associating it with another IOCP should fail.
- if _, err := windows.CreateIoCompletionPort(syscall.Handle(fd), 0, 0, 1); err != nil {
- t.Fatalf("%v fd=%v: is part of netpoll, but should not be: %v", f.Name(), fd, err)
- }
- }
- }); err != nil {
- t.Fatalf("%v fd=%v: is not initialized", f.Name(), f.Fd())
- }
-}
-
-func TestFileFdsAreInitialised(t *testing.T) {
- t.Parallel()
- exe, err := os.Executable()
- if err != nil {
- t.Fatal(err)
- }
- f, err := os.Open(exe)
- if err != nil {
- t.Fatal(err)
- }
- defer f.Close()
-
- checkFileIsNotPartOfNetpoll(t, f)
-}
-
-func TestSerialFdsAreInitialised(t *testing.T) {
- t.Parallel()
- for _, name := range []string{"COM1", "COM2", "COM3", "COM4"} {
- t.Run(name, func(t *testing.T) {
- t.Parallel()
- h, err := syscall.CreateFile(syscall.StringToUTF16Ptr(name),
- syscall.GENERIC_READ|syscall.GENERIC_WRITE,
- 0,
- nil,
- syscall.OPEN_EXISTING,
- syscall.FILE_ATTRIBUTE_NORMAL|syscall.FILE_FLAG_OVERLAPPED,
- 0)
- if err != nil {
- if errno, ok := err.(syscall.Errno); ok {
- switch errno {
- case syscall.ERROR_FILE_NOT_FOUND,
- syscall.ERROR_ACCESS_DENIED:
- t.Log("Skipping: ", err)
- return
- }
- }
- t.Fatal(err)
- }
- f := os.NewFile(uintptr(h), name)
- defer f.Close()
-
- checkFileIsNotPartOfNetpoll(t, f)
- })
- }
-}
-
func TestWSASocketConflict(t *testing.T) {
t.Parallel()
s, err := windows.WSASocket(syscall.AF_INET, syscall.SOCK_STREAM, syscall.IPPROTO_TCP, nil, 0, windows.WSA_FLAG_OVERLAPPED)