mirror of
https://github.com/golang/go
synced 2024-11-18 09:04:49 -07:00
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 <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
301bc66a47
commit
cc4b824e53
7
src/runtime/export_aix_test.go
Normal file
7
src/runtime/export_aix_test.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package runtime
|
||||||
|
|
||||||
|
var Fcntl = syscall_fcntl1
|
17
src/runtime/nbpipe_fcntl_aix_test.go
Normal file
17
src/runtime/nbpipe_fcntl_aix_test.go
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package runtime_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"runtime"
|
||||||
|
"syscall"
|
||||||
|
)
|
||||||
|
|
||||||
|
// We can't call syscall.Syscall on AIX. Therefore, fcntl is exported from the
|
||||||
|
// runtime in export_aix_test.go.
|
||||||
|
func fcntl(fd uintptr, cmd int, arg uintptr) (uintptr, syscall.Errno) {
|
||||||
|
res, errno := runtime.Fcntl(fd, uintptr(cmd), arg)
|
||||||
|
return res, syscall.Errno(errno)
|
||||||
|
}
|
14
src/runtime/nbpipe_fcntl_unix_test.go
Normal file
14
src/runtime/nbpipe_fcntl_unix_test.go
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
// Copyright 2019 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
// +build darwin dragonfly freebsd linux netbsd openbsd
|
||||||
|
|
||||||
|
package runtime_test
|
||||||
|
|
||||||
|
import "syscall"
|
||||||
|
|
||||||
|
func fcntl(fd uintptr, cmd int, arg uintptr) (uintptr, syscall.Errno) {
|
||||||
|
res, _, err := syscall.Syscall(syscall.SYS_FCNTL, fd, uintptr(cmd), arg)
|
||||||
|
return res, err
|
||||||
|
}
|
@ -49,7 +49,7 @@ func checkIsPipe(t *testing.T, r, w int32) {
|
|||||||
|
|
||||||
func checkNonblocking(t *testing.T, fd int32, name string) {
|
func checkNonblocking(t *testing.T, fd int32, name string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
flags, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_GETFL, 0)
|
flags, errno := fcntl(uintptr(fd), syscall.F_GETFL, 0)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
t.Errorf("fcntl(%s, F_GETFL) failed: %v", name, syscall.Errno(errno))
|
t.Errorf("fcntl(%s, F_GETFL) failed: %v", name, syscall.Errno(errno))
|
||||||
} else if flags&syscall.O_NONBLOCK == 0 {
|
} else if flags&syscall.O_NONBLOCK == 0 {
|
||||||
@ -59,7 +59,7 @@ func checkNonblocking(t *testing.T, fd int32, name string) {
|
|||||||
|
|
||||||
func checkCloseonexec(t *testing.T, fd int32, name string) {
|
func checkCloseonexec(t *testing.T, fd int32, name string) {
|
||||||
t.Helper()
|
t.Helper()
|
||||||
flags, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_GETFD, 0)
|
flags, errno := fcntl(uintptr(fd), syscall.F_GETFD, 0)
|
||||||
if errno != 0 {
|
if errno != 0 {
|
||||||
t.Errorf("fcntl(%s, F_GETFD) failed: %v", name, syscall.Errno(errno))
|
t.Errorf("fcntl(%s, F_GETFD) failed: %v", name, syscall.Errno(errno))
|
||||||
} else if flags&syscall.FD_CLOEXEC == 0 {
|
} else if flags&syscall.FD_CLOEXEC == 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user