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.
5 // +build aix darwin dragonfly freebsd linux nacl netbsd openbsd solaris
10 // Placeholders for saving original socket system calls.
11 origSocket
= socketFunc
13 origConnect
= connectFunc
14 origListen
= listenFunc
15 origAccept
= acceptFunc
16 origGetsockoptInt
= getsockoptIntFunc
18 extraTestHookInstallers
[]func()
19 extraTestHookUninstallers
[]func()
22 func installTestHooks() {
23 socketFunc
= sw
.Socket
25 connectFunc
= sw
.Connect
26 listenFunc
= sw
.Listen
27 acceptFunc
= sw
.Accept
28 getsockoptIntFunc
= sw
.GetsockoptInt
30 for _
, fn
:= range extraTestHookInstallers
{
35 func uninstallTestHooks() {
36 socketFunc
= origSocket
38 connectFunc
= origConnect
39 listenFunc
= origListen
40 acceptFunc
= origAccept
41 getsockoptIntFunc
= origGetsockoptInt
43 for _
, fn
:= range extraTestHookUninstallers
{
48 // forceCloseSockets must be called only from TestMain.
49 func forceCloseSockets() {
50 for s
:= range sw
.Sockets() {