1 // Copyright 2015 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
12 // Placeholders for saving original socket system calls.
13 origSocket = socketFunc
14 origClose = poll.CloseFunc
15 origConnect = connectFunc
16 origListen = listenFunc
17 origAccept = poll.AcceptFunc
18 origGetsockoptInt = getsockoptIntFunc
20 extraTestHookInstallers []func()
21 extraTestHookUninstallers []func()
24 func installTestHooks() {
25 socketFunc = sw.Socket
26 poll.CloseFunc = sw.Close
27 connectFunc = sw.Connect
28 listenFunc = sw.Listen
29 poll.AcceptFunc = sw.Accept
30 getsockoptIntFunc = sw.GetsockoptInt
32 for _, fn := range extraTestHookInstallers {
37 func uninstallTestHooks() {
38 socketFunc = origSocket
39 poll.CloseFunc = origClose
40 connectFunc = origConnect
41 listenFunc = origListen
42 poll.AcceptFunc = origAccept
43 getsockoptIntFunc = origGetsockoptInt
45 for _, fn := range extraTestHookUninstallers {
50 // forceCloseSockets must be called only from TestMain.
51 func forceCloseSockets() {
52 for s := range sw.Sockets() {