aboutsummaryrefslogtreecommitdiff
path: root/src/net/net_windows_test.go
AgeCommit message (Collapse)Author
2025-08-11net, os, file/filepath, syscall: use slices.Equal in testsTobias Klauser
Use slices.Equal to compare slices instead of strings.Join and then comparing strings. Change-Id: Ib916002b7357bd7f4e66b853dd7af8d98eba5549 Reviewed-on: https://go-review.googlesource.com/c/go/+/690475 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2025-02-25all: surround -test.run arguments with ^$qmuntal
If the -test.run value is not surrounded by ^$ then any test that matches the -test.run value will be run. This is normally not the desired behavior, as it can lead to unexpected tests being run. Change-Id: I3447aaebad5156bbef7f263cdb9f6b8c32331324 Reviewed-on: https://go-review.googlesource.com/c/go/+/651956 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2025-02-24all: use testenv.Executable instead of os.Executable and os.Args[0]qmuntal
In test files, using testenv.Executable is more reliable than os.Executable or os.Args[0]. Change-Id: I88e577efeabc20d02ada27bf706ae4523129128e Reviewed-on: https://go-review.googlesource.com/c/go/+/651955 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2025-02-04net: use strings.SplitSeq and bytes.SplitSeqapocelipes
Replace `for _, s := range {strings, bytes}.Split(v, sep)` with `for s := range {strings, bytes}.SplitSeq(v, sep)`, to simplify the code and reduce some memory allocations. Change-Id: Idead4de1e3928fc75cc5ba8caeff85542f1243d5 GitHub-Last-Rev: 5fb196a073e7583b23b1ebb446d6c067580ed63a GitHub-Pull-Request: golang/go#71554 Reviewed-on: https://go-review.googlesource.com/c/go/+/646216 Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-05-23all: change from sort functions to slices functions where feasibleIan Lance Taylor
Doing this because the slices functions are slightly faster and slightly easier to use. It also removes one dependency layer. This CL does not change packages that are used during bootstrap, as the bootstrap compiler does not have the required slices functions. It does not change the go/scanner package because the ErrorList Len, Swap, and Less methods are part of the Go 1 API. Change-Id: If52899be791c829198e11d2408727720b91ebe8a Reviewed-on: https://go-review.googlesource.com/c/go/+/587655 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
2022-03-31net: skip tests that use netsh on the windows-arm64-10 builderBryan C. Mills
These tests sometimes hang on Windows 10 on ARM64, due to what appears to be a platform bug. Since we have not yet observed any such hangs on the windows-arm64-11 builder, I am leaving the tests otherwise enabled on the theory that the platform bug may have been fixed in Windows 11. Fixes #52082 (at least for now). Change-Id: I79161f485b1921f083ebcf01865d6e7b0178ef70 Reviewed-on: https://go-review.googlesource.com/c/go/+/397315 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-02-19net: disable Windows netsh tests when netsh won't runRuss Cox
On my Surface Pro X running the insider preview, running "netsh help" from Powershell started from the task bar works. But running "powershell" at a cmd.exe prompt and then running "netsh help" produces missing DLL errors. These aren't our fault, so just skip the netsh-based tests if this happens. Change-Id: I13a17e01143d823d3b5242d827db056bd253e3e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/293849 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-26all: use strings.ReplaceAll and bytes.ReplaceAll where applicableBrad Fitzpatrick
I omitted vendor directories and anything necessary for bootstrapping. (Tested by bootstrapping with Go 1.4) Updates #27864 Change-Id: I7d9b68d0372d3a34dee22966cca323513ece7e8a Reviewed-on: https://go-review.googlesource.com/137856 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-02-15all: drop support for Windows Vista or below (Windows XP)Mikio Hara
Per the notice in the Go 1.10 release notes, this change drops the support for Windows Vista or below (including Windows XP) and simplifies the code for the sake of maintenance. There is one exception to the above. The code related to DLL and system calls still remains in the runtime package. The remaining code will be refined and used for supporting upcoming Windows versions in future. Updates #17245 Fixes #23072 Change-Id: I9e2821721f25ef9b83dfbf85be2b7ee5d9023aa5 Reviewed-on: https://go-review.googlesource.com/94255 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-12-25net: revert CL 82975Jeff Johnson
this solution as it stands doesn't work with non-english device names (golang/go#23191 (which has a fix)) and names some devices differently (golang/go#23153) probably due to the fact that this test previously only ran on Server 2008. Re-opens golang/go#20073 Change-Id: I5c36774ddd85ac07620b4015372d564acbb169ad Reviewed-on: https://go-review.googlesource.com/85315 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2017-12-08net: enable TestInterfaceHardwareAddrWithGetmac on all windows versionsJeff Johnson
Re-work the test to use wmic instead of PowerShell's getmac that's only avaliable on Server 2008. Maintains duplicate detection added for golang/go#21027. Tested on windows-amd64-{2008, 2012, 2016} buildlets. Enabling for Windows XP because it should work[1]. Fixes golang/go#20073 [1] https://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/wmic_overview.mspx?mfr=true Change-Id: Ic11d569f7964f61d08ae0dcc1b926efc5336ac5b Reviewed-on: https://go-review.googlesource.com/82975 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-11-10net: ignore duplicate interfaces in TestInterfaceHardwareAddrWithGetmacAlex Brainman
Sometimes getmac lists many interfaces for the same MAC address, while Interfaces returns only single name for that address. Adjust the test to ignore the names that are not returned by the Interfaces. Fixes #21027 Change-Id: I08d98746a7c669f2d730dba2da36e07451a6f405 Reviewed-on: https://go-review.googlesource.com/59411 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
2017-06-29net: fix Windows TestInterfaceHardwareAddrWithGetmacEgon Elbre
TestInterfaceHardwareAddrWithGetmac was panicing when getmac returned multiple network cards. Change-Id: I6fefa5a4910bce805b4cd9c09f94bd56c9682b9e Reviewed-on: https://go-review.googlesource.com/47190 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18net: adjust TestInterfaceHardwareAddrWithGetmacAlex Brainman
Ignore adapters with "Transport Name: N/A" line in getmac command output. This allows us to skip duplicate MAC addresses. Fixes #19537. Change-Id: I6b7be9d31322f963e02023c8f1037f6e9042b479 Reviewed-on: https://go-review.googlesource.com/39071 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Avelino <t@avelino.xxx> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-04-21net: skip Windows test using getmac if getmac cmdlet not availableBrad Fitzpatrick
This doesn't appear to be present on Windows Server 2012 or 2016: https://build.golang.org/log/6ea21b99c9b8a2be20f9aeaec6c425b84faf1af7 https://build.golang.org/log/2bcf04f1df003577352f4f987a39a59a081094ee Updates golang/go#17513 Updates golang/go#20073 Change-Id: I72820704b4cb16bb1720b7f6a9f2e10028c71334 Reviewed-on: https://go-review.googlesource.com/41395 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2016-03-30net: skip TestInterfacesWithNetsh if "netsh help" contains no English wordsAlex Brainman
Fixes #14859 Change-Id: I262d634ee22498ec9855d273afdd409149765294 Reviewed-on: https://go-review.googlesource.com/21195 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-03-02net: fix vet warningsMohit Agarwal
Updates #11041 Change-Id: I12c20beab75d7981efe470eb418e4b58dc8eb066 Reviewed-on: https://go-review.googlesource.com/20002 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-24all: fix typos and spellingMartin Möhrmann
Change-Id: Icd06d99c42b8299fd931c7da821e1f418684d913 Reviewed-on: https://go-review.googlesource.com/19829 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-16net: make TestInterfaceAddrsWithNetsh more robustAlex Brainman
TestInterfaceAddrsWithNetsh invokes Windows netsh command passing it a particular interface name. This approach somehow does not work on some computers (see issue for details). Change that to call netsh without specifying any interface name. This provides output for all interfaces available. So we can achieve same goal parsing this output. Also makes test faster because we only need to invoke netsh once. Fixes #14130. Change-Id: I7911692ca64e372af1e1f9d6acb718c67071de67 Reviewed-on: https://go-review.googlesource.com/19441 Reviewed-by: Volker Dobler <dr.volker.dobler@gmail.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2016-02-10net: make getmac based tests on windows more robustVolker Dobler
The Windows 7 getmac command may report the physical address of an adapter as "Disabled" or "N/A". Handle these two cases to make the tests more robust when building on Windows with manually disabled adapters or turned off hardware. Addresses issue #14130. Change-Id: I0c2f8554b4b6810568e4e60ed53857599401f296 Reviewed-on: https://go-review.googlesource.com/19411 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2016-01-21net: improve netsh usage in Windows unit testsTim Ebringer
The TestInterfaceAddrsWithNetsh Windows unit test parses and compares the output of the "netsh" command against more low level Windows API calls. In at least two cases, some quirks of netsh cause these comparisons to fail. One example appears to be wi-fi adapters. After a reboot, before it has been allowed to connect to a network, netsh for IPv4 will not show an address, whereas netsh for IPv6 will. If the interface is allowed to connect, and then disconnected, netsh for IPv4 now shows an address and the test will pass. The fix is to not compare netsh output if the interface is down. A related issue is that the IPv6 version of "netsh" can return an IPv4-embedded IPv6 address where the IPv4 component of the address is in decimal form, whilst the test is expecting hexadecimal form. For example, output might be: Address fe80::5efe:192.168.1.7%6 Parameters ... Whilst this is valid notation, the fix is to recognise this format in the "netsh" output and re-parse the address into the all-hexadecimal representation that the test is expecting. Fixes #13981 Change-Id: Ie8366673f4d43d07bad80d6d5d1d6e33f654b6cc Reviewed-on: https://go-review.googlesource.com/18711 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-01-18net: disable TestInterfaceAddrsWithNetsh on windowsMikio Hara
Updates #13981. Change-Id: Id8f3cd56a81a7a993cea5c757e619407da491fed Reviewed-on: https://go-review.googlesource.com/18710 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-12-19net: adjust TestInterfaceHardwareAddrWithGetmacAlex Brainman
CL skips interfaces that are not listed on getmac output. Fixes #13606 Change-Id: Ic25c9dc95e8eeff4d84b78e99131a4f97020164c Reviewed-on: https://go-review.googlesource.com/17994 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
2015-12-17net: include both ipv4 and ipv6 netsh output in TestInterfacesWithNetshAlex Brainman
Also include test for interface state (up or down). Updates #13606 Change-Id: I03538d65525ddd9c2d0254761861c2df7fc5bd5a Reviewed-on: https://go-review.googlesource.com/17850 Reviewed-by: Russ Cox <rsc@golang.org> Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Run-TryBot: Russ Cox <rsc@golang.org>
2015-12-10net, internal/syscall/windows: fix interface and address identification on ↵Mikio Hara
windows The current implementation including Go 1.5 through 1.5.2 misuses Windows API and mishandles the returned values from GetAdapterAddresses on Windows. This change fixes various issues related to network facility information by readjusting interface and interface address parsers. Updates #5395. Updates #10530. Updates #12301. Updates #12551. Updates #13542. Fixes #12691. Fixes #12811. Fixes #13476. Fixes #13544. Also fixes fragile screen scraping test cases in net_windows_test.go. Additional information for reviewers: It seems like almost all the issues above have the same root cause and it is misunderstanding of Windows API. If my interpretation of the information on MSDN is correctly, current implementation contains the following bugs: - SIO_GET_INTERFACE_LIST should not be used for IPv6. The behavior of SIO_GET_INTERFACE_LIST is different on kernels and probably it doesn't work correctly for IPv6 on old kernels such as Windows XP w/ SP2. Unfortunately MSDN doesn't describe the detail of SIO_GET_INTERFACE_LIST, but information on the net suggests so. - Fetching IP_ADAPTER_ADDRESSES structures with fixed size area may not work when using IPv6. IPv6 generates ton of interface addresses for various addressing scopes. We need to adjust the area appropriately. - PhysicalAddress field of IP_ADAPTER_ADDRESSES structure may have extra space. We cannot ignore PhysicalAddressLength field of IP_ADAPTER_ADDRESS structure. - Flags field of IP_ADAPTER_ADDRESSES structure doesn't represent any of administratively and operatinal statuses. It just represents settings for windows network adapter. - MTU field of IP_ADAPTER_ADDRESSES structure may have a uint32(-1) on 64-bit platform. We need to convert the value to interger appropriately. - IfType field of IP_ADAPTER_ADDRESSES structure is not a bit field. Bitwire operation for the field is completely wrong. - OperStatus field of IP_ADAPTER_ADDRESSES structure is not a bit field. Bitwire operation for the field is completely wrong. - IPv6IfIndex field of IP_ADAPTER_ADDRESSES structure is just a substitute for IfIndex field. We cannot prefer IPv6IfIndex to IfIndex. - Windows XP, 2003 server and below don't set OnLinkPrefixLength field of IP_ADAPTER_UNICAST_ADDRESS structure. We cannot rely on the field on old kernels. We can use FirstPrefix field of IP_ADAPTER_ADDRESSES structure and IP_ADAPTER_PREFIX structure instead. - Length field of IP_ADAPTER_{UNICAST,ANYCAST,MULTICAST}_ADDRESS sturecures doesn't represent an address prefix length. It just represents a socket address length. Change-Id: Icabdaf7bd1d41360a981d2dad0b830b02b584528 Reviewed-on: https://go-review.googlesource.com/17412 Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-12-09net: add TestInterfaceHardwareAddrWithGetmacAlex Brainman
Use Windows getmac command to verify interface MAC addresses net package returns. The test is to be enabled once issue #12691 is fixed. Updates #12691 Change-Id: Ic28c83303590cb4d48ee025250d4b6e30683bfd4 Reviewed-on: https://go-review.googlesource.com/17632 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-12-09net: add TestInterfaceAddrsWithNetshAlex Brainman
Use windows netsh command to verify interface addresses and netmasks net package returns. The test is to be enabled once issue #12811 is fixed. Updates #12811 Change-Id: I191e350a1403e5133791d4ec59561fefa24f5c61 Reviewed-on: https://go-review.googlesource.com/17478 Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com> Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-11-13net: make TestInterfaceList work on non-English WindowsYasuhiro Matsumoto
Fixes #13198 The output of netsh is encoded with ANSI encoding. So doesn't match with UTF-8 strings. Write output as UTF-8 using powershell. Change-Id: I6c7e93c590ed407f24ae847601d71df9523e028c Reviewed-on: https://go-review.googlesource.com/16756 TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-11-10net: fix off by one error while counting interfaces on windowsAlex Brainman
Fixes #12301 Change-Id: I8d01ec9551c6cff7e6129e06a7deb36a3be9de41 Reviewed-on: https://go-review.googlesource.com/16751 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-05-12net: relax error checking in TestAcceptIgnoreSomeErrorsAlex Brainman
TestAcceptIgnoreSomeErrors was created to test that network accept function ignores some errors. But conditions created by the test also affects network reads. Change the test to ignore these read errors when acceptable. Fixes #10785 Change-Id: I3da85cb55bd3e78c1980ad949e53e82391f9b41e Reviewed-on: https://go-review.googlesource.com/9942 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-05-07net: do not skip TestAcceptIgnoreSomeErrorsAlex Brainman
No code changes, but the test passes here. And TryBots are happy. Fixes #8662 maybe Change-Id: Id37380f72a951c9ad7cf96c0db153c05167e62ed Reviewed-on: https://go-review.googlesource.com/9778 Reviewed-by: Minux Ma <minux@golang.org>
2015-05-06net: simplify error messages in testsMikio Hara
This change simplifies unnecessarily redundant error messages in tests. There's no need to worry any more because package APIs now return consistent, self-descriptive error values. Alos renames ambiguous test functions and makes use of test tables. Change-Id: I7b61027607c4ae2a3cf605d08d58cf449fa27eb2 Reviewed-on: https://go-review.googlesource.com/9662 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
2014-09-08build: move package sources from src/pkg to srcRuss Cox
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.