Skip to content

Commit

Permalink
net: make getmac based tests on windows more robust
Browse files Browse the repository at this point in the history
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 <[email protected]>
Run-TryBot: Alex Brainman <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Russ Cox <[email protected]>
  • Loading branch information
vdobler authored and rsc committed Feb 10, 2016
1 parent 79d9f48 commit 811b785
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/net/net_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 = ""
Expand Down

0 comments on commit 811b785

Please sign in to comment.