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>
// 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))
package os
import (
+ "runtime"
"syscall"
"time"
)
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}
}
}
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)
// 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
// 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