commit | 760e229fe7c59d73e847df06a64f6dc9b36b83d5 | [log] [tgz] |
---|---|---|
author | Tobias Klauser <tklauser@distanz.ch> | Mon Nov 30 11:53:36 2020 +0100 |
committer | Tobias Klauser <tobias.klauser@gmail.com> | Mon Nov 30 17:19:29 2020 +0000 |
tree | 6b9e34eb9999a03cf54c73935a43769b79854038 | |
parent | 111129e158e253c67594dc4ea20d2e600aec2534 [diff] |
unix: test anyToSockaddr without creating actual socket 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>
This repository holds supplemental Go packages for low-level interactions with the operating system.
The easiest way to install is to run go get -u golang.org/x/sys
. You can also manually git clone the repository to $GOPATH/src/golang.org/x/sys
.
This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.
The main issue tracker for the sys repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/sys:” in the subject line, so it is easy to find.