Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: TestInterfaceAddrsWithNetsh fail on Windows 7 #14130

Closed
vdobler opened this issue Jan 28, 2016 · 9 comments
Closed

net: TestInterfaceAddrsWithNetsh fail on Windows 7 #14130

vdobler opened this issue Jan 28, 2016 · 9 comments

Comments

@vdobler
Copy link
Contributor

vdobler commented Jan 28, 2016

Go1.6rc1 on Windows 7, CGO_ENABLE=0:

--- FAIL: TestInterfaceAddrsWithNetsh (36.29s)
        net_windows_test.go:446: VMware Network Adapter VMnet8: unexpected addresses list ["192.168.209.1/24" "fe80::1587:c020:5827:b719"], want []
FAIL
FAIL    net     120.223s

The underlying cause is that netsh doesn't print anything when queried for this interface:

> netsh interface ipv4 show address name="VMware Network Adapter VMnet8"
[Nothing, just two blank lines]

But all information is output if not asked for this specific interface:

> netsh interface ipv4 show address
[...snip...]
Configuration for interface "VMware Network Adapter VMnet8"
    DHCP enabled:                         No
    IP Address:                           192.168.209.1
    Subnet Prefix:                        192.168.209.0/24 (mask 255.255.255.0)
    InterfaceMetric:                      20
[...snip...]

If the adapter is disabled this tests passes but then TestInterfaceHardwareAddrWithGetmac fails:
net_windows_test.go:528: getmac lists "VMware Network Adapter VMnet8", but it could not be found among Go interfaces

There might be some problem with this interface on Windows side.

@ianlancetaylor
Copy link
Contributor

CC @alexbrainman

@alexbrainman
Copy link
Member

@vdobler can you, please, run TestInterfaceHardwareAddrWithGetmac alone and show its error message in full. I think your error message above is missing its end. Thank you.

Alex

@vdobler
Copy link
Contributor Author

vdobler commented Jan 29, 2016

@alexbrainman Now it is Blootooth... :

