Commit 811b7851 authored by Volker Dobler's avatar Volker Dobler Committed by Russ Cox

net: make getmac based tests on windows more robust

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/19411Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 79d9f48c
......@@ -487,8 +487,13 @@ func TestInterfaceHardwareAddrWithGetmac(t *testing.T) {
//
//Connection Name: Bluetooth Network Connection
//Network Adapter: Bluetooth Device (Personal Area Network)
//Physical Address: XX-XX-XX-XX-XX-XX
//Transport Name: Media disconnected
//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
//
want := make(map[string]string)
var name string
......@@ -516,6 +521,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 = ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment