From 1750302e4be0a1d872bb26ee8a4d077fed496d89 Mon Sep 17 00:00:00 2001 From: Tom Parkin Date: Thu, 12 Mar 2020 14:34:51 +0000 Subject: [PATCH] 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 --- unix/syscall_internal_linux_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unix/syscall_internal_linux_test.go b/unix/syscall_internal_linux_test.go index 17684965..af56f833 100644 --- a/unix/syscall_internal_linux_test.go +++ b/unix/syscall_internal_linux_test.go @@ -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() {