libgo patch committed: use hostname -s on AIX

Ian Lance Taylor iant@golang.org
Sat Dec 16 01:50:00 GMT 2017


This patch by Tony Reix changes the libgo tests for the os package on
AIX to use hostname -s, not plain hostname.  Bootstrapped and ran Go
tests on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
-------------- next part --------------
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE	(revision 255737)
+++ gcc/go/gofrontend/MERGE	(working copy)
@@ -1,4 +1,4 @@
-d1f90c9b77baca5c33a398ab844fb4440c6a5ee7
+97eb3f61cf1c2cc01b9db6ed20e39bc04573c207
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: libgo/go/os/os_test.go
===================================================================
--- libgo/go/os/os_test.go	(revision 255666)
+++ libgo/go/os/os_test.go	(working copy)
@@ -1440,7 +1440,7 @@ func TestOpenNoName(t *testing.T) {
 	}
 }
 
-func runBinHostname(t *testing.T) string {
+func runBinHostname(t *testing.T, argv []string) string {
 	// Run /bin/hostname and collect output.
 	r, w, err := Pipe()
 	if err != nil {
@@ -1448,7 +1448,7 @@ 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}})
+	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)
@@ -1514,7 +1514,13 @@ func TestHostname(t *testing.T) {
 	if err != nil {
 		t.Fatalf("%v", err)
 	}
-	want := runBinHostname(t)
+
+	var want string
+	if runtime.GOOS == "aix" {
+		want = runBinHostname(t, []string{"hostname", "-s"})
+	} else {
+		want = runBinHostname(t, []string{"hostname"})
+	}
 	if hostname != want {
 		i := strings.Index(hostname, ".")
 		if i < 0 || hostname[0:i] != want {


More information about the Gcc-patches mailing list