unix: skip Linux/L2TP tests for kernels without L2TP support

Creating an IPPROTO_L2TP socket requires that the kernel's l2tp_ip or
l2tp_ip6 module is loaded.  If these modules are not running, the
socket call will return with error code EPROTONOSUPPORT.

To allow tests to run without the L2TP modules loaded, skip tests
where the unix.Socket() call returns EPROTONOSUPPORT.

Fixes golang/go#37787
This commit is contained in:
Tom Parkin
2020-03-12 14:34:51 +00:00
parent c0880b5844
commit 1750302e4b

View File

@@ -154,7 +154,12 @@ func Test_anyToSockaddr(t *testing.T) {
var err error
if tt.skt.domain != 0 {
fd, err = Socket(tt.skt.domain, tt.skt.typ, tt.skt.protocol)
if err != nil {
// Some sockaddr types need specific kernel modules running: if these
// are not present we'll get EPROTONOSUPPORT back when trying to create
// the socket. Skip the test in this situation.
if err == EPROTONOSUPPORT {
t.Skip("socket family/protocol not supported by kernel")
} else if err != nil {
t.Fatalf("socket(%v): %v", tt.skt, err)
}
defer func() {