aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2017-04-21 20:43:08 +0000
committerRuss Cox <rsc@golang.org>2017-10-25 18:56:37 +0000
commit7e2cd1d81ee7048d3feee75602c63bd631f825bc (patch)
tree265b47136f8901a9d4043e0b30baf938cc9cca17
parentf5bcb9b8fe9dd8949d4682b74be6ba72e5d554fb (diff)
downloadgo-7e2cd1d81ee7048d3feee75602c63bd631f825bc.tar.gz
go-7e2cd1d81ee7048d3feee75602c63bd631f825bc.zip
[release-branch.go1.8] net: skip Windows test using getmac if getmac cmdlet not available
This doesn't appear to be present on Windows Server 2012 or 2016: https://build.golang.org/log/6ea21b99c9b8a2be20f9aeaec6c425b84faf1af7 https://build.golang.org/log/2bcf04f1df003577352f4f987a39a59a081094ee Updates golang/go#17513 Updates golang/go#20073 Change-Id: I72820704b4cb16bb1720b7f6a9f2e10028c71334 Reviewed-on: https://go-review.googlesource.com/41395 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-on: https://go-review.googlesource.com/70845 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
-rw-r--r--src/net/net_windows_test.go15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/net/net_windows_test.go b/src/net/net_windows_test.go
index 38edbc29ab..a8daa3f7db 100644
--- a/src/net/net_windows_test.go
+++ b/src/net/net_windows_test.go
@@ -503,21 +503,26 @@ func TestInterfaceAddrsWithNetsh(t *testing.T) {
}
}
-func getmacSpeaksEnglish(t *testing.T) bool {
+// check that getmac exists as a powershell command, and that it
+// speaks English.
+func checkGetmac(t *testing.T) {
out, err := runCmd("getmac", "/?")
if err != nil {
+ if strings.Contains(err.Error(), "term 'getmac' is not recognized as the name of a cmdlet") {
+ t.Skipf("getmac not available")
+ }
t.Fatal(err)
}
- return bytes.Contains(out, []byte("network adapters on a system"))
+ if !bytes.Contains(out, []byte("network adapters on a system")) {
+ t.Skipf("skipping test on non-English system")
+ }
}
func TestInterfaceHardwareAddrWithGetmac(t *testing.T) {
if isWindowsXP(t) {
t.Skip("Windows XP does not have powershell command")
}
- if !getmacSpeaksEnglish(t) {
- t.Skip("English version of getmac required for this test")
- }
+ checkGetmac(t)
ift, err := Interfaces()
if err != nil {