Retro68/gcc/libgo/go/net/main_windows_test.go

46 lines
1.1 KiB
Go
Raw Normal View History

2017-04-10 11:32:00 +00:00
// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package net
2018-12-28 15:30:48 +00:00
import "internal/poll"
2017-04-10 11:32:00 +00:00
var (
// Placeholders for saving original socket system calls.
origSocket = socketFunc
2018-12-28 15:30:48 +00:00
origWSASocket = wsaSocketFunc
origClosesocket = poll.CloseFunc
2017-04-10 11:32:00 +00:00
origConnect = connectFunc
2018-12-28 15:30:48 +00:00
origConnectEx = poll.ConnectExFunc
2017-04-10 11:32:00 +00:00
origListen = listenFunc
2018-12-28 15:30:48 +00:00
origAccept = poll.AcceptFunc
2017-04-10 11:32:00 +00:00
)
func installTestHooks() {
socketFunc = sw.Socket
2018-12-28 15:30:48 +00:00
wsaSocketFunc = sw.WSASocket
poll.CloseFunc = sw.Closesocket
2017-04-10 11:32:00 +00:00
connectFunc = sw.Connect
2018-12-28 15:30:48 +00:00
poll.ConnectExFunc = sw.ConnectEx
2017-04-10 11:32:00 +00:00
listenFunc = sw.Listen
2018-12-28 15:30:48 +00:00
poll.AcceptFunc = sw.AcceptEx
2017-04-10 11:32:00 +00:00
}
func uninstallTestHooks() {
socketFunc = origSocket
2018-12-28 15:30:48 +00:00
wsaSocketFunc = origWSASocket
poll.CloseFunc = origClosesocket
2017-04-10 11:32:00 +00:00
connectFunc = origConnect
2018-12-28 15:30:48 +00:00
poll.ConnectExFunc = origConnectEx
2017-04-10 11:32:00 +00:00
listenFunc = origListen
2018-12-28 15:30:48 +00:00
poll.AcceptFunc = origAccept
2017-04-10 11:32:00 +00:00
}
// forceCloseSockets must be called only from TestMain.
2017-04-10 11:32:00 +00:00
func forceCloseSockets() {
for s := range sw.Sockets() {
2018-12-28 15:30:48 +00:00
poll.CloseFunc(s)
2017-04-10 11:32:00 +00:00
}
}