forked from mdlayher/vsock
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfd_linux_test.go
More file actions
33 lines (27 loc) · 1.25 KB
/
fd_linux_test.go
File metadata and controls
33 lines (27 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//+build linux
package vsock
import (
"os"
"golang.org/x/sys/unix"
)
var _ fd = &testFD{}
// A testFD is the test implementation of fd, with functions that can be set
// for each of its methods.
type testFD struct {
accept4 func(flags int) (fd, unix.Sockaddr, error)
bind func(sa unix.Sockaddr) error
close func() error
connect func(sa unix.Sockaddr) error
listen func(n int) error
newFile func(name string) *os.File
getsockname func() (unix.Sockaddr, error)
setNonblock func(nonblocking bool) error
}
func (fd *testFD) Accept4(flags int) (fd, unix.Sockaddr, error) { return fd.accept4(flags) }
func (fd *testFD) Bind(sa unix.Sockaddr) error { return fd.bind(sa) }
func (fd *testFD) Close() error { return fd.close() }
func (fd *testFD) Connect(sa unix.Sockaddr) error { return fd.connect(sa) }
func (fd *testFD) Getsockname() (unix.Sockaddr, error) { return fd.getsockname() }
func (fd *testFD) Listen(n int) error { return fd.listen(n) }
func (fd *testFD) NewFile(name string) *os.File { return fd.newFile(name) }
func (fd *testFD) SetNonblock(nonblocking bool) error { return fd.setNonblock(nonblocking) }