Skip to content

Commit cc4b824

Browse files
Helflymianlancetaylor
authored andcommitted
runtime: fix nbpipe_test for AIX
Fcntl can't be called using syscall.Syscall as it doesn't work on AIX. Moreover, fcntl isn't exported by syscall package. However, it can be accessed by exporting it from runtime package using export_aix_test.go. Change-Id: Ib6af66d9d7eacb9ca0525ebc4cd4c92951735f1a Reviewed-on: https://go-review.googlesource.com/c/go/+/204059 Run-TryBot: Ian Lance Taylor <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
1 parent 301bc66 commit cc4b824

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

src/runtime/export_aix_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package runtime
6+
7+
var Fcntl = syscall_fcntl1

src/runtime/nbpipe_fcntl_aix_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package runtime_test
6+
7+
import (
8+
"runtime"
9+
"syscall"
10+
)
11+
12+
// We can't call syscall.Syscall on AIX. Therefore, fcntl is exported from the
13+
// runtime in export_aix_test.go.
14+
func fcntl(fd uintptr, cmd int, arg uintptr) (uintptr, syscall.Errno) {
15+
res, errno := runtime.Fcntl(fd, uintptr(cmd), arg)
16+
return res, syscall.Errno(errno)
17+
}

src/runtime/nbpipe_fcntl_unix_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Copyright 2019 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build darwin dragonfly freebsd linux netbsd openbsd
6+
7+
package runtime_test
8+
9+
import "syscall"
10+
11+
func fcntl(fd uintptr, cmd int, arg uintptr) (uintptr, syscall.Errno) {
12+
res, _, err := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), arg)
13+
return res, err
14+
}

src/runtime/nbpipe_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func checkIsPipe(t *testing.T, r, w int32) {
4949

5050
func checkNonblocking(t *testing.T, fd int32, name string) {
5151
t.Helper()
52-
flags, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_GETFL, 0)
52+
flags, errno := fcntl(uintptr(fd), syscall.F_GETFL, 0)
5353
if errno != 0 {
5454
t.Errorf("fcntl(%s, F_GETFL) failed: %v", name, syscall.Errno(errno))
5555
} else if flags&syscall.O_NONBLOCK == 0 {
@@ -59,7 +59,7 @@ func checkNonblocking(t *testing.T, fd int32, name string) {
5959

6060
func checkCloseonexec(t *testing.T, fd int32, name string) {
6161
t.Helper()
62-
flags, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_GETFD, 0)
62+
flags, errno := fcntl(uintptr(fd), syscall.F_GETFD, 0)
6363
if errno != 0 {
6464
t.Errorf("fcntl(%s, F_GETFD) failed: %v", name, syscall.Errno(errno))
6565
} else if flags&syscall.FD_CLOEXEC == 0 {

0 commit comments

Comments
 (0)