Skip to content

Commit 7e2cd1d

Browse files
bradfitzrsc
authored andcommitted
[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 #17513 Updates #20073 Change-Id: I72820704b4cb16bb1720b7f6a9f2e10028c71334 Reviewed-on: https://go-review.googlesource.com/41395 Reviewed-by: Alex Brainman <[email protected]> Reviewed-on: https://go-review.googlesource.com/70845 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]>
1 parent f5bcb9b commit 7e2cd1d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/net/net_windows_test.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -503,21 +503,26 @@ func TestInterfaceAddrsWithNetsh(t *testing.T) {
503503
}
504504
}
505505

506-
func getmacSpeaksEnglish(t *testing.T) bool {
506+
// check that getmac exists as a powershell command, and that it
507+
// speaks English.
508+
func checkGetmac(t *testing.T) {
507509
out, err := runCmd("getmac", "/?")
508510
if err != nil {
511+
if strings.Contains(err.Error(), "term 'getmac' is not recognized as the name of a cmdlet") {
512+
t.Skipf("getmac not available")
513+
}
509514
t.Fatal(err)
510515
}
511-
return bytes.Contains(out, []byte("network adapters on a system"))
516+
if !bytes.Contains(out, []byte("network adapters on a system")) {
517+
t.Skipf("skipping test on non-English system")
518+
}
512519
}
513520

514521
func TestInterfaceHardwareAddrWithGetmac(t *testing.T) {
515522
if isWindowsXP(t) {
516523
t.Skip("Windows XP does not have powershell command")
517524
}
518-
if !getmacSpeaksEnglish(t) {
519-
t.Skip("English version of getmac required for this test")
520-
}
525+
checkGetmac(t)
521526

522527
ift, err := Interfaces()
523528
if err != nil {

0 commit comments

Comments
 (0)