]> Cypherpunks repositories - gostls13.git/commitdiff
net: make getmac based tests on windows more robust
authorVolker Dobler <dr.volker.dobler@gmail.com>
Tue, 9 Feb 2016 13:39:52 +0000 (14:39 +0100)
committerRuss Cox <rsc@golang.org>
Wed, 10 Feb 2016 14:42:30 +0000 (14:42 +0000)
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>
src/net/net_windows_test.go

index 095a339e02c8e69a8a258526733ee94d8a92bd1e..c26c6a77c91443397eb392697ae8c00617df6996 100644 (file)
@@ -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 = ""