$ go test -v -run TestInterfaceHardwareAddrWithGetmac net
=== RUN TestInterfaceHardwareAddrWithGetmac
--- FAIL: TestInterfaceHardwareAddrWithGetmac (3.14s)
net_windows_test.go:515: getmac lists "Bluetooth Network Connection", but it could not be found among Go interfaces map[isatap.{4A074996-3924-459F-BFCD-5970475AE151}:00:00:00:00:00:00:00:e0 VirtualBox Host-Only Network #2:08:00:27:00:60:5e Local Area Connection:ec:f4:bb:35:28:68 VirtualBox Host-Only Network #5:08:00:27:00:30:d5 VMware Network Adapter VMnet8:00:50:56:c0:00:08 isatap.{4A17C321-4472-4A7C-A305-82158B608E7F}:00:00:00:00:00:00:00:e0 isatap.{7F1E7FEE-3396-49AD-B22F-9B6A81EB3729}:00:00:00:00:00:00:00:e0 Reusable ISATAP Interface {D4CB953B-8F67-4964-B997-0A546C44D51F}:00:00:00:00:00:00:00:e0 isatap.{718ADE47-5B44-4AE4-A10E-849CDE26215D}:00:00:00:00:00:00:00:e0 Wireless Network Connection:80:86:f2:8e:55:a8 isatap.{A7C3755F-5CE1-4695-A67D-67C085D99088}:00:00:00:00:00:00:00:e0 Teredo Tunneling Pseudo-Interface:00:00:00:00:00:00:00:e0 isatap.{3160AADB-41E4-4A1A-B73F-D3FDBF455AE2}:00:00:00:00:00:00:00:e0 isatap.{FB7C9315-676D-4EAE-B550-CB8F59586F86}:00:00:00:00:00:00:00:e0 VirtualBox Host-Only Network #6:08:00:27:00:54:f8 isatap.{6E13A897-4E51-4F7A-8809-1D5B29E0CDF6}:00:00:00:00:00:00:00:e0 isatap.{E4154231-E9E3-45E0-8275-1AF043445EC0}:00:00:00:00:00:00:00:e0 Wireless Network Connection 2:82:86:f2:8e:55:a8 isatap.{954555DC-152A-4369-8EA8-6CE0F48ACBE3}:00:00:00:00:00:00:00:e0 isatap.{DD0440CD-133C-46D3-92ED-F6CE20D50AD4}:00:00:00:00:00:00:00:e0 Mobile Broadband Connection:00:a0:c6:00:00:12 VirtualBox Host-Only Network #4:08:00:27:00:8c:64 VMware Network Adapter VMnet1:00:50:56:c0:00:01 isatap.{9C819DC3-C04B-4D4C-904E-081E478C9765}:00:00:00:00:00:00:00:e0 VirtualBox Host-Only Network #3:08:00:27:00:fc:ba VirtualBox Host-Only Network:08:00:27:00:10:b7 isatap.{4BAD2286-A5D2-4D48-9C4D-4BCC6BFBA72A}:00:00:00:00:00:00:00:e0 Local Area Connection 2:00:ad:e1:ac:1c:1a]
FAIL
exit status 1
FAIL net 3.257s

@alexbrainman
Copy link
Member

@vdobler I am confused now. Your last error messages says: net_windows_test.go:515: getmac lists ..., but current net_windows_test.go:515 line cannot output this error. You must have changed the net_windows_test.go file. Your original error also says: net_windows_test.go:528: getmac lists ..., which seems correct to me - just another indication that you have changed the code.

But regardless of you changed the code. I don't see how TestInterfaceHardwareAddrWithGetmac is at fault here. The test has found "Bluetooth Network Connection" in the output of getmac /fo list /v command. Please check manually that "Bluetooth Network Connection" is listed in the output of getmac /fo list /v command. If "Bluetooth Network Connection" is listed by getmac command, it surely has to be returned by net.Interfaces function (see net_windows_test.go:459), and, it seems like, it is not. The only possible glitch in TestInterfaceHardwareAddrWithGetmac is that it ignores interfaces with net.FlagLoopback not set. But "Bluetooth Network Connection" should not be one of those. Can you, please, remove thse lines:

diff --git a/src/net/net_windows_test.go b/src/net/net_windows_test.go
index 095a339..e54199b 100644
--- a/src/net/net_windows_test.go
+++ b/src/net/net_windows_test.go
@@ -462,10 +462,6 @@ func TestInterfaceHardwareAddrWithGetmac(t *testing.T) {
    }
    have := make(map[string]string)
    for _, ifi := range ift {
-       if ifi.Flags&FlagLoopback != 0 {
-           // no MAC address for loopback interfaces
-           continue
-       }
        have[ifi.Name] = ifi.HardwareAddr.String()
    }

to see if it makes TestInterfaceHardwareAddrWithGetmac PASS? If TestInterfaceHardwareAddrWithGetmac is still broken, show us output of getmac /fo list /v command. Does "Bluetooth Network Connection" have non-blank MAC address there. If it does, surely net package should return the MAC too.

Thank you.

Alex

@vdobler
Copy link
Contributor Author

vdobler commented Feb 8, 2016

@alexbrainman Thanks for the feedback. And please excuse the confusion I produced, I'll try to be more systematic.

I think the Go code itself is okay and works properly.

But the test code executes netstat and getmac commands and parses their output and I believe this to be not robust enough. Actually these are two different non-robust tests; sorry for mixing these up in one issue.

I verified the following on go1.6rc1 and go1.6rc2 with a clean Go source tree and a (halfway freshly booted Windows 7 Enterprise Service Pack 1 with VMware Player 7.1.2 build-2780323 installed).

TestInterfaceAddrsWithNetsh

--- FAIL: TestInterfaceAddrsWithNetsh (13.02s)
    net_windows_test.go:446: VMware Network Adapter VMnet8: unexpected addresses list ["192.168.209.1/24" "fe80::1587:c020:5827:b719"], want []

but the problem is not the Go code as "192.168.209.1/24" is fine as it is the proper address as can be seen by running:

$ netsh interface ipv4 show address | grep -A 4 "VMware Network Adapter VMnet8"
Configuration for interface "VMware Network Adapter VMnet8"
    DHCP enabled:                         No
    IP Address:                           192.168.209.1
    Subnet Prefix:                        192.168.209.0/24 (mask 255.255.255.0)
    InterfaceMetric:                      20

Unfortunately the test code tries to get the address by executing

$ netsh interface ipv4 show address name="VMware Network Adapter VMnet8"

which returns 0 but prints just one blank line:

$ netsh interface ipv4 show address name="VMware Network Adapter VMnet8" | od -ta
0000000  cr  nl
0000002

This is strange and clearly a Windows-only, maybe even a "my-computer-only" problem.

The test code relies on the fact that netsh name="_the-name_" really returns sensible data which is not the case for my VMware Network Adapter VMnet8

Maybe parsing the whole output of netsh interface ipv4 show address could make the test more robust.

TestInterfaceHardwareAddrWithGetmac

If I disable (through Control Panel\Network and Internet\Network Connections) "VMware Network Adapter VMnet8" and have the wireless network turned off via the hardware switch then:

--- FAIL: TestInterfaceHardwareAddrWithGetmac (3.17s)
    net_windows_test.go:515: getmac lists "Bluetooth Network Connection", but it could not be found among Go interfaces map[VirtualBox Host-Only Network #2:08:00:27:00:60:5e VirtualBox Host-Only Network #5:08:00:27:00:30:d5 VirtualBox Host-Only Network #6:08:00:27:00:54:f8 Teredo Tunneling Pseudo-Interface:00:00:00:00:00:00:00:e0 isatap.{7F1E7FEE-3396-49AD-B22F-9B6A81EB3729}:00:00:00:00:00:00:00:e0 Wireless Network Connection 2:82:86:f2:8e:55:a8 Local Area Connection 2:00:ad:e1:ac:1c:1a Local Area Connection:ec:f4:bb:35:28:68 isatap.{E4154231-E9E3-45E0-8275-1AF043445EC0}:00:00:00:00:00:00:00:e0 isatap.{A7C3755F-5CE1-4695-A67D-67C085D99088}:00:00:00:00:00:00:00:e0 isatap.{DD0440CD-133C-46D3-92ED-F6CE20D50AD4}:00:00:00:00:00:00:00:e0 VirtualBox Host-Only Network:08:00:27:00:10:b7 VMware Network Adapter VMnet1:00:50:56:c0:00:01 isatap.{FB7C9315-676D-4EAE-B550-CB8F59586F86}:00:00:00:00:00:00:00:e0 isatap.{9C819DC3-C04B-4D4C-904E-081E478C9765}:00:00:00:00:00:00:00:e0 isatap.{954555DC-152A-4369-8EA8-6CE0F48ACBE3}:00:00:00:00:00:00:00:e0 isatap.{6E13A897-4E51-4F7A-8809-1D5B29E0CDF6}:00:00:00:00:00:00:00:e0 isatap.{4A074996-3924-459F-BFCD-5970475AE151}:00:00:00:00:00:00:00:e0 Mobile Broadband Connection:00:a0:c6:00:00:12 VirtualBox Host-Only Network #3:08:00:27:00:fc:ba isatap.corp.unic.com:00:00:00:00:00:00:00:e0 isatap.{3160AADB-41E4-4A1A-B73F-D3FDBF455AE2}:00:00:00:00:00:00:00:e0 Wireless Network Connection:80:86:f2:8e:55:a8 VirtualBox Host-Only Network #4:08:00:27:00:8c:64 isatap.{4A17C321-4472-4A7C-A305-82158B608E7F}:00:00:00:00:00:00:00:e0]
    net_windows_test.go:515: getmac lists "VMware Network Adapter VMnet8", but it could not be found among Go interfaces map[Mobile Broadband Connection:00:a0:c6:00:00:12 VirtualBox Host-Only Network #3:08:00:27:00:fc:ba isatap.corp.unic.com:00:00:00:00:00:00:00:e0 isatap.{9C819DC3-C04B-4D4C-904E-081E478C9765}:00:00:00:00:00:00:00:e0 isatap.{954555DC-152A-4369-8EA8-6CE0F48ACBE3}:00:00:00:00:00:00:00:e0 isatap.{6E13A897-4E51-4F7A-8809-1D5B29E0CDF6}:00:00:00:00:00:00:00:e0 isatap.{4A074996-3924-459F-BFCD-5970475AE151}:00:00:00:00:00:00:00:e0 Wireless Network Connection:80:86:f2:8e:55:a8 VirtualBox Host-Only Network #4:08:00:27:00:8c:64 isatap.{4A17C321-4472-4A7C-A305-82158B608E7F}:00:00:00:00:00:00:00:e0 isatap.{3160AADB-41E4-4A1A-B73F-D3FDBF455AE2}:00:00:00:00:00:00:00:e0 isatap.{7F1E7FEE-3396-49AD-B22F-9B6A81EB3729}:00:00:00:00:00:00:00:e0 Wireless Network Connection 2:82:86:f2:8e:55:a8 Local Area Connection 2:00:ad:e1:ac:1c:1a Local Area Connection:ec:f4:bb:35:28:68 VirtualBox Host-Only Network #2:08:00:27:00:60:5e VirtualBox Host-Only Network #5:08:00:27:00:30:d5 VirtualBox Host-Only Network #6:08:00:27:00:54:f8 Teredo Tunneling Pseudo-Interface:00:00:00:00:00:00:00:e0 VirtualBox Host-Only Network:08:00:27:00:10:b7 VMware Network Adapter VMnet1:00:50:56:c0:00:01 isatap.{FB7C9315-676D-4EAE-B550-CB8F59586F86}:00:00:00:00:00:00:00:e0 isatap.{E4154231-E9E3-45E0-8275-1AF043445EC0}:00:00:00:00:00:00:00:e0 isatap.{A7C3755F-5CE1-4695-A67D-67C085D99088}:00:00:00:00:00:00:00:e0 isatap.{DD0440CD-133C-46D3-92ED-F6CE20D50AD4}:00:00:00:00:00:00:00:e0]
FAIL

Running getmac:

$ getmac /fo list /v | grep -A 3 -E "VMnet8|Blue"
Connection Name:  Bluetooth Network Connection
Network Adapter:  Bluetooth Device (Personal Area Network)
Physical Address: N/A
Transport Name:   Hardware not present

--
Connection Name:  VMware Network Adapter VMnet8
Network Adapter:  VMware Virtual Ethernet Adapter for VMnet8
Physical Address: Disabled
Transport Name:   Disconnected

If I peek at TestInterfaceHardwareAddrWithGetmac around line 507 there is no code to test for the string "Disabled" or "N/A" as a value for "Physical Address" which explains the failed test.

A simple fix would be (I could prepare a complete CL):

diff --git a/src/net/net_windows_test.go b/src/net/net_windows_test.go
index 095a339..b9f116c 100644
--- a/src/net/net_windows_test.go
+++ b/src/net/net_windows_test.go
@@ -516,6 +516,9 @@ func TestInterfaceHardwareAddrWithGetmac(t *testing.T) {
                        if addr == "" {
                                t.Fatal("empty address on \"Physical Address\" line: %q", line)
                        }
+                       if addr == "disabled" || addr == "n/a" {
+                               continue
+                       }
                        addr = strings.Replace(addr, "-", ":", -1)
                        want[name] = addr
                        name = ""

@alexbrainman
Copy link
Member

@vdobler thank you for investigation. I agree we have to adjust these tests.

Maybe parsing the whole output of netsh interface ipv4 show address could make the test more robust.

I will try that.

netsh interface ipv4 show address

for ipv4, and

netsh interface ipv6 show address level=verbose

for ipv6.

A simple fix would be (I could prepare a complete CL):

Your proposed change looks good to me.

I will write a CL when I have some time. If you want to do it yourself (or even half of it), feel free to do it.

Thanks again.

Alex

@gopherbot
Copy link

CL https://golang.org/cl/19411 mentions this issue.

gopherbot pushed a commit that referenced this issue Feb 10, 2016
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>
@alexbrainman
Copy link
Member

@vdobler please check if https://go-review.googlesource.com/#/c/19441/ fixes problem on your computer. Thank you.

Alex

@gopherbot
Copy link

CL https://golang.org/cl/19441 mentions this issue.

@golang golang locked and limited conversation to collaborators Feb 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants