...
1 package wasi_snapshot_preview1
2
3 import (
4 "os"
5 "testing"
6
7 "github.com/tetratelabs/wazero/experimental/sys"
8 "github.com/tetratelabs/wazero/internal/sock"
9 "github.com/tetratelabs/wazero/internal/testing/require"
10 "github.com/tetratelabs/wazero/internal/wasip1"
11 )
12
13 func Test_getExtendedWasiFiletype(t *testing.T) {
14 s := testSock{}
15 ftype := getExtendedWasiFiletype(s, os.ModeIrregular)
16 require.Equal(t, wasip1.FILETYPE_SOCKET_STREAM, ftype)
17
18 c := testConn{}
19 ftype = getExtendedWasiFiletype(c, os.ModeIrregular)
20 require.Equal(t, wasip1.FILETYPE_SOCKET_STREAM, ftype)
21 }
22
23 type testSock struct {
24 sys.UnimplementedFile
25 }
26
27 func (t testSock) Accept() (sock.TCPConn, sys.Errno) {
28 panic("no-op")
29 }
30
31 type testConn struct {
32 sys.UnimplementedFile
33 }
34
35 func (t testConn) Recvfrom([]byte, int) (n int, errno sys.Errno) {
36 panic("no-op")
37 }
38
39 func (t testConn) Shutdown(int) sys.Errno {
40 panic("no-op")
41 }
42
View as plain text