"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 {
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") {