mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
net: disable Windows netsh tests when netsh won't run
On my Surface Pro X running the insider preview, running "netsh help" from Powershell started from the task bar works. But running "powershell" at a cmd.exe prompt and then running "netsh help" produces missing DLL errors. These aren't our fault, so just skip the netsh-based tests if this happens. Change-Id: I13a17e01143d823d3b5242d827db056bd253e3e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/293849 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
This commit is contained in:
parent
40765ffa95
commit
ee7038f6a5
1 changed files with 9 additions and 8 deletions
|
|
@ -204,12 +204,17 @@ func runCmd(args ...string) ([]byte, error) {
|
||||||
return removeUTF8BOM(out), nil
|
return removeUTF8BOM(out), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func netshSpeaksEnglish(t *testing.T) bool {
|
func checkNetsh(t *testing.T) {
|
||||||
out, err := runCmd("netsh", "help")
|
out, err := runCmd("netsh", "help")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
return bytes.Contains(out, []byte("The following commands are available:"))
|
if bytes.Contains(out, []byte("The following helper DLL cannot be loaded")) {
|
||||||
|
t.Skipf("powershell failure:\n%s", err)
|
||||||
|
}
|
||||||
|
if !bytes.Contains(out, []byte("The following commands are available:")) {
|
||||||
|
t.Skipf("powershell does not speak English:\n%s", out)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func netshInterfaceIPShowInterface(ipver string, ifaces map[string]bool) error {
|
func netshInterfaceIPShowInterface(ipver string, ifaces map[string]bool) error {
|
||||||
|
|
@ -256,9 +261,7 @@ func netshInterfaceIPShowInterface(ipver string, ifaces map[string]bool) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInterfacesWithNetsh(t *testing.T) {
|
func TestInterfacesWithNetsh(t *testing.T) {
|
||||||
if !netshSpeaksEnglish(t) {
|
checkNetsh(t)
|
||||||
t.Skip("English version of netsh required for this test")
|
|
||||||
}
|
|
||||||
|
|
||||||
toString := func(name string, isup bool) string {
|
toString := func(name string, isup bool) string {
|
||||||
if isup {
|
if isup {
|
||||||
|
|
@ -427,9 +430,7 @@ func netshInterfaceIPv6ShowAddress(name string, netshOutput []byte) []string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestInterfaceAddrsWithNetsh(t *testing.T) {
|
func TestInterfaceAddrsWithNetsh(t *testing.T) {
|
||||||
if !netshSpeaksEnglish(t) {
|
checkNetsh(t)
|
||||||
t.Skip("English version of netsh required for this test")
|
|
||||||
}
|
|
||||||
|
|
||||||
outIPV4, err := runCmd("netsh", "interface", "ipv4", "show", "address")
|
outIPV4, err := runCmd("netsh", "interface", "ipv4", "show", "address")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue