| 1 |
// Copyright 2022 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 |
//go:build aix || darwin |
| 6 |
|
| 7 |
package runtime_test |
| 8 |
|
| 9 |
import ( |
| 10 |
"runtime" |
| 11 |
"syscall" |
| 12 |
"testing" |
| 13 |
) |
| 14 |
|
| 15 |
func TestSetNonblock(t *testing.T) { |
| 16 |
t.Parallel() |
| 17 |
|
| 18 |
r, w, errno := runtime.Pipe() |
| 19 |
if errno != 0 { |
| 20 |
t.Fatal(syscall.Errno(errno)) |
| 21 |
} |
| 22 |
defer func() { |
| 23 |
runtime.Close(r) |
| 24 |
runtime.Close(w) |
| 25 |
}() |
| 26 |
|
| 27 |
checkIsPipe(t, r, w) |
| 28 |
|
| 29 |
runtime.SetNonblock(r) |
| 30 |
runtime.SetNonblock(w) |
| 31 |
checkNonblocking(t, r, "reader") |
| 32 |
checkNonblocking(t, w, "writer") |
| 33 |
|
| 34 |
runtime.Closeonexec(r) |
| 35 |
runtime.Closeonexec(w) |
| 36 |
checkCloseonexec(t, r, "reader") |
| 37 |
checkCloseonexec(t, w, "writer") |
| 38 |
} |