Source file
src/net/main_unix_test.go
1
2
3
4
5
6
7 package net
8
9 import (
10 "internal/poll"
11 "os/exec"
12 )
13
14 var (
15
16 origSocket = socketFunc
17 origClose = poll.CloseFunc
18 origConnect = connectFunc
19 origListen = listenFunc
20 origAccept = poll.AcceptFunc
21 origGetsockoptInt = getsockoptIntFunc
22
23 extraTestHookInstallers []func()
24 extraTestHookUninstallers []func()
25 )
26
27 func installTestHooks() {
28 socketFunc = sw.Socket
29 poll.CloseFunc = sw.Close
30 connectFunc = sw.Connect
31 listenFunc = sw.Listen
32 poll.AcceptFunc = sw.Accept
33 getsockoptIntFunc = sw.GetsockoptInt
34
35 for _, fn := range extraTestHookInstallers {
36 fn()
37 }
38 }
39
40 func uninstallTestHooks() {
41 socketFunc = origSocket
42 poll.CloseFunc = origClose
43 connectFunc = origConnect
44 listenFunc = origListen
45 poll.AcceptFunc = origAccept
46 getsockoptIntFunc = origGetsockoptInt
47
48 for _, fn := range extraTestHookUninstallers {
49 fn()
50 }
51 }
52
53
54 func forceCloseSockets() {
55 for s := range sw.Sockets() {
56 poll.CloseFunc(s)
57 }
58 }
59
60 func addCmdInheritedHandle(cmd *exec.Cmd, fd uintptr) {}
61
View as plain text