mirror of
https://github.com/golang/go
synced 2024-11-24 00:50:10 -07:00
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/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>
This commit is contained in:
parent
79d9f48c73
commit
811b785193
@ -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 = ""
|
||||
|
Loading…
Reference in New Issue
Block a user