diff options
Diffstat (limited to 'libgo/go/net/platform_test.go')
-rw-r--r-- | libgo/go/net/platform_test.go | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/libgo/go/net/platform_test.go b/libgo/go/net/platform_test.go index 7e9ad70..10f55c9 100644 --- a/libgo/go/net/platform_test.go +++ b/libgo/go/net/platform_test.go @@ -14,6 +14,23 @@ import ( "testing" ) +var unixEnabledOnAIX bool + +func init() { + if runtime.GOOS == "aix" { + // Unix network isn't properly working on AIX 7.2 with + // Technical Level < 2. + // The information is retrieved only once in this init() + // instead of everytime testableNetwork is called. + out, _ := exec.Command("oslevel", "-s").Output() + if len(out) >= len("7200-XX-ZZ-YYMM") { // AIX 7.2, Tech Level XX, Service Pack ZZ, date YYMM + aixVer := string(out[:4]) + tl, _ := strconv.Atoi(string(out[5:7])) + unixEnabledOnAIX = aixVer > "7200" || (aixVer == "7200" && tl >= 2) + } + } +} + // testableNetwork reports whether network is testable on the current // platform configuration. func testableNetwork(network string) bool { @@ -38,15 +55,7 @@ func testableNetwork(network string) bool { case "android", "nacl", "plan9", "windows": return false case "aix": - // Unix network isn't properly working on AIX 7.2 with Technical Level < 2 - out, err := exec.Command("oslevel", "-s").Output() - if err != nil { - return false - } - if tl, err := strconv.Atoi(string(out[5:7])); err != nil || tl < 2 { - return false - } - return true + return unixEnabledOnAIX } // iOS does not support unix, unixgram. if runtime.GOOS == "darwin" && (runtime.GOARCH == "arm" || runtime.GOARCH == "arm64") { |