]> Cypherpunks repositories - gostls13.git/commitdiff
os: fix tests for AIX
authorClément Chigot <clement.chigot@atos.net>
Thu, 25 Oct 2018 08:02:37 +0000 (10:02 +0200)
committerBrad Fitzpatrick <bradfitz@golang.org>
Fri, 26 Oct 2018 14:46:35 +0000 (14:46 +0000)
This commits fixes tests for AIX inside os package.

"hostname" command on AIX returns "name.domain" and not only "name".
So, "hostname -s" must be called.

Change-Id: I75e193bcb6ad607ce54ad99aabbed9839012f707
Reviewed-on: https://go-review.googlesource.com/c/144537
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/os/executable_test.go
src/os/file_posix.go
src/os/os_test.go
src/os/sticky_bsd.go
src/os/sticky_notbsd.go

index 4a9a8837be415a4faa30f24a53c20c973cd861e7..d513c8760ee6d7b436e9dfc35726409988f5b38d 100644 (file)
@@ -36,8 +36,8 @@ func TestExecutable(t *testing.T) {
        // forge argv[0] for child, so that we can verify we could correctly
        // get real path of the executable without influenced by argv[0].
        cmd.Args = []string{"-", "-test.run=XXXX"}
-       if runtime.GOOS == "openbsd" {
-               // OpenBSD relies on argv[0]
+       if runtime.GOOS == "openbsd" || runtime.GOOS == "aix" {
+               // OpenBSD and AIX rely on argv[0]
                cmd.Args[0] = fn
        }
        cmd.Env = append(os.Environ(), fmt.Sprintf("%s=1", executable_EnvVar))
index 544d0ad55d4d901276d69522e7a7be277f722a6c..1c0de5c3a163e1cdbabff4ec86debc4635b8a456 100644 (file)
@@ -7,6 +7,7 @@
 package os
 
 import (
+       "runtime"
        "syscall"
        "time"
 )
@@ -19,6 +20,10 @@ func Readlink(name string) (string, error) {
        for len := 128; ; len *= 2 {
                b := make([]byte, len)
                n, e := fixCount(syscall.Readlink(fixLongPath(name), b))
+               // buffer too small
+               if runtime.GOOS == "aix" && e == syscall.ERANGE {
+                       continue
+               }
                if e != nil {
                        return "", &PathError{"readlink", name, e}
                }
index 876058e73ad9abe3f3538d7b9bc904c44c47b3fc..9f09c9f639816e1b611fa0deece284b910a1da4e 100644 (file)
@@ -1493,7 +1493,11 @@ func runBinHostname(t *testing.T) string {
        }
        defer r.Close()
        const path = "/bin/hostname"
-       p, err := StartProcess(path, []string{"hostname"}, &ProcAttr{Files: []*File{nil, w, Stderr}})
+       argv := []string{"hostname"}
+       if runtime.GOOS == "aix" {
+               argv = []string{"hostname", "-s"}
+       }
+       p, err := StartProcess(path, argv, &ProcAttr{Files: []*File{nil, w, Stderr}})
        if err != nil {
                if _, err := Stat(path); IsNotExist(err) {
                        t.Skipf("skipping test; test requires %s but it does not exist", path)
index 6b54c758c70a1833eb898e1d85d556378e61ff6a..ae2744f81756bed1d41cd0556afa426739c65ca8 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-// +build darwin dragonfly freebsd netbsd openbsd solaris
+// +build aix darwin dragonfly freebsd netbsd openbsd solaris
 
 package os
 
index 834e79b0b5901f74d16b0e9e386f80cc0d0e9e2f..edb5f69bf0580ce8409eb9430d2261feddf092c9 100644 (file)
@@ -2,6 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
+// +build !aix
 // +build !darwin
 // +build !dragonfly
 // +build !freebsd