MCPcopy Create free account
hub / github.com/cloudwego/netpoll / TestDialerUnix

Function TestDialerUnix

net_dialer_test.go:66–106  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

64}
65
66func TestDialerUnix(t *testing.T) {
67 dialer := NewDialer()
68 conn, err := dialer.DialTimeout("unix", "tmp.sock", time.Second)
69 MustTrue(t, err != nil)
70 MustTrue(t, conn.(*UnixConnection) == nil)
71
72 ln, err := CreateListener("unix", "tmp.sock")
73 MustNil(t, err)
74 defer ln.Close()
75
76 stop := make(chan int, 1)
77 defer func() {
78 close(stop)
79 time.Sleep(time.Millisecond)
80 }()
81
82 go func() {
83 for {
84 select {
85 case <-stop:
86 err := ln.Close()
87 MustNil(t, err)
88 return
89 default:
90 }
91 conn, err := ln.Accept()
92 if conn == nil && err == nil {
93 continue
94 }
95 }
96 }()
97
98 conn, err = dialer.DialTimeout("unix", "tmp.sock", time.Second)
99 MustNil(t, err)
100 if runtime.GOOS == "linux" {
101 Equal(t, conn.LocalAddr().String(), "@")
102 } else {
103 Equal(t, conn.LocalAddr().String(), "")
104 }
105 Equal(t, conn.RemoteAddr().String(), "tmp.sock")
106}
107
108func TestDialerFdAlloc(t *testing.T) {
109 address := getTestAddress()

Callers

nothing calls this directly

Calls 10

DialTimeoutMethod · 0.95
AcceptMethod · 0.80
LocalAddrMethod · 0.80
RemoteAddrMethod · 0.80
NewDialerFunction · 0.70
CreateListenerFunction · 0.70
CloseMethod · 0.65
MustTrueFunction · 0.50
MustNilFunction · 0.50
EqualFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…