mirror of
https://github.com/golang/sys.git
synced 2026-02-08 19:56:04 +03:00
Test_anyToSockaddr on linux needs to create a socket with the given domain, type and protocol in order to test anyToSockaddr. Depending on kernel version, permission and other factors, a given combination might not be available on the system that runs the test, as is e.g. the case for AF_CAN/SOCK_DGRAM/CAN_J1939 on several builders after CL 272767. The only reason to create the socket is to be able to get the socket protocol in anyToSockaddr using GetsockoptInt(..., SO_PROTOCOL). Move this implementation into a wrapper func which can be overriden in tests to with a func unconditionally returning the protocol under test. This makes the test less dependent on the system it runs on and should fix the builders broken by CL 272767. While at it also removed the unused SocketSpec type in syscall_internal_bsd_test.go and remove an unnecessary error var declaration. Change-Id: Ie8754cf795fa96980b29ae43777f698cd86ae863 Reviewed-on: https://go-review.googlesource.com/c/sys/+/274046 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matt Layher <mdlayher@gmail.com>
69 KiB
69 KiB