1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
5 // +build darwin dragonfly freebsd linux nacl netbsd openbsd solaris windows
15 var eofErrorTests
= []struct {
21 {100, nil, &netFD
{sotype
: syscall
.SOCK_STREAM
}, nil},
22 {100, io
.EOF
, &netFD
{sotype
: syscall
.SOCK_STREAM
}, io
.EOF
},
23 {100, errClosing
, &netFD
{sotype
: syscall
.SOCK_STREAM
}, errClosing
},
24 {0, nil, &netFD
{sotype
: syscall
.SOCK_STREAM
}, io
.EOF
},
25 {0, io
.EOF
, &netFD
{sotype
: syscall
.SOCK_STREAM
}, io
.EOF
},
26 {0, errClosing
, &netFD
{sotype
: syscall
.SOCK_STREAM
}, errClosing
},
28 {100, nil, &netFD
{sotype
: syscall
.SOCK_DGRAM
}, nil},
29 {100, io
.EOF
, &netFD
{sotype
: syscall
.SOCK_DGRAM
}, io
.EOF
},
30 {100, errClosing
, &netFD
{sotype
: syscall
.SOCK_DGRAM
}, errClosing
},
31 {0, nil, &netFD
{sotype
: syscall
.SOCK_DGRAM
}, nil},
32 {0, io
.EOF
, &netFD
{sotype
: syscall
.SOCK_DGRAM
}, io
.EOF
},
33 {0, errClosing
, &netFD
{sotype
: syscall
.SOCK_DGRAM
}, errClosing
},
35 {100, nil, &netFD
{sotype
: syscall
.SOCK_SEQPACKET
}, nil},
36 {100, io
.EOF
, &netFD
{sotype
: syscall
.SOCK_SEQPACKET
}, io
.EOF
},
37 {100, errClosing
, &netFD
{sotype
: syscall
.SOCK_SEQPACKET
}, errClosing
},
38 {0, nil, &netFD
{sotype
: syscall
.SOCK_SEQPACKET
}, io
.EOF
},
39 {0, io
.EOF
, &netFD
{sotype
: syscall
.SOCK_SEQPACKET
}, io
.EOF
},
40 {0, errClosing
, &netFD
{sotype
: syscall
.SOCK_SEQPACKET
}, errClosing
},
42 {100, nil, &netFD
{sotype
: syscall
.SOCK_RAW
}, nil},
43 {100, io
.EOF
, &netFD
{sotype
: syscall
.SOCK_RAW
}, io
.EOF
},
44 {100, errClosing
, &netFD
{sotype
: syscall
.SOCK_RAW
}, errClosing
},
45 {0, nil, &netFD
{sotype
: syscall
.SOCK_RAW
}, nil},
46 {0, io
.EOF
, &netFD
{sotype
: syscall
.SOCK_RAW
}, io
.EOF
},
47 {0, errClosing
, &netFD
{sotype
: syscall
.SOCK_RAW
}, errClosing
},
50 func TestEOFError(t
*testing
.T
) {
51 for _
, tt
:= range eofErrorTests
{
52 actual
:= tt
.fd
.eofError(tt
.n
, tt
.err
)
53 if actual
!= tt
.expected
{
54 t
.Errorf("eofError(%v, %v, %v): expected %v, actual %v", tt
.n
, tt
.err
, tt
.fd
.sotype
, tt
.expected
, actual
)