forked from tetratelabs/wazero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sock_unit_test.go
41 lines (32 loc) · 895 Bytes
/
sock_unit_test.go
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
34
35
36
37
38
39
40
41
package wasi_snapshot_preview1
import (
"os"
"testing"
"github.com/tetratelabs/wazero/experimental/sys"
"github.com/tetratelabs/wazero/internal/sock"
"github.com/tetratelabs/wazero/internal/testing/require"
"github.com/tetratelabs/wazero/internal/wasip1"
)
func Test_getExtendedWasiFiletype(t *testing.T) {
s := testSock{}
ftype := getExtendedWasiFiletype(s, os.ModeIrregular)
require.Equal(t, wasip1.FILETYPE_SOCKET_STREAM, ftype)
c := testConn{}
ftype = getExtendedWasiFiletype(c, os.ModeIrregular)
require.Equal(t, wasip1.FILETYPE_SOCKET_STREAM, ftype)
}
type testSock struct {
sys.UnimplementedFile
}
func (t testSock) Accept() (sock.TCPConn, sys.Errno) {
panic("no-op")
}
type testConn struct {
sys.UnimplementedFile
}
func (t testConn) Recvfrom([]byte, int) (n int, errno sys.Errno) {
panic("no-op")
}
func (t testConn) Shutdown(int) sys.Errno {
panic("no-op")
}